Browse Source

华农新增上一年险别

wanghao 2 months ago
parent
commit
273a97f7e2

+ 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 java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -52,6 +54,9 @@ public final class HuaNongCrawlerQuoteResultsVoBuild {
                 .stream()
                 .collect(Collectors.toMap(x -> x.getContractMain().getRiskCode(), x -> x));
 
+        // 上年承保险别
+        Map<String, List<String>> companyRiskMap = new HashMap<>();
+
         contract.forEach(contractDTO -> {
 
             HuaNongCrawlerSaveResponse.BusinessDataDTO.ContractDTO contractDTO1 = collect.get(contractDTO.getContractMain()
@@ -88,8 +93,35 @@ public final class HuaNongCrawlerQuoteResultsVoBuild {
                 biRiskInfoVo.setStartDate(contractDTO.getCoverage().get(0).getValidDate());
                 biRiskInfoVo.setEndDate(contractDTO.getCoverage().get(0).getExpiryDate());
                 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();
         double sumPremium = 0.0;
@@ -121,7 +153,7 @@ public final class HuaNongCrawlerQuoteResultsVoBuild {
 
         scoreVo.setLossRation(ultimateScoreBiCi);
 
-        JSONArray scoreJson = new JSONArray();
+        JSONArray scoreJson = scoreVo.getScoreJson();
         scoreJson.add(new JSONObject()
                 .fluentPut("scoreName", "交商合计分")
                 .fluentPut("scoreKey", "mark")