<?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.SysDtuRemarkMapper">
    
    <resultMap type="SysDtuRemark" id="SysDtuRemarkResult">
        <result property="id"    column="id"    />
        <result property="imei"    column="imei"    />
        <result property="jbk"    column="jbk"    />
        <result property="jbg"    column="jbg"    />
        <result property="jlk"    column="jlk"    />
        <result property="jlg"    column="jlg"    />
        <result property="jm1k"    column="jm1k"    />
        <result property="jm1g"    column="jm1g"    />
        <result property="jm2k"    column="jm2k"    />
        <result property="jm2g"    column="jm2g"    />
        <result property="jm3k"    column="jm3k"    />
        <result property="jm3g"    column="jm3g"    />
        <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="version"    column="version"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="extJson"    column="ext_json"    />
    </resultMap>

    <sql id="selectSysDtuRemarkVo">
        select id, imei, jbk, jbg, jlk, jlg, jm1k, jm1g, jm2k, jm2g, jm3k, jm3g, temp1, humi1, temp2, humi2, temp3, humi3, temp4, humi4, version, create_by, create_time, update_by, update_time, ext_json from sys_dtu_remark
    </sql>

    <select id="selectSysDtuRemarkList" parameterType="SysDtuRemark" resultMap="SysDtuRemarkResult">
        <include refid="selectSysDtuRemarkVo"/>
        <where>  
            <if test="imei != null  and imei != ''"> and imei like concat('%', #{imei}, '%')</if>
        </where>
    </select>
    
    <select id="selectSysDtuRemarkById" parameterType="Long" resultMap="SysDtuRemarkResult">
        <include refid="selectSysDtuRemarkVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysDtuRemark" parameterType="SysDtuRemark" useGeneratedKeys="true" keyProperty="id">
        insert into sys_dtu_remark
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="imei != null and imei != ''">imei,</if>
            <if test="jbk != null">jbk,</if>
            <if test="jbg != null">jbg,</if>
            <if test="jlk != null">jlk,</if>
            <if test="jlg != null">jlg,</if>
            <if test="jm1k != null">jm1k,</if>
            <if test="jm1g != null">jm1g,</if>
            <if test="jm2k != null">jm2k,</if>
            <if test="jm2g != null">jm2g,</if>
            <if test="jm3k != null">jm3k,</if>
            <if test="jm3g != null">jm3g,</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="version != null">version,</if>
    create_by,
    create_time,
    update_by,
    update_time,
            <if test="extJson != null">ext_json,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="imei != null and imei != ''">#{imei},</if>
            <if test="jbk != null">#{jbk},</if>
            <if test="jbg != null">#{jbg},</if>
            <if test="jlk != null">#{jlk},</if>
            <if test="jlg != null">#{jlg},</if>
            <if test="jm1k != null">#{jm1k},</if>
            <if test="jm1g != null">#{jm1g},</if>
            <if test="jm2k != null">#{jm2k},</if>
            <if test="jm2g != null">#{jm2g},</if>
            <if test="jm3k != null">#{jm3k},</if>
            <if test="jm3g != null">#{jm3g},</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="version != null">#{version},</if>
        #{createBy},
        #{createTime},
        #{updateBy},
        #{updateTime},
            <if test="extJson != null">#{extJson},</if>
         </trim>
    </insert>

    <update id="updateSysDtuRemark" parameterType="SysDtuRemark">
        update sys_dtu_remark
        <trim prefix="SET" suffixOverrides=",">
            <if test="imei != null and imei != ''">imei = #{imei},</if>
            <if test="jbk != null">jbk = #{jbk},</if>
            <if test="jbg != null">jbg = #{jbg},</if>
            <if test="jlk != null">jlk = #{jlk},</if>
            <if test="jlg != null">jlg = #{jlg},</if>
            <if test="jm1k != null">jm1k = #{jm1k},</if>
            <if test="jm1g != null">jm1g = #{jm1g},</if>
            <if test="jm2k != null">jm2k = #{jm2k},</if>
            <if test="jm2g != null">jm2g = #{jm2g},</if>
            <if test="jm3k != null">jm3k = #{jm3k},</if>
            <if test="jm3g != null">jm3g = #{jm3g},</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>
            create_by = #{createBy},
            create_time = #{createTime},
            update_by = #{updateBy},
            update_time = #{updateTime},
            <if test="version != null">version = #{version},</if>
            <if test="extJson != null">ext_json = #{extJson},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysDtuRemarkById" parameterType="Long">
        delete from sys_dtu_remark where id = #{id}
    </delete>

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