From 076ae2ec06b5d0e6f61e0f70ef61b8af120537ab Mon Sep 17 00:00:00 2001
From: ZhuDongming <773644075@qq.com>
Date: Thu, 02 Apr 2020 16:04:31 +0800
Subject: [PATCH] update实时跑任务判断1号取那张表
---
src/main/resources/mapper/HistoryMapper.xml | 42 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/src/main/resources/mapper/HistoryMapper.xml b/src/main/resources/mapper/HistoryMapper.xml
index d357d6b..823b530 100644
--- a/src/main/resources/mapper/HistoryMapper.xml
+++ b/src/main/resources/mapper/HistoryMapper.xml
@@ -99,6 +99,48 @@
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="getSensorDataByMacOnce" resultType="java.util.LinkedHashMap">
+ SELECT
+ h.mac,DATE_FORMAT(time,'%Y-%m-%dT%H:%i') time,
+ <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,DATE_FORMAT(time,'%Y-%m-%dT%H:%i')
+ </select>
+
<select id="getSensorDataOnce" resultType="java.util.LinkedHashMap">
SELECT
h.mac,DATE_FORMAT(time,'%Y-%m-%dT%H:%i') time,
--
Gitblit v1.8.0