From 5fb572cd4dbda88099a2188d010a61c8dcabf010 Mon Sep 17 00:00:00 2001 From: 25604 Date: Thu, 21 Aug 2025 14:30:19 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E5=A4=8D=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E6=8A=A5=E8=AD=A6=E3=80=81=E7=83=AD=E6=B0=B4=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E7=94=9F=E6=88=90=EF=BC=9B=202=E3=80=81=E4=B8=BB=E6=9C=BA?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E6=8A=A5=E8=A1=A8=E7=9B=B8=E5=85=B3=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=B7=BB=E5=8A=A0=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/space/SpaceController.java | 5 + .../src/main/resources/application-dev.yml | 4 +- mh-admin/src/main/resources/application.yml | 2 +- .../test/java/com/mh/MHApplicationTest.java | 9 + .../core/domain/dto/HotWaterNowDataDTO.java | 6 +- .../domain/dto/MaglevReportSysParamDTO.java | 60 +++---- .../domain/entity/ReportSysRunParamHis.java | 26 ++- .../com/mh/common/utils/BigDecimalUtils.java | 12 ++ .../java/com/mh/quartz/task/ChillersTask.java | 27 +++ .../com/mh/quartz/task/CreateAlarmTask.java | 7 +- .../mh/quartz/task/PushDataToWechatTask.java | 2 +- .../device/CollectionParamsManageMapper.java | 20 ++- .../mapper/device/DataProcessMapper.java | 2 +- .../mapper/device/MaintainInfoMapper.java | 2 +- .../mapper/energy/HotEnergyQueryMapper.java | 2 +- .../report/ReportSysRunParamHisMapper.java | 2 +- .../CollectionParamsManageServiceImpl.java | 86 +++++++-- .../impl/AlarmRecordsServiceImpl.java | 8 +- .../report/impl/ReportSysServiceImpl.java | 8 +- .../service/space/IHouseInfoService.java | 2 + .../space/impl/HouseInfoServiceImpl.java | 165 +++++++++++++++++- 21 files changed, 375 insertions(+), 82 deletions(-) create mode 100644 mh-quartz/src/main/java/com/mh/quartz/task/ChillersTask.java diff --git a/mh-admin/src/main/java/com/mh/web/controller/space/SpaceController.java b/mh-admin/src/main/java/com/mh/web/controller/space/SpaceController.java index fc05d71..a40c41b 100644 --- a/mh-admin/src/main/java/com/mh/web/controller/space/SpaceController.java +++ b/mh-admin/src/main/java/com/mh/web/controller/space/SpaceController.java @@ -29,4 +29,9 @@ public class SpaceController extends BaseController { return AjaxResult.success(houseInfoService.buildTree(systemType)); } + @GetMapping("/floorTree") + public AjaxResult floorTree(@RequestParam(value = "systemType", required = false) String systemType) { + return AjaxResult.success(houseInfoService.buildFloorTree(systemType)); + } + } diff --git a/mh-admin/src/main/resources/application-dev.yml b/mh-admin/src/main/resources/application-dev.yml index d1a085c..7bb00e7 100644 --- a/mh-admin/src/main/resources/application-dev.yml +++ b/mh-admin/src/main/resources/application-dev.yml @@ -98,8 +98,8 @@ spring: # 主库数据源 master: #添加allowMultiQueries=true 在批量更新时才不会出错 -# url: jdbc:postgresql://127.0.0.1:5432/eemcs_hw_dev - url: jdbc:postgresql://127.0.0.1:5432/eemcs +# url: jdbc:postgresql://127.0.0.1:5432/eemcs + url: jdbc:postgresql://106.55.173.225:5505/eemcs username: postgres password: mh@803 # 从库数据源 diff --git a/mh-admin/src/main/resources/application.yml b/mh-admin/src/main/resources/application.yml index c3ae7c3..44f7920 100644 --- a/mh-admin/src/main/resources/application.yml +++ b/mh-admin/src/main/resources/application.yml @@ -1,6 +1,6 @@ spring: profiles: - active: dev + active: prod # 用户配置 user: diff --git a/mh-admin/src/test/java/com/mh/MHApplicationTest.java b/mh-admin/src/test/java/com/mh/MHApplicationTest.java index 8383426..905a2ae 100644 --- a/mh-admin/src/test/java/com/mh/MHApplicationTest.java +++ b/mh-admin/src/test/java/com/mh/MHApplicationTest.java @@ -15,6 +15,7 @@ import com.mh.system.mapper.device.DataProcessMapper; import com.mh.system.service.ISysParamsService; import com.mh.system.service.ISysUserService; import com.mh.system.service.device.IDeviceQrManageService; +import com.mh.system.service.operation.IAlarmRecordsService; import jakarta.annotation.Resource; import org.checkerframework.checker.units.qual.A; import org.junit.jupiter.api.Test; @@ -44,6 +45,14 @@ public class MHApplicationTest { @Autowired private HotWaterTask hotWaterTask; + @Autowired + private IAlarmRecordsService alarmRecordsService; + + @Test + public void createAlarmTask() { + alarmRecordsService.insertOrUpdateAlarmRecord("e1a3034edw6a9b3a79a86332886b24896"); + } + @Test public void calcAnalysisData() { for (int i = 9; i < 10; i++) { diff --git a/mh-common/src/main/java/com/mh/common/core/domain/dto/HotWaterNowDataDTO.java b/mh-common/src/main/java/com/mh/common/core/domain/dto/HotWaterNowDataDTO.java index bdded5a..82b6471 100644 --- a/mh-common/src/main/java/com/mh/common/core/domain/dto/HotWaterNowDataDTO.java +++ b/mh-common/src/main/java/com/mh/common/core/domain/dto/HotWaterNowDataDTO.java @@ -22,8 +22,10 @@ public class HotWaterNowDataDTO { private String waterTemp; //水箱水温 private String runState; //运行状态 private String isFault; //是否故障 - private String levelSet; //水位设置 - private String waterLevel; //实际水位 + private String levelSet1; //水位设置 + private String levelSet2; //水位设置 + private String waterLevel1; //实际水位 + private String waterLevel2; //实际水位 private String tankId; //水箱编号 private String tankName; //水箱名称 private String envTemp; //环境温度 diff --git a/mh-common/src/main/java/com/mh/common/core/domain/dto/MaglevReportSysParamDTO.java b/mh-common/src/main/java/com/mh/common/core/domain/dto/MaglevReportSysParamDTO.java index 8062ace..24d05c5 100644 --- a/mh-common/src/main/java/com/mh/common/core/domain/dto/MaglevReportSysParamDTO.java +++ b/mh-common/src/main/java/com/mh/common/core/domain/dto/MaglevReportSysParamDTO.java @@ -56,207 +56,207 @@ public class MaglevReportSysParamDTO { * 冷冻水进水温度℃ */ @ColumnWidth(10) - @ExcelProperty(value = {"${deviceType}", "蒸发器", "冷冻水进水温度℃"}, index = 2) + @ExcelProperty(value = {"${deviceType}", "蒸发器", "冷冻水进水温度℃"}, index = 1) private BigDecimal tempInChillerWater; /** * 冷冻水出水温度℃ */ - @ExcelProperty(value = {"${deviceType}", "蒸发器", "冷冻水出水温度℃"}, index = 3) + @ExcelProperty(value = {"${deviceType}", "蒸发器", "冷冻水出水温度℃"}, index = 2) @ColumnWidth(10) private BigDecimal tempOutChillerWater; /** * 设计流量% */ - @ExcelProperty(value = {"${deviceType}", "蒸发器", "设计流量%"}, index = 4) + @ExcelProperty(value = {"${deviceType}", "蒸发器", "设计流量%"}, index = 3) @ColumnWidth(10) private BigDecimal designFlow; /** * 蒸发器压力kpa */ - @ExcelProperty(value = {"${deviceType}", "蒸发器", "蒸发器压力kpa"}, index = 5) + @ExcelProperty(value = {"${deviceType}", "蒸发器", "蒸发器压力kpa"}, index = 4) @ColumnWidth(10) private BigDecimal pressEvapSaturation; /** * 蒸发器饱和温度℃ */ - @ExcelProperty(value = {"${deviceType}", "蒸发器", "蒸发器饱和温度℃"}, index = 6) + @ExcelProperty(value = {"${deviceType}", "蒸发器", "蒸发器饱和温度℃"}, index = 5) @ColumnWidth(10) private BigDecimal tempEvapSaturation; /** * 趋近温度℃ */ - @ExcelProperty(value = {"${deviceType}", "蒸发器", "趋近温度℃"}, index = 7) + @ExcelProperty(value = {"${deviceType}", "蒸发器", "趋近温度℃"}, index = 6) @ColumnWidth(10) private BigDecimal tempEvapApproaching; /** * 冷却水进水温度℃ */ - @ExcelProperty(value = {"${deviceType}", "冷凝器", "冷却水进水温度℃"}, index = 8) + @ExcelProperty(value = {"${deviceType}", "冷凝器", "冷却水进水温度℃"}, index = 7) @ColumnWidth(10) private BigDecimal tempInCoolingWater; /** * 冷却水出水温度℃ */ - @ExcelProperty(value = {"${deviceType}", "冷凝器", "冷却水出水温度℃"}, index = 9) + @ExcelProperty(value = {"${deviceType}", "冷凝器", "冷却水出水温度℃"}, index = 8) @ColumnWidth(10) private BigDecimal tempOutCoolingWater; /** * 冷凝器压力kpa */ - @ExcelProperty(value = {"${deviceType}", "冷凝器", "冷凝器压力kpa"}, index = 10) + @ExcelProperty(value = {"${deviceType}", "冷凝器", "冷凝器压力kpa"}, index = 9) @ColumnWidth(10) private BigDecimal pressCondenserSaturation; /** * 冷凝器饱和温度℃ */ - @ExcelProperty(value = {"${deviceType}", "冷凝器", "冷凝器饱和温度℃"}, index = 11) + @ExcelProperty(value = {"${deviceType}", "冷凝器", "冷凝器饱和温度℃"}, index = 10) @ColumnWidth(10) private BigDecimal tempCondenserSaturation; /** * 冷凝器趋近温度℃ */ - @ExcelProperty(value = {"${deviceType}", "冷凝器", "趋近温度℃"}, index = 12) + @ExcelProperty(value = {"${deviceType}", "冷凝器", "趋近温度℃"}, index = 11) @ColumnWidth(10) private BigDecimal tempCondenserApproaching; /** * 冷冻水设定值 */ - @ExcelProperty(value = {"${deviceType}", "系统", "冷冻水设定值℃"}, index = 13) + @ExcelProperty(value = {"${deviceType}", "系统", "冷冻水设定值℃"}, index = 12) @ColumnWidth(10) private BigDecimal setChillerWater; /** * 冷水机需求% */ - @ExcelProperty(value = {"${deviceType}", "系统", "冷水机需求%"}, index = 14) + @ExcelProperty(value = {"${deviceType}", "系统", "冷水机需求%"}, index = 13) @ColumnWidth(10) private BigDecimal setLoad; /** * 总电流A */ - @ExcelProperty(value = {"${deviceType}", "系统", "总电流A"}, index = 15) + @ExcelProperty(value = {"${deviceType}", "系统", "总电流A"}, index = 14) @ColumnWidth(10) private BigDecimal currentTotal; /** * 总输入功率kw */ - @ExcelProperty(value = {"${deviceType}", "系统", "总输入功率kw"}, index = 16) + @ExcelProperty(value = {"${deviceType}", "系统", "总输入功率kw"}, index = 15) @ColumnWidth(10) private BigDecimal inputPowerTotal; /** * 压缩比 */ - @ExcelProperty(value = {"${deviceType}", "系统", "压缩比"}, index = 17) + @ExcelProperty(value = {"${deviceType}", "系统", "压缩比"}, index = 16) @ColumnWidth(10) private BigDecimal ratioComp; /** * 膨胀阀开度% */ - @ExcelProperty(value = {"${deviceType}", "系统", "膨胀阀开度%"}, index = 18) + @ExcelProperty(value = {"${deviceType}", "系统", "膨胀阀开度%"}, index = 17) @ColumnWidth(10) private BigDecimal openExv; /** * 运行中的压缩机数量 */ - @ExcelProperty(value = {"${deviceType}", "系统", "运行中的压缩机数量"}, index = 19) + @ExcelProperty(value = {"${deviceType}", "系统", "运行中的压缩机数量"}, index = 18) @ColumnWidth(10) private Integer runCompNum; /** * 冷冻水泵频率hz */ - @ExcelProperty(value = {"${deviceType}", "冷冻泵", "冷冻水泵频率hz"}, index = 20) + @ExcelProperty(value = {"${deviceType}", "冷冻泵", "冷冻水泵频率hz"}, index = 19) @ColumnWidth(10) private BigDecimal frequencyChiller; /** * 冷冻水进水压力kpa */ - @ExcelProperty(value = {"${deviceType}", "冷冻泵", "冷冻水进水压力kpa"}, index = 21) + @ExcelProperty(value = {"${deviceType}", "冷冻泵", "冷冻水进水压力kpa"}, index = 20) @ColumnWidth(10) private BigDecimal pressInChillerWater; /** * 冷冻水出水压力kpa */ - @ExcelProperty(value = {"${deviceType}", "冷冻泵", "冷冻水出水压力kpa"}, index = 22) + @ExcelProperty(value = {"${deviceType}", "冷冻泵", "冷冻水出水压力kpa"}, index = 21) @ColumnWidth(10) private BigDecimal pressOutChillerWater; /** * 冷却水泵频率hz */ - @ExcelProperty(value = {"${deviceType}", "冷却泵", "冷却水泵频率hz"}, index = 23) + @ExcelProperty(value = {"${deviceType}", "冷却泵", "冷却水泵频率hz"}, index = 22) @ColumnWidth(10) private BigDecimal frequencyCooling; /** * 冷却水进水压力kpa */ - @ExcelProperty(value = {"${deviceType}", "冷却泵", "冷却水进水压力kpa"}, index = 24) + @ExcelProperty(value = {"${deviceType}", "冷却泵", "冷却水进水压力kpa"}, index = 23) @ColumnWidth(10) private BigDecimal pressInCoolingWater; /** * 冷却水出水压力kpa */ - @ExcelProperty(value = {"${deviceType}", "冷却泵", "冷却水出水压力kpa"}, index = 25) + @ExcelProperty(value = {"${deviceType}", "冷却泵", "冷却水出水压力kpa"}, index = 24) @ColumnWidth(10) private BigDecimal pressOutCoolingWater; /** * 冷却塔频率hz */ - @ExcelProperty(value = {"${deviceType}", "冷却塔", "冷却塔频率hz"}, index = 26) + @ExcelProperty(value = {"${deviceType}", "冷却塔", "冷却塔频率hz"}, index = 25) private BigDecimal frequencyCoolingTower; /** * 冷却塔运行数量(原注释可能有误,根据列名调整) */ - @ExcelProperty(value = {"${deviceType}", "冷却塔", "冷却塔运行数量"}, index = 27) + @ExcelProperty(value = {"${deviceType}", "冷却塔", "冷却塔运行数量"}, index = 26) private Integer runCoolingTower; /** * 室外温度℃ */ - @ExcelProperty(value = {"${deviceType}", "室外温度℃", "室外温度℃"}, index = 28) + @ExcelProperty(value = {"${deviceType}", "室外温度℃", "室外温度℃"}, index = 27) @ColumnWidth(10) private BigDecimal tempOutdoor; /** * 室外湿度% */ - @ExcelProperty(value = {"${deviceType}", "室外湿度%", "室外湿度%"}, index = 29) + @ExcelProperty(value = {"${deviceType}", "室外湿度%", "室外湿度%"}, index = 28) @ColumnWidth(10) private BigDecimal humidityOutdoor; /** * 恒压补水罐压力 */ - @ExcelProperty(value = {"${deviceType}", "恒压补水罐压力MPa", "恒压补水罐压力MPa"}, index = 30) + @ExcelProperty(value = {"${deviceType}", "恒压补水罐压力MPa", "恒压补水罐压力MPa"}, index = 29) @ColumnWidth(10) private BigDecimal pressConstantWaterTank; /** * 巡查记录人 */ - @ExcelProperty(value = {"${deviceType}", "巡查记录人", "巡查记录人"}, index = 31) + @ExcelProperty(value = {"${deviceType}", "巡查记录人", "巡查记录人"}, index = 30) @ColumnWidth(20) private String recorder; diff --git a/mh-common/src/main/java/com/mh/common/core/domain/entity/ReportSysRunParamHis.java b/mh-common/src/main/java/com/mh/common/core/domain/entity/ReportSysRunParamHis.java index e4c5434..4fe2425 100644 --- a/mh-common/src/main/java/com/mh/common/core/domain/entity/ReportSysRunParamHis.java +++ b/mh-common/src/main/java/com/mh/common/core/domain/entity/ReportSysRunParamHis.java @@ -10,9 +10,9 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.mh.common.core.domain.BaseEntity; -import jakarta.persistence.*; import lombok.*; import org.apache.commons.lang3.builder.ToStringBuilder; +import org.springframework.data.annotation.Id; import java.math.BigDecimal; import java.time.LocalDate; @@ -40,7 +40,7 @@ public class ReportSysRunParamHis extends BaseEntity { /** * 主机id */ - private String hostId; + private String deviceNum; /** * 日期 @@ -133,9 +133,19 @@ public class ReportSysRunParamHis extends BaseEntity { private BigDecimal inputPowerTotal; /** - * 压缩比 + * 压缩比1 */ - private BigDecimal ratioComp; + private BigDecimal ratioCompOne; + + /** + * 压缩比1 + */ + private BigDecimal ratioCompTwo; + + /** + * 压缩比1 + */ + private BigDecimal ratioCompThree; /** * 膨胀阀开度% @@ -245,7 +255,7 @@ public class ReportSysRunParamHis extends BaseEntity { public String toString() { return new ToStringBuilder(this) .append("id", id) - .append("hostId", hostId) + .append("deviceNum", deviceNum) .append("curDate", curDate) .append("curTime", curTime) .append("tempInChillerWater", tempInChillerWater) @@ -263,7 +273,9 @@ public class ReportSysRunParamHis extends BaseEntity { .append("setLoad", setLoad) .append("currentTotal", currentTotal) .append("inputPowerTotal", inputPowerTotal) - .append("ratioComp", ratioComp) + .append("ratioCompOne", ratioCompOne) + .append("ratioCompTwo", ratioCompTwo) + .append("ratioCompThree", ratioCompThree) .append("openExv", openExv) .append("runCompNum", runCompNum) .append("frequencyChiller", frequencyChiller) @@ -275,6 +287,8 @@ public class ReportSysRunParamHis extends BaseEntity { .append("frequencyCoolingTower", frequencyCoolingTower) .append("runCoolingTower", runCoolingTower) .append("pressConstantWaterTank", pressConstantWaterTank) + .append("tempOutdoor", tempOutdoor) + .append("humidityOutdoor", humidityOutdoor) .append("recorder", recorder) .append("remark", remark) .append("searchValue", searchValue) diff --git a/mh-common/src/main/java/com/mh/common/utils/BigDecimalUtils.java b/mh-common/src/main/java/com/mh/common/utils/BigDecimalUtils.java index b5eee7c..6c6c6f3 100644 --- a/mh-common/src/main/java/com/mh/common/utils/BigDecimalUtils.java +++ b/mh-common/src/main/java/com/mh/common/utils/BigDecimalUtils.java @@ -23,6 +23,7 @@ public class BigDecimalUtils { OPERATORS.put("<", (a, b) -> a.compareTo(b) < 0); OPERATORS.put("<=", (a, b) -> a.compareTo(b) <= 0); OPERATORS.put("==", (a, b) -> a.compareTo(b) == 0); + OPERATORS.put("=", (a, b) -> a.compareTo(b) == 0); // 添加对 = 运算符的支持 OPERATORS.put("!=", (a, b) -> a.compareTo(b) != 0); } @@ -41,4 +42,15 @@ public class BigDecimalUtils { } return predicate.test(a, b); } + + public static void main(String[] args) { + BigDecimal a = new BigDecimal("10.00"); + BigDecimal b = new BigDecimal("10.00"); + System.out.println(compare(">", a, b)); + System.out.println(compare(">=", a, b)); + System.out.println(compare("<", a, b)); + System.out.println(compare("<=", a, b)); + System.out.println(compare("==", a, b)); + System.out.println(compare("!=", a, b)); + } } diff --git a/mh-quartz/src/main/java/com/mh/quartz/task/ChillersTask.java b/mh-quartz/src/main/java/com/mh/quartz/task/ChillersTask.java new file mode 100644 index 0000000..0b8e9c9 --- /dev/null +++ b/mh-quartz/src/main/java/com/mh/quartz/task/ChillersTask.java @@ -0,0 +1,27 @@ +package com.mh.quartz.task; + +import com.mh.system.service.report.IReportSysService; +import org.springframework.stereotype.Component; + +/** + * @author LJF + * @version 1.0 + * @project EEMCS + * @description 冷水机组定时任务 + * @date 2025-08-13 17:22:09 + */ +@Component("chillersTask") +public class ChillersTask { + + private final IReportSysService reportSysService; + + public ChillersTask(IReportSysService reportSysService) { + this.reportSysService = reportSysService; + } + + public void createSysRunParam() { + // 定时执行运行脚本 + reportSysService.execProSysRunParamHis(); + } + +} diff --git a/mh-quartz/src/main/java/com/mh/quartz/task/CreateAlarmTask.java b/mh-quartz/src/main/java/com/mh/quartz/task/CreateAlarmTask.java index b38b989..68d5883 100644 --- a/mh-quartz/src/main/java/com/mh/quartz/task/CreateAlarmTask.java +++ b/mh-quartz/src/main/java/com/mh/quartz/task/CreateAlarmTask.java @@ -52,7 +52,12 @@ public class CreateAlarmTask { if (null == alarmTask) { return; } - sendMsgByTopic.sendDelayedAlarm(alarmTask, 1); + // 根据","逗号进行分割 + String[] alarmTaskArray = alarmTask.split(","); + // 遍历 + for (String id : alarmTaskArray) { + sendMsgByTopic.sendDelayedAlarm(id, 1); + } } } diff --git a/mh-quartz/src/main/java/com/mh/quartz/task/PushDataToWechatTask.java b/mh-quartz/src/main/java/com/mh/quartz/task/PushDataToWechatTask.java index 132b7dc..0996a3f 100644 --- a/mh-quartz/src/main/java/com/mh/quartz/task/PushDataToWechatTask.java +++ b/mh-quartz/src/main/java/com/mh/quartz/task/PushDataToWechatTask.java @@ -53,7 +53,7 @@ public class PushDataToWechatTask { } alarmRecords1.forEach(alarmRecords2 -> { // 每个小时推送两次 - if (alarmRecords2.getSendNum() < 3) { + if (alarmRecords2.getSendNum() <= 3) { // 查询需要推送的微信用户 List> wechatUserList = wechatService.queryWechatUser(0); if (null != wechatUserList && !wechatUserList.isEmpty()) { diff --git a/mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java b/mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java index 4174aa7..df1c515 100644 --- a/mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java +++ b/mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java @@ -3,6 +3,7 @@ package com.mh.system.mapper.device; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.mh.common.core.domain.dto.TempHumidityDTO; import com.mh.common.core.domain.entity.CollectionParamsManage; +import com.mh.common.core.domain.entity.FloorInfo; import com.mh.common.core.domain.vo.CollectionParamsManageVO; import com.mh.common.core.domain.vo.DeviceMonitorVO; import com.mh.common.core.domain.vo.HotWaterControlListVO; @@ -218,9 +219,9 @@ public interface CollectionParamsManageMapper extends BaseMapper selectBySystemType(@Param("systemType") String systemType); - @Select("select " + - " hi.house_name || right(cpm.other_name, " + - " 4) as name, " + + @Select("") + List> selectBySystemTypeAndBuildingId(@Param("systemType") String systemType, + @Param("floorIds") List floorIds); + @Select("select " + " dl.id, " + diff --git a/mh-system/src/main/java/com/mh/system/mapper/device/DataProcessMapper.java b/mh-system/src/main/java/com/mh/system/mapper/device/DataProcessMapper.java index dbb21a3..6c03a7a 100644 --- a/mh-system/src/main/java/com/mh/system/mapper/device/DataProcessMapper.java +++ b/mh-system/src/main/java/com/mh/system/mapper/device/DataProcessMapper.java @@ -187,7 +187,7 @@ public interface DataProcessMapper { * @param deviceNum * @return */ - @Select("select mt_init_value from collection_params_manage where mt_num = #{deviceNum} and is_use = '0' limit 1") + @Select("select mt_init_value from collection_params_manage where mt_num = #{deviceNum} and is_use = '0' limit 1 ") String queryInitValue1(@Param("deviceNum") String deviceNum); @Select("select * from ${tableName} where register_id = #{registerId} and cur_time >= CURRENT_TIMESTAMP - INTERVAL '24 hours' ") diff --git a/mh-system/src/main/java/com/mh/system/mapper/device/MaintainInfoMapper.java b/mh-system/src/main/java/com/mh/system/mapper/device/MaintainInfoMapper.java index f6b14a5..3f3ec1b 100644 --- a/mh-system/src/main/java/com/mh/system/mapper/device/MaintainInfoMapper.java +++ b/mh-system/src/main/java/com/mh/system/mapper/device/MaintainInfoMapper.java @@ -32,7 +32,7 @@ public interface MaintainInfoMapper extends BaseMapper { MaintainSum queryMaintainSum(@Param("buildingId") String buildingId, @Param("curDate") String curDate); //汇总维保量 - @Select("exec pro_maintain_sum #{curDate,jdbcType=VARCHAR,mode=IN} ") + @Select("call pro_maintain_sum(#{curDate,jdbcType=VARCHAR,mode=IN})") @Options(statementType = StatementType.CALLABLE) void proMaintainSum(@Param("curDate") String curDate); } diff --git a/mh-system/src/main/java/com/mh/system/mapper/energy/HotEnergyQueryMapper.java b/mh-system/src/main/java/com/mh/system/mapper/energy/HotEnergyQueryMapper.java index 1dd2d13..8e98541 100644 --- a/mh-system/src/main/java/com/mh/system/mapper/energy/HotEnergyQueryMapper.java +++ b/mh-system/src/main/java/com/mh/system/mapper/energy/HotEnergyQueryMapper.java @@ -66,7 +66,7 @@ public interface HotEnergyQueryMapper { ")) t1 on " + " dh.device_num = t1.mt_num " + "where " + - " date_trunc(#{dateType}, dh.last_time) = date_trunc(#{dateType},#{lastHour}::timestamp) " + + " date_trunc(#{dateType}, dh.cur_time) = date_trunc(#{dateType},#{lastHour}::timestamp) " + "order by " + " cur_time; " + "") diff --git a/mh-system/src/main/java/com/mh/system/mapper/report/ReportSysRunParamHisMapper.java b/mh-system/src/main/java/com/mh/system/mapper/report/ReportSysRunParamHisMapper.java index faaa105..dc8ec62 100644 --- a/mh-system/src/main/java/com/mh/system/mapper/report/ReportSysRunParamHisMapper.java +++ b/mh-system/src/main/java/com/mh/system/mapper/report/ReportSysRunParamHisMapper.java @@ -20,7 +20,7 @@ import java.util.List; @Mapper public interface ReportSysRunParamHisMapper extends BaseMapper { - @Select("exec pro_sys_run_param #{deviceNum,jdbcType=VARCHAR,mode=IN},#{curTime,jdbcType=VARCHAR,mode=IN} ") + @Select("call pro_sys_run_param(#{deviceNum,jdbcType=VARCHAR,mode=IN}, #{curTime,jdbcType=VARCHAR,mode=IN})") @Options(statementType = StatementType.CALLABLE) void execProSysRunParamHis(@Param("deviceNum") String deviceNum, @Param("curTime") String curTime); diff --git a/mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java b/mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java index 78a579c..69612b9 100644 --- a/mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java +++ b/mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java @@ -7,10 +7,7 @@ import com.mh.common.core.domain.dto.DeviceMonitorDTO; import com.mh.common.core.domain.dto.HotWaterControlDTO; import com.mh.common.core.domain.dto.HotWaterNowDataDTO; import com.mh.common.core.domain.dto.PumpInfoDTO; -import com.mh.common.core.domain.entity.ChillersEntity; -import com.mh.common.core.domain.entity.CollectionParamsManage; -import com.mh.common.core.domain.entity.DeviceLedger; -import com.mh.common.core.domain.entity.GatewayManage; +import com.mh.common.core.domain.entity.*; import com.mh.common.core.domain.vo.*; import com.mh.common.core.redis.RedisCache; import com.mh.common.utils.CRC16; @@ -21,6 +18,7 @@ import com.mh.system.mapper.device.CollectionParamsManageMapper; import com.mh.system.mapper.device.DataProcessMapper; import com.mh.system.mapper.device.DeviceLedgerMapper; import com.mh.system.mapper.device.GatewayManageMapper; +import com.mh.system.mapper.space.FloorInfoMapper; import com.mh.system.service.device.ICollectionParamsManageService; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; @@ -61,6 +59,9 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag @Resource private RedisCache redisCache; + @Resource + private FloorInfoMapper floorInfoMapper; + @Override public void createDtuCollectionParams() { List paramsManages = collectionParamsManageMapper.createOrderList(); @@ -415,7 +416,20 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag @Override public List monitorPublic(String systemType, String floorId) { - List> mapList = collectionParamsManageMapper.selectBySystemTypeAndBuildingId(systemType, floorId); + // 根据楼栋id查询对应的楼层列表,根据_进行分割 + List floorList = Arrays.asList(floorId.split("_")); + String buildingId = floorList.get(0); + String floorName = floorList.get(1); + List floorInfos = floorInfoMapper.selectList(new LambdaQueryWrapper().eq(FloorInfo::getBuildingId, buildingId).like(FloorInfo::getFloorName, floorName)); + if (floorInfos.isEmpty()) { + return List.of(); + } + // 遍历只获取floorInfos中的id,并赋值给List + List floorIds = new ArrayList<>(); + for (FloorInfo floorInfo : floorInfos) { + floorIds.add(floorInfo.getId()); + } + List> mapList = collectionParamsManageMapper.selectBySystemTypeAndBuildingId(systemType, floorIds); // stream流判断mapList中的数据curTime是否为今天日期,假如不是今天日期,则重新赋值value为"采集失败",然后响应赋值给List return mapList.stream() .filter(map -> { @@ -462,6 +476,15 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag @Override public List monitorList(String systemType, String floorId) { + // 根据楼栋id查询对应的楼层列表,根据_进行分割 + List floorList = Arrays.asList(floorId.split("_")); + String buildingId = floorList.get(0); + String floorName = floorList.get(1); + List floorInfos = floorInfoMapper.selectList(new LambdaQueryWrapper().eq(FloorInfo::getBuildingId, buildingId).like(FloorInfo::getFloorName, floorName)); + if (floorInfos.isEmpty()) { + return List.of(); + } + floorId = floorInfos.getFirst().getId(); // 处理热泵设备(deviceType=11) List hotPumps = collectionParamsManageMapper.selectHotWaterBySystemTypeAndBuildingIdAndDeviceType(systemType, floorId, "11"); Map> hotPumpGroups = hotPumps.stream() @@ -485,15 +508,15 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag dto.setIsFault(vo.getCollectValue()); break; case "14": // 温度设置 - dto.setTempSet(vo.getCollectValue()); + dto.setTempSet(new BigDecimal(vo.getCollectValue()).setScale(1).toString()); break; case "12": // 水温 - dto.setWaterTemp(vo.getCollectValue()); + dto.setWaterTemp(new BigDecimal(vo.getCollectValue()).setScale(1).toString()); break; } }); return dto; - }).collect(Collectors.toList()); + }).toList(); // 处理供水泵状态(deviceType=10) List waterPumps = collectionParamsManageMapper.selectHotWaterBySystemTypeAndBuildingIdAndDeviceType(systemType, floorId, "10"); @@ -556,12 +579,43 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag // 根据判断结果设置状态值 result.forEach(dto -> dto.setBackWaterState(backWaterState ? "1" : "0")); + List waterLevels = new ArrayList<>(); // 处理水箱液位(deviceType=16) - List waterLevels = collectionParamsManageMapper.selectHotWaterBySystemTypeAndBuildingIdAndDeviceType(systemType, floorId, "16"); + for (FloorInfo floorInfo : floorInfos) { + waterLevels.addAll(collectionParamsManageMapper.selectHotWaterBySystemTypeAndBuildingIdAndDeviceType(systemType, floorInfo.getId(), "16")); + } + + // 计算levelSet平均值(paramType=10) + Double levelSetAvg1 = waterLevels.stream() + .filter(vo -> vo.getParamType().equals("10") && (vo.getDeviceName().contains("裙楼") || vo.getDeviceName().contains("高区"))) + .mapToDouble(vo -> { + try { + return Double.parseDouble(vo.getCollectValue()); + } catch (NumberFormatException e) { + log.error("数值转换失败:设备ID={} 值={}", vo.getId(), vo.getCollectValue()); + return 0.0; // 返回默认值 + } + }) + .average() + .orElse(0.0); + + // 计算waterLevel平均值(paramType=11) + Double waterLevelAvg1 = waterLevels.stream() + .filter(vo -> vo.getParamType().equals("11") && (vo.getDeviceName().contains("裙楼") || vo.getDeviceName().contains("高区"))) + .mapToDouble(vo -> { + try { + return Double.parseDouble(vo.getCollectValue()); + } catch (NumberFormatException e) { + log.error("数值转换失败:设备ID={} 值={}", vo.getId(), vo.getCollectValue()); + return 0.0; // 返回默认值 + } + }) + .average() + .orElse(0.0); // 计算levelSet平均值(paramType=10) - Double levelSetAvg = waterLevels.stream() - .filter(vo -> vo.getParamType().equals("10")) + Double levelSetAvg2 = waterLevels.stream() + .filter(vo -> vo.getParamType().equals("10") && (vo.getDeviceName().contains("中厨") || vo.getDeviceName().contains("中区"))) .mapToDouble(vo -> { try { return Double.parseDouble(vo.getCollectValue()); @@ -574,8 +628,8 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag .orElse(0.0); // 计算waterLevel平均值(paramType=11) - Double waterLevelAvg = waterLevels.stream() - .filter(vo -> vo.getParamType().equals("11")) + Double waterLevelAvg2 = waterLevels.stream() + .filter(vo -> vo.getParamType().equals("11") && (vo.getDeviceName().contains("中厨") || vo.getDeviceName().contains("中区"))) .mapToDouble(vo -> { try { return Double.parseDouble(vo.getCollectValue()); @@ -589,8 +643,10 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag // 设置平均值到所有DTO(根据业务需求调整) result.forEach(dto -> { - dto.setLevelSet(String.format("%.2f", levelSetAvg)); - dto.setWaterLevel(String.format("%.2f", waterLevelAvg)); + dto.setLevelSet1(String.format("%.1f", levelSetAvg1)); + dto.setWaterLevel1(String.format("%.1f", waterLevelAvg1)); + dto.setLevelSet2(String.format("%.1f", levelSetAvg2)); + dto.setWaterLevel2(String.format("%.1f", waterLevelAvg2)); }); // result再根据orderNum排序 return result.stream() diff --git a/mh-system/src/main/java/com/mh/system/service/operation/impl/AlarmRecordsServiceImpl.java b/mh-system/src/main/java/com/mh/system/service/operation/impl/AlarmRecordsServiceImpl.java index bfcd5a7..6edc69c 100644 --- a/mh-system/src/main/java/com/mh/system/service/operation/impl/AlarmRecordsServiceImpl.java +++ b/mh-system/src/main/java/com/mh/system/service/operation/impl/AlarmRecordsServiceImpl.java @@ -208,6 +208,7 @@ public class AlarmRecordsServiceImpl implements IAlarmRecordsService { public String createAlarmTask() { // 查询仪表报警规则记录,查看哪些规则启用了 List alarmRules = alarmRulesService.selectAlarmRulesListByStatus(0); + StringBuilder result = new StringBuilder(); // 循环查询报警规则,判断是否满足报警条件 for (AlarmRules alarmRule : alarmRules) { // 判断报警类型 @@ -224,9 +225,9 @@ public class AlarmRecordsServiceImpl implements IAlarmRecordsService { Date curTime = collectionParamsManage.getCurTime(); // 阈值 String threshold1 = alarmRule.getThreshold1(); - if (curValue.compareTo(BigDecimal.ZERO) == 0 || curValue.compareTo(new BigDecimal(threshold1)) < 0) { + if (curValue.compareTo(BigDecimal.ZERO) == 0) { // 发送到延迟队列 - return collectionParamsManage.getId(); + result.append(",").append(collectionParamsManage.getId()); } else { // 设置Redis取消标记(有效期略大于延迟时间) redisTemplate.setCacheObject( @@ -234,10 +235,11 @@ public class AlarmRecordsServiceImpl implements IAlarmRecordsService { "true", 2, TimeUnit.MINUTES // 例如:延迟5分钟,设置10分钟过期 ); + insertOrUpdateRecord(alarmRule, curValue, threshold1, alarmCodeService.selectAlarmCodeByAlarmType(alarmRule.getEventType()), alarmRecords, collectionParamsManage); } } } - return null; + return result.toString(); } private void insertOrUpdateRecord(AlarmRules alarmRule, BigDecimal curValue, String threshold1, AlarmCode alarmCode, AlarmRecords alarmRecords, CollectionParamsManage collectionParamsManage) { diff --git a/mh-system/src/main/java/com/mh/system/service/report/impl/ReportSysServiceImpl.java b/mh-system/src/main/java/com/mh/system/service/report/impl/ReportSysServiceImpl.java index 919de93..6eb7619 100644 --- a/mh-system/src/main/java/com/mh/system/service/report/impl/ReportSysServiceImpl.java +++ b/mh-system/src/main/java/com/mh/system/service/report/impl/ReportSysServiceImpl.java @@ -45,11 +45,11 @@ public class ReportSysServiceImpl implements IReportSysService { LocalDateTime now = LocalDateTime.now(); // 获取一小时前的日期和时间 - LocalDateTime oneHourAgo = now.minusHours(1); +// LocalDateTime oneHourAgo = now.minusHours(1); // 格式化日期和时间 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - String formattedOneHourAgo = oneHourAgo.format(formatter); + String formattedOneHourAgo = now.format(formatter); // 固定写死三号主机 // reportSysRunParamHisMapper.execProSysRunParamHis("2", formattedOneHourAgo.substring(0, 13)); @@ -63,7 +63,7 @@ public class ReportSysServiceImpl implements IReportSysService { @Override public List selectList(ReportSysRunParamHis reportSysRunParamHis) { - String deviceNum = reportSysRunParamHis.getHostId(); + String deviceNum = reportSysRunParamHis.getDeviceNum(); if (StringUtils.isEmpty(deviceNum)) { // 默认3号主机 deviceNum = "3"; @@ -83,7 +83,7 @@ public class ReportSysServiceImpl implements IReportSysService { return reportSysRunParamHisMapper.selectList( new QueryWrapper() .between("cur_time", startTime, endTime) - .eq("host_id", deviceNum) + .eq("device_num", deviceNum) .orderByDesc("cur_time")); } diff --git a/mh-system/src/main/java/com/mh/system/service/space/IHouseInfoService.java b/mh-system/src/main/java/com/mh/system/service/space/IHouseInfoService.java index ec37a29..eba90a7 100644 --- a/mh-system/src/main/java/com/mh/system/service/space/IHouseInfoService.java +++ b/mh-system/src/main/java/com/mh/system/service/space/IHouseInfoService.java @@ -26,4 +26,6 @@ public interface IHouseInfoService { List buildTree(String systemType); + List buildFloorTree(String systemType); + } diff --git a/mh-system/src/main/java/com/mh/system/service/space/impl/HouseInfoServiceImpl.java b/mh-system/src/main/java/com/mh/system/service/space/impl/HouseInfoServiceImpl.java index 10b9c1b..718bf20 100644 --- a/mh-system/src/main/java/com/mh/system/service/space/impl/HouseInfoServiceImpl.java +++ b/mh-system/src/main/java/com/mh/system/service/space/impl/HouseInfoServiceImpl.java @@ -15,9 +15,7 @@ import jakarta.annotation.Resource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -168,10 +166,165 @@ public class HouseInfoServiceImpl implements IHouseInfoService { return List.of(); } + @Override + public List buildFloorTree(String systemType) { + QueryWrapper areaInfoQueryWrapper = new QueryWrapper<>(); + if (!StringUtils.isEmpty(systemType)) { + areaInfoQueryWrapper.eq("system_type", systemType); + } + areaInfoQueryWrapper.orderByAsc("order_num"); + List areaInfos = areaInfoMapper.selectList(areaInfoQueryWrapper); + if (areaInfos != null && !areaInfos.isEmpty()) { + List buildingInfos = buildingInfoMapper.selectList(new QueryWrapper().orderByAsc("order_num")); + List floorInfos = floorInfoMapper.selectList(new QueryWrapper().orderByAsc("order_num")); + return buildFloorTree(areaInfos, buildingInfos, floorInfos); + } + return List.of(); + } + + public List buildFloorTree(List areaInfos, + List buildingInfos, + List floorInfos) { + // 创建合并后的楼层节点 + Map> buildingMap = new HashMap<>(); + + // 遍历每个楼栋下的楼层信息 + Map> floorsByBuilding = floorInfos.stream() + .collect(Collectors.groupingBy(FloorInfo::getBuildingId)); + + for (Map.Entry> entry : floorsByBuilding.entrySet()) { + String buildingId = entry.getKey(); + List floorsInBuilding = entry.getValue(); + + // 提取楼层名称的前缀部分(例如从"-1楼裙楼"提取"-1楼") + Map> groupedByPrefix = new HashMap<>(); + + for (FloorInfo floor : floorsInBuilding) { + String floorName = floor.getFloorName(); + // 提取前缀,例如"-1楼" + String prefix = extractFloorPrefix(floorName); + + groupedByPrefix.computeIfAbsent(prefix, k -> new ArrayList<>()).add(floor); + } + + // 为每个前缀创建节点结构 + List mergedFloorNodes = new ArrayList<>(); + + for (Map.Entry> prefixEntry : groupedByPrefix.entrySet()) { + String prefix = prefixEntry.getKey(); + List floorsWithSamePrefix = prefixEntry.getValue(); + + if (floorsWithSamePrefix.size() > 1) { + // 如果有多个同前缀楼层,创建父节点并添加子节点 + SpaceTreeSelect parentNode = new SpaceTreeSelect(buildingId + "_" + prefix, prefix, false, buildingId, 3); + List children = floorsWithSamePrefix.stream() + .map(f -> { + // 子节点显示完整名称 + return new SpaceTreeSelect(f.getId(), f.getFloorName(), false, buildingId + "_" + prefix, 3); + }) + .sorted(Comparator.comparing(SpaceTreeSelect::getLabel)) // 子节点按名称排序 + .collect(Collectors.toList()); + parentNode.setChildren(null); + mergedFloorNodes.add(parentNode); + } else { + // 如果只有一个楼层,直接创建节点 + FloorInfo floor = floorsWithSamePrefix.get(0); + SpaceTreeSelect node = new SpaceTreeSelect(floor.getId(), floor.getFloorName(), false, buildingId, 3); + node.setChildren(null); + mergedFloorNodes.add(node); + } + } + + // 按楼层数字顺序排序(-1楼、1楼、2楼等) + mergedFloorNodes.sort((node1, node2) -> { + String label1 = node1.getLabel(); + String label2 = node2.getLabel(); + return compareFloorLabels(label1, label2); + }); + + buildingMap.put(buildingId, mergedFloorNodes); + } + + // 楼栋 -> 区域映射 + Map> areaMap = buildingInfos.stream() + .map(b -> { + SpaceTreeSelect node = new SpaceTreeSelect(b.getId(), b.getBuildingName(), false, b.getAreaId(), 2); + node.setChildren(buildingMap.getOrDefault(b.getId(), Collections.emptyList())); + return node; + }) + .collect(Collectors.groupingBy(SpaceTreeSelect::getParentId)); + + // 区域 -> 根节点映射 + Map> map = areaInfos.stream() + .map(a -> { + SpaceTreeSelect node = new SpaceTreeSelect(a.getId(), a.getAreaName(), false, "0", 1); + node.setChildren(areaMap.getOrDefault(a.getId(), Collections.emptyList())); + return node; + }) + .collect(Collectors.groupingBy(SpaceTreeSelect::getParentId)); + + List sysParams = sysParamsMapper.selectSysParamsList(); + return sysParams.stream().map(r -> { + SpaceTreeSelect node = new SpaceTreeSelect(r.getId(), r.getProName(), false, null, 0); + node.setChildren(map.getOrDefault(r.getId(), Collections.emptyList())); + return node; + }).collect(Collectors.toList()); + } + + // 提取楼层名称前缀的辅助方法 + private String extractFloorPrefix(String floorName) { + // 匹配类似"-1楼"、"1楼"、"B1楼"等前缀 + if (floorName.contains("楼")) { + int index = floorName.indexOf("楼"); + return floorName.substring(0, index + 1); + } + // 如果没有找到"楼"字,返回原名称 + return floorName; + } + + // 比较楼层标签的辅助方法 + private int compareFloorLabels(String label1, String label2) { + Integer floorNum1 = extractFloorNumber(label1); + Integer floorNum2 = extractFloorNumber(label2); + + // 如果都能提取到楼层号,则按楼层号排序 + if (floorNum1 != null && floorNum2 != null) { + return floorNum1.compareTo(floorNum2); + } + + // 如果其中一个能提取到楼层号,则能提取到的排在前面 + if (floorNum1 != null) { + return -1; + } + if (floorNum2 != null) { + return 1; + } + + // 都不能提取到楼层号,则按字典序排序 + return label1.compareTo(label2); + } + + // 从楼层标签中提取楼层号 + private Integer extractFloorNumber(String label) { + // 匹配模式如 "-1楼", "1楼", "B1楼" 等 + java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("(-?\\d+)楼"); + java.util.regex.Matcher matcher = pattern.matcher(label); + + if (matcher.find()) { + try { + return Integer.parseInt(matcher.group(1)); + } catch (NumberFormatException e) { + return null; + } + } + + return null; + } + public List buildTree(List areaInfos, - List buildingInfos, - List floorInfos, - List houseInfos) { + List buildingInfos, + List floorInfos, + List houseInfos) { // 房间 -> 楼层映射 Map> floorMap = houseInfos.stream() .map(r -> new SpaceTreeSelect(r.getId(), r.getHouseName(), false, r.getFloorId(), 4))