Browse Source

修改今天有实时数据才计算

yuejiaying 4 years ago
parent
commit
76e7fb50af

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

@@ -218,7 +218,7 @@ public class OnlineMonitorImpl implements OnlineMonitorService {
                             MonitorDataEntity monitorDataEntity = (MonitorDataEntity) ByteArrayUtils.bytesToObject(bytes).get();
                             SimpleDateFormat formatdate = new SimpleDateFormat("YYYY-MM-dd");//日期算换格式
                             //计算今日数据
-                            if(formatdate.format(new Date()).equals(monitorDataEntity.getCollectDate())) {
+                            if(formatdate.format(new Date()).equals(formatdate.format(monitorDataEntity.getCollectDate()))) {
                                 //筛选该设备相同属性的值
                                 List<MonitorDataValueEntity> attributeEntities = monitorDataEntity.getDataValues().stream().filter((MonitorDataValueEntity m)
                                         -> m.getAttributeId().equals(monitorData.getAttributeId())).collect(Collectors.toList());
@@ -275,7 +275,7 @@ public class OnlineMonitorImpl implements OnlineMonitorService {
                                     monitorData.setUnit(attributeEntity.getUnit());
                                     SimpleDateFormat formatdate = new SimpleDateFormat("YYYY-MM-dd");//日期算换格式
                                     //计算今日数据
-                                    if(formatdate.format(new Date()).equals(monitorDataEntity.getCollectDate())) {
+                                    if(formatdate.format(new Date()).equals(formatdate.format(monitorDataEntity.getCollectDate()))) {
                                         Double attributeValue =0d;
                                         if(attributeEntity.getDataValue() != null && monitorData.getLatestValue() != null){
                                             attributeValue=attributeEntity.getDataValue() - monitorData.getLatestValue();