zhaowenyu
2026-02-12 983e76d2aed7d3f123bf39ec9df569023f7ce47f
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?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="flightDuration" column="flight_duration"/>
        <result property="flightMileage" column="flight_mileage"/>
        <result property="aveSpeed" column="ave_speed"/>
        <result property="maxSpeed" column="max_speed"/>
        <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.flight_duration,
        aft.flight_mileage,
        aft.ave_speed,
        aft.max_speed,
        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>
                <if test="params.beginTime != null"><!-- 开始时间检索 -->
                    AND aft.create_time &gt;= #{params.beginTime}
                </if>
                <if test="params.endTime != null"><!-- 结束时间检索 -->
                    AND aft.create_time &lt;= #{params.endTime}
                </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="flightDuration != null">flight_duration,</if>
            <if test="flightMileage != null">flight_mileage,</if>
            <if test="aveSpeed != null">ave_speed,</if>
            <if test="maxSpeed != null">max_speed,</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="flightDuration != null">#{flightDuration},</if>
            <if test="flightMileage != null">#{flightMileage},</if>
            <if test="aveSpeed != null">#{aveSpeed},</if>
            <if test="maxSpeed != null">#{maxSpeed},</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>
 
    <update id="updateArdFlightTask" parameterType="com.ard.work.domain.entity.ArdFlightTask">
        update ard_flight_task
        <set>
            <if test="taskId != null">task_id = #{taskId},</if>
            <if test="boxSn != null">box_sn = #{boxSn},</if>
            <if test="boxName != null">box_name = #{boxName},</if>
            <if test="taskName != null">task_name = #{taskName},</if>
            <if test="videoCount != null">video_count = #{videoCount},</if>
            <if test="photoCount != null">photo_count = #{photoCount},</if>
            <if test="videoPath != null">video_path = #{videoPath},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="endTime != null">end_time = #{endTime},</if>
            <if test="flightDuration != null">flight_duration = #{flightDuration},</if>
            <if test="flightMileage != null">flight_mileage = #{flightMileage},</if>
            <if test="aveSpeed != null">ave_speed = #{aveSpeed},</if>
            <if test="maxSpeed != null">max_speed = #{maxSpeed},</if>
            <if test="serverId != null">server_id = #{serverId},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </set>
        where task_id = #{taskId}
    </update>
 
    <!-- 根据任务ID获取飞行任务 -->
    <select id="getArdFlightTaskById" resultMap="ArdFlightTaskResult">
        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>