调整获取用电量计算逻辑

master
FCD 2 weeks ago
parent 55eeaa8beb
commit 8fc71ae240

@ -123,11 +123,19 @@
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 (
SELECT
rpd.meter_value,
rpd.monitor_id,
FORMAT ( rpd.record_time, 'yyyy-MM' ) AS month_tag,
ROW_NUMBER ( ) OVER ( PARTITION BY FORMAT ( rpd.record_time, 'yyyy-MM' ), rpd.monitor_id ORDER BY rpd.record_time ASC ) AS rn_asc,
ROW_NUMBER ( ) OVER ( PARTITION BY FORMAT ( rpd.record_time, 'yyyy-MM' ), rpd.monitor_id ORDER BY rpd.record_time DESC ) AS rn_desc
FROM report_point_dnb rpd
LEFT JOIN base_monitor_info m ON m.monitor_id = rpd.monitor_id
<where> <where>
<if test="publicShareType != null and publicShareType != ''">and m.public_share_type = #{publicShareType} <if test="publicShareType != null and publicShareType != ''">and m.public_share_type = #{publicShareType}
</if> </if>
@ -145,9 +153,10 @@
and left(CONVERT(VARCHAR(19), rpd.begin_time, 120), 10) between #{startDay} and #{endDay} and left(CONVERT(VARCHAR(19), rpd.begin_time, 120), 10) between #{startDay} and #{endDay}
</if> </if>
</where> </where>
) ert ) a
group by ert.pointTime WHERE rn_asc = 1 OR rn_desc = 1
order by ert.pointTime 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