<?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.patrol.emergency.mapper.TEmergencyCabinetMapper">

    <resultMap type="TEmergencyCabinet" id="TEmergencyCabinetResult">
        <result property="id"    column="id"    />
        <result property="devName"    column="dev_name"    />
        <result property="devNum"    column="dev_num"    />
        <result property="quantityEquipment"    column="quantity_equipment"    />
        <result property="equipmentIntegrity"    column="equipment_integrity"    />
        <result property="equipmentCleanliness"    column="equipment_cleanliness"    />
        <result property="labelValidity"    column="label_validity"    />
        <result property="barometricValue"    column="barometric_value"    />
        <result property="respiratorExpiration"    column="respirator_expiration"    />
        <result property="confirmed"    column="confirmed"    />
        <result property="remarks"    column="remarks"    />
        <result property="checkDate"    column="check_date"    />
        <result property="devType"    column="dev_type"    />
        <result property="checkStatus"    column="check_status"    />
        <result property="month"    column="month"    />
        <result property="year"    column="year"    />
        <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="planId"    column="plan_id"    />
        <result property="problemFileUrl"    column="problem_file_url"    />
        <result property="fileUrl"    column="file_url"    />
        <result property="issuesStatus"    column="issues_status"    />
        <result property="issuesFlag"    column="issues_flag"    />
        <result property="repairFile"    column="repair_file"    />
    </resultMap>

    <sql id="selectTEmergencyCabinetVo">
        select id, dev_name, dev_num, quantity_equipment, equipment_integrity, equipment_cleanliness, label_validity, barometric_value, respirator_expiration, confirmed, remarks, check_date, dev_type, check_status, month, year, del_flag, creater_code, createdate, updater_code, updatedate, dept_id, plan_id, problem_file_url, file_url, issues_status, issues_flag, repair_file from t_emergency_cabinet
    </sql>

    <select id="selectTEmergencyCabinetList" parameterType="TEmergencyCabinet" resultMap="TEmergencyCabinetResult">
        <include refid="selectTEmergencyCabinetVo"/>
        <where>
            <if test="id != null "> and id = #{id}</if>
            <if test="devName != null  and devName != ''"> and dev_name like concat(concat('%', #{devName}), '%')</if>
            <if test="devNum != null  and devNum != ''"> and dev_num = #{devNum}</if>
            <if test="quantityEquipment != null  and quantityEquipment != ''"> and quantity_equipment = #{quantityEquipment}</if>
            <if test="equipmentIntegrity != null  and equipmentIntegrity != ''"> and equipment_integrity = #{equipmentIntegrity}</if>
            <if test="equipmentCleanliness != null  and equipmentCleanliness != ''"> and equipment_cleanliness = #{equipmentCleanliness}</if>
            <if test="labelValidity != null  and labelValidity != ''"> and label_validity = #{labelValidity}</if>
            <if test="barometricValue != null  and barometricValue != ''"> and barometric_value = #{barometricValue}</if>
            <if test="respiratorExpiration != null  and respiratorExpiration != ''"> and respirator_expiration = #{respiratorExpiration}</if>
            <if test="confirmed != null  and confirmed != ''"> and confirmed = #{confirmed}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
            <if test="checkDate != null "> and check_date = #{checkDate}</if>
            <if test="devType != null  and devType != ''"> and dev_type = #{devType}</if>
            <if test="checkStatus != null  and checkStatus != ''"> and check_status = #{checkStatus}</if>
            <if test="month != null "> and month = #{month}</if>
            <if test="year != null "> and year = #{year}</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>
            <if test="planId != null "> and plan_id = #{planId}</if>
            <if test="problemFileUrl != null  and problemFileUrl != ''"> and problem_file_url = #{problemFileUrl}</if>
            <if test="fileUrl != null  and fileUrl != ''"> and file_url = #{fileUrl}</if>
            <if test="issuesStatus != null  and issuesStatus != ''"> and issues_status = #{issuesStatus}</if>
            <if test="issuesFlag != null  and issuesFlag != ''"> and issues_flag = #{issuesFlag}</if>
            <if test="repairFile != null  and repairFile != ''"> and repair_file = #{repairFile}</if>
            and del_flag=0
        </where>
        order by check_status,check_date desc
    </select>

    <select id="selectTEmergencyCabinetById" parameterType="Long" resultMap="TEmergencyCabinetResult">
        <include refid="selectTEmergencyCabinetVo"/>
        where id = #{id}
    </select>

    <insert id="insertTEmergencyCabinet" parameterType="TEmergencyCabinet">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_emergency_cabinet.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_emergency_cabinet
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="devName != null">dev_name,</if>
            <if test="devNum != null">dev_num,</if>
            <if test="quantityEquipment != null">quantity_equipment,</if>
            <if test="equipmentIntegrity != null">equipment_integrity,</if>
            <if test="equipmentCleanliness != null">equipment_cleanliness,</if>
            <if test="labelValidity != null">label_validity,</if>
            <if test="barometricValue != null">barometric_value,</if>
            <if test="respiratorExpiration != null">respirator_expiration,</if>
            <if test="confirmed != null">confirmed,</if>
            <if test="remarks != null">remarks,</if>
            <if test="checkDate != null">check_date,</if>
            <if test="devType != null and devType != ''">dev_type,</if>
            <if test="checkStatus != null">check_status,</if>
            <if test="month != null">month,</if>
            <if test="year != null">year,</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="planId != null">plan_id,</if>
            <if test="problemFileUrl != null">problem_file_url,</if>
            <if test="fileUrl != null">file_url,</if>
            <if test="issuesStatus != null">issues_status,</if>
            <if test="issuesFlag != null">issues_flag,</if>
            <if test="repairFile != null">repair_file,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="devName != null">#{devName},</if>
            <if test="devNum != null">#{devNum},</if>
            <if test="quantityEquipment != null">#{quantityEquipment},</if>
            <if test="equipmentIntegrity != null">#{equipmentIntegrity},</if>
            <if test="equipmentCleanliness != null">#{equipmentCleanliness},</if>
            <if test="labelValidity != null">#{labelValidity},</if>
            <if test="barometricValue != null">#{barometricValue},</if>
            <if test="respiratorExpiration != null">#{respiratorExpiration},</if>
            <if test="confirmed != null">#{confirmed},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="checkDate != null">#{checkDate},</if>
            <if test="devType != null and devType != ''">#{devType},</if>
            <if test="checkStatus != null">#{checkStatus},</if>
            <if test="month != null">#{month},</if>
            <if test="year != null">#{year},</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="planId != null">#{planId},</if>
            <if test="problemFileUrl != null">#{problemFileUrl},</if>
            <if test="fileUrl != null">#{fileUrl},</if>
            <if test="issuesStatus != null">#{issuesStatus},</if>
            <if test="issuesFlag != null">#{issuesFlag},</if>
            <if test="repairFile != null">#{repairFile},</if>
         </trim>
    </insert>

    <update id="updateTEmergencyCabinet" parameterType="TEmergencyCabinet">
        update t_emergency_cabinet
        <trim prefix="SET" suffixOverrides=",">
            <if test="devName != null">dev_name = #{devName},</if>
            <if test="devNum != null">dev_num = #{devNum},</if>
            <if test="quantityEquipment != null">quantity_equipment = #{quantityEquipment},</if>
            <if test="equipmentIntegrity != null">equipment_integrity = #{equipmentIntegrity},</if>
            <if test="equipmentCleanliness != null">equipment_cleanliness = #{equipmentCleanliness},</if>
            <if test="labelValidity != null">label_validity = #{labelValidity},</if>
            <if test="barometricValue != null">barometric_value = #{barometricValue},</if>
            <if test="respiratorExpiration != null">respirator_expiration = #{respiratorExpiration},</if>
            <if test="confirmed != null">confirmed = #{confirmed},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="checkDate != null">check_date = #{checkDate},</if>
            <if test="devType != null and devType != ''">dev_type = #{devType},</if>
            <if test="checkStatus != null">check_status = #{checkStatus},</if>
            <if test="month != null">month = #{month},</if>
            <if test="year != null">year = #{year},</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="planId != null">plan_id = #{planId},</if>
            <if test="problemFileUrl != null">problem_file_url = #{problemFileUrl},</if>
            <if test="fileUrl != null">file_url = #{fileUrl},</if>
            <if test="issuesStatus != null">issues_status = #{issuesStatus},</if>
            <if test="issuesFlag != null">issues_flag = #{issuesFlag},</if>
            <if test="repairFile != null">repair_file = #{repairFile},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTEmergencyCabinetById" parameterType="Long">
        delete from t_emergency_cabinet where id = #{id}
    </delete>

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