diff --git a/mh-admin/src/main/java/com/mh/web/controller/report/ReportHeatingController.java b/mh-admin/src/main/java/com/mh/web/controller/report/ReportHeatingController.java new file mode 100644 index 0000000..fafce32 --- /dev/null +++ b/mh-admin/src/main/java/com/mh/web/controller/report/ReportHeatingController.java @@ -0,0 +1,90 @@ +package com.mh.web.controller.report; + +import com.alibaba.excel.EasyExcel; +import com.mh.common.core.controller.BaseController; +import com.mh.common.core.domain.AjaxResult; +import com.mh.common.core.domain.dto.ReportHeatingRunParamDTO; +import com.mh.common.core.domain.dto.ReportSteamRunParamDTO; +import com.mh.common.core.domain.entity.ReportHeatingRunParamHis; +import com.mh.common.core.domain.entity.ReportSteamRunParamHis; +import com.mh.common.core.page.TableDataInfo; +import com.mh.common.utils.file.handle.ExcelFillCellMergeHandler; +import com.mh.common.utils.file.handle.ReportSysParamHandler; +import com.mh.common.utils.file.handle.RowHeightStyleHandler; +import com.mh.system.service.report.IReportHeatingService; +import com.mh.system.service.report.IReportSteamService; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.web.bind.annotation.*; + +import java.io.IOException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author LJF + * @version 1.0 + * @project eemcs + * @description 采暖系统运行参数报表 + * @date 2024-05-30 08:45:57 + */ +@RestController +@RequestMapping("/reportHeating") +@Slf4j +public class ReportHeatingController extends BaseController { + + private final IReportHeatingService reportHeatingService; + + private ReportHeatingController(IReportHeatingService reportHeatingService) { + this.reportHeatingService = reportHeatingService; + } + + @PostMapping("/list") + public TableDataInfo list(@RequestBody ReportHeatingRunParamHis reportHeatingRunParamHis) { + startPage(); + List list = reportHeatingService.selectHeatingList(reportHeatingRunParamHis); + return getDataTable(list); + } + + @PutMapping("/edit") + public AjaxResult edit(@RequestBody ReportHeatingRunParamHis reportHeatingRunParamHis) { + return toAjax(reportHeatingService.updateRunParams(reportHeatingRunParamHis)); + } + + @PostMapping("/export") + public void exportExcel(@RequestBody ReportHeatingRunParamHis reportSteamRunParamHis, HttpServletResponse response) { + // 文件名 + try { + String fileName = "采暖系统运行记录表.xlsx"; + String headTitle = "采暖系统运行记录表"; + // 从数据库获取数据 + List list = reportHeatingService.selectHeatingList(reportSteamRunParamHis); + if (list != null) { + // 设置响应格式 + response.setContentType("application/vdn.ms-excel;charset=utf-8"); + response.setHeader("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(fileName, StandardCharsets.UTF_8) + "\""); + response.setCharacterEncoding(String.valueOf(StandardCharsets.UTF_8)); + ExcelFillCellMergeHandler mergePrevCol = new ExcelFillCellMergeHandler(); + List infoDTOS = list.stream().map(info -> { + ReportHeatingRunParamDTO deviceInfoDTO = new ReportHeatingRunParamDTO(); + BeanUtils.copyProperties(info, deviceInfoDTO); + return deviceInfoDTO; + }).collect(Collectors.toList()); + + // 内容格式 + EasyExcel.write(response.getOutputStream(), ReportHeatingRunParamDTO.class) + .registerWriteHandler(new ReportSysParamHandler(headTitle)) + .registerWriteHandler(mergePrevCol) + .registerWriteHandler(new RowHeightStyleHandler()) + .sheet(fileName.replace(".xlsx", "")) + .doWrite(infoDTOS); + } + } catch (IOException e) { + throw new RuntimeException("下载报表异常"); + } + } + +} diff --git a/mh-admin/src/main/resources/节能岛改造每日能耗统计表.xlsx b/mh-admin/src/main/resources/节能岛改造每日能耗统计表.xlsx index 0faaa02..a22cf2a 100644 Binary files a/mh-admin/src/main/resources/节能岛改造每日能耗统计表.xlsx and b/mh-admin/src/main/resources/节能岛改造每日能耗统计表.xlsx differ diff --git a/mh-common/src/main/java/com/mh/common/core/domain/dto/ReportHeatingRunParamDTO.java b/mh-common/src/main/java/com/mh/common/core/domain/dto/ReportHeatingRunParamDTO.java new file mode 100644 index 0000000..6803993 --- /dev/null +++ b/mh-common/src/main/java/com/mh/common/core/domain/dto/ReportHeatingRunParamDTO.java @@ -0,0 +1,166 @@ +package com.mh.common.core.domain.dto; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.*; +import com.alibaba.excel.enums.poi.BorderStyleEnum; +import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * @author LJF + * @version 1.0 + * @project NewZhujiang_Server + * @description 采暖系统参数报表 + * @date 2024-05-30 11:00:12 + */ +@Data +@NoArgsConstructor +@Accessors(chain = true) +@HeadRowHeight(25) +@HeadFontStyle(fontHeightInPoints = 14) +@ContentFontStyle(fontHeightInPoints = 13) +@ContentRowHeight(20) +@ContentStyle( + horizontalAlignment = HorizontalAlignmentEnum.CENTER, + borderBottom = BorderStyleEnum.THIN, + borderLeft = BorderStyleEnum.THIN, + borderRight = BorderStyleEnum.THIN, + borderTop = BorderStyleEnum.THIN +) +@ColumnWidth(10) +public class ReportHeatingRunParamDTO { + + /** + * 当前时间 + */ + @ColumnWidth(17) + @ExcelProperty(value = {"${deviceType}", "时间"}, index = 0) + private String curTime; + + /** + * 当前状态 + */ + @ColumnWidth(10) + @ExcelProperty(value = {"${deviceType}", "1号采暖设备", "运行状态"}, index = 1) + private String runStatusBoilerOne; + + /** + * 出水温度 + */ + @ExcelProperty(value = {"${deviceType}", "1号采暖设备", "出水温度(℃)"}, index = 2) + @ColumnWidth(10) + private BigDecimal tempOutBoilerOne; + + /** + * 回水温度 + */ + @ExcelProperty(value = {"${deviceType}", "1号采暖设备", "回水温度(℃)"}, index = 3) + @ColumnWidth(10) + private BigDecimal tempInBoilerOne; + + /** + * 炉水温度 + */ + @ExcelProperty(value = {"${deviceType}", "1号采暖设备", "炉水温度(℃)"}, index = 4) + @ColumnWidth(10) + private BigDecimal tempWaterBoilerOne; + + /** + * 烟道温度(℃) + */ + @ExcelProperty(value = {"${deviceType}", "1号采暖设备", "烟道温度(℃)"}, index = 5) + @ColumnWidth(10) + private BigDecimal tempFlueGasBoilerOne; + + /** + * 当前状态 + */ + @ColumnWidth(10) + @ExcelProperty(value = {"${deviceType}", "2号采暖设备", "运行状态"}, index = 6) + private String runStatusBoilerTwo; + + /** + * 出水温度 + */ + @ExcelProperty(value = {"${deviceType}", "2号采暖设备", "出水温度(℃)"}, index = 7) + @ColumnWidth(10) + private BigDecimal tempOutBoilerTwo; + + /** + * 回水温度 + */ + @ExcelProperty(value = {"${deviceType}", "2号采暖设备", "回水温度(℃)"}, index = 8) + @ColumnWidth(10) + private BigDecimal tempInBoilerTwo; + + /** + * 炉水温度 + */ + @ExcelProperty(value = {"${deviceType}", "2号采暖设备", "炉水温度(℃)"}, index = 9) + @ColumnWidth(10) + private BigDecimal tempWaterBoilerTwo; + + /** + * 烟道温度(℃) + */ + @ExcelProperty(value = {"${deviceType}", "2号采暖设备", "烟道温度(℃)"}, index = 10) + @ColumnWidth(10) + private BigDecimal tempFlueGasBoilerTwo; + + /** + * 当前状态 + */ + @ColumnWidth(10) + @ExcelProperty(value = {"${deviceType}", "1号采暖泵", "运行状态"}, index = 11) + private String runStatusPumpOne; + + /** + * 频率 + */ + @ColumnWidth(10) + @ExcelProperty(value = {"${deviceType}", "1号采暖泵", "频率(Hz)"}, index = 12) + private BigDecimal frequencyPumpOne; + + /** + * 当前状态 + */ + @ColumnWidth(10) + @ExcelProperty(value = {"${deviceType}", "2号采暖泵", "运行状态"}, index = 13) + private String runStatusPumpTwo; + + /** + * 频率 + */ + @ColumnWidth(10) + @ExcelProperty(value = {"${deviceType}", "2号采暖泵", "频率(Hz)"}, index = 14) + private BigDecimal frequencyPumpTwo; + + /** + * 当前状态 + */ + @ColumnWidth(10) + @ExcelProperty(value = {"${deviceType}", "3号采暖泵", "运行状态"}, index = 15) + private String runStatusPumpThree; + + /** + * 频率 + */ + @ColumnWidth(10) + @ExcelProperty(value = {"${deviceType}", "3号采暖泵", "频率(Hz)"}, index = 16) + private BigDecimal frequencyPumpThree; + + // 巡查记录人 + @ExcelProperty(value = {"${deviceType}", "巡查记录人", "巡查记录人"}, index = 17) + @ColumnWidth(20) + private String recorder; + + // 备注信息 + @ExcelProperty(value = {"${deviceType}", "备注", "备注"}, index = 18) + @ColumnWidth(20) + private String remark; + +} diff --git a/mh-common/src/main/java/com/mh/common/core/domain/entity/ReportHeatingRunParamHis.java b/mh-common/src/main/java/com/mh/common/core/domain/entity/ReportHeatingRunParamHis.java new file mode 100644 index 0000000..05b8fd8 --- /dev/null +++ b/mh-common/src/main/java/com/mh/common/core/domain/entity/ReportHeatingRunParamHis.java @@ -0,0 +1,201 @@ +package com.mh.common.core.domain.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.mh.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.Date; +import java.util.Map; +import java.util.StringJoiner; + +/** + * @author LJF + * @version 1.0 + * @project EEMCS + * @description 采暖系统运行记录表 + * @date 2025-10-21 10:26:12 + */ +@Data +@TableName("report_heating_run_param_his") // 指定数据库表名 +public class ReportHeatingRunParamHis extends BaseEntity { + + @TableId(value = "id", type = IdType.ASSIGN_UUID) + private String id; + + // 日期 + @TableField("cur_date") // 字段映射(可选,若字段名与属性名不一致时需指定) + private LocalDate curDate; + + // 时间 + @TableField("cur_time") + private String curTime; // 字符串类型直接映射 + + // 班次 + @TableField("classes") + private String classes; + + // 锅炉1状态 + @TableField("cur_status_boiler_one") + private Integer curStatusBoilerOne; + + // 锅炉1状态 + @TableField(exist = false) + private String runStatusBoilerOne; + + // 锅炉1出水温度(℃) + @TableField("temp_out_boiler_one") + private BigDecimal tempOutBoilerOne; // 精度要求高时使用BigDecimal + + // 锅炉1回水温度(℃) + @TableField("temp_in_boiler_one") + private BigDecimal tempInBoilerOne; + + // 锅炉1炉水温度(℃) + @TableField("temp_water_boiler_one") + private BigDecimal tempWaterBoilerOne; + + // 锅炉1烟道温度(℃) + @TableField("temp_flue_gas_boiler_one") + private BigDecimal tempFlueGasBoilerOne; + + // 锅炉2状态 + @TableField("cur_status_boiler_two") + private Integer curStatusBoilerTwo; + + // 锅炉2状态 + @TableField(exist = false) + private String runStatusBoilerTwo; + + // 锅炉2出水温度(℃) + @TableField("temp_out_boiler_two") + private BigDecimal tempOutBoilerTwo; + + // 锅炉2回水温度(℃) + @TableField("temp_in_boiler_two") + private BigDecimal tempInBoilerTwo; + + // 锅炉2炉水温度(℃) + @TableField("temp_water_boiler_two") + private BigDecimal tempWaterBoilerTwo; + + // 锅炉2烟道温度(℃) + @TableField("temp_flue_gas_boiler_two") + private BigDecimal tempFlueGasBoilerTwo; + + // 采暖泵1状态 + @TableField("cur_status_pump_one") + private Integer curStatusPumpOne; + + // 采暖泵1状态 + @TableField(exist = false) + private String runStatusPumpOne; + + // 采暖泵1频率(Hz) + @TableField("frequency_pump_one") + private BigDecimal frequencyPumpOne; + + // 采暖泵2状态 + @TableField("cur_status_pump_two") + private Integer curStatusPumpTwo; + + // 采暖泵2状态 + @TableField(exist = false) + private String runStatusPumpTwo; + + // 采暖泵2频率(Hz) + @TableField("frequency_pump_two") + private BigDecimal frequencyPumpTwo; + + // 采暖泵3状态 + @TableField("cur_status_pump_three") + private Integer curStatusPumpThree; + + // 采暖泵3状态 + @TableField(exist = false) + private String runStatusPumpThree; + + // 采暖泵3频率(Hz) + @TableField("frequency_pump_three") + private BigDecimal frequencyPumpThree; + + // 巡查记录人 + @TableField("recorder") + private String recorder; + + // 备注 + @TableField("remark") + private String remark; + + // 创建时间(自动填充) + @TableField(value = "create_date", fill = FieldFill.INSERT) // 插入时自动填充 + private LocalDateTime createDate; + + @JsonIgnore + @TableField(exist = false) + private String searchValue; + + /** + * 请求参数 + */ + @TableField(exist = false) + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private Map params; + + /** 创建者 */ + @JsonIgnore + @TableField(exist = false) + private String createBy; + + /** 创建时间 */ + @TableField(exist = false) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + + /** 更新者 */ + @JsonIgnore + @TableField(exist = false) + private String updateBy; + + /** 更新时间 */ + @JsonIgnore + @TableField(exist = false) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + + @Override + public String toString() { + return new StringJoiner(", ", ReportHeatingRunParamHis.class.getSimpleName() + "[", "]") + .add("id='" + id + "'") + .add("curDate=" + curDate) + .add("curTime='" + curTime + "'") + .add("classes='" + classes + "'") + .add("curStatusBoilerOne=" + curStatusBoilerOne) + .add("tempOutBoilerOne=" + tempOutBoilerOne) + .add("tempInBoilerOne=" + tempInBoilerOne) + .add("tempWaterBoilerOne=" + tempWaterBoilerOne) + .add("tempFlueGasBoilerOne=" + tempFlueGasBoilerOne) + .add("curStatusBoilerTwo=" + curStatusBoilerTwo) + .add("tempOutBoilerTwo=" + tempOutBoilerTwo) + .add("tempInBoilerTwo=" + tempInBoilerTwo) + .add("tempWaterBoilerTwo=" + tempWaterBoilerTwo) + .add("tempFlueGasBoilerTwo=" + tempFlueGasBoilerTwo) + .add("curStatusPumpOne=" + curStatusPumpOne) + .add("frequencyPumpOne=" + frequencyPumpOne) + .add("curStatusPumpTwo=" + curStatusPumpTwo) + .add("frequencyPumpTwo=" + frequencyPumpTwo) + .add("curStatusPumpThree=" + curStatusPumpThree) + .add("frequencyPumpThree=" + frequencyPumpThree) + .add("recorder='" + recorder + "'") + .add("remark='" + remark + "'") + .add("createDate=" + createDate) + .toString(); + } +} diff --git a/mh-quartz/src/main/java/com/mh/quartz/task/ReportTask.java b/mh-quartz/src/main/java/com/mh/quartz/task/ReportTask.java index ae7f439..4c19db8 100644 --- a/mh-quartz/src/main/java/com/mh/quartz/task/ReportTask.java +++ b/mh-quartz/src/main/java/com/mh/quartz/task/ReportTask.java @@ -3,6 +3,7 @@ package com.mh.quartz.task; import com.mh.common.utils.DateUtils; import com.mh.common.utils.StringUtils; import com.mh.system.service.report.IMeterReadingsHisService; +import com.mh.system.service.report.IReportHeatingService; import com.mh.system.service.report.IReportHotWaterService; import com.mh.system.service.report.IReportSteamService; import lombok.extern.slf4j.Slf4j; @@ -31,6 +32,9 @@ public class ReportTask { @Autowired private IReportSteamService reportSteamService; + @Autowired + private IReportHeatingService reportHeatingService; + /** * 创建抄表记录查询 */ @@ -61,4 +65,12 @@ public class ReportTask { reportSteamService.execProRunParamHis(); } + /** + * 创建采暖系统运行参数 + */ + public void createHeatingRunParam() { + // 定时执行运行脚本 + reportHeatingService.execProRunParamHis(); + } + } diff --git a/mh-system/src/main/java/com/mh/system/mapper/report/ReportHeatingRunParamHisMapper.java b/mh-system/src/main/java/com/mh/system/mapper/report/ReportHeatingRunParamHisMapper.java new file mode 100644 index 0000000..b6fafcb --- /dev/null +++ b/mh-system/src/main/java/com/mh/system/mapper/report/ReportHeatingRunParamHisMapper.java @@ -0,0 +1,32 @@ +package com.mh.system.mapper.report; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mh.common.core.domain.entity.ReportHeatingRunParamHis; +import com.mh.common.core.domain.entity.ReportHotWaterParamHis; +import com.mh.common.core.domain.entity.ReportSteamRunParamHis; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Options; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.mapping.StatementType; + +import java.util.List; + +/** + * @author LJF + * @version 1.0 + * @project NewZhujiang_Server + * @description 采暖系统运行参数服务类 + * @date 2024-05-29 11:23:32 + */ +@Mapper +public interface ReportHeatingRunParamHisMapper extends BaseMapper { + + @Select("call pro_heating_run_param(#{curTime,jdbcType=VARCHAR,mode=IN})") + @Options(statementType = StatementType.CALLABLE) + void execProHeatingRunParam(@Param("curTime") String curTime); + + @Select("select * from report_heating_run_param_his where cur_time >= #{beginDate} and cur_time <= #{endDate} order by cur_time desc ") + List findPage(@Param("beginDate") String beginDate, + @Param("endDate") String endDate); +} diff --git a/mh-system/src/main/java/com/mh/system/service/report/IReportHeatingService.java b/mh-system/src/main/java/com/mh/system/service/report/IReportHeatingService.java new file mode 100644 index 0000000..f7ee1ff --- /dev/null +++ b/mh-system/src/main/java/com/mh/system/service/report/IReportHeatingService.java @@ -0,0 +1,21 @@ +package com.mh.system.service.report; + +import com.mh.common.core.domain.entity.ReportHeatingRunParamHis; + +import java.util.List; + +/** + * @author LJF + * @version 1.0 + * @project NewZhujiang_Server + * @description 采暖泵服务类 + * @date 2024-05-29 11:20:30 + */ +public interface IReportHeatingService { + + void execProRunParamHis(); + + List selectHeatingList(ReportHeatingRunParamHis reportHeatingRunParamHis); + + int updateRunParams(ReportHeatingRunParamHis reportHeatingRunParamHis); +} diff --git a/mh-system/src/main/java/com/mh/system/service/report/impl/MeterReadingsHisServiceImpl.java b/mh-system/src/main/java/com/mh/system/service/report/impl/MeterReadingsHisServiceImpl.java index cc173e6..ab36229 100644 --- a/mh-system/src/main/java/com/mh/system/service/report/impl/MeterReadingsHisServiceImpl.java +++ b/mh-system/src/main/java/com/mh/system/service/report/impl/MeterReadingsHisServiceImpl.java @@ -28,11 +28,18 @@ public class MeterReadingsHisServiceImpl implements IMeterReadingsHisService { private ReportMeterReadingsHisMapper reportMeterReadingsHisMapper; private final List locationList = List.of( + "离心机2号空调主机", "磁悬浮3号空调主机", - "变频5号冷冻泵", + "1号冷冻泵", + "2号冷冻泵", + "3号冷冻泵", "4号冷冻泵", - "变频5号冷却泵", + "变频5号冷冻泵", + "1号冷却泵", + "2号冷却泵", + "3号冷却泵", "4号冷却泵", + "变频5号冷却泵", "变频1号冷却塔", "变频2号冷却塔", "变频3号冷却塔", @@ -42,23 +49,12 @@ public class MeterReadingsHisServiceImpl implements IMeterReadingsHisService { "洗衣房热泵控制柜", "群楼中厨水泵控制柜", "热水热泵系统用电总合计:", - "空调冷冻水", - "空调冷却水", "三楼中、高区热水", "群楼、中厨房热水", "热水热泵系统用水总合计:", - "蒸汽发生器+采暖", - "蒸汽发生器+采暖", - "蒸汽发生器+采暖用气总合计:", - "蒸汽发生器+采暖", - "蒸汽发生器+采暖用电总合计:", - "蒸汽发生器+采暖", - "蒸汽发生器用水总合计:", - "水、电、气费用总合计(水/电/气价预估单价,单价需以实际缴费为准):", - "中央空调冷冻流量", - "中央空调冷却流量", - "中央空调采暖流量", - "蒸汽流量" + "水、电费用总合计(水/电价预估单价,单价需以实际缴费为准):", + "中央空调制冷量(kw)", + "蒸汽流量(吨)" ); private final List mtTypeList = List.of( @@ -76,22 +72,15 @@ public class MeterReadingsHisServiceImpl implements IMeterReadingsHisService { "电表", "电表", "电表", - "水表", - "水表", - "水表", - "水表", - "水表", - "燃气表(常用)", - "燃气表(备用)", - "燃气表", + "电表", + "电表", + "电表", "电表", "电表", "水表", "水表", "总合计", "流量计量表", - "流量计量表", - "流量计量表", "流量计量表" ); @@ -177,18 +166,12 @@ public class MeterReadingsHisServiceImpl implements IMeterReadingsHisService { private void createAggregateObjects(List list, String curDate) { Map, ReportMeterReadingsHis>> aggregateCreators = Map.of( - 8, l -> createAggregateObject("电表", "空调系统用电总合计:", - calculateTotalByRange(l, 0, 9), Objects.requireNonNull(list.stream().filter(v -> v.getSortOrder() == 8).findFirst().orElse(null))), - 13, l -> createAggregateObject("电表", "热水热泵系统用电总合计:", - calculateTotalByRange(l, 9, 14), Objects.requireNonNull(list.stream().filter(v -> v.getSortOrder() == 13).findFirst().orElse(null))), - 18, l -> createAggregateObject("水表", "热水热泵系统用水总合计:", - calculateTotalByRange(l, 14, 19), Objects.requireNonNull(list.stream().filter(v -> v.getSortOrder() == 18).findFirst().orElse(null))), - 21, l -> createAggregateObject("燃气表", "蒸汽发生器+采暖用气总合计:", - calculateTotalByRange(l, 19, 22), Objects.requireNonNull(list.stream().filter(v -> v.getSortOrder() == 21).findFirst().orElse(null))), - 23, l -> createAggregateObject("电表", "蒸汽发生器+采暖用电总合计:", - calculateTotalByRange(l, 22, 24), Objects.requireNonNull(list.stream().filter(v -> v.getSortOrder() == 23).findFirst().orElse(null))), - 25, l -> createAggregateObject("水表", "蒸汽发生器用水总合计:", - calculateTotalByRange(l, 24, 26), Objects.requireNonNull(list.stream().filter(v -> v.getSortOrder() == 25).findFirst().orElse(null))) + 15, l -> createAggregateObject("电表", "空调系统用电总合计:", + calculateTotalByRange(l, 0, 16), Objects.requireNonNull(list.stream().filter(v -> v.getSortOrder() == 15).findFirst().orElse(null))), + 20, l -> createAggregateObject("电表", "热水热泵系统用电总合计:", + calculateTotalByRange(l, 16, 21), Objects.requireNonNull(list.stream().filter(v -> v.getSortOrder() == 20).findFirst().orElse(null))), + 23, l -> createAggregateObject("水表", "热水热泵系统用水总合计:", + calculateTotalByRange(l, 21, 24), Objects.requireNonNull(list.stream().filter(v -> v.getSortOrder() == 23).findFirst().orElse(null))) ); for (int i = 0; i < locationList.size(); i++) { if (aggregateCreators.containsKey(i)) { @@ -244,14 +227,14 @@ public class MeterReadingsHisServiceImpl implements IMeterReadingsHisService { // 添加水表、电表、燃气表、水、电、气费用总合计 ReportMeterReadingsHis totalReportMeterReadingsHis = new ReportMeterReadingsHis(); totalReportMeterReadingsHis.setMtType("总合计"); - totalReportMeterReadingsHis.setLocation("水、电、气费用总合计(水/电/气价预估单价,单价需以实际缴费为准):"); + totalReportMeterReadingsHis.setLocation("水、电费用总合计(水/电价预估单价,单价需以实际缴费为准):"); totalReportMeterReadingsHis.setYesterdayReading(new BigDecimal("0")); - Set sortOrderSet = Set.of(9, 14, 19, 22, 24, 26); + Set sortOrderSet = Set.of(16, 21, 24); BigDecimal grandTotal = calculateTotalBySpecificValues(list, sortOrderSet); totalReportMeterReadingsHis.setTodayReading(grandTotal); totalReportMeterReadingsHis.setMtRatio(1); - totalReportMeterReadingsHis.setSortOrder(27); + totalReportMeterReadingsHis.setSortOrder(25); totalReportMeterReadingsHis.setUnitPrice(new BigDecimal("1")); totalReportMeterReadingsHis.setTodayTimestamp(DateUtils.stringToDate(curDate + " 00:00:00", DateUtils.YYYY_MM_DD_HH_MM_SS)); diff --git a/mh-system/src/main/java/com/mh/system/service/report/impl/ReportHeatingServiceImpl.java b/mh-system/src/main/java/com/mh/system/service/report/impl/ReportHeatingServiceImpl.java new file mode 100644 index 0000000..2cc8045 --- /dev/null +++ b/mh-system/src/main/java/com/mh/system/service/report/impl/ReportHeatingServiceImpl.java @@ -0,0 +1,87 @@ +package com.mh.system.service.report.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.mh.common.core.domain.entity.ReportHeatingRunParamHis; +import com.mh.common.core.domain.entity.ReportSteamRunParamHis; +import com.mh.common.utils.StringUtils; +import com.mh.system.mapper.report.ReportHeatingRunParamHisMapper; +import com.mh.system.mapper.report.ReportSteamRunParamHisMapper; +import com.mh.system.service.report.IReportHeatingService; +import com.mh.system.service.report.IReportSteamService; +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.List; + +/** + * @author LJF + * @version 1.0 + * @project NewZhujiang_Server + * @description 采暖系统服务类 + * @date 2024-05-29 11:20:30 + */ +@Slf4j +@Service +public class ReportHeatingServiceImpl implements IReportHeatingService { + + @Resource + ReportHeatingRunParamHisMapper reportHeatingRunParamHisMapper; + + private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + + @Override + public int updateRunParams(ReportHeatingRunParamHis reportHeatingRunParamHis) { + return reportHeatingRunParamHisMapper.updateById(reportHeatingRunParamHis); + } + + @Override + public void execProRunParamHis() { + try { + log.info("执行计算采暖泵运行参数存储过程"); + // 获取当前日期和时间 + LocalDateTime now = LocalDateTime.now(); + // 格式化日期和时间 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String formattedOneHourAgo = now.format(formatter); + String timeParam = formattedOneHourAgo.substring(0, 13); + reportHeatingRunParamHisMapper.execProHeatingRunParam(timeParam); + log.info("执行计算采暖泵运行参数执行完成"); + } catch (Exception e) { + log.error("执行计算采暖泵参数存储过程执行失败", e); + throw new RuntimeException(e); + } + } + + + @Override + public List selectHeatingList(ReportHeatingRunParamHis reportHeatingRunParamHis) { + if (reportHeatingRunParamHis.getParams() == null) { + reportHeatingRunParamHis.setParams(new java.util.HashMap<>()); + } + String startTime = (String) reportHeatingRunParamHis.getParams().get("startTime"); + String endTime = (String) reportHeatingRunParamHis.getParams().get("endTime"); + if (StringUtils.isBlank(startTime)) { + LocalDateTime now = LocalDateTime.now(); + startTime = now.format(dateTimeFormatter).substring(0, 10); + endTime = now.format(dateTimeFormatter).substring(0, 10); + } + startTime = startTime + " 00"; + endTime = endTime + " 23"; + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.between("cur_time", startTime, endTime); + queryWrapper.orderByDesc("cur_time"); + List reportHeatingRunParamHis1 = reportHeatingRunParamHisMapper.selectList(queryWrapper); + // 遍历数据,判断curStatus=1,运行,curStatus=0 停止,赋值给runStatus + for (ReportHeatingRunParamHis reportHeatingRunParamHis2 : reportHeatingRunParamHis1) { + reportHeatingRunParamHis2.setRunStatusBoilerOne(reportHeatingRunParamHis2.getCurStatusBoilerOne() == 1 ? "运行" : "停止"); + reportHeatingRunParamHis2.setRunStatusBoilerTwo(reportHeatingRunParamHis2.getCurStatusBoilerTwo() == 1 ? "运行" : "停止"); + reportHeatingRunParamHis2.setRunStatusPumpOne(reportHeatingRunParamHis2.getCurStatusPumpOne() == 1 ? "运行" : "停止"); + reportHeatingRunParamHis2.setRunStatusPumpTwo(reportHeatingRunParamHis2.getCurStatusPumpTwo() == 1 ? "运行" : "停止"); + reportHeatingRunParamHis2.setRunStatusPumpThree(reportHeatingRunParamHis2.getCurStatusPumpThree() == 1 ? "运行" : "停止"); + } + return reportHeatingRunParamHis1; + } +} diff --git a/sql/2025新增.sql b/sql/2025新增.sql index 5640192..a28df2f 100644 --- a/sql/2025新增.sql +++ b/sql/2025新增.sql @@ -401,3 +401,60 @@ COMMENT ON COLUMN public.report_hot_water_param_his.level_water_tank_two IS '中 COMMENT ON COLUMN public.report_hot_water_param_his.recorder IS '巡查记录人(工号/姓名)'; COMMENT ON COLUMN public.report_hot_water_param_his.remark IS '异常情况备注说明'; COMMENT ON COLUMN public.report_hot_water_param_his.create_time IS '记录生成时间(含时区信息)'; + +-- 采暖系统运行记录报表 +CREATE TABLE public.report_heating_run_param_his ( + id varchar(36) NOT NULL ,-- 自增主键 + cur_date date NULL ,-- 日期 + cur_time varchar(20) NULL ,-- 时间 + classes varchar(50) NULL ,-- 班次 + cur_status_boiler_one int NULL ,-- 当前状态℃ + temp_out_boiler_one numeric(24, 2) NULL ,-- 出水温度 + temp_in_boiler_one numeric(24, 2) NULL ,-- 回水温度 + temp_water_boiler_one numeric(24, 2) NULL ,-- 炉水温度 + temp_flue_gas_boiler_one numeric(24, 2) NULL ,-- 烟道温度℃ + cur_status_boiler_two int NULL ,-- 当前状态℃ + temp_out_boiler_two numeric(24, 2) NULL ,-- 出水温度 + temp_in_boiler_two numeric(24, 2) NULL ,-- 回水温度 + temp_water_boiler_two numeric(24, 2) NULL ,-- 炉水温度 + temp_flue_gas_boiler_two numeric(24, 2) NULL ,-- 烟道温度℃ + cur_status_pump_one int null, -- 1号采暖泵运行状态 + frequency_pump_one numeric(24,2) null, -- 1号采暖泵当前频率 + cur_status_pump_two int null, -- 2号采暖泵运行状态 + frequency_pump_two numeric(24,2) null, -- 2号采暖泵当前频率 + cur_status_pump_three int null, -- 3号采暖泵运行状态 + frequency_pump_three numeric(24,2) null, -- 3号采暖泵当前频率 + recorder varchar(50) null, -- 巡查记录人 + remark varchar(200) null, -- 备注 + create_date timestamp default now(), -- 创建时间 + CONSTRAINT report_heating_run_param_his_pkey PRIMARY KEY (id) +); +CREATE INDEX idx_report_heating_run_param_his_cur_date ON public.report_heating_run_param_his USING btree (cur_date); +CREATE INDEX idx_report_heating_run_param_his_cur_time ON public.report_heating_run_param_his USING btree (cur_time); +CREATE INDEX idx_report_heating_run_param_his_recorder ON public.report_heating_run_param_his USING btree (recorder); + +-- Column comments + +COMMENT ON COLUMN public.report_heating_run_param_his.id IS '主键'; +COMMENT ON COLUMN public.report_heating_run_param_his.cur_date IS '日期(格式:YYYY-MM-DD)'; +COMMENT ON COLUMN public.report_heating_run_param_his.cur_time IS '时间(格式:HH24:MI:SS)'; +COMMENT ON COLUMN public.report_heating_run_param_his.classes IS '班次(如:早班、中班、夜班)'; +COMMENT ON COLUMN public.report_heating_run_param_his.cur_status_boiler_one IS '锅炉1当前状态(℃)'; +COMMENT ON COLUMN public.report_heating_run_param_his.temp_out_boiler_one IS '锅炉1出水温度(℃)'; +COMMENT ON COLUMN public.report_heating_run_param_his.temp_in_boiler_one IS '锅炉1回水温度(℃)'; +COMMENT ON COLUMN public.report_heating_run_param_his.temp_water_boiler_one IS '锅炉1炉水温度(℃)'; +COMMENT ON COLUMN public.report_heating_run_param_his.temp_flue_gas_boiler_one IS '锅炉1烟道温度(℃)'; +COMMENT ON COLUMN public.report_heating_run_param_his.cur_status_boiler_two IS '锅炉2当前状态(℃)'; +COMMENT ON COLUMN public.report_heating_run_param_his.temp_out_boiler_two IS '锅炉2出水温度(℃)'; +COMMENT ON COLUMN public.report_heating_run_param_his.temp_in_boiler_two IS '锅炉2回水温度(℃)'; +COMMENT ON COLUMN public.report_heating_run_param_his.temp_water_boiler_two IS '锅炉2炉水温度(℃)'; +COMMENT ON COLUMN public.report_heating_run_param_his.temp_flue_gas_boiler_two IS '锅炉2烟道温度(℃)'; +COMMENT ON COLUMN public.report_heating_run_param_his.cur_status_pump_one IS '1号采暖泵运行状态(0-停止,1-运行)'; +COMMENT ON COLUMN public.report_heating_run_param_his.frequency_pump_one IS '1号采暖泵当前频率(Hz)'; +COMMENT ON COLUMN public.report_heating_run_param_his.cur_status_pump_two IS '2号采暖泵运行状态(0-停止,1-运行)'; +COMMENT ON COLUMN public.report_heating_run_param_his.frequency_pump_two IS '2号采暖泵当前频率(Hz)'; +COMMENT ON COLUMN public.report_heating_run_param_his.cur_status_pump_three IS '3号采暖泵运行状态(0-停止,1-运行)'; +COMMENT ON COLUMN public.report_heating_run_param_his.frequency_pump_three IS '3号采暖泵当前频率(Hz)'; +COMMENT ON COLUMN public.report_heating_run_param_his.recorder IS '巡查记录人(操作员姓名)'; +COMMENT ON COLUMN public.report_heating_run_param_his.remark IS '备注(异常情况描述)'; +COMMENT ON COLUMN public.report_heating_run_param_his.create_date IS '记录创建时间(默认当前时间)'; \ No newline at end of file diff --git a/sql/创建采暖系统参数表存储过程.sql b/sql/创建采暖系统参数表存储过程.sql new file mode 100644 index 0000000..8b18d70 --- /dev/null +++ b/sql/创建采暖系统参数表存储过程.sql @@ -0,0 +1,145 @@ +-- DROP PROCEDURE public.pro_heating_run_param(varchar); + +CREATE OR REPLACE PROCEDURE public.pro_heating_run_param(IN cur_time_in character varying) + LANGUAGE plpgsql +AS $procedure$ +DECLARE + -- 变量声明(保持原有结构,默认值优化) +cur_status_boiler_one numeric(24, 2) := 0 ; + temp_out_boiler_one numeric(24,2) :=0; + temp_in_boiler_one numeric(24,2) :=0; + temp_water_boiler_one numeric(24,2) := 0; + temp_flue_gas_boiler_one numeric(24,2) := 0; + cur_status_boiler_two numeric(24, 2) := 0 ; + temp_out_boiler_two numeric(24,2) :=0; + temp_in_boiler_two numeric(24,2) :=0; + temp_water_boiler_two numeric(24,2) := 0; + temp_flue_gas_boiler_two numeric(24,2) := 0; + cur_status_pump_one numeric(24,2) := 0; + frequency_pump_one numeric(24,2) := 0; + cur_status_pump_two numeric(24,2) := 0; + frequency_pump_two numeric(24,2) := 0; + cur_status_pump_three numeric(24,2) := 0; + frequency_pump_three numeric(24,2) := 0; + is_exits INT := 0; + register_address VARCHAR(50); +value NUMERIC(24,2); + mt_num varchar(20); + + -- 游标:简化为普通游标(无需 REF CURSOR) + base_param CURSOR FOR +SELECT + cra.mt_num::VARCHAR, + COALESCE(MAX(cra.cur_value), 0)::NUMERIC(24,2) +FROM + collection_params_manage cra +WHERE + cra.mt_num IS NOT NULL + and cra.system_type = '3' and cra.device_ledger_id != '0243b3a898d85f3a1205a2d8cainuan01' and cra.device_ledger_id != '0243b3a898d85f3a1205a2d8cainuan100' + and TO_CHAR(cra.cur_time, 'YYYY-MM-DD HH24') = cur_time_in +GROUP BY + cra.cur_time::DATE, + cra.mt_num; + +BEGIN + + -- ------------------------------ + -- 4. 遍历游标获取寄存器参数(严格关闭游标) + -- ------------------------------ +OPEN base_param; +BEGIN -- 游标操作的异常处理块 + LOOP +FETCH NEXT FROM base_param INTO register_address, value; + EXIT WHEN NOT FOUND; + RAISE NOTICE 'Processing: % = %', register_address, value; -- 调试信息 + -- 根据寄存器地址映射参数值 + -- 根据寄存器地址映射参数值 +CASE + WHEN register_address IN ('PLC1500_DB611704', 'PLC1500_DB611694') THEN + cur_status_boiler_one := CASE WHEN value > 0 THEN 1 ELSE 0 END; +WHEN register_address = 'PLC1500_DB611686' THEN temp_out_boiler_one := value; +WHEN register_address = 'PLC1500_DB611684' THEN temp_in_boiler_one := value; +WHEN register_address = 'PLC1500_DB611688' THEN temp_water_boiler_one := value; +WHEN register_address = 'PLC1500_DB611690' THEN temp_flue_gas_boiler_one := value; +WHEN register_address IN ('PLC1500_DB611692', 'PLC1500_DB611706') THEN + cur_status_boiler_two := CASE WHEN value > 0 THEN 1 ELSE 0 END; +WHEN register_address = 'PLC1500_DB611698' THEN temp_out_boiler_two := value; +WHEN register_address = 'PLC1500_DB611696' THEN temp_in_boiler_two := value; +WHEN register_address = 'PLC1500_DB611700' THEN temp_water_boiler_two := value; +WHEN register_address = 'PLC1500_DB611702' THEN temp_flue_gas_boiler_two := value; +WHEN register_address = 'DBX83624' THEN cur_status_pump_one := value; +WHEN register_address = 'DB612034' THEN frequency_pump_one := value; +WHEN register_address = 'DBX83620' THEN cur_status_pump_two := value; +WHEN register_address = 'DB612050' THEN frequency_pump_two := value; +WHEN register_address = 'DBX83630' THEN cur_status_pump_three := value; +WHEN register_address = 'DB612066' THEN frequency_pump_three := value; +ELSE +END CASE; +END LOOP; +EXCEPTION + WHEN OTHERS THEN + -- 游标异常时记录错误 + RAISE NOTICE '游标遍历失败(设备:蒸汽机): %', SQLERRM; +END; +CLOSE base_param; -- 确保游标最终关闭 +RAISE NOTICE '关闭游标'; + + -- ------------------------------ + -- 5. 插入历史数据(处理唯一约束冲突) + -- ------------------------------ +SELECT COUNT(1) INTO is_exits +FROM report_heating_run_param_his +WHERE cur_time = cur_time_in; + +IF is_exits = 0 THEN + INSERT INTO public.report_heating_run_param_his ( + id, + cur_date, + cur_time, + cur_status_boiler_one , + temp_out_boiler_one , + temp_in_boiler_one , + temp_water_boiler_one , + temp_flue_gas_boiler_one , + cur_status_boiler_two , + temp_out_boiler_two , + temp_in_boiler_two , + temp_water_boiler_two , + temp_flue_gas_boiler_two , + cur_status_pump_one , + frequency_pump_one , + cur_status_pump_two , + frequency_pump_two , + cur_status_pump_three , + frequency_pump_three + ) VALUES ( + REPLACE(uuid_generate_v1mc()::TEXT, '-', ''), + LEFT(cur_time_in, 10)::DATE, + cur_time_in, + cur_status_boiler_one , + temp_out_boiler_one , + temp_in_boiler_one , + temp_water_boiler_one , + temp_flue_gas_boiler_one , + cur_status_boiler_two , + temp_out_boiler_two , + temp_in_boiler_two , + temp_water_boiler_two , + temp_flue_gas_boiler_two , + cur_status_pump_one , + frequency_pump_one , + cur_status_pump_two , + frequency_pump_two , + cur_status_pump_three , + frequency_pump_three + ); +END IF; + +EXCEPTION + WHEN OTHERS THEN + -- 主事务异常时,记录错误 + RAISE NOTICE '存储过程执行失败(设备:采暖系统,时间:%): %', + cur_time_in, SQLERRM; +END; +$procedure$ +;