<?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.fire.mapper.TFireDoorMapper">

    <resultMap type="TFireDoor" id="TFireDoorResult">
        <result property="id"    column="id"    />
        <result property="devNo"    column="dev_no"    />
        <result property="inactiveState"    column="inactive_state"    />
        <result property="sealingProperty"    column="sealing_property"    />
        <result property="appearance"    column="appearance"    />
        <result property="lubricatingProperty"    column="lubricating_property"    />
        <result property="doorClosers"    column="door_closers"    />
        <result property="performanceClosers"    column="performance_closers"    />
        <result property="confirmed"    column="confirmed"    />
        <result property="remarks"    column="remarks"    />
        <result property="checkStatus"    column="check_status"    />
        <result property="checkDate"    column="check_date"    />
        <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"    />
        <result property="devType"    column="dev_type"    />
    </resultMap>

    <sql id="selectTFireDoorVo">
        select id, dev_no, inactive_state, sealing_property, appearance, lubricating_property, door_closers, performance_closers, confirmed, remarks, check_status, check_date, 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, dev_type from t_fire_door
    </sql>

    <select id="selectTFireDoorList" parameterType="TFireDoor" resultMap="TFireDoorResult">
        <include refid="selectTFireDoorVo"/>
        <where>
            <if test="id != null "> and id = #{id}</if>
            <if test="precision != null  and precision != ''"> and dev_no =#{precision}</if>
            <if test="devNo != null  and devNo != ''"> and dev_no  like concat(concat('%', #{devNo}), '%')</if>
            <if test="inactiveState != null  and inactiveState != ''"> and inactive_state = #{inactiveState}</if>
            <if test="sealingProperty != null  and sealingProperty != ''"> and sealing_property = #{sealingProperty}</if>
            <if test="appearance != null  and appearance != ''"> and appearance = #{appearance}</if>
            <if test="lubricatingProperty != null  and lubricatingProperty != ''"> and lubricating_property = #{lubricatingProperty}</if>
            <if test="doorClosers != null  and doorClosers != ''"> and door_closers = #{doorClosers}</if>
            <if test="performanceClosers != null  and performanceClosers != ''"> and performance_closers = #{performanceClosers}</if>
            <if test="confirmed != null  and confirmed != ''"> and confirmed = #{confirmed}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
            <if test="checkStatus != null  and checkStatus != ''"> and check_status = #{checkStatus}</if>
            <if test="checkDate != null "> and check_date = #{checkDate}</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>
            <if test="devType != null  and devType != ''"> and dev_type = #{devType}</if>
            and del_flag=0
        </where>
        order by check_status,check_date desc
    </select>

    <select id="selectTFireDoor" parameterType="TFireDoor" resultMap="TFireDoorResult">
        <include refid="selectTFireDoorVo"/>
        <where>
            <if test="devNo != null  and devNo != ''">and dev_no = #{devNo}</if>
            <if test="planId != null ">and plan_id = #{planId}</if>
            <if test="devType != null  and devType != ''">and dev_type = #{devType}</if>
            and del_flag=0
        </where>
    </select>

    <select id="selectTFireDoorById" parameterType="Long" resultMap="TFireDoorResult">
        <include refid="selectTFireDoorVo"/>
        where id = #{id}
    </select>

    <insert id="insertTFireDoor" parameterType="TFireDoor">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_fire_door.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_fire_door
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="devNo != null">dev_no,</if>
            <if test="inactiveState != null">inactive_state,</if>
            <if test="sealingProperty != null">sealing_property,</if>
            <if test="appearance != null">appearance,</if>
            <if test="lubricatingProperty != null">lubricating_property,</if>
            <if test="doorClosers != null">door_closers,</if>
            <if test="performanceClosers != null">performance_closers,</if>
            <if test="confirmed != null">confirmed,</if>
            <if test="remarks != null">remarks,</if>
            <if test="checkStatus != null">check_status,</if>
            <if test="checkDate != null">check_date,</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>
            <if test="devType != null">dev_type,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="devNo != null">#{devNo},</if>
            <if test="inactiveState != null">#{inactiveState},</if>
            <if test="sealingProperty != null">#{sealingProperty},</if>
            <if test="appearance != null">#{appearance},</if>
            <if test="lubricatingProperty != null">#{lubricatingProperty},</if>
            <if test="doorClosers != null">#{doorClosers},</if>
            <if test="performanceClosers != null">#{performanceClosers},</if>
            <if test="confirmed != null">#{confirmed},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="checkStatus != null">#{checkStatus},</if>
            <if test="checkDate != null">#{checkDate},</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>
            <if test="devType != null">#{devType},</if>
         </trim>
    </insert>

    <update id="updateTFireDoor" parameterType="TFireDoor">
        update t_fire_door
        <trim prefix="SET" suffixOverrides=",">
            <if test="devNo != null">dev_no = #{devNo},</if>
            <if test="inactiveState != null">inactive_state = #{inactiveState},</if>
            <if test="sealingProperty != null">sealing_property = #{sealingProperty},</if>
            <if test="appearance != null">appearance = #{appearance},</if>
            <if test="lubricatingProperty != null">lubricating_property = #{lubricatingProperty},</if>
            <if test="doorClosers != null">door_closers = #{doorClosers},</if>
            <if test="performanceClosers != null">performance_closers = #{performanceClosers},</if>
            <if test="confirmed != null">confirmed = #{confirmed},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="checkStatus != null">check_status = #{checkStatus},</if>
            <if test="checkDate != null">check_date = #{checkDate},</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>
            <if test="devType != null">dev_type = #{devType},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTFireDoorById" parameterType="Long">
        delete from t_fire_door where id = #{id}
    </delete>

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