From 50cd32a0495af9304f8839c76056333a412a81bc Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Mon, 07 Sep 2020 16:43:04 +0800
Subject: [PATCH] update
---
src/main/resources/mapper/HangzhouAqiMapper.xml | 76 +++++++++++++++++++++++++++++++------
1 files changed, 63 insertions(+), 13 deletions(-)
diff --git a/src/main/resources/mapper/HangzhouAqiMapper.xml b/src/main/resources/mapper/HangzhouAqiMapper.xml
index 26e4898..20a903a 100644
--- a/src/main/resources/mapper/HangzhouAqiMapper.xml
+++ b/src/main/resources/mapper/HangzhouAqiMapper.xml
@@ -53,18 +53,68 @@
</select>
<select id="getAreaAvgDataByAreaCode" resultType="java.util.Map">
- SELECT
- DATE_FORMAT(time, #{typeFormat}) time,
- round(AVG(case when aqi_json->'$.${sensors}' is null then aqi_json->'$.${sensors1}' else aqi_json->'$.${sensors}' end),4) as '${sensors2}'
- FROM
- hangzhou_aqi ha
- WHERE
- ha.time >= #{start}
- AND ha.time <![CDATA[<]]> #{end}
- AND ha.city_code = #{areaCode}
- GROUP BY
- DATE_FORMAT(time, #{typeFormat})
- ORDER BY
- time
+ SELECT
+ DATE_FORMAT(time, #{typeFormat}) time,
+ round(AVG(case when aqi_json->'$.${sensors}' is null then aqi_json->'$.${sensors1}' else aqi_json->'$.${sensors}' end),4) as '${sensors2}'
+ FROM
+ hangzhou_aqi ha
+ WHERE
+ ha.time >= #{start}
+ AND ha.time <![CDATA[<]]> #{end}
+ AND ha.city_code = #{areaCode}
+ GROUP BY
+ DATE_FORMAT(time, #{typeFormat})
+ ORDER BY
+ time
+ </select>
+
+ <select id="getAqiDataByAreaCode" resultType="java.util.Map">
+ SELECT
+ DATE_FORMAT(time, #{typeFormat}) time,
+ ifnull(aqi_json->'$.O3C',aqi_json->'$.O3') as 'O3'
+ FROM
+ hangzhou_aqi ha
+ WHERE
+ ha.time >= #{start}
+ AND ha.time <![CDATA[<]]> #{end}
+ AND ha.city_code = #{cityCode}
+ ORDER BY
+ time
</select>
+
+ <select id="getAqi" resultType="java.util.Map">
+ select
+ DATE_FORMAT(time, #{typeFormat}) time,
+ aqi_json json
+ FROM
+ hangzhou_aqi
+ 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'
+ FROM
+ hangzhou_aqi
+ WHERE
+ time >= #{start}
+ AND time <![CDATA[<]]> #{end}
+ 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'
+ FROM
+ hangzhou_aqi
+ WHERE
+ time >= #{start}
+ AND time <![CDATA[<]]> #{end}
+ AND city_code = #{cityCode}
+ </select>
</mapper>
--
Gitblit v1.8.0