<?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.ruoyi.project.intact.mapper.TIntactYsjMapper">
    
    <resultMap type="TIntactYsj" id="TIntactYsjResult">
        <result property="id"    column="id"    />
        <result property="type"    column="type"    />
        <result property="plantCode"    column="plant_code"    />
        <result property="unit"    column="unit"    />
        <result property="devname"    column="devname"    />
        <result property="devno"    column="devno"    />
        <result property="position"    column="position"    />
        <result property="deviceSize"    column="device_size"    />
        <result property="desPressure"    column="des_pressure"    />
        <result property="desTemp"    column="des_temp"    />
        <result property="optPressure"    column="opt_pressure"    />
        <result property="optTemp"    column="opt_temp"    />
        <result property="medium"    column="medium"    />
        <result property="leakageMode"    column="leakage_mode"    />
        <result property="dataNo"    column="data_no"    />
        <result property="bookNo"    column="book_no"    />
        <result property="manufactor"    column="manufactor"    />
        <result property="remark"    column="remark"    />
        <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"    />
        <result property="deptName" column="dept_name" />
        <result property="approveTime" column="approve_time" />
        <result property="approveStatus" column="approve_status" />
    </resultMap>

    <sql id="selectTIntactYsjVo">
        select d.id, d.type, d.plant_code, d.unit, d.devname, d.devno, d.position, d.device_size, d.des_pressure, d.des_temp, d.opt_pressure, d.opt_temp, d.medium, d.leakage_mode, d.data_no, d.book_no, d.manufactor, d.remark, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate, d.dept_id ,d.approve_status, d.approve_time,s.dept_name from t_intact_ysj d
      left join sys_dept s on s.dept_id = d.dept_id
    </sql>

    <select id="selectTIntactYsjList" parameterType="TIntactYsj" resultMap="TIntactYsjResult">
        <include refid="selectTIntactYsjVo"/>
        <where>  
            <if test="type != null "> and type = #{type}</if>
            <if test="plantCode != null  and plantCode != ''"> and plant_code = #{plantCode}</if>
            <if test="unit != null  and unit != ''"> and unit = #{unit}</if>
            <if test="devname != null  and devname != ''"> and devname like concat(concat('%', #{devname}), '%')</if>
            <if test="devno != null  and devno != ''"> and devno = #{devno}</if>
            <if test="position != null  and position != ''"> and position = #{position}</if>
            <if test="deviceSize != null  and deviceSize != ''"> and device_size = #{deviceSize}</if>
            <if test="desPressure != null  and desPressure != ''"> and des_pressure = #{desPressure}</if>
            <if test="desTemp != null  and desTemp != ''"> and des_temp = #{desTemp}</if>
            <if test="optPressure != null  and optPressure != ''"> and opt_pressure = #{optPressure}</if>
            <if test="optTemp != null  and optTemp != ''"> and opt_temp = #{optTemp}</if>
            <if test="medium != null  and medium != ''"> and medium = #{medium}</if>
            <if test="leakageMode != null  and leakageMode != ''"> and leakage_mode = #{leakageMode}</if>
            <if test="dataNo != null  and dataNo != ''"> and data_no = #{dataNo}</if>
            <if test="bookNo != null  and bookNo != ''"> and book_no = #{bookNo}</if>
            <if test="manufactor != null  and manufactor != ''"> and manufactor = #{manufactor}</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 updater_code = #{updaterCode}</if>
            <if test="updatedate != null "> and updatedate = #{updatedate}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="approveStatus != null "> and approve_status = #{approveStatus}</if>
            <if test="approveTime != null "> and approve_time, = #{approveTime}</if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>
    
    <select id="selectTIntactYsjById" parameterType="Long" resultMap="TIntactYsjResult">
        <include refid="selectTIntactYsjVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTIntactYsj" parameterType="TIntactYsj">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_intact_ysj.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_intact_ysj
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="type != null">type,</if>
            <if test="plantCode != null and plantCode != ''">plant_code,</if>
            <if test="unit != null">unit,</if>
            <if test="devname != null">devname,</if>
            <if test="devno != null">devno,</if>
            <if test="position != null">position,</if>
            <if test="deviceSize != null">device_size,</if>
            <if test="desPressure != null">des_pressure,</if>
            <if test="desTemp != null">des_temp,</if>
            <if test="optPressure != null">opt_pressure,</if>
            <if test="optTemp != null">opt_temp,</if>
            <if test="medium != null">medium,</if>
            <if test="leakageMode != null">leakage_mode,</if>
            <if test="dataNo != null">data_no,</if>
            <if test="bookNo != null">book_no,</if>
            <if test="manufactor != null">manufactor,</if>
            <if test="remark != null">remark,</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>
            <if test="approveTime != null">approve_time,</if>
            <if test="approveStatus != null">approve_status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="type != null">#{type},</if>
            <if test="plantCode != null and plantCode != ''">#{plantCode},</if>
            <if test="unit != null">#{unit},</if>
            <if test="devname != null">#{devname},</if>
            <if test="devno != null">#{devno},</if>
            <if test="position != null">#{position},</if>
            <if test="deviceSize != null">#{deviceSize},</if>
            <if test="desPressure != null">#{desPressure},</if>
            <if test="desTemp != null">#{desTemp},</if>
            <if test="optPressure != null">#{optPressure},</if>
            <if test="optTemp != null">#{optTemp},</if>
            <if test="medium != null">#{medium},</if>
            <if test="leakageMode != null">#{leakageMode},</if>
            <if test="dataNo != null">#{dataNo},</if>
            <if test="bookNo != null">#{bookNo},</if>
            <if test="manufactor != null">#{manufactor},</if>
            <if test="remark != null">#{remark},</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>
            <if test="approveTime != null">#{approveTime},</if>
            <if test="approveStatus != null">#{approveStatus},</if>
         </trim>
    </insert>

    <update id="updateTIntactYsj" parameterType="TIntactYsj">
        update t_intact_ysj
        <trim prefix="SET" suffixOverrides=",">
            <if test="type != null">type = #{type},</if>
            <if test="plantCode != null and plantCode != ''">plant_code = #{plantCode},</if>
            <if test="unit != null">unit = #{unit},</if>
            <if test="devname != null">devname = #{devname},</if>
            <if test="devno != null">devno = #{devno},</if>
            <if test="position != null">position = #{position},</if>
            <if test="deviceSize != null">device_size = #{deviceSize},</if>
            <if test="desPressure != null">des_pressure = #{desPressure},</if>
            <if test="desTemp != null">des_temp = #{desTemp},</if>
            <if test="optPressure != null">opt_pressure = #{optPressure},</if>
            <if test="optTemp != null">opt_temp = #{optTemp},</if>
            <if test="medium != null">medium = #{medium},</if>
            <if test="leakageMode != null">leakage_mode = #{leakageMode},</if>
            <if test="dataNo != null">data_no = #{dataNo},</if>
            <if test="bookNo != null">book_no = #{bookNo},</if>
            <if test="manufactor != null">manufactor = #{manufactor},</if>
            <if test="remark != null">remark = #{remark},</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>
            <if test="approveTime != null">approve_time = #{approveTime},</if>
            <if test="approveStatus != null">approve_status = #{approveStatus},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="deleteTIntactYsjById" parameterType="Long">
        update t_intact_ysj set del_flag = -1 where id = #{id}
    </update>

    <update id="deleteTIntactYsjByIds" parameterType="String">
        update t_intact_ysj set del_flag = -1 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
    
</mapper>