From ed3870b7841c630f98fd35faadf72a3992585663 Mon Sep 17 00:00:00 2001
From: lizijie <lzjiiie@163.com>
Date: Thu, 31 Dec 2020 17:19:31 +0800
Subject: [PATCH] 程序离线报警

---
 src/main/resources/mapper/AQIMapper.xml |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/src/main/resources/mapper/AQIMapper.xml b/src/main/resources/mapper/AQIMapper.xml
index 766dd54..34beeb3 100644
--- a/src/main/resources/mapper/AQIMapper.xml
+++ b/src/main/resources/mapper/AQIMapper.xml
@@ -6,10 +6,43 @@
     </select>
 
     <insert id="insertAQIData">
-        INSERT INTO hangzhou_aqi (time, aqi_json,city_code)  values(
+        INSERT INTO hangzhou_aqi (`time`, aqi_json,city_code)  values(
         #{time},
         #{data},
         #{code}
         )
     </insert>
+
+    <select id="getO3" resultType="java.util.Map">
+        select DATE_FORMAT(time, #{typeFormat}) time,
+        ifnull(aqi_json->'$.O3C',aqi_json->'$.O3') 'O3'
+        from hangzhou_aqi
+        where city_code=#{cityCode}
+        and DATE_FORMAT(time, #{typeFormat}) in
+        <foreach collection="times" open="(" separator="," close=")" item="time">
+            #{time}
+        </foreach>
+    </select>
+
+    <select id="getAqiFromHangzhou" resultType="java.lang.String">
+        select ifnull(aqi_json->'$.${sensorKey}',aqi_json->'$.${sensorKey1}') as '${sensorKey}'
+        from hangzhou_aqi
+        where city_code=#{cityCode}
+        and DATE_FORMAT(time, #{typeFormat})=#{time}
+    </select>
+
+    <select id="getAqiByHour" resultType="java.util.Map">
+        select DATE_FORMAT(time, '%Y-%m-%d %H:%i:%s') time,
+        value
+        from history_aqi_${timeUnits}
+        where city_code=#{cityCode}
+        and DATE_FORMAT(time, '%Y%H')=#{yearAndHour}
+    </select>
+
+    <select id="getAqiFromHistory" resultType="java.lang.String">
+        select value ->'$.${sensorKey}' as '${sensorKey}'
+        from history_aqi_${timeUnits}
+        where city_code=#{cityCode}
+        and DATE_FORMAT(time, #{typeFormat})=#{time}
+    </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0