Browse Source

1、冷源系统一键启停修复;

2、温湿度系统优化逻辑;
3、能耗优化;
dev
mh 2 weeks ago
parent
commit
8b4b529cef
  1. 11
      mh-common/src/main/java/com/mh/common/core/domain/dto/HouseGroupDTO.java
  2. 2
      mh-common/src/main/java/com/mh/common/core/domain/vo/CollectionParamsManageVO.java
  3. 4
      mh-framework/src/main/java/com/mh/framework/dealdata/impl/DataProcessServiceImpl.java
  4. 7
      mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java
  5. 17
      mh-system/src/main/java/com/mh/system/mapper/energy/EnergyMapper.java
  6. 18
      mh-system/src/main/java/com/mh/system/mapper/energy/EnergyQueryMapper.java
  7. 19
      mh-system/src/main/java/com/mh/system/service/device/impl/IndoorTempMonitorServiceImpl.java
  8. 2
      mh-system/src/main/java/com/mh/system/service/energy/impl/EnergyAnalyzeServiceImpl.java
  9. 34
      mh-system/src/main/resources/mapper/system/EnergyMapper.xml

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

2
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

4
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 {

7
mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java

@ -147,7 +147,7 @@ public interface CollectionParamsManageMapper extends BaseMapper<CollectionParam
" cpm.cur_time, " +
" cpm.id as cpm_id, " +
" dl.status, " +
" cpm.order_num, " +
" hi.order_num, " +
" cpm.param_type, " +
" case " +
" when ar.create_time >= CURRENT_DATE " +
@ -162,13 +162,14 @@ public interface CollectionParamsManageMapper extends BaseMapper<CollectionParam
" csr.house_id = hi.id " +
"join device_ledger dl on " +
" dl.id = cpm.device_ledger_id " +
"join alarm_records ar on " +
"left join alarm_records ar on " +
" ar.cpm_id = cpm.id " +
"where " +
" csr.floor_id = #{floorId} " +
" and hi.floor_id = #{floorId} " +
" and cpm.param_type = #{paramType} " +
" and cpm.system_type = #{systemType}; ")
" and cpm.system_type = #{systemType}" +
" order by hi.order_num ; ")
List<TempHumidityDTO> selectByParamType(@Param("systemType") String systemType,
@Param("floorId") String floorId,
@Param("paramType") String paramType);

17
mh-system/src/main/java/com/mh/system/mapper/energy/EnergyMapper.java

@ -48,15 +48,15 @@ public interface EnergyMapper {
"where " +
" dm.cur_time &gt;= #{startTime}::timestamp " +
" AND dm.cur_time &lt;= #{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' " +
"<if test='systemType != null and systemType != \"\"'>" +
" and cpm.system_type = #{systemType} " +
"</if>" +
@ -99,15 +99,15 @@ public interface EnergyMapper {
"where " +
" dm.cur_time &gt;= #{startTime}::timestamp " +
" AND dm.cur_time &lt;= #{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' " +
"<if test='systemType != null and systemType != \"\"'>" +
" and cpm.system_type = #{systemType} " +
"</if>" +
@ -167,15 +167,16 @@ public interface EnergyMapper {
"where " +
" dm.cur_time &gt;= #{startTime}::timestamp " +
" AND dm.cur_time &lt;= #{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' " +
"<if test='systemType != null and systemType != \"\"'>" +
" and cpm.system_type = #{systemType} " +
"</if>" +

18
mh-system/src/main/java/com/mh/system/mapper/energy/EnergyQueryMapper.java

@ -48,15 +48,15 @@ public interface EnergyQueryMapper {
"where " +
" dm.cur_time &gt;= #{startTime}::timestamp " +
" AND dm.cur_time &lt;= #{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' " +
"<if test='systemType != null and systemType != \"\"'> " +
" and cpm.system_type = #{systemType} " +
"</if>" +
@ -99,15 +99,15 @@ public interface EnergyQueryMapper {
"where " +
" dm.cur_time &gt;= #{startTime}::timestamp " +
" AND dm.cur_time &lt;= #{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' " +
"<if test='systemType != null and systemType != \"\"'> " +
" and cpm.system_type = #{systemType} " +
"</if>" +
@ -169,15 +169,15 @@ public interface EnergyQueryMapper {
"where " +
" dm.cur_time &gt;= #{startTime}::timestamp " +
" AND dm.cur_time &lt;= #{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' " +
"<if test='systemType != null and systemType != \"\"'> " +
" and cpm.system_type = #{systemType} " +
"</if>" +

19
mh-system/src/main/java/com/mh/system/service/device/impl/IndoorTempMonitorServiceImpl.java

@ -48,8 +48,16 @@ public class IndoorTempMonitorServiceImpl implements IIndoorTempMonitorService {
public List<HouseGroupDTO> getIndoorTempByFloor(String systemType, String floorId) throws JsonProcessingException {
// 查询采集类型是温度的参数,采集参数是12
List<TempHumidityDTO> collectionParamsManages = collectionParamsManageMapper.selectByParamType(systemType, floorId, "12");
// 遍历重新设置otherName为温度
for (TempHumidityDTO tempHumidityDTO : collectionParamsManages) {
tempHumidityDTO.setOtherName("温度");
}
// 湿度采集参数:32
List<TempHumidityDTO> 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<HouseGroupDTO> convert(List<TempHumidityDTO> dataList) throws JsonProcessingException {
// 先按orderNum升序排序原始数据
dataList.sort(Comparator.comparingInt(TempHumidityDTO::getOrderNum));
// 使用复合键分组(houseId + houseName)
Map<String, HouseGroupDTO> 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<IndoorTempVO> getIndoorTempHisByFloorAndHouseId(String systemType, String floorId, String houseId) {
return List.of();

2
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<String, BigDecimal> result = deviceTypeEnergyEntities.stream()
// 过滤叼总表的数据(deviceType=15)
.filter(deviceTypeEnergyEntity -> !deviceTypeEnergyEntity.getDeviceType().equals("15"))
.collect(Collectors.groupingBy(DeviceTypeEnergy::getDeviceTypeRange))
.entrySet().stream().collect(Collectors.toMap(
Map.Entry<String, List<DeviceTypeEnergy>>::getKey,

34
mh-system/src/main/resources/mapper/system/EnergyMapper.xml

@ -104,7 +104,7 @@
<if test="systemType != null and systemType != '' ">
and cpm.system_type = #{systemType}
</if>
and cpm.grade = 40 )
and cpm.grade = 40 and cpm.terminal_device_type = '15' )
</if>
GROUP BY device_type, TO_CHAR(cur_time, 'YYYY-MM-DD HH24:MI:SS'), EXTRACT(YEAR FROM cur_time)
<include refid="commonGroupSql" />
@ -140,7 +140,7 @@
<if test="systemType != null and systemType != '' ">
and cpm.system_type = #{systemType}
</if>
and cpm.grade = 40 )
and cpm.grade = 40 and cpm.terminal_device_type = '15' )
</if>
GROUP BY device_type, TO_CHAR(cur_time, 'YYYY-MM-DD HH24:MI:SS'), EXTRACT(YEAR FROM cur_time)
<include refid="commonGroupSql" />
@ -175,7 +175,7 @@
<if test="systemType != null and systemType != '' ">
and cpm.system_type = #{systemType}
</if>
and cpm.grade = 40 )
and cpm.grade = 40 and cpm.terminal_device_type = '15' )
</if>
GROUP BY device_type, TO_CHAR(cur_time, 'YYYY-MM-DD HH24:MI:SS'), EXTRACT(YEAR FROM cur_time)
<include refid="commonGroupSql" />
@ -210,7 +210,7 @@
<if test="systemType != null and systemType != '' ">
and cpm.system_type = #{systemType}
</if>
and cpm.grade = 40 )
and cpm.grade = 40 and cpm.terminal_device_type = '15' )
</if>
GROUP BY device_type, TO_CHAR(cur_time, 'YYYY-MM-DD HH24:MI:SS'), EXTRACT(YEAR FROM cur_time)
<include refid="commonGroupSql" />
@ -252,7 +252,7 @@
<if test="systemType != null and systemType != '' ">
and cpm.system_type = #{systemType}
</if>
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 @@
<if test="systemType != null and systemType != '' ">
and cpm.system_type = #{systemType}
</if>
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 @@
<if test="systemType != null and systemType != '' ">
and cpm.system_type = #{systemType}
</if>
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 @@
<if test="systemType != null and systemType != '' ">
and cpm.system_type = #{systemType}
</if>
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 @@
<if test="systemType != null and systemType != '' ">
and cpm.system_type = #{systemType}
</if>
and cpm.grade = 40 )
and cpm.grade = 40 and cpm.terminal_device_type = '15' )
</if>
GROUP BY TO_CHAR(cur_time, 'YYYY-MM-DD HH24:MI:SS'), EXTRACT(YEAR FROM cur_time)
<if test="timeType!= null and timeType!= '' and timeType == 'month'">
@ -429,7 +429,7 @@
<if test="systemType != null and systemType != '' ">
and cpm.system_type = #{systemType}
</if>
and cpm.grade = 40 )
and cpm.grade = 40 and cpm.terminal_device_type = '15' )
</if>
GROUP BY EXTRACT(YEAR FROM cur_time)
<if test="timeType!= null and timeType!= '' and timeType == 'month'">
@ -490,7 +490,7 @@
<if test="systemType != null and systemType != '' ">
and cpm.system_type = #{systemType}
</if>
and cpm.grade = 40 )
and cpm.grade = 40 and cpm.terminal_device_type = '15' )
</if>
group by
substring(to_char(cur_time, 'YYYY-MM-DD HH24:MI:SS') from 1 for ${len}),
@ -530,7 +530,7 @@
<if test="systemType != null and systemType != '' ">
and cpm.system_type = #{systemType}
</if>
and cpm.grade = 40 )
and cpm.grade = 40 and cpm.terminal_device_type = '15' )
</if>
group by
extract(year from cur_time)
@ -581,7 +581,7 @@
<if test="systemType != null and systemType != '' ">
and cpm.system_type = #{systemType}
</if>
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 @@
<if test="systemType != null and systemType != '' ">
and cpm.system_type = #{systemType}
</if>
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 @@
<if test="systemType != null and systemType != '' ">
and cpm.system_type = #{systemType}
</if>
and cpm.grade = 40 )
and cpm.grade = 40 and cpm.terminal_device_type = '15' )
group by
extract(year from cur_time)
<include refid="commonLastGroupSql"/>
@ -667,7 +667,7 @@
<if test="systemType != null and systemType != '' ">
and cpm.system_type = #{systemType}
</if>
and cpm.grade = 40 )
and cpm.grade = 40 and cpm.terminal_device_type = '15' )
group by
extract(year from cur_time)
<include refid="commonLastGroupSql"/>
@ -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,
@ -880,6 +881,7 @@
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,

Loading…
Cancel
Save