add 统计能耗报表接口五种能源查询逻辑

maser
yinq 2 weeks ago
parent ad5e061b9a
commit 17c66730e1

@ -24,6 +24,26 @@ public interface EmsReportMapper
*/ */
List<EnergyStatisticalReport> energyStatisticalDnbReportList(Map hashMap); List<EnergyStatisticalReport> energyStatisticalDnbReportList(Map hashMap);
/**
*
*/
List<EnergyStatisticalReport> energyStatisticalWaterReportList(Map hashMap);
/**
*
*/
List<EnergyStatisticalReport> energyStatisticalSteamReportList(Map hashMap);
/**
*
*/
List<EnergyStatisticalReport> energyStatisticalAirReportList(Map hashMap);
/**
*
*/
List<EnergyStatisticalReport> energyStatisticalNitrogenReportList(Map hashMap);
/** /**
* *
* @param hashMap * @param hashMap

@ -47,16 +47,25 @@ public class EmsReportServiceImpl implements IEmsReportService {
*/ */
@Override @Override
public List<EnergyStatisticalReport> energyStatisticalReportList(Map hashMap) { public List<EnergyStatisticalReport> energyStatisticalReportList(Map hashMap) {
if (!hashMap.containsKey("dateType") && !hashMap.containsKey("energyType")) { if (hashMap == null || !hashMap.containsKey("dateType") || !hashMap.containsKey("energyType")) {
return null; return null;
} }
hashMap.put("timeSub", Integer.parseInt(String.valueOf(hashMap.get("dateType")))); hashMap.put("timeSub", Integer.parseInt(String.valueOf(hashMap.get("dateType"))));
List<EnergyStatisticalReport> reportList = new ArrayList<>(); String energyType = String.valueOf(hashMap.get("energyType"));
switch (energyType) {
if (Objects.equals(String.valueOf(hashMap.get("energyType")), "2")) { case "2":
reportList = emsReportMapper.energyStatisticalDnbReportList(hashMap); return emsReportMapper.energyStatisticalDnbReportList(hashMap);
case "3":
return emsReportMapper.energyStatisticalWaterReportList(hashMap);
case "4":
return emsReportMapper.energyStatisticalSteamReportList(hashMap);
case "5":
return emsReportMapper.energyStatisticalAirReportList(hashMap);
case "6":
return emsReportMapper.energyStatisticalNitrogenReportList(hashMap);
default:
return new ArrayList<>();
} }
return reportList;
} }
/** /**

@ -34,6 +34,122 @@
ORDER BY beginTime, workUnitCode ORDER BY beginTime, workUnitCode
</select> </select>
<select id="energyStatisticalWaterReportList" 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 * IIF(MWU.formula_mode = 0, 1, 0) * MWU.proportion) expend,
MAX(CAST(0 AS DECIMAL(18, 4))) powerExpend,
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_water 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 HH:mm:ss') between #{beginCollectTime} and #{endCollectTime}
</if>
<if test="workUnitCode != null and workUnitCode != ''">and WU.WORK_UNIT_CODE = #{workUnitCode}</if>
<if test="workUnitCodeList != null and workUnitCodeList.size > 0">
and WU.WORK_UNIT_CODE IN
<foreach item="workUnitCode" collection="workUnitCodeList" open="(" separator="," close=")">
#{workUnitCode}
</foreach>
</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>
<select id="energyStatisticalSteamReportList" 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 * IIF(MWU.formula_mode = 0, 1, 0) * MWU.proportion) expend,
MAX(CAST(0 AS DECIMAL(18, 4))) powerExpend,
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_steam 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 HH:mm:ss') between #{beginCollectTime} and #{endCollectTime}
</if>
<if test="workUnitCode != null and workUnitCode != ''">and WU.WORK_UNIT_CODE = #{workUnitCode}</if>
<if test="workUnitCodeList != null and workUnitCodeList.size > 0">
and WU.WORK_UNIT_CODE IN
<foreach item="workUnitCode" collection="workUnitCodeList" open="(" separator="," close=")">
#{workUnitCode}
</foreach>
</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>
<select id="energyStatisticalAirReportList" 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 * IIF(MWU.formula_mode = 0, 1, 0) * MWU.proportion) expend,
MAX(CAST(0 AS DECIMAL(18, 4))) powerExpend,
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_air 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 HH:mm:ss') between #{beginCollectTime} and #{endCollectTime}
</if>
<if test="workUnitCode != null and workUnitCode != ''">and WU.WORK_UNIT_CODE = #{workUnitCode}</if>
<if test="workUnitCodeList != null and workUnitCodeList.size > 0">
and WU.WORK_UNIT_CODE IN
<foreach item="workUnitCode" collection="workUnitCodeList" open="(" separator="," close=")">
#{workUnitCode}
</foreach>
</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>
<select id="energyStatisticalNitrogenReportList" 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 * IIF(MWU.formula_mode = 0, 1, 0) * MWU.proportion) expend,
MAX(CAST(0 AS DECIMAL(18, 4))) powerExpend,
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_nitrogen 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 HH:mm:ss') between #{beginCollectTime} and #{endCollectTime}
</if>
<if test="workUnitCode != null and workUnitCode != ''">and WU.WORK_UNIT_CODE = #{workUnitCode}</if>
<if test="workUnitCodeList != null and workUnitCodeList.size > 0">
and WU.WORK_UNIT_CODE IN
<foreach item="workUnitCode" collection="workUnitCodeList" open="(" separator="," close=")">
#{workUnitCode}
</foreach>
</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>
<select id="peaksValleysConsumptionReportList" <select id="peaksValleysConsumptionReportList"
resultType="com.os.ems.report.domain.PeaksValleysConsumptionReport" parameterType="java.util.HashMap"> resultType="com.os.ems.report.domain.PeaksValleysConsumptionReport" parameterType="java.util.HashMap">
SELECT ebwu.work_unit_code workUnitCode, ebwu.work_unit_name workUnitName, SELECT ebwu.work_unit_code workUnitCode, ebwu.work_unit_name workUnitName,

Loading…
Cancel
Save