调整获取用电量计算逻辑

master
FCD 2 weeks ago
parent 55eeaa8beb
commit 8fc71ae240

@ -123,31 +123,40 @@
where report_point_dnb.objid = #{objid} where report_point_dnb.objid = #{objid}
</select> </select>
<select id="energyConsumptionReportByTime" resultType="java.util.Map"> <select id="energyConsumptionReportByTime" resultType="java.util.Map">
select ert.pointTime, sum(isnull(ert.expend,0)) expend SELECT
from ( month_tag AS pointTime,
select left(CONVERT(VARCHAR(19), rpd.begin_time, 120), #{timeSub}) pointTime, rpd.expend MAX(meter_value) - MIN(meter_value) expend
from report_point_dnb rpd FROM
left join base_monitor_info m on m.monitor_id = rpd.monitor_id (
<where> SELECT
<if test="publicShareType != null and publicShareType != ''">and m.public_share_type = #{publicShareType} rpd.meter_value,
</if> rpd.monitor_id,
<if test="monitorIdList != null and monitorIdList.size > 0"> FORMAT ( rpd.record_time, 'yyyy-MM' ) AS month_tag,
and rpd.monitor_id IN ROW_NUMBER ( ) OVER ( PARTITION BY FORMAT ( rpd.record_time, 'yyyy-MM' ), rpd.monitor_id ORDER BY rpd.record_time ASC ) AS rn_asc,
<foreach item="monitorId" collection="monitorIdList" open="(" separator="," close=")"> ROW_NUMBER ( ) OVER ( PARTITION BY FORMAT ( rpd.record_time, 'yyyy-MM' ), rpd.monitor_id ORDER BY rpd.record_time DESC ) AS rn_desc
#{monitorId} FROM report_point_dnb rpd
</foreach> LEFT JOIN base_monitor_info m ON m.monitor_id = rpd.monitor_id
</if> <where>
<if test="monitorId != null and monitorId != ''">and rpd.monitor_id = #{monitorId}</if> <if test="publicShareType != null and publicShareType != ''">and m.public_share_type = #{publicShareType}
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''"> </if>
and rpd.begin_time between #{startTime} and #{endTime} <if test="monitorIdList != null and monitorIdList.size > 0">
</if> and rpd.monitor_id IN
<if test="startDay != null and startDay != '' and endDay != null and endDay != ''"> <foreach item="monitorId" collection="monitorIdList" open="(" separator="," close=")">
and left(CONVERT(VARCHAR(19), rpd.begin_time, 120), 10) between #{startDay} and #{endDay} #{monitorId}
</if> </foreach>
</where> </if>
) ert <if test="monitorId != null and monitorId != ''">and rpd.monitor_id = #{monitorId}</if>
group by ert.pointTime <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
order by ert.pointTime and rpd.begin_time between #{startTime} and #{endTime}
</if>
<if test="startDay != null and startDay != '' and endDay != null and endDay != ''">
and left(CONVERT(VARCHAR(19), rpd.begin_time, 120), 10) between #{startDay} and #{endDay}
</if>
</where>
) a
WHERE rn_asc = 1 OR rn_desc = 1
GROUP BY month_tag
ORDER BY month_tag DESC
</select> </select>
<select id="energyConsumptionAnalysisDetails" resultType="java.util.Map"> <select id="energyConsumptionAnalysisDetails" resultType="java.util.Map">

Loading…
Cancel
Save