Переглянути джерело

华泰重新生成保单bug

785834757 1 рік тому
батько
коміт
4a8489316d

+ 9 - 4
src/main/java/com/ydtech/modules/ins/utils/CompressUtil.java

@@ -10,6 +10,7 @@ import org.apache.commons.lang3.StringUtils;
 
 import java.io.*;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.zip.GZIPInputStream;
@@ -112,7 +113,7 @@ public class CompressUtil {
      * @param dest     解压路径
      * @param password 解压文件密码(可以为空)
      */
-    public static void unZip(String source, String dest, String password, String fileName, String licensePlate) {
+    public static void unZip(String source, String dest, String password, String fileName, String licensePlate,Boolean isBz) {
         try {
             File zipFile = new File(source);
             // 首先创建ZipFile指向磁盘上的.zip文件
@@ -139,9 +140,13 @@ public class CompressUtil {
             extractedFileList.toArray(extractedFiles);
 
             for (File f : extractedFileList) {
-                if (f.getName().contains("_bz")) {
-                    f.renameTo(new File(dest + fileName));
-                } else {
+                if(isBz) {
+                    if (f.getName().contains("_bz")) {
+                        f.renameTo(new File(dest + fileName));
+                    }
+                }
+                else
+                {
                     f.renameTo(new File(dest + fileName));
                 }
                 System.out.println(f.getAbsolutePath() + "文件解压成功!");

+ 10 - 10
src/main/java/com/ydtech/modules/order/service/impl/HuaTaiOrderApiServiceImpl.java

@@ -525,10 +525,10 @@ public class HuaTaiOrderApiServiceImpl implements HuaTaiOrderApiService {
                 for (HuaTaiInsurancePolicyPrintResponse.ElecDownLoadResultDto elecDownLoadResultDto : urlList) {
                     String url = elecDownLoadResultDto.getDownURL();
                     if (InsuranceRisk.TRAFFIC.getCode().equals(riskCode)) {
-                        crawlerPolicyPrintVo.setJqxPolicyUrl(gainCarInsPolicy(url, licensePlate + "-交强险", insAreaCompany.getId(), password) + "保单.pdf");
-                        crawlerPolicyPrintVo.setJqxFlagUrl(gainCarInsPolicy(url, licensePlate + "-交强险", insAreaCompany.getId(), password) + "标志.pdf");
+                        crawlerPolicyPrintVo.setJqxPolicyUrl(gainCarInsPolicy(url, licensePlate + "-交强险", insAreaCompany.getId(), password,false));
+                        crawlerPolicyPrintVo.setJqxFlagUrl(gainCarInsPolicy(url, licensePlate + "-交强险", insAreaCompany.getId(), password,true));
                     } else if (InsuranceRisk.BUSINESS.getCode().equals(riskCode)) {
-                        crawlerPolicyPrintVo.setSyxPolicyUrl(gainCarInsPolicy(url, licensePlate + "-商业险", insAreaCompany.getId(), password) + "保单.pdf");
+                        crawlerPolicyPrintVo.setSyxPolicyUrl(gainCarInsPolicy(url, licensePlate + "-商业险", insAreaCompany.getId(), password,false));
                     }
                     /**
                      * 先下载到本地,然后再解压到固定路径
@@ -541,9 +541,9 @@ public class HuaTaiOrderApiServiceImpl implements HuaTaiOrderApiService {
         return HttpResult.ok("下载成功", crawlerPolicyPrintVo);
     }
 
-    public String gainCarInsPolicy(String url, String fileName, String licensePlate, String password) {
+    public String gainCarInsPolicy(String url, String fileName, String licensePlate, String password,Boolean isBz) {
         String dir = "carInsPolicy/" + licensePlate + "/";
-        return FileUtil.netUrlStoreToLocal(url, dir, fileName, uploadFilePath, apiUrl + showFileUrl, password, licensePlate);
+        return FileUtil.netUrlStoreToLocal(url, dir, fileName, uploadFilePath, apiUrl + showFileUrl, password, licensePlate,isBz);
     }
 
     /**
@@ -942,10 +942,10 @@ public class HuaTaiOrderApiServiceImpl implements HuaTaiOrderApiService {
                     for (HuaTaiInsurancePolicyPrintResponse.ElecDownLoadResultDto elecDownLoadResultDto : urlList) {
                         String url = elecDownLoadResultDto.getDownURL();
                         if (InsuranceRisk.TRAFFIC.getCode().equals(jqFlag)) {
-                            crawlerPolicyPrintVo.setJqxPolicyUrl(gainCarInsPolicyNew(url, pathPrefix + insAreaCompany.getJqpolicyno() + "-" + InsuranceOrderPdf.JQBD.getDesc(), insAreaCompany.getId(), pathPrefix + insAreaCompany.getSypolicyno() + "-" + InsuranceOrderPdf.JQBD.getCode(), password, flag));
-                            crawlerPolicyPrintVo.setJqxFlagUrl(gainCarInsPolicyNew(url, pathPrefix + insAreaCompany.getJqpolicyno() + "-" + InsuranceOrderPdf.JQBZ.getDesc(), insAreaCompany.getId(), pathPrefix + insAreaCompany.getSypolicyno() + "-" + InsuranceOrderPdf.JQBZ.getCode(), password, flag));
+                            crawlerPolicyPrintVo.setJqxPolicyUrl(gainCarInsPolicyNew(url, pathPrefix + insAreaCompany.getJqpolicyno() + "-" + InsuranceOrderPdf.JQBD.getDesc(), insAreaCompany.getId(), pathPrefix + insAreaCompany.getSypolicyno() + "-" + InsuranceOrderPdf.JQBD.getCode(), password, flag,false));
+                            crawlerPolicyPrintVo.setJqxFlagUrl(gainCarInsPolicyNew(url, pathPrefix + insAreaCompany.getJqpolicyno() + "-" + InsuranceOrderPdf.JQBZ.getDesc(), insAreaCompany.getId(), pathPrefix + insAreaCompany.getSypolicyno() + "-" + InsuranceOrderPdf.JQBZ.getCode(), password, flag,true));
                         } else if (InsuranceRisk.BUSINESS.getCode().equals(jqFlag)) {
-                            crawlerPolicyPrintVo.setSyxPolicyUrl(gainCarInsPolicyNew(url, pathPrefix + insAreaCompany.getSypolicyno() + "-" + InsuranceOrderPdf.SYBD.getDesc(), insAreaCompany.getId(), pathPrefix + insAreaCompany.getSypolicyno() + "-" + InsuranceOrderPdf.SYBD.getCode(), password, flag));
+                            crawlerPolicyPrintVo.setSyxPolicyUrl(gainCarInsPolicyNew(url, pathPrefix + insAreaCompany.getSypolicyno() + "-" + InsuranceOrderPdf.SYBD.getDesc(), insAreaCompany.getId(), pathPrefix + insAreaCompany.getSypolicyno() + "-" + InsuranceOrderPdf.SYBD.getCode(), password, flag,false));
                         }
                     }
                 }
@@ -965,9 +965,9 @@ public class HuaTaiOrderApiServiceImpl implements HuaTaiOrderApiService {
      * @Date: 2024/10/18 9:37
      * @Description: 新路径
      */
-    public String gainCarInsPolicyNew(String url, String fileName, String subOrderId, String password, String path, boolean flag) {
+    public String gainCarInsPolicyNew(String url, String fileName, String subOrderId, String password, String path, boolean flag,Boolean isBz) {
         String dir = "carInsPolicyNew/" + subOrderId + "/";
-        return FileUtil.netUrlStoreToLocalNew(url, dir, fileName, uploadFilePath, apiUrl + showFileUrl,path , password, flag);
+        return FileUtil.netUrlStoreToLocalNew(url, dir, fileName, uploadFilePath, apiUrl + showFileUrl,path , password, flag,isBz);
     }
 
 }

+ 4 - 6
src/main/java/com/ydtech/utils/baidu/FileUtil.java

@@ -181,8 +181,7 @@ public class FileUtil {
 
     }
 
-    public static String netUrlStoreToLocal(String url, String dir, String fileName, String path, String showUrl, String password,
-                                            String licensePlate) {
+    public static String netUrlStoreToLocal(String url, String dir, String fileName, String path, String showUrl, String password,String licensePlate,Boolean isBz) {
         if (StringUtils.isEmpty(url)) return "";
         String showPath = String.format("%s%s%s", showUrl, dir, fileName);
         String uploadPath = path + dir;
@@ -207,7 +206,7 @@ public class FileUtil {
             File file = new File(uploadPath + licensePlate + ".zip");
             copyInputStreamToFile(inputStream, file);
 
-            CompressUtil.unZip(file.getPath(), uploadPath, password, fileName, licensePlate);
+            CompressUtil.unZip(file.getPath(), uploadPath, password, fileName, licensePlate,isBz);
             file.delete();
             return showPath;
 
@@ -298,8 +297,7 @@ public class FileUtil {
 
     }
 
-    public static String netUrlStoreToLocalNew(String url, String dir, String fileName, String path, String showUrl, String password,
-                                            String licensePlate,boolean flag) {
+    public static String netUrlStoreToLocalNew(String url, String dir, String fileName, String path, String showUrl, String password,String licensePlate,boolean flag,Boolean isBz) {
         if (StringUtils.isEmpty(url)){ return "";}
         String showPath = String.format("%s%s%s", showUrl, dir, fileName);
         String uploadPath = path + dir;
@@ -329,7 +327,7 @@ public class FileUtil {
             File file = new File(uploadPath + licensePlate + ".zip");
             copyInputStreamToFile(inputStream, file);
 
-            CompressUtil.unZip(file.getPath(), uploadPath, password, fileName, licensePlate);
+            CompressUtil.unZip(file.getPath(), uploadPath, password, fileName, licensePlate,isBz);
             file.delete();
             return showPath;