From 0d02d968ba0626009dfddfccda2ded84a118a88c Mon Sep 17 00:00:00 2001
From: rain <167982779@qq.com>
Date: Wed, 17 Jul 2024 10:49:45 +0800
Subject: [PATCH] 新增临时文件自动删除定时器,增加巡河喊话,修改水印文件上传方式
---
src/main/java/com/dji/sample/media/service/impl/MediaServiceImpl.java | 21 ++++++---------------
1 files changed, 6 insertions(+), 15 deletions(-)
diff --git a/src/main/java/com/dji/sample/media/service/impl/MediaServiceImpl.java b/src/main/java/com/dji/sample/media/service/impl/MediaServiceImpl.java
index 78afc16..cf44939 100644
--- a/src/main/java/com/dji/sample/media/service/impl/MediaServiceImpl.java
+++ b/src/main/java/com/dji/sample/media/service/impl/MediaServiceImpl.java
@@ -25,6 +25,7 @@
import com.dji.sample.media.service.IMediaService;
import com.dji.sample.wayline.model.dto.WaylineJobDTO;
import com.dji.sample.wayline.service.IWaylineJobService;
+import com.drew.imaging.ImageProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -88,7 +89,7 @@
}
@Override
- public Integer saveMediaFile(String workspaceId, FileUploadDTO file) {
+ public Integer saveMediaFile(String workspaceId, FileUploadDTO file){
return fileService.saveFile(workspaceId, file);
}
@@ -131,7 +132,7 @@
* @return
*/
@ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_FILE_UPLOAD_CALLBACK, outputChannel = ChannelName.OUTBOUND_EVENTS)
- public CommonTopicReceiver handleFileUploadCallBack(CommonTopicReceiver receiver) throws IOException, FontFormatException {
+ public CommonTopicReceiver handleFileUploadCallBack(CommonTopicReceiver receiver) throws IOException, FontFormatException, ImageProcessingException {
FileUploadCallback callback = objectMapper.convertValue(receiver.getData(), FileUploadCallback.class);
if (callback.getResult() != ResponseResult.CODE_SUCCESS) {
log.error("媒体文件上传失败;Media file upload failed!");
@@ -217,7 +218,7 @@
BizCodeEnum.FILE_UPLOAD_CALLBACK.getCode(), mediaFileCount);
}
- private Boolean parseMediaFile(FileUploadCallback callback, WaylineJobDTO job) throws IOException, FontFormatException {
+ private Boolean parseMediaFile(FileUploadCallback callback, WaylineJobDTO job) {
// Set the drone sn that shoots the media
Optional<DeviceDTO> dockDTO = deviceService.getDeviceBySn(job.getDockSn());
dockDTO.ifPresent(dock -> callback.getFile().getExt().setSn(dock.getChildDeviceSn()));
@@ -225,23 +226,13 @@
// set path
String objectKey = callback.getFile().getObjectKey();
callback.getFile().setPath(objectKey.substring(objectKey.indexOf("/") + 1, objectKey.lastIndexOf("/")));
- try {
- ExecutorService executor = Executors.newSingleThreadExecutor();
- executor.execute(() -> {
+ int count =fileService.saveFile(job.getWorkspaceId(), callback.getFile());
try {
fileService.saveMarkFile(job.getWorkspaceId(), callback.getFile());
} catch (Exception e) {
throw new RuntimeException(e);
}
- });
- executor.shutdown();
- } catch (Exception e) {
- log.error("方法执行有误==============: ", e);
- throw e;
- }
-
-
- return fileService.saveFile(job.getWorkspaceId(), callback.getFile()) > 0;
+ return count > 0;
}
/**
--
Gitblit v1.9.3