<?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.inspect.patrol.mapper.PatrolPosInfraredMapper">
    
    <resultMap type="PatrolPosInfrared" id="PatrolPosInfraredResult">
        <result property="patrolPosInfraredId"    column="patrol_pos_infrared_id"    />
        <result property="linkagePosId"    column="linkage_pos_id"    />
        <result property="measureAreaType"    column="measure_area_type"    />
        <result property="measureName"    column="measure_name"    />
        <result property="measureDistance"    column="measure_distance"    />
        <result property="radioRate"    column="radio_rate"    />
        <result property="warnMaxTemp"    column="warn_max_temp"    />
        <result property="warnMinTemp"    column="warn_min_temp"    />
        <result property="alarmMaxTemp"    column="alarm_max_temp"    />
        <result property="alarmMinTemp"    column="alarm_min_temp"    />
        <result property="coordinate"    column="coordinate"    />
        <result property="isEnable"    column="is_enable"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectPatrolPosInfraredVo">
        select patrol_pos_infrared_id, linkage_pos_id, measure_area_type, measure_name, measure_distance, radio_rate, warn_max_temp, warn_min_temp, alarm_max_temp, alarm_min_temp, coordinate, is_enable, create_time from patrol_pos_infrared
    </sql>

    <select id="selectPatrolPosInfraredList" parameterType="PatrolPosInfrared" resultMap="PatrolPosInfraredResult">
        <include refid="selectPatrolPosInfraredVo"/>
        <where>  
            <if test="linkagePosId != null "> and linkage_pos_id = #{linkagePosId}</if>
            <if test="measureAreaType != null  and measureAreaType != ''"> and measure_area_type = #{measureAreaType}</if>
            <if test="measureName != null  and measureName != ''"> and measure_name like concat('%', #{measureName}, '%')</if>
            <if test="measureDistance != null  and measureDistance != ''"> and measure_distance = #{measureDistance}</if>
            <if test="radioRate != null  and radioRate != ''"> and radio_rate = #{radioRate}</if>
            <if test="warnMaxTemp != null  and warnMaxTemp != ''"> and warn_max_temp = #{warnMaxTemp}</if>
            <if test="warnMinTemp != null  and warnMinTemp != ''"> and warn_min_temp = #{warnMinTemp}</if>
            <if test="alarmMaxTemp != null  and alarmMaxTemp != ''"> and alarm_max_temp = #{alarmMaxTemp}</if>
            <if test="alarmMinTemp != null  and alarmMinTemp != ''"> and alarm_min_temp = #{alarmMinTemp}</if>
            <if test="coordinate != null  and coordinate != ''"> and coordinate = #{coordinate}</if>
            <if test="isEnable != null  and isEnable != ''"> and is_enable = #{isEnable}</if>
        </where>
    </select>
    
    <select id="selectPatrolPosInfraredByPatrolPosInfraredId" parameterType="Long" resultMap="PatrolPosInfraredResult">
        <include refid="selectPatrolPosInfraredVo"/>
        where patrol_pos_infrared_id = #{patrolPosInfraredId}
    </select>
        
    <insert id="insertPatrolPosInfrared" parameterType="PatrolPosInfrared">
        insert into patrol_pos_infrared
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="patrolPosInfraredId != null">patrol_pos_infrared_id,</if>
            <if test="linkagePosId != null">linkage_pos_id,</if>
            <if test="measureAreaType != null">measure_area_type,</if>
            <if test="measureName != null">measure_name,</if>
            <if test="measureDistance != null">measure_distance,</if>
            <if test="radioRate != null">radio_rate,</if>
            <if test="warnMaxTemp != null">warn_max_temp,</if>
            <if test="warnMinTemp != null">warn_min_temp,</if>
            <if test="alarmMaxTemp != null">alarm_max_temp,</if>
            <if test="alarmMinTemp != null">alarm_min_temp,</if>
            <if test="coordinate != null">coordinate,</if>
            <if test="isEnable != null">is_enable,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="patrolPosInfraredId != null">#{patrolPosInfraredId},</if>
            <if test="linkagePosId != null">#{linkagePosId},</if>
            <if test="measureAreaType != null">#{measureAreaType},</if>
            <if test="measureName != null">#{measureName},</if>
            <if test="measureDistance != null">#{measureDistance},</if>
            <if test="radioRate != null">#{radioRate},</if>
            <if test="warnMaxTemp != null">#{warnMaxTemp},</if>
            <if test="warnMinTemp != null">#{warnMinTemp},</if>
            <if test="alarmMaxTemp != null">#{alarmMaxTemp},</if>
            <if test="alarmMinTemp != null">#{alarmMinTemp},</if>
            <if test="coordinate != null">#{coordinate},</if>
            <if test="isEnable != null">#{isEnable},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updatePatrolPosInfrared" parameterType="PatrolPosInfrared">
        update patrol_pos_infrared
        <trim prefix="SET" suffixOverrides=",">
            <if test="linkagePosId != null">linkage_pos_id = #{linkagePosId},</if>
            <if test="measureAreaType != null">measure_area_type = #{measureAreaType},</if>
            <if test="measureName != null">measure_name = #{measureName},</if>
            <if test="measureDistance != null">measure_distance = #{measureDistance},</if>
            <if test="radioRate != null">radio_rate = #{radioRate},</if>
            <if test="warnMaxTemp != null">warn_max_temp = #{warnMaxTemp},</if>
            <if test="warnMinTemp != null">warn_min_temp = #{warnMinTemp},</if>
            <if test="alarmMaxTemp != null">alarm_max_temp = #{alarmMaxTemp},</if>
            <if test="alarmMinTemp != null">alarm_min_temp = #{alarmMinTemp},</if>
            <if test="coordinate != null">coordinate = #{coordinate},</if>
            <if test="isEnable != null">is_enable = #{isEnable},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where patrol_pos_infrared_id = #{patrolPosInfraredId}
    </update>

    <delete id="deletePatrolPosInfraredByPatrolPosInfraredId" parameterType="Long">
        delete from patrol_pos_infrared where patrol_pos_infrared_id = #{patrolPosInfraredId}
    </delete>

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