<?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.cpms.project.asset.mapper.TLeakagePointsRecordMapper">
    
    <resultMap type="TLeakagePointsRecord" id="TLeakagePointsRecordResult">
        <result property="id"    column="id"    />
        <result property="patrolId"    column="patrol_id"    />
        <result property="pointNo"    column="point_no"    />
        <result property="leakagePosition"    column="leakage_position"    />
        <result property="leakageMedium"    column="leakage_medium"    />
        <result property="suspendPlateM"    column="suspend_plate_m"    />
        <result property="leakageStatusM"    column="leakage_status_m"    />
        <result property="suspendPlateN"    column="suspend_plate_n"    />
        <result property="leakageStatusN"    column="leakage_status_n"    />
        <result property="remarks"    column="remarks"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createrCode"    column="creater_code"    />
        <result property="createdate"    column="createdate"    />
        <result property="updaterCode"    column="updater_code"    />
        <result property="updatedate"    column="updatedate"    />
        <result property="deptId"    column="dept_id"    />
    </resultMap>

    <sql id="selectTLeakagePointsRecordVo">
        select id, patrol_id, point_no, leakage_position, leakage_medium, suspend_plate_m, leakage_status_m, suspend_plate_n, leakage_status_n, remarks, del_flag, creater_code, createdate, updater_code, updatedate, dept_id from t_leakage_points_record
    </sql>

    <select id="selectTLeakagePointsRecordList" parameterType="TLeakagePointsRecord" resultMap="TLeakagePointsRecordResult">
        <include refid="selectTLeakagePointsRecordVo"/>
        <where>  
            <if test="patrolId != null "> and patrol_id = #{patrolId}</if>
            <if test="pointNo != null  and pointNo != ''"> and point_no = #{pointNo}</if>
            <if test="leakagePosition != null  and leakagePosition != ''"> and leakage_position = #{leakagePosition}</if>
            <if test="leakageMedium != null  and leakageMedium != ''"> and leakage_medium = #{leakageMedium}</if>
            <if test="suspendPlateM != null  and suspendPlateM != ''"> and suspend_plate_m = #{suspendPlateM}</if>
            <if test="leakageStatusM != null  and leakageStatusM != ''"> and leakage_status_m = #{leakageStatusM}</if>
            <if test="suspendPlateN != null  and suspendPlateN != ''"> and suspend_plate_n = #{suspendPlateN}</if>
            <if test="leakageStatusN != null  and leakageStatusN != ''"> and leakage_status_n = #{leakageStatusN}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
            <if test="createrCode != null  and createrCode != ''"> and creater_code = #{createrCode}</if>
            <if test="createdate != null "> and createdate = #{createdate}</if>
            <if test="updaterCode != null  and updaterCode != ''"> and updater_code = #{updaterCode}</if>
            <if test="updatedate != null "> and updatedate = #{updatedate}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
        and del_flag=0
        </where>
    </select>
    
    <select id="selectTLeakagePointsRecordById" parameterType="Long" resultMap="TLeakagePointsRecordResult">
        <include refid="selectTLeakagePointsRecordVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTLeakagePointsRecord" parameterType="TLeakagePointsRecord" useGeneratedKeys="true" keyProperty="id">
        insert into t_leakage_points_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="patrolId != null">patrol_id,</if>
            <if test="pointNo != null">point_no,</if>
            <if test="leakagePosition != null">leakage_position,</if>
            <if test="leakageMedium != null">leakage_medium,</if>
            <if test="suspendPlateM != null">suspend_plate_m,</if>
            <if test="leakageStatusM != null">leakage_status_m,</if>
            <if test="suspendPlateN != null">suspend_plate_n,</if>
            <if test="leakageStatusN != null">leakage_status_n,</if>
            <if test="remarks != null">remarks,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createrCode != null">creater_code,</if>
            <if test="createdate != null">createdate,</if>
            <if test="updaterCode != null">updater_code,</if>
            <if test="updatedate != null">updatedate,</if>
            <if test="deptId != null">dept_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="patrolId != null">#{patrolId},</if>
            <if test="pointNo != null">#{pointNo},</if>
            <if test="leakagePosition != null">#{leakagePosition},</if>
            <if test="leakageMedium != null">#{leakageMedium},</if>
            <if test="suspendPlateM != null">#{suspendPlateM},</if>
            <if test="leakageStatusM != null">#{leakageStatusM},</if>
            <if test="suspendPlateN != null">#{suspendPlateN},</if>
            <if test="leakageStatusN != null">#{leakageStatusN},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createrCode != null">#{createrCode},</if>
            <if test="createdate != null">#{createdate},</if>
            <if test="updaterCode != null">#{updaterCode},</if>
            <if test="updatedate != null">#{updatedate},</if>
            <if test="deptId != null">#{deptId},</if>
         </trim>
    </insert>

    <update id="updateTLeakagePointsRecord" parameterType="TLeakagePointsRecord">
        update t_leakage_points_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="patrolId != null">patrol_id = #{patrolId},</if>
            <if test="pointNo != null">point_no = #{pointNo},</if>
            <if test="leakagePosition != null">leakage_position = #{leakagePosition},</if>
            <if test="leakageMedium != null">leakage_medium = #{leakageMedium},</if>
            <if test="suspendPlateM != null">suspend_plate_m = #{suspendPlateM},</if>
            <if test="leakageStatusM != null">leakage_status_m = #{leakageStatusM},</if>
            <if test="suspendPlateN != null">suspend_plate_n = #{suspendPlateN},</if>
            <if test="leakageStatusN != null">leakage_status_n = #{leakageStatusN},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createrCode != null">creater_code = #{createrCode},</if>
            <if test="createdate != null">createdate = #{createdate},</if>
            <if test="updaterCode != null">updater_code = #{updaterCode},</if>
            <if test="updatedate != null">updatedate = #{updatedate},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTLeakagePointsRecordById" parameterType="Long">
        delete from t_leakage_points_record where id = #{id}
    </delete>

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