Browse Source

工艺图单位

wangyangyang 4 years ago
parent
commit
b5935afb51

+ 7 - 1
sms_water/src/main/java/com/huaxu/controller/MonitorInfoController.java

@@ -52,6 +52,8 @@ public class MonitorInfoController {
     @Autowired
     private  DeviceAttributeSpecsService deviceAttributeSpecsService;
     @Autowired
+    private  DeviceAttributeService deviceAttributeService;
+    @Autowired
     private MonitorDataReportService monitorDataReportService;
 
     @ApiOperation(value = "按场景ID查询供水量出水量耗药量耗电量(已废弃)")
@@ -160,7 +162,11 @@ public class MonitorInfoController {
                                }
                            } else {
                                if (value != null) {
-                                   item.setMonitorValue(String.format("%.3f", map.get(item.getAttributeId()).getDataValue()) + (StringUtils.isNotEmpty(map.get(item.getAttributeId()).getUnit()) ? map.get(item.getAttributeId()).getUnit() : ""));
+                                   DeviceAttributeEntity deviceAttributeEntity = deviceAttributeService.getById(item.getAttributeId());
+                                   String unit = "";
+                                   if (deviceAttributeEntity != null && deviceAttributeEntity.getUnit() != null)
+                                       unit = deviceAttributeEntity.getUnit();
+                                   item.setMonitorValue(String.format("%.3f", map.get(item.getAttributeId()).getDataValue()) + unit);
                                }
                            }
                        }