<?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.admin.mapper.ReportMapper">
    
    <resultMap type="com.tuoheng.admin.entity.Report" id="ReportResult">
        <result property="id"    column="id"    />
        <result property="tenantId"    column="tenant_id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="reportCode"    column="report_code"    />
        <result property="inspectionId"    column="inspection_id"    />
        <result property="inspectionCode"    column="inspection_code"    />
        <result property="inspectionName"    column="inspection_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="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="autoGenerate"    column="auto_generate"    />
        <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>

    <sql id="selectReportVo">
        select id, tenant_id, dept_id, report_code, inspection_id, inspection_code, inspection_name, type, channel_id, channel_name, leg_id, leg_name, inspection_type, airport_id, airport_name, inspection_line, inspection_line_name, equipment_id, equipment_name, equipment_mount_id, equipment_mount_name, cloud_box_id, cloud_box_name, box_sn, flight_hand, flight_hand_name, inspection_time, execution_start_time, execution_end_time, is_live, is_taken, is_tilt, video_url, ai_video_url, report_url, srt_url, status, analyse_status, progressbar, note, weather, fly_height, srt_name, heartbeat_time, execution_status, auto_generate, start_longitude, start_latitude, end_longitude, end_latitude, mobile, patrol_location, create_user, create_time, update_user, update_time, mark from th_report
    </sql>

    <select id="selectPageList" parameterType="com.tuoheng.admin.request.report.QueryReportPageListRequest" resultMap="ReportResult">
        <include refid="selectReportVo"/>
        <where>
            <if test="1 == 1"> and mark = 1 </if>
            <if test="request.tenantId != null and request.tenantId != ''"> and tenant_id = #{request.tenantId} </if>
            <if test="request.inspectionCode!= null and request.inspectionCode != ''"> and inspection_code like concat('%', #{request.inspectionCode}, '%') </if>
            <if test="request.airportId != null and request.airportId != 0"> and airport_id = #{request.airportId} </if>
            <if test="request.type != null and request.type != 0"> and type = #{request.type} </if>
            <if test="request.deptIdList != null and request.deptIdList.size() > 0">
                and dept_id in
                <foreach item="deptId" collection="request.deptIdList" open="(" separator="," close=")">
                    #{deptId}
                </foreach>
            </if>
        </where>
        order by create_time desc
    </select>

</mapper>