xuqiang 3 месяцев назад
Родитель
Сommit
a2fba9fc3c

+ 26 - 10
tenant/insurance/quotation-ansheng/src/main/java/com/jzg/quotation/ansheng/crawler/build/AnShengCrawlerApplyApplicationRequestBuild.java

@@ -14,6 +14,7 @@ import com.jzg.quotation.ansheng.crawler.utils.PolicySpecialPromiseUtil;
 import com.jzg.quotation.commons.utils.TimeProcessing;
 import org.springframework.util.StringUtils;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -36,6 +37,21 @@ public final class AnShengCrawlerApplyApplicationRequestBuild {
                 .collect(Collectors.toMap(x -> x.getPolicyBase().getPlanCode(), x -> x));
 
         // 拷贝报价请求数据
+        BigDecimal netAmount = crawlerCalculatePremiumApply.getContracts().stream()
+                .map(contract -> contract.getPolicyBase())
+                .filter(policyBase -> policyBase != null)
+                .map(policyBase -> policyBase.getTotalNetPremium())
+                .filter(totalNetPremium -> totalNetPremium != null)
+                .map(BigDecimal::valueOf)
+                .reduce(BigDecimal.ZERO, BigDecimal::add);
+        BigDecimal taxAmount = crawlerCalculatePremiumApply.getContracts().stream()
+                .map(contract -> contract.getPolicyBase())
+                .filter(policyBase -> policyBase != null)
+                .map(policyBase -> policyBase.getAddedValueTax())
+                .filter(totalNetPremium -> totalNetPremium != null)
+                .map(BigDecimal::valueOf)
+                .reduce(BigDecimal.ZERO, BigDecimal::add);
+        String vehicleAlias = crawlerCalculatePremiumApply.getContracts().get(0).getTargetList().get(0).getPolicyPricing().getVehicleAlias();
         crawlerCalculatePremiumApply.getContracts().forEach(requestContracts -> {
             AnShengCrawlerApplyApplicationRequest.ContractsDTO contractsDTO = new AnShengCrawlerApplyApplicationRequest.ContractsDTO();
             AnShengCrawlerCalculatePremiumApplyResponse.DataDTO.ContractsDTO responseContracts = responseMap.get(requestContracts.getPolicyBase()
@@ -55,8 +71,8 @@ public final class AnShengCrawlerApplyApplicationRequestBuild {
 
             AnShengCrawlerApplyApplicationRequest.ContractsDTO.BillInfoDetailDTO billInfoDetailDTO = buildBillInfoDetailDTO(insuranerName, personDTO.getMobileTelephone());
             contractsDTO.setBillInfoDetail(billInfoDetailDTO);
-            AnShengCrawlerApplyApplicationRequest.ContractsDTO.BrandAutoModelDTO brandAutoModelDTO = buildBrandAutoModelDTO(responseContracts.getVehicle());
-            //contractsDTO.setBrandAutoModel(brandAutoModelDTO);
+            AnShengCrawlerApplyApplicationRequest.ContractsDTO.BrandAutoModelDTO brandAutoModelDTO = buildBrandAutoModelDTO(responseContracts.getVehicle(),vehicleAlias);
+            contractsDTO.setBrandAutoModel(brandAutoModelDTO);
             contractsDTO.setSaleChannelSource(new AnShengCrawlerApplyApplicationRequest.ContractsDTO.SaleChannelSourceDTO(""));
             contractsDTO.setUnderwriteInfos(List.of(new AnShengCrawlerApplyApplicationRequest.ContractsDTO.UnderwriteInfosDTO("1", "")));
             AnShengCrawlerApplyApplicationRequest.ContractsDTO.PolicyExtendDTO policyExtendDTO = buildPolicyExtend(insuranerName, personDTO.getMobileTelephone(),brand);
@@ -69,7 +85,7 @@ public final class AnShengCrawlerApplyApplicationRequestBuild {
                     .get(0), requestContracts.getTargetList().get(0));
             contractsDTO.setTargetList(List.of(targetListDTO));
 
-            AnShengCrawlerApplyApplicationRequest.ContractsDTO.PolicyPaymentsDTO policyPaymentsDTO = buildPolicyPaymentsDTO(personDTO, responseContracts.getPolicyBase());
+            AnShengCrawlerApplyApplicationRequest.ContractsDTO.PolicyPaymentsDTO policyPaymentsDTO = buildPolicyPaymentsDTO(personDTO, responseContracts.getPolicyBase(),netAmount,taxAmount);
             contractsDTO.setPolicyPayments(List.of(policyPaymentsDTO));
             // 人员信息
             contractsDTO.setPolicyPersons(requestContracts.getPolicyPersons());
@@ -401,7 +417,7 @@ public final class AnShengCrawlerApplyApplicationRequestBuild {
     }
 
     private static AnShengCrawlerApplyApplicationRequest.ContractsDTO.PolicyPaymentsDTO buildPolicyPaymentsDTO(AnShengCrawlerCalculatePremiumApplyMessage.ContractsDTO.PolicyPersonsDTO.PersonnelInfoBaseDTO.PersonDTO personDTO,
-                                                                                                               AnShengCrawlerCalculatePremiumApplyResponse.DataDTO.ContractsDTO.PolicyBaseDTO policyBaseDTO) {
+                                                                                                               AnShengCrawlerCalculatePremiumApplyResponse.DataDTO.ContractsDTO.PolicyBaseDTO policyBaseDTO, BigDecimal netAmount,BigDecimal taxAmount ) {
         String insuranceBeginTime = policyBaseDTO.getInsuranceBeginTime();
         String beginDate = TimeProcessing.dateTimeToDate(insuranceBeginTime);
         String endDate = TimeProcessing.plusDays(beginDate, 10);
@@ -410,8 +426,8 @@ public final class AnShengCrawlerApplyApplicationRequestBuild {
         policyPaymentsDTO.setPaymentPremiumTimes(1);
         policyPaymentsDTO.setBankAccountNo("");
         policyPaymentsDTO.setPrepaidPassword("");
-        policyPaymentsDTO.setNetAmount(policyBaseDTO.getTotalNetPremium());
-        policyPaymentsDTO.setTaxAmount(policyBaseDTO.getAddedValueTax());
+        policyPaymentsDTO.setNetAmount(taxAmount.doubleValue());
+        policyPaymentsDTO.setTaxAmount(taxAmount.doubleValue());
         policyPaymentsDTO.setPaymentEndDate(endDate);
         policyPaymentsDTO.setPaymentPersonCode(personDTO.getPersonnelName());
         policyPaymentsDTO.setPaymentPersonCertCode(personDTO.getCertificateNo());
@@ -496,14 +512,14 @@ public final class AnShengCrawlerApplyApplicationRequestBuild {
         policyBaseDTO.setApplyPolicyNo("");
         policyBaseDTO.setAgentRatioDegree("");
         policyBaseDTO.setAppointAreaCode("");
-        policyBaseDTO.setKeyOverServer(responsePolicyBase.getKeyOverServer());
+        policyBaseDTO.setKeyOverServer(com.jzg.commons.util.StringUtils.isNotEmpty(responsePolicyBase.getKeyOverServer()) ?  responsePolicyBase.getKeyOverServer() : "");
         policyBaseDTO.setEPolicyPDFTime("1");
         policyBaseDTO.setRatioOTHERSum("");
         policyBaseDTO.setDisputedSettleMode("0");
         policyBaseDTO.setProfessionalNo("");
         policyBaseDTO.setPolicyScoreDecisionWay("2");
         policyBaseDTO.setShortTimeCoefficient(String.valueOf(requestPolicyBase.getShortTimeCoefficient()));
-        policyBaseDTO.setKeyOverServerSY("");
+        policyBaseDTO.setKeyOverServerSY(com.jzg.commons.util.StringUtils.isNotEmpty(responsePolicyBase.getKeyOverServerSY()) ?  responsePolicyBase.getKeyOverServerSY() : "");
         policyBaseDTO.setChargeRateId("");
         policyBaseDTO.setRatioTPSum("");
         policyBaseDTO.setTotalStandardPremium(responsePolicyBase.getTotalStandardPremium());
@@ -565,11 +581,11 @@ public final class AnShengCrawlerApplyApplicationRequestBuild {
         return policyExtend;
     }
 
-    private static AnShengCrawlerApplyApplicationRequest.ContractsDTO.BrandAutoModelDTO buildBrandAutoModelDTO(AnShengCrawlerCalculatePremiumApplyResponse.DataDTO.ContractsDTO.VehicleDTO vehicle) {
+    private static AnShengCrawlerApplyApplicationRequest.ContractsDTO.BrandAutoModelDTO buildBrandAutoModelDTO(AnShengCrawlerCalculatePremiumApplyResponse.DataDTO.ContractsDTO.VehicleDTO vehicle,String vehicleAlias) {
         AnShengCrawlerApplyApplicationRequest.ContractsDTO.BrandAutoModelDTO brandAutoModelDTO = new AnShengCrawlerApplyApplicationRequest.ContractsDTO.BrandAutoModelDTO();
         brandAutoModelDTO.setModelDesc(vehicle.getDetailDesc());
         brandAutoModelDTO.setStandardName(vehicle.getStandardName());
-        brandAutoModelDTO.setVehicleAlias("");
+        brandAutoModelDTO.setVehicleAlias(vehicleAlias);
         return brandAutoModelDTO;
     }
 

+ 10 - 0
tenant/insurance/quotation-ansheng/src/main/java/com/jzg/quotation/ansheng/crawler/component/AnShengCrawlerRequestComponent.java

@@ -3,6 +3,7 @@ package com.jzg.quotation.ansheng.crawler.component;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.alibaba.fastjson2.JSONObject;
 import com.jzg.commons.exception.SystemException;
 import com.jzg.quotation.ansheng.crawler.constant.enums.RequestUrl;
 import com.jzg.quotation.ansheng.crawler.entity.request.*;
@@ -333,4 +334,13 @@ public class AnShengCrawlerRequestComponent {
         return "";
     }
 
+    public PureRiskPremiumQueryResponse pureRiskPremiumQuery(InsuranceContractRequest insuranceContractRequest, HttpHeaders httpHeaders) {
+        return post(RequestUrl.PURERISK_PREMIUM_QUERY, insuranceContractRequest, PureRiskPremiumQueryResponse.class, httpHeaders);
+
+    }
+
+    public List<AnShengCrawlerSearchVehicleByVinResponse.DataDTO> searchVehicleByName(JSONObject jsonObject, HttpHeaders headers) {
+        ResponseEntity<AnShengCrawlerSearchVehicleByVinResponse> responseEntity = requestComponent.formData(RequestUrl.SEARCHVEHICLE_BY_NAME.getRequestUrl(anShengCrawlerProperties.getUrl()), jsonObject, AnShengCrawlerSearchVehicleByVinResponse.class, headers);
+        return responseEntity.getBody().getData();
+    }
 }

+ 55 - 25
tenant/insurance/quotation-ansheng/src/main/java/com/jzg/quotation/ansheng/crawler/entity/request/AnShengCrawlerCalculatePremiumApplyMessage.java

@@ -35,14 +35,13 @@ public class AnShengCrawlerCalculatePremiumApplyMessage {
     public AnShengCrawlerCalculatePremiumApplyMessage(QuoteVo quoteVo, AnShengCrawlerSearchVehicleByVinResponse.DataDTO dataDTO,
                                                       AnShengCrawlerGetUserDetailResponse.DataDTO.AgentDefineDTO userDetailResponse, DepartmentPlanCode departmentPlanCode,
                                                       String checkVehicleCodeSecret) {
-        RiskInfoVo riskInfoVo = Optional.ofNullable(quoteVo.getCiRiskInfoVo())
-                .orElse(quoteVo.getBiRiskInfoVo());
+        RiskInfoVo riskInfoVo = Optional.ofNullable(quoteVo.getCiRiskInfoVo()).orElse(quoteVo.getBiRiskInfoVo());
 
         String customerNegotiatePrice = CustomerNegotiatePriceUtils.calculateTheDepreciationValue(departmentPlanCode.getCode(), quoteVo.getCarInfoVo()
                         .getEnergyTypeCode(),
                 dataDTO.getCustomerNegotiatePrice(), riskInfoVo.getStartDate(), quoteVo.getCarInfoVo()
                         .getRegisterDate());
-
+        String energyTypeCode = quoteVo.getCarInfoVo().getEnergyTypeCode();
         this.isTryCal = false;
         this.contracts = new ArrayList<>();
         if (!ObjectUtils.isEmpty(quoteVo.getCiRiskInfoVo())) {
@@ -53,7 +52,7 @@ public class AnShengCrawlerCalculatePremiumApplyMessage {
         }
         if (!ObjectUtils.isEmpty(quoteVo.getBiRiskInfoVo())) {
             ContractsDTO baseContracts = getBaseContracts(quoteVo.getBiRiskInfoVo(), quoteVo, dataDTO, customerNegotiatePrice, userDetailResponse, departmentPlanCode.getCode(), departmentPlanCode.getProductCode(), checkVehicleCodeSecret);
-            baseContracts.addBusinessInsurance(quoteVo.getKindInfoVo(),quoteVo);
+            baseContracts.addBusinessInsurance(quoteVo.getKindInfoVo(),quoteVo,energyTypeCode);
             baseContracts.addBiPolicyRatios();
             this.contracts.add(baseContracts);
         }
@@ -154,15 +153,49 @@ public class AnShengCrawlerCalculatePremiumApplyMessage {
             System.out.println(i);
         }
 
-        public void addBusinessInsurance(List<KindInfoVo> kindInfoVo, QuoteVo quoteVo) {
+        public void addBusinessInsurance(List<KindInfoVo> kindInfoVo, QuoteVo quoteVo,String energyTypeCode) {
             String seatCount = String.valueOf(Integer.parseInt(quoteVo.getCarInfoVo().getSeatCount()) - 1);
             for (KindInfoVo kind : kindInfoVo) {
                 PolicyCoveragesDTO dto = new PolicyCoveragesDTO(kind);
                 String code = dto.getDutyCode();
-                if (StringUtils.equalsAny(code, "APL", "APLDUOM")) dto.setSeats(seatCount);
+                if (StringUtils.equalsAny(code, "APL", "APLDUOM","NEAPL")) dto.setSeats(seatCount);
                 else if (StringUtils.equalsAny(code, "ADL", "NEADL")) dto.setSeats("1");
                 policyCoverages.add(dto);
             }
+            PolicyCoveragesDTO dto = new PolicyCoveragesDTO();
+            dto.setDutyCode(StringUtils.equals("0",energyTypeCode) ? "STORRS" : "NESTORR");
+            dto.setDutyChineseName(StringUtils.equals("0",energyTypeCode) ? "道路救援服务特约条款" : "道路救援服务特约条款(新能源车)");
+            dto.setInsuredAmount("0");
+            dto.setEquipmentInsureAmount("");
+            dto.setPremiumRate("");
+            dto.setDeductibleDiscount("");
+            dto.setTotalActualPremium("");
+            dto.setDeductionRate("0");
+            dto.setServiceNum("2");
+            dto.setIsTelpeson("1");
+            dto.setTelPhone("");
+            dto.setMileage("");
+            dto.setSetMeal("");
+            dto.setFireMultiple("");
+            dto.setAllAmount("");
+            dto.setRiskPremum("");
+            dto.setSeats("");
+            dto.setDeductible("");
+            dto.setTotalStandardPremium(0);
+            dto.setAddedValueTax(0);
+            dto.setTotalAgreePremium(0);
+            dto.setTotalNetPremium(0);
+            dto.setNewEquipmentList(Lists.newArrayList());
+            dto.setChargingPostDataList(Lists.newArrayList());
+            dto.setFullYearPremium("");
+            dto.setDieAmount("");
+            dto.setMedicalAmount("");
+            dto.setPropertyAmount("");
+            dto.setNoFaultDieAmount("");
+            dto.setNoFaultMedicalAmount("");
+            dto.setNoFaultPropertyAmount("");
+            dto.setBasePremium("");
+
         }
 
         public ContractsDTO(RiskInfoVo riskInfoVo, QuoteVo quoteVo, AnShengCrawlerSearchVehicleByVinResponse.DataDTO dataDTO,
@@ -178,7 +211,7 @@ public class AnShengCrawlerCalculatePremiumApplyMessage {
             this.saleBusinessSource = new SaleBusinessSourceDTO(userDetailResponse.getSaleAgentCode(), userDetailResponse.getSaleTeamCode());
             this.policyAttachments = new ArrayList<>();
             TargetListDTO targetListDTO = new TargetListDTO(dataDTO, quoteVo.getCarInfoVo(), quoteVo.getPolicyHolderInfo(), userDetailResponse.getDepartmentCode(), quoteVo.getOwnersInfo()
-                    .getName(), customerNegotiatePrice);
+                    .getName(), customerNegotiatePrice,!ObjectUtils.isEmpty(quoteVo.getBiRiskInfoVo()),productCode);
             targetListDTO.setCheckVehicleCodeSecret(checkVehicleCodeSecret);
             this.targetList = List.of(targetListDTO);
 
@@ -358,10 +391,10 @@ public class AnShengCrawlerCalculatePremiumApplyMessage {
             private String customerSource;
             @JsonProperty("totalNetPremium")
             @JSONField(name = "totalNetPremium")
-            private Integer totalNetPremium;
+            private Double totalNetPremium;
             @JsonProperty("addedValueTax")
             @JSONField(name = "addedValueTax")
-            private Integer addedValueTax;
+            private Double addedValueTax;
             @JsonProperty("relationPolicy")
             @JSONField(name = "relationPolicy")
             private String relationPolicy;
@@ -393,8 +426,8 @@ public class AnShengCrawlerCalculatePremiumApplyMessage {
                 this.renewType = "";
                 this.serviceNetCar = "";
                 this.customerSource = "";
-                this.totalNetPremium = 0;
-                this.addedValueTax = 0;
+                this.totalNetPremium = 0.0;
+                this.addedValueTax = 0.0;
                 this.relationPolicy = "";
             }
         }
@@ -766,7 +799,8 @@ public class AnShengCrawlerCalculatePremiumApplyMessage {
             @JSONField(name = "vehicleTax")
             private VehicleTaxDTO vehicleTax;
 
-            public TargetListDTO(AnShengCrawlerSearchVehicleByVinResponse.DataDTO dataDTO, CarInfoVo carInfoVo, CustomerInfoVo policyHolderInfo, String departmentCode, String personnelName, String customerNegotiatePrice) {
+            public TargetListDTO(AnShengCrawlerSearchVehicleByVinResponse.DataDTO dataDTO, CarInfoVo carInfoVo, CustomerInfoVo policyHolderInfo,
+                                 String departmentCode, String personnelName, String customerNegotiatePrice,boolean bi,String productCode) {
                 AnShengCrawlerSearchVehicleByVinResponse.DataDTO.BrandAutoModelDTO brandAutoModel = dataDTO.getBrandAutoModel();
                 this.linkId = "";
                 this.targetId = "";
@@ -805,7 +839,7 @@ public class AnShengCrawlerCalculatePremiumApplyMessage {
                 this.tradeNameAlien = "";
                 this.brandAlien = "";
                 this.deptNameAlien = "";
-                this.checkVehicleInfo = new CheckVehicleInfoDTO();
+                this.checkVehicleInfo = new CheckVehicleInfoDTO(carInfoVo);
                 this.departmentCode = departmentCode;
                 this.dbVehicleType = brandAutoModel.getInsuranceCode();
                 this.vehicleLicenceCode = carInfoVo.getLicenseNo();
@@ -884,7 +918,7 @@ public class AnShengCrawlerCalculatePremiumApplyMessage {
                 this.ownershipAttributeCode = "1";
                 this.beneficiaryList = new ArrayList<>();
                 this.checkVehicleCodeSecret = "";
-                this.policyPricing = new PolicyPricingDTO(dataDTO, carInfoVo);
+                this.policyPricing = new PolicyPricingDTO(dataDTO, carInfoVo,bi, productCode);
                 this.vehicleTax = new VehicleTaxDTO(policyHolderInfo);
             }
 
@@ -918,8 +952,8 @@ public class AnShengCrawlerCalculatePremiumApplyMessage {
                 @JSONField(name = "checkTime")
                 private String checkTime;
 
-                public CheckVehicleInfoDTO() {
-                    this.usageAttributeCode = "1";
+                public CheckVehicleInfoDTO(CarInfoVo carInfoVo) {
+                    this.usageAttributeCode = carInfoVo.getVehicleUseCode();
                     this.usageAttributeCodePM = "";
                     this.runRegionCode = "";
                     this.checkVehicleFlag = "";
@@ -1160,7 +1194,7 @@ public class AnShengCrawlerCalculatePremiumApplyMessage {
                 @JSONField(name = "customerSource")
                 private String customerSource;
 
-                public PolicyPricingDTO(AnShengCrawlerSearchVehicleByVinResponse.DataDTO dataDTO, CarInfoVo carInfoVo) {
+                public PolicyPricingDTO(AnShengCrawlerSearchVehicleByVinResponse.DataDTO dataDTO, CarInfoVo carInfoVo,boolean bi,String productCode) {
                     AnShengCrawlerSearchVehicleByVinResponse.DataDTO.BrandAutoModelDTO brandAutoModel = dataDTO.getBrandAutoModel();
                     this.usageAttributeCode = carInfoVo.getCarNatureCode();
                     this.usageAttributeCodePM = "";
@@ -1238,13 +1272,9 @@ public class AnShengCrawlerCalculatePremiumApplyMessage {
                     this.ifModelRate = "0";
                     this.isMotorcade = "";
                     this.scoreRunId = "";
-                    if (carInfoVo.isTransfer()) {
-                        this.specialCarFlag = "1";
-                        this.transferDate = carInfoVo.getTransferDate();
-                    } else {
-                        this.specialCarFlag = "";
-                        this.transferDate = "";
-                    }
+                    boolean isSpecialCar = (carInfoVo.isTransfer() && "105002".equals(productCode)) || (carInfoVo.isTransferBi() && "109002".equals(productCode));
+                    this.specialCarFlag = isSpecialCar ? "1" : "";
+                    this.transferDate = isSpecialCar ? carInfoVo.getTransferDate() : "";
                     this.vehicleAlias = brandAutoModel.getVehicleAlias();
                 }
             }
@@ -1812,7 +1842,7 @@ public class AnShengCrawlerCalculatePremiumApplyMessage {
                         this.certificateNo = customerInfoVo.getIdentifyNumber();
                         this.sexCode = customerInfoVo.getGender();
                         this.birthday = customerInfoVo.getBirthday() + " 00:00:00";
-                        this.personnelAge = String.valueOf(customerInfoVo.getAge() + 1);
+                        this.personnelAge = String.valueOf(customerInfoVo.getAge());
                         this.address = customerInfoVo.getAddr();
                         this.positionn = "";
                         this.mobileTelephone = customerInfoVo.getMobile();

+ 533 - 0
tenant/insurance/quotation-ansheng/src/main/java/com/jzg/quotation/ansheng/crawler/entity/request/InsuranceContractRequest.java

@@ -0,0 +1,533 @@
+package com.jzg.quotation.ansheng.crawler.entity.request;
+
+import com.alibaba.fastjson2.JSON;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * 安盛保险合同请求实体
+ *
+ * @author xxxx
+ * @date 2025-xx-xx
+ */
+@Data
+public class InsuranceContractRequest {
+
+    /**
+     * 合同列表
+     */
+    private List<Contract> contracts;
+
+    /**
+     * 自动获取时间标识-是
+     */
+    private static final String AUTO_GET_TIME_FLAG_YES = "1";
+
+    /**
+     * 固定计划编码
+     */
+    private static final String FIXED_PLAN_CODE = "109";
+
+    /**
+     * 固定产品编码
+     */
+    private static final String FIXED_PRODUCT_CODE = "109002";
+
+    /**
+     * 构造函数:通过保费计算消息构建保险合同请求
+     *
+     * @param crawlerCalculatePremiumApply 保费计算申请消息
+     */
+    public InsuranceContractRequest(AnShengCrawlerCalculatePremiumApplyMessage crawlerCalculatePremiumApply) {
+        // 空值校验
+        Objects.requireNonNull(crawlerCalculatePremiumApply, "保费计算申请消息不能为空");
+        List<AnShengCrawlerCalculatePremiumApplyMessage.ContractsDTO> sourceContracts = crawlerCalculatePremiumApply.getContracts();
+        if (sourceContracts == null || sourceContracts.isEmpty()) {
+            this.contracts = Collections.emptyList();
+            return;
+        }
+
+        // 初始化集合
+        this.contracts = new ArrayList<>();
+        List<PolicyCoverage> policyCoverageList = new ArrayList<>();
+        List<PolicyRatio> policyRatioList = new ArrayList<>();
+
+        // 遍历源数据,收集保障和费率信息
+        for (AnShengCrawlerCalculatePremiumApplyMessage.ContractsDTO contractDTO : sourceContracts) {
+            if (contractDTO == null) {
+                continue;
+            }
+            // 安全转换集合
+            List<PolicyCoverage> coverages = convertList(contractDTO.getPolicyCoverages(), PolicyCoverage.class);
+            List<PolicyRatio> ratios = convertList(contractDTO.getPolicyRatios(), PolicyRatio.class);
+
+            policyCoverageList.addAll(coverages);
+            policyRatioList.addAll(ratios);
+        }
+
+        // 构建单个合同(取第一个源合同作为基础)
+        AnShengCrawlerCalculatePremiumApplyMessage.ContractsDTO firstContract = sourceContracts.get(0);
+        Contract targetContract = buildContract(firstContract, policyCoverageList, policyRatioList);
+        this.contracts.add(targetContract);
+    }
+
+    /**
+     * 构建合同对象
+     */
+    private Contract buildContract(AnShengCrawlerCalculatePremiumApplyMessage.ContractsDTO source,
+                                   List<PolicyCoverage> coverages,
+                                   List<PolicyRatio> ratios) {
+        Contract contract = new Contract();
+        // 基础属性赋值
+        contract.setAutoGetTimeFlag(AUTO_GET_TIME_FLAG_YES);
+        // 对象深度拷贝
+        contract.setPolicyExtend(convertObject(source.getPolicyExtend(), PolicyExtend.class));
+        contract.setAgentDefine(convertObject(source.getAgentDefine(), AgentDefine.class));
+        contract.setDepartmentDefine(convertObject(source.getDepartmentDefine(), DepartmentDefine.class));
+        contract.setSaleBusinessSource(convertObject(source.getSaleBusinessSource(), SaleBusinessSource.class));
+        // 集合拷贝
+        contract.setTargetList(convertList(source.getTargetList(), Target.class));
+        contract.setPolicyPersons(convertList(source.getPolicyPersons(), PolicyPerson.class));
+        // 赋值收集的保障和费率
+        contract.setPolicyCoverages(coverages);
+        contract.setPolicyRatios(ratios);
+
+        // 构建并设置保单基础信息
+        PolicyBase policyBase = convertObject(source.getPolicyBase(), PolicyBase.class);
+        if (policyBase != null) {
+            policyBase.setPlanCode(FIXED_PLAN_CODE);
+            policyBase.setProductCode(FIXED_PRODUCT_CODE);
+        }
+        contract.setPolicyBase(policyBase);
+
+        return contract;
+    }
+
+    /**
+     * 安全转换对象(避免空指针和类型转换异常)
+     */
+    private <T> T convertObject(Object source, Class<T> clazz) {
+        if (source == null) {
+            return null;
+        }
+        return JSON.toJavaObject(JSON.parseObject(JSON.toJSONString(source)), clazz);
+    }
+
+    /**
+     * 安全转换集合(解决原始代码泛型擦除问题)
+     */
+    private <T> List<T> convertList(List<?> sourceList, Class<T> clazz) {
+        if (sourceList == null || sourceList.isEmpty()) {
+            return new ArrayList<>();
+        }
+        return JSON.parseArray(JSON.toJSONString(sourceList), clazz);
+    }
+
+    // ==================== 内部静态类 ====================
+    @Data
+    public static class Contract {
+        private PolicyExtend policyExtend;
+        private AgentDefine agentDefine;
+        private String autoGetTimeFlag;
+        private PolicyBase policyBase;
+        private DepartmentDefine departmentDefine;
+        private SaleBusinessSource saleBusinessSource;
+        private List<Target> targetList;
+        private List<PolicyCoverage> policyCoverages;
+        private List<PolicyRatio> policyRatios;
+        private List<PolicyPerson> policyPersons;
+    }
+
+    @Data
+    public static class PolicyExtend {
+        private String eicRiskScore;
+        private String vehicleRiskType;
+    }
+
+    @Data
+    public static class AgentDefine {
+        private String agentCode;
+    }
+
+    @Data
+    public static class PolicyBase {
+        private String rescueCountRemark;
+        private String agentCode;
+        private String businessType;
+        private String businessTypeDetail;
+        private String insuranceBeginTime;
+        private String insuranceEndTime;
+        private String planCode;
+        private String productCode;
+        private String departmentCode;
+        private String targetType;
+        private BigDecimal shortTimeCoefficient;
+    }
+
+    @Data
+    public static class DepartmentDefine {
+        private String departmentCode;
+    }
+
+    @Data
+    public static class SaleBusinessSource {
+        private String saleAgentCode;
+    }
+
+    @Data
+    public static class Target {
+        private String linkId;
+        private String targetId;
+        private String ymIsbuyOrnot;
+        private String ymBirthDate;
+        private String ymElecBatteryType;
+        private String marketDate;
+        private String vehicleStyleUniqueId;
+        private String vehicleCertificateNo;
+        private String vehicleCertificateType;
+        private String vehiclePurchasePrice;
+        private String modelsListedYear;
+        private String platformId;
+        private String vehicleColor;
+        private String theftproofEquipmentCode;
+        private String isMortgage;
+        private String isSpecialInsuranceVehicle;
+        private String vehicleVer;
+        private String groupCode;
+        private String standardName;
+        private String tradeName;
+        private String tradeCode;
+        private String totalVehicleWeight;
+        private String seriesCode;
+        private String modelIdCode;
+        private String seats;
+        private String rbCode;
+        private String otherEnergyTypeDesc;
+        private String madeDate;
+        private String exhaustCapability;
+        private String noDamageYears;
+        private String specialVehicleFlag;
+        private String overseasVehicleFlag;
+        private String brand;
+        private String modelCodeAlien;
+        private String carNameAlien;
+        private String tradeNameAlien;
+        private String brandAlien;
+        private String deptNameAlien;
+        private CheckVehicleInfo checkVehicleInfo;
+        private String departmentCode;
+        private String dbVehicleType;
+        private String vehicleLicenceCode;
+        private String vehicleFrameNo;
+        private String engineNo;
+        private String firstRegisterDate;
+        private String firstRegisterDateStr;
+        private String vehicleCertificateDate;
+        private BigDecimal weigth;
+        private String totalMass;
+        private String priceType;
+        private BigDecimal purchasePrice;
+        private BigDecimal vehicleLossInsuredValue;
+        private String importFlag;
+        private String modelCode;
+        private String carName;
+        private String theftProof;
+        private String vehicleType;
+        private String pureRange;
+        private String vehicleClass;
+        private String vehicleStyle;
+        private String autoModelCode;
+        private String vehicleBrand;
+        private String brandChnName;
+        private String averageMile;
+        private String csTradeName;
+        private String csTradeCode;
+        private String brandCode;
+        private String series;
+        private String noticeType;
+        private String categoryName;
+        private String categoryCode;
+        private String configType;
+        private String partInfo;
+        private String powerType;
+        private String vehicleFgwCode;
+        private String vehicleFgwName;
+        private String vehicleModelType;
+        private String vehicleStyleDesc;
+        private String vehicleTypeName;
+        private String makeDate;
+        private String detailDesc;
+        private String vehicleCategory;
+        private String personnelName;
+        private String refitDesc;
+        private String basicRateCode;
+        private String deptName;
+        private String deptCode;
+        private String vehicleSeats;
+        private String fuelType;
+        private String autoModelChnName;
+        private String licenceTypeCode;
+        private String ecdemicVehicleFlag;
+        private String vehicleTonnages;
+        private String power;
+        private String maxDesignSpeed;
+        private String runCardCertificateDate;
+        private BigDecimal customerNegotiatePrice;
+        private BigDecimal originalCustomerNegotiatePrice;
+        private String fleetNo;
+        private String maker;
+        private String approvedCapacity;
+        private String ineffectualDate;
+        private String lastCheckDate;
+        private String rejectDate;
+        private String riskFlag;
+        private String targetType;
+        private String fleetRate;
+        private String usageAttributeCode;
+        private String usageAttributeCodePM;
+        private String ownershipAttributeCode;
+        private List<Object> beneficiaryList;
+        private String checkVehicleCodeSecret;
+        private PolicyPricing policyPricing;
+    }
+
+    @Data
+    public static class CheckVehicleInfo {
+        private String usageAttributeCode;
+        private String usageAttributeCodePM;
+        private String runRegionCode;
+        private String checkVehicleFlag;
+        private String uploadCheckVehicleInfo;
+        private String checkVehicleSituation;
+        private String vehicleChecker;
+        private String checkRecord;
+        private String checkTime;
+    }
+
+    @Data
+    public static class PolicyPricing {
+        private String useBasicDataCoverFlag;
+        private String usageAttributeCode;
+        private String usageAttributeCodePM;
+        private String ownershipAttributeCode;
+        private String nonclaimAdjust;
+        private String claimAdjustLevel;
+        private String lastyearStartDate;
+        private String lastyearEndDate;
+        private String partInfo;
+        private String isMortgage;
+        private String isSpecialInsuranceVehicle;
+        private String claimRecordBizScoreSize;
+        private String loanVehicleFlag;
+        private String injurySite;
+        private String transferFlag;
+        private String searchSequenceNo;
+        private String dbVehicleAutoModelChnName;
+        private String refitDesc;
+        private String lastYearIsTel;
+        private String reinsureFlag;
+        private String rateFloatFlag;
+        private String ratioFluctuateType;
+        private String repairFactory;
+        private BigDecimal dbVehicleWeigth;
+        private String riskScore;
+        private String riskScoreTwenty;
+        private String algrId;
+        private String riskScoreColor;
+        private String scoreReason;
+        private String scoreReasonLevel;
+        private String scoreReasonLevel2;
+        private String scoreReasonLevel3;
+        private String highRiskFlag;
+        private String effectReason;
+        private String dbVehicleVeiw;
+        private String lastYearCompanyId;
+        private String chargeRateFinal;
+        private String rateType;
+        private String priceRises;
+        private String underWriteRate;
+        private String autoRuleRatioOD;
+        private String autoRuleRatioTP;
+        private String autoRuleRatioTHEFT;
+        private String autoRuleRatioOTHER;
+        private String underwriteRuleRatioOD;
+        private String underwriteRuleRatioTP;
+        private String underwriteRuleRatioTHEFT;
+        private String underwriteRuleRatioOTHER;
+        private String tlType;
+        private Integer autoFloatRatioOD;
+        private String autoFloatRatioTp;
+        private String autoFloatRatioTheft;
+        private String autoFloatRatioOther;
+        private String appointAreaCode;
+        private String fdConfigId;
+        private String modelDiscount;
+        private Integer autoFloatHandingCost;
+        private String modelrate;
+        private String advicediscount;
+        private String dbVehicleBrand;
+        private String dbVehicleTypeName;
+        private String usageLicenceName;
+        private String vehicleTypeChiName;
+        private String autoFloatTargetRebate;
+        private String riskFlag;
+        private String dbExhaustCapability;
+        private String dbVehicleSeats;
+        private String dbVehicleTonnages;
+        private BigDecimal dbVehicleValue;
+        private String ifModelRate;
+        private String isMotorcade;
+        private String scoreRunId;
+        private String specialCarFlag;
+        private String transferDate;
+        private String vehicleAlias;
+    }
+
+    @Data
+    public static class PolicyCoverage {
+        private String dutyCode;
+        private String dutyChineseName;
+        private BigDecimal insuredAmount;
+        private String equipmentInsureAmount;
+        private String premiumRate;
+        private String deductibleDiscount;
+        private String totalActualPremium;
+        private Integer deductionRate;
+        private String serviceNum;
+        private String isTelpeson;
+        private String telPhone;
+        private String mileage;
+        private String setMeal;
+        private String fireMultiple;
+        private String allAmount;
+        private String riskPremum;
+        private String seats;
+        private String isShareSumDutyFlag;
+        private String deductible;
+        private BigDecimal totalStandardPremium;
+        private BigDecimal addedValueTax;
+        private BigDecimal totalAgreePremium;
+        private BigDecimal totalNetPremium;
+        private List<Object> newEquipmentList;
+        private List<Object> chargingPostDataList;
+        private String fullYearPremium;
+        private String dieAmount;
+        private String medicalAmount;
+        private String propertyAmount;
+        private String noFaultDieAmount;
+        private String noFaultMedicalAmount;
+        private String noFaultPropertyAmount;
+        private String basePremium;
+    }
+
+    @Data
+    public static class PolicyRatio {
+        private String linkId;
+        private String ratio;
+        private String discountValue;
+        private String dutyCode;
+        private String factorCode;
+        private String factorValue;
+        private BigDecimal ratioOd;
+        private BigDecimal ratioTp;
+        private BigDecimal ratioTheft;
+        private BigDecimal ratioOther;
+        private BigDecimal ratiototal;
+    }
+
+    @Data
+    public static class PolicyPerson {
+        private String personnelAttribute;
+        private String appliWithInsRelaship;
+        private String relationshipWithInsured;
+        private PersonnelInfoBase personnelInfoBase;
+    }
+
+    @Data
+    public static class PersonnelInfoBase {
+        private String personTypeDetailCode;
+        private String personTypeOverseas;
+        private String vipMark;
+        private Person person;
+    }
+
+    @Data
+    public static class Person {
+        private String issuedAt;
+        private String nation;
+        private String personnelName;
+        private Object personnelCode;
+        private String baseId;
+        private String certificateType;
+        private String certificateNo;
+        private String sexCode;
+        private String birthday;
+        private String personnelAge;
+        private String address;
+        private String positionn;
+        private String mobileTelephone;
+        private String email;
+        private String postcode;
+        private String effectedDate;
+        private String certType;
+        private String expiredDate;
+        private String isRuralOrUrban;
+        private String idCardAddress;
+        private String nationalityType;
+        private String workUnit;
+        private String homeAddressAfter;
+        private String certificateAddressAfter;
+        private String annualIncome;
+        private String other1Address;
+        private String other1ProvinceCode;
+        private String other1CityCode;
+        private String other1AreaCountyCode;
+        private String other2Address;
+        private String other2ProvinceCode;
+        private String other2CityCode;
+        private String other2AreaCountyCode;
+        private String certificateaddress;
+        private String certiProvinceCode;
+        private String certiCityCode;
+        private String certiAreaCode;
+        private String homeAddress;
+        private String homeProvinceCode;
+        private String homeCityCode;
+        private String homeAreaCountyCode;
+        private String homeAreaCode;
+        private String homeTelephone;
+        private String driverLicenseExpirationDate;
+        private String drivingExpirationDate;
+        private String certificateAddressId;
+        private String homeAddressId;
+        private String idCardAddressId;
+        private String other1AddressId;
+        private String other2AddressId;
+        private String emailId;
+        private String mobileTelephoneId;
+        private String homeTelephoneId;
+        private String officeTelephoneId;
+        private String amlId;
+        private String teleNoOwnerIsSelfFlag;
+        private String phoneOwnerCertiType;
+        private String phoneOwnerCertiNo;
+        private String phoneOwnerName;
+        private String idCardAccess;
+        private String longExpiredDate;
+        private String bankCode;
+        private String bankAccount;
+        private String department;
+        private String marriedStatu;
+        private String applyYears;
+        private String mobileTelephoneMarkBecause;
+        private String invalidateFlag;
+        private String fixedTelephoneMarkBecause;
+        private String driveLicenseType1;
+        private String bankAccountId;
+    }
+}

+ 2 - 0
tenant/insurance/quotation-ansheng/src/main/java/com/jzg/quotation/ansheng/crawler/entity/response/AnShengCrawlerCalculatePremiumApplyResponse.java

@@ -191,6 +191,8 @@ public class AnShengCrawlerCalculatePremiumApplyResponse  implements Serializabl
                 private String quoteTaskNo;
                 @JsonProperty("keyOverServer")
                 private String keyOverServer;
+                @JsonProperty("keyOverServerSY")
+                private String keyOverServerSY;
                 @JsonProperty("applyQueryCode")
                 private String applyQueryCode;
                 @JsonProperty("applyQueryPlatformID")

+ 26 - 0
tenant/insurance/quotation-ansheng/src/main/java/com/jzg/quotation/ansheng/crawler/service/impl/AnShengCrawlerRequestImpl.java

@@ -1,5 +1,6 @@
 package com.jzg.quotation.ansheng.crawler.service.impl;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson2.JSONObject;
 import com.jzg.commons.constants.dict.InsOrderStatusEnum;
 import com.jzg.commons.entity.quote.vo.QuoteVo;
@@ -104,11 +105,35 @@ public class AnShengCrawlerRequestImpl implements AnShengCrawlerRequest {
         // 车架号查询
         AnShengCrawlerSearchVehicleByVinRequest anShengCrawlerSearchVehicleByVinRequest = new AnShengCrawlerSearchVehicleByVinRequest(quoteVo.getCarInfoVo(), userDetailResponse.getDepartmentCode(), userDetailResponse.getAgentCode(),userDetailResponse.getRealBusinessType());
         List<AnShengCrawlerSearchVehicleByVinResponse.DataDTO> dataDTOS = anShengCrawlerRequestComponent.searchVehicleByVin(anShengCrawlerSearchVehicleByVinRequest, httpHeaders);
+        if (CollectionUtil.isEmpty(dataDTOS)){
+            String energyTypeCode = quoteVo.getCarInfoVo().getEnergyTypeCode();
+            boolean b = StringUtils.equals("0", energyTypeCode) || StringUtils.equals("4", energyTypeCode) || StringUtils.equals("5", energyTypeCode);
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("planCode",b ? "109" : "113");
+            jsonObject.put("departmentCode",userDetailResponse.getDepartmentCode());
+            jsonObject.put("usageAttributeCode","1");
+            jsonObject.put("vehicleName",quoteVo.getCarInfoVo().getBrandName());
+            jsonObject.put("vehicleDBFlag","1");
+            dataDTOS = anShengCrawlerRequestComponent.searchVehicleByName(jsonObject, httpHeaders);
+        }
+        if (CollectionUtil.isEmpty(dataDTOS)){
+            throw new SystemException("车型库类型为空");
+        }
         AnShengCrawlerSearchVehicleByVinResponse.DataDTO dataDTO = CarModelsFilterUtils.to(dataDTOS, quoteVo.getCarInfoVo());
         // 报价
         AnShengCrawlerCalculatePremiumApplyMessage crawlerCalculatePremiumApply = new AnShengCrawlerCalculatePremiumApplyMessage(quoteVo, dataDTO, userDetailResponse, departmentPlanCode, checkVehicleCodeSecretGenerate);
         log.info("安盛报价参数:{}", JSONObject.toJSONString(crawlerCalculatePremiumApply));
 
+        InsuranceContractRequest insuranceContractRequest = new  InsuranceContractRequest(crawlerCalculatePremiumApply);
+        PureRiskPremiumQueryResponse premiumQueryResponse = anShengCrawlerRequestComponent.pureRiskPremiumQuery(insuranceContractRequest, httpHeaders);
+        PureRiskPremiumQueryResponse.TargetsBean targetsBean = premiumQueryResponse.getData().getContracts().get(0).getTargets().get(0);
+        String modelCode = targetsBean.getRtaVehilceList().get(0).getModelCode();
+        String brandChnName = targetsBean.getBrandChnName();
+        for (AnShengCrawlerCalculatePremiumApplyMessage.ContractsDTO contract : crawlerCalculatePremiumApply.getContracts()) {
+            contract.getTargetList().get(0).setModelCode(modelCode);
+            contract.getTargetList().get(0).setCarName(brandChnName);
+        }
+        log.info("=============:{}", JSONObject.toJSONString(premiumQueryResponse));
         AnShengCrawlerCalculatePremiumApplyResponse calculatePremiumApply = anShengCrawlerRequestComponent.calculatePremiumApply(crawlerCalculatePremiumApply, httpHeaders);
         // 处理重复投保
         if (calculatePremiumApply.getMessage().contains("重复投保")) {
@@ -187,6 +212,7 @@ public class AnShengCrawlerRequestImpl implements AnShengCrawlerRequest {
             contract.setPolicyAttachments(new ArrayList<>());
             contract.getPolicyBase().setFirstTrialTaskNo(simpleData.getFirstTrialTaskNo());
             contract.getTargetList().get(0).setVehicleTax(applicationRequest.getContracts().get(0).getTargetList().get(0).getVehicleTax());
+            contract.setPolicyAttachments(imagesInfo);
         });
         log.info("安盛核保参数:{}", JSONObject.toJSONString(applicationRequest));
         // 核保