change - add日月年能耗统计报表
parent
76953a968b
commit
26a50f50f4
@ -0,0 +1,55 @@
|
||||
package com.os.ems.report.controller;
|
||||
|
||||
import com.os.common.annotation.Log;
|
||||
import com.os.common.core.controller.BaseController;
|
||||
import com.os.common.core.domain.AjaxResult;
|
||||
import com.os.common.core.page.TableDataInfo;
|
||||
import com.os.common.enums.BusinessType;
|
||||
import com.os.common.utils.poi.ExcelUtil;
|
||||
import com.os.ems.report.domain.EnergyStatisticalReport;
|
||||
import com.os.ems.report.service.IEmsReportPointDnbService;
|
||||
import com.os.ems.report.service.IEmsReportService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* import java.util.List;Controller
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2024-05-22
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ems/report")
|
||||
public class EmsReportController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IEmsReportService emsReportService;
|
||||
|
||||
/**
|
||||
* 统计能耗报表
|
||||
* @param hashMap
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/energyStatisticalReportList")
|
||||
public TableDataInfo energyStatisticalReportList(@RequestParam(required = false) Map hashMap) {
|
||||
startPage();
|
||||
List<EnergyStatisticalReport> list = emsReportService.energyStatisticalReportList(hashMap);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出统计能耗报表
|
||||
*/
|
||||
@PostMapping("/energyStatisticalReportList/export" )
|
||||
public void export(HttpServletResponse response, @RequestParam(required = false) Map hashMap) {
|
||||
List<EnergyStatisticalReport> list = emsReportService.energyStatisticalReportList(hashMap);
|
||||
ExcelUtil<EnergyStatisticalReport> util = new ExcelUtil<>(EnergyStatisticalReport. class);
|
||||
util.exportExcel(response, list, "统计能耗报表" );
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package com.os.ems.report.domain;
|
||||
|
||||
|
||||
import com.os.common.annotation.Excel;
|
||||
import com.os.common.core.domain.BaseEntity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
/**
|
||||
* 统计能耗报表
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2023-10-12
|
||||
*/
|
||||
public class EnergyStatisticalReport extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 统计单元编号
|
||||
*/
|
||||
@Excel(name = "统计单元编号")
|
||||
private String workUnitCode;
|
||||
|
||||
/**
|
||||
* 统计单元名称
|
||||
*/
|
||||
@Excel(name = "统计单元名称")
|
||||
private String workUnitName;
|
||||
|
||||
/**
|
||||
* 耗量(kwh)
|
||||
*/
|
||||
@Excel(name = "耗量(kwh)")
|
||||
private BigDecimal expend;
|
||||
|
||||
/**
|
||||
* 开始日期
|
||||
*/
|
||||
@Excel(name = "开始日期")
|
||||
private String beginTime;
|
||||
|
||||
/**
|
||||
* 结束日期
|
||||
*/
|
||||
@Excel(name = "结束日期")
|
||||
private String endTime;
|
||||
|
||||
/**
|
||||
* 仪表值(kwh)
|
||||
*/
|
||||
@Excel(name = "仪表值(kwh)")
|
||||
private BigDecimal instrumentValue;
|
||||
|
||||
public String getWorkUnitCode() {
|
||||
return workUnitCode;
|
||||
}
|
||||
|
||||
public void setWorkUnitCode(String workUnitCode) {
|
||||
this.workUnitCode = workUnitCode;
|
||||
}
|
||||
|
||||
public String getWorkUnitName() {
|
||||
return workUnitName;
|
||||
}
|
||||
|
||||
public void setWorkUnitName(String workUnitName) {
|
||||
this.workUnitName = workUnitName;
|
||||
}
|
||||
|
||||
public BigDecimal getInstrumentValue() {
|
||||
return instrumentValue;
|
||||
}
|
||||
|
||||
public void setInstrumentValue(BigDecimal instrumentValue) {
|
||||
this.instrumentValue = instrumentValue;
|
||||
}
|
||||
|
||||
public BigDecimal getExpend() {
|
||||
return expend;
|
||||
}
|
||||
|
||||
public void setExpend(BigDecimal expend) {
|
||||
this.expend = expend;
|
||||
}
|
||||
|
||||
public String getBeginTime() {
|
||||
return beginTime;
|
||||
}
|
||||
|
||||
public void setBeginTime(String beginTime) {
|
||||
this.beginTime = beginTime;
|
||||
}
|
||||
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(String endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EnergyStatisticalReport{" +
|
||||
"workUnitCode='" + workUnitCode + '\'' +
|
||||
", workUnitName='" + workUnitName + '\'' +
|
||||
", instrumentValue=" + instrumentValue +
|
||||
", expend=" + expend +
|
||||
", beginTime='" + beginTime + '\'' +
|
||||
", endTime='" + endTime + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.os.ems.report.mapper;
|
||||
|
||||
|
||||
import com.os.ems.report.domain.EnergyStatisticalReport;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 能源报表Mapper接口
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2024-05-22
|
||||
*/
|
||||
public interface EmsReportMapper
|
||||
{
|
||||
|
||||
/**
|
||||
* 统计能耗报表
|
||||
* @param hashMap
|
||||
* @return
|
||||
*/
|
||||
List<EnergyStatisticalReport> energyStatisticalReportList(Map hashMap);
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.os.ems.report.service;
|
||||
|
||||
|
||||
import com.os.ems.report.domain.EnergyStatisticalReport;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 能源报表Service接口
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2024-05-22
|
||||
*/
|
||||
public interface IEmsReportService {
|
||||
|
||||
/**
|
||||
* 统计能耗报表
|
||||
* @param hashMap
|
||||
* @return
|
||||
*/
|
||||
List<EnergyStatisticalReport> energyStatisticalReportList(Map hashMap);
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.os.ems.report.service.impl;
|
||||
|
||||
import com.os.ems.report.domain.EnergyStatisticalReport;
|
||||
import com.os.ems.report.mapper.EmsReportMapper;
|
||||
import com.os.ems.report.service.IEmsReportService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 能源报表Service业务层处理
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2024-05-22
|
||||
*/
|
||||
@Service
|
||||
public class EmsReportServiceImpl implements IEmsReportService {
|
||||
@Autowired
|
||||
private EmsReportMapper emsReportMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 统计能耗报表
|
||||
* @param hashMap
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<EnergyStatisticalReport> energyStatisticalReportList(Map hashMap) {
|
||||
if (!hashMap.containsKey("dateType")){
|
||||
return null;
|
||||
}
|
||||
hashMap.put("timeSub", Integer.parseInt(String.valueOf(hashMap.get("dateType"))));
|
||||
return emsReportMapper.energyStatisticalReportList(hashMap);
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.os.ems.report.mapper.EmsReportMapper">
|
||||
|
||||
|
||||
<select id="energyStatisticalReportList" resultType="com.os.ems.report.domain.EnergyStatisticalReport"
|
||||
parameterType="java.util.HashMap">
|
||||
WITH DT AS (SELECT CAST(#{timeSub} AS INT) TIMESUB)
|
||||
SELECT WU.WORK_UNIT_CODE workUnitCode,
|
||||
WU.WORK_UNIT_NAME workUnitName,
|
||||
MAX(RPD.INSTRUMENT_VALUE) instrumentValue,
|
||||
SUM(RPD.EXPEND) expend,
|
||||
SUBSTRING(FORMAT(RPD.BEGIN_TIME, 'yyyy-MM-dd HH:mm:ss'), 1, DT.TIMESUB) beginTime,
|
||||
SUBSTRING(FORMAT(RPD.BEGIN_TIME, 'yyyy-MM-dd HH:mm:ss'), 1, DT.TIMESUB) endTime
|
||||
FROM ems_base_work_unit WU
|
||||
LEFT JOIN ems_base_monitor_work_unit MWU ON MWU.WORK_UNIT_CODE = WU.WORK_UNIT_CODE
|
||||
LEFT JOIN ems_report_point_dnb RPD ON RPD.MONITOR_CODE = MWU.MONITOR_CODE
|
||||
CROSS JOIN DT
|
||||
WHERE RPD.EXPEND IS NOT NULL
|
||||
<if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != ''">
|
||||
and FORMAT(RPD.BEGIN_TIME, 'yyyy-MM-dd') between #{beginCollectTime} and #{endCollectTime}
|
||||
</if>
|
||||
<if test="workUnitCode != null and workUnitCode != ''">and WU.WORK_UNIT_CODE = #{workUnitCode}</if>
|
||||
GROUP BY WU.WORK_UNIT_CODE, WU.WORK_UNIT_NAME, SUBSTRING(FORMAT(RPD.BEGIN_TIME, 'yyyy-MM-dd HH:mm:ss'), 1, DT.TIMESUB)
|
||||
ORDER BY beginTime, workUnitCode
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue