<?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.tuoheng.miniprogram.dao.InspectionMapper">
    <resultMap type="com.tuoheng.miniprogram.entity.Inspection" id="InspectionResult">
        <result property="id"    column="id"    />
        <result property="tenantId"    column="tenant_id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="code"    column="code"    />
        <result property="name"    column="name"    />
        <result property="type"    column="type"    />
        <result property="channelId"    column="channel_id"    />
        <result property="channelName"    column="channel_name"    />
        <result property="legId"    column="leg_id"    />
        <result property="legName"    column="leg_name"    />
        <result property="inspectionType"    column="inspection_type"    />
        <result property="airportId"    column="airport_id"    />
        <result property="sn"    column="sn"    />
        <result property="recordId"    column="record_id"    />
        <result property="airportName"    column="airport_name"    />
        <result property="inspectionLine"    column="inspection_line"    />
        <result property="inspectionLineName"    column="inspection_line_name"    />
        <result property="equipmentId"    column="equipment_id"    />
        <result property="equipmentName"    column="equipment_name"    />
        <result property="equipmentMountId"    column="equipment_mount_id"    />
        <result property="equipmentMountName"    column="equipment_mount_name"    />
        <result property="cloudBoxId"    column="cloud_box_id"    />
        <result property="cloudBoxName"    column="cloud_box_name"    />
        <result property="boxSn"    column="box_sn"    />
        <result property="flightHand"    column="flight_hand"    />
        <result property="flightHandName"    column="flight_hand_name"    />
        <result property="inspectionTime"    column="inspection_time"    />
        <result property="executionStartTime"    column="execution_start_time"    />
        <result property="executionEndTime"    column="execution_end_time"    />
        <result property="isLive"    column="is_live"    />
        <result property="isTaken"    column="is_taken"    />
        <result property="isTilt"    column="is_tilt"    />
        <result property="videoUrl"    column="video_url"    />
        <result property="aiVideoUrl"    column="ai_video_url"    />
        <result property="reportUrl"    column="report_url"    />
        <result property="srtUrl"    column="srt_url"    />
        <result property="status"    column="status"    />
        <result property="analyseStatus"    column="analyse_status"    />
        <result property="progressbar"    column="progressbar"    />
        <result property="note"    column="note"    />
        <result property="weather"    column="weather"    />
        <result property="flyHeight"    column="fly_height"    />
        <result property="srtName"    column="srt_name"    />
        <result property="heartbeatTime"    column="heartbeat_time"    />
        <result property="executionStatus"    column="execution_status"    />
        <result property="startLongitude"    column="start_longitude"    />
        <result property="startLatitude"    column="start_latitude"    />
        <result property="endLongitude"    column="end_longitude"    />
        <result property="endLatitude"    column="end_latitude"    />
        <result property="mobile"    column="mobile"    />
        <result property="patrolLocation"    column="patrol_location"    />
        <result property="createUser"    column="create_user"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateUser"    column="update_user"    />
        <result property="updateTime"    column="update_time"    />
        <result property="mark"    column="mark"    />
    </resultMap>


    <select id="queryPage" resultType="com.tuoheng.miniprogram.vo.InspectionInfoVo">
        select
        ti.id,
        ti.code,
        ti.name,
        ti.type,
        ti.status,
        ti.inspection_type as inspectionType,
        ti.inspection_line as inspectionLine,
        ti.inspection_line_name as inspectionLineName,
        ti.create_user as createUser,
        ti.execution_start_time as executionStartTime,
        ti.ai_video_url as aiVideoUrl
        from
        th_inspection ti
        where ti.mark=1 and ti.tenant_id = #{request.tenantId}
        <if test="request.deptId !=null and request.deptId !=''">
            and ti.dept_id = #{request.deptId}
        </if>
        <if test="request.status !=null">
            and ti.status in (10,15)
        </if>
        <if test="request.inspectionType !=null">
            and ti.inspection_type = #{request.inspectionType}
        </if>
        <if test="request.type !=null">
            and ti.type = #{request.type}
        </if>
        <if test="request.startTimeDate !=null and request.endTimeDate !=null">
            and ti.execution_start_time BETWEEN #{request.startTimeDate} AND #{request.endTimeDate}
        </if>
        ORDER BY
        ti.create_time DESC
    </select>
</mapper>