<?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.TLeakagePointsMapper">
    
    <resultMap type="TLeakagePoints" id="TLeakagePointsResult">
        <result property="id"    column="id"    />
        <result property="pointNo"    column="point_no"    />
        <result property="leakagePosition"    column="leakage_position"    />
        <result property="leakageMedium"    column="leakage_medium"    />
        <result property="discoveryTime"    column="discovery_time"    />
        <result property="discoveryName"    column="discovery_name"    />
        <result property="leakageAmount"    column="leakage_amount"    />
        <result property="sapNo"    column="sap_no"    />
        <result property="leakageEliminationTime"    column="leakage_elimination_time"    />
        <result property="leakageEliminationFunc"    column="leakage_elimination_func"    />
        <result property="listing"    column="listing"    />
        <result property="pressurePlugging"    column="pressure_plugging"    />
        <result property="leakageEliminationResult"    column="leakage_elimination_result"    />
        <result property="nextCheckDate"    column="next_check_date"    />
        <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="selectTLeakagePointsVo">
        select id, point_no, leakage_position, leakage_medium, discovery_time, discovery_name, leakage_amount, sap_no, leakage_elimination_time, leakage_elimination_func, listing, pressure_plugging, leakage_elimination_result, next_check_date, remarks, del_flag, creater_code, createdate, updater_code, updatedate, dept_id from t_leakage_points
    </sql>

    <select id="selectTLeakagePointsList" parameterType="TLeakagePoints" resultMap="TLeakagePointsResult">
        <include refid="selectTLeakagePointsVo"/>
        <where>  
            <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="discoveryTime != null "> and discovery_time = #{discoveryTime}</if>
            <if test="discoveryName != null  and discoveryName != ''"> and discovery_name like concat('%', #{discoveryName}, '%')</if>
            <if test="leakageAmount != null  and leakageAmount != ''"> and leakage_amount = #{leakageAmount}</if>
            <if test="sapNo != null  and sapNo != ''"> and sap_no = #{sapNo}</if>
            <if test="leakageEliminationTime != null "> and leakage_elimination_time = #{leakageEliminationTime}</if>
            <if test="leakageEliminationFunc != null  and leakageEliminationFunc != ''"> and leakage_elimination_func = #{leakageEliminationFunc}</if>
            <if test="listing != null  and listing != ''"> and listing = #{listing}</if>
            <if test="pressurePlugging != null  and pressurePlugging != ''"> and pressure_plugging = #{pressurePlugging}</if>
            <if test="leakageEliminationResult != null  and leakageEliminationResult != ''"> and leakage_elimination_result in
             <foreach collection="leakageEliminationResult.split(',')" item="item" index="index"
                      open="(" close=")" separator=",">
                #{item}
            </foreach>
            </if>
            <if test="nextCheckDate != null "> and next_check_date = #{nextCheckDate}</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>
        </where>
    </select>
    
    <select id="selectTLeakagePointsById" parameterType="Long" resultMap="TLeakagePointsResult">
        <include refid="selectTLeakagePointsVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTLeakagePoints" parameterType="TLeakagePoints" useGeneratedKeys="true" keyProperty="id">
        insert into t_leakage_points
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="pointNo != null">point_no,</if>
            <if test="leakagePosition != null">leakage_position,</if>
            <if test="leakageMedium != null">leakage_medium,</if>
            <if test="discoveryTime != null">discovery_time,</if>
            <if test="discoveryName != null">discovery_name,</if>
            <if test="leakageAmount != null">leakage_amount,</if>
            <if test="sapNo != null">sap_no,</if>
            <if test="leakageEliminationTime != null">leakage_elimination_time,</if>
            <if test="leakageEliminationFunc != null">leakage_elimination_func,</if>
            <if test="listing != null">listing,</if>
            <if test="pressurePlugging != null">pressure_plugging,</if>
            <if test="leakageEliminationResult != null">leakage_elimination_result,</if>
            <if test="nextCheckDate != null">next_check_date,</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="pointNo != null">#{pointNo},</if>
            <if test="leakagePosition != null">#{leakagePosition},</if>
            <if test="leakageMedium != null">#{leakageMedium},</if>
            <if test="discoveryTime != null">#{discoveryTime},</if>
            <if test="discoveryName != null">#{discoveryName},</if>
            <if test="leakageAmount != null">#{leakageAmount},</if>
            <if test="sapNo != null">#{sapNo},</if>
            <if test="leakageEliminationTime != null">#{leakageEliminationTime},</if>
            <if test="leakageEliminationFunc != null">#{leakageEliminationFunc},</if>
            <if test="listing != null">#{listing},</if>
            <if test="pressurePlugging != null">#{pressurePlugging},</if>
            <if test="leakageEliminationResult != null">#{leakageEliminationResult},</if>
            <if test="nextCheckDate != null">#{nextCheckDate},</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="updateTLeakagePoints" parameterType="TLeakagePoints">
        update t_leakage_points
        <trim prefix="SET" suffixOverrides=",">
            <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="discoveryTime != null">discovery_time = #{discoveryTime},</if>
            <if test="discoveryName != null">discovery_name = #{discoveryName},</if>
            <if test="leakageAmount != null">leakage_amount = #{leakageAmount},</if>
            <if test="sapNo != null">sap_no = #{sapNo},</if>
            <if test="leakageEliminationTime != null">leakage_elimination_time = #{leakageEliminationTime},</if>
            <if test="leakageEliminationFunc != null">leakage_elimination_func = #{leakageEliminationFunc},</if>
            <if test="listing != null">listing = #{listing},</if>
            <if test="pressurePlugging != null">pressure_plugging = #{pressurePlugging},</if>
            <if test="leakageEliminationResult != null">leakage_elimination_result = #{leakageEliminationResult},</if>
            <if test="nextCheckDate != null">next_check_date = #{nextCheckDate},</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="deleteTLeakagePointsById" parameterType="Long">
        delete from t_leakage_points where id = #{id}
    </delete>

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