<?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.agri.system.mapper.SysSpecialDtuDataMapper">
    
    <resultMap type="SysSpecialDtuData" id="SysSpecialDtuDataResult">
        <result property="id"    column="id"    />
        <result property="imei"    column="imei"    />
        <result property="ts"    column="ts"    />
        <result property="time"    column="time"    />
        <result property="temp1"    column="temp1"    />
        <result property="humi1"    column="humi1"    />
        <result property="temp2"    column="temp2"    />
        <result property="humi2"    column="humi2"    />
        <result property="temp3"    column="temp3"    />
        <result property="humi3"    column="humi3"    />
        <result property="temp4"    column="temp4"    />
        <result property="humi4"    column="humi4"    />
        <result property="temp5"    column="temp5"    />
        <result property="humi5"    column="humi5"    />
        <result property="temp6"    column="temp6"    />
        <result property="humi6"    column="humi6"    />
        <result property="temp7"    column="temp7"    />
        <result property="humi7"    column="humi7"    />
        <result property="temp8"    column="temp8"    />
        <result property="humi8"    column="humi8"    />
        <result property="temp9"    column="temp9"    />
        <result property="humi9"    column="humi9"    />
        <result property="temp10"    column="temp10"    />
        <result property="humi10"    column="humi10"    />
        <result property="temp11"    column="temp11"    />
        <result property="humi11"    column="humi11"    />
        <result property="temp12"    column="temp12"    />
        <result property="humi12"    column="humi12"    />
        <result property="raw"    column="raw"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectSysSpecialDtuDataVo">
        select id, imei, ts, time, temp1, humi1, temp2, humi2, temp3, humi3, temp4, humi4, temp5, humi5, temp6, humi6, temp7, humi7, temp8, humi8, temp9, humi9, temp10, humi10, temp11, humi11, temp12, humi12, raw, create_by, create_time from sys_special_dtu_data
    </sql>

    <select id="selectSysSpecialDtuDataList" parameterType="SysSpecialDtuData" resultMap="SysSpecialDtuDataResult">
        <include refid="selectSysSpecialDtuDataVo"/>
        <where>  
            <if test="imei != null  and imei != ''"> and imei = #{imei}</if>
            <if test="ts != null "> and ts = #{ts}</if>
        </where>
    </select>
    
    <select id="selectSysSpecialDtuDataById" parameterType="Long" resultMap="SysSpecialDtuDataResult">
        <include refid="selectSysSpecialDtuDataVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysSpecialDtuData" parameterType="SysSpecialDtuData" useGeneratedKeys="true" keyProperty="id">
        insert into sys_special_dtu_data
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="imei != null and imei != ''">imei,</if>
            <if test="ts != null">ts,</if>
            <if test="time != null">time,</if>
            <if test="temp1 != null">temp1,</if>
            <if test="humi1 != null">humi1,</if>
            <if test="temp2 != null">temp2,</if>
            <if test="humi2 != null">humi2,</if>
            <if test="temp3 != null">temp3,</if>
            <if test="humi3 != null">humi3,</if>
            <if test="temp4 != null">temp4,</if>
            <if test="humi4 != null">humi4,</if>
            <if test="temp5 != null">temp5,</if>
            <if test="humi5 != null">humi5,</if>
            <if test="temp6 != null">temp6,</if>
            <if test="humi6 != null">humi6,</if>
            <if test="temp7 != null">temp7,</if>
            <if test="humi7 != null">humi7,</if>
            <if test="temp8 != null">temp8,</if>
            <if test="humi8 != null">humi8,</if>
            <if test="temp9 != null">temp9,</if>
            <if test="humi9 != null">humi9,</if>
            <if test="temp10 != null">temp10,</if>
            <if test="humi10 != null">humi10,</if>
            <if test="temp11 != null">temp11,</if>
            <if test="humi11 != null">humi11,</if>
            <if test="temp12 != null">temp12,</if>
            <if test="humi12 != null">humi12,</if>
            <if test="raw != null">raw,</if>
    create_by,
    create_time,
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="imei != null and imei != ''">#{imei},</if>
            <if test="ts != null">#{ts},</if>
            <if test="time != null">#{time},</if>
            <if test="temp1 != null">#{temp1},</if>
            <if test="humi1 != null">#{humi1},</if>
            <if test="temp2 != null">#{temp2},</if>
            <if test="humi2 != null">#{humi2},</if>
            <if test="temp3 != null">#{temp3},</if>
            <if test="humi3 != null">#{humi3},</if>
            <if test="temp4 != null">#{temp4},</if>
            <if test="humi4 != null">#{humi4},</if>
            <if test="temp5 != null">#{temp5},</if>
            <if test="humi5 != null">#{humi5},</if>
            <if test="temp6 != null">#{temp6},</if>
            <if test="humi6 != null">#{humi6},</if>
            <if test="temp7 != null">#{temp7},</if>
            <if test="humi7 != null">#{humi7},</if>
            <if test="temp8 != null">#{temp8},</if>
            <if test="humi8 != null">#{humi8},</if>
            <if test="temp9 != null">#{temp9},</if>
            <if test="humi9 != null">#{humi9},</if>
            <if test="temp10 != null">#{temp10},</if>
            <if test="humi10 != null">#{humi10},</if>
            <if test="temp11 != null">#{temp11},</if>
            <if test="humi11 != null">#{humi11},</if>
            <if test="temp12 != null">#{temp12},</if>
            <if test="humi12 != null">#{humi12},</if>
            <if test="raw != null">#{raw},</if>
        #{createBy},
        #{createTime},
         </trim>
    </insert>

    <update id="updateSysSpecialDtuData" parameterType="SysSpecialDtuData">
        update sys_special_dtu_data
        <trim prefix="SET" suffixOverrides=",">
            <if test="imei != null and imei != ''">imei = #{imei},</if>
            <if test="ts != null">ts = #{ts},</if>
            <if test="time != null">time = #{time},</if>
            <if test="temp1 != null">temp1 = #{temp1},</if>
            <if test="humi1 != null">humi1 = #{humi1},</if>
            <if test="temp2 != null">temp2 = #{temp2},</if>
            <if test="humi2 != null">humi2 = #{humi2},</if>
            <if test="temp3 != null">temp3 = #{temp3},</if>
            <if test="humi3 != null">humi3 = #{humi3},</if>
            <if test="temp4 != null">temp4 = #{temp4},</if>
            <if test="humi4 != null">humi4 = #{humi4},</if>
            <if test="temp5 != null">temp5 = #{temp5},</if>
            <if test="humi5 != null">humi5 = #{humi5},</if>
            <if test="temp6 != null">temp6 = #{temp6},</if>
            <if test="humi6 != null">humi6 = #{humi6},</if>
            <if test="temp7 != null">temp7 = #{temp7},</if>
            <if test="humi7 != null">humi7 = #{humi7},</if>
            <if test="temp8 != null">temp8 = #{temp8},</if>
            <if test="humi8 != null">humi8 = #{humi8},</if>
            <if test="temp9 != null">temp9 = #{temp9},</if>
            <if test="humi9 != null">humi9 = #{humi9},</if>
            <if test="temp10 != null">temp10 = #{temp10},</if>
            <if test="humi10 != null">humi10 = #{humi10},</if>
            <if test="temp11 != null">temp11 = #{temp11},</if>
            <if test="humi11 != null">humi11 = #{humi11},</if>
            <if test="temp12 != null">temp12 = #{temp12},</if>
            <if test="humi12 != null">humi12 = #{humi12},</if>
            <if test="raw != null">raw = #{raw},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysSpecialDtuDataById" parameterType="Long">
        delete from sys_special_dtu_data where id = #{id}
    </delete>

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