From f0ebb071ac4828e1a5b55eccbba8d8dd9a4d80ad Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Thu, 13 Aug 2020 11:26:19 +0800
Subject: [PATCH] 根据臭氧预测算法更新接口
---
src/main/resources/mapper/HangzhouAqiMapper.xml | 97 +++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 86 insertions(+), 11 deletions(-)
diff --git a/src/main/resources/mapper/HangzhouAqiMapper.xml b/src/main/resources/mapper/HangzhouAqiMapper.xml
index 75d5c97..5e1a166 100644
--- a/src/main/resources/mapper/HangzhouAqiMapper.xml
+++ b/src/main/resources/mapper/HangzhouAqiMapper.xml
@@ -1,21 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
-<mapper namespace="com.moral.mapper.HangzhouAqiMapper" >
- <resultMap id="BaseResultMap" type="com.moral.entity.HangzhouAqi" >
- <id column="time" property="time" jdbcType="TIMESTAMP" />
- <result column="aqi_json" property="aqiJson" jdbcType="OTHER" />
- <result column="city_code" property="cityCode" jdbcType="VARCHAR" />
- </resultMap>
- <sql id="Base_Column_List" >
+<mapper namespace="com.moral.mapper.HangzhouAqiMapper">
+ <resultMap id="BaseResultMap" type="com.moral.entity.HangzhouAqi">
+ <id column="time" property="time" jdbcType="TIMESTAMP"/>
+ <result column="aqi_json" property="aqiJson" jdbcType="OTHER"/>
+ <result column="city_code" property="cityCode" jdbcType="VARCHAR"/>
+ </resultMap>
+ <sql id="Base_Column_List">
time, aqi_json, city_code
</sql>
- <!--<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.util.Date" >-->
+ <!--<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.util.Date" >-->
<!--select-->
<!--<include refid="Base_Column_List" />-->
<!--from hangzhou_aqi-->
<!--where time = #{time,jdbcType=TIMESTAMP}-->
- <!--</select>-->
- <select id="selectAqisByCodeAndTimePeriod" resultType="map" parameterType="java.util.Date" >
+ <!--</select>-->
+ <select id="selectAqisByCodeAndTimePeriod" resultType="map" parameterType="java.util.Date">
select
aqi_json->'$.AQI' as aqi,DATE_FORMAT(time,'${@com.moral.common.util.ReportTimeFormat@toMySqlTimeFormat(timePeriod.timeUnits)}') as 'time'
from hangzhou_aqi
@@ -32,4 +32,79 @@
)
order by time asc
</select>
-</mapper>
\ No newline at end of file
+
+ <select id="getAqisByOrganizationId" resultType="map">
+ SELECT
+ h.aqi_json ->> '$.AQI' * 1 aqi,
+ DATE_FORMAT( h.time, '%H' ) * 1 time
+ FROM
+ hangzhou_aqi h
+ <where>
+ h.city_code = #{cityCode}
+ AND h.time <![CDATA[<]]> #{end}
+ </where>
+ ORDER BY
+ h.time DESC
+ LIMIT 24
+ </select>
+
+ <select id="queryCityCode" resultType="integer">
+ select city_code from area where area_code = #{areaCode}
+ </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>
+
+ <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>
+
+</mapper>
--
Gitblit v1.8.0