<?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.reliability.mapper.TSafetyvavleMapper">
    
    <resultMap type="TSafetyvavle" id="TSafetyvavleResult">
        <result property="id"    column="id"    />
        <result property="plantCode"    column="plant_code"    />
        <result property="unit"    column="unit"    />
        <result property="subarea"    column="subarea"    />
        <result property="tagno"    column="tagno"    />
        <result property="placedesc"    column="placedesc"    />
        <result property="psvcalcreport"    column="psvcalcreport"    />
        <result property="datasheetdoc"    column="datasheetdoc"    />
        <result property="datasupplier"    column="datasupplier"    />
        <result property="deasignscenarios"    column="deasignscenarios"    />
        <result property="relief"    column="relief"    />
        <result property="releaseplace"    column="releaseplace"    />
        <result property="service"    column="service"    />
        <result property="type"    column="type"    />
        <result property="manufacture"    column="manufacture"    />
        <result property="settingpres"    column="settingpres"    />
        <result property="settingtestpres"    column="settingtestpres"    />
        <result property="maxbackpres"    column="maxbackpres"    />
        <result property="workingpres"    column="workingpres"    />
        <result property="workingtemp"    column="workingtemp"    />
        <result property="sizeinlet"    column="sizeinlet"    />
        <result property="sizeoutlet"    column="sizeoutlet"    />
        <result property="materials"    column="materials"    />
        <result property="fluidname"    column="fluidname"    />
        <result property="fluidstate"    column="fluidstate"    />
        <result property="inspectingdate"    column="inspectingdate"    />
        <result property="nextinspectdate"    column="nextinspectdate"    />
        <result property="pid"    column="pid"    />
        <result property="usingdate"    column="usingdate"    />
        <result property="vendordoc"    column="vendordoc"    />
        <result property="item"    column="item"    />
        <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="remarks"    column="remarks"    />
        <result property="deptId"    column="dept_id"    />
        <result property="uploadStatus"    column="upload_status"    />
        <result property="uploadDate"    column="upload_date"    />
        <result property="deptName" column="dept_name" />
    </resultMap>

    <sql id="selectTSafetyvavleVo">
        select d.id, d.plant_code, d.unit, d.subarea, d.tagno, d.placedesc, d.psvcalcreport, d.datasheetdoc, d.datasupplier, d.deasignscenarios, d.relief, d.releaseplace, d.service, d.type, d.manufacture, d.settingpres, d.settingtestpres, d.maxbackpres, d.workingpres, d.workingtemp, d.sizeinlet, d.sizeoutlet, d.materials, d.fluidname, d.fluidstate, d.inspectingdate, d.nextinspectdate, d.pid, d.usingdate, d.vendordoc, d.item, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate, d.remarks, d.dept_id, d.upload_status, d.upload_date ,s.dept_name from t_safetyvavle d
      left join sys_dept s on s.dept_id = d.dept_id
    </sql>

    <select id="selectTSafetyvavleList" parameterType="TSafetyvavle" resultMap="TSafetyvavleResult">
        <include refid="selectTSafetyvavleVo"/>
        <where>  
            <if test="tagno != null  and tagno != ''"> and tagno = #{tagno}</if>
            <if test="item != null "> and item = #{item}</if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
        order by d.id desc
    </select>

    <select id="selectList" parameterType="TSafetyvavle" resultMap="TSafetyvavleResult">
        <include refid="selectTSafetyvavleVo"/>
        <where>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
        order by d.id desc
    </select>
    
    <select id="selectTSafetyvavleById" parameterType="Long" resultMap="TSafetyvavleResult">
        <include refid="selectTSafetyvavleVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTSafetyvavle" parameterType="TSafetyvavle">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_safetyvavle.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_safetyvavle
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="plantCode != null and plantCode != ''">plant_code,</if>
            <if test="unit != null">unit,</if>
            <if test="subarea != null">subarea,</if>
            <if test="tagno != null">tagno,</if>
            <if test="placedesc != null">placedesc,</if>
            <if test="psvcalcreport != null">psvcalcreport,</if>
            <if test="datasheetdoc != null">datasheetdoc,</if>
            <if test="datasupplier != null">datasupplier,</if>
            <if test="deasignscenarios != null">deasignscenarios,</if>
            <if test="relief != null">relief,</if>
            <if test="releaseplace != null">releaseplace,</if>
            <if test="service != null">service,</if>
            <if test="type != null">type,</if>
            <if test="manufacture != null">manufacture,</if>
            <if test="settingpres != null">settingpres,</if>
            <if test="settingtestpres != null">settingtestpres,</if>
            <if test="maxbackpres != null">maxbackpres,</if>
            <if test="workingpres != null">workingpres,</if>
            <if test="workingtemp != null">workingtemp,</if>
            <if test="sizeinlet != null">sizeinlet,</if>
            <if test="sizeoutlet != null">sizeoutlet,</if>
            <if test="materials != null">materials,</if>
            <if test="fluidname != null">fluidname,</if>
            <if test="fluidstate != null">fluidstate,</if>
            <if test="inspectingdate != null">inspectingdate,</if>
            <if test="nextinspectdate != null">nextinspectdate,</if>
            <if test="pid != null">pid,</if>
            <if test="usingdate != null">usingdate,</if>
            <if test="vendordoc != null">vendordoc,</if>
            <if test="item != null">item,</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="remarks != null">remarks,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="uploadStatus != null">upload_status,</if>
            <if test="uploadDate != null">upload_date,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="plantCode != null and plantCode != ''">#{plantCode},</if>
            <if test="unit != null">#{unit},</if>
            <if test="subarea != null">#{subarea},</if>
            <if test="tagno != null">#{tagno},</if>
            <if test="placedesc != null">#{placedesc},</if>
            <if test="psvcalcreport != null">#{psvcalcreport},</if>
            <if test="datasheetdoc != null">#{datasheetdoc},</if>
            <if test="datasupplier != null">#{datasupplier},</if>
            <if test="deasignscenarios != null">#{deasignscenarios},</if>
            <if test="relief != null">#{relief},</if>
            <if test="releaseplace != null">#{releaseplace},</if>
            <if test="service != null">#{service},</if>
            <if test="type != null">#{type},</if>
            <if test="manufacture != null">#{manufacture},</if>
            <if test="settingpres != null">#{settingpres},</if>
            <if test="settingtestpres != null">#{settingtestpres},</if>
            <if test="maxbackpres != null">#{maxbackpres},</if>
            <if test="workingpres != null">#{workingpres},</if>
            <if test="workingtemp != null">#{workingtemp},</if>
            <if test="sizeinlet != null">#{sizeinlet},</if>
            <if test="sizeoutlet != null">#{sizeoutlet},</if>
            <if test="materials != null">#{materials},</if>
            <if test="fluidname != null">#{fluidname},</if>
            <if test="fluidstate != null">#{fluidstate},</if>
            <if test="inspectingdate != null">#{inspectingdate},</if>
            <if test="nextinspectdate != null">#{nextinspectdate},</if>
            <if test="pid != null">#{pid},</if>
            <if test="usingdate != null">#{usingdate},</if>
            <if test="vendordoc != null">#{vendordoc},</if>
            <if test="item != null">#{item},</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="remarks != null">#{remarks},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="uploadStatus != null">#{uploadStatus},</if>
            <if test="uploadDate != null">#{uploadDate},</if>
         </trim>
    </insert>

    <update id="updateTSafetyvavle" parameterType="TSafetyvavle">
        update t_safetyvavle
        <trim prefix="SET" suffixOverrides=",">
            <if test="plantCode != null and plantCode != ''">plant_code = #{plantCode},</if>
            <if test="unit != null">unit = #{unit},</if>
            <if test="subarea != null">subarea = #{subarea},</if>
            <if test="tagno != null">tagno = #{tagno},</if>
            <if test="placedesc != null">placedesc = #{placedesc},</if>
            <if test="psvcalcreport != null">psvcalcreport = #{psvcalcreport},</if>
            <if test="datasheetdoc != null">datasheetdoc = #{datasheetdoc},</if>
            <if test="datasupplier != null">datasupplier = #{datasupplier},</if>
            <if test="deasignscenarios != null">deasignscenarios = #{deasignscenarios},</if>
            <if test="relief != null">relief = #{relief},</if>
            <if test="releaseplace != null">releaseplace = #{releaseplace},</if>
            <if test="service != null">service = #{service},</if>
            <if test="type != null">type = #{type},</if>
            <if test="manufacture != null">manufacture = #{manufacture},</if>
            <if test="settingpres != null">settingpres = #{settingpres},</if>
            <if test="settingtestpres != null">settingtestpres = #{settingtestpres},</if>
            <if test="maxbackpres != null">maxbackpres = #{maxbackpres},</if>
            <if test="workingpres != null">workingpres = #{workingpres},</if>
            <if test="workingtemp != null">workingtemp = #{workingtemp},</if>
            <if test="sizeinlet != null">sizeinlet = #{sizeinlet},</if>
            <if test="sizeoutlet != null">sizeoutlet = #{sizeoutlet},</if>
            <if test="materials != null">materials = #{materials},</if>
            <if test="fluidname != null">fluidname = #{fluidname},</if>
            <if test="fluidstate != null">fluidstate = #{fluidstate},</if>
            <if test="inspectingdate != null">inspectingdate = #{inspectingdate},</if>
            <if test="nextinspectdate != null">nextinspectdate = #{nextinspectdate},</if>
            <if test="pid != null">pid = #{pid},</if>
            <if test="usingdate != null">usingdate = #{usingdate},</if>
            <if test="vendordoc != null">vendordoc = #{vendordoc},</if>
            <if test="item != null">item = #{item},</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="remarks != null">remarks = #{remarks},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="uploadStatus != null">upload_status = #{uploadStatus},</if>
            <if test="uploadDate != null">upload_date = #{uploadDate},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="deleteTSafetyvavleById" parameterType="Long">
        update t_safetyvavle set del_flag = 2 where id = #{id}
    </update>

    <update id="deleteTSafetyvavleByIds" parameterType="String">
        update t_safetyvavle set del_flag = 2 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>

    <update id="uploadTSafetyvavleById" parameterType="Long">
        update t_safetyvavle set upload_status = 1, upload_date = to_timestamp(to_CHAR(sysdate,'YYYY-MM-DD')||to_char(sysdate,'hh24:mi:ss'),'yyyy-mm-dd hh24:mi:ss') where id = #{id}
    </update>

    <update id="uploadTSafetyvavleByIds" parameterType="String">
        update t_safetyvavle set upload_status = 1, upload_date = to_timestamp(to_CHAR(sysdate,'YYYY-MM-DD')||to_char(sysdate,'hh24:mi:ss'),'yyyy-mm-dd hh24:mi:ss') where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
    
</mapper>