From 249d316e0b8c79b71b779b5716bc488e1d08a9b3 Mon Sep 17 00:00:00 2001
From: aix <vip_xiaobin810@163.com>
Date: Tue, 30 Jul 2024 14:48:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/ht-dev' into ht-dev

---
 src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java |   61 ++++++++++++++++--------------
 1 files changed, 33 insertions(+), 28 deletions(-)

diff --git a/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java b/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java
index 0d89bc5..919be81 100644
--- a/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java
+++ b/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java
@@ -130,6 +130,10 @@
             nailEntity.setWorkspaceId(workspaceId);
             nailEntity.setFileId(UUID.randomUUID().toString());
             nailMapper.insert(nailEntity);
+            MediaFileZipEntity zipEntity = this.fileUploadConvertToZipEntity((file));
+            zipEntity.setWorkspaceId(workspaceId);
+            zipEntity.setFileId(UUID.randomUUID().toString());
+            zipMapper.insert(zipEntity);
         } else {
             String url = pojo.getEndpoint() + "/" + pojo.getBucket() + file.getObjectKey();
             File file1 = TbFjServiceImpl.downloadFile(url);
@@ -145,37 +149,38 @@
             nailEntity.setFilePath("nail" + file.getPath());
             String nailName = nailEntity.getObjectKey();
             nailEntity.setFileId(UUID.randomUUID().toString());
+            uploadFile("http://139.196.74.78:9000", "sxkj", "sxkj2024", "cloud-bucket", file.getObjectKey(), file1, "image/jpeg");
             uploadFile(pojo.getEndpoint(), pojo.getAccessKey(), pojo.getSecretKey(), pojo.getBucket(), nailName, nailFile, "image/jpeg");
             uploadFile("http://139.196.74.78:9000", "sxkj", "sxkj2024", "cloud-bucket", nailName, nailFile, "image/jpeg");
             nailMapper.insert(nailEntity);
         }
     }
 
-//    public void saveZipFile(String workspaceId, FileUploadDTO file) throws IOException, ImageProcessingException {
-//        updateStatue(file.getName());
-//        boolean endsWith = file.getObjectKey().endsWith(".mp4");
-//        if (endsWith) {
-//            MediaFileZipEntity nailEntity = this.fileUploadConvertToZipEntity((file));
-//            nailEntity.setWorkspaceId(workspaceId);
-//            nailEntity.setFileId(UUID.randomUUID().toString());
-//            zipMapper.insert(nailEntity);
-//        } else {
-//            String url = pojo.getEndpoint() + "/" + pojo.getBucket() + file.getObjectKey();
-//            File file1 = TbFjServiceImpl.downloadFile(url);
-//            File nailFile = new File(ImgZipUtil.compressImageAndGetFile(file1, 0.5f).toURI());
-//            MediaFileZipEntity zipEntity = this.fileUploadConvertToZipEntity(file);
-//            zipEntity.setIsOriginal(false);
-//            zipEntity.setWorkspaceId(workspaceId);
-//            zipEntity.setFileName("zip" + file.getName());
-//            zipEntity.setObjectKey("/zip" + file.getPath() + "/" + file.getName());
-//            zipEntity.setFilePath("zip" + file.getPath());
-//            String nailName = zipEntity.getObjectKey();
-//            zipEntity.setFileId(UUID.randomUUID().toString());
-//            uploadFile(pojo.getEndpoint(), pojo.getAccessKey(), pojo.getSecretKey(), pojo.getBucket(), nailName, nailFile, "image/jpeg");
-//            uploadFile("http://139.196.74.78:9000", "sxkj", "sxkj2024", "cloud-bucket", nailName, nailFile, "image/jpeg");
-//            zipMapper.insert(zipEntity);
-//        }
-//    }
+    public void saveZipFile(String workspaceId, FileUploadDTO file) throws IOException, ImageProcessingException {
+        updateStatue(file.getName());
+        boolean endsWith = file.getObjectKey().endsWith(".mp4");
+        if (endsWith) {
+            MediaFileZipEntity zipEntity = this.fileUploadConvertToZipEntity((file));
+            zipEntity.setWorkspaceId(workspaceId);
+            zipEntity.setFileId(UUID.randomUUID().toString());
+            zipMapper.insert(zipEntity);
+        } else {
+            String url = pojo.getEndpoint() + "/" + pojo.getBucket() + file.getObjectKey();
+            File file1 = TbFjServiceImpl.downloadFile(url);
+            File nailFile = new File(ImgZipUtil.compressImageAndGetFile(file1, 0.5f).toURI());
+            MediaFileZipEntity zipEntity = this.fileUploadConvertToZipEntity(file);
+            zipEntity.setIsOriginal(false);
+            zipEntity.setWorkspaceId(workspaceId);
+            zipEntity.setFileName("zip" + file.getName());
+            zipEntity.setObjectKey("/zip" + file.getPath() + "/" + file.getName());
+            zipEntity.setFilePath("zip" + file.getPath());
+            String nailName = zipEntity.getObjectKey();
+            zipEntity.setFileId(UUID.randomUUID().toString());
+            uploadFile(pojo.getEndpoint(), pojo.getAccessKey(), pojo.getSecretKey(), pojo.getBucket(), nailName, nailFile, "image/jpeg");
+            uploadFile("http://139.196.74.78:9000", "sxkj", "sxkj2024", "cloud-bucket", nailName, nailFile, "image/jpeg");
+            zipMapper.insert(zipEntity);
+        }
+    }
 
     public void updateStatue(String filename) {
         if (filename.contains("~")) {
@@ -451,11 +456,11 @@
     @Override
     public ResponseResult downloadImages(List<String> jobIds) {
         try {
-            String bucketPath = "/data/software/minio-data/cloud-bucket/";
+            String bucketPath = "/data/software/minio-data/cloud-bucket";
             List<String> prefixes = getUniqueFilePaths(jobIds);
             MinioFileDownloader downloader = new MinioFileDownloader(bucketPath);
             // 下载并压缩文件到本地目录
-            String localSaveDir = "/data/software/minio-data/zip-bucket/"; // 修改为你想保存的本地目录
+            String localSaveDir = "/data/software/minio-data/zip-bucket"; // 修改为你想保存的本地目录
             downloader.downloadAndZipFolders(prefixes, localSaveDir);
         } catch (Exception e) {
             e.printStackTrace();
@@ -1051,7 +1056,7 @@
         for (MediaFileNailEntity mark : markEntities) {
             updateNailMediaFileNames(mark.getJobId());
             updateMediaFileNames(mark.getJobId());
-//            updateMediaZipFileNames(mark.getJobId());
+            updateMediaZipFileNames(mark.getJobId());
         }
     }
 

--
Gitblit v1.9.3