From 1babbf1c0b2bc8d27f2874c85369e394b545594a Mon Sep 17 00:00:00 2001 From: ZhuDongming <773644075@qq.com> Date: Mon, 11 May 2020 11:24:00 +0800 Subject: [PATCH] add轨迹信息显示按秒级显示,update轨迹数据先从history表查询,update报表单位问题 --- src/main/resources/mapper/HistoryHourlyMapper.xml | 35 +++++++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-) diff --git a/src/main/resources/mapper/HistoryHourlyMapper.xml b/src/main/resources/mapper/HistoryHourlyMapper.xml index 599bac1..ba3c970 100644 --- a/src/main/resources/mapper/HistoryHourlyMapper.xml +++ b/src/main/resources/mapper/HistoryHourlyMapper.xml @@ -17,4 +17,39 @@ </if> </where> </select> + + <select id="getPollutionSourceDataByHour" resultType="java.util.Map"> + SELECT + DATE_FORMAT(time,'%Y-%m-%d %H') time, + <foreach collection="sensorKeys" separator="," item="sensorKey"> + AVG(h.value ->'$.${sensorKey}') AS '${sensorKey}' + </foreach> + FROM + <if test="mac!=null and time!=null"> + (select mac,value,time,version from history + where mac=#{mac} and time BETWEEN DATE_SUB(#{time}, INTERVAL 1 HOUR) and #{time}) h + </if> + GROUP BY + DATE_FORMAT(time,'%Y-%m-%d %H') + <if test="time!=null"> + having time=DATE_FORMAT(DATE_SUB(#{time}, INTERVAL 1 HOUR),'%Y-%m-%d %H') + </if> + </select> + + <select id="getPollutionSourceDataAll" resultType="java.util.Map"> + SELECT + DATE_FORMAT(time,'%Y-%m-%d %H') time, + <foreach collection="sensorKeys" separator="," item="sensorKey"> + AVG(h.value ->'$.${sensorKey}') AS '${sensorKey}' + </foreach> + FROM + <if test="mac!=null"> + (select mac,value,time,version from history + where mac=#{mac} and time BETWEEN DATE_SUB(#{time}, INTERVAL 1 DAY) and #{time}) h + </if> + GROUP BY + DATE_FORMAT(time,'%Y-%m-%d %H') + order by time desc + limit 0,1 + </select> </mapper> \ No newline at end of file -- Gitblit v1.8.0