11 changed files with 835 additions and 41 deletions
@ -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<ReportHeatingRunParamHis> 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<ReportHeatingRunParamHis> 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<ReportHeatingRunParamDTO> 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("下载报表异常"); |
||||
} |
||||
} |
||||
|
||||
} |
||||
Binary file not shown.
@ -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; |
||||
|
||||
} |
||||
@ -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<String, Object> 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(); |
||||
} |
||||
} |
||||
@ -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<ReportHeatingRunParamHis> { |
||||
|
||||
@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<ReportHotWaterParamHis> findPage(@Param("beginDate") String beginDate, |
||||
@Param("endDate") String endDate); |
||||
} |
||||
@ -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<ReportHeatingRunParamHis> selectHeatingList(ReportHeatingRunParamHis reportHeatingRunParamHis); |
||||
|
||||
int updateRunParams(ReportHeatingRunParamHis reportHeatingRunParamHis); |
||||
} |
||||
@ -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<ReportHeatingRunParamHis> 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<ReportHeatingRunParamHis> queryWrapper = new QueryWrapper<>(); |
||||
queryWrapper.between("cur_time", startTime, endTime); |
||||
queryWrapper.orderByDesc("cur_time"); |
||||
List<ReportHeatingRunParamHis> 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; |
||||
} |
||||
} |
||||
@ -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$ |
||||
; |
||||
Loading…
Reference in new issue