<?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="org.springblade.modules.business.equipment.inspection.plan.mapper.EquipmentInspectionPlanMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="inspectionInfoResultMap"
               type="org.springblade.modules.business.equipment.inspection.plan.entity.EquipmentInspectionPlanEntity">
        <result column="inspection_id" property="inspectionId"/>
        <result column="plan_title" property="planTitle"/>
        <result column="plan_scheduled_type" property="planScheduledType"/>
        <result column="time_type" property="timeType"/>
        <result column="plan_status" property="planStatus"/>
        <result column="org_id" property="orgId"/>
        <result column="project_id" property="projectId"/>
        <result column="inspection_complete_time" property="inspectionCompleteTime"/>
        <result column="inspection_start_time" property="beforeRainSeasonStartTime"/>
        <result column="inspection_end_time" property="beforeRainSeasonEndTime"/>
        <result column="before_rain_season_start_time" property="beforeRainSeasonStartTime"/>
        <result column="before_rain_season_end_time" property="beforeRainSeasonEndTime"/>
        <result column="rain_season_first_start_time" property="rainSeasonFirstStartTime"/>
        <result column="rain_season_first_end_time" property="rainSeasonFirstEndTime"/>
        <result column="rain_season_second_start_time" property="rainSeasonSecondStartTime"/>
        <result column="rain_season_second_end_time" property="rainSeasonSecondEndTime"/>
        <result column="plan_desc" property="planDesc"/>
        <result column="batch_id" property="batchId"/>

    </resultMap>


    <resultMap id="inspectionInfoVOResultMap"
               type="org.springblade.modules.business.equipment.inspection.plan.vo.EquipmentInspectionPlanVO">
        <result column="inspection_id" property="inspectionId"/>
        <result column="plan_title" property="planTitle"/>
        <result column="plan_scheduled_type" property="planScheduledType"/>
        <result column="time_type" property="timeType"/>
        <result column="plan_status" property="planStatus"/>
        <result column="org_id" property="orgId"/>
        <result column="project_id" property="projectId"/>
        <result column="inspection_complete_time" property="inspectionCompleteTime"/>
        <result column="inspection_start_time" property="beforeRainSeasonStartTime"/>
        <result column="inspection_end_time" property="beforeRainSeasonEndTime"/>
        <result column="before_rain_season_start_time" property="beforeRainSeasonStartTime"/>
        <result column="before_rain_season_end_time" property="beforeRainSeasonEndTime"/>
        <result column="rain_season_first_start_time" property="rainSeasonFirstStartTime"/>
        <result column="rain_season_first_end_time" property="rainSeasonFirstEndTime"/>
        <result column="rain_season_second_start_time" property="rainSeasonSecondStartTime"/>
        <result column="rain_season_second_end_time" property="rainSeasonSecondEndTime"/>
        <result column="plan_desc" property="planDesc"/>
        <result column="batch_id" property="batchId"/>

    </resultMap>

    <select id="selectPage" resultMap="inspectionInfoVOResultMap">
        SELECT
        n.*
        FROM
        equipment_inspection_plan n
        WHERE
        n.is_deleted = 0
        <if test="planDTO.planScheduledType!=null">
            and n.plan_scheduled_type =  #{planDTO.planScheduledType}
        </if>
    </select>


    <select id="planCount" resultType="java.lang.Long">
        SELECT
        count(*)
        FROM
        equipment_inspection_plan n
        WHERE
        n.is_deleted = 0
        <if test="planDTO.orgId!=null">
            and n.org_id = #{planDTO.orgId}
        </if>
        <if test="planDTO.planScheduledType!=null">
            and n.plan_scheduled_type = #{planDTO.planScheduledType}
        </if>

    </select>

</mapper>
