From 97228942b08eae44ffb9388921e5fdf568f6a4ee Mon Sep 17 00:00:00 2001 From: ZhuDongming <773644075@qq.com> Date: Tue, 31 Mar 2020 08:32:21 +0800 Subject: [PATCH] update --- src/main/resources/mapper/HistoryMapper.xml | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/src/main/resources/mapper/HistoryMapper.xml b/src/main/resources/mapper/HistoryMapper.xml index d357d6b..4e677f0 100644 --- a/src/main/resources/mapper/HistoryMapper.xml +++ b/src/main/resources/mapper/HistoryMapper.xml @@ -99,6 +99,27 @@ h.mac </select> + <select id="getSensorDataByMac" resultType="java.util.LinkedHashMap"> + SELECT + h.mac, + <foreach collection="sensorKeys" separator="," item="sensorKey"> + AVG(value->'$.${sensorKey}') AS '${sensorKey}', + MAX(cast(h.value ->'$.${sensorKey}' as decimal(11,3))) AS 'MAX${sensorKey}', + MIN(cast(h.value ->'$.${sensorKey}' as decimal(11,3))) AS 'MIN${sensorKey}' + </foreach> + FROM + history h + WHERE + h.time >= #{start} + AND h.time <![CDATA[<]]> #{end} + and h.mac in + <foreach collection="macList" index="index" item="mac" open="(" separator="," close=")"> + #{mac} + </foreach> + group by + h.mac + </select> + <select id="getSensorDataOnce" resultType="java.util.LinkedHashMap"> SELECT h.mac,DATE_FORMAT(time,'%Y-%m-%dT%H:%i') time, -- Gitblit v1.8.0