|
|
|
@ -122,6 +122,43 @@ public class NowDataController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 多路控制设备名称常量
|
|
|
|
|
|
|
|
private static final String[] MULTI_CONTROL_PUMP_NAMES = { |
|
|
|
|
|
|
|
"1号供水泵", "2号供水泵", "1号抽水泵", "2号抽水泵", "补水电磁阀" |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
private static final String[] WATER_SUPPLY_PUMP_NAMES = { |
|
|
|
|
|
|
|
"1号供水泵", "2号供水泵", "补水电磁阀" |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 创建设备记录并保存 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void createAndSaveDeviceRecord(String pumpId, String pumpName, String buildingId, |
|
|
|
|
|
|
|
String buildingName, String curDate) { |
|
|
|
|
|
|
|
NowDataEntity nowData = new NowDataEntity(); |
|
|
|
|
|
|
|
nowData.setPumpId(pumpId); |
|
|
|
|
|
|
|
nowData.setPumpName(pumpName); |
|
|
|
|
|
|
|
nowData.setBuildingId(buildingId); |
|
|
|
|
|
|
|
nowData.setBuildingName(buildingName); |
|
|
|
|
|
|
|
nowData.setRunState("0"); |
|
|
|
|
|
|
|
nowData.setIsFault("0"); |
|
|
|
|
|
|
|
nowData.setCurDate(curDate); |
|
|
|
|
|
|
|
nowDataService.saveNowData(nowData); //当前状态表
|
|
|
|
|
|
|
|
nowDataService.saveHistoryData(nowData); //历史状态表
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 批量创建设备记录 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void batchCreateDeviceRecords(List<DeviceModel> deviceList, String[] pumpNames, |
|
|
|
|
|
|
|
String buildingId, String buildingName, String curDate) { |
|
|
|
|
|
|
|
for (DeviceModel device : deviceList) { |
|
|
|
|
|
|
|
for (String pumpName : pumpNames) { |
|
|
|
|
|
|
|
createAndSaveDeviceRecord(device.getDeviceAddr(), pumpName, buildingId, buildingName, curDate); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@SysLogger(title = "实时监控", optDesc = "实时查看每楼栋多路控制运行情况") |
|
|
|
@SysLogger(title = "实时监控", optDesc = "实时查看每楼栋多路控制运行情况") |
|
|
|
@PostMapping("/queryMultiNow") |
|
|
|
@PostMapping("/queryMultiNow") |
|
|
|
public HttpResult queryMultiNowData(@RequestParam(value = "buildingId") String buildingId) { |
|
|
|
public HttpResult queryMultiNowData(@RequestParam(value = "buildingId") String buildingId) { |
|
|
|
@ -131,85 +168,48 @@ public class NowDataController { |
|
|
|
String maxWaterTemp = nowDataService.selectMaxTemp(buildingId); |
|
|
|
String maxWaterTemp = nowDataService.selectMaxTemp(buildingId); |
|
|
|
String buildingName = buildingService.queryBuildingName(buildingId);//获取楼栋名称
|
|
|
|
String buildingName = buildingService.queryBuildingName(buildingId);//获取楼栋名称
|
|
|
|
|
|
|
|
|
|
|
|
// SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
// Date date = new Date();
|
|
|
|
|
|
|
|
// String curDate = sdf1.format(date);
|
|
|
|
|
|
|
|
// curDate = curDate.substring(0, 13) + ":00:00";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String curDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:00:00")); |
|
|
|
String curDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:00:00")); |
|
|
|
|
|
|
|
|
|
|
|
NowPublicDataEntity nowPublicData = new NowPublicDataEntity(); |
|
|
|
NowPublicDataEntity nowPublicData = new NowPublicDataEntity(); |
|
|
|
nowPublicData.setBuildingId(buildingId); |
|
|
|
nowPublicData.setBuildingId(buildingId); |
|
|
|
nowPublicData.setBuildingName(buildingName); |
|
|
|
nowPublicData.setBuildingName(buildingName); |
|
|
|
if (avgWaterTemp != null) { |
|
|
|
nowPublicData.setBackWaterTemp(avgWaterTemp != null ? avgWaterTemp : "0"); |
|
|
|
nowPublicData.setBackWaterTemp(avgWaterTemp); |
|
|
|
nowPublicData.setUseWaterTemp(maxWaterTemp != null ? maxWaterTemp : "0"); |
|
|
|
} else { |
|
|
|
|
|
|
|
nowPublicData.setBackWaterTemp("0"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (maxWaterTemp != null) { |
|
|
|
|
|
|
|
nowPublicData.setUseWaterTemp(maxWaterTemp); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
nowPublicData.setUseWaterTemp("0"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
nowPublicDataService.saveNowHistoryPublicData(nowPublicData); |
|
|
|
nowPublicDataService.saveNowHistoryPublicData(nowPublicData); |
|
|
|
|
|
|
|
|
|
|
|
//监视表生成初始记录
|
|
|
|
//监视表生成初始记录
|
|
|
|
List<NowDataEntity> list = nowDataService.queryNowData(buildingId); |
|
|
|
List<NowDataEntity> list = nowDataService.queryNowData(buildingId); |
|
|
|
if (list.isEmpty()) {//实时表生成记录
|
|
|
|
if (list.isEmpty()) { |
|
|
|
|
|
|
|
// 多路控制设备
|
|
|
|
List<DeviceModel> deviceList = deviceInstallService.selectDevices(buildingId, "多路控制"); |
|
|
|
List<DeviceModel> deviceList = deviceInstallService.selectDevices(buildingId, "多路控制"); |
|
|
|
if (!deviceList.isEmpty()) { |
|
|
|
batchCreateDeviceRecords(deviceList, MULTI_CONTROL_PUMP_NAMES, buildingId, buildingName, curDate); |
|
|
|
for (DeviceModel list2 : deviceList) { |
|
|
|
|
|
|
|
NowDataEntity nowData = new NowDataEntity(); |
|
|
|
|
|
|
|
nowData.setPumpId(list2.getDeviceAddr()); |
|
|
|
|
|
|
|
nowData.setPumpName("1号供水泵"); |
|
|
|
|
|
|
|
nowData.setBuildingId(buildingId); |
|
|
|
|
|
|
|
nowData.setBuildingName(buildingName); |
|
|
|
|
|
|
|
nowData.setRunState("0"); |
|
|
|
|
|
|
|
nowData.setIsFault("0"); |
|
|
|
|
|
|
|
nowData.setCurDate(curDate); |
|
|
|
|
|
|
|
nowDataService.saveNowData(nowData); //当前状态表
|
|
|
|
|
|
|
|
nowDataService.saveHistoryData(nowData); //历史状态表
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nowData.setPumpId(list2.getDeviceAddr()); |
|
|
|
// 供水泵设备
|
|
|
|
nowData.setPumpName("2号供水泵"); |
|
|
|
deviceList = deviceInstallService.selectDevices(buildingId, "供水泵"); |
|
|
|
nowData.setBuildingId(buildingId); |
|
|
|
batchCreateDeviceRecords(deviceList, WATER_SUPPLY_PUMP_NAMES, buildingId, buildingName, curDate); |
|
|
|
nowData.setBuildingName(buildingName); |
|
|
|
|
|
|
|
nowData.setRunState("0"); |
|
|
|
|
|
|
|
nowData.setIsFault("0"); |
|
|
|
|
|
|
|
nowData.setCurDate(curDate); |
|
|
|
|
|
|
|
nowDataService.saveNowData(nowData); //当前状态表
|
|
|
|
|
|
|
|
nowDataService.saveHistoryData(nowData); //历史状态表
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nowData.setPumpId(list2.getDeviceAddr()); |
|
|
|
// 补水电磁阀
|
|
|
|
nowData.setPumpName("1号抽水泵"); |
|
|
|
deviceList = deviceInstallService.selectDevices(buildingId, "补水电磁阀"); |
|
|
|
nowData.setBuildingId(buildingId); |
|
|
|
for (DeviceModel device : deviceList) { |
|
|
|
nowData.setBuildingName(buildingName); |
|
|
|
createAndSaveDeviceRecord(device.getDeviceAddr(), "补水电磁阀", buildingId, buildingName, curDate); |
|
|
|
nowData.setRunState("0"); |
|
|
|
} |
|
|
|
nowData.setIsFault("0"); |
|
|
|
|
|
|
|
nowData.setCurDate(curDate); |
|
|
|
|
|
|
|
nowDataService.saveNowData(nowData); //当前状态表
|
|
|
|
|
|
|
|
nowDataService.saveHistoryData(nowData); //历史状态表
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nowData.setPumpId(list2.getDeviceAddr()); |
|
|
|
// 单箱电磁阀
|
|
|
|
nowData.setPumpName("2号抽水泵"); |
|
|
|
deviceList = deviceInstallService.selectDevices(buildingId, "单箱电磁阀"); |
|
|
|
nowData.setBuildingId(buildingId); |
|
|
|
for (DeviceModel device : deviceList) { |
|
|
|
nowData.setBuildingName(buildingName); |
|
|
|
createAndSaveDeviceRecord(device.getDeviceAddr(), "单箱电磁阀", buildingId, buildingName, curDate); |
|
|
|
nowData.setRunState("0"); |
|
|
|
} |
|
|
|
nowData.setIsFault("0"); |
|
|
|
|
|
|
|
nowData.setCurDate(curDate); |
|
|
|
|
|
|
|
nowDataService.saveNowData(nowData); //当前状态表
|
|
|
|
|
|
|
|
nowDataService.saveHistoryData(nowData); //历史状态表
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nowData.setPumpId(list2.getDeviceAddr()); |
|
|
|
// 多箱电磁阀
|
|
|
|
nowData.setPumpName("补水电磁阀"); |
|
|
|
deviceList = deviceInstallService.selectDevices(buildingId, "多箱电磁阀"); |
|
|
|
nowData.setBuildingId(buildingId); |
|
|
|
for (DeviceModel device : deviceList) { |
|
|
|
nowData.setBuildingName(buildingName); |
|
|
|
createAndSaveDeviceRecord(device.getDeviceAddr(), "多箱电磁阀", buildingId, buildingName, curDate); |
|
|
|
nowData.setRunState("0"); |
|
|
|
|
|
|
|
nowData.setIsFault("0"); |
|
|
|
|
|
|
|
nowData.setCurDate(curDate); |
|
|
|
|
|
|
|
nowDataService.saveNowData(nowData); //当前状态表
|
|
|
|
|
|
|
|
nowDataService.saveHistoryData(nowData); //历史状态表
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 多箱电动阀
|
|
|
|
|
|
|
|
deviceList = deviceInstallService.selectDevices(buildingId, "多箱电动阀"); |
|
|
|
|
|
|
|
for (DeviceModel device : deviceList) { |
|
|
|
|
|
|
|
createAndSaveDeviceRecord(device.getDeviceAddr(), "多箱电动阀", buildingId, buildingName, curDate); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
List<MultiControlModel> resultList = nowDataService.queryMultiControlNowData(buildingId); |
|
|
|
List<MultiControlModel> resultList = nowDataService.queryMultiControlNowData(buildingId); |
|
|
|
@ -227,7 +227,7 @@ public class NowDataController { |
|
|
|
NowDataEntity nowDataEntity = nowDataService.queryNowDataByPump(buildingId, pumpId); |
|
|
|
NowDataEntity nowDataEntity = nowDataService.queryNowDataByPump(buildingId, pumpId); |
|
|
|
return HttpResult.ok(nowDataEntity); |
|
|
|
return HttpResult.ok(nowDataEntity); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
log.error("按热泵查询当前监控状态出错!", e); |
|
|
|
return HttpResult.error("按热泵查询当前监控状态出错!"); |
|
|
|
return HttpResult.error("按热泵查询当前监控状态出错!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|