From 5c2a50c544bb637bb57c6deee3601c88e7d6c6a4 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期一, 30 十二月 2024 11:40:52 +0800
Subject: [PATCH] 日志输出

---
 ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/sync/VideoPulSync.java |   37 +++++++++++++++++++++----------------
 1 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/sync/VideoPulSync.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/sync/VideoPulSync.java
index 192eda8..3a0db25 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/sync/VideoPulSync.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/sync/VideoPulSync.java
@@ -2,6 +2,8 @@
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.SerializationFeature;
+import lombok.extern.slf4j.Slf4j;
+import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.utils.DateUtils;
 import org.dromara.common.oss.core.OssClient;
 import org.dromara.common.oss.entity.SynchronousRequest;
@@ -21,6 +23,7 @@
 import org.springframework.mock.web.MockMultipartFile;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
@@ -29,7 +32,9 @@
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Objects;
 
+@Slf4j
 @Component
 public class VideoPulSync {
 
@@ -43,28 +48,28 @@
         this.baseMapper = baseMapper;
     }
 
-//    @Scheduled(cron = "0 0/1 * * * ?")
+    @Scheduled(cron = "0 0/1 * * * ?")
     public void get() throws IOException {
-        System.out.println("鍚屾涓婁紶......");
-
+        log.error("鍚屾涓婁紶");
         List<String> list = FtpApche.downloadList(ftpConfig);
-        if(list.size() == 0){
+
+        if(CollectionUtils.isEmpty(list)){
+            log.error("no files in ftp");
             return;
         }
+        log.error("ftp get all fileinfo锛�" + list.get(0));
         for (String str : list) {
-            //瀵嗙爜
-            String password = str.substring(0,6);
-            //鏂囦欢鍚嶇О
-            String fileName = str.substring(6,str.length());
+            String password = str.substring(0, 6);
+            String fileName = str.substring(6, str.length());
             InputStream input = FtpApche.downloadFileFromDailyDir(str);
-            byte[] fileBytesByName = FtpApche.getFileBytesByName(input);
-            OssClient storage = OssFactory.instance();
-            UploadResult uploadResult = storage.upload(input,getPath(fileName),fileName.substring(14,fileName.length()));
-            FtpApche.deleteFile(str);
-            MultipartFile file = new MockMultipartFile(fileName,fileName, fileName.substring(14,fileName.length()), input);
-            buildResultEntity(fileName, fileName.substring(14,fileName.length()), "minio", uploadResult, file,
-                password, fileBytesByName);
-
+            if (Objects.nonNull(input)) {
+                byte[] fileBytesByName = FtpApche.getFileBytesByName(input);
+                OssClient storage = OssFactory.instance();
+                MockMultipartFile mockMultipartFile = new MockMultipartFile(fileName, fileName, fileName.substring(14, fileName.length()), input);
+                UploadResult uploadResult = storage.uploadSuffix2(fileBytesByName, getPath(fileName), "multipart/form-data; charset=ISO-8859-1");
+                buildResultEntity(fileName, fileName.substring(14, fileName.length()), "minio", uploadResult, (MultipartFile)mockMultipartFile, password, fileBytesByName);
+                FtpApche.deleteFile(str);
+            }
         }
 
     }

--
Gitblit v1.8.0