Browse Source

1、修复定时报警、热水记录生成;

2、主机运行报表相关接口添加;
dev_mz
25604 5 days ago
parent
commit
5fb572cd4d
  1. 5
      mh-admin/src/main/java/com/mh/web/controller/space/SpaceController.java
  2. 4
      mh-admin/src/main/resources/application-dev.yml
  3. 2
      mh-admin/src/main/resources/application.yml
  4. 9
      mh-admin/src/test/java/com/mh/MHApplicationTest.java
  5. 6
      mh-common/src/main/java/com/mh/common/core/domain/dto/HotWaterNowDataDTO.java
  6. 60
      mh-common/src/main/java/com/mh/common/core/domain/dto/MaglevReportSysParamDTO.java
  7. 26
      mh-common/src/main/java/com/mh/common/core/domain/entity/ReportSysRunParamHis.java
  8. 12
      mh-common/src/main/java/com/mh/common/utils/BigDecimalUtils.java
  9. 27
      mh-quartz/src/main/java/com/mh/quartz/task/ChillersTask.java
  10. 7
      mh-quartz/src/main/java/com/mh/quartz/task/CreateAlarmTask.java
  11. 2
      mh-quartz/src/main/java/com/mh/quartz/task/PushDataToWechatTask.java
  12. 18
      mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java
  13. 2
      mh-system/src/main/java/com/mh/system/mapper/device/DataProcessMapper.java
  14. 2
      mh-system/src/main/java/com/mh/system/mapper/device/MaintainInfoMapper.java
  15. 2
      mh-system/src/main/java/com/mh/system/mapper/energy/HotEnergyQueryMapper.java
  16. 2
      mh-system/src/main/java/com/mh/system/mapper/report/ReportSysRunParamHisMapper.java
  17. 86
      mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java
  18. 8
      mh-system/src/main/java/com/mh/system/service/operation/impl/AlarmRecordsServiceImpl.java
  19. 8
      mh-system/src/main/java/com/mh/system/service/report/impl/ReportSysServiceImpl.java
  20. 2
      mh-system/src/main/java/com/mh/system/service/space/IHouseInfoService.java
  21. 159
      mh-system/src/main/java/com/mh/system/service/space/impl/HouseInfoServiceImpl.java

5
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));
}
}

4
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
# 从库数据源

2
mh-admin/src/main/resources/application.yml

@ -1,6 +1,6 @@
spring:
profiles:
active: dev
active: prod
# 用户配置
user:

9
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++) {

6
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; //环境温度

60
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;

26
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)

12
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));
}
}

27
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();
}
}

7
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);
}
}
}

2
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<Map<String, Object>> wechatUserList = wechatService.queryWechatUser(0);
if (null != wechatUserList && !wechatUserList.isEmpty()) {

18
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<CollectionParam
" order by dl.device_type ,dl.order_num ,cpm.order_num ")
List<CollectionParamsManageVO> selectBySystemType(@Param("systemType") String systemType);
@Select("select " +
" hi.house_name || right(cpm.other_name, " +
" 4) as name, " +
@Select("<script>" +
"select " +
" hi.house_name || right(cpm.other_name, 4) as name, " +
" cpm.cur_value as value, " +
" cpm.cur_time as \"curTime\" " +
"from " +
@ -234,12 +235,17 @@ public interface CollectionParamsManageMapper extends BaseMapper<CollectionParam
"where " +
" (cpm.param_type = '12' " +
" or cpm.param_type = '13') " +
" and csr.floor_id = #{floorId} " +
" and cpm.system_type = #{systemType}" +
" and hi.house_name is not null " +
" order by hi.house_name, cpm.param_type ")
" and csr.floor_id IN " +
" <foreach collection='floorIds' item='floorId' open='(' separator=',' close=')'>" +
" #{floorId}" +
" </foreach>" +
" order by hi.house_name, cpm.param_type " +
"</script>")
List<Map<String, Object>> selectBySystemTypeAndBuildingId(@Param("systemType") String systemType,
@Param("floorId") String floor_id);
@Param("floorIds") List<String> floorIds);
@Select("select " +
" dl.id, " +

2
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' ")

2
mh-system/src/main/java/com/mh/system/mapper/device/MaintainInfoMapper.java

@ -32,7 +32,7 @@ public interface MaintainInfoMapper extends BaseMapper<MaintainInfo> {
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);
}

2
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; " +
"</script>")

2
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<ReportSysRunParamHis> {
@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);

86
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<CollectionParamsManage> paramsManages = collectionParamsManageMapper.createOrderList();
@ -415,7 +416,20 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
@Override
public List<ColumnFilter> monitorPublic(String systemType, String floorId) {
List<Map<String, Object>> mapList = collectionParamsManageMapper.selectBySystemTypeAndBuildingId(systemType, floorId);
// 根据楼栋id查询对应的楼层列表,根据_进行分割
List<String> floorList = Arrays.asList(floorId.split("_"));
String buildingId = floorList.get(0);
String floorName = floorList.get(1);
List<FloorInfo> floorInfos = floorInfoMapper.selectList(new LambdaQueryWrapper<FloorInfo>().eq(FloorInfo::getBuildingId, buildingId).like(FloorInfo::getFloorName, floorName));
if (floorInfos.isEmpty()) {
return List.of();
}
// 遍历只获取floorInfos中的id,并赋值给List<String>
List<String> floorIds = new ArrayList<>();
for (FloorInfo floorInfo : floorInfos) {
floorIds.add(floorInfo.getId());
}
List<Map<String, Object>> mapList = collectionParamsManageMapper.selectBySystemTypeAndBuildingId(systemType, floorIds);
// stream流判断mapList中的数据curTime是否为今天日期,假如不是今天日期,则重新赋值value为"采集失败",然后响应赋值给List<ColumnFilter>
return mapList.stream()
.filter(map -> {
@ -462,6 +476,15 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
@Override
public List<HotWaterNowDataDTO> monitorList(String systemType, String floorId) {
// 根据楼栋id查询对应的楼层列表,根据_进行分割
List<String> floorList = Arrays.asList(floorId.split("_"));
String buildingId = floorList.get(0);
String floorName = floorList.get(1);
List<FloorInfo> floorInfos = floorInfoMapper.selectList(new LambdaQueryWrapper<FloorInfo>().eq(FloorInfo::getBuildingId, buildingId).like(FloorInfo::getFloorName, floorName));
if (floorInfos.isEmpty()) {
return List.of();
}
floorId = floorInfos.getFirst().getId();
// 处理热泵设备(deviceType=11)
List<DeviceMonitorVO> hotPumps = collectionParamsManageMapper.selectHotWaterBySystemTypeAndBuildingIdAndDeviceType(systemType, floorId, "11");
Map<String, List<DeviceMonitorVO>> 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<DeviceMonitorVO> waterPumps = collectionParamsManageMapper.selectHotWaterBySystemTypeAndBuildingIdAndDeviceType(systemType, floorId, "10");
@ -556,12 +579,43 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
// 根据判断结果设置状态值
result.forEach(dto -> dto.setBackWaterState(backWaterState ? "1" : "0"));
List<DeviceMonitorVO> waterLevels = new ArrayList<>();
// 处理水箱液位(deviceType=16)
List<DeviceMonitorVO> 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()

8
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> 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) {

8
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<ReportSysRunParamHis> 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<ReportSysRunParamHis>()
.between("cur_time", startTime, endTime)
.eq("host_id", deviceNum)
.eq("device_num", deviceNum)
.orderByDesc("cur_time"));
}

2
mh-system/src/main/java/com/mh/system/service/space/IHouseInfoService.java

@ -26,4 +26,6 @@ public interface IHouseInfoService {
List<SpaceTreeSelect> buildTree(String systemType);
List<SpaceTreeSelect> buildFloorTree(String systemType);
}

159
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,6 +166,161 @@ public class HouseInfoServiceImpl implements IHouseInfoService {
return List.of();
}
@Override
public List<SpaceTreeSelect> buildFloorTree(String systemType) {
QueryWrapper<AreaInfo> areaInfoQueryWrapper = new QueryWrapper<>();
if (!StringUtils.isEmpty(systemType)) {
areaInfoQueryWrapper.eq("system_type", systemType);
}
areaInfoQueryWrapper.orderByAsc("order_num");
List<AreaInfo> areaInfos = areaInfoMapper.selectList(areaInfoQueryWrapper);
if (areaInfos != null && !areaInfos.isEmpty()) {
List<BuildingInfo> buildingInfos = buildingInfoMapper.selectList(new QueryWrapper<BuildingInfo>().orderByAsc("order_num"));
List<FloorInfo> floorInfos = floorInfoMapper.selectList(new QueryWrapper<FloorInfo>().orderByAsc("order_num"));
return buildFloorTree(areaInfos, buildingInfos, floorInfos);
}
return List.of();
}
public List<SpaceTreeSelect> buildFloorTree(List<AreaInfo> areaInfos,
List<BuildingInfo> buildingInfos,
List<FloorInfo> floorInfos) {
// 创建合并后的楼层节点
Map<String, List<SpaceTreeSelect>> buildingMap = new HashMap<>();
// 遍历每个楼栋下的楼层信息
Map<String, List<FloorInfo>> floorsByBuilding = floorInfos.stream()
.collect(Collectors.groupingBy(FloorInfo::getBuildingId));
for (Map.Entry<String, List<FloorInfo>> entry : floorsByBuilding.entrySet()) {
String buildingId = entry.getKey();
List<FloorInfo> floorsInBuilding = entry.getValue();
// 提取楼层名称的前缀部分(例如从"-1楼裙楼"提取"-1楼")
Map<String, List<FloorInfo>> 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<SpaceTreeSelect> mergedFloorNodes = new ArrayList<>();
for (Map.Entry<String, List<FloorInfo>> prefixEntry : groupedByPrefix.entrySet()) {
String prefix = prefixEntry.getKey();
List<FloorInfo> floorsWithSamePrefix = prefixEntry.getValue();
if (floorsWithSamePrefix.size() > 1) {
// 如果有多个同前缀楼层,创建父节点并添加子节点
SpaceTreeSelect parentNode = new SpaceTreeSelect(buildingId + "_" + prefix, prefix, false, buildingId, 3);
List<SpaceTreeSelect> 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<String, List<SpaceTreeSelect>> 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<String, List<SpaceTreeSelect>> 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> 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<SpaceTreeSelect> buildTree(List<AreaInfo> areaInfos,
List<BuildingInfo> buildingInfos,
List<FloorInfo> floorInfos,

Loading…
Cancel
Save