@ -4,7 +4,9 @@ import com.lzbi.bi.domain.*;
import com.lzbi.common.config.TargetModelConfig ;
import com.lzbi.common.utils.bean.BeanUtils ;
import com.lzbi.draft.domain.DcBusiTargetDraftDay ;
import com.lzbi.draft.domain.DcBusiTargetDraftMonth ;
import com.lzbi.draft.mapper.DcBusiTargetDraftDayMapper ;
import com.lzbi.draft.mapper.DcBusiTargetDraftMonthMapper ;
import org.apache.commons.collections4.CollectionUtils ;
import org.apache.commons.lang3.ObjectUtils ;
import org.springframework.beans.factory.annotation.Autowired ;
@ -15,6 +17,7 @@ import java.math.BigDecimal;
import java.util.ArrayList ;
import java.util.List ;
import java.util.Map ;
import java.util.concurrent.atomic.AtomicReference ;
import java.util.stream.Collectors ;
/ * *
@ -31,19 +34,20 @@ public class DcBusiDataScreenNewService {
@Resource
private DcBusiTargetDraftDayMapper dcBusiTargetDraftDayMapper ;
@Resource
private DcBusiTargetDraftMonthMapper dcBusiTargetDraftMonthMapper ;
public List < UserIOverViewVO > getUserOverview ( DcBusDataScreenNewReq dcBusDataScreenNewReq ) {
List < UserIOverViewVO > list = new ArrayList < > ( ) ;
// list.add(new UserIOverViewVO("热源1", BigDecimal.valueOf(10000), BigDecimal.valueOf(8000)));
// list.add(new UserIOverViewVO("热源2", BigDecimal.valueOf(10000), BigDecimal.valueOf(8000)));
// list.add(new UserIOverViewVO("热源3", BigDecimal.valueOf(10000), BigDecimal.valueOf(8000)));
// list.add(new UserIOverViewVO("热源4", BigDecimal.valueOf(10000), BigDecimal.valueOf(8000)));
DcBusiTargetDraftDay params = new DcBusiTargetDraftDay ( ) ;
BeanUtils . copyBeanProp ( params , dcBusDataScreenNewReq ) ;
String yearMonthDay = dcBusDataScreenNewReq . getYearMonthDay ( ) ;
String [ ] yearMonthDayArr = yearMonthDay . split ( "-" ) ;
if ( yearMonthDayArr . length > 1 ) {
params . setCountYear ( yearMonthDayArr [ 0 ] ) ;
params . setCountMonth ( yearMonthDayArr [ 1 ] ) ;
params . setTargetCode ( targetModelConfig . getUser ( ) ) ;
}
params . setTargetModelCode ( targetModelConfig . getUser ( ) ) ;
List < DcBusiTargetDraftDay > dcBusiTargetDraftDayList = dcBusiTargetDraftDayMapper . selectDcBusiTargetDraftDayList ( params ) ;
if ( CollectionUtils . isNotEmpty ( dcBusiTargetDraftDayList ) ) {
Map < Object , List < DcBusiTargetDraftDay > > map ;
@ -52,7 +56,6 @@ public class DcBusiDataScreenNewService {
} else {
map = dcBusiTargetDraftDayList . stream ( ) . collect ( Collectors . groupingBy ( DcBusiTargetDraftDay : : getAssetCode ) ) ;
}
Class < DcBusiTargetDraftDay > dcBusiTargetDraftMonthClass = DcBusiTargetDraftDay . class ;
map . forEach ( ( key , value ) - > {
UserIOverViewVO userIOverViewVO = new UserIOverViewVO ( ) ;
if ( ObjectUtils . isEmpty ( dcBusDataScreenNewReq . getOrgId ( ) ) ) {
@ -76,11 +79,17 @@ public class DcBusiDataScreenNewService {
public ProvideAnswerWaterAverageTemperatureVO getProvideAnswerWaterAverageTemperature ( DcBusDataScreenNewReq dcBusDataScreenNewReq ) {
ProvideAnswerWaterAverageTemperatureVO provideAnswerWaterAverageTemperatureVO = new ProvideAnswerWaterAverageTemperatureVO ( ) ;
ProvideAnswerWaterAverageTemperatureReq params = new ProvideAnswerWaterAverageTemperatureReq ( ) ;
params . setCompanyId ( dcBusDataScreenNewReq . getCompanyId ( ) ) ;
String yearMonthDay = dcBusDataScreenNewReq . getYearMonthDay ( ) ;
String [ ] yearMonthDayArr = yearMonthDay . split ( "-" ) ;
dcBusDataScreenNewReq . setYear ( yearMonthDayArr [ 0 ] ) ;
dcBusDataScreenNewReq . setMonth ( yearMonthDayArr [ 1 ] ) ;
List < ProvideAnswerWaterAverageTemperatureDTO > provideAnswerWaterAverageTemperatureDTOS = dcBusiTargetDraftDayMapper . selectProvideAnswerWaterAverageTemperatureList ( dcBusDataScreenNewReq ) ;
if ( yearMonthDayArr . length > 1 ) {
params . setYear ( yearMonthDayArr [ 0 ] ) ;
params . setMonth ( yearMonthDayArr [ 1 ] ) ;
}
params . setProvideWaterAverageTemperature ( targetModelConfig . getProvideWaterAverageTemperature ( ) ) ;
params . setAnswerWaterAverageTemperature ( targetModelConfig . getAnswerWaterAverageTemperature ( ) ) ;
List < ProvideAnswerWaterAverageTemperatureDTO > provideAnswerWaterAverageTemperatureDTOS = dcBusiTargetDraftDayMapper . selectProvideAnswerWaterAverageTemperatureList ( params ) ;
if ( CollectionUtils . isNotEmpty ( provideAnswerWaterAverageTemperatureDTOS ) ) {
List < String > xArr = new ArrayList < > ( ) ;
List < BigDecimal > yArr1 = new ArrayList < > ( ) ;
@ -99,56 +108,169 @@ public class DcBusiDataScreenNewService {
public List < BoilerStatisticsVO > getBoilerStatistics ( DcBusDataScreenNewReq dcBusDataScreenNewReq ) {
List < BoilerStatisticsVO > list = new ArrayList < > ( ) ;
list . add ( new BoilerStatisticsVO ( "热源1" , BigDecimal . valueOf ( 248776 ) ) ) ;
list . add ( new BoilerStatisticsVO ( "热源2" , BigDecimal . valueOf ( 248776 ) ) ) ;
list . add ( new BoilerStatisticsVO ( "热源3" , BigDecimal . valueOf ( 248776 ) ) ) ;
// list.add(new BoilerStatisticsVO("热源1", BigDecimal.valueOf(248776)));
// list.add(new BoilerStatisticsVO("热源2", BigDecimal.valueOf(248776)));
// list.add(new BoilerStatisticsVO("热源3", BigDecimal.valueOf(248776)));
DcBusiTargetDraftMonth params = new DcBusiTargetDraftMonth ( ) ;
BeanUtils . copyBeanProp ( params , dcBusDataScreenNewReq ) ;
String yearMonthDay = dcBusDataScreenNewReq . getYearMonthDay ( ) ;
String [ ] yearMonthDayArr = yearMonthDay . split ( "-" ) ;
if ( yearMonthDayArr . length > 1 ) {
params . setCountYear ( yearMonthDayArr [ 0 ] ) ;
params . setCountMonth ( yearMonthDayArr [ 1 ] ) ;
}
params . setTargetModelCode ( targetModelConfig . getBoiler ( ) ) ;
List < DcBusiTargetDraftMonth > dcBusiTargetDraftMonths = dcBusiTargetDraftMonthMapper . selectDcBusiTargetDraftMonthList ( params ) ;
if ( CollectionUtils . isNotEmpty ( dcBusiTargetDraftMonths ) ) {
Map < Object , List < DcBusiTargetDraftMonth > > map ;
if ( ObjectUtils . isEmpty ( dcBusDataScreenNewReq . getOrgId ( ) ) ) {
map = dcBusiTargetDraftMonths . stream ( ) . collect ( Collectors . groupingBy ( DcBusiTargetDraftMonth : : getOrgId ) ) ;
} else {
map = dcBusiTargetDraftMonths . stream ( ) . collect ( Collectors . groupingBy ( DcBusiTargetDraftMonth : : getAssetCode ) ) ;
}
map . forEach ( ( key , value ) - > {
BoilerStatisticsVO boilerStatisticsVO = new BoilerStatisticsVO ( ) ;
if ( ObjectUtils . isEmpty ( dcBusDataScreenNewReq . getOrgId ( ) ) ) {
boilerStatisticsVO . setLabel ( value . get ( 0 ) . getOrgName ( ) ) ;
} else {
boilerStatisticsVO . setLabel ( value . get ( 0 ) . getAssetName ( ) ) ;
}
BigDecimal sum = new BigDecimal ( 0 ) ;
for ( int i = 0 , len = value . size ( ) ; i < len ; i + + ) {
sum = sum . add ( value . get ( i ) . getValOriginal ( ) ) ;
}
boilerStatisticsVO . setValue ( sum ) ;
list . add ( boilerStatisticsVO ) ;
} ) ;
}
return list ;
}
public List < ConsumesStatisticsVO > getConsumesStatistics ( DcBusDataScreenNewReq dcBusDataScreenNewReq ) {
List < ConsumesStatisticsVO > list = new ArrayList < > ( ) ;
list . add ( new ConsumesStatisticsVO ( "热源1" , BigDecimal . valueOf ( 458 . 14 ) , BigDecimal . valueOf ( 1 . 25 ) , BigDecimal . valueOf ( 37 . 57 ) ) ) ;
list . add ( new ConsumesStatisticsVO ( "热源2" , BigDecimal . valueOf ( 458 . 14 ) , BigDecimal . valueOf ( 1 . 25 ) , BigDecimal . valueOf ( 37 . 57 ) ) ) ;
list . add ( new ConsumesStatisticsVO ( "热源3" , BigDecimal . valueOf ( 458 . 14 ) , BigDecimal . valueOf ( 1 . 25 ) , BigDecimal . valueOf ( 37 . 57 ) ) ) ;
list . add ( new ConsumesStatisticsVO ( "热源4" , BigDecimal . valueOf ( 458 . 14 ) , BigDecimal . valueOf ( 1 . 25 ) , BigDecimal . valueOf ( 37 . 57 ) ) ) ;
list . add ( new ConsumesStatisticsVO ( "热源5" , BigDecimal . valueOf ( 458 . 14 ) , BigDecimal . valueOf ( 1 . 25 ) , BigDecimal . valueOf ( 37 . 57 ) ) ) ;
return list ;
ConsumesStatisticsDTO consumesStatisticsDTO = new ConsumesStatisticsDTO ( ) ;
consumesStatisticsDTO . setCompanyId ( dcBusDataScreenNewReq . getCompanyId ( ) ) ;
String yearMonthDay = dcBusDataScreenNewReq . getYearMonthDay ( ) ;
String [ ] yearMonthDayArr = yearMonthDay . split ( "-" ) ;
if ( yearMonthDayArr . length > 1 ) {
consumesStatisticsDTO . setYear ( yearMonthDayArr [ 0 ] ) ;
consumesStatisticsDTO . setMonth ( yearMonthDayArr [ 1 ] ) ;
}
consumesStatisticsDTO . setElectricityConsumes ( targetModelConfig . getElectricityConsumes ( ) ) ;
consumesStatisticsDTO . setWaterConsumes ( targetModelConfig . getWaterConsumes ( ) ) ;
consumesStatisticsDTO . setCoalConsumes ( targetModelConfig . getCoalConsumes ( ) ) ;
return dcBusiTargetDraftDayMapper . getConsumesStatistics ( consumesStatisticsDTO ) ;
}
public List < CalorificValueVO > getCalorificValue ( DcBusDataScreenNewReq dcBusDataScreenNewReq ) {
List < CalorificValueVO > list = new ArrayList < > ( ) ;
list . add ( new CalorificValueVO ( "热源1" , BigDecimal . valueOf ( 7897 ) , 17 ) ) ;
list . add ( new CalorificValueVO ( "热源2" , BigDecimal . valueOf ( 9766 ) , 21 ) ) ;
list . add ( new CalorificValueVO ( "热源3" , BigDecimal . valueOf ( 5571 ) , 12 ) ) ;
list . add ( new CalorificValueVO ( "热源4" , BigDecimal . valueOf ( 7897 ) , 17 ) ) ;
list . add ( new CalorificValueVO ( "热源5" , BigDecimal . valueOf ( 9766 ) , 21 ) ) ;
list . add ( new CalorificValueVO ( "热源6" , BigDecimal . valueOf ( 5571 ) , 12 ) ) ;
DcBusiTargetDraftDay params = new DcBusiTargetDraftDay ( ) ;
BeanUtils . copyBeanProp ( params , dcBusDataScreenNewReq ) ;
String yearMonthDay = dcBusDataScreenNewReq . getYearMonthDay ( ) ;
String [ ] yearMonthDayArr = yearMonthDay . split ( "-" ) ;
if ( yearMonthDayArr . length > 1 ) {
params . setCountYear ( yearMonthDayArr [ 0 ] ) ;
params . setCountMonth ( yearMonthDayArr [ 1 ] ) ;
}
params . setTargetModelCode ( targetModelConfig . getCalorific ( ) ) ;
List < DcBusiTargetDraftDay > dcBusiTargetDraftDayList = dcBusiTargetDraftDayMapper . selectDcBusiTargetDraftDayList ( params ) ;
if ( CollectionUtils . isNotEmpty ( dcBusiTargetDraftDayList ) ) {
Map < Object , List < DcBusiTargetDraftDay > > map ;
if ( ObjectUtils . isEmpty ( dcBusDataScreenNewReq . getOrgId ( ) ) ) {
map = dcBusiTargetDraftDayList . stream ( ) . collect ( Collectors . groupingBy ( DcBusiTargetDraftDay : : getOrgId ) ) ;
} else {
map = dcBusiTargetDraftDayList . stream ( ) . collect ( Collectors . groupingBy ( DcBusiTargetDraftDay : : getAssetCode ) ) ;
}
AtomicReference < BigDecimal > total = new AtomicReference < > ( new BigDecimal ( 0 ) ) ;
map . forEach ( ( key , value ) - > {
CalorificValueVO calorificValueVO = new CalorificValueVO ( ) ;
if ( ObjectUtils . isEmpty ( dcBusDataScreenNewReq . getOrgId ( ) ) ) {
calorificValueVO . setLabel ( value . get ( 0 ) . getOrgName ( ) ) ;
} else {
calorificValueVO . setLabel ( value . get ( 0 ) . getAssetName ( ) ) ;
}
BigDecimal sum = new BigDecimal ( 0 ) ;
for ( int i = 0 , len = value . size ( ) ; i < len ; i + + ) {
sum = sum . add ( value . get ( i ) . getValAccumulative ( ) ) ;
total . set ( total . get ( ) . add ( value . get ( i ) . getValAccumulative ( ) ) ) ;
}
calorificValueVO . setValue ( sum ) ;
list . add ( calorificValueVO ) ;
} ) ;
BigDecimal percentageSum = BigDecimal . valueOf ( 100 ) ;
for ( int i = 0 , len = list . size ( ) ; i < len ; i + + ) {
CalorificValueVO item = list . get ( i ) ;
BigDecimal percentage = item . getValue ( ) . divide ( total . get ( ) , 2 , BigDecimal . ROUND_HALF_UP ) . multiply ( BigDecimal . valueOf ( 100 ) ) ;
if ( i < len - 1 ) {
percentageSum = percentageSum . subtract ( percentage ) ;
item . setPercentage ( percentage . intValue ( ) ) ;
} else {
item . setPercentage ( percentageSum . intValue ( ) ) ;
}
}
}
return list ;
}
public HeatSuppliedVO getHeatSupplied ( DcBusDataScreenNewReq dcBusDataScreenNewReq ) {
HeatSuppliedVO heatSuppliedVO = new HeatSuppliedVO ( ) ;
List < String > labelArr = new ArrayList < > ( ) ;
DcBusiTargetDraftDay params = new DcBusiTargetDraftDay ( ) ;
BeanUtils . copyBeanProp ( params , dcBusDataScreenNewReq ) ;
String yearMonthDay = dcBusDataScreenNewReq . getYearMonthDay ( ) ;
String [ ] yearMonthDayArr = yearMonthDay . split ( "-" ) ;
if ( yearMonthDayArr . length > 1 ) {
params . setCountYear ( yearMonthDayArr [ 0 ] ) ;
params . setCountMonth ( yearMonthDayArr [ 1 ] ) ;
}
params . setTargetModelCode ( targetModelConfig . getHeatSupplied ( ) ) ;
List < DcBusiTargetDraftDay > dcBusiTargetDraftDayList = dcBusiTargetDraftDayMapper . selectDcBusiTargetDraftDayList ( params ) ;
if ( CollectionUtils . isNotEmpty ( dcBusiTargetDraftDayList ) ) {
Map < Object , List < DcBusiTargetDraftDay > > map ;
if ( ObjectUtils . isEmpty ( dcBusDataScreenNewReq . getOrgId ( ) ) ) {
map = dcBusiTargetDraftDayList . stream ( ) . collect ( Collectors . groupingBy ( DcBusiTargetDraftDay : : getOrgId ) ) ;
} else {
map = dcBusiTargetDraftDayList . stream ( ) . collect ( Collectors . groupingBy ( DcBusiTargetDraftDay : : getAssetCode ) ) ;
}
List < HeatSuppliedVO . Label > labelArray = new ArrayList < > ( ) ;
List < BigDecimal > valueArr = new ArrayList < > ( ) ;
labelArr . add ( "热源1" ) ;
labelArr . add ( "热源2" ) ;
labelArr . add ( "热源3" ) ;
labelArr . add ( "热源4" ) ;
labelArr . add ( "热源5" ) ;
labelArr . add ( "热源6" ) ;
valueArr . add ( BigDecimal . valueOf ( 300 ) ) ;
valueArr . add ( BigDecimal . valueOf ( 500 ) ) ;
valueArr . add ( BigDecimal . valueOf ( 300 ) ) ;
valueArr . add ( BigDecimal . valueOf ( 100 ) ) ;
valueArr . add ( BigDecimal . valueOf ( 500 ) ) ;
valueArr . add ( BigDecimal . valueOf ( 100 ) ) ;
heatSuppliedVO . setLabelArr ( labelArr ) ;
final BigDecimal [ ] max = { new BigDecimal ( 0 ) } ;
map . forEach ( ( key , value ) - > {
HeatSuppliedVO . Label label = new HeatSuppliedVO . Label ( ) ;
if ( ObjectUtils . isEmpty ( dcBusDataScreenNewReq . getOrgId ( ) ) ) {
label . setName ( value . get ( 0 ) . getOrgName ( ) ) ;
} else {
label . setName ( value . get ( 0 ) . getAssetName ( ) ) ;
}
BigDecimal sum = new BigDecimal ( 0 ) ;
for ( int i = 0 , len = value . size ( ) ; i < len ; i + + ) {
sum = sum . add ( value . get ( i ) . getValAccumulative ( ) ) ;
}
valueArr . add ( sum ) ;
if ( max [ 0 ] . compareTo ( sum ) < 0 ) {
max [ 0 ] = sum ;
}
labelArray . add ( label ) ;
} ) ;
labelArray . stream ( ) . forEach ( label - > label . setMax ( max [ 0 ] ) ) ;
heatSuppliedVO . setLabelArr ( labelArray ) ;
heatSuppliedVO . setValueArr ( valueArr ) ;
}
return heatSuppliedVO ;
}
public CorporateStatisticsVO getCorporateStatistics ( DcBusDataScreenNewReq dcBusDataScreenNewReq ) {
CorporateStatisticsVO corporateStatisticsVO = new CorporateStatisticsVO ( ) ;
return new CorporateStatisticsVO ( BigDecimal . valueOf ( 3820 ) , BigDecimal . valueOf ( 3820 ) , BigDecimal . valueOf ( 3820 ) , BigDecimal . valueOf ( 3820 ) ) ;
CorporateStatisticsDTO corporateStatisticsDTO = new CorporateStatisticsDTO ( ) ;
corporateStatisticsDTO . setCompanyId ( dcBusDataScreenNewReq . getCompanyId ( ) ) ;
String yearMonthDay = dcBusDataScreenNewReq . getYearMonthDay ( ) ;
String [ ] yearMonthDayArr = yearMonthDay . split ( "-" ) ;
if ( yearMonthDayArr . length > 1 ) {
corporateStatisticsDTO . setYear ( yearMonthDayArr [ 0 ] ) ;
corporateStatisticsDTO . setMonth ( yearMonthDayArr [ 1 ] ) ;
}
corporateStatisticsDTO . setAcreage ( targetModelConfig . getAcreage ( ) ) ;
corporateStatisticsDTO . setOutputOfPlant ( targetModelConfig . getOutputOfPlant ( ) ) ;
corporateStatisticsDTO . setCalorificValue ( targetModelConfig . getCalorific ( ) ) ;
corporateStatisticsDTO . setHeatSupplied ( targetModelConfig . getHeatSupplied ( ) ) ;
CorporateStatisticsVO corporateStatisticsVO = dcBusiTargetDraftDayMapper . getCorporateStatistics ( corporateStatisticsDTO ) ;
return corporateStatisticsVO ;
}
}