diff --git a/mh-admin/src/main/java/com/mh/web/controller/device/MaintainInfoController.java b/mh-admin/src/main/java/com/mh/web/controller/device/MaintainInfoController.java index aa7f0fd..60b333b 100644 --- a/mh-admin/src/main/java/com/mh/web/controller/device/MaintainInfoController.java +++ b/mh-admin/src/main/java/com/mh/web/controller/device/MaintainInfoController.java @@ -99,12 +99,14 @@ public class MaintainInfoController extends BaseController { @RequestParam(value= "curDate", required=false)String curDate) { try { MaintainSum record; - if (buildingId == null || buildingId.equals("")) { + if (buildingId == null || buildingId.isEmpty()) { record = maintainInfoService.queryMaintainSum("所有", curDate); } else { record = maintainInfoService.queryMaintainSum(buildingId, curDate); } - + if (record == null) { + record = new MaintainSum(); + } return AjaxResult.success(record); } catch (Exception e) { return AjaxResult.error(); diff --git a/mh-common/src/main/java/com/mh/common/constant/Constants.java b/mh-common/src/main/java/com/mh/common/constant/Constants.java index 91b18bf..c3079a3 100644 --- a/mh-common/src/main/java/com/mh/common/constant/Constants.java +++ b/mh-common/src/main/java/com/mh/common/constant/Constants.java @@ -195,7 +195,7 @@ public class Constants { public static final String TYPE_REGISTER = "registers"; // 查询ddc指令 public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; // 格式化时间 - public static final String METER_TYPE = "meter"; + public static final String METER_TYPE = "5"; public static final String CLOUD_TYPE = "cloud"; diff --git a/mh-common/src/main/java/com/mh/common/core/domain/entity/CollectionParamsManage.java b/mh-common/src/main/java/com/mh/common/core/domain/entity/CollectionParamsManage.java index a9e90d8..32ef0e5 100644 --- a/mh-common/src/main/java/com/mh/common/core/domain/entity/CollectionParamsManage.java +++ b/mh-common/src/main/java/com/mh/common/core/domain/entity/CollectionParamsManage.java @@ -183,6 +183,19 @@ public class CollectionParamsManage extends BaseEntity { */ private String collectionType; + /** + * 终端设备类型实际上就是设备类型 + */ + private String terminalDeviceType; + + public String getTerminalDeviceType() { + return terminalDeviceType; + } + + public void setTerminalDeviceType(String terminalDeviceType) { + this.terminalDeviceType = terminalDeviceType; + } + public String getCollectionType() { return collectionType; } @@ -478,6 +491,7 @@ public class CollectionParamsManage extends BaseEntity { .append("paramType", paramType) .append("systemType", systemType) .append("collectionType", collectionType) + .append("terminalDeviceType", terminalDeviceType) .toString(); } } diff --git a/mh-common/src/main/java/com/mh/common/core/domain/entity/DeviceLedger.java b/mh-common/src/main/java/com/mh/common/core/domain/entity/DeviceLedger.java index 97c2b07..c73b2db 100644 --- a/mh-common/src/main/java/com/mh/common/core/domain/entity/DeviceLedger.java +++ b/mh-common/src/main/java/com/mh/common/core/domain/entity/DeviceLedger.java @@ -100,6 +100,19 @@ public class DeviceLedger extends BaseEntity { @JsonInclude(JsonInclude.Include.NON_EMPTY) private Map params; + /** + * 系统类型 + */ + private String systemType; + + public String getSystemType() { + return systemType; + } + + public void setSystemType(String systemType) { + this.systemType = systemType; + } + public String getId() { return id; } @@ -253,6 +266,7 @@ public class DeviceLedger extends BaseEntity { .append("searchValue", searchValue) .append("remark", remark) .append("params", params) + .append("systemType", systemType) .toString(); } } diff --git a/mh-common/src/main/java/com/mh/common/core/domain/entity/DeviceReport.java b/mh-common/src/main/java/com/mh/common/core/domain/entity/DeviceReport.java index 3410064..9a8db8d 100644 --- a/mh-common/src/main/java/com/mh/common/core/domain/entity/DeviceReport.java +++ b/mh-common/src/main/java/com/mh/common/core/domain/entity/DeviceReport.java @@ -25,6 +25,8 @@ public class DeviceReport implements Serializable { private Date updateTime; private String deviceNum; private String deviceCode; + // 寄存器地址 + private String registerAddr; private String deviceType; private String lastValue; @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") diff --git a/mh-common/src/main/java/com/mh/common/core/domain/entity/DeviceTypeEnergy.java b/mh-common/src/main/java/com/mh/common/core/domain/entity/DeviceTypeEnergy.java index 4878a98..b04200f 100644 --- a/mh-common/src/main/java/com/mh/common/core/domain/entity/DeviceTypeEnergy.java +++ b/mh-common/src/main/java/com/mh/common/core/domain/entity/DeviceTypeEnergy.java @@ -74,13 +74,13 @@ public class DeviceTypeEnergy implements Serializable { } public String getDeviceTypeRange() { - if (Integer.parseInt(this.grade) < 10) { + if (Integer.parseInt(this.deviceType) == 0) { return "冷水机组(kwh)"; - } else if (Integer.parseInt(this.grade) >= 10 && Integer.parseInt(this.grade) < 20) { + } else if (Integer.parseInt(this.deviceType) == 2) { return "冷冻泵(kwh)"; - } else if (Integer.parseInt(this.grade) >= 20 && Integer.parseInt(this.grade) < 30) { + } else if (Integer.parseInt(this.deviceType) == 1) { return "冷却泵(kwh)"; - } else if (Integer.parseInt(this.grade) >= 30 && Integer.parseInt(this.grade) < 40) { + } else if (Integer.parseInt(this.deviceType) == 3) { return "冷却塔(kwh)"; } else { return "其他"; diff --git a/mh-common/src/main/java/com/mh/common/core/domain/entity/MaintainSum.java b/mh-common/src/main/java/com/mh/common/core/domain/entity/MaintainSum.java index 0af4cb4..47346c1 100644 --- a/mh-common/src/main/java/com/mh/common/core/domain/entity/MaintainSum.java +++ b/mh-common/src/main/java/com/mh/common/core/domain/entity/MaintainSum.java @@ -19,21 +19,21 @@ public class MaintainSum { private String curDate; - private int dayNum; + private int dayNum=0; - private String dayP; + private String dayP = "0"; - private int weekNum; + private int weekNum = 0; - private String weekP; + private String weekP = "0"; - private int monthNum; + private int monthNum = 0; - private String monthP; + private String monthP = "0"; - private int yearNum; + private int yearNum = 0; - private String yearP; + private String yearP = "0"; public String getId() { return id; diff --git a/mh-common/src/main/java/com/mh/common/utils/PageUtils.java b/mh-common/src/main/java/com/mh/common/utils/PageUtils.java index 6fcc8f0..ffbe485 100644 --- a/mh-common/src/main/java/com/mh/common/utils/PageUtils.java +++ b/mh-common/src/main/java/com/mh/common/utils/PageUtils.java @@ -19,6 +19,9 @@ public class PageUtils extends PageHelper { PageDomain pageDomain = TableSupport.buildPageRequest(); Integer pageNum = pageDomain.getPageNum(); + if (pageNum == 0) { + return; + } Integer pageSize = pageDomain.getPageSize(); String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); Boolean reasonable = pageDomain.getReasonable(); diff --git a/mh-quartz/src/main/java/com/mh/quartz/task/DealDataTask.java b/mh-quartz/src/main/java/com/mh/quartz/task/DealDataTask.java index c7e840b..b5e63ab 100644 --- a/mh-quartz/src/main/java/com/mh/quartz/task/DealDataTask.java +++ b/mh-quartz/src/main/java/com/mh/quartz/task/DealDataTask.java @@ -112,6 +112,8 @@ public class DealDataTask { firstEntity.setCurValue(entity.getCurValue().toString()); firstEntity.setDeviceNum(entity.getMtNum()); firstEntity.setDeviceCode(entity.getMtCode()); + // 寄存器地址 + firstEntity.setRegisterAddr(entity.getRegisterAddr()); firstEntity.setDeviceType(deviceType); firstEntity.setRatio(ratio); double usedValue = entity.getCurValue().doubleValue() - Double.parseDouble(initValue); @@ -135,6 +137,8 @@ public class DealDataTask { firstEntity.setCurValue(entity.getCurValue().toString()); firstEntity.setDeviceNum(entity.getMtNum()); firstEntity.setDeviceCode(entity.getMtCode()); + // 寄存器地址 + firstEntity.setRegisterAddr(entity.getRegisterAddr()); firstEntity.setDeviceType(deviceType); firstEntity.setRatio(ratio); double usedValue = entity.getCurValue().doubleValue() - Double.parseDouble(lastValue); 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 940867b..1462586 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 @@ -35,8 +35,8 @@ public interface CollectionParamsManageMapper extends BaseMapper" + "select " + - " dh.calc_value, " + - " dh.device_num, " + - " dm.remark, " + - " dm.grade " + + " dm.calc_value, " + + " dm.device_num, " + + " cpm.other_name as remark, " + + " cpm.terminal_device_type as device_type " + "from " + - " ${lastTableName} dh " + - "join device_manage dm " + - "on " + - " dh.device_num = dm.device_num " + + " ${lastTableName} dm " + + "join collection_params_manage cpm " + + " on " + + " cpm.mt_num = dm.device_num " + + " and cpm.mt_code = dm.device_code " + + " and cpm.register_addr = dm.register_addr " + + "join device_ledger dl " + + " on " + + " cpm.device_ledger_id = dl.id " + "where " + - " dh.cur_time >= #{startTime} " + - " and dh.cur_time <= #{endTime} " + - " and dm.grade < 40 " + - " and dm.device_type like '%meter%' " + - " and dm.status = 0" + + " dm.cur_time >= #{startTime} " + + " and dm.cur_time <= #{endTime} " + + " and cpm.grade = 40 " + + " and cpm.is_use = 0 " + "" + - " and dh.device_type = #{paramType}" + + " and dl.device_type = #{paramType}" + "" + "union all " + "select " + - " dh.calc_value, " + - " dh.device_num, " + - " dm.remark, " + - " dm.grade " + + " dm.calc_value, " + + " dm.device_num, " + + " cpm.other_name as remark, " + + " cpm.terminal_device_type as device_type " + "from " + - " ${curTableName} dh " + - "join device_manage dm " + - "on " + - " dh.device_num = dm.device_num " + + " ${curTableName} dm " + + "join collection_params_manage cpm " + + " on " + + " cpm.mt_num = dm.device_num " + + " and cpm.mt_code = dm.device_code " + + " and cpm.register_addr = dm.register_addr " + + "join device_ledger dl " + + " on " + + " cpm.device_ledger_id = dl.id " + "where " + - " dh.cur_time >= #{startTime} " + - " and dh.cur_time <= #{endTime} " + - " and dm.grade < 40 " + - " and dm.device_type like '%meter%' " + - " and dm.status = 0" + + " dm.cur_time >= #{startTime} " + + " and dm.cur_time <= #{endTime} " + + " and cpm.grade = 40 " + + " and cpm.is_use = 0 " + "" + - " and dh.device_type = #{paramType}" + + " and dl.device_type = #{paramType}" + "" + "") List queryManyTable(@Param("startTime") String startTime, @@ -83,23 +91,27 @@ public interface EnergyAnalyzeMapper { */ @Select("") List queryOneTable(@Param("startTime") String startTime, diff --git a/mh-system/src/main/java/com/mh/system/service/device/impl/MaintainInfoServiceImpl.java b/mh-system/src/main/java/com/mh/system/service/device/impl/MaintainInfoServiceImpl.java index 5241b57..2ba96bd 100644 --- a/mh-system/src/main/java/com/mh/system/service/device/impl/MaintainInfoServiceImpl.java +++ b/mh-system/src/main/java/com/mh/system/service/device/impl/MaintainInfoServiceImpl.java @@ -3,12 +3,15 @@ package com.mh.system.service.device.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.mh.common.core.domain.entity.MaintainInfo; import com.mh.common.core.domain.entity.MaintainSum; +import com.mh.common.utils.DateUtils; import com.mh.common.utils.StringUtils; import com.mh.system.mapper.device.MaintainInfoMapper; import com.mh.system.service.device.IMaintainInfoService; import jakarta.annotation.Resource; import org.springframework.stereotype.Service; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.List; /** @@ -34,13 +37,30 @@ public class MaintainInfoServiceImpl implements IMaintainInfoService { if (maintainInfo.getMaintainType() != null) { queryWrapper.eq("maintain_type", maintainInfo.getMaintainType()); } + if (!StringUtils.isEmpty(maintainInfo.getBuildingId())) { + queryWrapper.eq("building_id", maintainInfo.getBuildingId()); + } // 维保人员 if (!StringUtils.isEmpty(maintainInfo.getMaintainPeople())) { queryWrapper.like("maintain_people", maintainInfo.getMaintainPeople()); } - // 设备id - if (!StringUtils.isEmpty(maintainInfo.getDeviceId())) { - queryWrapper.eq("device_id", maintainInfo.getDeviceId()); + // 设备类型 + if (!StringUtils.isEmpty(maintainInfo.getDeviceType())) { + queryWrapper.eq("device_type", maintainInfo.getDeviceType()); + } + // 创建时间(格式为 yyyy-MM-dd) + // 添加时间范围 + if (maintainInfo.getParams() != null && !maintainInfo.getParams().isEmpty()) { + String beginTimeStr = (String) maintainInfo.getParams().get("beginTime"); + String endTimeStr = (String) maintainInfo.getParams().get("endTime"); + + if (StringUtils.isNotEmpty(beginTimeStr) && StringUtils.isNotEmpty(endTimeStr)) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate beginTime = LocalDate.parse(beginTimeStr, formatter); + LocalDate endTime = LocalDate.parse(endTimeStr, formatter); + + queryWrapper.between("create_time", java.sql.Date.valueOf(beginTime), java.sql.Date.valueOf(endTime)); + } } queryWrapper.orderByDesc("create_time"); return maintainInfoMapper.selectList(queryWrapper); diff --git a/mh-system/src/main/java/com/mh/system/service/energy/EnergyAnalyzeService.java b/mh-system/src/main/java/com/mh/system/service/energy/EnergyAnalyzeService.java index 70151ae..01cb95b 100644 --- a/mh-system/src/main/java/com/mh/system/service/energy/EnergyAnalyzeService.java +++ b/mh-system/src/main/java/com/mh/system/service/energy/EnergyAnalyzeService.java @@ -1,7 +1,6 @@ package com.mh.system.service.energy; import com.alibaba.fastjson2.JSONObject; -import com.mh.common.core.domain.AjaxResult; import com.mh.common.core.domain.vo.EnergyQueryVO; import java.util.List; diff --git a/mh-system/src/main/java/com/mh/system/service/energy/impl/EnergyAnalyzeServiceImpl.java b/mh-system/src/main/java/com/mh/system/service/energy/impl/EnergyAnalyzeServiceImpl.java index 3a3eef8..58e0d34 100644 --- a/mh-system/src/main/java/com/mh/system/service/energy/impl/EnergyAnalyzeServiceImpl.java +++ b/mh-system/src/main/java/com/mh/system/service/energy/impl/EnergyAnalyzeServiceImpl.java @@ -93,16 +93,16 @@ public class EnergyAnalyzeServiceImpl implements EnergyAnalyzeService { } // 查询各个冷水机组的 0-9 - List chiller = createDeviceTypeData(deviceTypeEnergyEntities, 10, 0); + List chiller = createDeviceTypeData(deviceTypeEnergyEntities, 0, 0); // 查询各个冷冻泵的 10-19 - List chillerPump = createDeviceTypeData(deviceTypeEnergyEntities, 20, 10); + List chillerPump = createDeviceTypeData(deviceTypeEnergyEntities, 2, 2); // 查询各个冷却泵的 20-29 - List coolPump = createDeviceTypeData(deviceTypeEnergyEntities, 30, 20); + List coolPump = createDeviceTypeData(deviceTypeEnergyEntities, 1, 1); // 查询各个冷却塔的 30-39 - List coolTower = createDeviceTypeData(deviceTypeEnergyEntities, 40, 30); + List coolTower = createDeviceTypeData(deviceTypeEnergyEntities, 3, 3); // 从device_manage查询不是总表的 List deviceByOther = collectionParamsManageMapper.getDeviceByOther(null); @@ -259,7 +259,7 @@ public class EnergyAnalyzeServiceImpl implements EnergyAnalyzeService { .filter(val -> val.getDeviceNum().equals(deviceManageEntity.getMtNum())) .peek(val -> { val.setDeviceType(deviceManageEntity.getMtType()); - val.setRemark(deviceManageEntity.getRemark()); + val.setRemark(deviceManageEntity.getOtherName()); val.setGrade(String.valueOf(deviceManageEntity.getGrade())); }) .sorted(Comparator.comparing(DeviceTypeEnergy::getGrade)) @@ -268,7 +268,7 @@ public class EnergyAnalyzeServiceImpl implements EnergyAnalyzeService { private static List createDeviceTypeData(List deviceTypeEnergyEntities, int x, int x1) { return deviceTypeEnergyEntities.stream() - .filter(val -> Integer.parseInt(val.getGrade()) < x && Integer.parseInt(val.getGrade()) >= x1) + .filter(val -> Integer.parseInt(val.getDeviceType()) == x) .collect(Collectors.groupingBy(DeviceTypeEnergy::getDeviceNum, Collectors.summarizingDouble(DeviceTypeEnergy::getDoubleCalcValue))) .entrySet().stream() .map(entry -> { diff --git a/sql/表结构设计.sql b/sql/表结构设计.sql index a954cf2..8701440 100644 --- a/sql/表结构设计.sql +++ b/sql/表结构设计.sql @@ -565,3 +565,26 @@ CREATE INDEX idx_alarm_records_create_time ON alarm_records(create_time); ALTER TABLE public.alarm_rules ADD status int4 NULL; COMMENT ON COLUMN public.alarm_rules.status IS '状态:0:已启用,1:未启用'; +ALTER TABLE public.data_min2025 ADD register_addr varchar(20) NULL; +COMMENT ON COLUMN public.data_min2025.register_addr IS '寄存器地址'; + +ALTER TABLE public.data_hour2024 ADD register_addr varchar(20) NULL; +COMMENT ON COLUMN public.data_hour2024.register_addr IS '寄存器地址'; + +ALTER TABLE public.data_hour2025 ADD register_addr varchar(20) NULL; +COMMENT ON COLUMN public.data_hour2025.register_addr IS '寄存器地址'; + +ALTER TABLE public.data_day2024 ADD register_addr varchar(20) NULL; +COMMENT ON COLUMN public.data_day2024.register_addr IS '寄存器地址'; + +ALTER TABLE public.data_month ADD register_addr varchar(20) NULL; +COMMENT ON COLUMN public.data_month.register_addr IS '寄存器地址'; + +ALTER TABLE public.data_year ADD register_addr varchar(20) NULL; +COMMENT ON COLUMN public.data_year.register_addr IS '寄存器地址'; + +ALTER TABLE public.device_ledger ADD system_type varchar NULL; +COMMENT ON COLUMN public.device_ledger.system_type IS '系统类型'; + +ALTER TABLE public.collection_params_manage ADD terminal_device_type varchar(10) NULL; +COMMENT ON COLUMN public.collection_params_manage.terminal_device_type IS '终端设备类型';