From 498a8192c6d915ddfa21f5113bca41c39037ccf1 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 19 Mar 2025 17:52:33 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E9=A1=B9=E7=9B=AE=E6=80=BB=E8=A7=88?= =?UTF-8?q?=EF=BC=9A=E7=AE=80=E4=BB=8B=E6=8E=A5=E5=8F=A3=E3=80=81=E6=A6=82?= =?UTF-8?q?=E5=86=B5=E6=8E=A5=E5=8F=A3=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../comprehensive/ProOverviewController.java | 58 ++++++ .../core/domain/dto/OverviewEnergyDTO.java | 32 ++++ .../common/core/domain/dto/ProProfileDTO.java | 86 +++++++++ .../common/core/domain/entity/SysParams.java | 22 +++ .../system/mapper/energy/OverviewMapper.java | 62 +++++++ .../service/overview/IProOverviewService.java | 20 +++ .../overview/impl/ProOverviewServiceImpl.java | 166 ++++++++++++++++++ .../mapper/system/SysParamsMapper.xml | 5 +- 8 files changed, 450 insertions(+), 1 deletion(-) create mode 100644 mh-admin/src/main/java/com/mh/web/controller/comprehensive/ProOverviewController.java create mode 100644 mh-common/src/main/java/com/mh/common/core/domain/dto/OverviewEnergyDTO.java create mode 100644 mh-common/src/main/java/com/mh/common/core/domain/dto/ProProfileDTO.java create mode 100644 mh-system/src/main/java/com/mh/system/mapper/energy/OverviewMapper.java create mode 100644 mh-system/src/main/java/com/mh/system/service/overview/IProOverviewService.java create mode 100644 mh-system/src/main/java/com/mh/system/service/overview/impl/ProOverviewServiceImpl.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 new file mode 100644 index 0000000..b8b7d08 --- /dev/null +++ b/mh-admin/src/main/java/com/mh/web/controller/comprehensive/ProOverviewController.java @@ -0,0 +1,58 @@ +package com.mh.web.controller.comprehensive; + +import com.mh.common.core.controller.BaseController; +import com.mh.common.core.page.TableDataInfo; +import com.mh.system.service.ISysParamsService; +import com.mh.system.service.overview.IProOverviewService; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author LJF + * @version 1.0 + * @project EEMCS + * @description 项目总览 + * @date 2025-03-19 11:08:41 + */ +@RestController +@RequestMapping("/pro/overview") +public class ProOverviewController extends BaseController { + + private final ISysParamsService sysParamsService; + + private final IProOverviewService proOverviewService; + + public ProOverviewController(ISysParamsService sysParamsService, IProOverviewService proOverviewService) { + this.sysParamsService = sysParamsService; + this.proOverviewService = proOverviewService; + } + + /** + * 获取项目简介 + * @return + */ + @GetMapping("/introduction") + public TableDataInfo introduction() { + return getDataTable(sysParamsService.queryList()); + } + + /** + * 获取项目概况 + * @return + */ + @GetMapping("/profile") + public TableDataInfo profile() { + return getDataTable(proOverviewService.getProProfile()); + } + + /** + * 获取能耗分析:查询最近12个月的能耗数据 + * @return + */ + @GetMapping("energyAnalysis") + public TableDataInfo energyAnalysis() { + return getDataTable(proOverviewService.energyAnalysis()); + } + +} diff --git a/mh-common/src/main/java/com/mh/common/core/domain/dto/OverviewEnergyDTO.java b/mh-common/src/main/java/com/mh/common/core/domain/dto/OverviewEnergyDTO.java new file mode 100644 index 0000000..d696ec0 --- /dev/null +++ b/mh-common/src/main/java/com/mh/common/core/domain/dto/OverviewEnergyDTO.java @@ -0,0 +1,32 @@ +package com.mh.common.core.domain.dto; + +import lombok.Getter; +import lombok.Setter; +import org.apache.commons.lang3.builder.ToStringBuilder; + +/** + * @author LJF + * @version 1.0 + * @project EEMCS + * @description 项目总览能耗分析 + * @date 2025-03-19 17:43:24 + */ +@Setter +@Getter +public class OverviewEnergyDTO { + + private String name; + + private String[] data; + + private String[] timeStr; + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("name", name) + .append("data", data) + .append("timeStr", timeStr) + .toString(); + } +} diff --git a/mh-common/src/main/java/com/mh/common/core/domain/dto/ProProfileDTO.java b/mh-common/src/main/java/com/mh/common/core/domain/dto/ProProfileDTO.java new file mode 100644 index 0000000..4e146aa --- /dev/null +++ b/mh-common/src/main/java/com/mh/common/core/domain/dto/ProProfileDTO.java @@ -0,0 +1,86 @@ +package com.mh.common.core.domain.dto; + +import lombok.Getter; +import lombok.Setter; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import java.math.BigDecimal; + +/** + * @author LJF + * @version 1.0 + * @project EEMCS + * @description + * @date 2025-03-19 11:43:26 + */ +@Setter +@Getter +public class ProProfileDTO { + + /** + * 总耗电量 + */ + private BigDecimal totalEle; + + /** + * 总冷量 + */ + private BigDecimal totalCold; + + /** + * z总用水量 + */ + private BigDecimal totalWater; + + /** + * 总用气量 + */ + private BigDecimal totalGas; + + /** + * 年耗电量 + */ + private BigDecimal yearEle; + + /** + * 总冷量 + */ + private BigDecimal yearCold; + + /** + * 年用水量 + */ + private BigDecimal yearWater; + + /** + * 年用气量 + */ + private BigDecimal yearGas; + + public ProProfileDTO() { + } + + public ProProfileDTO(BigDecimal totalEle, BigDecimal totalCold, BigDecimal totalWater, BigDecimal totalGas, BigDecimal yearEle, BigDecimal yearCold, BigDecimal yearWater, BigDecimal yearGas) { + this.totalEle = totalEle.setScale(2, BigDecimal.ROUND_HALF_UP); + this.totalCold = totalCold.setScale(2, BigDecimal.ROUND_HALF_UP); + this.totalWater = totalWater.setScale(2, BigDecimal.ROUND_HALF_UP); + this.totalGas = totalGas.setScale(2, BigDecimal.ROUND_HALF_UP); + this.yearEle = yearEle.setScale(2, BigDecimal.ROUND_HALF_UP); + this.yearCold = yearCold.setScale(2, BigDecimal.ROUND_HALF_UP); + this.yearWater = yearWater.setScale(2, BigDecimal.ROUND_HALF_UP); + this.yearGas = yearGas.setScale(2, BigDecimal.ROUND_HALF_UP); + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("totalEle", totalEle) + .append("totalCold", totalCold) + .append("totalWater", totalWater) + .append("totalGas", totalGas) + .append("yearEle", yearEle) + .append("yearWater", yearWater) + .append("yearGas", yearGas) + .toString(); + } +} diff --git a/mh-common/src/main/java/com/mh/common/core/domain/entity/SysParams.java b/mh-common/src/main/java/com/mh/common/core/domain/entity/SysParams.java index b825057..bfb0c09 100644 --- a/mh-common/src/main/java/com/mh/common/core/domain/entity/SysParams.java +++ b/mh-common/src/main/java/com/mh/common/core/domain/entity/SysParams.java @@ -3,11 +3,14 @@ package com.mh.common.core.domain.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import com.mh.common.core.domain.BaseEntity; import lombok.Getter; import lombok.Setter; import org.apache.commons.lang3.builder.ToStringBuilder; +import java.util.Date; + /** * @author LJF * @version 1.0 @@ -38,6 +41,22 @@ public class SysParams extends BaseEntity { */ private String proArea; + /** + * 项目地址 + */ + private String proAddr; + + /** + * 建筑面积 + */ + private String buildingArea; + + /** + * 运营开始时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date operateStartTime; + @Override public String toString() { return new ToStringBuilder(this) @@ -45,6 +64,9 @@ public class SysParams extends BaseEntity { .append("proName", proName) .append("logo", logo) .append("proArea", proArea) + .append("proAddr", proAddr) + .append("buildingArea", buildingArea) + .append("operateStartTime", operateStartTime) .toString(); } } diff --git a/mh-system/src/main/java/com/mh/system/mapper/energy/OverviewMapper.java b/mh-system/src/main/java/com/mh/system/mapper/energy/OverviewMapper.java new file mode 100644 index 0000000..c314be5 --- /dev/null +++ b/mh-system/src/main/java/com/mh/system/mapper/energy/OverviewMapper.java @@ -0,0 +1,62 @@ +package com.mh.system.mapper.energy; + +import com.mh.common.core.domain.entity.ChillersEntity; +import com.mh.common.core.domain.entity.CollectionParamsManage; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.math.BigDecimal; +import java.util.List; + +/** + * @author LJF + * @version 1.0 + * @project EEMCS + * @description 项目总览 + * @date 2025-03-19 16:37:22 + */ +@Mapper +public interface OverviewMapper { + + @Select("") + BigDecimal queryByDeviceNum(@Param("deviceNums") List deviceNums); + + @Select("") + List energyAnalysis(@Param("deviceNums") List deviceNums); +} 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 new file mode 100644 index 0000000..0272451 --- /dev/null +++ b/mh-system/src/main/java/com/mh/system/service/overview/IProOverviewService.java @@ -0,0 +1,20 @@ +package com.mh.system.service.overview; + +import com.mh.common.core.domain.dto.OverviewEnergyDTO; +import com.mh.common.core.domain.dto.ProProfileDTO; + +import java.util.List; + +/** + * @author LJF + * @version 1.0 + * @project EEMCS + * @description 项目总览 + * @date 2025-03-19 11:40:47 + */ +public interface IProOverviewService { + + List getProProfile(); + + List energyAnalysis(); +} 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 new file mode 100644 index 0000000..93733f2 --- /dev/null +++ b/mh-system/src/main/java/com/mh/system/service/overview/impl/ProOverviewServiceImpl.java @@ -0,0 +1,166 @@ +package com.mh.system.service.overview.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.mh.common.core.domain.dto.OverviewEnergyDTO; +import com.mh.common.core.domain.dto.ProProfileDTO; +import com.mh.common.core.domain.entity.ChillersEntity; +import com.mh.common.core.domain.entity.CollectionParamsManage; +import com.mh.common.core.domain.entity.SysDictData; +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 org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +/** + * @author LJF + * @version 1.0 + * @project EEMCS + * @description 项目总览服务实现类 + * @date 2025-03-19 15:44:31 + */ +@Service +public class ProOverviewServiceImpl implements IProOverviewService { + + private final CollectionParamsManageMapper collectionParamsManageMapper; + + private final SysDictDataMapper sysDictDataMapper; + + private final OverviewMapper overviewMapper; + + public ProOverviewServiceImpl(CollectionParamsManageMapper collectionParamsManageMapper, SysDictDataMapper sysDictDataMapper, OverviewMapper overviewMapper) { + this.collectionParamsManageMapper = collectionParamsManageMapper; + this.sysDictDataMapper = sysDictDataMapper; + this.overviewMapper = overviewMapper; + } + + @Override + public List energyAnalysis() { + List dataList = overviewMapper.energyAnalysis(null); + return List.of(); + } + + @Override + public List getProProfile() { + // 请求各个系统中有没有对应的总表,如果有直接查询总表,没有就是各个分表之和 + List sysTypeData = sysDictDataMapper.selectDictDataByType("sys_type"); + // 查询采集参数是这几个的: + // 耗电量 16 + // 产冷量 17 + // 用水量 18 + // 用气量 19 + BigDecimal totalEle = new BigDecimal(0); + BigDecimal totalCold = new BigDecimal(0); + BigDecimal totalWater = new BigDecimal(0); + BigDecimal totalGas = new BigDecimal(0); + + BigDecimal yearEle = new BigDecimal(0); + BigDecimal yearCold = new BigDecimal(0); + BigDecimal yearWater = new BigDecimal(0); + BigDecimal yearGas = new BigDecimal(0); + + for (SysDictData sysDictData : sysTypeData) { + String sysType = sysDictData.getDictValue(); + String[] paramTypes = {"16", "17", "18", "19"}; + for (String paramType : paramTypes) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("param_type", paramType); + queryWrapper.eq("system_type", sysType); + queryWrapper.eq("grade", 40); + queryWrapper.eq("mt_is_sum", 0); + Long count = collectionParamsManageMapper.selectCount(queryWrapper); + if (count > 0) { + // 查询总表 + getTotalData(paramType, queryWrapper, totalEle, + totalCold, + totalWater, + totalGas, + yearEle, + yearCold, + yearWater, + yearGas); + } else { + // 查询分表综合 + queryWrapper.eq("mt_is_sum", 1); + // 查询分表总和 + getTotalData(paramType, queryWrapper, + totalEle, + totalCold, + totalWater, + totalGas, + yearEle, + yearCold, + yearWater, + yearGas); + } + } + + } + ProProfileDTO proProfileDTO = new ProProfileDTO(totalEle, totalCold, totalWater, totalGas, yearEle, yearCold, yearWater, yearGas); + List proProfileDTOS = new ArrayList<>(); + proProfileDTOS.add(proProfileDTO); + return proProfileDTOS; + } + + private void getTotalData(String paramType, + QueryWrapper queryWrapper, + BigDecimal totalEle, + BigDecimal totalCold, + BigDecimal totalWater, + BigDecimal totalGas, + BigDecimal yearEle, + BigDecimal yearCold, + BigDecimal yearWater, + BigDecimal yearGas) { + List collectionParamsManages = collectionParamsManageMapper.selectList(queryWrapper); + // 遍历计算得出总用电量 + collectionParamsManages.forEach(collectionParamsManage -> { + // TODO + switch (Integer.parseInt(paramType)) { + case 16: + totalEle.add((collectionParamsManage.getCurValue().subtract(collectionParamsManage.getMtInitValue())) + .multiply(new BigDecimal(collectionParamsManage.getMtRatio()))); + break; + case 17: + totalCold.add((collectionParamsManage.getCurValue().subtract(collectionParamsManage.getMtInitValue())) + .multiply(new BigDecimal(collectionParamsManage.getMtRatio()))); + break; + case 18: + totalWater.add((collectionParamsManage.getCurValue().subtract(collectionParamsManage.getMtInitValue())) + .multiply(new BigDecimal(collectionParamsManage.getMtRatio()))); + break; + case 19: + totalGas.add((collectionParamsManage.getCurValue().subtract(collectionParamsManage.getMtInitValue())) + .multiply(new BigDecimal(collectionParamsManage.getMtRatio()))); + break; + default: + break; + } + + }); + // 计算得出今年的各个参数用量 + BigDecimal yearValue = overviewMapper.queryByDeviceNum(collectionParamsManages); + switch (Integer.parseInt(paramType)) { + case 16: + yearEle = yearValue; + break; + case 17: + yearCold = yearValue; + break; + case 18: + yearWater = yearValue; + break; + case 19: + yearGas = yearValue; + break; + default: + break; + } + + } + +} diff --git a/mh-system/src/main/resources/mapper/system/SysParamsMapper.xml b/mh-system/src/main/resources/mapper/system/SysParamsMapper.xml index 94ffe64..cfa1b1e 100644 --- a/mh-system/src/main/resources/mapper/system/SysParamsMapper.xml +++ b/mh-system/src/main/resources/mapper/system/SysParamsMapper.xml @@ -9,11 +9,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + +