From e399f702d76b2b170956a5996b5364f148b54b8d Mon Sep 17 00:00:00 2001
From: 于紫祥_1901 <email@yuzixiang_1910>
Date: Thu, 10 Sep 2020 15:13:37 +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