<?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.ForecastWeatherMapper">
|
<resultMap id="BaseResultMap" type="com.moral.entity.ForecastWeather">
|
<id column="city_code" property="cityCode" jdbcType="INTEGER"/>
|
</resultMap>
|
<select id="getForecastHour" resultType="java.util.Map">
|
SELECT
|
DATE_FORMAT(time, #{typeFormat}) time,
|
json->'$.${sensor1}' '${sensor2}'
|
from forecast_weather
|
where time >= #{start}
|
AND time <![CDATA[<]]> #{end}
|
AND city_code=#{cityCode}
|
</select>
|
|
<select id="getForecast" resultType="java.util.Map">
|
SELECT DATE_FORMAT(time, #{typeFormat}) time,
|
json
|
from forecast_weather
|
where time >= #{start}
|
AND time <![CDATA[<]]> #{end}
|
AND city_code=#{cityCode}
|
ORDER BY
|
time
|
</select>
|
|
<update id="updateForecastWeather">
|
update forecast_weather set json=#{json}
|
where city_code=#{cityCode}
|
and time=#{time}
|
</update>
|
|
|
<select id="getPrecip6Hour" resultType="java.util.Map">
|
select
|
round(sum(json->'$.precip'),2) 'precip6'
|
FROM
|
forecast_weather
|
WHERE
|
time >= #{start}
|
AND time <![CDATA[<]]> #{end}
|
AND city_code = #{cityCode}
|
</select>
|
|
<select id="getO38Hours" resultType="java.util.Map">
|
select
|
cast(AVG(json->'$.O3C') as UNSIGNED integer) 'O3_8H'
|
FROM
|
forecast_weather
|
WHERE
|
time >= #{start}
|
AND time <![CDATA[<]]> #{end}
|
AND city_code = #{cityCode}
|
</select>
|
</mapper>
|