Parcourir la source

Merge branch 'test' of http://www.baoxianzhanggui.com:8090/sxzgd/java-insagent-pc into test-cyr

caiyaru il y a 2 ans
Parent
commit
07da611ba3

+ 2 - 2
src/main/java/com/ydtech/modules/order/controller/PingAnOrderApiController.java

@@ -185,12 +185,12 @@ public class PingAnOrderApiController {
      */
     @PostMapping("/getPolicyPrint")
     @ApiOperation(value = "8电子保单查看")
-    public HttpResult<CrawlerPolicyPrintVo> getPolicyPrint(String companyId) throws Exception {
+    public HttpResult<CrawlerPolicyPrintVo> getPolicyPrint(@RequestSingleParam(value = "companyId") String companyId) throws Exception {
         return this.pingAnOrderApiService.getPolicyPrint(companyId);
     }
     @PostMapping("/getDocumentStatusList")
     @ApiOperation(value = "9订单状态查询")
-    public HttpResult<Object> getOrderDetail(String companyId) throws Exception {
+    public HttpResult<Object> getOrderDetail(@RequestSingleParam(value = "companyId") String companyId) throws Exception {
         return this.pingAnOrderApiService.getDocumentStatusList(companyId);
     }
     /**

+ 10 - 0
src/main/java/com/ydtech/modules/order/entity/api/pingan/request/CarConfirmRequest.java

@@ -14,6 +14,7 @@ import com.ydtech.modules.order.entity.config.PingAnConfigureParameters;
 import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
+import org.apache.commons.lang3.StringUtils;
 
 import java.io.Serializable;
 import java.util.Map;
@@ -205,12 +206,21 @@ public class CarConfirmRequest extends PingAnBaseRequest {
         this.vehicle = new VehicleDTO(carInfo, modelsDto);
         // 车主
         CustomerInfoVo ownerInfo = quoteInfo.getOwnerInfo();
+        if(StringUtils.isBlank(ownerInfo.getIdentifyType())){
+            ownerInfo.setIdentifyType("01");
+        }
         this.register=new RegisterDTO(ownerInfo);
         // 投保人信息
         CustomerInfoVo policyHolderInfo = quoteInfo.getPolicyHolderInfo();
+        if(StringUtils.isBlank(policyHolderInfo.getIdentifyType())){
+            policyHolderInfo.setIdentifyType("01");
+        }
         this.applicant=new ApplicantDTO(policyHolderInfo);
         // 被保人信息
         CustomerInfoVo insuredPersonInfo = quoteInfo.getInsuredPersonInfo();
+        if(StringUtils.isBlank(insuredPersonInfo.getIdentifyType())){
+            insuredPersonInfo.setIdentifyType("01");
+        }
         this.insured=new InsuredDTO(insuredPersonInfo);
         // 过户标志
         this.bizQuote = new BizQuoteDTO(String.valueOf(carInfo.isTransferFlag()),carInfo.getTransferDate());

+ 2 - 2
src/main/java/com/ydtech/modules/order/entity/api/pingan/request/PolicyPdfRequest.java

@@ -45,11 +45,11 @@ public class PolicyPdfRequest extends PingAnBaseRequest{
      */
     private VehicleDTO vehicle;
 
-    public PolicyPdfRequest(String userId, String documentNo,String checkNo,String licenseNo,String frameNo) {
+    public PolicyPdfRequest(String userId, String documentNo,String checkNo,String licenseNo,String frameNo,String flag) {
           this.setUserId(userId);
           this.setDocumentNo(documentNo);
           this.setCheckNo(checkNo);
-          this.setIsUnAutoPolicy("false");
+          this.setIsUnAutoPolicy(flag);
           this.setVehicle(new VehicleDTO(licenseNo,frameNo));
     }
 

+ 10 - 0
src/main/java/com/ydtech/modules/order/entity/api/pingan/request/SubmitApplyRequest.java

@@ -13,6 +13,7 @@ import com.ydtech.modules.order.entity.po.InsTaskImages;
 import com.ydtech.modules.order.entity.po.InsUploadFiles;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
+import org.apache.commons.lang3.StringUtils;
 
 import java.io.Serializable;
 import java.util.ArrayList;
@@ -353,12 +354,21 @@ public class SubmitApplyRequest extends PingAnBaseRequest {
         this.setMacAddress(map.get("mac"));
         // 车主
         CustomerInfoVo ownerInfo = insOrders.getOwnerinfo().toJavaObject(CustomerInfoVo.class);
+        if(StringUtils.isBlank(ownerInfo.getIdentifyType())){
+            ownerInfo.setIdentifyType("01");
+        }
         this.register=new SubmitApplyRequest.RegisterDTO(ownerInfo);
         // 投保人信息
         CustomerInfoVo policyHolderInfo = insOrders.getApplyinfo().toJavaObject(CustomerInfoVo.class);
+        if(StringUtils.isBlank(policyHolderInfo.getIdentifyType())){
+            policyHolderInfo.setIdentifyType("01");
+        }
         this.applicant=new SubmitApplyRequest.ApplicantDTO(policyHolderInfo);
         // 被保人信息
         CustomerInfoVo insuredPersonInfo = insOrders.getInsureinfo().toJavaObject(CustomerInfoVo.class);
+        if(StringUtils.isBlank(insuredPersonInfo.getIdentifyType())){
+            insuredPersonInfo.setIdentifyType("01");
+        }
         this.insured=new SubmitApplyRequest.InsuredDTO(insuredPersonInfo);
         // 地址
         AddressDTO  addressDTO =new AddressDTO("1", policyHolderInfo.getAddr(), policyHolderInfo.getName(), policyHolderInfo.getMobile(), "", "");

+ 3 - 1
src/main/java/com/ydtech/modules/order/entity/api/pingan/utils/PDFUtil.java

@@ -21,9 +21,11 @@ public class PDFUtil {
 
         File encryptFile = new File(filePath);
         String parentPath = encryptFile.getParent();
+        String name = encryptFile.getName();
+        String fileName = name.split("\\.")[0] + "-decipher.pdf";
         PDDocument load = PDDocument.load(encryptFile, password);
         load.setAllSecurityToBeRemoved(true);
-        String decodeFilePath = parentPath + File.separator+"decipher.pdf";
+        String decodeFilePath = parentPath + File.separator+fileName;
         load.save(decodeFilePath);
         load.close();
     }

+ 182 - 29
src/main/java/com/ydtech/modules/order/service/impl/PingAnOrderApiServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ydtech.modules.order.service.impl;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.google.gson.Gson;
 import com.ydtech.config.properties.PingAnApiConfigurationProperties;
@@ -54,6 +55,7 @@ import com.ydtech.utils.CalculateUtils;
 import com.ydtech.utils.StringUtils;
 import lombok.RequiredArgsConstructor;
 import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.ObjectUtils;
 
@@ -94,7 +96,12 @@ public class PingAnOrderApiServiceImpl implements PingAnOrderApiService {
 
     private final InsTaskImagesMapper insTaskImagesMapper;
 
+    @Value("${upload.file.path}")
+    private String uploadPath;
 
+    private String EXCEL_PATH = "excel//";
+
+    private String UPLOAD_PATH = "/upload//excel//";
     /**
      * @Description 获取财意险险种套餐列表  调用 4.4
      * @Author hxl
@@ -205,6 +212,8 @@ public class PingAnOrderApiServiceImpl implements PingAnOrderApiService {
 
         //验证参数
         checkData(quoteVo);
+        //补充身份证信息
+        quoteInfo = getQuoteInfoData(quoteInfo);
         // 车型查询
         CarInfoVo carInfo = quoteInfo.getCarInfo();
         PinganApiLog pinganApiLog = new PinganApiLog(quoteVo.getOrderNo(),null,quoteVo.getAgreementId());
@@ -239,13 +248,31 @@ public class PingAnOrderApiServiceImpl implements PingAnOrderApiService {
             SearchPAVehicleListResponse.ModelsDto model = new SearchPAVehicleListResponse.ModelsDto();
             if (models != null && models.size() == 1) {
                 model = models.get(0);
-                //通过年款和新车购置价确定唯一
             } else if (models != null && models.size() > 1) {
-                String modelNames="";
-                for(SearchPAVehicleListResponse.ModelsDto dto: models){
-                    modelNames += dto.getModelName()+"||----------------------||";
+                //通过年款和新车购置价确定唯一
+                String purchasePrice = carInfo.getPurchasePrice();
+                String caryear = carInfo.getPurchasePrice();
+                Iterator<SearchPAVehicleListResponse.ModelsDto> it = models.iterator();
+                while(it.hasNext()){
+                    SearchPAVehicleListResponse.ModelsDto x = it.next();
+                    if(!purchasePrice.equals(x.getPrice())){
+                        it.remove();
+                    }
+                }
+                if(StringUtils.isNotBlank(caryear) && models.size()>1){
+                    Iterator<SearchPAVehicleListResponse.ModelsDto> itNew = models.iterator();
+                    while(it.hasNext()){
+                        SearchPAVehicleListResponse.ModelsDto x = itNew.next();
+                        if(!caryear.contains(x.getMarketDate())){
+                            it.remove();
+                        }
+                    }
+                }
+                if(models.size()>1){
+                    throw new SystemException("请确认车型,检索出多个下车型,请填写正确信息");
+                }else{
+                    model = models.get(0);
                 }
-                throw new SystemException("请确认车型,检索出以下车型||----------------------||"+modelNames);
             }
             // 3. 车辆信息确认
             pinganApiLog.setId(null);
@@ -283,6 +310,34 @@ public class PingAnOrderApiServiceImpl implements PingAnOrderApiService {
             throw new SystemException(e.getMessage());
         }
     }
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/8/9 10:29
+     *  @Description: 补充信息
+     */
+    private static BaseQuoteInfoVo  getQuoteInfoData(BaseQuoteInfoVo quoteInfo) {
+        // 车主
+        CustomerInfoVo ownerInfo = quoteInfo.getOwnerInfo();
+        if(org.apache.commons.lang3.StringUtils.isBlank(ownerInfo.getIdentifyType())){
+            ownerInfo.setIdentifyType("01");
+            quoteInfo.setOwnerInfo(ownerInfo);
+        }
+        // 投保人信息
+        CustomerInfoVo policyHolderInfo = quoteInfo.getPolicyHolderInfo();
+        if(org.apache.commons.lang3.StringUtils.isBlank(policyHolderInfo.getIdentifyType())){
+            policyHolderInfo.setIdentifyType("01");
+            quoteInfo.setPolicyHolderInfo(policyHolderInfo);
+        }
+        // 被保人信息
+        CustomerInfoVo insuredPersonInfo = quoteInfo.getInsuredPersonInfo();
+        if(org.apache.commons.lang3.StringUtils.isBlank(insuredPersonInfo.getIdentifyType())){
+            insuredPersonInfo.setIdentifyType("01");
+            quoteInfo.setInsuredPersonInfo(insuredPersonInfo);
+        }
+        return quoteInfo;
+    }
+
     /**
      *  @version
      *  @author: hxl
@@ -291,6 +346,7 @@ public class PingAnOrderApiServiceImpl implements PingAnOrderApiService {
      */
     private static void checkData(PingAnQuoteVo<Map<String, Object>> quoteVo) {
         String agreementId = quoteVo.getAgreementId();
+
         if(StringUtils.isBlank(agreementId)){
             throw new SystemException("未选择协议不能报价");
         }
@@ -689,43 +745,138 @@ public class PingAnOrderApiServiceImpl implements PingAnOrderApiService {
         CustomerInfoVo ownerInfo = insOrders.getOwnerinfo().toJavaObject(CustomerInfoVo.class);
         CarInfoVo carInfoVo = insOrders.getCarinfo().toJavaObject(CarInfoVo.class);
         PinganApiLog pinganApiLog = new PinganApiLog(insAreaCompany.getOrderno(),subOrderNo,insAreaCompany.getAgreementId());
+        //交强保单号
         String jqpolicyno = insAreaCompany.getJqpolicyno();
-        //调用  电子保单pdf  001
-        PolicyPdfRequest policyPdfRequest = new PolicyPdfRequest(parameters.getUserId(), jqpolicyno, ownerInfo.getIdentifyNumber(), carInfoVo.getLicenseNo(), carInfoVo.getFrameNo());
+        //商业保单号
+        String sypolicyno = insAreaCompany.getSypolicyno();
+        JSONArray crossInsurance = insAreaCompany.getCrossInsurance();
+        //非车保单号
+        String application = null;
+        if(crossInsurance!=null && crossInsurance.size() > 0) {
+            application = crossInsurance.getJSONObject(0).getString("application");
+        }
+        CrawlerPolicyPrintVo  crawlerPolicyPrintVo =new CrawlerPolicyPrintVo();
+        //交强
+
+        if(StringUtils.isNotBlank(jqpolicyno) ){
+            String fileName="_交强险保单";
+            String fileBZName="-交强险标志";
+            String jqbdUrl= uploadPath+"//" + EXCEL_PATH +  insAreaCompany.getOrderno()+"-"+ insAreaCompany.getId()+"-"+ jqpolicyno+fileName+"-decipher.pdf";
+            String jqbzUrl= uploadPath+"//" + EXCEL_PATH +  insAreaCompany.getOrderno()+"-"+ insAreaCompany.getId()+"-"+ jqpolicyno+fileBZName+"-decipher.pdf";
+            String jqbdUrl_= UPLOAD_PATH +  insAreaCompany.getOrderno()+"-"+ insAreaCompany.getId()+"-"+ jqpolicyno+fileName+"-decipher.pdf";
+            String jqbzUrl_= UPLOAD_PATH +  insAreaCompany.getOrderno()+"-"+ insAreaCompany.getId()+"-"+ jqpolicyno+fileBZName+"-decipher.pdf";
+            File jqbdURL = new File(jqbdUrl);
+            File jqbzURL = new File(jqbzUrl);
+            if(jqbdURL.exists()){
+                crawlerPolicyPrintVo.setJqxPolicyUrl(jqbdUrl_);
+            }
+            if(jqbzURL.exists()){
+                crawlerPolicyPrintVo.setJqxFlagUrl(jqbzUrl_);
+            }
+            if(!jqbdURL.exists() && !jqbzURL.exists() ){
+                getPdfUrl(parameters, jqpolicyno,ownerInfo,carInfoVo, pinganApiLog, insAreaCompany, crawlerPolicyPrintVo,1);
+            }
+        }
+        if(StringUtils.isNotBlank(sypolicyno)){
+            String fileName="_商业险保单";
+            String sybdUrl= uploadPath+"//" + EXCEL_PATH +  insAreaCompany.getOrderno()+"-"+ insAreaCompany.getId()+"-"+ sypolicyno+fileName+"-decipher.pdf";
+            String sybdUrl_= UPLOAD_PATH +  insAreaCompany.getOrderno()+"-"+ insAreaCompany.getId()+"-"+ sypolicyno+fileName+"-decipher.pdf";
+            File sybdURL = new File(sybdUrl);
+            if(sybdURL.exists()){
+                crawlerPolicyPrintVo.setSyxPolicyUrl(sybdUrl_);
+            }
+            if(!sybdURL.exists()) {
+                getPdfUrl(parameters, sypolicyno, ownerInfo, carInfoVo, pinganApiLog, insAreaCompany, crawlerPolicyPrintVo, 2);
+            }
+        }
+        if(StringUtils.isNotBlank(application)){
+            String fileName="_非车险保单";
+            String fcxbdUrl= uploadPath+"//" + EXCEL_PATH +  insAreaCompany.getOrderno()+"-"+ insAreaCompany.getId()+"-"+ application+fileName+"-decipher.pdf";
+            String fcxbdUrl_= UPLOAD_PATH +  insAreaCompany.getOrderno()+"-"+ insAreaCompany.getId()+"-"+ application+fileName+"-decipher.pdf";
+            File fcxbdURL = new File(fcxbdUrl);
+            if(fcxbdURL.exists()){
+                List<CrawlerPolicyPrintVo.JyxInfoListDTO> jyxInfoListDTOS = new ArrayList<>();
+                CrawlerPolicyPrintVo.JyxInfoListDTO jyxInfoListDTO = new CrawlerPolicyPrintVo.JyxInfoListDTO();
+                jyxInfoListDTO.setJyxPolicyUrl(fcxbdUrl_);
+                jyxInfoListDTOS.add(jyxInfoListDTO);
+                crawlerPolicyPrintVo.setJyxInfoList(jyxInfoListDTOS);
+            }
+            if(!fcxbdURL.exists()) {
+                getPdfUrl(parameters, application,ownerInfo,carInfoVo, pinganApiLog, insAreaCompany, crawlerPolicyPrintVo,3);
+            }
+
+        }
+        return HttpResult.ok(crawlerPolicyPrintVo);
+    }
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/8/9 15:07
+     *  @Description: 获取保单地址
+     */
+    private void getPdfUrl(PingAnConfigureParameters parameters, String policyno, CustomerInfoVo ownerInfo, CarInfoVo carInfoVo, PinganApiLog pinganApiLog, InsAreaCompany insAreaCompany, CrawlerPolicyPrintVo crawlerPolicyPrintVo,int type) {
+        pinganApiLog.setId(null);
+        String flag ="false";
+        String fileName="";
+        String fileBZName="";
+        //驾意险
+        if(type==3){
+            flag="true";
+            fileName="_非车险保单";
+        }else if(type==1){
+           //交强
+            fileName="_交强险保单";
+            fileBZName="-交强险标志";
+        }else if(type==2){
+            //商业
+            fileName="_商业险保单";
+        }
+        PolicyPdfRequest policyPdfRequest = new PolicyPdfRequest(parameters.getUserId(), policyno, ownerInfo.getIdentifyNumber(), carInfoVo.getLicenseNo(), carInfoVo.getFrameNo(),flag);
         PolicyPdfResponse policyPdfResponse = null;
         try {
-            policyPdfResponse = pinganRequestApiComponents.getPolicyPdf(policyPdfRequest,pinganApiLog);
+            policyPdfResponse = pinganRequestApiComponents.getPolicyPdf(policyPdfRequest, pinganApiLog);
         } catch (Exception e) {
             throw new SystemException(e.getMessage());
         }
+        String saveFilePath = uploadPath+"//" + EXCEL_PATH;
+        String jqbdPath = "";
+        String jqbzPath = "";
         if (policyPdfResponse != null) {
             if (PolicyPdfResponseCodeEnum.POLICY_PDF_CODE_MSG_0.getCode().equals(policyPdfResponse.getResultCode())) {
-                CrawlerPolicyPrintVo crawlerPolicyPrintVo = new CrawlerPolicyPrintVo();
                 String policyPdfBase64Str = policyPdfResponse.getPolicyPdf();
-                //存储系统临时文件
-                // 获取当前项目的目录
-                File projectFile =new File(System.getProperty("user.dir"));
-                // 获取上级目录
-                String parentPath = projectFile.getParent();
-                StringBuffer filePath = new StringBuffer();
-                filePath.append(parentPath).append(jqpolicyno).append(File.separator).append(System.currentTimeMillis()).append(".pdf");
-                String targertPath = filePath.toString();
-                try {
-                    PDFUtil.decryptFileByPassword(policyPdfBase64Str, targertPath, properties.getPingAnPublicKey());
-                    if (Boolean.parseBoolean(policyPdfResponse.getPolicyPdf())) {
-                        crawlerPolicyPrintVo.setJqxPolicyUrl(targertPath);
-                    } else {
-                        crawlerPolicyPrintVo.setSyxPolicyUrl(targertPath);
+                String flagPdf = policyPdfResponse.getFlagPdf();
+                String yqbdFileName = insAreaCompany.getOrderno()+"-"+ insAreaCompany.getId()+"-"+ policyno+fileName+".pdf";
+                jqbdPath = UPLOAD_PATH +  insAreaCompany.getOrderno()+"-"+ insAreaCompany.getId()+"-"+ policyno+fileName+"-decipher.pdf";;
+                if(type==1){
+                    String yqbzFileName = insAreaCompany.getOrderno()+"-"+ insAreaCompany.getId()+"-"+ policyno+fileBZName+".pdf";
+                    jqbzPath = UPLOAD_PATH +   insAreaCompany.getOrderno()+"-"+ insAreaCompany.getId()+"-"+ policyno+fileBZName+"-decipher.pdf";;
+                    String jqBzTargertPath = saveFilePath+yqbzFileName;
+                    try {
+                        PDFUtil.decryptFileByPassword(flagPdf, jqBzTargertPath, properties.getPingAnPublicKey());
+                    } catch (Exception e) {
+                        jqbzPath=null;
                     }
-                    return HttpResult.ok(crawlerPolicyPrintVo);
+                    crawlerPolicyPrintVo.setJqxFlagUrl(jqbzPath);
+                }
+                try {
+                    String jqBdTargertPath = saveFilePath+yqbdFileName;
+                    PDFUtil.decryptFileByPassword(policyPdfBase64Str, jqBdTargertPath, properties.getPingAnPublicKey());
                 } catch (Exception e) {
-                    return HttpResult.error("文件解密失败!!!");
+                    jqbdPath=null;
+                }
+                if(type==1){
+                    crawlerPolicyPrintVo.setJqxPolicyUrl(jqbdPath);
+                }else if(type==2){
+                    crawlerPolicyPrintVo.setSyxPolicyUrl(jqbdPath);
+                }else if(type==3){
+                    List<CrawlerPolicyPrintVo.JyxInfoListDTO> jyxInfoListDTOS = new ArrayList<>();
+                    CrawlerPolicyPrintVo.JyxInfoListDTO jyxInfoListDTO = new CrawlerPolicyPrintVo.JyxInfoListDTO();
+                    jyxInfoListDTO.setJyxPolicyUrl(jqbdPath);
+                    jyxInfoListDTOS.add(jyxInfoListDTO);
+                    crawlerPolicyPrintVo.setJyxInfoList(jyxInfoListDTOS);
                 }
-            } else {
-                return HttpResult.error(PinAnEnumUtils.getEnumValueByCode(PolicyPdfResponseCodeEnum.class, policyPdfResponse.getResultCode()));
             }
         }
-        return HttpResult.error("获取保单地址失败");
     }
 
     /**
@@ -860,7 +1011,7 @@ public class PingAnOrderApiServiceImpl implements PingAnOrderApiService {
                         } else {
                             return HttpResult.error("二维码支付接口报错");
                         }
-                        insAreaCompany.setPaymentLink(payUrl);
+                        insAreaCompany.setNoticeNo(noticeNo);
                         insAreaCompany.setOrderstatus(InsOrderStatusEnum.WAIT_PAY.getCode());
                     }
                 }
@@ -1357,6 +1508,8 @@ public class PingAnOrderApiServiceImpl implements PingAnOrderApiService {
                 throw new SystemException(e.getMessage());
             }
             noticeNo = noticeDoResponse.getNoticeNo();
+            insAreaCompany.setNoticeNo(noticeNo);
+            insAreaCompanyService.updateById(insAreaCompany);
         }
 
         // 获取支付的链接 只支持通知单号类型07    单证类型(01投保单02保单03批改申请单04批单05赔案号06报案号07通知单号)