From d85eddf40bc7d5db0c8f4ec6cd74ade775ff2c57 Mon Sep 17 00:00:00 2001
From: Xiajijian <1176061145@qq.com>
Date: Wed, 26 Nov 2025 10:23:18 +0800
Subject: [PATCH] 1.增加缓存航线信息。
---
ard-work/src/main/java/com/ard/work/service/impl/ArdFlightTaskServiceServiceImpl.java | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 51 insertions(+), 1 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 a0d5290..1627d98 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
@@ -1,5 +1,8 @@
package com.ard.work.service.impl;
+import com.ard.common.constant.CacheConstants;
+import com.ard.common.core.domain.entity.SysUser;
+import com.ard.common.core.redis.RedisCache;
import com.ard.common.utils.DateUtils;
import com.ard.common.utils.file.MimeTypeUtils;
import com.ard.common.utils.uuid.IdUtils;
@@ -16,8 +19,10 @@
import com.ard.work.mapper.ArdMediaMapper;
import com.ard.work.service.IArdFlightTaskService;
import com.ard.work.service.IArdServerInfoService;
+import com.ard.work.service.control.UavControlService;
import com.ard.work.util.osSelect;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
@@ -57,7 +62,10 @@
private OssServiceContext ossServiceContext;
@Resource
private ThreadPoolTaskExecutor threadPoolTaskExecutor; // 使用线程池执行异步任务
-
+ @Resource
+ private UavControlService uavControlService;
+ @Autowired
+ private RedisCache redisCache;
/**
* 查询飞行架次列表
*
@@ -128,6 +136,14 @@
.startTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, boxHistoryReceiver.getStartTime()))
.endTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, boxHistoryReceiver.getEndTime()))
.build();
+
+ Long flyUserId = uavControlService.getCurrentController(flightTask.getBoxSn(), "fly");
+ if (flyUserId != null) {
+ SysUser flyUser = redisCache.getCacheObject(CacheConstants.SYS_USER_KEY + flyUserId);
+ if (flyUser != null && flyUser.getNickName() != null) {
+ flightTask.setCreateBy(flyUser.getNickName());
+ }
+ }
flightTask.setCreateTime(DateUtils.getNowDate());
// 插入新记录
int rows = ardFlightTaskMapper.insertArdFlightTask(flightTask);
@@ -144,6 +160,7 @@
} else {
// 如果存在,则更新记录
log.debug("Updating task {}", boxHistoryReceiver.getTaskId());
+ updateFlightTask(ardFlightTask, boxHistoryReceiver);
// 增量更新
updateVideoToDatabase(ardFlightTask, boxHistoryReceiver.getVideoPathList());
// 增量更新图片
@@ -151,6 +168,39 @@
}
}
+ private void updateFlightTask(ArdFlightTask local, BoxHistoryReceiver remote) {
+
+ boolean needUpdate = false;
+
+ // endTime 更新(重要!!!)
+ Date newEnd = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, remote.getEndTime());
+ if (newEnd != null && (local.getEndTime() == null || !local.getEndTime().equals(newEnd))) {
+ local.setEndTime(newEnd);
+ needUpdate = true;
+ }
+
+ // photoCount 更新
+ int remotePhotoCount = Integer.parseInt(remote.getPhotoCount());
+ if (local.getPhotoCount() != remotePhotoCount) {
+ local.setPhotoCount(remotePhotoCount);
+ needUpdate = true;
+ }
+
+ // videoCount 更新
+ int remoteVideoCount = remote.getVideoPathList() != null ? remote.getVideoPathList().size() : 0;
+ if (local.getVideoCount() != remoteVideoCount) {
+ local.setVideoCount(remoteVideoCount);
+ needUpdate = true;
+ }
+
+ if (needUpdate) {
+ ardFlightTaskMapper.updateArdFlightTask(local);
+ }
+
+ // 其它媒体增量更新
+ updateVideoToDatabase(local, remote.getVideoPathList());
+ updatePhotoToDatabase(local, local.getServerId(), remote.getBoxSn());
+ }
// 调用接口获取飞行历史数据
--
Gitblit v1.9.3