From 0288f2cffb53ca232c732616081421ab25a6d926 Mon Sep 17 00:00:00 2001 From: 25604 Date: Fri, 30 Jan 2026 18:18:14 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E8=AE=BE=E5=A4=87=E9=87=87=E9=9B=86?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E7=AE=A1=E7=90=86=EF=BC=9B=202=E3=80=81?= =?UTF-8?q?=E7=83=AD=E5=9B=9E=E6=94=B6=E9=A6=96=E9=A1=B5=E3=80=81=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E7=83=AD=E9=87=8F=E6=9F=A5=E8=AF=A2=E3=80=81=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E7=BB=84=E7=83=AD=E9=87=8F=E6=9F=A5=E8=AF=A2=E3=80=81?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E7=83=AD=E9=87=8F=E6=9F=A5=E8=AF=A2=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../comprehensive/ProOverviewController.java | 14 + .../energy/SysEnergyQueryController.java | 44 +- .../monitor/ERSMonitorController.java | 45 ++ .../vo/CollectionParamsManageDataVO.java | 51 +++ .../java/com/mh/common/utils/DateUtils.java | 11 + .../device/CollectionParamsManageMapper.java | 19 +- .../mapper/energy/HeatEnergyQueryMapper.java | 222 ++++++++++ .../ICollectionParamsManageService.java | 2 + .../CollectionParamsManageServiceImpl.java | 140 +++++++ .../energy/IHeatQueryAnalyzeService.java | 18 + .../energy/impl/EnergyQueryServiceImpl.java | 8 + .../energy/impl/HeatQueryAnalyzeImpl.java | 200 +++++++++ .../service/overview/IProOverviewService.java | 2 + .../overview/impl/ProOverviewServiceImpl.java | 386 +++++++++++++++++- 14 files changed, 1146 insertions(+), 16 deletions(-) create mode 100644 mh-admin/src/main/java/com/mh/web/controller/monitor/ERSMonitorController.java create mode 100644 mh-common/src/main/java/com/mh/common/core/domain/vo/CollectionParamsManageDataVO.java create mode 100644 mh-system/src/main/java/com/mh/system/mapper/energy/HeatEnergyQueryMapper.java create mode 100644 mh-system/src/main/java/com/mh/system/service/energy/IHeatQueryAnalyzeService.java create mode 100644 mh-system/src/main/java/com/mh/system/service/energy/impl/HeatQueryAnalyzeImpl.java diff --git a/mh-admin/src/main/java/com/mh/web/controller/comprehensive/ProOverviewController.java b/mh-admin/src/main/java/com/mh/web/controller/comprehensive/ProOverviewController.java index 0eae057..a7956aa 100644 --- a/mh-admin/src/main/java/com/mh/web/controller/comprehensive/ProOverviewController.java +++ b/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)); + } } diff --git a/mh-admin/src/main/java/com/mh/web/controller/energy/SysEnergyQueryController.java b/mh-admin/src/main/java/com/mh/web/controller/energy/SysEnergyQueryController.java index ad317c4..4135f86 100644 --- a/mh-admin/src/main/java/com/mh/web/controller/energy/SysEnergyQueryController.java +++ b/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> dataList = (List>) energyQueryService.sysQuery(vo).get("data"); if (dataList != null) { @@ -71,18 +74,33 @@ public class SysEnergyQueryController { for (Map map : dataList) { if (map.containsKey("titleArr")) { titleArr = Arrays.asList((String[]) map.get("titleArr")); - List head0 = ListUtils.newArrayList(); - head0.add("日期"); - List head1 = ListUtils.newArrayList(); - head1.add("制冷量"); - List head2 = ListUtils.newArrayList(); - head2.add("耗电量"); - List head3= ListUtils.newArrayList(); - head3.add("COP"); - head.add(head0); - head.add(head1); - head.add(head2); - head.add(head3); + if (vo.getSystemType().equalsIgnoreCase("7")) { + List head0 = ListUtils.newArrayList(); + head0.add("日期"); + List head1 = ListUtils.newArrayList(); + head1.add("散热量"); + List head2 = ListUtils.newArrayList(); + head2.add("总热量回收"); + List head3 = ListUtils.newArrayList(); + head3.add("热利用率"); + head.add(head0); + head.add(head1); + head.add(head2); + head.add(head3); + } else { + List head0 = ListUtils.newArrayList(); + head0.add("日期"); + List head1 = ListUtils.newArrayList(); + head1.add("制冷量"); + List head2 = ListUtils.newArrayList(); + head2.add("耗电量"); + List head3 = ListUtils.newArrayList(); + head3.add("COP"); + head.add(head0); + head.add(head1); + 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); diff --git a/mh-admin/src/main/java/com/mh/web/controller/monitor/ERSMonitorController.java b/mh-admin/src/main/java/com/mh/web/controller/monitor/ERSMonitorController.java new file mode 100644 index 0000000..9f0bb44 --- /dev/null +++ b/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 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); + } + +} diff --git a/mh-common/src/main/java/com/mh/common/core/domain/vo/CollectionParamsManageDataVO.java b/mh-common/src/main/java/com/mh/common/core/domain/vo/CollectionParamsManageDataVO.java new file mode 100644 index 0000000..b4b4373 --- /dev/null +++ b/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 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"); + } + +} diff --git a/mh-common/src/main/java/com/mh/common/utils/DateUtils.java b/mh-common/src/main/java/com/mh/common/utils/DateUtils.java index f2593dc..516faa2 100644 --- a/mh-common/src/main/java/com/mh/common/utils/DateUtils.java +++ b/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); } 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 63d5446..7c97abc 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 @@ -201,7 +201,7 @@ public interface CollectionParamsManageMapper extends BaseMapper 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> selectErsDatas(@Param("systemType") String systemType); + } diff --git a/mh-system/src/main/java/com/mh/system/mapper/energy/HeatEnergyQueryMapper.java b/mh-system/src/main/java/com/mh/system/mapper/energy/HeatEnergyQueryMapper.java new file mode 100644 index 0000000..8cae04b --- /dev/null +++ b/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("") + List 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 totalHeat); + + /** + * 单表查询操作 + * @param startTime 开始时间 + * @param endTime 结束时间 + * @param lastTableName 上一个表名 + * @param curTableName 当前表名 + * @return + */ + @Select("") + List 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 list); + +} diff --git a/mh-system/src/main/java/com/mh/system/service/device/ICollectionParamsManageService.java b/mh-system/src/main/java/com/mh/system/service/device/ICollectionParamsManageService.java index e197566..f2dadcf 100644 --- a/mh-system/src/main/java/com/mh/system/service/device/ICollectionParamsManageService.java +++ b/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); } diff --git a/mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java b/mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java index 006cede..8bf5b2d 100644 --- a/mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java +++ b/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> 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 convertedList = list.stream() + .map(CollectionParamsManageDataVO::new) + .collect(Collectors.toList()); + // 组装热量数据 + Map heatData = getHeatData(convertedList); + return List.of(heatData); + } + + /** + * 获取热量数据 + */ + private Map getHeatData(List list) { + Map result = new HashMap<>(); + + // 生产累积热量 (order_num=1,2,3,4) + List 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 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 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 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 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 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)); diff --git a/mh-system/src/main/java/com/mh/system/service/energy/IHeatQueryAnalyzeService.java b/mh-system/src/main/java/com/mh/system/service/energy/IHeatQueryAnalyzeService.java new file mode 100644 index 0000000..ab0d687 --- /dev/null +++ b/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); + +} diff --git a/mh-system/src/main/java/com/mh/system/service/energy/impl/EnergyQueryServiceImpl.java b/mh-system/src/main/java/com/mh/system/service/energy/impl/EnergyQueryServiceImpl.java index 2c65014..f17752e 100644 --- a/mh-system/src/main/java/com/mh/system/service/energy/impl/EnergyQueryServiceImpl.java +++ b/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 lastTableName = new AtomicReference<>("data_" + vo.getTimeType()); AtomicReference curTableName = new AtomicReference<>("data_" + vo.getTimeType()); diff --git a/mh-system/src/main/java/com/mh/system/service/energy/impl/HeatQueryAnalyzeImpl.java b/mh-system/src/main/java/com/mh/system/service/energy/impl/HeatQueryAnalyzeImpl.java new file mode 100644 index 0000000..50925db --- /dev/null +++ b/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 lastTableName = new AtomicReference<>("data_" + vo.getTimeType()); + AtomicReference curTableName = new AtomicReference<>("data_" + vo.getTimeType()); + String timeType = vo.getTimeType(); + // 根据houseId获取参数类型id值 + // 固定houseId:总热量回收:4be8a8d42a8bd0cbe824c8ad06780e20,散热总热量:15238cf860e41559fd63ad6c6c32b798 + List totalHeat = cpmSpaceRelationMapper.selectListByHouseId("4be8a8d42a8bd0cbe824c8ad06780e20"); + if (totalHeat.isEmpty()) { + return AjaxResult.error("未查到设备信息"); + } + // 散热总热量 + List dissHeat = cpmSpaceRelationMapper.selectListByHouseId("15238cf860e41559fd63ad6c6c32b798"); + if (dissHeat.isEmpty()) { + return AjaxResult.error("未查到设备信息"); + } + + List totalDatas = null; + + List 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 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> listData = new ArrayList<>(); + Map cold = new HashMap<>(); + cold.put("cold", map.get("coldArr")); + listData.add(cold); + Map meter = new HashMap<>(); + meter.put("meter", map.get("meterArr")); + listData.add(meter); + Map cop = new HashMap<>(); + cop.put("cop", map.get("copArr")); + listData.add(cop); + String[] titleArr = new String[]{"cold", "meter", "cop"}; + Map titles = new HashMap<>(); + titles.put("titleArr", titleArr); + listData.add(titles); + Map timeStr = new HashMap<>(); + timeStr.put("timeStrArr", map.get("timeStrArr")); + listData.add(timeStr); + return AjaxResult.success(listData); + } + + private static String[] getArr(List copLineData, String[] lineTimeStrArr) { + String[] lineCopArr = new String[lineTimeStrArr.length]; + for (int i = 0; i < lineTimeStrArr.length; i++) { + int j = i; + Optional 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; + } + +} diff --git a/mh-system/src/main/java/com/mh/system/service/overview/IProOverviewService.java b/mh-system/src/main/java/com/mh/system/service/overview/IProOverviewService.java index 8f2a461..258b6c2 100644 --- a/mh-system/src/main/java/com/mh/system/service/overview/IProOverviewService.java +++ b/mh-system/src/main/java/com/mh/system/service/overview/IProOverviewService.java @@ -20,4 +20,6 @@ public interface IProOverviewService { List energyAnalysis(); List mainParams(); + + List ersDatas(String systemType); } diff --git a/mh-system/src/main/java/com/mh/system/service/overview/impl/ProOverviewServiceImpl.java b/mh-system/src/main/java/com/mh/system/service/overview/impl/ProOverviewServiceImpl.java index f9bd2b0..c50cb7b 100644 --- a/mh-system/src/main/java/com/mh/system/service/overview/impl/ProOverviewServiceImpl.java +++ b/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> 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> 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 convertedList = convertToCollectionParamsManageDataVO(list); + + // 组装出水温度数据 + List> outWaterTempData = getOutWaterTemperatureData(convertedList); + + // 组装热量数据 + Map heatData = getHeatData(convertedList); + + // 组装系统数据 + List> systemData = getSystemData(convertedList); + + // 组装阀门开度数据 + List> valveData = getValveData(convertedList); + + // 组装热回收数据 + Map heatRecoveryData = getHeatRecoveryData(convertedList); + + // 组装应用侧数据 + Map applicationData = getApplicationData(convertedList); + + // 构建最终返回结果 + Map 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 convertToCollectionParamsManageDataVO(List> list) { + return list.stream() + .map(CollectionParamsManageDataVO::new) + .collect(Collectors.toList()); + } + + /** + * 获取出水温度数据 + */ + private List> getOutWaterTemperatureData(List 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 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 getHeatData(List list) { + Map result = new HashMap<>(); + + // 生产累积热量 (order_num=1,2,3,4) + List 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 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 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> getSystemData(List 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 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> getValveData(List 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 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 getHeatRecoveryData(List list) { + Map result = new HashMap<>(); + + // 瞬时热量 (device_type=6, order_num=1,2,3,4,5,6, param_type=47, grade=140, other_name like '%瞬时热量%') + List 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 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 getApplicationData(List list) { + Map result = new HashMap<>(); + + // 瞬时热量 (device_type=6, order_num=1,2,3,4, param_type=47, grade=140, other_name like '%瞬时热量%') + List 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 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 mainParams() { // 查询系统类型数据 @@ -396,7 +778,7 @@ public class ProOverviewServiceImpl implements IProOverviewService { public List getProProfile() { // 增加缓存处理 if (redisCache.hasKey(CacheConstants.PRO_PROFILE)) { - List resultList = redisCache.getCacheList(CacheConstants.PRO_PROFILE, ProProfileDTO.class); + List resultList = redisCache.getCacheList(CacheConstants.PRO_PROFILE, ProProfileDTO.class); if (resultList != null && !resultList.isEmpty()) { return resultList; } @@ -510,7 +892,7 @@ public class ProOverviewServiceImpl implements IProOverviewService { private HashMap getTotalData(String paramType, - QueryWrapper queryWrapper, LocalDateTime startTime, LocalDateTime endTime) { + QueryWrapper queryWrapper, LocalDateTime startTime, LocalDateTime endTime) { List collectionParamsManages = collectionParamsManageMapper.selectList(queryWrapper); HashMap result = new HashMap<>(); // 遍历计算得出总用电量