Browse Source

统一路径

huangtf 2 years ago
parent
commit
ebcd40d1fb

+ 12 - 0
blade-service/blade-archive/pom.xml

@@ -67,6 +67,12 @@
             <version>2.9.1.RELEASE</version>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>org.springblade</groupId>
+            <artifactId>blade-system-api</artifactId>
+            <version>2.9.1.RELEASE</version>
+            <scope>compile</scope>
+        </dependency>
         <dependency>
             <groupId>org.springblade</groupId>
             <artifactId>blade-core-cloud</artifactId>
@@ -120,6 +126,12 @@
             <groupId>org.springframework</groupId>
             <artifactId>spring-messaging</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.springblade</groupId>
+            <artifactId>blade-system-api</artifactId>
+            <version>2.9.1.RELEASE</version>
+            <scope>compile</scope>
+        </dependency>
 
     </dependencies>
 

+ 8 - 5
blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchiveAutoPdfServiceImpl.java

@@ -19,6 +19,7 @@ import org.springblade.archive.utils.FileUtils;
 import org.springblade.archive.utils.FormulaUtil;
 import org.springblade.business.entity.ArchiveFile;
 import org.springblade.business.feign.ArchiveFileClient;
+import org.springblade.common.constant.CommonConstant;
 import org.springblade.common.constant.OssConstant;
 import org.springblade.common.utils.CommonUtil;
 import org.springblade.common.utils.SnowFlakeUtil;
@@ -30,6 +31,7 @@ import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.core.tool.utils.ResourceUtil;
 import org.springblade.core.tool.utils.StringUtil;
 import org.springblade.resource.feign.NewIOSSClient;
+import org.springblade.system.cache.ParamCache;
 import org.springframework.stereotype.Service;
 
 
@@ -81,7 +83,8 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
 //        files.add(file2);
 //        BladeFile bladeFile = newIOSSClient.uploadFile1(file2,"123");
 
-        String file_path = "D:\\tmp";
+        String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+        boolean flag = FileUtils.LocalPath.equals(file_path);
         String excelUrl = file_path +  "\\备考表.xlsx";
 
         Map<String, Object> DataInfo = new HashMap<>();
@@ -265,8 +268,8 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
             String url = getPdfFileUrl(f);
             urls.add(url);
         }
-
-        List<String> pageUrls = FileUtils.doForPageNumberUseItextpdf(urls,newIOSSClient);
+        String localPath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+        List<String> pageUrls = FileUtils.doForPageNumberUseItextpdf(urls,localPath,newIOSSClient);
         for(int i=0;i<waitArchiveFiles.size();i++){
             waitArchiveFiles.get(i).setPdfPageUrl(pageUrls.get(i));
         }
@@ -286,7 +289,7 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
         // Step 1: Get the list of formulas using archiveFormulaConfigService
         List<ArchiveFormulaConfig> formulaConfigs = archiveFormulaConfigService.getByNumber(number);
 
-        String file_path = FileUtils.LocalPath;
+        String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
         String excelUrl = getUrlByNumber(number);
         Map<String, Object> dataInfo = new HashMap<>();
 
@@ -751,7 +754,7 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
     public String MergePdfAndUpload(List<String> urlList,String fileName,String filePath,Long pojectId) {
        String url = "";
        Long id = SnowFlakeUtil.getId();
-       String localPdf = FileUtils.LocalPath + "/pdf/" + id + ".pdf";
+       String localPdf = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL) + "/pdf/" + id + ".pdf";
 
        try {
             //合并pdf

+ 2 - 2
blade-service/blade-archive/src/main/java/org/springblade/archive/utils/FileUtils.java

@@ -426,7 +426,7 @@ public class FileUtils {
      * @Author yangyj
      * @Date 2021.12.17 14:21
      **/
-    public static List<String> doForPageNumberUseItextpdf(List<String> uris, NewIOSSClient newIOSSClient)  {
+    public static List<String> doForPageNumberUseItextpdf(List<String> uris, String localPath ,NewIOSSClient newIOSSClient)  {
         List<String> result = new ArrayList<>();
         if(uris!= null && uris.size() > 0){
             int cursor=0;
@@ -487,7 +487,7 @@ public class FileUtils {
                     pdfStamper.close();
                     page = page + "-" + cursor + ".pdf";
                     String fileName = fileNameWithoutExtension +  "-" +  page;
-                    String filePath = LocalPath + fileName;
+                    String filePath = localPath + fileName;
                     if (newIOSSClient!= null ) {
                         BladeFile bladeFile  = newIOSSClient.updateFile(out.toByteArray(),fileName);
                         result.add(bladeFile.getLink());