feat(property): 添加用电/水/气趋势分析功能
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?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="org.dromara.property.mapper.smartDevicesMapper.TbMeterRecordMapper">
|
||||
<select id="getHourTrend" resultType="map">
|
||||
SELECT CONCAT_WS(':', HOUR(reading_time), '00') as hour, SUM(consumption) as total_consumption
|
||||
FROM tb_meter_record a
|
||||
LEFT JOIN tb_meter_info b ON a.meter_id = b.id
|
||||
WHERE DATE(reading_time) = #{day}
|
||||
AND b.meter_type = #{meterType}
|
||||
<if test="floorId != '' and floorId != null">
|
||||
AND b.floor_id = #{floorId}
|
||||
</if>
|
||||
<if test="meterId != '' and meterId != null">
|
||||
AND a.meter_id = #{meterId}
|
||||
</if>
|
||||
GROUP BY CONCAT_WS(':', HOUR(reading_time), '00')
|
||||
ORDER BY hour
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getDayTrend" resultType="map">
|
||||
SELECT
|
||||
DAY(reading_time) AS `day`,
|
||||
SUM(consumption) AS total_consumption
|
||||
FROM tb_meter_record a
|
||||
LEFT JOIN tb_meter_info b ON a.meter_id = b.id
|
||||
WHERE YEAR(reading_time) = #{year}
|
||||
AND MONTH(reading_time) = #{month}
|
||||
AND b.meter_type = #{meterType}
|
||||
<if test="floorId != '' and floorId != null">
|
||||
AND b.floor_id = #{floorId}
|
||||
</if>
|
||||
<if test="meterId != '' and meterId != null">
|
||||
AND a.meter_id = #{meterId}
|
||||
</if>
|
||||
GROUP BY DAY(reading_time)
|
||||
ORDER BY `day`;
|
||||
</select>
|
||||
|
||||
<select id="getMonthTrend" resultType="map">
|
||||
SELECT
|
||||
MONTH(reading_time) AS `month`,
|
||||
SUM(consumption) AS total_consumption
|
||||
FROM tb_meter_record a
|
||||
LEFT JOIN tb_meter_info b ON a.meter_id = b.id
|
||||
WHERE YEAR(reading_time) = #{year}
|
||||
AND b.meter_type = #{meterType}
|
||||
<if test="floorId != '' and floorId != null">
|
||||
AND b.floor_id = #{floorId}
|
||||
</if>
|
||||
<if test="meterId != '' and meterId != null">
|
||||
AND a.meter_id = #{meterId}
|
||||
</if>
|
||||
GROUP BY MONTH(reading_time)
|
||||
ORDER BY `month`;
|
||||
</select>
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user