<?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.patrolresultdefault.mapper.PatrolResultDefaultValueMapper">

    <resultMap type="PatrolResultDefaultValue" id="PatrolResultDefaultValueResult">
        <result property="valueId" column="value_id"/>
        <result property="patrolPointId" column="patrol_point_id"/>
        <result property="defaultValue" column="default_value"/>
        <result property="defaultValueUnit" column="default_value_unit"/>
        <result property="hour0" column="hour_0"/>
        <result property="hour1" column="hour_1"/>
        <result property="hour2" column="hour_2"/>
        <result property="hour3" column="hour_3"/>
        <result property="hour4" column="hour_4"/>
        <result property="hour5" column="hour_5"/>
        <result property="hour6" column="hour_6"/>
        <result property="hour7" column="hour_7"/>
        <result property="hour8" column="hour_8"/>
        <result property="hour9" column="hour_9"/>
        <result property="hour10" column="hour_10"/>
        <result property="hour11" column="hour_11"/>
        <result property="hour12" column="hour_12"/>
        <result property="hour13" column="hour_13"/>
        <result property="hour14" column="hour_14"/>
        <result property="hour15" column="hour_15"/>
        <result property="hour16" column="hour_16"/>
        <result property="hour17" column="hour_17"/>
        <result property="hour18" column="hour_18"/>
        <result property="hour19" column="hour_19"/>
        <result property="hour20" column="hour_20"/>
        <result property="hour21" column="hour_21"/>
        <result property="hour22" column="hour_22"/>
        <result property="hour23" column="hour_23"/>
    </resultMap>

    <sql id="selectPatrolResultDefaultValueVo">
        select value_id,
               patrol_point_id,
               default_value,
               default_value_unit,
               hour_0,
               hour_1,
               hour_2,
               hour_3,
               hour_4,
               hour_5,
               hour_6,
               hour_7,
               hour_8,
               hour_9,
               hour_10,
               hour_11,
               hour_12,
               hour_13,
               hour_14,
               hour_15,
               hour_16,
               hour_17,
               hour_18,
               hour_19,
               hour_20,
               hour_21,
               hour_22,
               hour_23
        from patrol_result_defaultvalue
    </sql>

    <select id="selectPatrolResultDefaultValueList" parameterType="PatrolResultDefaultValue"
            resultMap="PatrolResultDefaultValueResult">
        <include refid="selectPatrolResultDefaultValueVo"/>
        <where>
            <if test="patrolPointId != null ">and patrol_point_id = #{patrolPointId}</if>
            <if test="defaultValue != null  and defaultValue != ''">and default_value = #{defaultValue}</if>
            <if test="defaultValueUnit != null  and defaultValueUnit != ''">and default_value_unit =
                #{defaultValueUnit}
            </if>
            <if test="hour0 != null  and hour0 != ''">and hour_0 = #{hour0}</if>
            <if test="hour1 != null  and hour1 != ''">and hour_1 = #{hour1}</if>
            <if test="hour2 != null  and hour2 != ''">and hour_2 = #{hour2}</if>
            <if test="hour3 != null  and hour3 != ''">and hour_3 = #{hour3}</if>
            <if test="hour4 != null  and hour4 != ''">and hour_4 = #{hour4}</if>
            <if test="hour5 != null  and hour5 != ''">and hour_5 = #{hour5}</if>
            <if test="hour6 != null  and hour6 != ''">and hour_6 = #{hour6}</if>
            <if test="hour7 != null  and hour7 != ''">and hour_7 = #{hour7}</if>
            <if test="hour8 != null  and hour8 != ''">and hour_8 = #{hour8}</if>
            <if test="hour9 != null  and hour9 != ''">and hour_9 = #{hour9}</if>
            <if test="hour10 != null  and hour10 != ''">and hour_10 = #{hour10}</if>
            <if test="hour11 != null  and hour11 != ''">and hour_11 = #{hour11}</if>
            <if test="hour12 != null  and hour12 != ''">and hour_12 = #{hour12}</if>
            <if test="hour13 != null  and hour13 != ''">and hour_13 = #{hour13}</if>
            <if test="hour14 != null  and hour14 != ''">and hour_14 = #{hour14}</if>
            <if test="hour15 != null  and hour15 != ''">and hour_15 = #{hour15}</if>
            <if test="hour16 != null  and hour16 != ''">and hour_16 = #{hour16}</if>
            <if test="hour17 != null  and hour17 != ''">and hour_17 = #{hour17}</if>
            <if test="hour18 != null  and hour18 != ''">and hour_18 = #{hour18}</if>
            <if test="hour19 != null  and hour19 != ''">and hour_19 = #{hour19}</if>
            <if test="hour20 != null  and hour20 != ''">and hour_20 = #{hour20}</if>
            <if test="hour21 != null  and hour21 != ''">and hour_21 = #{hour21}</if>
            <if test="hour22 != null  and hour22 != ''">and hour_22 = #{hour22}</if>
            <if test="hour23 != null  and hour23 != ''">and hour_23 = #{hour23}</if>
        </where>
    </select>

    <select id="selectPatrolResultDefaultValueByResultDefaultValueId" parameterType="Long"
            resultMap="PatrolResultDefaultValueResult">
        <include refid="selectPatrolResultDefaultValueVo"/>
        where value_id = #{valueId}
    </select>

    <insert id="insertPatrolResultDefaultValue" parameterType="PatrolResultDefaultValue" useGeneratedKeys="true"
            keyProperty="valueId">
        insert into patrol_result_defaultvalue
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="patrolPointId != null">patrol_point_id,</if>
            <if test="defaultValue != null">default_value,</if>
            <if test="defaultValueUnit != null">default_value_unit,</if>
            <if test="hour0 != null">hour_0,</if>
            <if test="hour1 != null">hour_1,</if>
            <if test="hour2 != null">hour_2,</if>
            <if test="hour3 != null">hour_3,</if>
            <if test="hour4 != null">hour_4,</if>
            <if test="hour5 != null">hour_5,</if>
            <if test="hour6 != null">hour_6,</if>
            <if test="hour7 != null">hour_7,</if>
            <if test="hour8 != null">hour_8,</if>
            <if test="hour9 != null">hour_9,</if>
            <if test="hour10 != null">hour_10,</if>
            <if test="hour11 != null">hour_11,</if>
            <if test="hour12 != null">hour_12,</if>
            <if test="hour13 != null">hour_13,</if>
            <if test="hour14 != null">hour_14,</if>
            <if test="hour15 != null">hour_15,</if>
            <if test="hour16 != null">hour_16,</if>
            <if test="hour17 != null">hour_17,</if>
            <if test="hour18 != null">hour_18,</if>
            <if test="hour19 != null">hour_19,</if>
            <if test="hour20 != null">hour_20,</if>
            <if test="hour21 != null">hour_21,</if>
            <if test="hour22 != null">hour_22,</if>
            <if test="hour23 != null">hour_23,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="patrolPointId != null">#{patrolPointId},</if>
            <if test="defaultValue != null">#{defaultValue},</if>
            <if test="defaultValueUnit != null">#{defaultValueUnit},</if>
            <if test="hour0 != null">#{hour0},</if>
            <if test="hour1 != null">#{hour1},</if>
            <if test="hour2 != null">#{hour2},</if>
            <if test="hour3 != null">#{hour3},</if>
            <if test="hour4 != null">#{hour4},</if>
            <if test="hour5 != null">#{hour5},</if>
            <if test="hour6 != null">#{hour6},</if>
            <if test="hour7 != null">#{hour7},</if>
            <if test="hour8 != null">#{hour8},</if>
            <if test="hour9 != null">#{hour9},</if>
            <if test="hour10 != null">#{hour10},</if>
            <if test="hour11 != null">#{hour11},</if>
            <if test="hour12 != null">#{hour12},</if>
            <if test="hour13 != null">#{hour13},</if>
            <if test="hour14 != null">#{hour14},</if>
            <if test="hour15 != null">#{hour15},</if>
            <if test="hour16 != null">#{hour16},</if>
            <if test="hour17 != null">#{hour17},</if>
            <if test="hour18 != null">#{hour18},</if>
            <if test="hour19 != null">#{hour19},</if>
            <if test="hour20 != null">#{hour20},</if>
            <if test="hour21 != null">#{hour21},</if>
            <if test="hour22 != null">#{hour22},</if>
            <if test="hour23 != null">#{hour23},</if>
        </trim>
    </insert>

    <update id="updatePatrolResultDefaultValue" parameterType="PatrolResultDefaultValue">
        update patrol_result_defaultvalue
        <trim prefix="SET" suffixOverrides=",">
            <if test="patrolPointId != null">patrol_point_id = #{patrolPointId},</if>
            <if test="defaultValue != null">default_value = #{defaultValue},</if>
            <if test="defaultValueUnit != null">default_value_unit = #{defaultValueUnit},</if>
            <if test="hour0 != null">hour_0 = #{hour0},</if>
            <if test="hour1 != null">hour_1 = #{hour1},</if>
            <if test="hour2 != null">hour_2 = #{hour2},</if>
            <if test="hour3 != null">hour_3 = #{hour3},</if>
            <if test="hour4 != null">hour_4 = #{hour4},</if>
            <if test="hour5 != null">hour_5 = #{hour5},</if>
            <if test="hour6 != null">hour_6 = #{hour6},</if>
            <if test="hour7 != null">hour_7 = #{hour7},</if>
            <if test="hour8 != null">hour_8 = #{hour8},</if>
            <if test="hour9 != null">hour_9 = #{hour9},</if>
            <if test="hour10 != null">hour_10 = #{hour10},</if>
            <if test="hour11 != null">hour_11 = #{hour11},</if>
            <if test="hour12 != null">hour_12 = #{hour12},</if>
            <if test="hour13 != null">hour_13 = #{hour13},</if>
            <if test="hour14 != null">hour_14 = #{hour14},</if>
            <if test="hour15 != null">hour_15 = #{hour15},</if>
            <if test="hour16 != null">hour_16 = #{hour16},</if>
            <if test="hour17 != null">hour_17 = #{hour17},</if>
            <if test="hour18 != null">hour_18 = #{hour18},</if>
            <if test="hour19 != null">hour_19 = #{hour19},</if>
            <if test="hour20 != null">hour_20 = #{hour20},</if>
            <if test="hour21 != null">hour_21 = #{hour21},</if>
            <if test="hour22 != null">hour_22 = #{hour22},</if>
            <if test="hour23 != null">hour_23 = #{hour23},</if>
        </trim>
        where value_id = #{valueId}
    </update>

    <delete id="deletePatrolResultDefaultValueByResultDefaultValueId" parameterType="Long">
        delete
        from patrol_result_defaultvalue
        where value_id = #{valueId}
    </delete>

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