|
|
|
@ -49,7 +49,7 @@ public class BoardNewServiceImpl implements BoardNewService { |
|
|
|
//获取此租户编码 |
|
|
|
Long realTenantCode = UserContext.getRealTenantCode(); |
|
|
|
//查询这个月的 "总用电": "G01","总用水": "G03","总蒸汽": "G02","总压缩空气": "D_V0000151_1","天然气":"C2"用能情况 |
|
|
|
List<TsKvDTO> tsKvByCodeAndAttrs = tsKvService.findTsKvByCodeAndAttrs("CO_" + realTenantCode, Lists.newArrayList("A29mm", "B1mm", "E3mm", "D2mm","C2mm"), dayTime, endTime, true); |
|
|
|
List<TsKvDTO> tsKvByCodeAndAttrs = tsKvService.findTsKvByCodeAndAttrs("CO_" + realTenantCode, Lists.newArrayList("A29mm", "B2mm", "E3mm", "D2mm","C2mm"), dayTime, endTime, true); |
|
|
|
if(CollectionUtil.isNotEmpty(tsKvByCodeAndAttrs)){ |
|
|
|
for (TsKvDTO tsKvDTO : tsKvByCodeAndAttrs) { |
|
|
|
String code = tsKvDTO.getThingCode(); |
|
|
|
@ -57,7 +57,7 @@ public class BoardNewServiceImpl implements BoardNewService { |
|
|
|
if ("A29mm".equals(code)) { |
|
|
|
// 月用电量 |
|
|
|
result.setElectricDayValue(new BigDecimal(value).setScale(2, RoundingMode.HALF_UP)); |
|
|
|
} else if ("B1mm".equals(code)) { |
|
|
|
} else if ("B2mm".equals(code)) { |
|
|
|
// 月用水量 |
|
|
|
result.setWaterDayValue(new BigDecimal(value).setScale(2, RoundingMode.HALF_UP)); |
|
|
|
} else if ("E3mm".equals(code)) { |
|
|
|
@ -88,7 +88,7 @@ public class BoardNewServiceImpl implements BoardNewService { |
|
|
|
Long realTenantCode = UserContext.getRealTenantCode(); |
|
|
|
|
|
|
|
//查询这一年的 "总用电": "G01","总用水": "G03","总蒸汽": "G02","总压缩空气": "D_V0000151_1","天然气":"C2"用能情况 |
|
|
|
List<TsKvDTO> tsKvByCodeAndAttrs = tsKvService.findTsKvByCodeAndAttrs("CO_" + realTenantCode, Lists.newArrayList("A29yy", "B1yy", "E3yy", "D2yy","C2yy"), dayTime, endTime, true); |
|
|
|
List<TsKvDTO> tsKvByCodeAndAttrs = tsKvService.findTsKvByCodeAndAttrs("CO_" + realTenantCode, Lists.newArrayList("A29yy", "B2yy", "E3yy", "D2yy","C2yy"), dayTime, endTime, true); |
|
|
|
if(CollectionUtil.isNotEmpty(tsKvByCodeAndAttrs)){ |
|
|
|
for (TsKvDTO tsKvDTO : tsKvByCodeAndAttrs) { |
|
|
|
String code = tsKvDTO.getThingCode(); |
|
|
|
@ -96,7 +96,7 @@ public class BoardNewServiceImpl implements BoardNewService { |
|
|
|
if ("A29yy".equals(code)) { |
|
|
|
// 年用电量 |
|
|
|
result.setElectricDayValue(new BigDecimal(value).setScale(2, RoundingMode.HALF_UP)); |
|
|
|
} else if ("B1yy".equals(code)) { |
|
|
|
} else if ("B2yy".equals(code)) { |
|
|
|
// 年用水量 |
|
|
|
result.setWaterDayValue(new BigDecimal(value).setScale(2, RoundingMode.HALF_UP)); |
|
|
|
} else if ("E3yy".equals(code)) { |
|
|
|
@ -130,7 +130,7 @@ public class BoardNewServiceImpl implements BoardNewService { |
|
|
|
if ("电".equals(type)) { |
|
|
|
attrs.add("A29dd"); |
|
|
|
} else if ("水".equals(type)) { |
|
|
|
attrs.add("B1dd"); |
|
|
|
attrs.add("B2dd"); |
|
|
|
} else if ("蒸汽".equals(type)) { |
|
|
|
attrs.add("E3dd"); |
|
|
|
} else if ("压缩空气".equals(type)) { |
|
|
|
@ -176,45 +176,45 @@ public class BoardNewServiceImpl implements BoardNewService { |
|
|
|
// Long yearEndTime = DateTimeUtils.convertTimeToLong(DateTimeUtils.getYearEndTime(day)); |
|
|
|
EnergyCostProportionDataDTO energyA29 = new EnergyCostProportionDataDTO(); |
|
|
|
energyA29.setName("电"); |
|
|
|
EnergyCostProportionDataDTO energyB1 = new EnergyCostProportionDataDTO(); |
|
|
|
energyB1.setName("水"); |
|
|
|
EnergyCostProportionDataDTO energyB2 = new EnergyCostProportionDataDTO(); |
|
|
|
energyB2.setName("水"); |
|
|
|
Long realTenantCode = UserContext.getRealTenantCode(); |
|
|
|
EnergyCostProportionDataDTO energyE3 = new EnergyCostProportionDataDTO(); |
|
|
|
energyE3.setName("蒸气"); |
|
|
|
//月用电 |
|
|
|
List<TsKvDTO> tsKvMonth = tsKvService.findTsKvByCodeAndAttrs("CO_" + realTenantCode, Lists.newArrayList("A29mm", "B1mm", "G02", "E3mm"), monthDayTime, monthEndTime, true); |
|
|
|
List<TsKvDTO> tsKvMonth = tsKvService.findTsKvByCodeAndAttrs("CO_" + realTenantCode, Lists.newArrayList("A29mm", "B2mm", "G02", "E3mm"), monthDayTime, monthEndTime, true); |
|
|
|
|
|
|
|
//年用电 |
|
|
|
// List<TsKvDTO> tsKvYear = tsKvService.findTsKvByCodeAndAttrs("CO_" + realTenantCode, Lists.newArrayList("G01", "G03", "G02", "D_V0000151_1","C2"), monthDayTime, monthEndTime, true); |
|
|
|
if(CollectionUtil.isNotEmpty(tsKvMonth)){ |
|
|
|
BigDecimal totalValueA29 = BigDecimal.ZERO; |
|
|
|
BigDecimal totalValueB1 = BigDecimal.ZERO; |
|
|
|
BigDecimal totalValueB2 = BigDecimal.ZERO; |
|
|
|
BigDecimal totalValueE3 = BigDecimal.ZERO; |
|
|
|
List<TsKvDTO> listA29 = tsKvMonth.stream().filter(tsKvDTO -> StringUtils.equals("A29mm", tsKvDTO.getAttrKey())).toList(); |
|
|
|
List<TsKvDTO> listB1 = tsKvMonth.stream().filter(tsKvDTO -> StringUtils.equals("B1mm", tsKvDTO.getAttrKey())).toList(); |
|
|
|
List<TsKvDTO> listB2 = tsKvMonth.stream().filter(tsKvDTO -> StringUtils.equals("B2mm", tsKvDTO.getAttrKey())).toList(); |
|
|
|
List<TsKvDTO> listE3 = tsKvMonth.stream().filter(tsKvDTO -> StringUtils.equals("E3mm", tsKvDTO.getAttrKey())).toList(); |
|
|
|
if(CollectionUtil.isNotEmpty(listA29)){ |
|
|
|
BigDecimal reduce = listA29.stream().map(v -> new BigDecimal(v.getVal())).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
totalValueA29 = reduce.multiply(new BigDecimal("0.1229")).divide(new BigDecimal("1000"),2,RoundingMode.HALF_UP); |
|
|
|
} |
|
|
|
if(CollectionUtil.isNotEmpty(listB1)){ |
|
|
|
BigDecimal reduce = listB1.stream().map(v -> new BigDecimal(v.getVal())).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
totalValueB1 = reduce.multiply(new BigDecimal("0.2571")).divide(new BigDecimal("1000"),2,RoundingMode.HALF_UP); |
|
|
|
if(CollectionUtil.isNotEmpty(listB2)){ |
|
|
|
BigDecimal reduce = listB2.stream().map(v -> new BigDecimal(v.getVal())).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
totalValueB2 = reduce.multiply(new BigDecimal("0.2571")).divide(new BigDecimal("1000"),2,RoundingMode.HALF_UP); |
|
|
|
} |
|
|
|
if(CollectionUtil.isNotEmpty(listE3)){ |
|
|
|
BigDecimal reduce = listE3.stream().map(v -> new BigDecimal(v.getVal())).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
totalValueE3 = reduce.multiply(new BigDecimal("1.2143")).divide(new BigDecimal("1000"),2,RoundingMode.HALF_UP); |
|
|
|
} |
|
|
|
BigDecimal total = totalValueA29.add(totalValueB1).add(totalValueE3); |
|
|
|
BigDecimal total = totalValueA29.add(totalValueB2).add(totalValueE3); |
|
|
|
energyA29.setProportion(totalValueA29.divide(total,4,RoundingMode.HALF_UP).toPlainString()); |
|
|
|
energyA29.setValue(totalValueA29); |
|
|
|
energyB1.setProportion(totalValueB1.divide(total,4,RoundingMode.HALF_UP).toPlainString()); |
|
|
|
energyB1.setValue(totalValueB1); |
|
|
|
energyB2.setProportion(totalValueB2.divide(total,4,RoundingMode.HALF_UP).toPlainString()); |
|
|
|
energyB2.setValue(totalValueB2); |
|
|
|
energyE3.setProportion(totalValueE3.divide(total,4,RoundingMode.HALF_UP).toPlainString()); |
|
|
|
energyE3.setValue(totalValueE3); |
|
|
|
} |
|
|
|
result.add(energyA29); |
|
|
|
result.add(energyB1); |
|
|
|
result.add(energyB2); |
|
|
|
result.add(energyE3); |
|
|
|
return result; |
|
|
|
} |
|
|
|
@ -236,7 +236,7 @@ public class BoardNewServiceImpl implements BoardNewService { |
|
|
|
// 检查数据是否为空 |
|
|
|
if (CollectionUtil.isEmpty(attr)) { |
|
|
|
// 如果没有数据,返回错误 |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
for (TsKvDTO kv : attr) { |
|
|
|
// 获取时间戳 |
|
|
|
@ -411,7 +411,7 @@ public class BoardNewServiceImpl implements BoardNewService { |
|
|
|
// if (tsKvEntry.getValue()!=null){ |
|
|
|
// if ("A29".equals(key)){ |
|
|
|
// result.setElectricValue(new BigDecimal(tsKvEntry.getValue().toString()).setScale(2,BigDecimal.ROUND_HALF_UP)); |
|
|
|
// }else if("B1".equals(key)){ |
|
|
|
// }else if("B2".equals(key)){ |
|
|
|
// result.setWaterValue(new BigDecimal(tsKvEntry.getValue().toString()).setScale(2,BigDecimal.ROUND_HALF_UP)); |
|
|
|
// }else if("E3".equals(key)){ |
|
|
|
// result.setSteamValue(new BigDecimal(tsKvEntry.getValue().toString()).setScale(2,BigDecimal.ROUND_HALF_UP)); |
|
|
|
|