xiangpei
2024-12-30 0a9dbf381791653ab21adfeb666faf074d57833a
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/sync/VideoPulSync.java
@@ -23,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;
@@ -31,6 +32,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
@Slf4j
@Component
@@ -48,26 +50,26 @@
    @Scheduled(cron = "0 0/1 * * * ?")
    public void get() throws IOException {
        System.out.println("同步上传......");
        log.info("同步上传");
        log.error("同步上传");
        List<String> list = FtpApche.downloadList(ftpConfig);
        if(list.size() == 0){
        if(CollectionUtils.isEmpty(list)){
            log.error("no files in ftp");
            System.out.println("ftp get 0 fileinfo");
            return;
        }
        System.out.println("ftp get all fileinfo:" + list.get(0));
        log.info("ftp get all fileinfo:" + list.get(0));
        for (String str : list) {
            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();
            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");
            FtpApche.deleteFile(str);
            buildResultEntity(fileName, fileName.substring(14, fileName.length()), "minio", uploadResult, (MultipartFile)mockMultipartFile, 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);
            }
        }
    }