<?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.TValveNoncMapper">
    
    <resultMap type="TValveNonc" id="TValveNoncResult">
        <result property="id"    column="id"    />
        <result property="vtNo"    column="vt_no"    />
        <result property="pidNo"    column="pid_no"    />
        <result property="locationAt"    column="location_at"    />
        <result property="medium"    column="medium"    />
        <result property="valveType"    column="valve_type"    />
        <result property="valveSize"    column="valve_size"    />
        <result property="responsibility"    column="responsibility"    />
        <result property="pidStatus"    column="pid_status"    />
        <result property="riskLevel"    column="risk_level"    />
        <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="selectTValveNoncVo">
        select id, vt_no, pid_no, location_at, medium, valve_type, valve_size, responsibility, pid_status, risk_level, remarks, del_flag, creater_code, createdate, updater_code, updatedate, dept_id from t_valve_nonc
    </sql>

    <select id="selectTValveNoncList" parameterType="TValveNonc" resultMap="TValveNoncResult">
        <include refid="selectTValveNoncVo"/>
        <where>  
            <if test="vtNo != null  and vtNo != ''"> and vt_no = #{vtNo}</if>
            <if test="pidNo != null  and pidNo != ''"> and pid_no = #{pidNo}</if>
            <if test="locationAt != null  and locationAt != ''"> and location_at = #{locationAt}</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="responsibility != null  and responsibility != ''"> and responsibility = #{responsibility}</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="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="selectTValveNoncById" parameterType="Long" resultMap="TValveNoncResult">
        <include refid="selectTValveNoncVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTValveNonc" parameterType="TValveNonc" useGeneratedKeys="true" keyProperty="id">
        insert into t_valve_nonc
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="vtNo != null">vt_no,</if>
            <if test="pidNo != null">pid_no,</if>
            <if test="locationAt != null">location_at,</if>
            <if test="medium != null">medium,</if>
            <if test="valveType != null">valve_type,</if>
            <if test="valveSize != null">valve_size,</if>
            <if test="responsibility != null">responsibility,</if>
            <if test="pidStatus != null">pid_status,</if>
            <if test="riskLevel != null">risk_level,</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="vtNo != null">#{vtNo},</if>
            <if test="pidNo != null">#{pidNo},</if>
            <if test="locationAt != null">#{locationAt},</if>
            <if test="medium != null">#{medium},</if>
            <if test="valveType != null">#{valveType},</if>
            <if test="valveSize != null">#{valveSize},</if>
            <if test="responsibility != null">#{responsibility},</if>
            <if test="pidStatus != null">#{pidStatus},</if>
            <if test="riskLevel != null">#{riskLevel},</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="updateTValveNonc" parameterType="TValveNonc">
        update t_valve_nonc
        <trim prefix="SET" suffixOverrides=",">
            <if test="vtNo != null">vt_no = #{vtNo},</if>
            <if test="pidNo != null">pid_no = #{pidNo},</if>
            <if test="locationAt != null">location_at = #{locationAt},</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="responsibility != null">responsibility = #{responsibility},</if>
            <if test="pidStatus != null">pid_status = #{pidStatus},</if>
            <if test="riskLevel != null">risk_level = #{riskLevel},</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="deleteTValveNoncById" parameterType="Long">
        delete from t_valve_nonc where id = #{id}
    </delete>

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