From 32983a583c99c190ecb4361d72b6f13cd06fefc7 Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Thu, 27 Aug 2020 10:22:57 +0800
Subject: [PATCH] 根据小时不同天气预测o3,光照

---
 src/main/resources/mapper/HistoryHourlyMapper.xml |   51 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/src/main/resources/mapper/HistoryHourlyMapper.xml b/src/main/resources/mapper/HistoryHourlyMapper.xml
index 0c12c40..cf4fc42 100644
--- a/src/main/resources/mapper/HistoryHourlyMapper.xml
+++ b/src/main/resources/mapper/HistoryHourlyMapper.xml
@@ -14,7 +14,7 @@
     <select id="getHourlySensorData" resultType="java.util.LinkedHashMap">
         SELECT
         h.mac,
-        <foreach  collection="sensorKeys" separator="," item="sensorKey">
+        <foreach collection="sensorKeys" separator="," item="sensorKey">
             AVG(json->'$.${sensorKey}[0]') AS '${sensorKey}',
             MIN(json->'$.${sensorKey}[1]') AS 'MIN${sensorKey}',
             MAX(json->'$.${sensorKey}[2]') AS 'MAX${sensorKey}'
@@ -24,7 +24,7 @@
         WHERE
         h.time >= #{start}
         AND h.time <![CDATA[<]]> #{end}
-        AND	h.mac in
+        AND h.mac in
         <foreach collection="macs" open="(" separator="," close=")"
                  item="mac">
             #{mac}
@@ -33,4 +33,51 @@
         h.mac
     </select>
 
+    <select id="getHourlySensorDataToCalculateO3" resultType="java.util.LinkedHashMap">
+        SELECT
+        h.mac,
+        <foreach collection="sensorKeys" separator="," item="sensorKey">
+            AVG(json->'$.${sensorKey}[0]') AS '${sensorKey}',
+            MIN(json->'$.${sensorKey}[1]') AS 'MIN${sensorKey}',
+            MAX(json->'$.${sensorKey}[2]') AS 'MAX${sensorKey}'
+        </foreach>
+        FROM
+        history_hourly h
+        WHERE
+        h.time = #{time}
+        AND h.mac in
+        <foreach collection="macList" open="(" separator="," close=")"
+                 item="mac">
+            #{mac}
+        </foreach>
+        group by
+        h.mac
+    </select>
+
+    <insert id="insertHistoryO3Hourly">
+        insert into
+        history_hourly_o3
+        values
+        <foreach collection="list" item="map" separator=",">
+            (#{map.mac},#{map.time},#{map.json})
+        </foreach>
+    </insert>
+
+    <select id="getBeamByMacs" resultType="java.util.Map">
+        SELECT
+        DATE_FORMAT(h.time,#{typeFormat}) time,
+        avg(h.json->'$.e12[0]') 'beam'
+        FROM history_hourly h
+        WHERE h.mac in
+        <foreach collection="macs" open="(" separator="," close=")" item="mac">
+            #{mac}
+        </foreach>
+        and h.time in
+        <foreach collection="times" open="(" separator="," close=")" item="time">
+            #{time}
+        </foreach>
+        and h.json->'$.e12[0]' is not null
+        group by h.time
+    </select>
+
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0