71 lines
2.8 KiB
XML
71 lines
2.8 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<!DOCTYPE mapper
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
|
<mapper namespace="com.securitycontrol.screen.mapper.DeviceEnergyAnalysisMapper">
|
|
|
|
<select id="selectEnergyStatsByDateRange" resultType="com.securitycontrol.screen.domain.DeviceEnergyAnalysis">
|
|
SELECT stat_date AS statDate,
|
|
SUM(consumption_kwh) AS consumptionKwh,
|
|
SUM(renewable_used_kwh) AS renewableUsedKwh
|
|
FROM device_energy_analysis
|
|
WHERE stat_date BETWEEN #{startDate} AND #{endDate}
|
|
and pro_id =#{proId}
|
|
GROUP BY stat_date
|
|
ORDER BY stat_date ASC
|
|
</select>
|
|
|
|
<select id="selectDeviceEnergyByDateRange" resultType="com.securitycontrol.screen.domain.DeviceEnergyAnalysis">
|
|
SELECT device_name AS deviceName,
|
|
SUM(consumption_kwh) AS consumptionKwh
|
|
FROM device_energy_analysis
|
|
WHERE stat_date BETWEEN #{startDate} AND #{endDate}
|
|
and pro_id = #{proId}
|
|
GROUP BY device_name
|
|
ORDER BY consumptionKwh ASC
|
|
LIMIT 10
|
|
</select>
|
|
|
|
<select id="selectAnomalyByDateRange" resultType="com.securitycontrol.screen.domain.DeviceEnergyAnalysis">
|
|
SELECT id AS id,
|
|
device_name AS deviceName,
|
|
stat_date AS statDate,
|
|
consumption_kwh AS consumptionKwh,
|
|
renewable_used_kwh AS renewableUsedKwh,
|
|
anomaly_level AS anomalyLevel,
|
|
anomaly_desc AS anomalyDesc
|
|
FROM device_energy_analysis
|
|
WHERE anomaly_flag = 1
|
|
AND stat_date BETWEEN #{startDate} AND #{endDate}
|
|
and pro_id = #{proId}
|
|
ORDER BY
|
|
FIELD(anomaly_level, 'danger', 'warning', 'info') ASC,
|
|
stat_date ASC;
|
|
</select>
|
|
|
|
<select id="selectLatestAll" resultType="com.securitycontrol.screen.domain.EnergySavingMeasure">
|
|
SELECT esm.id AS id,
|
|
esm.measure_name AS measureName,
|
|
esm.coverage_rate AS coverageRate,
|
|
esm.stat_date AS statDate
|
|
FROM energy_saving_measures esm
|
|
INNER JOIN (SELECT measure_name,
|
|
MAX(stat_date) AS max_date,
|
|
pro_id
|
|
FROM energy_saving_measures
|
|
WHERE pro_id = #{proId}
|
|
AND stat_date BETWEEN #{startDate} AND #{endDate}
|
|
GROUP BY measure_name, pro_id) t ON esm.measure_name = t.measure_name
|
|
AND esm.stat_date = t.max_date
|
|
AND esm.pro_id = t.pro_id
|
|
WHERE esm.pro_id = #{proId}
|
|
AND esm.stat_date BETWEEN #{startDate} AND #{endDate};
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
</mapper>
|