1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?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.ard.work.mapper.ArdFlightTaskMapper">
    <!-- 结果映射 -->
    <resultMap id="ArdFlightTaskResult" type="ArdFlightTask">
        <result property="taskId" column="task_id"/>
        <result property="boxSn" column="box_sn"/>
        <result property="boxName" column="box_name"/>
        <result property="taskName" column="task_name"/>
        <result property="videoCount" column="video_count"/>
        <result property="photoCount" column="photo_count"/>
        <result property="videoPath" column="video_path"/>
        <result property="startTime" column="start_time"/>
        <result property="endTime" column="end_time"/>
        <result property="serverId" column="server_id"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
    </resultMap>
    <!-- 查询任务记录并联接图片和视频 -->
    <select id="selectArdFlightTask" resultMap="ArdFlightTaskResult">
        SELECT
        aft.task_id,
        aft.box_sn,
        aft.box_name,
        aft.task_name,
        aft.video_count,
        aft.photo_count,
        aft.video_path,
        aft.start_time,
        aft.end_time,
        aft.server_id,
        aft.create_by,
        aft.create_time,
        aft.update_by,
        aft.update_time,
        aft.remark
        FROM ard_flight_task aft
        <where>
            <trim prefix="" suffix="" suffixOverrides="AND,OR">
                <if test="taskId != null">AND aft.task_id = #{taskId}</if>
                <if test="boxSn != null">AND aft.box_sn = #{boxSn}</if>
                <if test="boxName != null">AND aft.box_name LIKE CONCAT('%', #{boxName}, '%')</if>
                <if test="taskName != null">AND aft.task_name LIKE CONCAT('%', #{taskName}, '%')</if>
                <if test="startTime != null">AND aft.start_time &gt;= #{startTime}</if>
                <if test="endTime != null">AND aft.end_time &lt;= #{endTime}</if>
                <if test="serverId != null">AND aft.server_id = #{serverId}</if>
            </trim>
        </where>
        ORDER BY aft.task_id DESC
    </select>
 
    <!-- 插入飞行任务 -->
    <insert id="insertArdFlightTask" parameterType="com.ard.work.domain.entity.ArdFlightTask">
        insert into ard_flight_task
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskId != null">task_id,</if>
            <if test="boxSn != null">box_sn,</if>
            <if test="boxName != null">box_name,</if>
            <if test="taskName != null">task_name,</if>
            <if test="videoCount != null">video_count,</if>
            <if test="photoCount != null">photo_count,</if>
            <if test="videoPath != null">video_path,</if>
            <if test="startTime != null">start_time,</if>
            <if test="endTime != null">end_time,</if>
            <if test="serverId != null">server_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskId != null">#{taskId},</if>
            <if test="boxSn != null">#{boxSn},</if>
            <if test="boxName != null">#{boxName},</if>
            <if test="taskName != null">#{taskName},</if>
            <if test="videoCount != null">#{videoCount},</if>
            <if test="photoCount != null">#{photoCount},</if>
            <if test="videoPath != null">#{videoPath},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="endTime != null">#{endTime},</if>
            <if test="serverId != null">#{serverId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>
 
 
    <!-- 根据任务ID获取飞行任务 -->
    <select id="getArdFlightTaskById" resultType="ArdFlightTask">
        SELECT *
        FROM ard_flight_task
        WHERE task_id = #{taskId}
    </select>
 
 
    <!-- 获取某个时间戳后的任务 -->
    <select id="getTasksAfter" resultType="ArdFlightTask">
        SELECT *
        FROM ard_flight_task
        WHERE end_time > #{lastSyncTime}
    </select>
    <select id="findMaxStartTimeByServerId" resultType="java.util.Date">
        SELECT MAX(start_time)
        FROM ard_flight_task
        WHERE server_id = #{serverId}
    </select>
</mapper>