<?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.production.mapper.TPpeStaffLockerMapper">

    <resultMap type="TPpeStaffLocker" id="TPpeStaffLockerResult">
        <result property="id"    column="id"    />
        <result property="ppeType"    column="ppe_type"    />
        <result property="usePost"    column="use_post"    />
        <result property="isEquip"    column="is_equip"    />
        <result property="isPollution"    column="is_pollution"    />
        <result property="putAsRequired"    column="put_as_required"    />
        <result property="isRequire"    column="is_require"    />
        <result property="isValidity"    column="is_validity"    />
        <result property="isIdentification"    column="is_identification"    />
        <result property="isWetTissue"    column="is_wet_tissue"    />
        <result property="mainId"    column="main_id"    />
        <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="deptName" column="dept_name" />
    </resultMap>

    <sql id="selectTPpeStaffLockerVo">
        select d.id, d.ppe_type, d.use_post, d.is_equip, d.is_pollution, d.put_as_required, d.is_require, d.is_validity, d.is_identification, d.is_wet_tissue, d.main_id, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate, d.remarks, d.dept_id ,s.dept_name from t_ppe_staff_locker d
      left join sys_dept s on s.dept_id = d.dept_id
    </sql>

    <select id="selectTPpeStaffLockerList" parameterType="TPpeStaffLocker" resultMap="TPpeStaffLockerResult">
        <include refid="selectTPpeStaffLockerVo"/>
        <where>
            <if test="ppeType != null  and ppeType != ''"> and ppe_type = #{ppeType}</if>
            <if test="usePost != null  and usePost != ''"> and use_post = #{usePost}</if>
            <if test="isEquip != null  and isEquip != ''"> and is_equip = #{isEquip}</if>
            <if test="isPollution != null  and isPollution != ''"> and is_pollution = #{isPollution}</if>
            <if test="putAsRequired != null  and putAsRequired != ''"> and put_as_required = #{putAsRequired}</if>
            <if test="isRequire != null  and isRequire != ''"> and is_require = #{isRequire}</if>
            <if test="isValidity != null  and isValidity != ''"> and is_validity = #{isValidity}</if>
            <if test="isIdentification != null  and isIdentification != ''"> and is_identification = #{isIdentification}</if>
            <if test="isWetTissue != null  and isWetTissue != ''"> and is_wet_tissue = #{isWetTissue}</if>
            <if test="mainId != null "> and main_id = #{mainId}</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="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
        order by createdate
    </select>

    <select id="selectTPpeStaffLockerById" parameterType="Long" resultMap="TPpeStaffLockerResult">
        <include refid="selectTPpeStaffLockerVo"/>
        where id = #{id}
    </select>

    <select id="selectTPpeStaffLockerListByMainId" parameterType="Long" resultMap="TPpeStaffLockerResult">
        <include refid="selectTPpeStaffLockerVo"/>
        where main_id = #{mainId}
        order by createdate
    </select>

    <insert id="insertTPpeStaffLocker" parameterType="TPpeStaffLocker">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_ppe_staff_locker.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_ppe_staff_locker
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="ppeType != null">ppe_type,</if>
            <if test="usePost != null">use_post,</if>
            <if test="isEquip != null">is_equip,</if>
            <if test="isPollution != null">is_pollution,</if>
            <if test="putAsRequired != null">put_as_required,</if>
            <if test="isRequire != null">is_require,</if>
            <if test="isValidity != null">is_validity,</if>
            <if test="isIdentification != null">is_identification,</if>
            <if test="isWetTissue != null">is_wet_tissue,</if>
            <if test="mainId != null">main_id,</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>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="ppeType != null">#{ppeType},</if>
            <if test="usePost != null">#{usePost},</if>
            <if test="isEquip != null">#{isEquip},</if>
            <if test="isPollution != null">#{isPollution},</if>
            <if test="putAsRequired != null">#{putAsRequired},</if>
            <if test="isRequire != null">#{isRequire},</if>
            <if test="isValidity != null">#{isValidity},</if>
            <if test="isIdentification != null">#{isIdentification},</if>
            <if test="isWetTissue != null">#{isWetTissue},</if>
            <if test="mainId != null">#{mainId},</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>
         </trim>
    </insert>

    <update id="updateTPpeStaffLocker" parameterType="TPpeStaffLocker">
        update t_ppe_staff_locker
        <trim prefix="SET" suffixOverrides=",">
            <if test="ppeType != null">ppe_type = #{ppeType},</if>
            <if test="usePost != null">use_post = #{usePost},</if>
            <if test="isEquip != null">is_equip = #{isEquip},</if>
            <if test="isPollution != null">is_pollution = #{isPollution},</if>
            <if test="putAsRequired != null">put_as_required = #{putAsRequired},</if>
            <if test="isRequire != null">is_require = #{isRequire},</if>
            <if test="isValidity != null">is_validity = #{isValidity},</if>
            <if test="isIdentification != null">is_identification = #{isIdentification},</if>
            <if test="isWetTissue != null">is_wet_tissue = #{isWetTissue},</if>
            <if test="mainId != null">main_id = #{mainId},</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>
        </trim>
        where id = #{id}
    </update>

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

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

</mapper>
