Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master'

liub 1 mēnesi atpakaļ
vecāks
revīzija
55e206fd4b
13 mainītis faili ar 258 papildinājumiem un 35 dzēšanām
  1. 4 1
      commons/src/main/java/com/jzg/commons/entity/dto/PtlAgreementCostParam.java
  2. 26 3
      platform/src/main/resources/mapper/JyxConfigMapper.xml
  3. 4 0
      tenant/insurance/quotation-chengtai/src/main/java/com/jzg/quotation/chengtai/api/build/ChengTaiAPIQuoteResultsVoBuild.java
  4. 12 0
      tenant/insurance/quotation-dajia/src/main/java/com/jzg/quotation/dajia/crawler/build/DaJiaCrawlerQuoteResultsVoBuild.java
  5. 33 1
      tenant/insurance/quotation-huanong/src/main/java/com/jzg/quotation/huanong/crawler/build/HuaNongCrawlerQuoteResultsVoBuild.java
  6. 14 0
      tenant/insurance/quotation-huatai/src/main/java/com/jzg/quotation/huatai/crawler/build/HuaTaiCrawlerQuoteResultsVoBuild.java
  7. 4 1
      tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/aop/aspect/QuoteVerificationAspect.java
  8. 9 11
      tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/controller/UnifyOrderManager.java
  9. 93 0
      tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/AgreementCacheService.java
  10. 2 2
      tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/impl/InsOrdersServiceImpl.java
  11. 24 0
      tenant/insurance/quotation-taishan/src/main/java/com/jzg/quotation/taishan/crawler/build/TaiShanCrawlerQuoteResultsVoBuild.java
  12. 27 16
      tenant/insurance/quotation-yongcheng/src/main/java/com/jzg/quotation/yongcheng/api/service/impl/YongChengApiRequestImpl.java
  13. 6 0
      tenant/organization/src/main/resources/mapper/PtlAgreementCostMapper.xml

+ 4 - 1
commons/src/main/java/com/jzg/commons/entity/dto/PtlAgreementCostParam.java

@@ -54,6 +54,9 @@ public class PtlAgreementCostParam extends PageRequest {
     @Schema(description = "是否启用")
     @Schema(description = "是否启用")
     private String isEnabled;
     private String isEnabled;
 
 
-
+    @Schema(description = "协议id")
+    private String agreementId;
+    @Schema(description = "承包规则id")
+    private String coverRuleId;
 
 
 }
 }

+ 26 - 3
platform/src/main/resources/mapper/JyxConfigMapper.xml

@@ -121,9 +121,32 @@
 
 
     <select id="selectMainInsurance" resultType="com.jzg.commons.entity.vo.JyxConfigVo">
     <select id="selectMainInsurance" resultType="com.jzg.commons.entity.vo.JyxConfigVo">
         select
         select
-        <include refid="params"/> ,
-        jb.id as blame_id,jb.blame,jb.blame_code,jb.blame_coverage,jb.blame_premium,jb.system_code as blame_system_code,jb.jyx_config_id as blame_jyx_config_id,
-        js.id as setting_id,js.seats,js.coverage as setting_coverage,js.premium as setting_premium,js.system_code as setting_system_code,js.jyx_config_id as setting_jyx_config_id
+        jc.`id`,
+        jc.`product_type`,
+        jc.`parent_id`,
+        jc.`product_name`,
+        jc.`alias`,
+        jc.`company`,
+        jc.`product_code`,
+        jc.`connection_method`,
+        jc.`premium_setting`,
+        jc.`coverage` AS jsCoverage,
+        jc.`premium` AS jsPremium,
+        jc.`system_code`,
+        jc.`is_delete` AS isDelete,
+        jb.id AS blame_id,
+        jb.blame,
+        jb.blame_code,
+        jb.blame_coverage,
+        jb.blame_premium,
+        jb.system_code AS blame_system_code,
+        jb.jyx_config_id AS blame_jyx_config_id,
+        js.id AS setting_id,
+        js.seats,
+        js.coverage AS setting_coverage,
+        js.premium AS setting_premium,
+        js.system_code AS setting_system_code,
+        js.jyx_config_id AS setting_jyx_config_id
         from jyx_config jc
         from jyx_config jc
         left join jyx_blame jb on jc.id = jb.jyx_config_id AND jb.is_delete = 0
         left join jyx_blame jb on jc.id = jb.jyx_config_id AND jb.is_delete = 0
         left join jyx_setting js on jc.id = js.jyx_config_id AND js.is_delete = 0
         left join jyx_setting js on jc.id = js.jyx_config_id AND js.is_delete = 0

+ 4 - 0
tenant/insurance/quotation-chengtai/src/main/java/com/jzg/quotation/chengtai/api/build/ChengTaiAPIQuoteResultsVoBuild.java

@@ -134,6 +134,10 @@ public final class ChengTaiAPIQuoteResultsVoBuild {
                     .fluentPut("scoreName", "自主定价系数")
                     .fluentPut("scoreName", "自主定价系数")
                     .fluentPut("scoreKey","coefficient")
                     .fluentPut("scoreKey","coefficient")
                     .fluentPut("score", coefficientVal));
                     .fluentPut("score", coefficientVal));
+            scoreJson.add(new JSONObject()
+                    .fluentPut("scoreName", "一账通评分")
+                    .fluentPut("scoreKey", "YztScore")
+                    .fluentPut("score", premiumCalculationResponse.getYztScore().getCentile()));
         }
         }
         scoreVo.setScoreJson(scoreJson);
         scoreVo.setScoreJson(scoreJson);
         return scoreVo;
         return scoreVo;

+ 12 - 0
tenant/insurance/quotation-dajia/src/main/java/com/jzg/quotation/dajia/crawler/build/DaJiaCrawlerQuoteResultsVoBuild.java

@@ -27,6 +27,7 @@ import java.math.BigDecimal;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
 /**
 /**
@@ -192,6 +193,7 @@ public final class DaJiaCrawlerQuoteResultsVoBuild {
         }
         }
         boolean sy = CollectionUtil.isNotEmpty(businessInsurance.getItemKinds());
         boolean sy = CollectionUtil.isNotEmpty(businessInsurance.getItemKinds());
         if (sy) {
         if (sy) {
+            String flatCarReinsuredMessage = businessInsurance.getProductInfo().getFlatCarReinsuredMessage();
             scoreVo.setSyLossRation(StringUtils.isNotEmpty(businessInsurance.getCoefficientInfo().getLossRatioBi()) ? businessInsurance.getCoefficientInfo().getLossRatioBi() : null);
             scoreVo.setSyLossRation(StringUtils.isNotEmpty(businessInsurance.getCoefficientInfo().getLossRatioBi()) ? businessInsurance.getCoefficientInfo().getLossRatioBi() : null);
             scoreVo.setBiClaims(String.valueOf(new BigDecimal(businessInsurance.getCoefficientInfo().getLastPolicyNum()).intValue()));
             scoreVo.setBiClaims(String.valueOf(new BigDecimal(businessInsurance.getCoefficientInfo().getLastPolicyNum()).intValue()));
             String renewalFrequency = businessInsurance.getCoefficientInfo().getRenewalFrequency();
             String renewalFrequency = businessInsurance.getCoefficientInfo().getRenewalFrequency();
@@ -215,6 +217,16 @@ public final class DaJiaCrawlerQuoteResultsVoBuild {
         }
         }
         CompulsoryInsuranceDTO.CoefficientInfoDTO coefficientInfo = daJiaCrawlerSaveResponse.getCompulsoryInsurance().getCoefficientInfo();
         CompulsoryInsuranceDTO.CoefficientInfoDTO coefficientInfo = daJiaCrawlerSaveResponse.getCompulsoryInsurance().getCoefficientInfo();
         JSONArray scoreArray = new JSONArray();
         JSONArray scoreArray = new JSONArray();
+        Optional.ofNullable(businessInsurance)
+                .map(BusinessInsuranceDTO::getProductInfo)
+                .map(BusinessInsuranceDTO.ProductInfoDTO::getFlatCarReinsuredMessage)
+                .filter(StringUtils::isNotEmpty)
+                .ifPresent(msg ->
+                        scoreArray.add(new JSONObject()
+                                .fluentPut("scoreName", "上年承保险别")
+                                .fluentPut("scoreKey", "priorCoverage")
+                                .fluentPut("score", msg))
+                );
         scoreArray.add(new JSONObject()
         scoreArray.add(new JSONObject()
                 .fluentPut("scoreName","交强类型评分")
                 .fluentPut("scoreName","交强类型评分")
                 .fluentPut("scoreKey","jqPubScores")
                 .fluentPut("scoreKey","jqPubScores")

+ 33 - 1
tenant/insurance/quotation-huanong/src/main/java/com/jzg/quotation/huanong/crawler/build/HuaNongCrawlerQuoteResultsVoBuild.java

@@ -15,6 +15,8 @@ import com.jzg.quotation.huanong.enums.dictionary.Risk;
 import org.springframework.util.ObjectUtils;
 import org.springframework.util.ObjectUtils;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
@@ -52,6 +54,9 @@ public final class HuaNongCrawlerQuoteResultsVoBuild {
                 .stream()
                 .stream()
                 .collect(Collectors.toMap(x -> x.getContractMain().getRiskCode(), x -> x));
                 .collect(Collectors.toMap(x -> x.getContractMain().getRiskCode(), x -> x));
 
 
+        // 上年承保险别
+        Map<String, List<String>> companyRiskMap = new HashMap<>();
+
         contract.forEach(contractDTO -> {
         contract.forEach(contractDTO -> {
 
 
             HuaNongCrawlerSaveResponse.BusinessDataDTO.ContractDTO contractDTO1 = collect.get(contractDTO.getContractMain()
             HuaNongCrawlerSaveResponse.BusinessDataDTO.ContractDTO contractDTO1 = collect.get(contractDTO.getContractMain()
@@ -88,8 +93,35 @@ public final class HuaNongCrawlerQuoteResultsVoBuild {
                 biRiskInfoVo.setStartDate(contractDTO.getCoverage().get(0).getValidDate());
                 biRiskInfoVo.setStartDate(contractDTO.getCoverage().get(0).getValidDate());
                 biRiskInfoVo.setEndDate(contractDTO.getCoverage().get(0).getExpiryDate());
                 biRiskInfoVo.setEndDate(contractDTO.getCoverage().get(0).getExpiryDate());
                 quoteResultsVo.setBiRiskInfoVo(biRiskInfoVo);
                 quoteResultsVo.setBiRiskInfoVo(biRiskInfoVo);
+
+                // 上年承保险别
+                for (HuaNongCrawlerQuotedPriceResponse.BusinessDataDTO.ContractDTO.PlatFormMessageDTO.ReInsureDTO reInsureDTO : contractDTO.getPlatFormMessage().getReInsure()) {
+                    String insurerName = reInsureDTO.getInsurerName();
+                    String coverageName = reInsureDTO.getCoverageName();
+                    companyRiskMap.computeIfAbsent(insurerName, k -> new ArrayList<>()).add(coverageName);
+                }
+
             }
             }
         });
         });
+        // 上年承保险别
+        StringBuilder lastYearRiskSb = new StringBuilder();
+        for (Map.Entry<String, List<String>> entry : companyRiskMap.entrySet()) {
+            String company = entry.getKey();
+            List<String> riskList = entry.getValue();
+            // 保险公司:险种1、险种2、险种3;
+            lastYearRiskSb.append(company)
+                    .append(":")
+                    .append(String.join("、", riskList))
+                    .append(";");
+        }
+        JSONArray scoreJson = new JSONArray();
+        scoreJson.add(new JSONObject()
+                .fluentPut("scoreName", "上年承保险别")
+                .fluentPut("scoreKey", "lastYearRisk")
+                .fluentPut("score", lastYearRiskSb.toString()));
+        quoteResultsVo.getScoreVo().setScoreJson(scoreJson);
+
+
         // 计算总保费 = 交强险 + 商业险 + 驾意险 + 车船税
         // 计算总保费 = 交强险 + 商业险 + 驾意险 + 车船税
         QuoteResultsVo.CostsVo costs = quoteResultsVo.getCosts();
         QuoteResultsVo.CostsVo costs = quoteResultsVo.getCosts();
         double sumPremium = 0.0;
         double sumPremium = 0.0;
@@ -121,7 +153,7 @@ public final class HuaNongCrawlerQuoteResultsVoBuild {
 
 
         scoreVo.setLossRation(ultimateScoreBiCi);
         scoreVo.setLossRation(ultimateScoreBiCi);
 
 
-        JSONArray scoreJson = new JSONArray();
+        JSONArray scoreJson = scoreVo.getScoreJson();
         scoreJson.add(new JSONObject()
         scoreJson.add(new JSONObject()
                 .fluentPut("scoreName", "交商合计分")
                 .fluentPut("scoreName", "交商合计分")
                 .fluentPut("scoreKey", "mark")
                 .fluentPut("scoreKey", "mark")

+ 14 - 0
tenant/insurance/quotation-huatai/src/main/java/com/jzg/quotation/huatai/crawler/build/HuaTaiCrawlerQuoteResultsVoBuild.java

@@ -18,6 +18,7 @@ import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.LocalTime;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatter;
+import java.util.Collections;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
@@ -74,6 +75,19 @@ public class HuaTaiCrawlerQuoteResultsVoBuild {
                 .fluentPut("scoreName","商业业务品质")
                 .fluentPut("scoreName","商业业务品质")
                 .fluentPut("scoreKey","SyBusiQuality")
                 .fluentPut("scoreKey","SyBusiQuality")
                 .fluentPut("score",quoteResponseData.getApplicationdto().getBicategory()));
                 .fluentPut("score",quoteResponseData.getApplicationdto().getBicategory()));
+        List<HtCrawlerQuoteResponse.DataDTO.CoverageDTOList.CoverageDTO> coverageDTOList = quoteResponseData.getCoveragedtolist().getCoveragedto();
+        if (coverageDTOList != null && !coverageDTOList.isEmpty()) {
+            // 获取商业险种是否有上年保单出单日期、上年保单开始结束日期
+            Map<String, String> renewalMap = coverageDTOList.stream().filter(x -> StringUtils.isNotBlank(x.getLaststartdate()) && StringUtils.isNotBlank(x.getLastenddate()) && !ContractEnum.C_BZ.getKindCode().equals(x.getComcoveragecode())).collect(Collectors.toMap(HtCrawlerQuoteResponse.DataDTO.CoverageDTOList.CoverageDTO::getCoveragename, x -> x.getLastbilldate() != null ? x.getLastbilldate() : ""));
+            // 放入 scoreJson
+            // 获取renewalMap中所有的key 逗号分隔
+            if (!renewalMap.isEmpty()) {
+                scoreJson.add(new JSONObject()
+                        .fluentPut("scoreName", "上年承保险别")
+                        .fluentPut("scoreKey", "HTOrigItemKind")
+                        .fluentPut("score", String.join(",", renewalMap.keySet())));
+            }
+        }
         quoteResultsVo.getScoreVo().setScoreJson(scoreJson);
         quoteResultsVo.getScoreVo().setScoreJson(scoreJson);
 
 
         //续保标志
         //续保标志

+ 4 - 1
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/aop/aspect/QuoteVerificationAspect.java

@@ -252,13 +252,16 @@ public class QuoteVerificationAspect {
         List<RuleAttrMappingVo> ruleAttrMappingVoList = RuleAttrMappingVo.getRuleAttrMappingVoList(insOrdersOther,insOrdersCarInfo,
         List<RuleAttrMappingVo> ruleAttrMappingVoList = RuleAttrMappingVo.getRuleAttrMappingVoList(insOrdersOther,insOrdersCarInfo,
                 riskList, insOrdersCarUserInfos, kindList, insOrdersCosts, insOrdersAccidentalDriving, isNewCar);
                 riskList, insOrdersCarUserInfos, kindList, insOrdersCosts, insOrdersAccidentalDriving, isNewCar);
 
 
+        // 字典数据在一次报价内是只读不变的,提到循环外避免N+1远程调用
+        // 修复批量报价时该方法被 organization 服务打爆的问题
+        List<PtlAgreementUndwrtRulesDictLabal> undwrtRulesDictList = ptlNewAgreementClient.getUndwrtRulesDictList();
+
         for (int i = 0; i < agreementProductCosts.size(); i++) {
         for (int i = 0; i < agreementProductCosts.size(); i++) {
             //判断是否匹配
             //判断是否匹配
             log.info("费用因子匹配开始:" + agreementProductCosts.get(i).getId());
             log.info("费用因子匹配开始:" + agreementProductCosts.get(i).getId());
 //
 //
             log.info("车牌号:" + insOrdersCarInfo.getLicenseNo());
             log.info("车牌号:" + insOrdersCarInfo.getLicenseNo());
             logs.append("费用id:" + agreementProductCosts.get(i).getId() + "\n");
             logs.append("费用id:" + agreementProductCosts.get(i).getId() + "\n");
-            List<PtlAgreementUndwrtRulesDictLabal> undwrtRulesDictList = ptlNewAgreementClient.getUndwrtRulesDictList();
 
 
             if (FactorMatch.judgements(agreementProductCosts.get(i).getPtlAgreementCostRuleList(),ruleAttrMappingVoList,undwrtRulesAttrList,logs, undwrtRulesDictList)) {
             if (FactorMatch.judgements(agreementProductCosts.get(i).getPtlAgreementCostRuleList(),ruleAttrMappingVoList,undwrtRulesAttrList,logs, undwrtRulesDictList)) {
                 log.info("匹配到的费用id:{}",agreementProductCosts.get(i).getId());
                 log.info("匹配到的费用id:{}",agreementProductCosts.get(i).getId());

+ 9 - 11
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/controller/UnifyOrderManager.java

@@ -134,6 +134,9 @@ public class UnifyOrderManager {
     @Autowired
     @Autowired
     OrgClient orgClient;
     OrgClient orgClient;
 
 
+    @Autowired
+    AgreementCacheService agreementCacheService;
+
     @Autowired
     @Autowired
     InsOrdersPolicyService insOrdersPolicyService;
     InsOrdersPolicyService insOrdersPolicyService;
 
 
@@ -268,12 +271,7 @@ public class UnifyOrderManager {
         AssertionUtils.isFail(esmInsCompanyHttpResult.getCode() != 200, esmInsCompanyHttpResult.getMsg());
         AssertionUtils.isFail(esmInsCompanyHttpResult.getCode() != 200, esmInsCompanyHttpResult.getMsg());
         String companyName = CompanyConstants.getCompanyNameByCode(esmInsCompanyHttpResult.getData().getCompanyCode());
         String companyName = CompanyConstants.getCompanyNameByCode(esmInsCompanyHttpResult.getData().getCompanyCode());
 
 
-        log.info("查询保司配置的协议:systemCode=[{}],companyId=[{}]", systemCode, esmInsCompanyHttpResult.getData().getId());
-        HttpResult<List<PtlAgreement>> byCompanyId = orgClient.getByCompanyId(esmInsCompanyHttpResult.getData().getId(), systemCode);
-        if (CollUtil.isEmpty(byCompanyId.getData())) {
-            AssertionUtils.isFail(true, "保司未配置协议");
-        }
-        PtlAgreement ptlAgreement = byCompanyId.getData().stream().filter(x -> x.getId().equals(quoteVo.getOrder().getAgreementId())).findFirst().orElse(null);
+        PtlAgreement ptlAgreement = agreementCacheService.getByAgreementId(quoteVo.getOrder().getAgreementId());
         if (Objects.isNull(ptlAgreement)) {
         if (Objects.isNull(ptlAgreement)) {
             log.info("协议不存在。quoteVo.getOrder().getAgreementId()=[{}]", quoteVo.getOrder().getAgreementId());
             log.info("协议不存在。quoteVo.getOrder().getAgreementId()=[{}]", quoteVo.getOrder().getAgreementId());
             throw new SystemException("当前无调度协议配置,无法确认协议");
             throw new SystemException("当前无调度协议配置,无法确认协议");
@@ -857,8 +855,8 @@ public class UnifyOrderManager {
         String systemCode = getSystemCode();
         String systemCode = getSystemCode();
 
 
         //先默认第一个协议
         //先默认第一个协议
-        HttpResult<List<PtlAgreement>> byCompanyId = orgClient.getByCompanyId(insOrders.getCompanyId(), systemCode);
-        if (byCompanyId.getData().isEmpty()) {
+        List<PtlAgreement> byCompanyId = agreementCacheService.getByCompanyId(insOrders.getCompanyId(), systemCode);
+        if (CollUtil.isEmpty(byCompanyId)) {
             AssertionUtils.isFail(true, "保司未配置协议");
             AssertionUtils.isFail(true, "保司未配置协议");
         }
         }
 
 
@@ -892,8 +890,8 @@ public class UnifyOrderManager {
         String systemCode = getSystemCode();
         String systemCode = getSystemCode();
 
 
         //先默认第一个协议
         //先默认第一个协议
-        HttpResult<List<PtlAgreement>> byCompanyId = orgClient.getByCompanyId(insOrders.getCompanyId(), systemCode);
-        if (byCompanyId.getData().isEmpty()) {
+        List<PtlAgreement> byCompanyId = agreementCacheService.getByCompanyId(insOrders.getCompanyId(), systemCode);
+        if (CollUtil.isEmpty(byCompanyId)) {
             AssertionUtils.isFail(true, "保司未配置协议");
             AssertionUtils.isFail(true, "保司未配置协议");
         }
         }
 
 
@@ -920,7 +918,7 @@ public class UnifyOrderManager {
         clauseDataVo.getOrder().setInsuranceCompanyId(esmInsCompanyHttpResult.getData().getId());
         clauseDataVo.getOrder().setInsuranceCompanyId(esmInsCompanyHttpResult.getData().getId());
         clauseDataVo.getOrder().setInsuranceCompanyCode(esmInsCompanyHttpResult.getData().getCompanyCode());
         clauseDataVo.getOrder().setInsuranceCompanyCode(esmInsCompanyHttpResult.getData().getCompanyCode());
         clauseDataVo.getOrder().setApiType(Integer.parseInt(insOrders.getApiType()));
         clauseDataVo.getOrder().setApiType(Integer.parseInt(insOrders.getApiType()));
-        clauseDataVo.getOrder().setAgreementId(byCompanyId.getData().get(0).getId());
+        clauseDataVo.getOrder().setAgreementId(byCompanyId.get(0).getId());
         QuotationBaseService quoteService = companyFactory.getClauseDataService(clauseDataVo);
         QuotationBaseService quoteService = companyFactory.getClauseDataService(clauseDataVo);
         quoteService.queryClauseData(clauseDataVo);
         quoteService.queryClauseData(clauseDataVo);
 
 

+ 93 - 0
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/AgreementCacheService.java

@@ -0,0 +1,93 @@
+package com.jzg.quotation.summary.service;
+
+import cn.hutool.json.JSONUtil;
+import com.jzg.commons.core.page.HttpResult;
+import com.jzg.commons.entity.po.PtlAgreement;
+import com.jzg.quotation.commons.client.OrgClient;
+import lombok.extern.slf4j.Slf4j;
+import org.redisson.api.RBucket;
+import org.redisson.api.RedissonClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * 协议信息 Redis 缓存服务
+ * <p>
+ * 用于降低批量报价时对 organization 服务的并发压力。
+ * 多实例部署时缓存共享。
+ * </p>
+ */
+@Slf4j
+@Service
+public class AgreementCacheService {
+
+    @Autowired
+    private RedissonClient redissonClient;
+
+    @Autowired
+    private OrgClient orgClient;
+
+    private static final String AGREEMENT_ID_KEY_PREFIX = "quotation:agreement:id:";
+    private static final String AGREEMENT_COMPANY_KEY_PREFIX = "quotation:agreement:company:";
+    private static final long CACHE_TTL = 10;
+    private static final TimeUnit CACHE_TTL_UNIT = TimeUnit.MINUTES;
+
+    /**
+     * 根据协议ID获取协议(带Redis缓存)
+     */
+    public PtlAgreement getByAgreementId(String agreementId) {
+        if (agreementId == null) {
+            return null;
+        }
+        String key = AGREEMENT_ID_KEY_PREFIX + agreementId;
+        try {
+            RBucket<String> bucket = redissonClient.getBucket(key);
+            String cached = bucket.get();
+            if (cached != null) {
+                log.debug("getByAgreementId cache hit, agreementId={}", agreementId);
+                return JSONUtil.toBean(cached, PtlAgreement.class);
+            }
+            log.debug("getByAgreementId cache miss, agreementId={}", agreementId);
+            PtlAgreement agreement = orgClient.getByAgreementId(agreementId);
+            if (agreement != null) {
+                bucket.set(JSONUtil.toJsonStr(agreement), CACHE_TTL, CACHE_TTL_UNIT);
+            }
+            return agreement;
+        } catch (Exception e) {
+            log.error("getByAgreementId from redis cache failed, agreementId={}", agreementId, e);
+            return orgClient.getByAgreementId(agreementId);
+        }
+    }
+
+    /**
+     * 根据保险公司ID获取协议列表(带Redis缓存)
+     */
+    public List<PtlAgreement> getByCompanyId(String companyId, String systemCode) {
+        if (companyId == null || systemCode == null) {
+            return null;
+        }
+        String key = AGREEMENT_COMPANY_KEY_PREFIX + companyId + ":" + systemCode;
+        try {
+            RBucket<String> bucket = redissonClient.getBucket(key);
+            String cached = bucket.get();
+            if (cached != null) {
+                log.debug("getByCompanyId cache hit, companyId={}, systemCode={}", companyId, systemCode);
+                return JSONUtil.toList(cached, PtlAgreement.class);
+            }
+            log.debug("getByCompanyId cache miss, companyId={}, systemCode={}", companyId, systemCode);
+            HttpResult<List<PtlAgreement>> result = orgClient.getByCompanyId(companyId, systemCode);
+            List<PtlAgreement> agreements = result != null ? result.getData() : null;
+            if (agreements != null) {
+                bucket.set(JSONUtil.toJsonStr(agreements), CACHE_TTL, CACHE_TTL_UNIT);
+            }
+            return agreements;
+        } catch (Exception e) {
+            log.error("getByCompanyId from redis cache failed, companyId={}, systemCode={}", companyId, systemCode, e);
+            HttpResult<List<PtlAgreement>> result = orgClient.getByCompanyId(companyId, systemCode);
+            return result != null ? result.getData() : null;
+        }
+    }
+}

+ 2 - 2
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/impl/InsOrdersServiceImpl.java

@@ -947,8 +947,8 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
             if (CollectionUtil.isNotEmpty(accidentalDrivingList) && jyPremium != null) {
             if (CollectionUtil.isNotEmpty(accidentalDrivingList) && jyPremium != null) {
                 // 按保费乘以数量计算每个驾意险的总保费
                 // 按保费乘以数量计算每个驾意险的总保费
                 for (InsOrdersAccidentalDriving driving : accidentalDrivingList){
                 for (InsOrdersAccidentalDriving driving : accidentalDrivingList){
-                    BigDecimal perPremium = jyPremium.multiply(new BigDecimal(driving.getQuantity())).setScale(2, java.math.RoundingMode.HALF_UP);
-                    driving.setAmount(perPremium.toString());
+                    //BigDecimal perPremium = jyPremium.multiply(new BigDecimal(driving.getQuantity())).setScale(2, java.math.RoundingMode.HALF_UP);
+                    driving.setAmount(jyPremium.toString());
                 }
                 }
                 insOrdersAccidentalDrivingService.updateBatchById(accidentalDrivingList);
                 insOrdersAccidentalDrivingService.updateBatchById(accidentalDrivingList);
             }
             }

+ 24 - 0
tenant/insurance/quotation-taishan/src/main/java/com/jzg/quotation/taishan/crawler/build/TaiShanCrawlerQuoteResultsVoBuild.java

@@ -70,6 +70,30 @@ public class TaiShanCrawlerQuoteResultsVoBuild {
                     .fluentPut("riskScore", saveResponse.getResult().getProposalInfo().getRiskScore()));
                     .fluentPut("riskScore", saveResponse.getResult().getProposalInfo().getRiskScore()));
         }
         }
 
 
+        // 上年承保险别
+        // 泰山 ItemKind 单险种没有 lastStartDate/lastEndDate,用 ProductInfo 整单维度的上年保单日期作为"是否续保"判断
+        // itemKinds 本身已是本年承保的险种列表,不需要"不投保"过滤
+        if (saveResponse != null
+                && saveResponse.getResult() != null
+                && saveResponse.getResult().getBusinessInsurance() != null) {
+            TaiShanCrawlerQuotationSaveResponse.Result.BusinessInsurance businessInsurance = saveResponse.getResult().getBusinessInsurance();
+            if (CollUtil.isNotEmpty(businessInsurance.getItemKinds())
+                    && businessInsurance.getProductInfo() != null
+                    && StringUtils.hasText(businessInsurance.getProductInfo().getLastStartDate())
+                    && StringUtils.hasText(businessInsurance.getProductInfo().getLastEndDate())) {
+                String origItemKinds = businessInsurance.getItemKinds().stream()
+                        .map(TaiShanCrawlerQuotationSaveResponse.Result.BusinessInsurance.ItemKind::getKindName)
+                        .filter(StringUtils::hasText)
+                        .collect(Collectors.joining(","));
+                if (StringUtils.hasText(origItemKinds)) {
+                    scoreJson.add(new JSONObject()
+                            .fluentPut("scoreName", "上年承保险别")
+                            .fluentPut("scoreKey", "TSOrigItemKind")
+                            .fluentPut("score", origItemKinds));
+                }
+            }
+        }
+
         if(riskResponse != null && riskResponse.getResult() != null){
         if(riskResponse != null && riskResponse.getResult() != null){
             // 续保标识逻辑:renewalClass不为空时jq_renewalflag=1,否则=0;sy_renewalflag 一样  有值就是续保  对照python最新更改
             // 续保标识逻辑:renewalClass不为空时jq_renewalflag=1,否则=0;sy_renewalflag 一样  有值就是续保  对照python最新更改
             String renewalClass = riskResponse.getResult().getRenewalClass();
             String renewalClass = riskResponse.getResult().getRenewalClass();

+ 27 - 16
tenant/insurance/quotation-yongcheng/src/main/java/com/jzg/quotation/yongcheng/api/service/impl/YongChengApiRequestImpl.java

@@ -169,12 +169,21 @@ public class YongChengApiRequestImpl implements YongChengApiRequest {
 
 
         //build参数
         //build参数
         List<String> requestInfoList = new ArrayList<>();
         List<String> requestInfoList = new ArrayList<>();
-
+        BigDecimal finalNegotiatedPrice = negotiatedPrice;
+        quoteVo.getKindInfoVo().stream()
+        .filter(Objects::nonNull) // 防止集合内元素为null
+        .forEach(item -> {
+            if ("A".equals(item.getPlatformKindCode())) {
+                String priceStr = finalNegotiatedPrice.toString();
+                item.setAmount(priceStr);
+                item.setUnitAmount(priceStr);
+            }
+        });
         QuoteRequest quoteRequest = this.builderParams(configurationProperties, quoteVo, vehicleInfo, negotiatedPrice.toString());
         QuoteRequest quoteRequest = this.builderParams(configurationProperties, quoteVo, vehicleInfo, negotiatedPrice.toString());
         QuoteResponse quoteResponse = this.getResponse(quoteRequest,quoteVo, requestInfoList,url);
         QuoteResponse quoteResponse = this.getResponse(quoteRequest,quoteVo, requestInfoList,url);
 
 
         QuoteResultsVo quoteResultsVo = buildQuoteRespVo(order.getOrdersNo(), quoteResponse, quoteVo);
         QuoteResultsVo quoteResultsVo = buildQuoteRespVo(order.getOrdersNo(), quoteResponse, quoteVo);
-
+        quoteResultsVo.setCarActualValue(depreciationPrice);
         return quoteResultsVo;
         return quoteResultsVo;
     }
     }
 
 
@@ -483,11 +492,9 @@ public class YongChengApiRequestImpl implements YongChengApiRequest {
         // 保险公司订单号
         // 保险公司订单号
         quoteRespVo.setCompanyOrderNo(rd.getBase().getCresvTxt6());
         quoteRespVo.setCompanyOrderNo(rd.getBase().getCresvTxt6());
 
 
-        List<KindInfoVo> kindList = buildQuoteKindList(rd);
-
-        quoteRespVo.setKindInfoVo(kindList);
+//        List<KindInfoVo> kindList = buildQuoteKindList(rd);
 
 
-        buildQuoteKindList(rd,quoteVo.getKindInfoVo());
+        quoteRespVo.setKindInfoVo(buildQuoteKindList(rd,quoteVo.getKindInfoVo()));
 
 
         //车船税
         //车船税
         double sumTax = 0;
         double sumTax = 0;
@@ -497,6 +504,8 @@ public class YongChengApiRequestImpl implements YongChengApiRequest {
         //意外险
         //意外险
         if (null != rd.getProposal()) {
         if (null != rd.getProposal()) {
             jyPremium = Double.parseDouble(rd.getProposal().getPremium());
             jyPremium = Double.parseDouble(rd.getProposal().getPremium());
+            quoteVo.getAccidentalDrivings().get(0).setPremium(String.valueOf(jyPremium));
+//            quoteRespVo.set
         }
         }
 
 
 
 
@@ -691,15 +700,17 @@ public class YongChengApiRequestImpl implements YongChengApiRequest {
         if (null == rd.getCvrgListSY() || null == rd.getCvrgListSY().getCvrgSY()) {
         if (null == rd.getCvrgListSY() || null == rd.getCvrgListSY().getCvrgSY()) {
             return Collections.emptyList();
             return Collections.emptyList();
         }
         }
-
         List<KindInfoVo> kindList = new ArrayList<>();
         List<KindInfoVo> kindList = new ArrayList<>();
 
 
-//        rd.getCvrgListSY().getCvrgSY().forEach(a -> {
-//
-//            String kindcode = a.getCCvrgNo();
+        rd.getCvrgListSY().getCvrgSY().forEach(a -> {
+
+            String kindcode = a.getCCvrgNo();
+            KindInfoVo kindInfoVo = new KindInfoVo();
+            kindInfoVo.setKindCode(kindcode);
+            kindInfoVo.setAmount(a.getNPrm());
 //            int i = ArrayUtil.indexOf(InsuranceTypeCorrespondence.getYongchengConnectInsuranceType(), kindcode);
 //            int i = ArrayUtil.indexOf(InsuranceTypeCorrespondence.getYongchengConnectInsuranceType(), kindcode);
-////            InsurKind insurKind = Enum.valueOf(InsurKind.class, InsuranceTypeCorrespondence.getJinZhangGuiType()[i]);
-//
+//            InsurKind insurKind = Enum.valueOf(InsurKind.class, InsuranceTypeCorrespondence.getJinZhangGuiType()[i]);
+
 //            double premium = Double.parseDouble(a.getNPrm());
 //            double premium = Double.parseDouble(a.getNPrm());
 //            double amount = Double.parseDouble(a.getNPerAmt());
 //            double amount = Double.parseDouble(a.getNPerAmt());
 //            QuoteKindRespVo kind;
 //            QuoteKindRespVo kind;
@@ -724,10 +735,10 @@ public class YongChengApiRequestImpl implements YongChengApiRequest {
 //            if (ArrayUtil.indexOf(InsuranceTypeCorrespondence.getSpecialContractClause(), insurKind.getCode()) >= 0) {
 //            if (ArrayUtil.indexOf(InsuranceTypeCorrespondence.getSpecialContractClause(), insurKind.getCode()) >= 0) {
 //                kind.setServiceTimes(a.getNLiabDaysLmt());
 //                kind.setServiceTimes(a.getNLiabDaysLmt());
 //            }
 //            }
-//
-//            kindList.add(kind);
-//
-//        });
+
+            kindList.add(kindInfoVo);
+
+        });
 
 
         return kindList;
         return kindList;
     }
     }

+ 6 - 0
tenant/organization/src/main/resources/mapper/PtlAgreementCostMapper.xml

@@ -406,6 +406,12 @@
             <if test="costParam.productId != null and costParam.productId != ''">
             <if test="costParam.productId != null and costParam.productId != ''">
                 AND pc.product_id = #{costParam.productId}
                 AND pc.product_id = #{costParam.productId}
             </if>
             </if>
+            <if test="costParam.agreementId != null and costParam.agreementId != ''">
+                AND pc.ptl_agreement_id = #{costParam.agreementId}
+            </if>
+            <if test="costParam.coverRuleId != null and costParam.coverRuleId != ''">
+                AND pc.cover_rule_id = #{costParam.coverRuleId}
+            </if>
             <if test="costParam.rulesName != null and costParam.rulesName != ''">
             <if test="costParam.rulesName != null and costParam.rulesName != ''">
                 AND (
                 AND (
                     (pr_raw.parent_id IS NOT NULL AND pr_raw.parent_id != ''
                     (pr_raw.parent_id IS NOT NULL AND pr_raw.parent_id != ''