<?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.training.mapper.TWorklicenseCertificateMapper">
    
    <resultMap type="TWorklicenseCertificate" id="TWorklicenseCertificateResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="employeeid"    column="employeeid"    />
        <result property="idnum"    column="idnum"    />
        <result property="classes"    column="classes"    />
        <result property="post"    column="post"    />
        <result property="idtype"    column="idtype"    />
        <result property="worklicenseIdnum"    column="worklicense_idnum"    />
        <result property="boiler"    column="boiler"    />
        <result property="cracking"    column="cracking"    />
        <result property="hotarea"    column="hotarea"    />
        <result property="coldarea"    column="coldarea"    />
        <result property="aromatic"    column="aromatic"    />
        <result property="recertificatedate"    column="recertificatedate"    />
        <result property="validity"    column="validity"    />
        <result property="container"    column="container"    />
        <result property="pipe"    column="pipe"    />
        <result property="reviewdate"    column="reviewdate"    />
        <result property="pipevalidity"    column="pipevalidity"    />
        <result property="certificateNo"    column="certificate_no"    />
        <result property="boilerid"    column="boilerid"    />
        <result property="boilvalidity"    column="boilvalidity"    />
        <result property="hydrogenation"    column="hydrogenation"    />
        <result property="hydvalidity"    column="hydvalidity"    />
        <result property="hydnextreview"    column="hydnextreview"    />
        <result property="crackingid"    column="crackingid"    />
        <result property="crackingvalidity"    column="crackingvalidity"    />
        <result property="crackingreview"    column="crackingreview"    />
        <result property="refrigeration"    column="refrigeration"    />
        <result property="refrigerationvalidity"    column="refrigerationvalidity"    />
        <result property="refrigerationview"    column="refrigerationview"    />
        <result property="foremantrain"    column="foremantrain"    />
        <result property="foremanreview"    column="foremanreview"    />
        <result property="foremannextreview"    column="foremannextreview"    />
        <result property="fireProtection"    column="fire_protection"    />
        <result property="waterdate"    column="waterdate"    />
        <result property="energydate"    column="energydate"    />
        <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" />
    </resultMap>

    <sql id="selectTWorklicenseCertificateVo">
        select d.id, d.name, d.employeeid, d.idnum, d.classes, d.post, d.idtype, d.worklicense_idnum, d.boiler, d.cracking, d.hotarea, d.coldarea, d.aromatic, d.recertificatedate, d.validity, d.container, d.pipe, d.reviewdate, d.pipevalidity, d.certificate_no, d.boilerid, d.boilvalidity, d.hydrogenation, d.hydvalidity, d.hydnextreview, d.crackingid, d.crackingvalidity, d.crackingreview, d.refrigeration, d.refrigerationvalidity, d.refrigerationview, d.foremantrain, d.foremanreview, d.foremannextreview, d.fire_protection, d.waterdate, d.energydate, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate, d.dept_id from t_worklicense_certificate d
      left join sys_dept s on s.dept_id = d.dept_id
    </sql>

    <select id="selectTWorklicenseCertificateList" parameterType="TWorklicenseCertificate" resultMap="TWorklicenseCertificateResult">
        <include refid="selectTWorklicenseCertificateVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat(concat('%', #{name}), '%')</if>
            <if test="employeeid != null  and employeeid != ''"> and employeeid like concat(concat('%', #{employeeid}), '%')</if>
            <if test="idnum != null  and idnum != ''"> and idnum = #{idnum}</if>
            <if test="classes != null  and classes != ''"> and classes = #{classes}</if>
            <if test="post != null  and post != ''"> and post = #{post}</if>
            <if test="idtype != null  and idtype != ''"> and idtype = #{idtype}</if>
            <if test="worklicenseIdnum != null  and worklicenseIdnum != ''"> and worklicense_idnum = #{worklicenseIdnum}</if>
            <if test="boiler != null  and boiler != ''"> and boiler = #{boiler}</if>
            <if test="cracking != null  and cracking != ''"> and cracking = #{cracking}</if>
            <if test="hotarea != null  and hotarea != ''"> and hotarea = #{hotarea}</if>
            <if test="coldarea != null  and coldarea != ''"> and coldarea = #{coldarea}</if>
            <if test="aromatic != null  and aromatic != ''"> and aromatic = #{aromatic}</if>
            <if test="recertificatedate != null "> and recertificatedate = #{recertificatedate}</if>
            <if test="validity != null "> and validity = #{validity}</if>
            <if test="container != null  and container != ''"> and container = #{container}</if>
            <if test="pipe != null  and pipe != ''"> and pipe = #{pipe}</if>
            <if test="reviewdate != null "> and reviewdate = #{reviewdate}</if>
            <if test="pipevalidity != null "> and pipevalidity = #{pipevalidity}</if>
            <if test="certificateNo != null  and certificateNo != ''"> and certificate_no = #{certificateNo}</if>
            <if test="boilerid != null  and boilerid != ''"> and boilerid = #{boilerid}</if>
            <if test="boilvalidity != null "> and boilvalidity = #{boilvalidity}</if>
            <if test="hydrogenation != null  and hydrogenation != ''"> and hydrogenation = #{hydrogenation}</if>
            <if test="hydvalidity != null "> and hydvalidity = #{hydvalidity}</if>
            <if test="hydnextreview != null "> and hydnextreview = #{hydnextreview}</if>
            <if test="crackingid != null  and crackingid != ''"> and crackingid = #{crackingid}</if>
            <if test="crackingvalidity != null "> and crackingvalidity = #{crackingvalidity}</if>
            <if test="crackingreview != null "> and crackingreview = #{crackingreview}</if>
            <if test="refrigeration != null  and refrigeration != ''"> and refrigeration = #{refrigeration}</if>
            <if test="refrigerationvalidity != null "> and refrigerationvalidity = #{refrigerationvalidity}</if>
            <if test="refrigerationview != null "> and refrigerationview = #{refrigerationview}</if>
            <if test="foremantrain != null "> and foremantrain = #{foremantrain}</if>
            <if test="foremanreview != null "> and foremanreview = #{foremanreview}</if>
            <if test="foremannextreview != null "> and foremannextreview = #{foremannextreview}</if>
            <if test="fireProtection != null "> and fire_protection = #{fireProtection}</if>
            <if test="waterdate != null "> and waterdate = #{waterdate}</if>
            <if test="energydate != null "> and energydate = #{energydate}</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>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
        order by d.id asc
    </select>
    
    <select id="selectTWorklicenseCertificateById" parameterType="Long" resultMap="TWorklicenseCertificateResult">
        <include refid="selectTWorklicenseCertificateVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTWorklicenseCertificate" parameterType="TWorklicenseCertificate">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_worklicense_certificate.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_worklicense_certificate
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="name != null">name,</if>
            <if test="employeeid != null">employeeid,</if>
            <if test="idnum != null">idnum,</if>
            <if test="classes != null">classes,</if>
            <if test="post != null">post,</if>
            <if test="idtype != null">idtype,</if>
            <if test="worklicenseIdnum != null">worklicense_idnum,</if>
            <if test="boiler != null">boiler,</if>
            <if test="cracking != null">cracking,</if>
            <if test="hotarea != null">hotarea,</if>
            <if test="coldarea != null">coldarea,</if>
            <if test="aromatic != null">aromatic,</if>
            <if test="recertificatedate != null">recertificatedate,</if>
            <if test="validity != null">validity,</if>
            <if test="container != null">container,</if>
            <if test="pipe != null">pipe,</if>
            <if test="reviewdate != null">reviewdate,</if>
            <if test="pipevalidity != null">pipevalidity,</if>
            <if test="certificateNo != null">certificate_no,</if>
            <if test="boilerid != null">boilerid,</if>
            <if test="boilvalidity != null">boilvalidity,</if>
            <if test="hydrogenation != null">hydrogenation,</if>
            <if test="hydvalidity != null">hydvalidity,</if>
            <if test="hydnextreview != null">hydnextreview,</if>
            <if test="crackingid != null">crackingid,</if>
            <if test="crackingvalidity != null">crackingvalidity,</if>
            <if test="crackingreview != null">crackingreview,</if>
            <if test="refrigeration != null">refrigeration,</if>
            <if test="refrigerationvalidity != null">refrigerationvalidity,</if>
            <if test="refrigerationview != null">refrigerationview,</if>
            <if test="foremantrain != null">foremantrain,</if>
            <if test="foremanreview != null">foremanreview,</if>
            <if test="foremannextreview != null">foremannextreview,</if>
            <if test="fireProtection != null">fire_protection,</if>
            <if test="waterdate != null">waterdate,</if>
            <if test="energydate != null">energydate,</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="id != null">#{id},</if>
            <if test="name != null">#{name},</if>
            <if test="employeeid != null">#{employeeid},</if>
            <if test="idnum != null">#{idnum},</if>
            <if test="classes != null">#{classes},</if>
            <if test="post != null">#{post},</if>
            <if test="idtype != null">#{idtype},</if>
            <if test="worklicenseIdnum != null">#{worklicenseIdnum},</if>
            <if test="boiler != null">#{boiler},</if>
            <if test="cracking != null">#{cracking},</if>
            <if test="hotarea != null">#{hotarea},</if>
            <if test="coldarea != null">#{coldarea},</if>
            <if test="aromatic != null">#{aromatic},</if>
            <if test="recertificatedate != null">#{recertificatedate},</if>
            <if test="validity != null">#{validity},</if>
            <if test="container != null">#{container},</if>
            <if test="pipe != null">#{pipe},</if>
            <if test="reviewdate != null">#{reviewdate},</if>
            <if test="pipevalidity != null">#{pipevalidity},</if>
            <if test="certificateNo != null">#{certificateNo},</if>
            <if test="boilerid != null">#{boilerid},</if>
            <if test="boilvalidity != null">#{boilvalidity},</if>
            <if test="hydrogenation != null">#{hydrogenation},</if>
            <if test="hydvalidity != null">#{hydvalidity},</if>
            <if test="hydnextreview != null">#{hydnextreview},</if>
            <if test="crackingid != null">#{crackingid},</if>
            <if test="crackingvalidity != null">#{crackingvalidity},</if>
            <if test="crackingreview != null">#{crackingreview},</if>
            <if test="refrigeration != null">#{refrigeration},</if>
            <if test="refrigerationvalidity != null">#{refrigerationvalidity},</if>
            <if test="refrigerationview != null">#{refrigerationview},</if>
            <if test="foremantrain != null">#{foremantrain},</if>
            <if test="foremanreview != null">#{foremanreview},</if>
            <if test="foremannextreview != null">#{foremannextreview},</if>
            <if test="fireProtection != null">#{fireProtection},</if>
            <if test="waterdate != null">#{waterdate},</if>
            <if test="energydate != null">#{energydate},</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="updateTWorklicenseCertificate" parameterType="TWorklicenseCertificate">
        update t_worklicense_certificate
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="employeeid != null">employeeid = #{employeeid},</if>
            <if test="idnum != null">idnum = #{idnum},</if>
            <if test="classes != null">classes = #{classes},</if>
            <if test="post != null">post = #{post},</if>
            <if test="idtype != null">idtype = #{idtype},</if>
            <if test="worklicenseIdnum != null">worklicense_idnum = #{worklicenseIdnum},</if>
            <if test="boiler != null">boiler = #{boiler},</if>
            <if test="cracking != null">cracking = #{cracking},</if>
            <if test="hotarea != null">hotarea = #{hotarea},</if>
            <if test="coldarea != null">coldarea = #{coldarea},</if>
            <if test="aromatic != null">aromatic = #{aromatic},</if>
            <if test="recertificatedate != null">recertificatedate = #{recertificatedate},</if>
            <if test="validity != null">validity = #{validity},</if>
            <if test="container != null">container = #{container},</if>
            <if test="pipe != null">pipe = #{pipe},</if>
            <if test="reviewdate != null">reviewdate = #{reviewdate},</if>
            <if test="pipevalidity != null">pipevalidity = #{pipevalidity},</if>
            <if test="certificateNo != null">certificate_no = #{certificateNo},</if>
            <if test="boilerid != null">boilerid = #{boilerid},</if>
            <if test="boilvalidity != null">boilvalidity = #{boilvalidity},</if>
            <if test="hydrogenation != null">hydrogenation = #{hydrogenation},</if>
            <if test="hydvalidity != null">hydvalidity = #{hydvalidity},</if>
            <if test="hydnextreview != null">hydnextreview = #{hydnextreview},</if>
            <if test="crackingid != null">crackingid = #{crackingid},</if>
            <if test="crackingvalidity != null">crackingvalidity = #{crackingvalidity},</if>
            <if test="crackingreview != null">crackingreview = #{crackingreview},</if>
            <if test="refrigeration != null">refrigeration = #{refrigeration},</if>
            <if test="refrigerationvalidity != null">refrigerationvalidity = #{refrigerationvalidity},</if>
            <if test="refrigerationview != null">refrigerationview = #{refrigerationview},</if>
            <if test="foremantrain != null">foremantrain = #{foremantrain},</if>
            <if test="foremanreview != null">foremanreview = #{foremanreview},</if>
            <if test="foremannextreview != null">foremannextreview = #{foremannextreview},</if>
            <if test="fireProtection != null">fire_protection = #{fireProtection},</if>
            <if test="waterdate != null">waterdate = #{waterdate},</if>
            <if test="energydate != null">energydate = #{energydate},</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>

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

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