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

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.usky.fire.domain.PatrolInspectionPlanSiteSon">
        <id column="id" property="id"/>
        <result column="plan_id" property="planId"/>
        <result column="site_id" property="siteId"/>
        <result column="inspection_status" property="inspectionStatus"/>
        <result column="create_time" property="createTime"/>
    </resultMap>

    <select id="planSonSiteCout" resultType="int">
        SELECT
        COUNT(*)
        FROM
        patrol_inspection_area AS pia
        JOIN patrol_inspection_plan_son AS pips ON pia.id = pips.area_id
        JOIN patrol_inspection_plan_site_son AS pipss ON pips.id = pipss.plan_id
        <where>
            pia.company_id = 1
            AND pia. ENABLE = 1
            AND pips.interval_time BETWEEN #{startTime}
            AND #{endTime}
            <if test="inspectionStatus != null and inspectionStatus!=0">
                AND pipss.inspection_status = #{inspectionStatus}
            </if>
        </where>
    </select>

</mapper>
