单体电池添加入参site_id

This commit is contained in:
2025-06-30 22:22:47 +08:00
parent 93bd88b94c
commit 8663ab8325
7 changed files with 48 additions and 21 deletions

View File

@ -177,21 +177,22 @@
SELECT NULL AS type, NULL AS device_id FROM DUAL WHERE 1=0
</select>
<select id="getAllBatteryDataByClusterId" parameterType="String" resultType="com.xzzn.ems.domain.vo.BatteryDataStatsListVo">
SELECT
update_time as updateTime,
voltage, temperature, soc, soh,
device_id as deviceId
FROM (
SELECT
t.update_time, t.voltage, t.temperature, t.soc, t.soh, t.device_id,
ROW_NUMBER() OVER (
PARTITION BY t.device_id ORDER BY t.update_time DESC
) AS rn
FROM ems_battery_data t
WHERE t.cluster_device_id = #{clusterDeviceId}
) ranked
WHERE rn = 1
<select id="getAllBatteryDataByClusterId" resultType="com.xzzn.ems.domain.vo.BatteryDataStatsListVo">
SELECT t.update_time as updateTime, t.voltage, t.temperature,
t.soc, t.soh, t.device_id as deviceId
FROM ems_battery_data t
JOIN ( SELECT device_id, MAX(update_time) AS max_update_time
FROM ems_battery_data
WHERE site_id = #{siteId}
<if test="clusterDeviceId != null and clusterDeviceId != ''">
and cluster_device_id = #{clusterDeviceId}
</if>
GROUP BY device_id
) latest ON t.device_id = latest.device_id AND t.update_time = latest.max_update_time
WHERE t.site_id = #{siteId}
<if test="clusterDeviceId != null and clusterDeviceId != ''">
and t.cluster_device_id = #{clusterDeviceId}
</if>
</select>

View File

@ -371,4 +371,21 @@
WHERE tmp.site_id = #{siteId}
order by tmp.device_id
</select>
<select id="getPcsDataByDate" resultType="com.xzzn.ems.domain.vo.SiteMonitorDataVo">
select CONCAT(t.date_month,'/',t.date_day) as ammeterDate,
sum(t.daily_ac_charge_energy) as chargedCap,
sum(t.daily_ac_discharge_energy) as disChargedCap
from ( SELECT p.site_id, p.device_id,p.date_month,p.date_day, MAX(p.data_update_time) AS max_update_time
FROM ems_pcs_data p
where p.site_id = #{siteId}
GROUP BY p.site_id,p.device_id,p.date_month,p.date_day
) latest inner join ems_pcs_data t ON latest.site_id = t.site_id
AND latest.device_id = t.device_id
AND latest.max_update_time = t.data_update_time
and latest.date_month = t.date_month
and latest.date_day = t.date_day
group by ammeterDate
order by ammeterDate desc
</select>
</mapper>