<?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.fastbee.deviceData.mapper.DeviceRealtimedataMeteorologyMapper">

    <resultMap type="DeviceRealtimedataMeteorology" id="DeviceRealtimedataMeteorologyResult">
        <result property="id"    column="id"    />
        <result property="deviceId"    column="device_id"    />
        <result property="airTemp"    column="air_temp"    />
        <result property="airHumi"    column="air_humi"    />
        <result property="windSpeed"    column="wind_speed"    />
        <result property="windDir"    column="wind_dir"    />
        <result property="airPre"    column="air_pre"    />
        <result property="guangzhao"    column="guangzhao"    />
        <result property="fushe"    column="fushe"    />
        <result property="sumRain"    column="sum_rain"    />
        <result property="insRain"    column="ins_rain"    />
        <result property="dayRain"    column="day_rain"    />
        <result property="zhengfa"    column="zhengfa"    />
        <result property="soilTemp"    column="soil_temp"    />
        <result property="soilHumi"    column="soil_humi"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="saveTime"    column="save_time"    />
        <result property="realTime"    column="real_time"    />
    </resultMap>

    <sql id="selectDeviceRealtimedataMeteorologyVo">
        select id, device_id, air_temp, air_humi, wind_speed, wind_dir, air_pre, guangzhao, fushe, sum_rain, ins_rain, day_rain, zhengfa, soil_temp, soil_humi, del_flag, save_time, real_time from iot_device_realtimedata_meteorology
    </sql>

    <select id="selectDeviceRealtimedataMeteorologyList" parameterType="DeviceRealtimedataMeteorology" resultMap="DeviceRealtimedataMeteorologyResult">
        <include refid="selectDeviceRealtimedataMeteorologyVo"/>
        <where>
            <if test="deviceId != null  and deviceId != ''"> and device_id = #{deviceId}</if>
            <if test="airTemp != null "> and air_temp = #{airTemp}</if>
            <if test="airHumi != null "> and air_humi = #{airHumi}</if>
            <if test="windSpeed != null "> and wind_speed = #{windSpeed}</if>
            <if test="windDir != null "> and wind_dir = #{windDir}</if>
            <if test="airPre != null "> and air_pre = #{airPre}</if>
            <if test="guangzhao != null "> and guangzhao = #{guangzhao}</if>
            <if test="fushe != null "> and fushe = #{fushe}</if>
            <if test="sumRain != null "> and sum_rain = #{sumRain}</if>
            <if test="insRain != null "> and ins_rain = #{insRain}</if>
            <if test="dayRain != null "> and day_rain = #{dayRain}</if>
            <if test="zhengfa != null "> and zhengfa = #{zhengfa}</if>
            <if test="soilTemp != null "> and soil_temp = #{soilTemp}</if>
            <if test="soilHumi != null "> and soil_humi = #{soilHumi}</if>
            <if test="saveTime != null "> and save_time = #{saveTime}</if>
            <if test="realTime != null "> and real_time = #{realTime}</if>
        </where>
    </select>

    <select id="selectDeviceRealtimedataMeteorologyById" parameterType="Long" resultMap="DeviceRealtimedataMeteorologyResult">
        <include refid="selectDeviceRealtimedataMeteorologyVo"/>
        where id = #{id}
    </select>

    <insert id="insertDeviceRealtimedataMeteorology" parameterType="DeviceRealtimedataMeteorology" useGeneratedKeys="true" keyProperty="id">
        insert into iot_device_realtimedata_meteorology
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deviceId != null">device_id,</if>
            <if test="airTemp != null">air_temp,</if>
            <if test="airHumi != null">air_humi,</if>
            <if test="windSpeed != null">wind_speed,</if>
            <if test="windDir != null">wind_dir,</if>
            <if test="airPre != null">air_pre,</if>
            <if test="guangzhao != null">guangzhao,</if>
            <if test="fushe != null">fushe,</if>
            <if test="sumRain != null">sum_rain,</if>
            <if test="insRain != null">ins_rain,</if>
            <if test="dayRain != null">day_rain,</if>
            <if test="zhengfa != null">zhengfa,</if>
            <if test="soilTemp != null">soil_temp,</if>
            <if test="soilHumi != null">soil_humi,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="saveTime != null">save_time,</if>
            <if test="realTime != null">real_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deviceId != null">#{deviceId},</if>
            <if test="airTemp != null">#{airTemp},</if>
            <if test="airHumi != null">#{airHumi},</if>
            <if test="windSpeed != null">#{windSpeed},</if>
            <if test="windDir != null">#{windDir},</if>
            <if test="airPre != null">#{airPre},</if>
            <if test="guangzhao != null">#{guangzhao},</if>
            <if test="fushe != null">#{fushe},</if>
            <if test="sumRain != null">#{sumRain},</if>
            <if test="insRain != null">#{insRain},</if>
            <if test="dayRain != null">#{dayRain},</if>
            <if test="zhengfa != null">#{zhengfa},</if>
            <if test="soilTemp != null">#{soilTemp},</if>
            <if test="soilHumi != null">#{soilHumi},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="saveTime != null">#{saveTime},</if>
            <if test="realTime != null">#{realTime},</if>
        </trim>
    </insert>

    <update id="updateDeviceRealtimedataMeteorology" parameterType="DeviceRealtimedataMeteorology">
        update iot_device_realtimedata_meteorology
        <trim prefix="SET" suffixOverrides=",">
            <if test="deviceId != null">device_id = #{deviceId},</if>
            <if test="airTemp != null">air_temp = #{airTemp},</if>
            <if test="airHumi != null">air_humi = #{airHumi},</if>
            <if test="windSpeed != null">wind_speed = #{windSpeed},</if>
            <if test="windDir != null">wind_dir = #{windDir},</if>
            <if test="airPre != null">air_pre = #{airPre},</if>
            <if test="guangzhao != null">guangzhao = #{guangzhao},</if>
            <if test="fushe != null">fushe = #{fushe},</if>
            <if test="sumRain != null">sum_rain = #{sumRain},</if>
            <if test="insRain != null">ins_rain = #{insRain},</if>
            <if test="dayRain != null">day_rain = #{dayRain},</if>
            <if test="zhengfa != null">zhengfa = #{zhengfa},</if>
            <if test="soilTemp != null">soil_temp = #{soilTemp},</if>
            <if test="soilHumi != null">soil_humi = #{soilHumi},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="saveTime != null">save_time = #{saveTime},</if>
            <if test="realTime != null">real_time = #{realTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDeviceRealtimedataMeteorologyById" parameterType="Long">
        delete from iot_device_realtimedata_meteorology where id = #{id}
    </delete>

    <delete id="deleteDeviceRealtimedataMeteorologyByIds" parameterType="String">
        delete from iot_device_realtimedata_meteorology where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>