|
|
|
@ -731,16 +731,30 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag |
|
|
|
result.forEach(dto -> dto.setFreq2(new BigDecimal(freq2.getCollectValue()).setScale(2, RoundingMode.HALF_UP).toString())); |
|
|
|
result.forEach(dto -> dto.setFreq2(new BigDecimal(freq2.getCollectValue()).setScale(2, RoundingMode.HALF_UP).toString())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 处理水箱,水箱绑定了补水阀参数(deviceType=16)
|
|
|
|
// 处理水箱:液位、温度
|
|
|
|
List<DeviceMonitorVO> waterValves = collectionParamsManageMapper.selectHotWaterBySystemTypeAndBuildingIdAndDeviceType(systemType, floorId, "16"); |
|
|
|
List<DeviceMonitorVO> waterValves = collectionParamsManageMapper.selectHotWaterBySystemTypeAndBuildingIdAndDeviceType(systemType, floorId, "17"); |
|
|
|
if (!waterValves.isEmpty()) { |
|
|
|
if (!waterValves.isEmpty()) { |
|
|
|
// 判断是否存在collectValue>0的记录
|
|
|
|
// 遍历液位
|
|
|
|
boolean useWaterState = waterValves.stream() |
|
|
|
waterValves.stream() |
|
|
|
.anyMatch(vo -> "2".equals(vo.getParamType()) |
|
|
|
.filter(vo -> "11".equals(vo.getParamType()) && vo.getCollectValue() != null) |
|
|
|
&& vo.getCollectValue() != null |
|
|
|
.forEach(vo -> { |
|
|
|
&& new BigDecimal(vo.getCollectValue()).intValue() > 0); |
|
|
|
if (vo.getOrderNum()==1) { |
|
|
|
// 根据判断结果设置状态值
|
|
|
|
result.forEach(dto -> dto.setWaterLevel1(vo.getCollectValue())); |
|
|
|
result.forEach(dto -> dto.setUseWaterState(useWaterState ? "1" : "0")); |
|
|
|
} else if (vo.getOrderNum()==2) { |
|
|
|
|
|
|
|
result.forEach(dto -> dto.setWaterLevel2(vo.getCollectValue())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
// 遍历温度
|
|
|
|
|
|
|
|
waterValves.stream() |
|
|
|
|
|
|
|
.filter(vo -> "12".equals(vo.getParamType()) && vo.getCollectValue() != null) |
|
|
|
|
|
|
|
.forEach(vo -> { |
|
|
|
|
|
|
|
if (vo.getOrderNum()==1) { |
|
|
|
|
|
|
|
result.forEach(dto -> dto.setTankWaterTemp(vo.getCollectValue())); |
|
|
|
|
|
|
|
} else if (vo.getOrderNum()==2) { |
|
|
|
|
|
|
|
result.forEach(dto -> dto.setTankWaterTemp2(vo.getCollectValue())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 处理回水阀(deviceType=22)
|
|
|
|
// 处理回水阀(deviceType=22)
|
|
|
|
@ -756,43 +770,43 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 处理水箱液位(deviceType=16)
|
|
|
|
// // 处理水箱液位(deviceType=16)
|
|
|
|
List<DeviceMonitorVO> waterLevels = collectionParamsManageMapper.selectHotWaterBySystemTypeAndBuildingIdAndDeviceType(systemType, floorId, "16"); |
|
|
|
// List<DeviceMonitorVO> waterLevels = collectionParamsManageMapper.selectHotWaterBySystemTypeAndBuildingIdAndDeviceType(systemType, floorId, "16");
|
|
|
|
if (!waterLevels.isEmpty()) { |
|
|
|
// if (!waterLevels.isEmpty()) {
|
|
|
|
// 计算levelSet平均值(paramType=10)
|
|
|
|
// // 计算levelSet平均值(paramType=10)
|
|
|
|
Double levelSetAvg = waterLevels.stream() |
|
|
|
// Double levelSetAvg = waterLevels.stream()
|
|
|
|
.filter(vo -> vo.getParamType().equals("10")) |
|
|
|
// .filter(vo -> vo.getParamType().equals("10"))
|
|
|
|
.mapToDouble(vo -> { |
|
|
|
// .mapToDouble(vo -> {
|
|
|
|
try { |
|
|
|
// try {
|
|
|
|
return Double.parseDouble(vo.getCollectValue()); |
|
|
|
// return Double.parseDouble(vo.getCollectValue());
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
// } catch (NumberFormatException e) {
|
|
|
|
log.error("数值转换失败:设备ID={} 值={}", vo.getId(), vo.getCollectValue()); |
|
|
|
// log.error("数值转换失败:设备ID={} 值={}", vo.getId(), vo.getCollectValue());
|
|
|
|
return 0.0; // 返回默认值
|
|
|
|
// return 0.0; // 返回默认值
|
|
|
|
} |
|
|
|
// }
|
|
|
|
}) |
|
|
|
// })
|
|
|
|
.average() |
|
|
|
// .average()
|
|
|
|
.orElse(0.0); |
|
|
|
// .orElse(0.0);
|
|
|
|
|
|
|
|
//
|
|
|
|
// 计算waterLevel平均值(paramType=11)
|
|
|
|
// // 计算waterLevel平均值(paramType=11)
|
|
|
|
Double waterLevelAvg = waterLevels.stream() |
|
|
|
// Double waterLevelAvg = waterLevels.stream()
|
|
|
|
.filter(vo -> vo.getParamType().equals("11")) |
|
|
|
// .filter(vo -> vo.getParamType().equals("11"))
|
|
|
|
.mapToDouble(vo -> { |
|
|
|
// .mapToDouble(vo -> {
|
|
|
|
try { |
|
|
|
// try {
|
|
|
|
return Double.parseDouble(vo.getCollectValue()); |
|
|
|
// return Double.parseDouble(vo.getCollectValue());
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
// } catch (NumberFormatException e) {
|
|
|
|
log.error("数值转换失败:设备ID={} 值={}", vo.getId(), vo.getCollectValue()); |
|
|
|
// log.error("数值转换失败:设备ID={} 值={}", vo.getId(), vo.getCollectValue());
|
|
|
|
return 0.0; // 返回默认值
|
|
|
|
// return 0.0; // 返回默认值
|
|
|
|
} |
|
|
|
// }
|
|
|
|
}) |
|
|
|
// })
|
|
|
|
.average() |
|
|
|
// .average()
|
|
|
|
.orElse(0.0); |
|
|
|
// .orElse(0.0);
|
|
|
|
|
|
|
|
//
|
|
|
|
// 设置平均值到所有DTO(根据业务需求调整)
|
|
|
|
// // 设置平均值到所有DTO(根据业务需求调整)
|
|
|
|
result.forEach(dto -> { |
|
|
|
// result.forEach(dto -> {
|
|
|
|
dto.setLevelSet(String.format("%.2f", levelSetAvg)); |
|
|
|
// dto.setLevelSet(String.format("%.2f", levelSetAvg));
|
|
|
|
dto.setWaterLevel(String.format("%.2f", waterLevelAvg)); |
|
|
|
// dto.setWaterLevel(String.format("%.2f", waterLevelAvg));
|
|
|
|
}); |
|
|
|
// });
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// result再根据orderNum排序
|
|
|
|
// result再根据orderNum排序
|
|
|
|
return result.stream() |
|
|
|
return result.stream() |
|
|
|
|