电表逻辑修改

This commit is contained in:
2025-06-30 18:14:24 +08:00
parent 337599d1c6
commit fbab6ea631
7 changed files with 45 additions and 25 deletions

View File

@ -114,23 +114,23 @@
</foreach>
</delete>
<select id="getAmmeterDetailInfo" parameterType="String" resultType="com.xzzn.ems.domain.vo.AmmeterDataDetailInfo">
<select id="getAmmeterDetailInfo" resultType="com.xzzn.ems.domain.vo.AmmeterDataDetailInfo">
SELECT t.category as category,
t.total_kwh as totalKwh,
t.sharp_kwh as sharpKwh,
t.flat_kwh as flatKwh,
t.peak_kwh as peakKwh,
t.valley_kwh as valleyKwh,
t.device_id as deviceId,
t.valley_kwh as valleyKwh,
Max(t.data_update_time) as updateTime
FROM ems_ammeter_data t
INNER JOIN (
SELECT p.site_id, p.device_id,p.category,MAX(p.data_update_time) AS max_update_time
FROM ems_ammeter_data p
WHERE p.site_id = #{siteId}
WHERE p.site_id = #{siteId} and p.device_id = #{deviceId}
GROUP BY p.site_id,p.device_id,p.category
) latest on t.device_id = latest.device_id and t.data_update_time = latest.max_update_time
WHERE t.site_id = #{siteId}
WHERE t.site_id = #{siteId} and t.device_id = #{deviceId}
group by t.category,t.total_kwh,t.sharp_kwh,t.flat_kwh,t.peak_kwh,t.valley_kwh,t.device_id
order by updateTime desc
</select>