Kaynağa Gözat

水电耗对比分析

lihui007 4 yıl önce
ebeveyn
işleme
c772167859

+ 3 - 0
sms_water/src/main/java/com/huaxu/controller/MonitorDataReportController.java

@@ -68,11 +68,14 @@ public class MonitorDataReportController {
             List<MonitorDataChartReportDeviceDto> energy = monitorDataReportService.monitorDataEnergyReport(reportType,sceneIds,localDate.getYear(),localDate.getMonthValue(),localDate.getDayOfMonth(),sceneType);
             //水质(PH8、余氯11、浊度10)
             List<MonitorDataChartReportDeviceDto> quality = monitorDataReportService.monitorDataQualityReport(reportType,sceneIds,localDate.getYear(),localDate.getMonthValue(),localDate.getDayOfMonth());
+            // 水电耗
+            List<MonitorDataChartReportDeviceDto> consumption = monitorDataReportService.monitorWaterPowerConsumptionReport(reportType,sceneIds,localDate.getYear(),localDate.getMonthValue(),localDate.getDayOfMonth(),1);
             //报警(报警次数)
             List<MonitorDataChartReportDeviceDto> alarm = monitorDataReportService.deviceAlarmReport(reportType,sceneIds,localDate.getYear(),localDate.getMonthValue(),localDate.getDayOfMonth());
 
             reportList.add(energy);
             reportList.add(quality);
+            reportList.add(consumption);
             reportList.add(alarm);
         }
         return new AjaxMessage<>(ResultStatus.OK, reportList);

+ 2 - 1
sms_water/src/main/java/com/huaxu/service/MonitorDataReportService.java

@@ -35,7 +35,8 @@ public interface MonitorDataReportService {
     List<MonitorDataChartReportDeviceDto> monitorDataQualityReport(Integer type, List<Long>  sceneIds, Integer year, Integer month , Integer day);
     //能耗对比
     List<MonitorDataChartReportDeviceDto> monitorDataEnergyReport(Integer type, List<Long>  sceneIds, Integer year, Integer month , Integer day, Integer sceneType);
-
+    // 水电耗
+    List<MonitorDataChartReportDeviceDto> monitorWaterPowerConsumptionReport(Integer type, List<Long>  sceneIds, Integer year, Integer month , Integer day, Integer sceneType);
     List<DeviceEntity> getDeviceBySceneTypeName(String sceneTypeName);
 
     List<MonitorDataChartReportDeviceDto> monitorDataDeviceReport(Integer type, List<Long>  deviceIds, Integer searchType, Integer year, Integer month , Integer day);

+ 55 - 0
sms_water/src/main/java/com/huaxu/service/impl/MonitorDataReportServiceImpl.java

@@ -168,6 +168,61 @@ public class MonitorDataReportServiceImpl implements MonitorDataReportService {
         return monitorDataChartReportDeviceDtos;
     }
     @Override
+    public List<MonitorDataChartReportDeviceDto> monitorWaterPowerConsumptionReport(Integer type, List<Long> sceneIds, Integer year, Integer month , Integer day, Integer sceneType) {
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        List<MonitorDataChartReportDeviceDto> monitorDataChartReportDeviceDtos = null;
+        if (type != null && type == 3){
+            monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReportByDay(sceneType,sceneIds,year,month,day,
+                    loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
+        } else if(type != null && type == 2){
+            monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReportByMonth(sceneType,sceneIds,year,month,
+                    loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
+        } else if(type != null && type == 1){
+            monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReportByYear(sceneType,sceneIds,year,
+                    loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
+        }
+        if (monitorDataChartReportDeviceDtos != null) {
+            FillLoseData(monitorDataChartReportDeviceDtos,type,year,month,day);
+        }
+        for (MonitorDataChartReportDeviceDto water: monitorDataChartReportDeviceDtos) {
+            List<MonitorDataChartReportAttributeDto> newAttrDataList  = new ArrayList();
+            MonitorDataChartReportAttributeDto newAttrData = new MonitorDataChartReportAttributeDto();
+            List<MonitorDataChartReportAttributeDto> attributeDtos =  water.getAttributeData();
+            newAttrData.setAttributeName("水电耗");
+            newAttrData.setUnit("kwh/㎡");
+            if (attributeDtos.size()  == 2) {
+                MonitorDataChartReportAttributeDto attributeDto1 = attributeDtos.get(0);
+                MonitorDataChartReportAttributeDto attributeDto2 = attributeDtos.get(1);
+                Map<Integer,MonitorDataChartReportValueDto> map1 = attributeDto1.getMonitorDataChartReportValue().stream().collect(Collectors.toMap(MonitorDataChartReportValueDto::getDateLabel, a -> a,(k1, k2)->k1));
+                Map<Integer,MonitorDataChartReportValueDto> map2 = attributeDto2.getMonitorDataChartReportValue().stream().collect(Collectors.toMap(MonitorDataChartReportValueDto::getDateLabel, a -> a,(k1, k2)->k1));
+                // 耗电量
+                if ("5".equals(attributeDto1.getAttributeType())) {
+                    calculation(attributeDto1, map2);
+                    newAttrData.setMonitorDataChartReportValue(attributeDto1.getMonitorDataChartReportValue());
+                } else {
+                    calculation(attributeDto2, map1);
+                    newAttrData.setMonitorDataChartReportValue(attributeDto2.getMonitorDataChartReportValue());
+                }
+            }
+            newAttrDataList.add(newAttrData);
+            water.setAttributeData(newAttrDataList);
+        }
+        return monitorDataChartReportDeviceDtos;
+    }
+
+    private void calculation(MonitorDataChartReportAttributeDto attributeDto, Map<Integer,MonitorDataChartReportValueDto> map){
+        for (MonitorDataChartReportValueDto valueDto : attributeDto.getMonitorDataChartReportValue()) {
+            BigDecimal b1 = new BigDecimal(valueDto.getData());
+            BigDecimal b2 = new BigDecimal(map.get(valueDto.getDateLabel()).getData());
+            valueDto.setMonitorData("");
+            if (b1.compareTo(new BigDecimal(0)) == 0 || b2.compareTo(new BigDecimal(0)) == 0) {
+                valueDto.setData(0d);
+            } else {
+                valueDto.setData(b1.divide(b2, 5, RoundingMode.HALF_UP).multiply(new BigDecimal(100)).doubleValue());
+            }
+        }
+    }
+    @Override
     public List<DeviceEntity> getDeviceBySceneTypeName(String sceneTypeName){
         LoginUser loginUser = UserUtil.getCurrentUser();
         return monitorDataReportMapper.getDeviceBySceneTypeName(sceneTypeName,loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());