平台修改意见20251120-统计报表-收益报表

This commit is contained in:
zq
2025-12-07 18:35:32 +08:00
parent fc5f56b3b0
commit 28dfb0c152
9 changed files with 435 additions and 34 deletions

View File

@ -1061,4 +1061,83 @@
and device_id = #{deviceId}
ORDER BY data_update_time DESC LIMIT 1
</select>
<select id="selectHourlyAmmeterData" resultType="com.xzzn.ems.domain.vo.AmmeterStatisListVo">
SELECT
DATE_FORMAT(dataTime, '%Y-%m-%d') dataTime,
DATE_FORMAT(dataTime, '%H:%i') as timePart,
(activeTotalKwhMax-activeTotalKwhMin) activeTotalKwh,
(reActiveTotalKwhMax-reActiveTotalKwhMin) reActiveTotalKwh
from (
SELECT
DATE_FORMAT(data_update_time, '%Y-%m-%d %H:00:00') as dataTime,
MAX(current_forward_active_total) as activeTotalKwhMax,
MIN(current_forward_active_total) as activeTotalKwhMin,
MAX(current_forward_reactive_total) as reActiveTotalKwhMax,
MIN(current_forward_reactive_total) as reActiveTotalKwhMin
FROM
ems_ammeter_data
where device_id = 'METE'
<if test="startTime != null">
AND data_update_time > #{startTime}
</if>
<if test="endTime != null">
AND data_update_time &lt;= #{endTime}
</if>
<if test="siteId != null and siteId != ''">
AND site_id = #{siteId}
</if>
GROUP BY
DATE_FORMAT(data_update_time, '%Y-%m-%d %H:00:00')
ORDER BY
dataTime
) temp
</select>
<select id="selectDailyAmmeterData" resultType="com.xzzn.ems.domain.vo.AmmeterStatisListVo">
SELECT
dataTime,
(activePeakKwhMax-activePeakKwhMin) as activePeakKwh,
(activeHighKwhMax-activeHighKwhMin) as activeHighKwh,
(activeFlatKwhMax-activeFlatKwhMin) as activeFlatKwh,
(activeValleyKwhMax-activeValleyKwhMin) as activeValleyKwh,
(reActivePeakKwhMax-reActivePeakKwhMin) as reActivePeakKwh,
(reActiveHignKwhMax-reActiveHignKwhMin) as reActiveHignKwh,
(reActiveFlatKwhMax-reActiveFlatKwhMin) as reActiveFlatKwh,
(reActiveValleyKwhMax-reActiveValleyKwhMin) as reActiveValleyKwh
FROM (
SELECT
DATE(data_update_time) as dataTime,
MAX(current_forward_active_peak) as activePeakKwhMax,
MIN(current_forward_active_peak) as activePeakKwhMin,
MAX(current_forward_active_high) as activeHighKwhMax,
MIN(current_forward_active_high) as activeHighKwhMin,
MAX(current_forward_active_flat) as activeFlatKwhMax,
MIN(current_forward_active_flat) as activeFlatKwhMin,
MAX(current_forward_active_valley) as activeValleyKwhMax,
MIN(current_forward_active_valley) as activeValleyKwhMin,
MAX(current_forward_reactive_peak) as reActivePeakKwhMax,
MIN(current_forward_reactive_peak) as reActivePeakKwhMin,
MAX(current_forward_reactive_high) as reActiveHignKwhMax,
MIN(current_forward_reactive_high) as reActiveHignKwhMin,
MAX(current_forward_reactive_flat) as reActiveFlatKwhMax,
MIN(current_forward_reactive_flat) as reActiveFlatKwhMin,
MAX(current_forward_reactive_valley) as reActiveValleyKwhMax,
MIN(current_forward_reactive_valley) as reActiveValleyKwhMin
FROM
ems_ammeter_data
WHERE device_id = 'METE'
<if test="startTime != null">
AND data_update_time > #{startTime}
</if>
<if test="endTime != null">
AND data_update_time &lt;= #{endTime}
</if>
<if test="siteId != null and siteId != ''">
AND site_id = #{siteId}
</if>
GROUP BY
DATE(data_update_time)
ORDER BY
dataTime
) temp
</select>
</mapper>

View File

@ -177,18 +177,41 @@
where t.`year` = #{currentYear}
and t.`month` = #{currentMonth}
</select>
<select id="getConfigListByTimeFrame" resultType="com.xzzn.ems.domain.EmsEnergyPriceConfig">
<include refid="selectEmsEnergyPriceConfigVo"/>
<select id="getConfigListByTimeFrame" resultType="com.xzzn.ems.domain.vo.EnergyPriceConfigVo">
select
epc.yearMonth as yearMonth,
epc.peak,
epc.high,
epc.flat,
epc.valley,
eptc.start_time as startTime,
eptc.end_time as endTime,
eptc.cost_type as costType
from
(
select
id, site_id, peak, high, flat, valley,
CONCAT(year, '-', LPAD(month, 2, '0')) as yearMonth,
STR_TO_DATE(CONCAT(year, '-', month, '-01'), '%Y-%m-%d') as dateTime
from ems_energy_price_config
where 1 = 1
<if test="siteId != null and siteId != ''">
and site_id = #{siteId}
</if>
order by year, month
) epc
left join ems_price_time_config eptc on eptc.price_id = epc.id
<where>
<if test="siteId != null and siteId != ''">
and site_id = #{siteId}
</if>
<if test="startTime != null and endTime != null">
and STR_TO_DATE(CONCAT(year, '-', month, '-01'), '%Y-%m-%d') between #{startTime} and #{endTime}
<if test="startDate != null and endDate != null">
(
(#{startDate} between dateTime and LAST_DAY(dateTime))
or
( #{endDate} between dateTime and LAST_DAY(dateTime))
or
(dateTime between #{startDate} and #{endDate})
)
</if>
</where>
order by
`year` asc,
`month` desc;
order by epc.yearMonth, eptc.start_time
</select>
</mapper>