<?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.zcloud.fire.check.persistence.mapper.FireCheckListMapper">
    <select id="getInfoById" resultType="com.zcloud.fire.check.persistence.dataobject.FireCheckListDO">
        select cl.*,
               fclu.department_id as departmentId ,
               d.name as departmentName,
               GROUP_CONCAT(DISTINCT u.name) AS userName,
               p.post_name as postName
        from fire_check_list cl
                 LEFT JOIN fire_check_list_user fclu on cl.fire_check_id = fclu.fire_check_id
                 left join department d on fclu.department_id = d.id and d.delete_enum = 'FALSE'
                 left join user u on fclu.user_id = u.id and u.delete_enum = 'FALSE'
                 left join post p on u.post_id = p.id and p.delete_enum = 'FALSE'
        where cl.id = #{id}
          and cl.delete_enum = 'FALSE'
        group by cl.id
        order by cl.create_time desc
    </select>
    <select id="listPage" resultType="com.zcloud.fire.check.persistence.dataobject.FireCheckListDO">
        SELECT
        cl.*,
        d.name AS departmentName,
        GROUP_CONCAT(DISTINCT u.name) AS userName
        FROM fire_check_list cl
        LEFT JOIN fire_check_list_user fclu on cl.fire_check_id = fclu.fire_check_id
        LEFT JOIN department d ON fclu.department_id = d.id AND d.delete_enum = 'FALSE'
        LEFT JOIN user u ON fclu.user_id = u.id AND u.delete_enum = 'FALSE'
        WHERE cl.delete_enum = 'FALSE'
            AND cl.corpinfo_id = #{params.corpinfoId}
            <if test="params.fireCheckType != null and params.fireCheckType != ''">
                AND cl.fire_check_type = #{params.fireCheckType}
            </if>
            <if test="params.departmentId != null and params.departmentId != ''">
                AND fclu.department_id = #{params.departmentId}
            </if>
            <if test="params.fireCheckName != null and params.fireCheckName != ''">
                AND cl.fire_check_name LIKE CONCAT('%', #{params.fireCheckName}, '%')
            </if>
            <if test="params.userName != null and params.userName != ''">
                and u.name like CONCAT('%', #{params.userName}, '%')
            </if>
            <if test="params.stateList != null and params.stateList.size > 0 ">
                and cl.state IN
                <foreach item="item" collection="params.stateList" separator="," open="(" close=")" index="">
                    #{item}
                </foreach>
            </if>
        group by cl.id
        ORDER BY cl.create_time DESC
    </select>

    <select id="appCheckList" resultType="com.zcloud.fire.check.persistence.dataobject.FireCheckListDO">
        -- 待排查的记录
        select
        cl.*,
        GROUP_CONCAT(DISTINCT u.name) AS userName,
        d.name AS departmentName,
        COUNT(distinct cr.id) AS checkedCount
        from fire_check_list cl
        LEFT JOIN fire_check_list_item cli on cl.fire_check_id = cli.fire_check_id
        LEFT JOIN fire_check_list_user fclu on cl.fire_check_id = fclu.fire_check_id
        LEFT JOIN user u ON fclu.user_id = u.id  AND u.delete_enum = 'FALSE'
        LEFT JOIN department d ON fclu.department_id = d.id  AND d.delete_enum = 'FALSE'
        LEFT JOIN fire_check_record cr ON cl.fire_check_id = cr.fire_check_id
        AND cr.delete_enum = 'FALSE'
        AND (
        (cl.fire_check_type = 'fireCheckPeriod0001' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.dayStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.dayEndTime} and cr.finished_flag=1)
        OR (cl.fire_check_type = 'fireCheckPeriod0002' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.weeklyStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.weeklyEndTime} and cr.finished_flag=1)
        OR (cl.fire_check_type = 'fireCheckPeriod0003' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.tenDaysStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.tenDaysEndTime} and cr.finished_flag=1)
        OR (cl.fire_check_type = 'FireCheckPeriod0004' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.monthlyStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.monthlyEndTime} and cr.finished_flag=1)
        OR (cl.fire_check_type = 'fireCheckPeriod0005' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.quarterlyStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.quarterlyEndTime} and cr.finished_flag=1)
        OR (cl.fire_check_type = 'fireCheckPeriod0006' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.yearlyStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.yearlyEndTime} and cr.finished_flag=1)
        OR (cl.fire_check_type = 'fireCheckPeriod0007' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.halfYearStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.halfYearEndTime} and cr.finished_flag=1)
        OR (cl.fire_check_type = 'fireCheckPeriod0008' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.halfMonthStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.halfMonthEndTime} and cr.finished_flag=1)
        OR (cl.fire_check_type = 'fireCheckPeriod0009' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.weeklyStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.weeklyEndTime} and cr.finished_flag=1)
        )
        WHERE
        cl.delete_enum = 'FALSE'
        AND cl.corpinfo_id = #{params.corpinfoId}
        AND cl.state = 0
        <if test="params.firePointId != null and params.firePointId != ''">
            and cli.fire_point_id =#{params.firePointId}
        </if>
        <if test="params.userId != null and params.userId != ''">
            AND fclu.user_id = #{params.userId}
        </if>

        GROUP BY cl.fire_check_id
        HAVING
        1=1
        <if test="params.checkStatus != null and params.checkStatus != ''">
            <choose>
                <when test="params.checkStatus == 1">
                    AND (cl.fire_check_type = 'fireCheckPeriod0009' OR checkedCount = 0)
                </when>
                <when test="params.checkStatus == 2">
                    AND (cl.fire_check_type = 'fireCheckPeriod0009' OR checkedCount > 0)
                </when>
            </choose>
        </if>
        ORDER BY cl.create_time desc

    </select>

    <select id="riskDistribution" resultType="com.zcloud.fire.check.persistence.dataobject.RiskDistributionDO">
        SELECT c.corp_name as corpinfoName,
               c.id as corpinfoId,
               IFNULL(r.regionCount, 0) as fireRegionCount,
               IFNULL(p.pointCount, 0)  as firePointCount,
               IFNULL(d.deviceCount, 0) as fireDeviceCount
        FROM corp_info c
                 LEFT JOIN (SELECT corpinfo_id, COUNT(*) as regionCount
                            FROM fire_region
                            WHERE delete_enum = 'FALSE'
                              AND state = 0
                            GROUP BY corpinfo_id) r ON r.corpinfo_id = c.id
                 LEFT JOIN (SELECT corpinfo_id, COUNT(*) as pointCount
                            FROM fire_point
                            WHERE delete_enum = 'FALSE'
                            GROUP BY corpinfo_id) p ON p.corpinfo_id = c.id
                 LEFT JOIN (SELECT corpinfo_id, COUNT(*) as deviceCount
                            FROM fire_device
                            WHERE delete_enum = 'FALSE'
                            GROUP BY corpinfo_id) d ON d.corpinfo_id = c.id
        WHERE c.delete_enum = 'FALSE'
           <if test="params.corpinfoId != null and params.corpinfoId != ''">
               c.corp_name LIKE '%公司%'
        </if>
        order by c.corp_order asc
    </select>
    <select id="pointDistribution" resultType="com.zcloud.fire.check.persistence.dataobject.PointDistributionDO">
        select ci.corp_name,
               r.fire_region_name      as fireRegionName,
               dept.name               as departmentName,
               p.fire_point_name       as firePointName,
               d.fire_device_type      as fireDeviceType,
               d.fire_device_type_name as fireDeviceTypeName,
               d.fire_device_code      as fireDeviceCode
        from fire_device d
                 left join fire_point p on d.fire_point_id = p.fire_point_id and p.delete_enum = 'FALSE'
                 left join fire_region r on p.fire_region_id = r.fire_region_id and r.delete_enum = 'FALSE'
                 left join corp_info ci on ci.id = d.corpinfo_id
                 left join department dept on dept.id = r.department_id
        where d.delete_enum = 'FALSE'
          and d.corpinfo_id = #{params.corpinfoId}

        <if test="params.vagueKey != null and params.vagueKey != ''">
           and (r.fire_region_name like '%${params.vagueKey}%' or p.fire_point_name like '%${params.vagueKey}%' or d.fire_device_code like '%${params.vagueKey}%' )
        </if>

    </select>
    <select id="getCheckPointList" resultType="com.zcloud.fire.check.persistence.FireCheckPointListDO">
        select fd.fire_device_id        as fireDeviceId,
               fd.fire_device_code      as fireDeviceCode,
               fd.fire_device_type      as fireDeviceType,
               fd.fire_device_type_name as fireDeviceTypeName,
               fp.fire_point_name       as firePointName,
               fp.fire_point_code       as firePointCode,
               fp.fire_point_id         as firePointId,
               fr.fire_region_name      as fireRegionName,
               fr.fire_region_code      as fireRegionCode,
               fr.fire_region_id        as fireRegionId,
               count(distinct fcs.id)                   AS standardCount
        from fire_check_list cl
                 left join fire_check_list_item cli on cl.fire_check_id = cli.fire_check_id and cli.delete_enum = 'FALSE'
                 left join fire_device fd on fd.fire_device_id = cli.fire_device_id
                 left join fire_point fp on fd.fire_point_id = fp.fire_point_id
                 left join fire_region fr on fp.fire_region_id = fr.fire_region_id
                 left join fire_check_standard fcs on fd.fire_device_type = fcs.fire_device_type and fcs.delete_enum = 'FALSE'
        where cl.delete_enum = 'FALSE'
          and fd.delete_enum = 'FALSE'
          and fp.delete_enum = 'FALSE'
          and fr.delete_enum = 'FALSE'
          and cl.fire_check_id = #{fireCheckId}
        group by fd.fire_device_id
    </select>

    <select id="getBackChecKList" resultType="com.zcloud.fire.check.persistence.dataobject.FireCheckListDO">
        select cl.id,cl.fire_check_id as fireCheckId,
               cl.fire_check_name as fireCheckName,
               d.name as departmentName,
               cl.fire_check_type as fireCheckType,
               cl.fire_check_type_name as fireCheckTypeName
        from fire_check_list cl
                 left join fire_check_list_user clu on cl.fire_check_id = clu.fire_check_id and clu.delete_enum = 'FALSE'
                 left join fire_check_record cr on cl.fire_check_id = cr.fire_check_id and cr.delete_enum = 'FALSE'
                 left join fire_check_record_point cfp on cr.fire_record_id = cfp.fire_record_id and cfp.delete_enum = 'FALSE'
                 left join fire_check_record_device crd on cr.fire_record_id = crd.fire_record_id and crd.fire_record_point_id = cfp.fire_record_point_id and crd.delete_enum = 'FALSE'
                 left join department d on clu.department_id = d.id and d.delete_enum = 'FALSE'
        where cl.delete_enum = 'FALSE'
          and clu.user_id=#{params.userId}
          and cl.state = 0
          and crd.checked_flag = 2
        group by cl.id
        order by cl.create_time desc
    </select>

    <select id="getChecKRecordList" resultType="com.zcloud.fire.check.persistence.dataobject.FireCheckListDO">
        select
               d.name as departmentName,
               cl.*
        from fire_check_list cl
                 left join fire_check_list_user clu on cl.fire_check_id = clu.fire_check_id and clu.delete_enum = 'FALSE'
                 left join fire_check_record cr on cl.fire_check_id = cr.fire_check_id and cr.delete_enum = 'FALSE'

                 left join fire_check_record_point cfp on cr.fire_record_id = cfp.fire_record_id and cfp.delete_enum = 'FALSE'
                 left join fire_check_record_device crd on cr.fire_record_id = crd.fire_record_id and crd.fire_record_point_id = cfp.fire_record_point_id and crd.delete_enum = 'FALSE'
                 left join department d on clu.department_id = d.id and d.delete_enum = 'FALSE'
                 left join user u on clu.user_id = u.id
        where cl.delete_enum = 'FALSE'
          and clu.user_id=#{params.userId}
          and cl.corpinfo_id = #{params.corpinfoId}
          and cl.state = 0
        <if test="params.fireCheckName != null and params.fireCheckName != ''">
            and cl.fire_check_name = #{params.fireCheckName}
        </if>
        <if test="params.fireCheckType != null and params.fireCheckType != ''">
            and cl.fire_check_type = #{params.fireCheckType}
        </if>
        <if test="params.departmentId != null and params.departmentId != ''">
            and clu.department_id = #{params.departmentId}
        </if>
        <if test="params.userName != null and params.userName != ''">
            and u.user_name like CONCAT('%', #{params.userName}, '%')
        </if>
        group by cl.id
        order by cl.create_time desc
    </select>

    <select id = "checkListRecordList" resultType="com.zcloud.fire.check.persistence.dataobject.FireCheckListDO">

        select
        cl.*,
        GROUP_CONCAT(DISTINCT u.name) AS userName,
        COUNT(distinct cr.id) AS checkCycleCount,
        d.name AS departmentName
        from fire_check_list cl
        LEFT JOIN fire_check_list_user fclu on cl.fire_check_id = fclu.fire_check_id
        LEFT JOIN user u ON fclu.user_id = u.id  AND u.delete_enum = 'FALSE'
        LEFT JOIN department d ON fclu.department_id = d.id  AND d.delete_enum = 'FALSE'
        LEFT JOIN fire_check_record cr ON cl.fire_check_id = cr.fire_check_id
        AND cr.delete_enum = 'FALSE'
        AND (
        (cl.fire_check_type = 'fireCheckPeriod0001' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.dayStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.dayEndTime} and cr.finished_flag=1)
        OR (cl.fire_check_type = 'fireCheckPeriod0002' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.weeklyStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.weeklyEndTime} and cr.finished_flag=1)
        OR (cl.fire_check_type = 'fireCheckPeriod0003' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.tenDaysStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.tenDaysEndTime} and cr.finished_flag=1)
        OR (cl.fire_check_type = 'FireCheckPeriod0004' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.monthlyStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.monthlyEndTime} and cr.finished_flag=1)
        OR (cl.fire_check_type = 'fireCheckPeriod0005' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.quarterlyStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.quarterlyEndTime} and cr.finished_flag=1)
        OR (cl.fire_check_type = 'fireCheckPeriod0006' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.yearlyStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.yearlyEndTime} and cr.finished_flag=1)
        OR (cl.fire_check_type = 'fireCheckPeriod0007' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.halfYearStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.halfYearEndTime} and cr.finished_flag=1)
        OR (cl.fire_check_type = 'fireCheckPeriod0008' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.halfMonthStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.halfMonthEndTime} and cr.finished_flag=1)
        OR (cl.fire_check_type = 'fireCheckPeriod0009' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.weeklyStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.weeklyEndTime} and cr.finished_flag=1)
        )
        left join fire_check_record_user cru on cr.fire_record_id = cru.fire_record_id and cru.delete_enum = 'FALSE'
        WHERE
        cl.delete_enum = 'FALSE'
        AND cl.corpinfo_id = #{params.corpinfoId}

        <if test="params.userId != null and params.userId != ''">
            AND (fclu.user_id =  #{params.userId} or cru.user_id= #{params.userId})
        </if>
        <if test="params.fireCheckName != null and params.fireCheckName != ''">
            AND cl.fire_check_name like CONCAT('%', #{params.fireCheckName}, '%')
        </if>
        <if test="params.departmentId != null and params.departmentId != ''">
            AND fclu.department_id = #{params.departmentId}
        </if>
        <if test="params.userName != null and params.userName != ''">
            AND u.name like CONCAT('%', #{params.userName}, '%')
        </if>
        <if test="params.fireCheckType != null and params.fireCheckType != ''">
            AND cl.fire_check_type = #{params.fireCheckType}
        </if>
        <if test="params.state != null and params.state != ''">
            AND cl.state = #{params.state}
        </if>
        <if test="params.stateList != null and params.stateList.size > 0 ">
            and cl.state IN
            <foreach item="item" collection="params.stateList" separator="," open="(" close=")" index="">
                #{item}
            </foreach>
        </if>

        GROUP BY cl.fire_check_id
        HAVING
        1=1
        <if test="params.checkStatus != null and params.checkStatus != ''">
            <choose>
                <when test="params.checkStatus == 1">
                    AND (cl.fire_check_type = 'fireCheckPeriod0009' OR checkCycleCount = 0)
                </when>
                <when test="params.checkStatus == 2">
                    AND (cl.fire_check_type = 'fireCheckPeriod0009' OR checkCycleCount > 0)
                </when>
            </choose>
        </if>
        ORDER BY cl.state asc, cl.create_time desc
    </select>

    <select id="getCheckListRecord" resultType="com.zcloud.fire.check.persistence.dataobject.FireCheckListDO">
        select
        cl.*,
        GROUP_CONCAT(DISTINCT u.name) AS userName,

        d.name AS departmentName
        from fire_check_list cl
        LEFT JOIN fire_check_list_user fclu on cl.fire_check_id = fclu.fire_check_id
        LEFT JOIN user u ON fclu.user_id = u.id  AND u.delete_enum = 'FALSE'
        LEFT JOIN department d ON fclu.department_id = d.id  AND d.delete_enum = 'FALSE'
        LEFT JOIN fire_check_record cr ON cl.fire_check_id = cr.fire_check_id
            AND cr.delete_enum = 'FALSE' and cr.finished_flag=1
            <if test="params.startTime != null and params.startTime != ''">
                and cr.check_time >= #{params.startTime}
            </if>
            <if test="params.endTime != null and params.endTime != ''">
                and cr.check_time <![CDATA[<=]]> #{params.endTime}
            </if>
        left join fire_check_record_user cru on cr.fire_record_id = cru.fire_record_id and cru.delete_enum = 'FALSE'
        WHERE
        cl.delete_enum = 'FALSE'
        AND cl.corpinfo_id = #{params.corpinfoId}

        <if test="params.userId != null and params.userId != ''">
            AND (fclu.user_id =  #{params.userId} or cru.user_id= #{params.userId})
        </if>
        <if test="params.fireCheckName != null and params.fireCheckName != ''">
            AND cl.fire_check_name like CONCAT('%', #{params.fireCheckName}, '%')
        </if>
        <if test="params.departmentId != null and params.departmentId != ''">
            AND fclu.department_id = #{params.departmentId}
        </if>
        <if test="params.userName != null and params.userName != ''">
            AND u.name like CONCAT('%', #{params.userName}, '%')
        </if>
        <if test="params.fireCheckType != null and params.fireCheckType != ''">
            AND cl.fire_check_type = #{params.fireCheckType}
        </if>
        <if test="params.state != null and params.state != ''">
            AND cl.state = #{params.state}
        </if>


        GROUP BY cl.fire_check_id
        ORDER BY cl.create_time desc
    </select>

    <select id="getNoFinishedCheckList" resultType="com.zcloud.fire.check.persistence.dataobject.FireCheckListDO">
        -- 待排查的记录
        select
            cl.*,
            COUNT(distinct cr.id) AS checkCycleCount
        from fire_check_list cl
                 LEFT JOIN fire_check_list_user fclu on cl.fire_check_id = fclu.fire_check_id
                 LEFT JOIN fire_check_record cr ON cl.fire_check_id = cr.fire_check_id
            AND cr.delete_enum = 'FALSE'
            AND (
               (cl.fire_check_type = 'fireCheckPeriod0001' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.dayStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.dayEndTime} and cr.finished_flag=1)
                   OR (cl.fire_check_type = 'fireCheckPeriod0002' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.weeklyStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.weeklyEndTime} and cr.finished_flag=1)
                   OR (cl.fire_check_type = 'fireCheckPeriod0003' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.tenDaysStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.tenDaysEndTime} and cr.finished_flag=1)
                   OR (cl.fire_check_type = 'FireCheckPeriod0004' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.monthlyStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.monthlyEndTime} and cr.finished_flag=1)
                   OR (cl.fire_check_type = 'fireCheckPeriod0005' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.quarterlyStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.quarterlyEndTime} and cr.finished_flag=1)
                   OR (cl.fire_check_type = 'fireCheckPeriod0006' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.yearlyStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.yearlyEndTime} and cr.finished_flag=1)
                   OR (cl.fire_check_type = 'fireCheckPeriod0007' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.halfYearStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.halfYearEndTime} and cr.finished_flag=1)
                   OR (cl.fire_check_type = 'fireCheckPeriod0008' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.halfMonthStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.halfMonthEndTime} and cr.finished_flag=1)
                   OR (cl.fire_check_type = 'fireCheckPeriod0009' AND cr.check_time <![CDATA[>=]]> #{dateTimeE.weeklyStartTime} AND cr.check_time <![CDATA[<=]]> #{dateTimeE.weeklyEndTime} and cr.finished_flag=1)
               )
        WHERE
            cl.delete_enum = 'FALSE'
          AND cl.state = 0
        GROUP BY cl.fire_check_id
        HAVING
          checkedCount = 0
        ORDER BY cl.create_time desc
    </select>
    
    <select id="overTimeRecord" resultType="com.zcloud.fire.check.persistence.dataobject.FireCheckListDO">
        select m.*
        from fire_check_list m
        WHERE m.delete_enum = 'FALSE'
          and m.state = 0
          and m.fire_check_type = #{checkType}
          and m.fire_check_id not in (select cr.fire_check_id
                                      from fire_check_record cr
                                      where cr.delete_enum = 'FALSE'
                                        and (
                                          cr.CHECK_TIME BETWEEN #{startDate} AND #{endDate}
                                          )
                                        and cr.fire_check_type = #{checkType}
                                         and cr.finished_flag=1
                                        and cr.delete_enum = 'FALSE')
    </select>
</mapper>

