From 991e6e3da063c07c47f1cb951bc08a22fda588ed Mon Sep 17 00:00:00 2001 From: lizijie <lzjiiie@163.com> Date: Thu, 29 Aug 2019 09:55:32 +0800 Subject: [PATCH] 站点排名 --- src/main/resources/mapper/HistoryMapper.xml | 45 +++------------------------------------------ 1 files changed, 3 insertions(+), 42 deletions(-) diff --git a/src/main/resources/mapper/HistoryMapper.xml b/src/main/resources/mapper/HistoryMapper.xml index dba7c1e..7aec033 100644 --- a/src/main/resources/mapper/HistoryMapper.xml +++ b/src/main/resources/mapper/HistoryMapper.xml @@ -175,7 +175,9 @@ SELECT DATE_FORMAT(time,'%Y-%m-%d %H:%i') time, <foreach collection="sensorKeys" separator="," item="sensorKey"> - AVG(h.value ->'$.${sensorKey}') AS '${sensorKey}' + AVG(h.value ->'$.${sensorKey}') AS '${sensorKey}', + MIN(cast(h.value ->'$.${sensorKey}' as decimal(11,5))) AS 'min${sensorKey}', + MAX(cast(h.value ->'$.${sensorKey}' as decimal(11,5))) AS 'max${sensorKey}' </foreach> FROM history h @@ -192,45 +194,4 @@ time </select> - <select id="getSensorDataTodayMin" resultType="java.util.LinkedHashMap"> - SELECT - DATE_FORMAT(time,'%Y-%m-%d %H:%i') time, - <foreach collection="sensorKeys" separator="," item="sensorKey"> - MIN(h.value ->'$.${sensorKey}') AS '${sensorKey}' - </foreach> - FROM - history h - <where> - <if test="mac!=null"> - and h.mac=#{mac} - </if> - and h.time >= #{startTime} - and h.time <![CDATA[<=]]> #{endTime} - </where> - GROUP BY - DATE_FORMAT(time,'%Y-%m-%d %H:%i') - ORDER BY - time - </select> - - <select id="getSensorDataTodayMax" resultType="java.util.LinkedHashMap"> - SELECT - DATE_FORMAT(time,'%Y-%m-%d %H:%i') time, - <foreach collection="sensorKeys" separator="," item="sensorKey"> - MAX(h.value ->'$.${sensorKey}') AS '${sensorKey}' - </foreach> - FROM - history h - <where> - <if test="mac!=null"> - and h.mac=#{mac} - </if> - and h.time >= #{startTime} - and h.time <![CDATA[<=]]> #{endTime} - </where> - GROUP BY - DATE_FORMAT(time,'%Y-%m-%d %H:%i') - ORDER BY - time - </select> </mapper> \ No newline at end of file -- Gitblit v1.8.0