fengxiang
2018-08-24 41863d2c44c03dca9f0bff4e3fad2be454362da0
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
<?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" >
    time, aqi_json, city_code
  </sql>
  <!--<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
        aqi_json->'$.AQI' as aqi,DATE_FORMAT(time,'${@com.moral.common.util.ReportTimeFormat@toMySqlTimeFormat(timePeriod.timeUnits)}') as 'time'
      from hangzhou_aqi
       where
          (
          time >= #{timePeriod.startTime}
          and time <![CDATA[<=]]> #{timePeriod.endTime}
          )
          and
          (
             city_code = #{code}
             or
             aqi_json->'$.city_code' = #{code}
          )
          order by time asc
    </select>
</mapper>