Browse Source

修改统计量

wangyangyang 4 years ago
parent
commit
6809398b38
1 changed files with 13 additions and 11 deletions
  1. 13 11
      sms_water/src/main/java/com/huaxu/controller/MonitorInfoController.java

+ 13 - 11
sms_water/src/main/java/com/huaxu/controller/MonitorInfoController.java

@@ -174,17 +174,19 @@ public class MonitorInfoController {
                         DeviceAttributeSpecsEntity deviceAttributeSpecsEntity = new DeviceAttributeSpecsEntity();
                         deviceAttributeSpecsEntity.setAttributeId(item.getAttributeId());
                         List<DeviceAttributeSpecsEntity> deviceAttributeSpecsEntities = deviceAttributeSpecsService.findList(deviceAttributeSpecsEntity);
-                        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()) {
-                                        item.setMonitorValue(specsEntity.getSpecsName());
-                                    }
-                            }
-                        } else {
-                            item.setMonitorValue(String.format("%.3f", map.get(item.getAttributeId()).getDataValue()) + (StringUtils.isNotEmpty(map.get(item.getAttributeId()).getUnit()) ? map.get(item.getAttributeId()).getUnit() : ""));
-                        }
+                       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()) {
+                                           item.setMonitorValue(specsEntity.getSpecsName());
+                                       }
+                               }
+                           } else {
+                               item.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()))
                             item.setIsAlarm(1);