This commit is contained in:
2026-02-22 18:59:40 +08:00
parent 4e7d387edf
commit 5ab2cb8f90
30 changed files with 1712 additions and 2588 deletions

View File

@ -236,26 +236,40 @@
<select id="getRevenueDataBySiteId" resultType="com.xzzn.ems.domain.vo.AmmeterRevenueStatisListVo">
select
t.data_date as dataTime,
ROUND(t.peak_charge_diff * pc.peak, 3) as activePeakPrice,
ROUND(t.peak_discharge_diff * pc.peak, 3) as reActivePeakPrice,
ROUND(t.high_charge_diff * pc.high, 3) as activeHighPrice,
ROUND(t.high_discharge_diff * pc.high, 3) as reActiveHighPrice,
ROUND(t.flat_charge_diff * pc.flat, 3) as activeFlatPrice,
ROUND(t.flat_discharge_diff * pc.flat, 3) as reActiveFlatPrice,
ROUND(t.valley_charge_diff * pc.valley, 3) as activeValleyPrice,
ROUND(t.valley_discharge_diff * pc.valley, 3) as reActiveValleyPrice
COALESCE(c.is_workday, CASE WHEN WEEKDAY(t.data_date) &lt; 5 THEN 1 ELSE 0 END) as isWorkday,
CASE
WHEN COALESCE(c.is_workday, CASE WHEN WEEKDAY(t.data_date) &lt; 5 THEN 1 ELSE 0 END) = 1 THEN '工作日'
ELSE '节假日'
END as dayType,
COALESCE(NULLIF(TRIM(w.weather_desc), ''), '--') as weatherDesc,
ROUND(IFNULL(t.peak_charge_diff, 0) * IFNULL(pc.peak, 0), 3) as activePeakPrice,
ROUND(IFNULL(t.peak_discharge_diff, 0) * IFNULL(pc.peak, 0), 3) as reActivePeakPrice,
ROUND(IFNULL(t.high_charge_diff, 0) * IFNULL(pc.high, 0), 3) as activeHighPrice,
ROUND(IFNULL(t.high_discharge_diff, 0) * IFNULL(pc.high, 0), 3) as reActiveHighPrice,
ROUND(IFNULL(t.flat_charge_diff, 0) * IFNULL(pc.flat, 0), 3) as activeFlatPrice,
ROUND(IFNULL(t.flat_discharge_diff, 0) * IFNULL(pc.flat, 0), 3) as reActiveFlatPrice,
ROUND(IFNULL(t.valley_charge_diff, 0) * IFNULL(pc.valley, 0), 3) as activeValleyPrice,
ROUND(IFNULL(t.valley_discharge_diff, 0) * IFNULL(pc.valley, 0), 3) as reActiveValleyPrice
from ems_daily_energy_data t
left join (
select
id, site_id, peak, high, flat, valley,
CONCAT(year, '-', LPAD(month, 2, '0')) as yearMonth
from ems_energy_price_config
where 1=1
<if test="siteId != null">
and site_id = #{siteId}
</if>
order by year, month
) pc on pc.yearMonth = DATE_FORMAT(t.data_date, '%Y-%m')
left join ems_calendar_day c on c.calendar_date = t.data_date
left join ems_site_weather_day w on w.site_id = t.site_id and w.calendar_date = t.data_date
left join ems_energy_price_config pc on pc.id = COALESCE(
(
select p.id
from ems_energy_price_config p
where p.site_id = t.site_id
and STR_TO_DATE(CONCAT(p.year, '-', LPAD(p.month, 2, '0'), '-01'), '%Y-%m-%d') &lt;= DATE_FORMAT(t.data_date, '%Y-%m-01')
order by STR_TO_DATE(CONCAT(p.year, '-', LPAD(p.month, 2, '0'), '-01'), '%Y-%m-%d') desc
limit 1
),
(
select p2.id
from ems_energy_price_config p2
where p2.site_id = t.site_id
order by STR_TO_DATE(CONCAT(p2.year, '-', LPAD(p2.month, 2, '0'), '-01'), '%Y-%m-%d') asc
limit 1
)
)
where 1=1
<if test="siteId != null">
and t.site_id = #{siteId}
@ -266,6 +280,7 @@
<if test="endTime != null">
and t.data_date &lt;= #{endTime}
</if>
order by t.data_date desc
</select>
</mapper>
</mapper>