Browse Source

1、设备采集参数管理;

2、热回收首页、设备热量查询、设备组热量查询、系统热量查询;
dev_gh_ers
25604 3 weeks ago
parent
commit
0288f2cffb
  1. 14
      mh-admin/src/main/java/com/mh/web/controller/comprehensive/ProOverviewController.java
  2. 20
      mh-admin/src/main/java/com/mh/web/controller/energy/SysEnergyQueryController.java
  3. 45
      mh-admin/src/main/java/com/mh/web/controller/monitor/ERSMonitorController.java
  4. 51
      mh-common/src/main/java/com/mh/common/core/domain/vo/CollectionParamsManageDataVO.java
  5. 11
      mh-common/src/main/java/com/mh/common/utils/DateUtils.java
  6. 19
      mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java
  7. 222
      mh-system/src/main/java/com/mh/system/mapper/energy/HeatEnergyQueryMapper.java
  8. 2
      mh-system/src/main/java/com/mh/system/service/device/ICollectionParamsManageService.java
  9. 140
      mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java
  10. 18
      mh-system/src/main/java/com/mh/system/service/energy/IHeatQueryAnalyzeService.java
  11. 8
      mh-system/src/main/java/com/mh/system/service/energy/impl/EnergyQueryServiceImpl.java
  12. 200
      mh-system/src/main/java/com/mh/system/service/energy/impl/HeatQueryAnalyzeImpl.java
  13. 2
      mh-system/src/main/java/com/mh/system/service/overview/IProOverviewService.java
  14. 382
      mh-system/src/main/java/com/mh/system/service/overview/impl/ProOverviewServiceImpl.java

14
mh-admin/src/main/java/com/mh/web/controller/comprehensive/ProOverviewController.java

@ -91,4 +91,18 @@ public class ProOverviewController extends BaseController {
return getDataTable(proOverviewService.mainParams());
}
/**
* 获取热回收系统相关数据
* 出水温度离心机高温出水温度中温换热出水温度低温1换热出水温度低温2换热出水温度
* 热量数据生产累积热量散热累积热量总热量回收热利用率
* 系统数据离心机入口温度离心机出水温度保障进水温度
* 阀门开度二通阀阀门开度三通阀阀门开度
* 热回收数据瞬时热量日累积热量累积热量
* 应用侧数据瞬时热量日累计热量累积热量
*
*/
@GetMapping("/ersDatas")
public TableDataInfo ersDatas(@RequestParam("systemType") String systemType) {
return getDataTable(proOverviewService.ersDatas(systemType));
}
}

20
mh-admin/src/main/java/com/mh/web/controller/energy/SysEnergyQueryController.java

@ -54,6 +54,9 @@ public class SysEnergyQueryController {
// 文件名
try {
String fileName = "机房整体能耗表.xlsx";
if (vo.getSystemType().equalsIgnoreCase("7")) {
fileName = "热回收热量总计表.xlsx";
}
// 从数据库获取数据
List<Map<String, Object>> dataList = (List<Map<String, Object>>) energyQueryService.sysQuery(vo).get("data");
if (dataList != null) {
@ -71,6 +74,20 @@ public class SysEnergyQueryController {
for (Map<String, Object> map : dataList) {
if (map.containsKey("titleArr")) {
titleArr = Arrays.asList((String[]) map.get("titleArr"));
if (vo.getSystemType().equalsIgnoreCase("7")) {
List<String> head0 = ListUtils.newArrayList();
head0.add("日期");
List<String> head1 = ListUtils.newArrayList();
head1.add("散热量");
List<String> head2 = ListUtils.newArrayList();
head2.add("总热量回收");
List<String> head3 = ListUtils.newArrayList();
head3.add("热利用率");
head.add(head0);
head.add(head1);
head.add(head2);
head.add(head3);
} else {
List<String> head0 = ListUtils.newArrayList();
head0.add("日期");
List<String> head1 = ListUtils.newArrayList();
@ -84,6 +101,7 @@ public class SysEnergyQueryController {
head.add(head2);
head.add(head3);
}
}
if (map.containsKey("timeStrArr")) {
timeStrArr = Arrays.asList((String[])map.get("timeStrArr"));
}
@ -107,7 +125,7 @@ public class SysEnergyQueryController {
excelDataList.add(list1);
}
// 内容格式
EasyExcel.write(response.getOutputStream()).head(head).sheet("机房整体能耗表").doWrite(excelDataList);
EasyExcel.write(response.getOutputStream()).head(head).sheet(fileName.substring(0, fileName.lastIndexOf("."))).doWrite(excelDataList);
}
} catch (Exception e) {
log.error("下载报表异常", e);

45
mh-admin/src/main/java/com/mh/web/controller/monitor/ERSMonitorController.java

@ -0,0 +1,45 @@
package com.mh.web.controller.monitor;
import com.mh.common.core.controller.BaseController;
import com.mh.common.core.domain.dto.DeviceMonitorDTO;
import com.mh.common.core.page.TableDataInfo;
import com.mh.system.service.device.ICollectionParamsManageService;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author LJF
* @version 1.0
* @project EEMCS
* @description 热回收系统工业流程图
* @date 2026-01-28 13:48:13
*/
@RestController
@RequestMapping("/device/ers")
public class ERSMonitorController extends BaseController {
@Resource
private ICollectionParamsManageService iCollectionParamsManageService;
@PreAuthorize("@ss.hasPermi('device:cpm:list')")
@GetMapping("/monitor/list")
public TableDataInfo list(@RequestParam(name = "systemType") String systemType)
{
List<DeviceMonitorDTO> list = iCollectionParamsManageService.selectMonitorListBySystemType(systemType);
return getDataTable(list);
}
@GetMapping("/monitor/totalDatas")
public TableDataInfo totalERSDatas(@RequestParam(name = "systemType") String systemType)
{
List<?> list = iCollectionParamsManageService.totalERSDatas(systemType);
return getDataTable(list);
}
}

51
mh-common/src/main/java/com/mh/common/core/domain/vo/CollectionParamsManageDataVO.java

@ -0,0 +1,51 @@
package com.mh.common.core.domain.vo;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;
/**
* @author LJF
* @version 1.0
* @project EEMCS
* @description 辅助计算类
* @date 2026-01-28 14:27:20
*/
@Data
public class CollectionParamsManageDataVO {
// getter方法
private String deviceName;
private Integer orderNum;
private String systemType;
private String deviceType;
private String otherName;
private String paramType;
private BigDecimal curValue;
private Date curTime;
private Integer grade;
private Integer status;
// 构造函数
public CollectionParamsManageDataVO(Map<String, Object> map) {
this.deviceName = (String) map.get("device_name");
this.orderNum = map.get("order_num") instanceof Integer ?
(Integer) map.get("order_num") :
(map.get("order_num") != null ? Integer.valueOf(map.get("order_num").toString()) : null);
this.systemType = (String) map.get("system_type");
this.deviceType = (String) map.get("device_type");
this.otherName = (String) map.get("other_name");
this.paramType = (String) map.get("param_type");
this.curValue = map.get("cur_value") instanceof BigDecimal ?
(BigDecimal) map.get("cur_value") :
(map.get("cur_value") != null ? new BigDecimal(map.get("cur_value").toString()) : BigDecimal.ZERO);
this.curTime = (Date) map.get("cur_time");
this.grade = map.get("grade") instanceof Integer ?
(Integer) map.get("grade") :
(map.get("grade") != null ? Integer.valueOf(map.get("grade").toString()) : null);
this.status = (Integer) map.get("status");
}
}

11
mh-common/src/main/java/com/mh/common/utils/DateUtils.java

@ -39,6 +39,17 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
public static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
/**
* 判断日期是否为今天
*/
public static boolean isToday(Date date) {
if (date == null) return false;
LocalDate localDate = date.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate();
return localDate.equals(LocalDate.now());
}
public static String localDateToStr(LocalDateTime timeType) {
return timeType.format(DATE_TIME_FORMATTER);
}

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

@ -201,7 +201,7 @@ public interface CollectionParamsManageMapper extends BaseMapper<CollectionParam
" cpm.device_ledger_id, " +
" dl.device_name, " +
" cpm.other_name, " +
" cpm.cur_value, " +
" COALESCE(cpm.cur_value, 0) as cur_value, " +
" cpm.cur_time, " +
" cpm.param_type," +
" dl.order_num as dl_order_num," +
@ -366,4 +366,21 @@ public interface CollectionParamsManageMapper extends BaseMapper<CollectionParam
" or param_type = '11' " +
" or param_type = '48')")
List<CollectionParamsManage> createOrderList();
@Select("SELECT " +
" dl.device_name, " +
" dl.order_num, " +
" dl.system_type, " +
" dl.device_type, " +
" cpm.other_name, " +
" cpm.param_type, " +
" cpm.cur_value, " +
" cpm.cur_time, " +
" cpm.grade " +
"FROM collection_params_manage cpm " +
"JOIN device_ledger dl ON cpm.device_ledger_id = dl.id " +
"WHERE dl.system_type = #{systemType}")
List<Map<String, Object>> selectErsDatas(@Param("systemType") String systemType);
}

222
mh-system/src/main/java/com/mh/system/mapper/energy/HeatEnergyQueryMapper.java

@ -0,0 +1,222 @@
package com.mh.system.mapper.energy;
import com.mh.common.core.domain.entity.ConsumptionAnalyze;
import com.mh.common.core.domain.entity.CpmSpaceRelation;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* @author LJF
* @version 1.0
* @project gh_ers
* @description 系统热量查询
* @date 2023-12-13 16:00:01
*/
@Mapper
public interface HeatEnergyQueryMapper {
/**
* 跨表查询操作
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param lastTableName 上一个表名
* @param curTableName 当前表名
* @param totalHeat
* @return
*/
@Select("<script>" +
"select " +
" sum(dm.calc_value) as curValue, " +
" dm.device_type, " +
" TO_CHAR(dm.cur_time, " +
" <choose>" +
" <when test='len == 4'>'YYYY'</when>" +
" <when test='len == 7'>'YYYY-MM'</when>" +
" <when test='len == 10'>'YYYY-MM-DD'</when>" +
" <when test='len == 13'>'YYYY-MM-DD HH24'</when>" +
" <when test='len == 16'>'YYYY-MM-DD HH24:MI'</when>" +
" <otherwise>'YYYY-MM-DD HH24:MI:SS'</otherwise>" +
" </choose>" +
" ) AS timeStr " +
"from " +
" ${lastTableName} dm " +
"where " +
" dm.cur_time &gt;= #{startTime}::timestamp " +
" AND dm.cur_time &lt;= #{endTime}::timestamp " +
" and dh.device_num in ( " +
" select " +
" cpm.mt_num " +
" from " +
" collection_params_manage cpm " +
" join device_ledger dl " +
"on " +
" cpm.device_ledger_id = dl.id " +
" and dl.device_type in ('6') " +
"<if test='systemType != null and systemType != \"\"'> " +
" and cpm.system_type = #{systemType} " +
"</if>" +
"<if test='paramType != null and paramType != \"\"'>" +
" and cpm.param_type = #{paramType} " +
"</if>" +
"<if test='list != null and list.size() > 0'>" +
" and cpm.id in " +
" <foreach collection='list' item='item' open='(' separator=',' close=')'>" +
" #{item.cpmId}" +
" </foreach>" +
" </if>" +
") " +
") " +
"group by " +
" device_type, " +
" TO_CHAR(dm.cur_time, " +
" <choose>" +
" <when test='len == 4'>'YYYY'</when>" +
" <when test='len == 7'>'YYYY-MM'</when>" +
" <when test='len == 10'>'YYYY-MM-DD'</when>" +
" <when test='len == 13'>'YYYY-MM-DD HH24'</when>" +
" <when test='len == 16'>'YYYY-MM-DD HH24:MI'</when>" +
" <otherwise>'YYYY-MM-DD HH24:MI:SS'</otherwise>" +
" </choose>" +
" ) " +
"union all " +
"select " +
" sum(dm.calc_value) as curValue, " +
" dm.device_type, " +
" TO_CHAR(dm.cur_time, " +
" <choose>" +
" <when test='len == 4'>'YYYY'</when>" +
" <when test='len == 7'>'YYYY-MM'</when>" +
" <when test='len == 10'>'YYYY-MM-DD'</when>" +
" <when test='len == 13'>'YYYY-MM-DD HH24'</when>" +
" <when test='len == 16'>'YYYY-MM-DD HH24:MI'</when>" +
" <otherwise>'YYYY-MM-DD HH24:MI:SS'</otherwise>" +
" </choose>" +
" ) AS timeStr " +
"from " +
" ${curTableName} dm " +
"where " +
" dm.cur_time &gt;= #{startTime}::timestamp " +
" AND dm.cur_time &lt;= #{endTime}::timestamp " +
" and dm.device_num in ( " +
" select " +
" cpm.mt_num " +
" from " +
" collection_params_manage cpm " +
" join device_ledger dl " +
"on " +
" cpm.device_ledger_id = dl.id " +
" and dl.device_type in ('6') " +
"<if test='systemType != null and systemType != \"\"'> " +
" and cpm.system_type = #{systemType} " +
"</if>" +
"<if test='paramType != null and paramType != \"\"'>" +
" and cpm.param_type = #{paramType} " +
"</if>" +
"<if test='list != null and list.size() > 0'>" +
" and cpm.id in " +
" <foreach collection='list' item='item' open='(' separator=',' close=')'>" +
" #{item.cpmId}" +
" </foreach>" +
" </if>" +
") " +
") " +
"group by " +
" device_type, " +
" TO_CHAR(dm.cur_time, " +
" <choose>" +
" <when test='len == 4'>'YYYY'</when>" +
" <when test='len == 7'>'YYYY-MM'</when>" +
" <when test='len == 10'>'YYYY-MM-DD'</when>" +
" <when test='len == 13'>'YYYY-MM-DD HH24'</when>" +
" <when test='len == 16'>'YYYY-MM-DD HH24:MI'</when>" +
" <otherwise>'YYYY-MM-DD HH24:MI:SS'</otherwise>" +
" </choose>" +
" ) " +
"</script>")
List<ConsumptionAnalyze> queryManyTable(@Param("startTime") String startTime,
@Param("endTime") String endTime,
@Param("lastTableName") String lastTableName,
@Param("curTableName") String curTableName,
@Param("len") String dateLen,
@Param("paramType") String paramType,
@Param("systemType") String systemType,
@Param("list") List<CpmSpaceRelation> totalHeat);
/**
* 单表查询操作
* @param startTime 开始时间
* @param endTime 结束时间
* @param lastTableName 上一个表名
* @param curTableName 当前表名
* @return
*/
@Select("<script>" +
"select " +
" sum(dm.calc_value) as curValue, " +
" dm.device_type, " +
" TO_CHAR(dm.cur_time, " +
" <choose>" +
" <when test='len == 4'>'YYYY'</when>" +
" <when test='len == 7'>'YYYY-MM'</when>" +
" <when test='len == 10'>'YYYY-MM-DD'</when>" +
" <when test='len == 13'>'YYYY-MM-DD HH24'</when>" +
" <when test='len == 16'>'YYYY-MM-DD HH24:MI'</when>" +
" <otherwise>'YYYY-MM-DD HH24:MI:SS'</otherwise>" +
" </choose>" +
" ) AS timeStr " +
"from " +
" ${lastTableName} dm " +
"where " +
" dm.cur_time &gt;= #{startTime}::timestamp " +
" AND dm.cur_time &lt;= #{endTime}::timestamp " +
" and dm.device_num in ( " +
" select " +
" cpm.mt_num " +
" from " +
" collection_params_manage cpm " +
" join device_ledger dl " +
"on " +
" cpm.device_ledger_id = dl.id " +
" and dl.device_type in ('6') " +
"<if test='systemType != null and systemType != \"\"'> " +
" and cpm.system_type = #{systemType} " +
"</if>" +
"<if test='paramType != null and paramType != \"\"'>" +
" and cpm.param_type = #{paramType} " +
"</if>" +
"<if test='list != null and list.size() > 0'>" +
" and cpm.id in " +
" <foreach collection='list' item='item' open='(' separator=',' close=')'>" +
" #{item.cpmId}" +
" </foreach>" +
" </if>" +
") " +
"group by " +
" device_type, " +
" TO_CHAR(dm.cur_time, " +
" <choose>" +
" <when test='len == 4'>'YYYY'</when>" +
" <when test='len == 7'>'YYYY-MM'</when>" +
" <when test='len == 10'>'YYYY-MM-DD'</when>" +
" <when test='len == 13'>'YYYY-MM-DD HH24'</when>" +
" <when test='len == 16'>'YYYY-MM-DD HH24:MI'</when>" +
" <otherwise>'YYYY-MM-DD HH24:MI:SS'</otherwise>" +
" </choose>" +
" ) " +
"order by " +
" timeStr " +
"</script>")
List<ConsumptionAnalyze> queryOneTable(@Param("startTime") String startTime,
@Param("endTime") String endTime,
@Param("lastTableName") String lastTableName,
@Param("curTableName") String curTableName,
@Param("len") String dateLen,
@Param("paramType") String paramType,
@Param("systemType") String systemType,
@Param("list") List<CpmSpaceRelation> list);
}

2
mh-system/src/main/java/com/mh/system/service/device/ICollectionParamsManageService.java

@ -91,4 +91,6 @@ public interface ICollectionParamsManageService {
List<?> selectHeatPumpAlarmListByParams(String systemType, String type, String mtType, String sysParamType);
List<?> selectHeatPumpOnlineByParams(String systemType, String type);
List<?> totalERSDatas(String systemType);
}

140
mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java

@ -97,6 +97,145 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
"DB611596"// 锅炉1-用户温度设定值
);
@Override
public List<?> totalERSDatas(String systemType) {
List<Map<String, Object>> list = collectionParamsManageMapper.selectErsDatas(systemType);
if (list.isEmpty()) {
return List.of();
}
// 为每个map添加status字段,初始为0(正常)
list.forEach(map -> {
Date curTime = (Date) map.get("cur_time");
// 判断cur_time是否为今天
boolean isToday = DateUtils.isToday(curTime);
map.put("status", isToday ? 0 : 1); // 0正常,1异常
});
// 将数据转换为CollectionParamsManage对象列表,便于处理
List<CollectionParamsManageDataVO> convertedList = list.stream()
.map(CollectionParamsManageDataVO::new)
.collect(Collectors.toList());
// 组装热量数据
Map<String, Object> heatData = getHeatData(convertedList);
return List.of(heatData);
}
/**
* 获取热量数据
*/
private Map<String, Object> getHeatData(List<CollectionParamsManageDataVO> list) {
Map<String, Object> result = new HashMap<>();
// 生产累积热量 (order_num=1,2,3,4)
List<CollectionParamsManageDataVO> productionHeat = list.stream()
.filter(item -> "6".equals(item.getDeviceType()) &&
"47".equals(item.getParamType()) &&
Integer.valueOf(40).equals(item.getGrade()) &&
item.getOtherName() != null &&
item.getOtherName().contains("累积热量") &&
item.getOrderNum() != null &&
item.getOrderNum() >= 1 && item.getOrderNum() <= 4)
.toList();
BigDecimal productionHeatSum = productionHeat.stream()
.map(CollectionParamsManageDataVO::getCurValue)
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 散热累积热量 (order_num=5,6)
List<CollectionParamsManageDataVO> dissipationHeat = list.stream()
.filter(item -> "6".equals(item.getDeviceType()) &&
"47".equals(item.getParamType()) &&
Integer.valueOf(40).equals(item.getGrade()) &&
item.getOtherName() != null &&
item.getOtherName().contains("累积热量") &&
item.getOrderNum() != null &&
(item.getOrderNum() == 5 || item.getOrderNum() == 6))
.toList();
BigDecimal dissipationHeatSum = dissipationHeat.stream()
.map(CollectionParamsManageDataVO::getCurValue)
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 总热量回收 (order_num=1,2,3,4,5,6)
List<CollectionParamsManageDataVO> totalHeatRecovery = list.stream()
.filter(item -> "6".equals(item.getDeviceType()) &&
"47".equals(item.getParamType()) &&
Integer.valueOf(40).equals(item.getGrade()) &&
item.getOtherName() != null &&
item.getOtherName().contains("累积热量") &&
item.getOrderNum() != null &&
item.getOrderNum() >= 1 && item.getOrderNum() <= 6)
.toList();
BigDecimal totalHeatRecoverySum = totalHeatRecovery.stream()
.map(CollectionParamsManageDataVO::getCurValue)
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 离心机热量回收(order_num=1,2,3,5)
List<CollectionParamsManageDataVO> centrifugalHeatRecovery = list.stream()
.filter(item -> "6".equals(item.getDeviceType()) &&
"47".equals(item.getParamType()) &&
Integer.valueOf(40).equals(item.getGrade()) &&
item.getOtherName() != null &&
item.getOtherName().contains("累积热量") &&
item.getOrderNum() != null &&
item.getOrderNum() >= 1 && item.getOrderNum() <= 5)
.toList();
BigDecimal centrifugalHeatRecoverySum = centrifugalHeatRecovery.stream()
.map(CollectionParamsManageDataVO::getCurValue)
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 后处理以及MD热量回收(order_num=4,6)
List<CollectionParamsManageDataVO> postProcessingAndMdHeatRecovery = list.stream()
.filter(item -> "6".equals(item.getDeviceType()) &&
"47".equals(item.getParamType()) &&
Integer.valueOf(40).equals(item.getGrade()) &&
item.getOtherName() != null &&
item.getOtherName().contains("累积热量") &&
item.getOrderNum() != null &&
item.getOrderNum() >= 4 && item.getOrderNum() <= 6)
.toList();
BigDecimal postProcessingAndMdHeatRecoverySum = postProcessingAndMdHeatRecovery.stream()
.map(CollectionParamsManageDataVO::getCurValue)
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 水源热泵热量(order_num=7)
List<CollectionParamsManageDataVO> waterSourceHeatPump = list.stream()
.filter(item -> "6".equals(item.getDeviceType()) &&
"47".equals(item.getParamType()) &&
Integer.valueOf(40).equals(item.getGrade()) &&
item.getOtherName() != null &&
item.getOtherName().contains("累积热量") &&
item.getOrderNum() != null &&
item.getOrderNum() == 7)
.toList();
BigDecimal waterSourceHeatPumpSum = waterSourceHeatPump.stream()
.map(CollectionParamsManageDataVO::getCurValue)
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 热利用率
BigDecimal heatUtilization = BigDecimal.ZERO;
if (totalHeatRecoverySum.compareTo(BigDecimal.ZERO) > 0) {
heatUtilization = productionHeatSum.multiply(new BigDecimal("100"))
.divide(totalHeatRecoverySum, 2, BigDecimal.ROUND_HALF_UP);
}
// result.put("productionHeatSum", productionHeatSum);
// result.put("dissipationHeatSum", dissipationHeatSum);
// 热回收总量
result.put("totalHeatRecoverySum", totalHeatRecoverySum);
// 离心机热量回收
result.put("centrifugalHeatRecoverySum", centrifugalHeatRecoverySum);
// 后处理以及MD热量回收
result.put("postProcessingAndMdHeatRecoverySum", postProcessingAndMdHeatRecoverySum);
// 水源热泵热量
result.put("waterSourceHeatPumpSum", waterSourceHeatPumpSum);
// 热利用率
result.put("heatUtilization", heatUtilization);
return result;
}
@Override
public List<?> selectHeatPumpOnlineByParams(String systemType, String type) {
if (StringUtils.isEmpty(systemType)) {
@ -558,6 +697,7 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
}
return deviceMonitorVO;
})
.sorted(Comparator.comparingInt(DeviceMonitorVO::getOrderNum))
.filter(vo -> vo.getDeviceType() != null)
.collect(Collectors.groupingBy(DeviceMonitorVO::getDeviceType));

18
mh-system/src/main/java/com/mh/system/service/energy/IHeatQueryAnalyzeService.java

@ -0,0 +1,18 @@
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;
/**
* @author LJF
* @version 1.0
* @project EEMCS
* @description 系统热量查询分析
* @date 2026-01-29 09:21:37
*/
public interface IHeatQueryAnalyzeService {
AjaxResult sysAnalyze(EnergyQueryVO vo);
}

8
mh-system/src/main/java/com/mh/system/service/energy/impl/EnergyQueryServiceImpl.java

@ -9,6 +9,7 @@ import com.mh.common.utils.StringUtils;
import com.mh.system.mapper.device.CollectionParamsManageMapper;
import com.mh.system.mapper.energy.*;
import com.mh.system.service.energy.IEnergyQueryService;
import com.mh.system.service.energy.IHeatQueryAnalyzeService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
@ -70,6 +71,9 @@ public class EnergyQueryServiceImpl implements IEnergyQueryService {
@Resource
AnalysisMapper analysisMapper;
@Resource
private IHeatQueryAnalyzeService heatQueryAnalyzeService;
@Override
public void calcAnalysisData(String lastHourTime) {
try {
@ -178,6 +182,10 @@ public class EnergyQueryServiceImpl implements IEnergyQueryService {
@Override
public AjaxResult sysQuery(EnergyQueryVO vo) {
DateUtils.sysEnergyDateChange(vo);
// 判断是什么系统 vo.getSystemType() == 7 热回收系统
if (vo.getSystemType().equals("7")) {
return heatQueryAnalyzeService.sysAnalyze(vo);
}
// 获取参数
AtomicReference<String> lastTableName = new AtomicReference<>("data_" + vo.getTimeType());
AtomicReference<String> curTableName = new AtomicReference<>("data_" + vo.getTimeType());

200
mh-system/src/main/java/com/mh/system/service/energy/impl/HeatQueryAnalyzeImpl.java

@ -0,0 +1,200 @@
package com.mh.system.service.energy.impl;
import com.mh.common.core.domain.AjaxResult;
import com.mh.common.core.domain.entity.ConsumptionAnalyze;
import com.mh.common.core.domain.entity.CpmSpaceRelation;
import com.mh.common.core.domain.vo.EnergyQueryVO;
import com.mh.common.utils.DateUtils;
import com.mh.system.mapper.energy.HeatEnergyQueryMapper;
import com.mh.system.mapper.space.CpmSpaceRelationMapper;
import com.mh.system.service.energy.IHeatQueryAnalyzeService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
/**
* @author LJF
* @version 1.0
* @project EEMCS
* @description 系统热量查询分析
* @date 2026-01-29 09:22:15
*/
@Slf4j
@Service
public class HeatQueryAnalyzeImpl implements IHeatQueryAnalyzeService {
@Resource
private HeatEnergyQueryMapper energyERSQueryMapper;
@Resource
private CpmSpaceRelationMapper cpmSpaceRelationMapper;
@Override
public AjaxResult sysAnalyze(EnergyQueryVO vo) {
// 获取参数
AtomicReference<String> lastTableName = new AtomicReference<>("data_" + vo.getTimeType());
AtomicReference<String> curTableName = new AtomicReference<>("data_" + vo.getTimeType());
String timeType = vo.getTimeType();
// 根据houseId获取参数类型id值
// 固定houseId:总热量回收:4be8a8d42a8bd0cbe824c8ad06780e20,散热总热量:15238cf860e41559fd63ad6c6c32b798
List<CpmSpaceRelation> totalHeat = cpmSpaceRelationMapper.selectListByHouseId("4be8a8d42a8bd0cbe824c8ad06780e20");
if (totalHeat.isEmpty()) {
return AjaxResult.error("未查到设备信息");
}
// 散热总热量
List<CpmSpaceRelation> dissHeat = cpmSpaceRelationMapper.selectListByHouseId("15238cf860e41559fd63ad6c6c32b798");
if (dissHeat.isEmpty()) {
return AjaxResult.error("未查到设备信息");
}
List<ConsumptionAnalyze> totalDatas = null;
List<ConsumptionAnalyze> dissDatas = null;
// 表格数据
if ("month".equalsIgnoreCase(timeType) || "year".equalsIgnoreCase(timeType)) {
// 单表
totalDatas = energyERSQueryMapper.queryOneTable(vo.getStartTime(),
vo.getEndTime(),
lastTableName.get(),
curTableName.get(),
DateUtils.getTimeLen(vo.getTimeType()),
null,
vo.getSystemType(),
totalHeat);
dissDatas = energyERSQueryMapper.queryOneTable(vo.getStartTime(),
vo.getEndTime(),
lastTableName.get(),
curTableName.get(),
DateUtils.getTimeLen(vo.getTimeType()),
null,
vo.getSystemType(),
dissHeat);
} else {
lastTableName.set(lastTableName + vo.getStartTime().substring(0, 4));
curTableName.set(curTableName + vo.getEndTime().substring(0, 4));
if (lastTableName.get().equalsIgnoreCase(curTableName.get())) {
// 单表
totalDatas = energyERSQueryMapper.queryOneTable(vo.getStartTime(),
vo.getEndTime(),
lastTableName.get(),
curTableName.get(),
DateUtils.getTimeLen(vo.getTimeType()),
null,
vo.getSystemType(),
totalHeat);
dissDatas = energyERSQueryMapper.queryOneTable(vo.getStartTime(),
vo.getEndTime(),
lastTableName.get(),
curTableName.get(),
DateUtils.getTimeLen(vo.getTimeType()),
null,
vo.getSystemType(),
dissHeat);
} else {
// 多表
totalDatas = energyERSQueryMapper.queryManyTable(vo.getStartTime(),
vo.getEndTime(),
lastTableName.get(),
curTableName.get(),
DateUtils.getTimeLen(vo.getTimeType()),
null,
vo.getSystemType(),
totalHeat);
dissDatas = energyERSQueryMapper.queryManyTable(vo.getStartTime(),
vo.getEndTime(),
lastTableName.get(),
curTableName.get(),
DateUtils.getTimeLen(vo.getTimeType()),
null,
vo.getSystemType(),
dissHeat);
}
}
if (null == totalDatas || totalDatas.isEmpty()) {
return AjaxResult.success();
}
// 处理数据,totalDatas:总热量回收,匹配meter,dissDatas:散热总热量,匹配cold
String[] copArr = new String[totalDatas.size()];
String[] timeStrArr = totalDatas.stream()
.map(ConsumptionAnalyze::getTimeStr)
.toArray(String[]::new);
String[] meterArr = totalDatas.stream()
.map(ConsumptionAnalyze::getCurValue)
.toArray(String[]::new);
String[] coldArr = getArr(dissDatas, timeStrArr);
// 计算COP=总热量回收-散热总热量/总热量回收
for (int i = 0; i < totalDatas.size(); i++) {
try {
double cold = Math.round(Double.parseDouble(coldArr[i]) * 100) / 100.0;
double meter = Math.round(Double.parseDouble(meterArr[i]) * 100) / 100.0;
double cop = Math.round((meter == 0 ? 0.00 : (meter - cold) / meter) * 100);
copArr[i] = String.valueOf(cop);
} catch (NumberFormatException e) {
log.error("处理累计能耗异常==>", e);
throw new RuntimeException(e);
}
}
// 表格数据
Map<String, Object> map = new HashMap<>();
int pageNum = vo.getPageNum();
int pageSize = vo.getPageSize();
if (pageNum == 0) {
map.put("coldArr", coldArr);
map.put("meterArr", meterArr);
map.put("copArr", copArr);
map.put("timeStrArr", timeStrArr);
} else {
int startIndex = (pageNum - 1) * pageSize;
int endIndex = Math.min(pageNum * pageSize, coldArr.length);
if (startIndex > endIndex) {
return AjaxResult.success();
}
map.put("coldArr", Arrays.copyOfRange(coldArr, startIndex, endIndex));
map.put("meterArr", Arrays.copyOfRange(meterArr, startIndex, endIndex));
map.put("copArr", Arrays.copyOfRange(copArr, startIndex, endIndex));
map.put("timeStrArr", Arrays.copyOfRange(timeStrArr, startIndex, endIndex));
}
// 添加总条数
map.put("total",timeStrArr.length);
// 组装赋值
List<Map<String, Object>> listData = new ArrayList<>();
Map<String, Object> cold = new HashMap<>();
cold.put("cold", map.get("coldArr"));
listData.add(cold);
Map<String, Object> meter = new HashMap<>();
meter.put("meter", map.get("meterArr"));
listData.add(meter);
Map<String, Object> cop = new HashMap<>();
cop.put("cop", map.get("copArr"));
listData.add(cop);
String[] titleArr = new String[]{"cold", "meter", "cop"};
Map<String, Object> titles = new HashMap<>();
titles.put("titleArr", titleArr);
listData.add(titles);
Map<String, Object> timeStr = new HashMap<>();
timeStr.put("timeStrArr", map.get("timeStrArr"));
listData.add(timeStr);
return AjaxResult.success(listData);
}
private static String[] getArr(List<ConsumptionAnalyze> copLineData, String[] lineTimeStrArr) {
String[] lineCopArr = new String[lineTimeStrArr.length];
for (int i = 0; i < lineTimeStrArr.length; i++) {
int j = i;
Optional<ConsumptionAnalyze> first = copLineData.stream().filter(s -> lineTimeStrArr[j].equalsIgnoreCase(s.getTimeStr())).findFirst();
if (first.isPresent()) {
lineCopArr[i] = first.get().getCurValue();
} else {
lineCopArr[i] = "0.00";
}
}
return lineCopArr;
}
}

2
mh-system/src/main/java/com/mh/system/service/overview/IProOverviewService.java

@ -20,4 +20,6 @@ public interface IProOverviewService {
List<OverviewEnergyDTO> energyAnalysis();
List<DeviceMonitorDTO> mainParams();
List<?> ersDatas(String systemType);
}

382
mh-system/src/main/java/com/mh/system/service/overview/impl/ProOverviewServiceImpl.java

@ -8,17 +8,21 @@ import com.mh.common.core.domain.dto.OverviewEnergyDTO;
import com.mh.common.core.domain.dto.ProProfileDTO;
import com.mh.common.core.domain.entity.CollectionParamsManage;
import com.mh.common.core.domain.entity.SysDictData;
import com.mh.common.core.domain.vo.CollectionParamsManageDataVO;
import com.mh.common.core.redis.RedisCache;
import com.mh.common.utils.DateUtils;
import com.mh.system.mapper.SysDictDataMapper;
import com.mh.system.mapper.device.CollectionParamsManageMapper;
import com.mh.system.mapper.energy.OverviewMapper;
import com.mh.system.service.overview.IProOverviewService;
import lombok.Getter;
import lombok.Setter;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.concurrent.CompletableFuture;
@ -50,6 +54,384 @@ public class ProOverviewServiceImpl implements IProOverviewService {
this.overviewMapper = overviewMapper;
}
// @Override
// public List<?> ersDatas(String systemType) {
// // 从collection_params_manage、device_ledger中查询数据,获取device_ledger.device_name,order_num,system_type,device_type
// // collection_params_manage的other_name,param_type,cur_value,cur_time,grade
// List<Map<String, Object>> list = collectionParamsManageMapper.selectErsDatas(systemType);
// if (list.isEmpty()) {
// return List.of();
// }
// // list里面的map再增加一个status,status=0正常,status=1异常
// // 开始组装数据
// // 出水温度:
// // 离心机高温出水温度(device_type=6,order_num=1,param_type=12,other_name like '%出水温度%')的cur_value值,如果cur_time不是当天,status标识异常,
// // 中温换热出水温度(device_type=6,order_num=2,param_type=12,other_name like '%出水温度%')的cur_value值,如果cur_time不是当天,status标识异常,
// // 低温1换热出水温度(device_type=6,order_num=3,param_type=12,other_name like '%出水温度%')的cur_value值,如果cur_time不是当天,status标识异常,
// // 低温2换热出水温度(device_type=6,order_num=4,param_type=12,other_name like '%出水温度%')的cur_value值,如果cur_time不是当天,status标识异常,
// // 热量数据:
// // 生产累积热量(device_type=6,order_num=1,2,3,4,param_type=47,grade=40,other_name like '%累积热量%')的cur_value合值,
// // 散热累积热量(device_type=6,order_num=5,6,param_type=47,grade=40,other_name like '%累积热量%')的cur_value合值,
// // 总热量回收(device_type=6,order_num=1,2,3,4,5,6,param_type=47,grade=40,other_name like '%累积热量%')的cur_value合值,
// // 热利用率(生产累积热量*100/总热量回收)
// // 系统数据:
// // 离心机入口温度(device_type=14,order_num=4,param_type=31)的cur_value值,如果cur_time不是当天,status标识异常,
// // 离心机出水温度(device_type=6,order_num=1,param_type=12,other_name like '%出水温度%')的cur_value值,如果cur_time不是当天,status标识异常,
// // 保障进水温度(device_type=14,order_num=3,param_type=31)的cur_value值,如果cur_time不是当天,status标识异常,
// // 阀门开度:
// // 二通阀阀门开度(device_type=26,order_num=1,param_type=4)的cur_value值,如果cur_time不是当天,status标识异常,
// // 三通阀阀门开度(device_type=27,order_num=1,param_type=4)的cur_value值,如果cur_time不是当天,status标识异常,
// // 热回收数据:
// // 瞬时热量(device_type=6,order_num=1,2,3,4,5,6,param_type=47,grade=140,other_name like '%瞬时热量%')的cur_value合值,,
// // 日累积热量,先默认0,
// // 累积热量(device_type=6,order_num=1,2,3,4,5,6,param_type=47,grade=40,other_name like '%累积热量%')的cur_value合值,
// // 应用侧数据:
// // 瞬时热量(device_type=6,order_num=1,2,3,4,param_type=47,grade=140,other_name like '%瞬时热量%')的cur_value合值,
// // 日累计热量,先默认0,
// // 累积热量(device_type=6,order_num=1,2,3,4,param_type=47,grade=40,other_name like '%累积热量%')的cur_value合值,
// return null;
// }
@Override
public List<?> ersDatas(String systemType) {
// 从collection_params_manage、device_ledger中查询数据,获取device_ledger.device_name,order_num,system_type,device_type
// collection_params_manage的other_name,param_type,cur_value,cur_time,grade
List<Map<String, Object>> list = collectionParamsManageMapper.selectErsDatas(systemType);
if (list.isEmpty()) {
return List.of();
}
// 为每个map添加status字段,初始为0(正常)
list.forEach(map -> {
Date curTime = (Date) map.get("cur_time");
// 判断cur_time是否为今天
boolean isToday = DateUtils.isToday(curTime);
map.put("status", isToday ? 0 : 1); // 0正常,1异常
});
// 将数据转换为CollectionParamsManage对象列表,便于处理
List<CollectionParamsManageDataVO> convertedList = convertToCollectionParamsManageDataVO(list);
// 组装出水温度数据
List<Map<String, Object>> outWaterTempData = getOutWaterTemperatureData(convertedList);
// 组装热量数据
Map<String, Object> heatData = getHeatData(convertedList);
// 组装系统数据
List<Map<String, Object>> systemData = getSystemData(convertedList);
// 组装阀门开度数据
List<Map<String, Object>> valveData = getValveData(convertedList);
// 组装热回收数据
Map<String, Object> heatRecoveryData = getHeatRecoveryData(convertedList);
// 组装应用侧数据
Map<String, Object> applicationData = getApplicationData(convertedList);
// 构建最终返回结果
Map<String, Object> result = new HashMap<>();
result.put("outWaterTemperature", outWaterTempData);
result.put("heatData", heatData);
result.put("systemData", systemData);
result.put("valveData", valveData);
result.put("heatRecoveryData", heatRecoveryData);
result.put("applicationData", applicationData);
return List.of(result);
}
private List<CollectionParamsManageDataVO> convertToCollectionParamsManageDataVO(List<Map<String, Object>> list) {
return list.stream()
.map(CollectionParamsManageDataVO::new)
.collect(Collectors.toList());
}
/**
* 获取出水温度数据
*/
private List<Map<String, Object>> getOutWaterTemperatureData(List<CollectionParamsManageDataVO> list) {
return list.stream()
.filter(item -> "6".equals(item.getDeviceType()) &&
"12".equals(item.getParamType()) &&
item.getOtherName() != null &&
item.getOtherName().contains("出水温度"))
.filter(item -> item.getOrderNum() != null && item.getOrderNum() <= 4) // 离心机高温出水温度(order_num=1), 中温换热出水温度(order_num=2), 低温1换热出水温度(order_num=3), 低温2换热出水温度(order_num=4)
.map(item -> {
Map<String, Object> result = new HashMap<>();
result.put("deviceName", item.getDeviceName());
result.put("orderNum", item.getOrderNum());
result.put("paramType", item.getParamType());
result.put("otherName", item.getOtherName());
result.put("curValue", item.getCurValue());
result.put("curTime", item.getCurTime());
result.put("status", item.getStatus());
// 根据order_num确定设备类型名称
String deviceTypeName = switch (item.getOrderNum()) {
case 1 -> "离心机高温出水温度";
case 2 -> "中温换热出水温度";
case 3 -> "低温1换热出水温度";
case 4 -> "低温2换热出水温度";
default -> "出水温度";
};
result.put("deviceTypeName", deviceTypeName);
return result;
})
.collect(Collectors.toList());
}
/**
* 获取热量数据
*/
private Map<String, Object> getHeatData(List<CollectionParamsManageDataVO> list) {
Map<String, Object> result = new HashMap<>();
// 生产累积热量 (order_num=1,2,3,4)
List<CollectionParamsManageDataVO> productionHeat = list.stream()
.filter(item -> "6".equals(item.getDeviceType()) &&
"47".equals(item.getParamType()) &&
Integer.valueOf(40).equals(item.getGrade()) &&
item.getOtherName() != null &&
item.getOtherName().contains("累积热量") &&
item.getOrderNum() != null &&
item.getOrderNum() >= 1 && item.getOrderNum() <= 4)
.collect(Collectors.toList());
BigDecimal productionHeatSum = productionHeat.stream()
.map(CollectionParamsManageDataVO::getCurValue)
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 散热累积热量 (order_num=5,6)
List<CollectionParamsManageDataVO> dissipationHeat = list.stream()
.filter(item -> "6".equals(item.getDeviceType()) &&
"47".equals(item.getParamType()) &&
Integer.valueOf(40).equals(item.getGrade()) &&
item.getOtherName() != null &&
item.getOtherName().contains("累积热量") &&
item.getOrderNum() != null &&
(item.getOrderNum() == 5 || item.getOrderNum() == 6))
.collect(Collectors.toList());
BigDecimal dissipationHeatSum = dissipationHeat.stream()
.map(CollectionParamsManageDataVO::getCurValue)
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 总热量回收 (order_num=1,2,3,4,5,6)
List<CollectionParamsManageDataVO> totalHeatRecovery = list.stream()
.filter(item -> "6".equals(item.getDeviceType()) &&
"47".equals(item.getParamType()) &&
Integer.valueOf(40).equals(item.getGrade()) &&
item.getOtherName() != null &&
item.getOtherName().contains("累积热量") &&
item.getOrderNum() != null &&
item.getOrderNum() >= 1 && item.getOrderNum() <= 6)
.collect(Collectors.toList());
BigDecimal totalHeatRecoverySum = totalHeatRecovery.stream()
.map(CollectionParamsManageDataVO::getCurValue)
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 热利用率
BigDecimal heatUtilization = BigDecimal.ZERO;
if (totalHeatRecoverySum.compareTo(BigDecimal.ZERO) > 0) {
heatUtilization = productionHeatSum.multiply(new BigDecimal("100"))
.divide(totalHeatRecoverySum, 2, BigDecimal.ROUND_HALF_UP);
}
result.put("productionHeatSum", productionHeatSum);
result.put("dissipationHeatSum", dissipationHeatSum);
result.put("totalHeatRecoverySum", totalHeatRecoverySum);
result.put("heatUtilization", heatUtilization);
// result.put("productionHeatDetails", productionHeat);
// result.put("dissipationHeatDetails", dissipationHeat);
// result.put("totalHeatRecoveryDetails", totalHeatRecovery);
return result;
}
/**
* 获取系统数据
*/
private List<Map<String, Object>> getSystemData(List<CollectionParamsManageDataVO> list) {
return list.stream()
.filter(item ->
// 离心机入口温度 (device_type=14, order_num=4, param_type=31)
("14".equals(item.getDeviceType()) &&
"31".equals(item.getParamType()) &&
Integer.valueOf(4).equals(item.getOrderNum())) ||
// 离心机出水温度 (device_type=6, order_num=1, param_type=12, other_name like '%出水温度%')
("6".equals(item.getDeviceType()) &&
"12".equals(item.getParamType()) &&
Integer.valueOf(1).equals(item.getOrderNum()) &&
item.getOtherName() != null &&
item.getOtherName().contains("出水温度")) ||
// 保障进水温度 (device_type=14, order_num=3, param_type=31)
("14".equals(item.getDeviceType()) &&
"31".equals(item.getParamType()) &&
Integer.valueOf(3).equals(item.getOrderNum())) ||
// 离心机进水压力 (device_type=13, order_num=4, param_type=13)
("13".equals(item.getDeviceType()) && "13".equals(item.getParamType()) && Integer.valueOf(4).equals(item.getOrderNum())) ||
// 离心机出水压力 (device_type=13, order_num=5, param_type=13)
("13".equals(item.getDeviceType()) && "13".equals(item.getParamType()) && Integer.valueOf(5).equals(item.getOrderNum()))
)
.map(item -> {
Map<String, Object> result = new HashMap<>();
result.put("deviceName", item.getDeviceName());
result.put("orderNum", item.getOrderNum());
result.put("paramType", item.getParamType());
result.put("otherName", item.getOtherName());
result.put("curValue", item.getCurValue());
result.put("curTime", item.getCurTime());
result.put("status", item.getStatus());
// 根据条件确定设备类型名称
String deviceTypeName = "";
if ("14".equals(item.getDeviceType()) && "31".equals(item.getParamType()) && Integer.valueOf(4).equals(item.getOrderNum())) {
deviceTypeName = "离心机入口温度";
} else if ("6".equals(item.getDeviceType()) && "12".equals(item.getParamType()) && Integer.valueOf(1).equals(item.getOrderNum())) {
deviceTypeName = "离心机出水温度";
} else if ("14".equals(item.getDeviceType()) && "31".equals(item.getParamType()) && Integer.valueOf(3).equals(item.getOrderNum())) {
deviceTypeName = "保障进水温度";
} else if ("13".equals(item.getDeviceType()) && "13".equals(item.getParamType()) && Integer.valueOf(4).equals(item.getOrderNum())) {
deviceTypeName = "离心机进水压力";
} else if ("13".equals(item.getDeviceType()) && "13".equals(item.getParamType()) && Integer.valueOf(5).equals(item.getOrderNum())) {
deviceTypeName = "离心机出水压力";
}
result.put("deviceTypeName", deviceTypeName);
return result;
})
.collect(Collectors.toList());
}
/**
* 获取阀门开度数据
*/
private List<Map<String, Object>> getValveData(List<CollectionParamsManageDataVO> list) {
return list.stream()
.filter(item ->
// 二通阀阀门开度 (device_type=26, order_num=1, param_type=4)
("26".equals(item.getDeviceType()) &&
"4".equals(item.getParamType()) &&
Integer.valueOf(1).equals(item.getOrderNum())) ||
// 三通阀阀门开度 (device_type=27, order_num=1, param_type=4)
("27".equals(item.getDeviceType()) &&
"4".equals(item.getParamType()) &&
Integer.valueOf(1).equals(item.getOrderNum()))
)
.map(item -> {
Map<String, Object> result = new HashMap<>();
result.put("deviceName", item.getDeviceName());
result.put("orderNum", item.getOrderNum());
result.put("paramType", item.getParamType());
result.put("otherName", item.getOtherName());
result.put("curValue", item.getCurValue());
result.put("curTime", item.getCurTime());
result.put("status", item.getStatus());
// 根据条件确定设备类型名称
String deviceTypeName = "26".equals(item.getDeviceType()) ? "二通阀阀门开度" : "三通阀阀门开度";
result.put("deviceTypeName", deviceTypeName);
return result;
})
.collect(Collectors.toList());
}
/**
* 获取热回收数据
*/
private Map<String, Object> getHeatRecoveryData(List<CollectionParamsManageDataVO> list) {
Map<String, Object> result = new HashMap<>();
// 瞬时热量 (device_type=6, order_num=1,2,3,4,5,6, param_type=47, grade=140, other_name like '%瞬时热量%')
List<CollectionParamsManageDataVO> instantaneousHeat = list.stream()
.filter(item -> "6".equals(item.getDeviceType()) &&
"47".equals(item.getParamType()) &&
Integer.valueOf(140).equals(item.getGrade()) &&
item.getOtherName() != null &&
item.getOtherName().contains("瞬时热量") &&
item.getOrderNum() != null &&
item.getOrderNum() >= 1 && item.getOrderNum() <= 6)
.collect(Collectors.toList());
BigDecimal instantaneousHeatSum = instantaneousHeat.stream()
.map(CollectionParamsManageDataVO::getCurValue)
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 累积热量 (device_type=6, order_num=1,2,3,4,5,6, param_type=47, grade=40, other_name like '%累积热量%')
List<CollectionParamsManageDataVO> accumulatedHeat = list.stream()
.filter(item -> "6".equals(item.getDeviceType()) &&
"47".equals(item.getParamType()) &&
Integer.valueOf(40).equals(item.getGrade()) &&
item.getOtherName() != null &&
item.getOtherName().contains("累积热量") &&
item.getOrderNum() != null &&
item.getOrderNum() >= 1 && item.getOrderNum() <= 6)
.collect(Collectors.toList());
BigDecimal accumulatedHeatSum = accumulatedHeat.stream()
.map(CollectionParamsManageDataVO::getCurValue)
.reduce(BigDecimal.ZERO, BigDecimal::add);
result.put("instantaneousHeatSum", instantaneousHeatSum);
result.put("accumulatedHeatSum", accumulatedHeatSum);
result.put("dailyAccumulatedHeat", BigDecimal.ZERO); // 日累积热量,先默认0
// result.put("instantaneousHeatDetails", instantaneousHeat);
// result.put("accumulatedHeatDetails", accumulatedHeat);
return result;
}
/**
* 获取应用侧数据
*/
private Map<String, Object> getApplicationData(List<CollectionParamsManageDataVO> list) {
Map<String, Object> result = new HashMap<>();
// 瞬时热量 (device_type=6, order_num=1,2,3,4, param_type=47, grade=140, other_name like '%瞬时热量%')
List<CollectionParamsManageDataVO> instantaneousHeat = list.stream()
.filter(item -> "6".equals(item.getDeviceType()) &&
"47".equals(item.getParamType()) &&
Integer.valueOf(140).equals(item.getGrade()) &&
item.getOtherName() != null &&
item.getOtherName().contains("瞬时热量") &&
item.getOrderNum() != null &&
item.getOrderNum() >= 1 && item.getOrderNum() <= 4)
.collect(Collectors.toList());
BigDecimal instantaneousHeatSum = instantaneousHeat.stream()
.map(CollectionParamsManageDataVO::getCurValue)
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 累积热量 (device_type=6, order_num=1,2,3,4, param_type=47, grade=40, other_name like '%累积热量%')
List<CollectionParamsManageDataVO> accumulatedHeat = list.stream()
.filter(item -> "6".equals(item.getDeviceType()) &&
"47".equals(item.getParamType()) &&
Integer.valueOf(40).equals(item.getGrade()) &&
item.getOtherName() != null &&
item.getOtherName().contains("累积热量") &&
item.getOrderNum() != null &&
item.getOrderNum() >= 1 && item.getOrderNum() <= 4)
.collect(Collectors.toList());
BigDecimal accumulatedHeatSum = accumulatedHeat.stream()
.map(CollectionParamsManageDataVO::getCurValue)
.reduce(BigDecimal.ZERO, BigDecimal::add);
result.put("instantaneousHeatSum", instantaneousHeatSum);
result.put("accumulatedHeatSum", accumulatedHeatSum);
result.put("dailyAccumulatedHeat", BigDecimal.ZERO); // 日累计热量,先默认0
// result.put("instantaneousHeatDetails", instantaneousHeat);
// result.put("accumulatedHeatDetails", accumulatedHeat);
return result;
}
@Override
public List<DeviceMonitorDTO> mainParams() {
// 查询系统类型数据

Loading…
Cancel
Save