wangyangyang vor 4 Jahren
Ursprung
Commit
1014358504

+ 5 - 169
sms_water/src/main/java/com/huaxu/controller/AppDataController.java

@@ -29,48 +29,14 @@ import java.util.stream.Collectors;
 @Api(tags = "App数据")
 public class AppDataController {
     @Autowired
-    private MonitorDataReportService monitorDataReportService;
+    private AppDataService appDataService;
     @Autowired
     private SceneService sceneService;
-    @Autowired
-    private MonitorInfoService monitorInfoService;
-    @Autowired
-    private RedisUtil redisUtil;
-    @Autowired
-    private AlarmDetailsService alarmDetailsService;
-    @Autowired
-    private DeviceAttributeSpecsService deviceAttributeSpecsService;
-    @Autowired
-    private DeviceParmService deviceParmService;
 
     @RequestMapping(value = "getProductionDataForSameMonth", method = RequestMethod.GET)
     @ApiOperation(value = "综合调度——本月供水情况")
     public AjaxMessage<AppSmsDataDto> getMonthWaterSupply(@ApiParam(value = "类型名称(水源、水厂、泵站、售水)") @RequestParam(required = true) String typeName) {
-        //3用水量or供水量or制水量  4 取水量or进水量 5耗电量 6耗药量
-        AppSmsDataDto appSmsDataDto = new AppSmsDataDto();
-        switch (typeName) {
-            case "水源":
-                appSmsDataDto.setIntakeWaterUsage(monitorDataReportService.getAmountCount(null, null, typeName, 4, 2).doubleValue());
-                appSmsDataDto.setPowerUsage(monitorDataReportService.getAmountCount(null, null, typeName, 5, 2).doubleValue());
-                break;
-            case "水厂":
-                appSmsDataDto.setIntakeWaterUsage(monitorDataReportService.getAmountCount(null, null, typeName, 3, 2).doubleValue());
-                appSmsDataDto.setPowerUsage(monitorDataReportService.getAmountCount(null, null, typeName, 5, 2).doubleValue());
-                appSmsDataDto.setDrugUsage(monitorDataReportService.getAmountCount(null, null, typeName, 6, 2).doubleValue());
-                break;
-            case "泵站":
-                appSmsDataDto.setYieldWaterUsage(monitorDataReportService.getAmountCount(null, null, typeName, 3, 2).doubleValue());
-                appSmsDataDto.setPowerUsage(monitorDataReportService.getAmountCount(null, null, typeName, 5, 2).doubleValue());
-                break;
-            case "售水":
-                appSmsDataDto.setYieldWaterUsage(monitorDataReportService.getAmountCount(null, null, "水厂", 3, 2).doubleValue());
-                appSmsDataDto.setWaterUsage(monitorDataReportService.getUseAmount(null, 1).doubleValue());
-                double amount = appSmsDataDto.getYieldWaterUsage() - appSmsDataDto.getWaterUsage();
-                if (appSmsDataDto.getYieldWaterUsage() != null && appSmsDataDto.getYieldWaterUsage() != 0d) {
-                    appSmsDataDto.setWaterFeeRecoveryRate(BigDecimal.valueOf(amount).divide(BigDecimal.valueOf(appSmsDataDto.getYieldWaterUsage()), 3, BigDecimal.ROUND_HALF_UP).doubleValue() * 100);
-                }
-                break;
-        }
+        AppSmsDataDto appSmsDataDto = appDataService.getProductionDataForSameMonth(typeName);
         return new AjaxMessage<>(ResultStatus.OK, appSmsDataDto);
     }
 
@@ -82,146 +48,16 @@ public class AppDataController {
         return new AjaxMessage<>(ResultStatus.OK, sceneEntities);
     }
 
-    /**
-     * 今日统计量
-     * @param typeName
-     * @param id
-     * @return
-     */
-    private   List<SceneDataDto> getTotalAmount(@ApiParam(value = "类型名称(水源、水厂、泵站、售水)") @RequestParam(required = true) String typeName,
-                                              @ApiParam(value = "场景ID", required = true) @RequestParam Long id) {
-        List<SceneDataDto> sceneDataDtos = new ArrayList<>();
-        switch (typeName) {
-            case "水源":
-                SceneDataDto item1 = new SceneDataDto();
-                item1.setMonitorName("今日取水量");
-                item1.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 4, 1).doubleValue() + "m³");
-                sceneDataDtos.add(item1);
-                SceneDataDto item2 = new SceneDataDto();
-                item2.setMonitorName("今日耗电量");
-                item2.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 5, 1).doubleValue() + "kw");
-                sceneDataDtos.add(item2);
-                break;
-            case "水厂":
-                SceneDataDto item5 = new SceneDataDto();
-                item5.setMonitorName("今日进水量");
-                item5.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 4, 1).doubleValue() + "m³");
-                sceneDataDtos.add(item5);
-                SceneDataDto item3 = new SceneDataDto();
-                item3.setMonitorName("今日制水量");
-                item3.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 3, 1).doubleValue() + "m³");
-                sceneDataDtos.add(item3);
-                SceneDataDto item4 = new SceneDataDto();
-                item4.setMonitorName("今日耗电量");
-                item4.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 5, 1).doubleValue() + "kw");
-                sceneDataDtos.add(item4);
-                SceneDataDto item6 = new SceneDataDto();
-                item6.setMonitorName("今日耗药量");
-                item6.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 6, 1).doubleValue() + "kg");
-                sceneDataDtos.add(item6);
-                break;
-            case "泵站":
-                SceneDataDto item7 = new SceneDataDto();
-                item7.setMonitorName("今日进水量");
-                item7.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 4, 1).doubleValue() + "m³");
-                sceneDataDtos.add(item7);
-                SceneDataDto item8 = new SceneDataDto();
-                item8.setMonitorName("今日供水量");
-                item8.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 3, 1).doubleValue() + "m³");
-                sceneDataDtos.add(item8);
-                SceneDataDto item9 = new SceneDataDto();
-                item9.setMonitorName("今日耗电量");
-                item9.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 5, 1).doubleValue() + "kw");
-                sceneDataDtos.add(item9);
-                break;
-        }
-        return sceneDataDtos;
-    }
 
     @ApiOperation(value = "综合调度——工艺场景(详情)")
     @RequestMapping(value = "/findBySceneId", method = RequestMethod.GET)
     @ResponseBody
     public AjaxMessage<SceneDataForAppDto> findBySceneId(
-            @ApiParam(value = "类型名称(水源、水厂、泵站、售水)") @RequestParam(required = true) String typeName,
+            @ApiParam(value = "类型名称(水源、水厂、泵站)") @RequestParam(required = true) String typeName,
             @ApiParam(value = "场景ID", required = true) @RequestParam Long id) {
-        SceneDataForAppDto returnInfo = new SceneDataForAppDto();
-        SceneEntity sceneEntity = sceneService.findSceneByIdForApp(id);
-        if (sceneEntity != null) {
-            returnInfo.setAddress(sceneEntity.getAddress());
-            returnInfo.setSceneName(sceneEntity.getSceneName());
-            returnInfo.setImagePath(sceneEntity.getSceneImages().size() > 0 ? sceneEntity.getSceneImages().get(0).getImagePath() : null);
-            if (sceneEntity.getParentSceneId().equals("0")) {
-                List<SceneDataDto> sceneDataDtos = getTotalAmount(typeName, id);
-                returnInfo.getInfos().addAll(sceneDataDtos);
-            }
-        } else {
-            return null;
-        }
-        List<SceneDataDto> sceneDataDtos = new ArrayList<>();
-        List<String> deviceCodes = new ArrayList<>();
-        //查询到所有的测点信息
-        List<DeviceParmEntity> deviceParmEntities = deviceParmService.selectByScendId(id.intValue());
-        Map<String, List<AlarmDetailsDto>> alarms = new HashMap<>();
-        Map<String, List<DeviceParmEntity>> parmMap = new HashMap<>();
-        for (DeviceParmEntity deviceParmEntity : deviceParmEntities) {
-            if (!deviceCodes.contains(deviceParmEntity.getDeviceCode())) {
-                deviceCodes.add(deviceParmEntity.getDeviceCode());
-                //查询报警信息
-                List<AlarmDetailsDto> alarmDetailsDtos = alarmDetailsService.selectByDeviceId(deviceParmEntity.getDeviceId());
-                alarms.put(deviceParmEntity.getDeviceCode(), alarmDetailsDtos);
-                List<DeviceParmEntity> deviceParms = new ArrayList<>();
-                deviceParms.add(deviceParmEntity);
-                parmMap.put(deviceParmEntity.getDeviceCode(), deviceParms);
-            } else {
-                parmMap.get(deviceParmEntity.getDeviceId()).add(deviceParmEntity);
-            }
-        }
-        for (String deveiceCode : deviceCodes) {
-            byte[] bytes = redisUtil.get(("sms_water_" + deveiceCode).getBytes());
-            //将报警信息放置map中
-            Map<Integer, AlarmDetailsDto> mapAlarm = new HashMap<>();
-            List<AlarmDetailsDto> alarmDetailsDtos = alarms.get(deveiceCode);
-            mapAlarm = alarmDetailsDtos.stream().collect(Collectors.toMap(AlarmDetailsDto::getAttributeId, a -> a, (k1, k2) -> k1));
-            //将缓存中的实时数据放到map中方便进行遍历
-            if (bytes != null && bytes.length > 0) {
-                MonitorDataEntity monitorDataEntity = (MonitorDataEntity) ByteArrayUtils.bytesToObject(bytes).get();
-                Map<Long, MonitorDataValueEntity> map = new HashMap<>();
-                returnInfo.setCollectDate(monitorDataEntity.getCollectDate());
-                //将缓存中的实时数据放到map中方便进行遍历
-                map = monitorDataEntity.getDataValues().stream().collect(Collectors.toMap(MonitorDataValueEntity::getAttributeId, a -> a, (k1, k2) -> k1));
-                for (DeviceParmEntity item : parmMap.get(deveiceCode)) {
-                    SceneDataDto sceneDataDto = new SceneDataDto();
-                    sceneDataDto.setMonitorName(item.getAttributeName());
-                    //按属性ID查询标签值
-                    DeviceAttributeSpecsEntity deviceAttributeSpecsEntity = new DeviceAttributeSpecsEntity();
-                    deviceAttributeSpecsEntity.setAttributeId(Long.valueOf(item.getAttributeId()));
-                    List<DeviceAttributeSpecsEntity> deviceAttributeSpecsEntities = deviceAttributeSpecsService.findList(deviceAttributeSpecsEntity);
-                    if (map.containsKey(item.getAttributeId())) {
-                        Double value = map.get(item.getAttributeId()).getDataValue();
-                        if (deviceAttributeSpecsEntities.size() > 0) {
-                            if (value != null) {
-                                for (DeviceAttributeSpecsEntity specsEntity : deviceAttributeSpecsEntities)
-                                    if (Integer.valueOf(specsEntity.getSpecsValue()) == value.intValue()) {
-                                        sceneDataDto.setMonitorValue(specsEntity.getSpecsName());
-                                    }
-                            }
-                        } else {
-                            if (value != null) {
-                                sceneDataDto.setMonitorValue(String.format("%.3f", map.get(item.getAttributeId()).getDataValue()) + (StringUtils.isNotEmpty(map.get(item.getAttributeId()).getUnit()) ? map.get(item.getAttributeId()).getUnit() : ""));
-                            }
-                        }
-                    }
-                    //判断是否报警
-                    if (mapAlarm.containsKey(item.getAttributeId().intValue()))
-                        sceneDataDto.setIsAlarm(1);
-                    else
-                        sceneDataDto.setIsAlarm(0);
-                    sceneDataDtos.add(sceneDataDto);
-                }
-            }
-        }
-        returnInfo.setInfos(sceneDataDtos);
+        SceneDataForAppDto returnInfo = appDataService.getSceneDataForApp(typeName, id);
         return new AjaxMessage<>(ResultStatus.OK, returnInfo);
     }
 
+
 }

+ 3 - 2
sms_water/src/main/java/com/huaxu/controller/ComDisplayController.java

@@ -175,11 +175,12 @@ public class ComDisplayController {
             //查询子公司的取水量、制水量 产销差(制水量-售水量)/制水量  X 100%
             receFee.get(0).setIntakeWaterUsage(monitorDataReportService.getAmountCount(companyOrgId, null, "水源", 4, 2).divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP).doubleValue());
             receFee.get(0).setYieldWaterUsage(monitorDataReportService.getAmountCount(companyOrgId, null, "水厂", 3, 2).divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP).doubleValue());
+            receFee.get(0).setMeterReadingArrivalRate(BigDecimal.valueOf(receFee.get(0).getMeterReadingArrivalRate()).multiply(BigDecimal.valueOf(100)).divide(BigDecimal.valueOf(1), 2, BigDecimal.ROUND_HALF_UP).doubleValue());
             double amount = receFee.get(0).getYieldWaterUsage() - waterUsage;
             if (receFee.get(0).getYieldWaterUsage() == 0d)
-                receFee.get(0).setWaterFeeRecoveryRate(0d);
+                receFee.get(0).setWaterFeeRecoveryRate(BigDecimal.valueOf(0).divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_HALF_UP).doubleValue());
             else
-                receFee.get(0).setWaterFeeRecoveryRate(BigDecimal.valueOf(amount).divide(BigDecimal.valueOf(receFee.get(0).getYieldWaterUsage()), 3, BigDecimal.ROUND_HALF_UP).doubleValue());
+                receFee.get(0).setWaterFeeRecoveryRate(BigDecimal.valueOf(amount).multiply(BigDecimal.valueOf(100)).divide(BigDecimal.valueOf(receFee.get(0).getYieldWaterUsage()), 2, BigDecimal.ROUND_HALF_UP).doubleValue());
         }
         return new AjaxMessage<>(ResultStatus.OK, receFee.get(0));
     }

+ 215 - 0
sms_water/src/main/java/com/huaxu/service/AppDataService.java

@@ -0,0 +1,215 @@
+package com.huaxu.service;
+
+import com.huaxu.common.StringUtils;
+import com.huaxu.dto.AlarmDetailsDto;
+import com.huaxu.dto.AppSmsDataDto;
+import com.huaxu.dto.SceneDataDto;
+import com.huaxu.dto.SceneDataForAppDto;
+import com.huaxu.entity.*;
+import com.huaxu.util.ByteArrayUtils;
+import com.huaxu.util.RedisUtil;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Service
+public class AppDataService {
+    @Autowired
+    private MonitorDataReportService monitorDataReportService;
+    @Autowired
+    private MonitorInfoService monitorInfoService;
+    @Autowired
+    private RedisUtil redisUtil;
+    @Autowired
+    private AlarmDetailsService alarmDetailsService;
+    @Autowired
+    private DeviceAttributeSpecsService deviceAttributeSpecsService;
+    @Autowired
+    private DeviceParmService deviceParmService;
+    @Autowired
+    private SceneService sceneService;
+
+    /**
+     * 查询场景信息
+     *
+     * @param typeName 类型名称(水源、水厂、泵站、售水)
+     * @return
+     */
+    public AppSmsDataDto getProductionDataForSameMonth(String typeName) {
+        //3用水量or供水量or制水量  4 取水量or进水量 5耗电量 6耗药量
+        AppSmsDataDto appSmsDataDto = new AppSmsDataDto();
+        switch (typeName) {
+            case "水源":
+                appSmsDataDto.setIntakeWaterUsage(monitorDataReportService.getAmountCount(null, null, typeName, 4, 2).doubleValue());
+                appSmsDataDto.setPowerUsage(monitorDataReportService.getAmountCount(null, null, typeName, 5, 2).doubleValue());
+                break;
+            case "水厂":
+                appSmsDataDto.setIntakeWaterUsage(monitorDataReportService.getAmountCount(null, null, typeName, 3, 2).doubleValue());
+                appSmsDataDto.setPowerUsage(monitorDataReportService.getAmountCount(null, null, typeName, 5, 2).doubleValue());
+                appSmsDataDto.setDrugUsage(monitorDataReportService.getAmountCount(null, null, typeName, 6, 2).doubleValue());
+                break;
+            case "泵站":
+                appSmsDataDto.setYieldWaterUsage(monitorDataReportService.getAmountCount(null, null, typeName, 3, 2).doubleValue());
+                appSmsDataDto.setPowerUsage(monitorDataReportService.getAmountCount(null, null, typeName, 5, 2).doubleValue());
+                break;
+            case "售水":
+                appSmsDataDto.setYieldWaterUsage(monitorDataReportService.getAmountCount(null, null, "水厂", 3, 2).doubleValue());
+                appSmsDataDto.setWaterUsage(monitorDataReportService.getUseAmount(null, 1).doubleValue());
+                double amount = appSmsDataDto.getYieldWaterUsage() - appSmsDataDto.getWaterUsage();
+                if (appSmsDataDto.getYieldWaterUsage() != null && appSmsDataDto.getYieldWaterUsage() != 0d) {
+                    appSmsDataDto.setWaterFeeRecoveryRate(BigDecimal.valueOf(amount).divide(BigDecimal.valueOf(appSmsDataDto.getYieldWaterUsage()), 3, BigDecimal.ROUND_HALF_UP).doubleValue() * 100);
+                }
+                break;
+        }
+        return appSmsDataDto;
+    }
+    /**
+     * 今日统计量
+     * @param typeName 类型名称(水源、水厂、泵站、售水)
+     * @param id 场景ID
+     * @return
+     */
+    private List<SceneDataDto> getTotalAmount(String typeName,Long id) {
+        List<SceneDataDto> sceneDataDtos = new ArrayList<>();
+        switch (typeName) {
+            case "水源":
+                SceneDataDto item1 = new SceneDataDto();
+                item1.setMonitorName("今日取水量");
+                item1.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 4, 1).doubleValue() + "m³");
+                sceneDataDtos.add(item1);
+                SceneDataDto item2 = new SceneDataDto();
+                item2.setMonitorName("今日耗电量");
+                item2.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 5, 1).doubleValue() + "kw");
+                sceneDataDtos.add(item2);
+                break;
+            case "水厂":
+                SceneDataDto item5 = new SceneDataDto();
+                item5.setMonitorName("今日进水量");
+                item5.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 4, 1).doubleValue() + "m³");
+                sceneDataDtos.add(item5);
+                SceneDataDto item3 = new SceneDataDto();
+                item3.setMonitorName("今日制水量");
+                item3.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 3, 1).doubleValue() + "m³");
+                sceneDataDtos.add(item3);
+                SceneDataDto item4 = new SceneDataDto();
+                item4.setMonitorName("今日耗电量");
+                item4.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 5, 1).doubleValue() + "kw");
+                sceneDataDtos.add(item4);
+                SceneDataDto item6 = new SceneDataDto();
+                item6.setMonitorName("今日耗药量");
+                item6.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 6, 1).doubleValue() + "kg");
+                sceneDataDtos.add(item6);
+                break;
+            case "泵站":
+                SceneDataDto item7 = new SceneDataDto();
+                item7.setMonitorName("今日进水量");
+                item7.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 4, 1).doubleValue() + "m³");
+                sceneDataDtos.add(item7);
+                SceneDataDto item8 = new SceneDataDto();
+                item8.setMonitorName("今日供水量");
+                item8.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 3, 1).doubleValue() + "m³");
+                sceneDataDtos.add(item8);
+                SceneDataDto item9 = new SceneDataDto();
+                item9.setMonitorName("今日耗电量");
+                item9.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 5, 1).doubleValue() + "kw");
+                sceneDataDtos.add(item9);
+                break;
+        }
+        return sceneDataDtos;
+    }
+
+    /**
+     * 工艺场景(详情)
+     * @param typeName 类型名称(水源、水厂、泵站、售水)
+     * @param id 场景ID
+     * @return
+     */
+    public SceneDataForAppDto getSceneDataForApp(String typeName,Long id) {
+        SceneDataForAppDto returnInfo = new SceneDataForAppDto();
+        SceneEntity sceneEntity = sceneService.findSceneByIdForApp(id);
+        if (sceneEntity != null) {
+            returnInfo.setAddress(sceneEntity.getAddress());
+            returnInfo.setSceneName(sceneEntity.getSceneName());
+            returnInfo.setImagePath(sceneEntity.getSceneImages().size() > 0 ? sceneEntity.getSceneImages().get(0).getImagePath() : null);
+            if (sceneEntity.getParentSceneId().equals("0")) {
+                List<SceneDataDto> sceneDataDtos = getTotalAmount(typeName, id);
+                returnInfo.getInfos().addAll(sceneDataDtos);
+            }
+        } else {
+            return null;
+        }
+        List<SceneDataDto> sceneDataDtos = new ArrayList<>();
+        List<String> deviceCodes = new ArrayList<>();
+        //查询到所有的测点信息
+        List<DeviceParmEntity> deviceParmEntities = deviceParmService.selectByScendId(id.intValue());
+        Map<String, List<AlarmDetailsDto>> alarms = new HashMap<>();
+        Map<String, List<DeviceParmEntity>> parmMap = new HashMap<>();
+        for (DeviceParmEntity deviceParmEntity : deviceParmEntities) {
+            if (!deviceCodes.contains(deviceParmEntity.getDeviceCode())) {
+                deviceCodes.add(deviceParmEntity.getDeviceCode());
+                //查询报警信息
+                List<AlarmDetailsDto> alarmDetailsDtos = alarmDetailsService.selectByDeviceId(deviceParmEntity.getDeviceId());
+                alarms.put(deviceParmEntity.getDeviceCode(), alarmDetailsDtos);
+                List<DeviceParmEntity> deviceParms = new ArrayList<>();
+                deviceParms.add(deviceParmEntity);
+                parmMap.put(deviceParmEntity.getDeviceCode(), deviceParms);
+            } else {
+                parmMap.get(deviceParmEntity.getDeviceId()).add(deviceParmEntity);
+            }
+        }
+        for (String deveiceCode : deviceCodes) {
+            byte[] bytes = redisUtil.get(("sms_water_" + deveiceCode).getBytes());
+            //将报警信息放置map中
+            Map<Integer, AlarmDetailsDto> mapAlarm = new HashMap<>();
+            List<AlarmDetailsDto> alarmDetailsDtos = alarms.get(deveiceCode);
+            mapAlarm = alarmDetailsDtos.stream().collect(Collectors.toMap(AlarmDetailsDto::getAttributeId, a -> a, (k1, k2) -> k1));
+            //将缓存中的实时数据放到map中方便进行遍历
+            if (bytes != null && bytes.length > 0) {
+                MonitorDataEntity monitorDataEntity = (MonitorDataEntity) ByteArrayUtils.bytesToObject(bytes).get();
+                Map<Long, MonitorDataValueEntity> map = new HashMap<>();
+                returnInfo.setCollectDate(monitorDataEntity.getCollectDate());
+                //将缓存中的实时数据放到map中方便进行遍历
+                map = monitorDataEntity.getDataValues().stream().collect(Collectors.toMap(MonitorDataValueEntity::getAttributeId, a -> a, (k1, k2) -> k1));
+                for (DeviceParmEntity item : parmMap.get(deveiceCode)) {
+                    SceneDataDto sceneDataDto = new SceneDataDto();
+                    sceneDataDto.setMonitorName(item.getAttributeName());
+                    //按属性ID查询标签值
+                    DeviceAttributeSpecsEntity deviceAttributeSpecsEntity = new DeviceAttributeSpecsEntity();
+                    deviceAttributeSpecsEntity.setAttributeId(Long.valueOf(item.getAttributeId()));
+                    List<DeviceAttributeSpecsEntity> deviceAttributeSpecsEntities = deviceAttributeSpecsService.findList(deviceAttributeSpecsEntity);
+                    if (map.containsKey(item.getAttributeId())) {
+                        Double value = map.get(item.getAttributeId()).getDataValue();
+                        if (deviceAttributeSpecsEntities.size() > 0) {
+                            if (value != null) {
+                                for (DeviceAttributeSpecsEntity specsEntity : deviceAttributeSpecsEntities)
+                                    if (Integer.valueOf(specsEntity.getSpecsValue()) == value.intValue()) {
+                                        sceneDataDto.setMonitorValue(specsEntity.getSpecsName());
+                                    }
+                            }
+                        } else {
+                            if (value != null) {
+                                sceneDataDto.setMonitorValue(String.format("%.3f", map.get(item.getAttributeId()).getDataValue()) + (StringUtils.isNotEmpty(map.get(item.getAttributeId()).getUnit()) ? map.get(item.getAttributeId()).getUnit() : ""));
+                            }
+                        }
+                    }
+                    //判断是否报警
+                    if (mapAlarm.containsKey(item.getAttributeId().intValue()))
+                        sceneDataDto.setIsAlarm(1);
+                    else
+                        sceneDataDto.setIsAlarm(0);
+                    sceneDataDtos.add(sceneDataDto);
+                }
+            }
+        }
+        returnInfo.setInfos(sceneDataDtos);
+        return returnInfo;
+    }
+}

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

@@ -915,7 +915,6 @@ public class MonitorDataReportServiceImpl implements MonitorDataReportService {
                     value.stream().forEach(waterSupplyData -> {
                         Period period = Period.between(LocalDate.of(waterSupplyData.getYear(), waterSupplyData.getMonth(), waterSupplyData.getDay()), LocalDate.now());
                         waterSupplyChart.setSort(period.getDays());
-
                         if (waterSupplyData.getParmType() == 3) { //供水
                             waterSupplyChart.setWaterData(waterSupplyData.getAmount());
                         } else if (waterSupplyData.getParmType() == 5) {//电耗
@@ -1032,7 +1031,7 @@ public class MonitorDataReportServiceImpl implements MonitorDataReportService {
                         if (waterSupplyData.getParmType() == 3) { //供水
                             waterSupplyChart.setWaterData(waterSupplyData.getAmount().divide(BigDecimal.valueOf(10000),3, RoundingMode.HALF_UP));
                         } else if (waterSupplyData.getParmType() == 5) {//电耗
-                            waterSupplyChart.setPowerData(waterSupplyData.getAmount());
+                            waterSupplyChart.setPowerData(waterSupplyData.getAmount().divide(BigDecimal.valueOf(10000),3, RoundingMode.HALF_UP));
                         }
                     });
                     waterSupplyCharts.add(waterSupplyChart);

+ 0 - 1
sms_water/src/main/resources/mapper/MonitorDataReportMapper.xml

@@ -1317,7 +1317,6 @@
                 and (s.DEPT_ORG_ID is null or s.DEPT_ORG_ID =0)
             </if>
         </if>
-
         group by r.year,r.month,r.day,dp.PARM_TYPE,da.UNIT
     </select>