From e0a6ad18bb69cdba48064327a439efca5673dcf1 Mon Sep 17 00:00:00 2001
From: liusuyi <1951119284@qq.com>
Date: Fri, 19 Dec 2025 09:57:01 +0800
Subject: [PATCH] 增加无人机在线离线事件监听 增加飞行轨迹业务处理

---
 ard-work/src/main/java/com/ard/work/service/impl/ArdFlightTaskServiceServiceImpl.java |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/ard-work/src/main/java/com/ard/work/service/impl/ArdFlightTaskServiceServiceImpl.java b/ard-work/src/main/java/com/ard/work/service/impl/ArdFlightTaskServiceServiceImpl.java
index 1627d98..567e7f7 100644
--- a/ard-work/src/main/java/com/ard/work/service/impl/ArdFlightTaskServiceServiceImpl.java
+++ b/ard-work/src/main/java/com/ard/work/service/impl/ArdFlightTaskServiceServiceImpl.java
@@ -135,6 +135,10 @@
                     .serverId(serverId)
                     .startTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, boxHistoryReceiver.getStartTime()))
                     .endTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, boxHistoryReceiver.getEndTime()))
+                    .flightMileage(boxHistoryReceiver.getFlightMileage())
+                    .flightDuration(boxHistoryReceiver.getFlightDuration())
+                    .aveSpeed(boxHistoryReceiver.getAveSpeed())
+                    .maxSpeed(boxHistoryReceiver.getMaxSpeed())
                     .build();
 
             Long flyUserId = uavControlService.getCurrentController(flightTask.getBoxSn(), "fly");
@@ -196,10 +200,6 @@
         if (needUpdate) {
             ardFlightTaskMapper.updateArdFlightTask(local);
         }
-
-        // 其它媒体增量更新
-        updateVideoToDatabase(local, remote.getVideoPathList());
-        updatePhotoToDatabase(local, local.getServerId(), remote.getBoxSn());
     }
 
 
@@ -283,12 +283,13 @@
         if (videoPathList == null) {
             return;
         }
-        Integer count = flightTask.getVideoCount();//获取本地库视频数量
+        // 需要插入新的视频
+        List<ArdMedia> existingVideos = ardMediaMapper.selectArdMediaByTaskIdAndType(flightTask.getTaskId(), 1);
+        Integer count = existingVideos.size();//获取本地库视频数量
         int size = videoPathList.size();//获取接口返回的视频数量
         if (count != null && size > count) {
             log.info("任务【{}】录像数量不一致,需要更新数据库", flightTask.getTaskId());
-            // 需要插入新的视频
-            List<ArdMedia> existingVideos = ardMediaMapper.selectArdMediaByTaskIdAndType(flightTask.getTaskId(), 1);
+
             // 提取现有的视频路径
             List<String> existingVideoPaths = existingVideos.stream()
                     .map(ArdMedia::getSourceUrl) // 获取每个视频的 URL
@@ -373,7 +374,10 @@
     }
 
     private void updatePhotoToDatabase(ArdFlightTask flightTask, String serverId, String boxSn) {
-        int count = flightTask.getPhotoCount(); //获取本地库图片数量
+
+        // 获取本地数据库中已存在的图片记录(类型为 0 表示图片)
+        List<ArdMedia> existingPhotos = ardMediaMapper.selectArdMediaByTaskIdAndType(flightTask.getTaskId(), 0);
+        int count = existingPhotos.size(); //获取本地库图片数量
         // 查询图片
         BoxPhotosDTO boxPhotosDTO = BoxPhotosDTO.builder()
                 .taskId(flightTask.getTaskId())
@@ -387,8 +391,6 @@
 
         if (size > count) {
             log.info("任务【{}】图片数量不一致,需要更新数据库", flightTask.getTaskId());
-            // 获取本地数据库中已存在的图片记录(类型为 0 表示图片)
-            List<ArdMedia> existingPhotos = ardMediaMapper.selectArdMediaByTaskIdAndType(flightTask.getTaskId(), 0);
             // 需要插入新的视频
             // 提取现有的图片路径(根据 imgUrl 来判断是否重复)
             List<String> existingPhotoUrls = existingPhotos.stream()
@@ -449,7 +451,6 @@
                     });
         }
     }
-
 
     // 获取文件大小
     private long getFileSizeByUrl(String fileUrl) {

--
Gitblit v1.9.3