From d6cb70708e6bb9e18cbc2fbc0034f3dd998fcd38 Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Tue, 15 Sep 2020 14:49:07 +0800
Subject: [PATCH] 获取城市天气,aqi更新

---
 src/main/resources/mapper/HangzhouAqiMapper.xml |   48 +++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 43 insertions(+), 5 deletions(-)

diff --git a/src/main/resources/mapper/HangzhouAqiMapper.xml b/src/main/resources/mapper/HangzhouAqiMapper.xml
index 20a903a..b2299e7 100644
--- a/src/main/resources/mapper/HangzhouAqiMapper.xml
+++ b/src/main/resources/mapper/HangzhouAqiMapper.xml
@@ -73,11 +73,25 @@
         DATE_FORMAT(time, #{typeFormat}) time,
         ifnull(aqi_json->'$.O3C',aqi_json->'$.O3') as 'O3'
         FROM
-        hangzhou_aqi ha
+        hangzhou_aqi
         WHERE
-        ha.time >= #{start}
-        AND ha.time <![CDATA[<]]> #{end}
-        AND ha.city_code = #{cityCode}
+        time >= #{start}
+        AND time <![CDATA[<]]> #{end}
+        AND city_code = #{cityCode}
+        ORDER BY
+        time
+  </select>
+
+    <select id="getHistoryO3" resultType="java.util.Map">
+        SELECT
+        DATE_FORMAT(time, #{typeFormat}) time,
+        value->'$.O3' as 'O3'
+        FROM
+        history_aqi_${timeUnits}
+        WHERE
+        time >= #{start}
+        AND time <![CDATA[<]]> #{end}
+        AND city_code = #{cityCode}
         ORDER BY
         time
   </select>
@@ -96,9 +110,23 @@
         time
     </select>
 
+    <select id="getHistoryAqi" resultType="java.util.Map">
+        select
+        DATE_FORMAT(time, #{typeFormat}) time,
+        value json
+        FROM
+        history_aqi_${timeUnits}
+        WHERE
+        time >= #{start}
+        AND time <![CDATA[<]]> #{end}
+        AND city_code = #{cityCode}
+        ORDER BY
+        time
+    </select>
+
     <select id="getAvgO3EightHours" resultType="java.util.Map">
         select
-        AVG(case when aqi_json->'$.O3C' is null then aqi_json->'$.O3' else aqi_json->'$.O3C' end)  as 'O3C_8H'
+        cast(AVG(case when aqi_json->'$.O3C' is null then aqi_json->'$.O3' else aqi_json->'$.O3C' end) as UNSIGNED  integer) 'O3_8H'
         FROM
         hangzhou_aqi
         WHERE
@@ -107,6 +135,16 @@
         AND city_code = #{cityCode}
     </select>
 
+    <select id="getHistoryO3EightHours" resultType="java.util.Map">
+        select
+        value->'$.O3_8h' 'O3_8H'
+        FROM
+        history_aqi_${timeUnits}
+        WHERE
+        time = #{time}
+        and city_code=#{cityCode}
+    </select>
+
     <select id="getSumO3" resultType="java.util.Map">
         select
         SUM(case when aqi_json->'$.O3C' is null then aqi_json->'$.O3' else aqi_json->'$.O3C' end) 'O3Sum'

--
Gitblit v1.8.0