Przeglądaj źródła

Revert "质检-同步合同段-本地文件不存在,就通过oss获取文件"

This reverts commit 7c0127a0515acd6151f0bdd901fb2725655a8b0d.
LHB 3 tygodni temu
rodzic
commit
569370482a

+ 2 - 10
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -80,8 +80,6 @@ import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.io.*;
 import java.net.URLEncoder;
-import java.nio.file.Files;
-import java.nio.file.Path;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
@@ -1055,14 +1053,8 @@ public class InformationWriteQueryController extends BladeController {
                             oldHtml.setId(SnowFlakeUtil.getId());
                             oldHtml.setCreateUser(getUser().getUserId());
                             String htmlUrl = wbsTreeContract.getHtmlUrl();
-                            // 获取或下载文件
-                            Path sourcePath = FileUtils.getOrDownloadFile(htmlUrl);
-                            // 生成副本路径
-                            Path copyPath = FileUtils.generateCopyPath(sourcePath);
-                            // 复制文件
-                            Files.copy(sourcePath, copyPath);
-
-                            oldHtml.setOldHtmlUrl(copyPath.toFile().getAbsolutePath());
+                            String s = FileUtils.copyFileWithAbsolutePath(htmlUrl);
+                            oldHtml.setOldHtmlUrl(FileUtils.copyFileWithAbsolutePath(htmlUrl));
                             data.add(oldHtml);
                         }
                         wbsTreeContractOldHtmlClient.save(data);

+ 0 - 48
blade-service/blade-business/src/main/java/org/springblade/business/utils/FileUtils.java

@@ -31,7 +31,6 @@ import java.awt.geom.AffineTransform;
 import java.awt.image.AffineTransformOp;
 import java.awt.image.BufferedImage;
 import java.io.*;
-import java.net.URL;
 import java.net.URLEncoder;
 import java.nio.file.*;
 import java.util.Arrays;
@@ -378,11 +377,6 @@ public class FileUtils {
         try {
             // 1. 获取源文件的绝对路径
             File sourceFile = new File(sourcePath);
-            if(!sourceFile.exists()){
-                String path = getNetUrl(sourcePath);
-                InputStream ossInputStream = CommonUtil.getOSSInputStream(getNetUrl(sourcePath));
-            }
-
             String absolutePath = sourceFile.getAbsolutePath();
             System.out.println("源文件绝对路径: " + absolutePath);
 
@@ -451,46 +445,4 @@ public class FileUtils {
             throw new ServiceException("IO错误");
         }
     }
-
-    /**
-     * 获取本地文件,若不存在则从URL下载
-     */
-    public static Path getOrDownloadFile(String localPath) throws IOException {
-        Path path = Paths.get(localPath);
-
-        // 如果本地文件不存在,则从URL下载
-        if (!Files.exists(path)) {
-            System.out.println("本地文件不存在,开始下载...");
-            // 确保父目录存在
-            Path parentDir = path.getParent();
-            if (parentDir != null && !Files.exists(parentDir)) {
-                Files.createDirectories(parentDir);
-            }
-
-            // 从URL下载文件
-            try (InputStream in = CommonUtil.getOSSInputStream(getNetUrl(localPath))) {
-                Files.copy(in, path);
-                System.out.println("文件下载成功: " + path);
-            } catch (IOException e) {
-                throw new IOException("下载文件失败: " + e.getMessage(), e);
-            }
-        }
-        return path;
-    }
-
-    /**
-     * 生成带后缀的副本路径
-     */
-    public static Path generateCopyPath(Path originalPath) {
-        String suffix = "_copy";
-        String fileName = originalPath.getFileName().toString();
-        int dotIndex = fileName.lastIndexOf('.');
-
-        // 处理带扩展名和不带扩展名的文件
-        String newName = (dotIndex > 0)
-                ? fileName.substring(0, dotIndex) + suffix + fileName.substring(dotIndex)
-                : fileName + suffix;
-
-        return originalPath.resolveSibling(newName);
-    }
 }