<?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.ruoyi.ems.mapper.AdmWeatherForecastMapper">
    <resultMap id="BaseResultMap" type="com.huashe.common.domain.model.WeatherForecast">
        <result column="adcode" property="adcode" jdbcType="VARCHAR"/>
        <result column="area_name" property="areaName" jdbcType="VARCHAR"/>
        <result column="date" property="date" jdbcType="DATE"/>
        <result column="day_weather_type" property="dayWeatherType" jdbcType="VARCHAR"/>
        <result column="day_weather_cn" property="dayWeatherCn" jdbcType="VARCHAR"/>
        <result column="night_weather_type" property="nightWeatherType" jdbcType="VARCHAR"/>
        <result column="night_weather_cn" property="nightWeatherCn" jdbcType="VARCHAR"/>
        <result column="day_temp" property="dayTemp" jdbcType="DOUBLE"/>
        <result column="night_temp" property="nightTemp" jdbcType="DOUBLE"/>
        <result column="day_wind_power" property="dayWindPower" jdbcType="VARCHAR"/>
        <result column="night_wind_power" property="nightWindPower" jdbcType="VARCHAR"/>
        <result column="day_wind_dir" property="dayWindDir" jdbcType="VARCHAR"/>
        <result column="night_wind_dir" property="nightWindDir" jdbcType="VARCHAR"/>
        <result column="report_time" property="reportTime" jdbcType="TIMESTAMP"/>
    </resultMap>

    <select id="getByAdcode" parameterType="java.lang.String" resultMap="BaseResultMap" >
        SELECT
            `adcode`, `area_name`, `date`, `day_weather_type`, `day_weather_cn`, `night_weather_type`, `night_weather_cn`, `day_temp`, `night_temp`, `day_wind_power`, `night_wind_power`, `day_wind_dir`, `night_wind_dir`, `report_time`
        FROM `adm_area_weather_forecast`
        <where>
            `adcode` = #{adcode}
            <if test="startTime != null and startTime != '' and endTime != null and endTime !=''">
                and `date` &gt;= #{startTime} and `date` &lt;= #{endTime}
            </if>
        </where>
    </select>

    <update id="insertBatch" parameterType="java.util.List">
        INSERT INTO `adm_area_weather_forecast`
            (`adcode`, `area_name`, `date`, `day_weather_type`, `day_weather_cn`, `night_weather_type`, `night_weather_cn`, `day_temp`, `night_temp`, `day_wind_power`, `night_wind_power`, `day_wind_dir`, `night_wind_dir`, `report_time`)
        VALUES
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.adcode}, #{item.areaName}, #{item.date}, #{item.dayWeatherType}, #{item.dayWeatherCn}, #{item.nightWeatherType}, #{item.nightWeatherCn},
             #{item.dayTemp}, #{item.nightTemp}, #{item.dayWindPower}, #{item.nightWindPower}, #{item.dayWindDir}, #{item.nightWindDir}, #{item.reportTime})
        </foreach>
    </update>

    <delete id="deleteByAdcode" parameterType="java.lang.String">
        delete from `adm_area_weather_forecast` where adcode = #{adcode}
    </delete>
</mapper>
