Kaynağa Gözat

合并兼容

chenendian 21 saat önce
ebeveyn
işleme
bc5bc0dc78

+ 18 - 20
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/utils/ServiceFileUtil.java

@@ -1,5 +1,6 @@
 package com.siwei.apply.utils;
 
+import com.siwei.apply.common.Constant;
 import com.siwei.common.core.exception.ServiceException;
 import com.siwei.common.core.utils.DateUtils;
 import com.siwei.common.core.utils.StringUtils;
@@ -21,7 +22,6 @@ import java.util.zip.ZipOutputStream;
 
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.springframework.web.util.UriComponentsBuilder;
 
 import javax.servlet.http.HttpServletResponse;
 
@@ -314,16 +314,22 @@ public class ServiceFileUtil {
      * @param destinationPath
      * @throws IOException
      */
-    public static void downloadFile(String fileURL,String fileName, String destinationPath) throws IOException {
-        String newUrl = "";
-        if(StringUtils.contains(fileName,"&")){
-            newUrl = StringUtils.replace(fileURL, "&fileName="+fileName, "");
-        }else {
-            newUrl = fileURL.replaceAll("&fileName=[^&]*$", "");
+    public static void downloadFile(String fileURL,String fileName, String destinationPath,String fromRoute) throws IOException {
+        String fullUrl= "";
+        if(Constant.GG.equalsIgnoreCase(fromRoute)){
+            String newUrl = "";
+            if(StringUtils.contains(fileName,"&")){
+                newUrl = StringUtils.replace(fileURL, "&fileName="+fileName, "");
+            }else {
+                newUrl = fileURL.replaceAll("&fileName=[^&]*$", "");
+            }
+            String encodeFileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8);
+            // 拼接合法URL
+            fullUrl = newUrl + "&fileName=" + encodeFileName;
+        }else if(Constant.BDC.equalsIgnoreCase(fromRoute)){
+            fullUrl = fileURL;
         }
-        String encodeFileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8);
-        // 拼接合法URL
-        String fullUrl = newUrl + "&fileName=" + encodeFileName;
+
         URL url = new URL(fullUrl);
         HttpURLConnection connection = (HttpURLConnection) url.openConnection();
         connection.setRequestMethod("GET");
@@ -352,11 +358,6 @@ public class ServiceFileUtil {
     }
 
 
-
-
-
-
-
     public static void test() throws Exception {
         Path dirPath = Paths.get("C:\\Users\\Administrator\\Desktop\\01\\一码管地相关\\数据库.docx");
         String extension = FilenameUtils.getExtension(dirPath.toString());
@@ -369,14 +370,11 @@ public class ServiceFileUtil {
     public static void main(String[] args) {
         System.out.println("==========start=============");
         try {
-
             String baseUrl = "http://10.224.130.138:7071/aplanmis-rest/province/downDzzzFileByFileId?fileId=605028ecf919500a380acc5a&fileName=阳光三路工程规划许可证申请表.pdf";
             String fileName = "阳光三路工程规划许可证申请表.pdf";
-
             String savePath = "C:\\home\\siwei\\uploadPath\\2026\\06\\13\\建设用地规划许可_20260613182743A035_20260613182743A036\\建设工程规划许可证申请表";
-            downloadFile(baseUrl, fileName, savePath);
-
-            downloadFile(baseUrl,fileName,savePath);
+            downloadFile(baseUrl, fileName, savePath,Constant.GG);
+            downloadFile(baseUrl,fileName,savePath,Constant.GG);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }

+ 2 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/utils/ServiceUtil.java

@@ -36,6 +36,8 @@ public class ServiceUtil {
 
 
 
+
+
     /**
      * 获取指定目录下的子children list
      *