Kaynağa Gözat

Merge remote-tracking branch 'origin/test' into test

Qchen 2 yıl önce
ebeveyn
işleme
01aef335d9

+ 23 - 67
src/main/java/com/ydtech/modules/order/entity/api/pingan/utils/Base64Convert.java

@@ -1,67 +1,23 @@
-//package com.ydtech.modules.order.entity.api.pingan.utils;
-//
-//import sun.misc.BASE64Decoder;
-//import sun.misc.BASE64Encoder;
-//
-//import java.io.*;
-///**
-// *  @version
-// *  @author: hxl
-// *  @Date: 2024/3/27 17:22
-// *  @Description:  base64字符串处理工具类
-// */
-//public class Base64Convert {
-//    /**
-//     * 流转换为字符串
-//     *
-//     * @param in
-//     * @return
-//     * @throws IOException
-//     */
-//    public static String ioToBase64(InputStream in) throws IOException {
-//        String strBase64 = null;
-//        try {
-//            // in.available()返回文件的字节长度
-//            byte[] bytes = new byte[in.available()];
-//            // 将文件中的内容读入到数组中
-//            in.read(bytes);
-//            strBase64 = new BASE64Encoder().encode(bytes);      //将字节流数组转换为字符串
-//        } finally {
-//            if (in != null) {
-//                in.close();
-//            }
-//        }
-//
-//        return strBase64;
-//    }
-//
-//    /**
-//     * 流转换为字符串
-//     *
-//     * @param bytes
-//     * @return
-//     * @throws IOException
-//     */
-//    public static String byteToBase64(byte[] bytes)  {
-//        String strBase64 = null;
-//            // in.available()返回文件的字节长度
-//            strBase64 = new BASE64Encoder().encode(bytes);      //将字节流数组转换为字符串
-//        return strBase64;
-//    }
-//
-//
-//
-//
-//    /**
-//     * 将base64 转为字节
-//     *
-//     * @param strBase64
-//     * @return
-//     * @throws IOException
-//     */
-//    public static byte[] base64ToByte(String strBase64) throws IOException {
-//        // 解码,然后将字节转换为文件
-//        byte[] bytes = new BASE64Decoder().decodeBuffer(strBase64);   //将字符串转换为byte数组
-//        return bytes;
-//    }
-//}
+package com.ydtech.modules.order.entity.api.pingan.utils;
+
+import org.apache.commons.codec.binary.Base64;
+
+/**
+ *  @version  将字节流转换为Base64字符串。
+ *  解决使用jdk的base64转码打包错误的问题
+ *  处理平安保单文件加密预览
+ *  @author: hxl
+ *  @Date: 2024/4/2 14:32
+ *  @Description:
+ */
+public class Base64Convert {
+
+    /**
+     * 将字节流转换为Base64字符串。
+     * @param data 字节流数据
+     * @return Base64编码后的字符串
+     */
+    public static String byteToBase64(byte[] data) {
+        return Base64.encodeBase64String(data);
+    }
+}

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 134
src/main/java/com/ydtech/modules/order/entity/api/pingan/utils/PDFUtil.java


+ 18 - 5
src/main/java/com/ydtech/modules/order/service/impl/PingAnOrderApiServiceImpl.java

@@ -19,6 +19,7 @@ import com.ydtech.modules.order.entity.api.pingan.constants.unAutoProductDetail.
 import com.ydtech.modules.order.entity.api.pingan.constants.unAutoProductList.UnAutoProductListResponseCodeEnum;
 import com.ydtech.modules.order.entity.api.pingan.request.*;
 import com.ydtech.modules.order.entity.api.pingan.response.*;
+import com.ydtech.modules.order.entity.api.pingan.utils.PDFUtil;
 import com.ydtech.modules.order.entity.api.pingan.utils.PinAnEnumUtils;
 import com.ydtech.modules.order.entity.api.pingan.utils.UUIDUtils;
 import com.ydtech.modules.order.entity.config.BoHaiConfigureParameters;
@@ -41,6 +42,7 @@ import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.util.ObjectUtils;
 
+import java.io.File;
 import java.time.LocalDateTime;
 import java.util.*;
 
@@ -424,12 +426,23 @@ public class PingAnOrderApiServiceImpl implements PingAnOrderApiService {
         if(policyPdfResponse!=null){
             if(PolicyPdfResponseCodeEnum.POLICY_PDF_CODE_MSG_0.getCode().equals(policyPdfResponse.getResultCode())){
                 CrawlerPolicyPrintVo crawlerPolicyPrintVo =new CrawlerPolicyPrintVo();
-                if(Boolean.parseBoolean(policyPdfResponse.getPolicyPdf())){
-                    crawlerPolicyPrintVo.setJqxPolicyUrl(policyPdfResponse.getPolicyPdf());
-                }else{
-                    crawlerPolicyPrintVo.setSyxPolicyUrl(policyPdfResponse.getPolicyPdf());
+                String policyPdfBase64Str = policyPdfResponse.getPolicyPdf();
+                //存储系统临时文件
+                String tempDir = System.getProperty("java.io.tmpdir");
+                StringBuffer filePath = new StringBuffer();
+                filePath.append(tempDir).append(File.separator).append(System.currentTimeMillis()).append(File.separator).append("source.pdf");
+                String  targertPath=filePath.toString();
+                try{
+                    PDFUtil.decryptFileByPassword(policyPdfBase64Str,targertPath,properties.getSelfPrivateKey());
+                    if(Boolean.parseBoolean(policyPdfResponse.getPolicyPdf())){
+                        crawlerPolicyPrintVo.setJqxPolicyUrl(targertPath);
+                    }else{
+                        crawlerPolicyPrintVo.setSyxPolicyUrl(targertPath);
+                    }
+                    return HttpResult.ok(crawlerPolicyPrintVo);
+                }catch (Exception e){
+                    return HttpResult.error("文件解密失败!!!");
                 }
-                return HttpResult.ok(crawlerPolicyPrintVo);
             }else{
                 return HttpResult.error(PinAnEnumUtils.getEnumValueByCode(PolicyPdfResponseCodeEnum.class,policyPdfResponse.getResultCode()));
             }

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor