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