<?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.huashe.common.data.mapper.AdmWeatherRtMapper">
    <resultMap id="BaseResultMap" type="com.huashe.common.domain.model.WeatherRt">
        <result column="adcode" property="adcode" jdbcType="VARCHAR"/>
        <result column="area_name" property="areaName" jdbcType="VARCHAR"/>
        <result column="date" property="date" jdbcType="DATE"/>
        <result column="weather_type" property="weatherType" jdbcType="VARCHAR"/>
        <result column="weather_cn" property="weatherCn" jdbcType="VARCHAR"/>
        <result column="temperature" property="temperature" jdbcType="DOUBLE"/>
        <result column="humidity" property="humidity" jdbcType="INTEGER"/>
        <result column="wind_power" property="windPower" jdbcType="VARCHAR"/>
        <result column="wind_direction" property="windDirection" jdbcType="VARCHAR"/>
        <result column="report_time" property="reportTime" jdbcType="TIMESTAMP"/>
    </resultMap>

    <update id="merge" parameterType="com.huashe.common.domain.model.WeatherRt">
        REPLACE INTO `adm_area_weather_rt`
        (
            `adcode`,
            `area_name`,
            `date`,
            `weather_type`,
            `weather_cn`,
            `temperature`,
            `humidity`,
            `wind_power`,
            `wind_direction`,
            `report_time`
        )
        VALUES (#{adcode}, #{areaName}, #{date}, #{weatherType}, #{weatherCn}, #{temperature}, #{humidity}, #{windPower}, #{windDirection}, #{reportTime})
    </update>

    <select id="getByAdcode" resultMap="BaseResultMap">
        select
            `adcode`,`area_name`,`date`,`weather_type`,`weather_cn`,`temperature`,`humidity`,`wind_power`,`wind_direction`,`report_time`
        from `adm_area_weather_rt`
        where `adcode` = #{adcode} and `date` = #{date}
    </select>

    <select id="getByTime" resultMap="BaseResultMap">
        select
            `adcode`,`area_name`,`date`,`weather_type`,`weather_cn`,`temperature`,`humidity`,`wind_power`,`wind_direction`,`report_time`
        from `adm_area_weather_rt`
        where `adcode` = #{adcode} and `date` &gt;= STR_TO_DATE(#{startTime},'%Y-%m-%d') and date &lt;= STR_TO_DATE(#{endTime},'%Y-%m-%d')
    </select>
</mapper>
