jinpengyong
2021-11-25 6050927edf6c00f2f06b0b0775502d38eb5b7705
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?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.AQIMapper">
    <select id="getCityAqiConfig" resultType="java.util.LinkedHashMap">
        select * from city_aqi_config;
    </select>
 
    <insert id="insertAQIData">
        INSERT INTO hangzhou_aqi (`time`, aqi_json,city_code)  values(
        #{time},
        #{data},
        #{code}
        )
    </insert>
 
    <select id="getStationConfig" resultType="java.util.Map">
        select station_code,city_code from aqi_station_config
    </select>
 
    <insert id="insertStationData">
        insert into
        history_aqi_station
        values
        <foreach collection="list" item="item" separator=",">
            (#{item.time},#{item.json},#{item.stationCode},#{item.cityCode})
        </foreach>
    </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>