<?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.process.mapper.TLockValveMapper">
    
    <resultMap type="TLockValve" id="TLockValveResult">
        <result property="id"    column="id"    />
        <result property="unit"    column="unit"    />
        <result property="vtNo"    column="vt_no"    />
        <result property="pidNo"    column="pid_no"    />
        <result property="locationDes"    column="location_des"    />
        <result property="medium"    column="medium"    />
        <result property="valveType"    column="valve_type"    />
        <result property="valveSize"    column="valve_size"    />
        <result property="identifier"    column="identifier"    />
        <result property="valvePosition"    column="valve_position"    />
        <result property="firmlySecured"    column="firmly_secured"    />
        <result property="responsibility"    column="responsibility"    />
        <result property="checkedBy"    column="checked_by"    />
        <result property="checkBeforeSu"    column="check_before_su"    />
        <result property="pidStatus"    column="pid_status"    />
        <result property="riskLevel"    column="risk_level"    />
        <result property="sheReview"    column="she_review"    />
        <result property="checkDate"    column="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="selectTLockValveVo">
        select id, unit, vt_no, pid_no, location_des, medium, valve_type, valve_size, identifier, valve_position, firmly_secured, responsibility, checked_by, check_before_su, pid_status, risk_level, she_review, check_date, remarks, del_flag, creater_code, createdate, updater_code, updatedate, dept_id from t_lock_valve
    </sql>

    <select id="selectTLockValveList" parameterType="TLockValve" resultMap="TLockValveResult">
        <include refid="selectTLockValveVo"/>
        <where>  
            <if test="unit != null  and unit != ''"> and unit = #{unit}</if>
            <if test="vtNo != null  and vtNo != ''"> and vt_no = #{vtNo}</if>
            <if test="pidNo != null  and pidNo != ''"> and pid_no = #{pidNo}</if>
            <if test="locationDes != null  and locationDes != ''"> and location_des = #{locationDes}</if>
            <if test="medium != null  and medium != ''"> and medium = #{medium}</if>
            <if test="valveType != null  and valveType != ''"> and valve_type = #{valveType}</if>
            <if test="valveSize != null  and valveSize != ''"> and valve_size = #{valveSize}</if>
            <if test="identifier != null  and identifier != ''"> and identifier = #{identifier}</if>
            <if test="valvePosition != null  and valvePosition != ''"> and valve_position = #{valvePosition}</if>
            <if test="firmlySecured != null  and firmlySecured != ''"> and firmly_secured = #{firmlySecured}</if>
            <if test="responsibility != null  and responsibility != ''"> and responsibility = #{responsibility}</if>
            <if test="checkedBy != null  and checkedBy != ''"> and checked_by = #{checkedBy}</if>
            <if test="checkBeforeSu != null  and checkBeforeSu != ''"> and check_before_su = #{checkBeforeSu}</if>
            <if test="pidStatus != null  and pidStatus != ''"> and pid_status = #{pidStatus}</if>
            <if test="riskLevel != null  and riskLevel != ''"> and risk_level = #{riskLevel}</if>
            <if test="sheReview != null  and sheReview != ''"> and she_review = #{sheReview}</if>
            <if test="checkDate != null "> and check_date = #{checkDate}</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="selectTLockValveById" parameterType="Long" resultMap="TLockValveResult">
        <include refid="selectTLockValveVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTLockValve" parameterType="TLockValve" useGeneratedKeys="true" keyProperty="id">
        insert into t_lock_valve
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="unit != null">unit,</if>
            <if test="vtNo != null">vt_no,</if>
            <if test="pidNo != null">pid_no,</if>
            <if test="locationDes != null">location_des,</if>
            <if test="medium != null">medium,</if>
            <if test="valveType != null">valve_type,</if>
            <if test="valveSize != null">valve_size,</if>
            <if test="identifier != null">identifier,</if>
            <if test="valvePosition != null">valve_position,</if>
            <if test="firmlySecured != null">firmly_secured,</if>
            <if test="responsibility != null">responsibility,</if>
            <if test="checkedBy != null">checked_by,</if>
            <if test="checkBeforeSu != null">check_before_su,</if>
            <if test="pidStatus != null">pid_status,</if>
            <if test="riskLevel != null">risk_level,</if>
            <if test="sheReview != null">she_review,</if>
            <if test="checkDate != null">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="unit != null">#{unit},</if>
            <if test="vtNo != null">#{vtNo},</if>
            <if test="pidNo != null">#{pidNo},</if>
            <if test="locationDes != null">#{locationDes},</if>
            <if test="medium != null">#{medium},</if>
            <if test="valveType != null">#{valveType},</if>
            <if test="valveSize != null">#{valveSize},</if>
            <if test="identifier != null">#{identifier},</if>
            <if test="valvePosition != null">#{valvePosition},</if>
            <if test="firmlySecured != null">#{firmlySecured},</if>
            <if test="responsibility != null">#{responsibility},</if>
            <if test="checkedBy != null">#{checkedBy},</if>
            <if test="checkBeforeSu != null">#{checkBeforeSu},</if>
            <if test="pidStatus != null">#{pidStatus},</if>
            <if test="riskLevel != null">#{riskLevel},</if>
            <if test="sheReview != null">#{sheReview},</if>
            <if test="checkDate != null">#{checkDate},</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="updateTLockValve" parameterType="TLockValve">
        update t_lock_valve
        <trim prefix="SET" suffixOverrides=",">
            <if test="unit != null">unit = #{unit},</if>
            <if test="vtNo != null">vt_no = #{vtNo},</if>
            <if test="pidNo != null">pid_no = #{pidNo},</if>
            <if test="locationDes != null">location_des = #{locationDes},</if>
            <if test="medium != null">medium = #{medium},</if>
            <if test="valveType != null">valve_type = #{valveType},</if>
            <if test="valveSize != null">valve_size = #{valveSize},</if>
            <if test="identifier != null">identifier = #{identifier},</if>
            <if test="valvePosition != null">valve_position = #{valvePosition},</if>
            <if test="firmlySecured != null">firmly_secured = #{firmlySecured},</if>
            <if test="responsibility != null">responsibility = #{responsibility},</if>
            <if test="checkedBy != null">checked_by = #{checkedBy},</if>
            <if test="checkBeforeSu != null">check_before_su = #{checkBeforeSu},</if>
            <if test="pidStatus != null">pid_status = #{pidStatus},</if>
            <if test="riskLevel != null">risk_level = #{riskLevel},</if>
            <if test="sheReview != null">she_review = #{sheReview},</if>
            <if test="checkDate != null">check_date = #{checkDate},</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="deleteTLockValveById" parameterType="Long">
        delete from t_lock_valve where id = #{id}
    </delete>

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