51 lines
1.9 KiB
XML
51 lines
1.9 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>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
</mapper>
|