From 8b4b529cef83d1ee0ddce4897d5f8e92145fb916 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 23 Apr 2025 17:42:28 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=86=B7=E6=BA=90=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E9=94=AE=E5=90=AF=E5=81=9C=E4=BF=AE=E5=A4=8D=EF=BC=9B?= =?UTF-8?q?=202=E3=80=81=E6=B8=A9=E6=B9=BF=E5=BA=A6=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=80=BB=E8=BE=91=EF=BC=9B=203=E3=80=81?= =?UTF-8?q?=E8=83=BD=E8=80=97=E4=BC=98=E5=8C=96=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/core/domain/dto/HouseGroupDTO.java | 11 +++++ .../domain/vo/CollectionParamsManageVO.java | 2 +- .../dealdata/impl/DataProcessServiceImpl.java | 4 +- .../device/CollectionParamsManageMapper.java | 7 ++-- .../mh/system/mapper/energy/EnergyMapper.java | 17 ++++---- .../mapper/energy/EnergyQueryMapper.java | 18 ++++----- .../impl/IndoorTempMonitorServiceImpl.java | 19 +++++++-- .../energy/impl/EnergyAnalyzeServiceImpl.java | 2 + .../resources/mapper/system/EnergyMapper.xml | 40 ++++++++++--------- 9 files changed, 75 insertions(+), 45 deletions(-) diff --git a/mh-common/src/main/java/com/mh/common/core/domain/dto/HouseGroupDTO.java b/mh-common/src/main/java/com/mh/common/core/domain/dto/HouseGroupDTO.java index 3ca73e7..8406f9c 100644 --- a/mh-common/src/main/java/com/mh/common/core/domain/dto/HouseGroupDTO.java +++ b/mh-common/src/main/java/com/mh/common/core/domain/dto/HouseGroupDTO.java @@ -11,12 +11,14 @@ import java.util.List; public class HouseGroupDTO { private String houseId; private String houseName; + private int orderNum; private List deviceList = new ArrayList<>(); // 分组构造器 public HouseGroupDTO(TempHumidityDTO data) { this.houseId = data.getHouseId(); this.houseName = data.getHouseName(); + this.orderNum = data.getOrderNum(); } // 合并设备的方法 @@ -29,6 +31,14 @@ public class HouseGroupDTO { this.deviceList.add(new DeviceDTO(data)); } + public int getOrderNum() { + return orderNum; + } + + public void setOrderNum(int orderNum) { + this.orderNum = orderNum; + } + public String getHouseId() { return houseId; } @@ -61,4 +71,5 @@ public class HouseGroupDTO { .append("deviceList", deviceList) .toString(); } + } diff --git a/mh-common/src/main/java/com/mh/common/core/domain/vo/CollectionParamsManageVO.java b/mh-common/src/main/java/com/mh/common/core/domain/vo/CollectionParamsManageVO.java index 9a54c2f..d861870 100644 --- a/mh-common/src/main/java/com/mh/common/core/domain/vo/CollectionParamsManageVO.java +++ b/mh-common/src/main/java/com/mh/common/core/domain/vo/CollectionParamsManageVO.java @@ -49,7 +49,7 @@ public class CollectionParamsManageVO { } public void setCurValue(BigDecimal curValue) { - this.curValue = curValue.setScale(1, BigDecimal.ROUND_HALF_UP); + this.curValue = curValue.setScale(2, BigDecimal.ROUND_HALF_UP); } @Override diff --git a/mh-framework/src/main/java/com/mh/framework/dealdata/impl/DataProcessServiceImpl.java b/mh-framework/src/main/java/com/mh/framework/dealdata/impl/DataProcessServiceImpl.java index 14a8c05..e821f6e 100644 --- a/mh-framework/src/main/java/com/mh/framework/dealdata/impl/DataProcessServiceImpl.java +++ b/mh-framework/src/main/java/com/mh/framework/dealdata/impl/DataProcessServiceImpl.java @@ -88,7 +88,7 @@ public class DataProcessServiceImpl implements DataProcessService { for (CollectionParamsManage entity : collect) { BigDecimal temp = new BigDecimal(String.valueOf(data.getParams().getCurrentTemperature().getValue())); BigDecimal humidity = new BigDecimal(String.valueOf(data.getParams().getCurrentHumidity().getValue())); - if ((data.getId()+"1").equals(String.valueOf(entity.getMtNum()))) { + if (("1"+data.getId()).equals(String.valueOf(entity.getMtNum()))) { CollectionParamsManage collectionParamsManage = new CollectionParamsManage(); collectionParamsManage = entity; try { @@ -99,7 +99,7 @@ public class DataProcessServiceImpl implements DataProcessService { } collectionParamsManage.setCurTime(curTime); entities.add(collectionParamsManage); - } else if ((data.getId()+"2").equals(String.valueOf(entity.getMtNum()))) { + } else if (("2"+data.getId()).equals(String.valueOf(entity.getMtNum()))) { CollectionParamsManage collectionParamsManage = new CollectionParamsManage(); collectionParamsManage = entity; try { 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 b55d1d4..8ba00b7 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 @@ -147,7 +147,7 @@ public interface CollectionParamsManageMapper extends BaseMapper= CURRENT_DATE " + @@ -162,13 +162,14 @@ public interface CollectionParamsManageMapper extends BaseMapper selectByParamType(@Param("systemType") String systemType, @Param("floorId") String floorId, @Param("paramType") String paramType); diff --git a/mh-system/src/main/java/com/mh/system/mapper/energy/EnergyMapper.java b/mh-system/src/main/java/com/mh/system/mapper/energy/EnergyMapper.java index babcaa0..362bb4b 100644 --- a/mh-system/src/main/java/com/mh/system/mapper/energy/EnergyMapper.java +++ b/mh-system/src/main/java/com/mh/system/mapper/energy/EnergyMapper.java @@ -48,15 +48,15 @@ public interface EnergyMapper { "where " + " dm.cur_time >= #{startTime}::timestamp " + " AND dm.cur_time <= #{endTime}::timestamp " + - " and device_num in ( " + + " and dm.device_num in ( " + " select " + - " device_num " + + " cpm.mt_num " + " from " + " collection_params_manage cpm " + " join device_ledger dl " + "on " + " cpm.device_ledger_id = dl.id " + - " and dl.device_type in ('5', '6') and cpm.grade = 40 " + + " and dl.device_type in ('5', '6') and cpm.grade = 40 and cpm.terminal_device_type = '15' " + "" + " and cpm.system_type = #{systemType} " + "" + @@ -99,15 +99,15 @@ public interface EnergyMapper { "where " + " dm.cur_time >= #{startTime}::timestamp " + " AND dm.cur_time <= #{endTime}::timestamp " + - " and device_num in ( " + + " and dm.device_num in ( " + " select " + - " device_num " + + " cpm.mt_num " + " from " + " collection_params_manage cpm " + " join device_ledger dl " + "on " + " cpm.device_ledger_id = dl.id " + - " and dl.device_type in ('5', '6') and cpm.grade = 40 " + + " and dl.device_type in ('5', '6') and cpm.grade = 40 and cpm.terminal_device_type = '15' " + "" + " and cpm.system_type = #{systemType} " + "" + @@ -167,15 +167,16 @@ public interface EnergyMapper { "where " + " dm.cur_time >= #{startTime}::timestamp " + " AND dm.cur_time <= #{endTime}::timestamp " + - " and device_num in ( " + + " and dm.device_num in ( " + " select " + - " device_num " + + " cpm.mt_num " + " from " + " collection_params_manage cpm " + " join device_ledger dl " + "on " + " cpm.device_ledger_id = dl.id " + " and dl.device_type in ('5', '6') and cpm.grade = 40 " + + " and cpm.terminal_device_type = '15' " + "" + " and cpm.system_type = #{systemType} " + "" + diff --git a/mh-system/src/main/java/com/mh/system/mapper/energy/EnergyQueryMapper.java b/mh-system/src/main/java/com/mh/system/mapper/energy/EnergyQueryMapper.java index 888853d..eff4eb0 100644 --- a/mh-system/src/main/java/com/mh/system/mapper/energy/EnergyQueryMapper.java +++ b/mh-system/src/main/java/com/mh/system/mapper/energy/EnergyQueryMapper.java @@ -48,15 +48,15 @@ public interface EnergyQueryMapper { "where " + " dm.cur_time >= #{startTime}::timestamp " + " AND dm.cur_time <= #{endTime}::timestamp " + - " and device_num in ( " + + " and dh.device_num in ( " + " select " + - " device_num " + + " cpm.mt_num " + " from " + " collection_params_manage cpm " + " join device_ledger dl " + "on " + " cpm.device_ledger_id = dl.id " + - " and dl.device_type in ('5', '6') " + + " and dl.device_type in ('5', '6') and cpm.terminal_device_type = '15' " + " " + " and cpm.system_type = #{systemType} " + "" + @@ -99,15 +99,15 @@ public interface EnergyQueryMapper { "where " + " dm.cur_time >= #{startTime}::timestamp " + " AND dm.cur_time <= #{endTime}::timestamp " + - " and device_num in ( " + + " and dm.device_num in ( " + " select " + - " device_num " + + " cpm.mt_num " + " from " + " collection_params_manage cpm " + " join device_ledger dl " + "on " + " cpm.device_ledger_id = dl.id " + - " and dl.device_type in ('5', '6') " + + " and dl.device_type in ('5', '6') and cpm.terminal_device_type = '15' " + " " + " and cpm.system_type = #{systemType} " + "" + @@ -169,15 +169,15 @@ public interface EnergyQueryMapper { "where " + " dm.cur_time >= #{startTime}::timestamp " + " AND dm.cur_time <= #{endTime}::timestamp " + - " and device_num in ( " + + " and dm.device_num in ( " + " select " + - " device_num " + + " cpm.mt_num " + " from " + " collection_params_manage cpm " + " join device_ledger dl " + "on " + " cpm.device_ledger_id = dl.id " + - " and dl.device_type in ('5', '6') " + + " and dl.device_type in ('5', '6') and cpm.terminal_device_type = '15' " + " " + " and cpm.system_type = #{systemType} " + "" + diff --git a/mh-system/src/main/java/com/mh/system/service/device/impl/IndoorTempMonitorServiceImpl.java b/mh-system/src/main/java/com/mh/system/service/device/impl/IndoorTempMonitorServiceImpl.java index fa2da58..c736bd1 100644 --- a/mh-system/src/main/java/com/mh/system/service/device/impl/IndoorTempMonitorServiceImpl.java +++ b/mh-system/src/main/java/com/mh/system/service/device/impl/IndoorTempMonitorServiceImpl.java @@ -48,8 +48,16 @@ public class IndoorTempMonitorServiceImpl implements IIndoorTempMonitorService { public List getIndoorTempByFloor(String systemType, String floorId) throws JsonProcessingException { // 查询采集类型是温度的参数,采集参数是12 List collectionParamsManages = collectionParamsManageMapper.selectByParamType(systemType, floorId, "12"); + // 遍历重新设置otherName为温度 + for (TempHumidityDTO tempHumidityDTO : collectionParamsManages) { + tempHumidityDTO.setOtherName("温度"); + } // 湿度采集参数:32 List humidityDTOS = collectionParamsManageMapper.selectByParamType(systemType, floorId, "32"); + // 遍历重新设置otherName为湿度 + for (TempHumidityDTO tempHumidityDTO : humidityDTOS) { + tempHumidityDTO.setOtherName("湿度"); + } // 合并collectionParamsManages和humidityDTOS collectionParamsManages.addAll(humidityDTOS); return convert(collectionParamsManages); @@ -63,11 +71,13 @@ public class IndoorTempMonitorServiceImpl implements IIndoorTempMonitorService { * @throws JsonProcessingException */ public static List convert(List dataList) throws JsonProcessingException { + // 先按orderNum升序排序原始数据 + dataList.sort(Comparator.comparingInt(TempHumidityDTO::getOrderNum)); + // 使用复合键分组(houseId + houseName) Map groupedMap = dataList.stream() .collect(Collectors.groupingBy( data -> { - // 添加日志以检查每条数据的 houseId 和 houseName log.info("Processing data: houseId={}, houseName={}", data.getHouseId(), data.getHouseName()); return data.getHouseId() + "|" + data.getHouseName(); }, @@ -86,10 +96,13 @@ public class IndoorTempMonitorServiceImpl implements IIndoorTempMonitorService { ) )); - // 转换为有序列表(按首次出现顺序) - return new ArrayList<>(groupedMap.values()); + // 转换为有序列表(按orderNum升序) + return groupedMap.values().stream() + .sorted(Comparator.comparingInt(HouseGroupDTO::getOrderNum)) + .collect(Collectors.toList()); } + @Override public List getIndoorTempHisByFloorAndHouseId(String systemType, String floorId, String houseId) { return List.of(); 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 7ff6f38..d605801 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 @@ -83,6 +83,8 @@ public class EnergyAnalyzeServiceImpl implements EnergyAnalyzeService { // 开始进行分组 // 通过device_manage的grade进行分组,分为四类:0-9:冷水机,10-19:冷冻泵,20-29:冷却泵,30-39:冷却塔 HashMap result = deviceTypeEnergyEntities.stream() + // 过滤叼总表的数据(deviceType=15) + .filter(deviceTypeEnergyEntity -> !deviceTypeEnergyEntity.getDeviceType().equals("15")) .collect(Collectors.groupingBy(DeviceTypeEnergy::getDeviceTypeRange)) .entrySet().stream().collect(Collectors.toMap( Map.Entry>::getKey, diff --git a/mh-system/src/main/resources/mapper/system/EnergyMapper.xml b/mh-system/src/main/resources/mapper/system/EnergyMapper.xml index a20a0fe..fe1d883 100644 --- a/mh-system/src/main/resources/mapper/system/EnergyMapper.xml +++ b/mh-system/src/main/resources/mapper/system/EnergyMapper.xml @@ -104,7 +104,7 @@ and cpm.system_type = #{systemType} - and cpm.grade = 40 ) + and cpm.grade = 40 and cpm.terminal_device_type = '15' ) GROUP BY device_type, TO_CHAR(cur_time, 'YYYY-MM-DD HH24:MI:SS'), EXTRACT(YEAR FROM cur_time) @@ -140,7 +140,7 @@ and cpm.system_type = #{systemType} - and cpm.grade = 40 ) + and cpm.grade = 40 and cpm.terminal_device_type = '15' ) GROUP BY device_type, TO_CHAR(cur_time, 'YYYY-MM-DD HH24:MI:SS'), EXTRACT(YEAR FROM cur_time) @@ -175,7 +175,7 @@ and cpm.system_type = #{systemType} - and cpm.grade = 40 ) + and cpm.grade = 40 and cpm.terminal_device_type = '15' ) GROUP BY device_type, TO_CHAR(cur_time, 'YYYY-MM-DD HH24:MI:SS'), EXTRACT(YEAR FROM cur_time) @@ -210,7 +210,7 @@ and cpm.system_type = #{systemType} - and cpm.grade = 40 ) + and cpm.grade = 40 and cpm.terminal_device_type = '15' ) GROUP BY device_type, TO_CHAR(cur_time, 'YYYY-MM-DD HH24:MI:SS'), EXTRACT(YEAR FROM cur_time) @@ -252,7 +252,7 @@ and cpm.system_type = #{systemType} - and cpm.grade = 40 ) + and cpm.grade = 40 and cpm.terminal_device_type = '15' ) GROUP BY device_type, SUBSTRING(TO_CHAR(cur_time, 'YYYY-MM-DD HH24:MI:SS') FROM 1 FOR ${len}), @@ -281,7 +281,7 @@ and cpm.system_type = #{systemType} - and cpm.grade = 40 ) + and cpm.grade = 40 and cpm.terminal_device_type = '15' ) GROUP BY device_type, SUBSTRING(TO_CHAR(cur_time, 'YYYY-MM-DD HH24:MI:SS') FROM 1 FOR ${len}), @@ -311,7 +311,7 @@ and cpm.system_type = #{systemType} - and cpm.grade = 40 ) + and cpm.grade = 40 and cpm.terminal_device_type = '15' ) GROUP BY device_type, SUBSTRING(TO_CHAR(cur_time, 'YYYY-MM-DD HH24:MI:SS') FROM 1 FOR ${len}), @@ -340,7 +340,7 @@ and cpm.system_type = #{systemType} - and cpm.grade = 40 ) + and cpm.grade = 40 and cpm.terminal_device_type = '15' ) GROUP BY device_type, SUBSTRING(TO_CHAR(cur_time, 'YYYY-MM-DD HH24:MI:SS') FROM 1 FOR ${len}), @@ -391,7 +391,7 @@ and cpm.system_type = #{systemType} - and cpm.grade = 40 ) + and cpm.grade = 40 and cpm.terminal_device_type = '15' ) GROUP BY TO_CHAR(cur_time, 'YYYY-MM-DD HH24:MI:SS'), EXTRACT(YEAR FROM cur_time) @@ -429,7 +429,7 @@ and cpm.system_type = #{systemType} - and cpm.grade = 40 ) + and cpm.grade = 40 and cpm.terminal_device_type = '15' ) GROUP BY EXTRACT(YEAR FROM cur_time) @@ -490,7 +490,7 @@ and cpm.system_type = #{systemType} - and cpm.grade = 40 ) + and cpm.grade = 40 and cpm.terminal_device_type = '15' ) group by substring(to_char(cur_time, 'YYYY-MM-DD HH24:MI:SS') from 1 for ${len}), @@ -530,7 +530,7 @@ and cpm.system_type = #{systemType} - and cpm.grade = 40 ) + and cpm.grade = 40 and cpm.terminal_device_type = '15' ) group by extract(year from cur_time) @@ -581,7 +581,7 @@ and cpm.system_type = #{systemType} - and cpm.grade = 40 ) + and cpm.grade = 40 and cpm.terminal_device_type = '15' ) group by substring(to_char(cur_time, 'YYYY-MM-DD HH24:MI:SS') from 1 for ${len}), extract(year from cur_time) @@ -610,7 +610,7 @@ and cpm.system_type = #{systemType} - and cpm.grade = 40 ) + and cpm.grade = 40 and cpm.terminal_device_type = '15' ) group by substring(to_char(cur_time, 'YYYY-MM-DD HH24:MI:SS') from 1 for ${len}), extract(year from cur_time) @@ -640,7 +640,7 @@ and cpm.system_type = #{systemType} - and cpm.grade = 40 ) + and cpm.grade = 40 and cpm.terminal_device_type = '15' ) group by extract(year from cur_time) @@ -667,7 +667,7 @@ and cpm.system_type = #{systemType} - and cpm.grade = 40 ) + and cpm.grade = 40 and cpm.terminal_device_type = '15' ) group by extract(year from cur_time) @@ -854,6 +854,7 @@ cpm.device_ledger_id = dl.id and dl.device_type = '5' and cpm.grade = 140 + and cpm.terminal_device_type = '15' ) group by device_type, @@ -877,9 +878,10 @@ collection_params_manage cpm join device_ledger dl on - cpm.device_ledger_id = dl.id - and dl.device_type = '6' - and cpm.grade = 140 + cpm.device_ledger_id = dl.id + and dl.device_type = '6' + and cpm.grade = 140 + and cpm.terminal_device_type = '15' ) group by device_type,