|
@@ -20,6 +20,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.text.DecimalFormat;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -188,6 +189,7 @@ public class OnlineMonitorImpl implements OnlineMonitorService {
|
|
|
byte[] bytes = redisUtil.get(("sms_water_"+monData.getDeviceCode()).getBytes());
|
|
|
if(bytes != null && bytes.length>0){
|
|
|
MonitorDataEntity monitorDataEntity= (MonitorDataEntity) ByteArrayUtils.bytesToObject(bytes).get();
|
|
|
+ SimpleDateFormat formatdate = new SimpleDateFormat("YYYY-MM-dd");//日期算换格式
|
|
|
monDataCol.setCollectDate(monitorDataEntity.getCollectDate());
|
|
|
//筛选该设备相同属性的值
|
|
|
List<MonitorDataValueEntity> attributeEntities=monitorDataEntity.getDataValues().stream().filter((MonitorDataValueEntity m)
|
|
@@ -214,30 +216,32 @@ public class OnlineMonitorImpl implements OnlineMonitorService {
|
|
|
byte[] bytes = redisUtil.get(("sms_water_"+monitorData.getDeviceCode()).getBytes());
|
|
|
if(bytes != null && bytes.length>0) {
|
|
|
MonitorDataEntity monitorDataEntity = (MonitorDataEntity) ByteArrayUtils.bytesToObject(bytes).get();
|
|
|
- //筛选该设备相同属性的值
|
|
|
- List<MonitorDataValueEntity> attributeEntities = monitorDataEntity.getDataValues().stream().filter((MonitorDataValueEntity m)
|
|
|
- -> m.getAttributeId().equals(monitorData.getAttributeId())).collect(Collectors.toList());
|
|
|
- MonitorDataValueEntity attributeEntity=attributeEntities.size()>0?attributeEntities.get(0):null;
|
|
|
- if (attributeEntity != null) {
|
|
|
- Double attributeValue =0d;
|
|
|
- if(attributeEntity.getDataValue() != null && monitorData.getLatestValue() != null){
|
|
|
- attributeValue=attributeEntity.getDataValue() - monitorData.getLatestValue();
|
|
|
- }else if(attributeEntity.getDataValue() != null && monitorData.getLatestValue() == null) {
|
|
|
- attributeValue=attributeEntity.getDataValue();
|
|
|
- }
|
|
|
- switch (monitorData.getAttributeType()) {
|
|
|
- case "3":
|
|
|
- monDataCol.setYieldWaterUsage(monDataCol.getYieldWaterUsage() != null ? monDataCol.getYieldWaterUsage() + attributeValue : attributeValue);
|
|
|
- break;
|
|
|
- case "4":
|
|
|
- monDataCol.setIntakeWaterUsage(monDataCol.getIntakeWaterUsage() != null ? monDataCol.getIntakeWaterUsage() + attributeValue : attributeValue);
|
|
|
- break;
|
|
|
- case "5":
|
|
|
- monDataCol.setPowerUsage(monDataCol.getPowerUsage() != null ? monDataCol.getPowerUsage() + attributeValue : attributeValue);
|
|
|
- break;
|
|
|
- case "6":
|
|
|
- monDataCol.setDrugUsage(monDataCol.getDrugUsage() != null ? monDataCol.getDrugUsage() + attributeValue : attributeValue);
|
|
|
- break;
|
|
|
+ SimpleDateFormat formatdate = new SimpleDateFormat("YYYY-MM-dd");//日期算换格式
|
|
|
+ //计算今日数据
|
|
|
+ if(formatdate.format(new Date()).equals(monitorDataEntity.getCollectDate())) {
|
|
|
+ //筛选该设备相同属性的值
|
|
|
+ List<MonitorDataValueEntity> attributeEntities = monitorDataEntity.getDataValues().stream().filter((MonitorDataValueEntity m)
|
|
|
+ -> m.getAttributeId().equals(monitorData.getAttributeId())).collect(Collectors.toList());
|
|
|
+ MonitorDataValueEntity attributeEntity=attributeEntities.size()>0?attributeEntities.get(0):null;
|
|
|
+ if (attributeEntity != null) {
|
|
|
+ Double attributeValue =0d;
|
|
|
+ if(attributeEntity.getDataValue() != null && monitorData.getLatestValue() != null){
|
|
|
+ attributeValue=attributeEntity.getDataValue() - monitorData.getLatestValue();
|
|
|
+ }
|
|
|
+ switch (monitorData.getAttributeType()) {
|
|
|
+ case "3":
|
|
|
+ monDataCol.setYieldWaterUsage(monDataCol.getYieldWaterUsage() != null ? monDataCol.getYieldWaterUsage() + attributeValue : attributeValue);
|
|
|
+ break;
|
|
|
+ case "4":
|
|
|
+ monDataCol.setIntakeWaterUsage(monDataCol.getIntakeWaterUsage() != null ? monDataCol.getIntakeWaterUsage() + attributeValue : attributeValue);
|
|
|
+ break;
|
|
|
+ case "5":
|
|
|
+ monDataCol.setPowerUsage(monDataCol.getPowerUsage() != null ? monDataCol.getPowerUsage() + attributeValue : attributeValue);
|
|
|
+ break;
|
|
|
+ case "6":
|
|
|
+ monDataCol.setDrugUsage(monDataCol.getDrugUsage() != null ? monDataCol.getDrugUsage() + attributeValue : attributeValue);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -260,65 +264,70 @@ public class OnlineMonitorImpl implements OnlineMonitorService {
|
|
|
byte[] bytes = redisUtil.get(("sms_water_"+monitorData.getDeviceCode()).getBytes());
|
|
|
if(bytes != null && bytes.length>0) {
|
|
|
MonitorDataEntity monitorDataEntity = (MonitorDataEntity) ByteArrayUtils.bytesToObject(bytes).get();
|
|
|
- monDataCol.setCollectDate(monitorDataEntity.getCollectDate());
|
|
|
- //筛选该设备相同属性的值
|
|
|
- List<MonitorDataValueEntity> attributeEntities = monitorDataEntity.getDataValues().stream().filter((MonitorDataValueEntity m)
|
|
|
- -> m.getAttributeId().equals(monitorData.getAttributeId())).collect(Collectors.toList());
|
|
|
- MonitorDataValueEntity attributeEntity=attributeEntities.size()>0?attributeEntities.get(0):null;
|
|
|
- if (attributeEntity != null) {
|
|
|
- Double attributeValue =0d;
|
|
|
- if(attributeEntity.getDataValue() != null && monitorData.getLatestValue() != null){
|
|
|
- attributeValue=attributeEntity.getDataValue() - monitorData.getLatestValue();
|
|
|
- }else if(attributeEntity.getDataValue() != null && monitorData.getLatestValue() == null) {
|
|
|
- attributeValue=attributeEntity.getDataValue();
|
|
|
- }
|
|
|
- //实时数据
|
|
|
- monitorData.setDataValue(attributeEntity.getDataValue());
|
|
|
- monitorData.setUnit(attributeEntity.getUnit());
|
|
|
- switch (monitorData.getAttributeType()) {
|
|
|
- case "3"://供水量or出水量
|
|
|
- monDataCol.setYieldWaterUsage(monDataCol.getYieldWaterUsage() != null ? monDataCol.getYieldWaterUsage() + attributeValue : attributeValue);
|
|
|
- break;
|
|
|
- case "4"://取水量or进水量
|
|
|
- monDataCol.setIntakeWaterUsage(monDataCol.getIntakeWaterUsage() != null ? monDataCol.getIntakeWaterUsage() + attributeValue : attributeValue);
|
|
|
- break;
|
|
|
- case "5"://耗电量
|
|
|
- monDataCol.setPowerUsage(monDataCol.getPowerUsage() != null ? monDataCol.getPowerUsage() + attributeValue : attributeValue);
|
|
|
- break;
|
|
|
- case "6"://耗药量
|
|
|
- monDataCol.setDrugUsage(monDataCol.getDrugUsage() != null ? monDataCol.getDrugUsage() + attributeValue : attributeValue);
|
|
|
- break;
|
|
|
- case "7"://取水PHor进水PH
|
|
|
- monDataCol.setIntakePh(monitorData);
|
|
|
- break;
|
|
|
- case "8"://供水PHor出水PH
|
|
|
- monDataCol.setYieldPh(monitorData);
|
|
|
- break;
|
|
|
- case "9"://取水浊度or进水浊度
|
|
|
- monDataCol.setIntakeTurbidity(monitorData);
|
|
|
- break;
|
|
|
- case "10"://供水浊度or出水浊度
|
|
|
- monDataCol.setYieldTurbidity(monitorData);
|
|
|
- break;
|
|
|
- case "11"://余氯
|
|
|
- monDataCol.setResidualChlorine(monitorData);
|
|
|
- break;
|
|
|
- case "12"://水位
|
|
|
- monDataCol.setWaterLevel(monitorData);
|
|
|
- break;
|
|
|
- case "13"://压力
|
|
|
- monDataCol.setPressure(monitorData);
|
|
|
- break;
|
|
|
- case "14"://瞬时流量
|
|
|
- monDataCol.setInstantFlow(monitorData);
|
|
|
- break;
|
|
|
- case "2"://水泵状态
|
|
|
- DecimalFormat decimalFormat = new DecimalFormat("###################.###########");//去掉末尾小数点
|
|
|
- String specsValue = attributeEntity.getDataValue() == null ? null : decimalFormat.format(attributeEntity.getDataValue());
|
|
|
- monitorData.setSpecsName(specsValue == null ? null : deviceAttributeSpecsService.selectSpecsName(attributeEntity.getAttributeId(), specsValue));
|
|
|
- pumpStatus.add(monitorData);
|
|
|
- monDataCol.setPumpStatus(pumpStatus);
|
|
|
- break;
|
|
|
+ monDataCol.setCollectDate(monitorDataEntity.getCollectDate());
|
|
|
+ //筛选该设备相同属性的值
|
|
|
+ List<MonitorDataValueEntity> attributeEntities = monitorDataEntity.getDataValues().stream().filter((MonitorDataValueEntity m)
|
|
|
+ -> m.getAttributeId().equals(monitorData.getAttributeId())).collect(Collectors.toList());
|
|
|
+ MonitorDataValueEntity attributeEntity=attributeEntities.size()>0?attributeEntities.get(0):null;
|
|
|
+ if (attributeEntity != null) {
|
|
|
+ //实时数据
|
|
|
+ monitorData.setDataValue(attributeEntity.getDataValue());
|
|
|
+ monitorData.setUnit(attributeEntity.getUnit());
|
|
|
+ SimpleDateFormat formatdate = new SimpleDateFormat("YYYY-MM-dd");//日期算换格式
|
|
|
+ //计算今日数据
|
|
|
+ if(formatdate.format(new Date()).equals(monitorDataEntity.getCollectDate())) {
|
|
|
+ Double attributeValue =0d;
|
|
|
+ if(attributeEntity.getDataValue() != null && monitorData.getLatestValue() != null){
|
|
|
+ attributeValue=attributeEntity.getDataValue() - monitorData.getLatestValue();
|
|
|
+ }
|
|
|
+ switch (monitorData.getAttributeType()) {
|
|
|
+ case "3"://供水量or出水量
|
|
|
+ monDataCol.setYieldWaterUsage(monDataCol.getYieldWaterUsage() != null ? monDataCol.getYieldWaterUsage() + attributeValue : attributeValue);
|
|
|
+ break;
|
|
|
+ case "4"://取水量or进水量
|
|
|
+ monDataCol.setIntakeWaterUsage(monDataCol.getIntakeWaterUsage() != null ? monDataCol.getIntakeWaterUsage() + attributeValue : attributeValue);
|
|
|
+ break;
|
|
|
+ case "5"://耗电量
|
|
|
+ monDataCol.setPowerUsage(monDataCol.getPowerUsage() != null ? monDataCol.getPowerUsage() + attributeValue : attributeValue);
|
|
|
+ break;
|
|
|
+ case "6"://耗药量
|
|
|
+ monDataCol.setDrugUsage(monDataCol.getDrugUsage() != null ? monDataCol.getDrugUsage() + attributeValue : attributeValue);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (monitorData.getAttributeType()) {
|
|
|
+ case "7"://取水PHor进水PH
|
|
|
+ monDataCol.setIntakePh(monitorData);
|
|
|
+ break;
|
|
|
+ case "8"://供水PHor出水PH
|
|
|
+ monDataCol.setYieldPh(monitorData);
|
|
|
+ break;
|
|
|
+ case "9"://取水浊度or进水浊度
|
|
|
+ monDataCol.setIntakeTurbidity(monitorData);
|
|
|
+ break;
|
|
|
+ case "10"://供水浊度or出水浊度
|
|
|
+ monDataCol.setYieldTurbidity(monitorData);
|
|
|
+ break;
|
|
|
+ case "11"://余氯
|
|
|
+ monDataCol.setResidualChlorine(monitorData);
|
|
|
+ break;
|
|
|
+ case "12"://水位
|
|
|
+ monDataCol.setWaterLevel(monitorData);
|
|
|
+ break;
|
|
|
+ case "13"://压力
|
|
|
+ monDataCol.setPressure(monitorData);
|
|
|
+ break;
|
|
|
+ case "14"://瞬时流量
|
|
|
+ monDataCol.setInstantFlow(monitorData);
|
|
|
+ break;
|
|
|
+ case "2"://水泵状态
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("###################.###########");//去掉末尾小数点
|
|
|
+ String specsValue = attributeEntity.getDataValue() == null ? null : decimalFormat.format(attributeEntity.getDataValue());
|
|
|
+ monitorData.setSpecsName(specsValue == null ? null : deviceAttributeSpecsService.selectSpecsName(attributeEntity.getAttributeId(), specsValue));
|
|
|
+ pumpStatus.add(monitorData);
|
|
|
+ monDataCol.setPumpStatus(pumpStatus);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -326,5 +335,4 @@ public class OnlineMonitorImpl implements OnlineMonitorService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
}
|