优化
This commit is contained in:
@ -205,14 +205,15 @@
|
||||
</delete>
|
||||
|
||||
<select id="getPcsBranchInfoList" resultType="com.xzzn.ems.domain.vo.PcsBranchInfo">
|
||||
select tmp.branch_id as branchId, tmp.discharge_status as dischargeStatus,
|
||||
SELECT tmp.branch_id as branchId, tmp.discharge_status as dischargeStatus,
|
||||
tmp.dc_power as dcPower, tmp.dc_voltage as dcVoltage,
|
||||
tmp.dc_current as dcCurrent, tmp.site_id as siteId, tmp.device_id as deviceId
|
||||
from ems_pcs_branch_data tmp
|
||||
where tmp.site_id = #{siteId}
|
||||
and tmp.device_id = #{deviceId}
|
||||
and tmp.update_time = (select MAX(t.update_time) FROM ems_pcs_branch_data t where t.site_id = tmp.site_id
|
||||
and t.device_id = tmp.device_id and t.branch_id = tmp.branch_id)
|
||||
order by tmp.branch_id
|
||||
FROM (
|
||||
SELECT t.*, ROW_NUMBER() OVER ( PARTITION BY t.branch_id ORDER BY t.update_time DESC ) AS rn
|
||||
FROM ems_pcs_branch_data t
|
||||
WHERE t.site_id = #{siteId} AND t.device_id = #{deviceId}
|
||||
) tmp
|
||||
WHERE rn = 1
|
||||
ORDER BY tmp.branch_id;
|
||||
</select>
|
||||
</mapper>
|
Reference in New Issue
Block a user