Forráskód Böngészése

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

lipf 4 hónapja
szülő
commit
aa4065b28d

+ 50 - 15
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/aop/FactorMatch.java

@@ -1,9 +1,12 @@
 package com.jzg.quotation.summary.aop;
 
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
 import com.jzg.commons.constants.quote.enums.quote.EnergyTypeCode;
 import com.jzg.commons.entity.po.PtlAgreementCostRule;
 import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttr;
 import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttrLink;
+import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesDictLabal;
 import com.jzg.commons.entity.vo.RuleAttrMappingVo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -11,11 +14,9 @@ import org.slf4j.LoggerFactory;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.stream.Collectors;
 
 /**
  * 因子匹配类
@@ -33,7 +34,7 @@ public class FactorMatch {
      * @return
      */
     public static boolean judgements(List<PtlAgreementCostRule> ptlAgreementCostRuleList, List<RuleAttrMappingVo> ruleAttrMappingVoList,
-                                     List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList, StringBuilder logs) {
+                                     List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList, StringBuilder logs,  List<PtlAgreementUndwrtRulesDictLabal> undwrtRulesDictList) {
         boolean useFlag = true;
         for (PtlAgreementCostRule ptlAgreementProductCostsAttrLink : ptlAgreementCostRuleList) {
             //查找规则中的 传值属性
@@ -69,15 +70,33 @@ public class FactorMatch {
                         .filter(x -> x.getAttrCode().equals(ptlAgreementProductCostsAttrLink.getAttrCode()))
                         .toList();
 
+                Map<String, String> codeToNameMap = new HashMap<>();
+                if (CollUtil.isNotEmpty(undwrtRulesDictList)){
+                    Map<Integer, List<PtlAgreementUndwrtRulesDictLabal>> dictMap = undwrtRulesDictList.stream()
+                            .collect(Collectors.groupingBy(PtlAgreementUndwrtRulesDictLabal::getDictId));
+                    List<PtlAgreementUndwrtRulesDictLabal> ptlAgreementUndwrtRulesDictLabals = dictMap.getOrDefault(ptlAgreementUndwrtRulesAttr.getDictId(), CollUtil.newArrayList());
+                    if (CollUtil.isNotEmpty(ptlAgreementUndwrtRulesDictLabals)){
+                        codeToNameMap = ptlAgreementUndwrtRulesDictLabals.stream()
+                                .collect(Collectors.toMap(
+                                        PtlAgreementUndwrtRulesDictLabal::getCode,
+                                        PtlAgreementUndwrtRulesDictLabal::getName,
+                                        (existing, replacement) -> existing
+                                ));
+                    }
+                }
+
                 if (ptlAgreementProductCostsAttrLink.getMin() != null) {
-                    logs.append("检验的值:" + ptlAgreementProductCostsAttrLink.getMin() + "\n");
+                    String min = codeToNameMap.getOrDefault(ptlAgreementProductCostsAttrLink.getMin(), StrUtil.EMPTY);
+                    logs.append("检验的值:" + (StrUtil.isNotBlank(min) ? min : ptlAgreementProductCostsAttrLink.getMin()) + "\n");
                 } else {
-                    logs.append("检验的值:" + ptlAgreementProductCostsAttrLink.getMax() + "\n");
+                    String max = codeToNameMap.getOrDefault(ptlAgreementProductCostsAttrLink.getMax(), StrUtil.EMPTY);
+                    logs.append("检验的值:" + (StrUtil.isNotBlank(max) ? max : ptlAgreementProductCostsAttrLink.getMax()) + "\n");
                 }
 
-                logs.append("传入的值:" + ruleAttrMappingVo.getValue() + "\n");
+                String val = codeToNameMap.getOrDefault(ruleAttrMappingVo.getValue(), StrUtil.EMPTY);
+                logs.append("传入的值:" + (StrUtil.isNotBlank(val) ? val : ruleAttrMappingVo.getValue()) + "\n");
 
-                if (!collect.isEmpty()) {
+                if (CollUtil.isNotEmpty(collect)) {
 //                    logs.append("<span style=\"color:red;\">规则匹配失败:" + collect.get(0).getAttrName() + "</span>\n");
                     logs.append("规则匹配失败:" + collect.get(0).getAttrName() + "\n");
                 }
@@ -90,7 +109,7 @@ public class FactorMatch {
 
 
     public static boolean judgementsUnderwrite(List<PtlAgreementUndwrtRulesAttrLink> ptlAgreementCostRuleList, List<RuleAttrMappingVo> ruleAttrMappingVoList,
-                                     List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList, StringBuilder logs) {
+                                     List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList, StringBuilder logs, List<PtlAgreementUndwrtRulesDictLabal> undwrtRulesDictList) {
         boolean useFlag = true;
         for (PtlAgreementUndwrtRulesAttrLink ptlAgreementProductCostsAttrLink : ptlAgreementCostRuleList) {
             //查找规则中的 传值属性
@@ -134,20 +153,36 @@ public class FactorMatch {
                 log.info("传入的值:" + ruleAttrMappingVo.getValue());
                 log.info("规则匹配失败:" + ptlAgreementProductCostsAttrLink.getAttrCode());
 
-
                 List<PtlAgreementUndwrtRulesAttr> collect = undwrtRulesAttrList.stream()
                         .filter(x -> x.getAttrCode().equals(ptlAgreementProductCostsAttrLink.getAttrCode()))
                         .toList();
 
+                Map<String, String> codeToNameMap = new HashMap<>();
+                if (CollUtil.isNotEmpty(undwrtRulesDictList)){
+                    Map<Integer, List<PtlAgreementUndwrtRulesDictLabal>> dictMap = undwrtRulesDictList.stream()
+                            .collect(Collectors.groupingBy(PtlAgreementUndwrtRulesDictLabal::getDictId));
+                    List<PtlAgreementUndwrtRulesDictLabal> ptlAgreementUndwrtRulesDictLabals = dictMap.getOrDefault(ptlAgreementUndwrtRulesAttr.getDictId(), CollUtil.newArrayList());
+                    if (CollUtil.isNotEmpty(ptlAgreementUndwrtRulesDictLabals)){
+                        codeToNameMap = ptlAgreementUndwrtRulesDictLabals.stream()
+                                .collect(Collectors.toMap(
+                                        PtlAgreementUndwrtRulesDictLabal::getCode,
+                                        PtlAgreementUndwrtRulesDictLabal::getName,
+                                        (existing, replacement) -> existing
+                                ));
+                    }
+                }
                 if (ptlAgreementProductCostsAttrLink.getMin() != null) {
-                    logs.append("检验的值4:" + ptlAgreementProductCostsAttrLink.getMin() + "\n");
+                    String min = codeToNameMap.getOrDefault(ptlAgreementProductCostsAttrLink.getMin(), StrUtil.EMPTY);
+                    logs.append("检验的值4:" + (StrUtil.isNotBlank(min) ? min : ptlAgreementProductCostsAttrLink.getMin()) + "\n");
                 } else {
-                    logs.append("检验的值5:" + ptlAgreementProductCostsAttrLink.getMax() + "\n");
+                    String max = codeToNameMap.getOrDefault(ptlAgreementProductCostsAttrLink.getMax(), StrUtil.EMPTY);
+                    logs.append("检验的值5:" + (StrUtil.isNotBlank(max) ? max : ptlAgreementProductCostsAttrLink.getMax()) + "\n");
                 }
 
-                logs.append("传入的值:" + ruleAttrMappingVo.getValue() + "\n");
+                String val = codeToNameMap.getOrDefault(ruleAttrMappingVo.getValue(), StrUtil.EMPTY);
+                logs.append("传入的值:" + (StrUtil.isNotBlank(val) ? val : ruleAttrMappingVo.getValue()) + "\n");
 
-                if (!collect.isEmpty()) {
+                if (CollUtil.isNotEmpty(collect)) {
                     logs.append("<span style=\"color:red;\">规则匹配失败:" + collect.get(0).getAttrName() + "</span>\n");
                 }
 

+ 6 - 8
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/aop/aspect/AuditVerificationAspect.java

@@ -7,17 +7,14 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.jzg.commons.core.base.BaseController;
 import com.jzg.commons.core.page.HttpResult;
 import com.jzg.commons.entity.orders.po.*;
-import com.jzg.commons.entity.po.InsFeeOrders;
-import com.jzg.commons.entity.po.PtlAgreementCost;
-import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttr;
-import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttrLink;
+import com.jzg.commons.entity.po.*;
 import com.jzg.commons.entity.quote.vo.aggregated.UnderwritingVo;
-import com.jzg.commons.entity.vo.CostsListVo;
 import com.jzg.commons.entity.vo.RuleAttrMappingVo;
 import com.jzg.commons.exception.SystemException;
 import com.jzg.commons.util.AssertionUtils;
 import com.jzg.quotation.commons.client.OrgClient;
 import com.jzg.quotation.summary.aop.FactorMatch;
+import com.jzg.quotation.summary.client.PtlNewAgreementClient;
 import com.jzg.quotation.summary.service.*;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -26,7 +23,6 @@ import org.aspectj.lang.annotation.Aspect;
 import org.aspectj.lang.annotation.Before;
 import org.springframework.stereotype.Component;
 
-import java.math.BigDecimal;
 import java.time.format.DateTimeFormatter;
 import java.util.List;
 import java.util.Objects;
@@ -59,6 +55,8 @@ public class AuditVerificationAspect {
 
     private final BaseController baseController;
 
+    private final PtlNewAgreementClient ptlNewAgreementClient;
+
 
 
     @Before("@annotation(com.jzg.quotation.summary.aop.AuditVerification)")
@@ -130,11 +128,11 @@ public class AuditVerificationAspect {
         List<RuleAttrMappingVo> ruleAttrMappingVoList = RuleAttrMappingVo.getRuleAttrMappingVoList(insOrdersOther,insOrdersCarInfo,
                 riskList, insOrdersCarUserInfos, kindList, insOrdersCosts, insOrdersAccidentalDriving, isNewCar);
 
-
+        List<PtlAgreementUndwrtRulesDictLabal> undwrtRulesDictList = ptlNewAgreementClient.getUndwrtRulesDictList();
         for (int i = 0; i < ruleAttrMappingVoList.size(); i++) {
 //            logs.append("触发承保规则:" + ruleAttrMappingVoList.get(i).getAttrCode() + "\n");
             //判断是否匹配
-            if (!FactorMatch.judgementsUnderwrite(ptlAgreementUndwrtRulesNews, ruleAttrMappingVoList, undwrtRulesAttrList, logs)) {
+            if (!FactorMatch.judgementsUnderwrite(ptlAgreementUndwrtRulesNews, ruleAttrMappingVoList, undwrtRulesAttrList, logs, undwrtRulesDictList)) {
                 throw new SystemException(logs.toString());
             }else{
                 //如果没有出现异常则清空匹配消息

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

@@ -16,6 +16,7 @@ import com.jzg.commons.entity.quote.vo.aggregated.QuoteResultsVo;
 import com.jzg.commons.entity.vo.*;
 import com.jzg.quotation.commons.client.OrgClient;
 import com.jzg.quotation.summary.aop.FactorMatch;
+import com.jzg.quotation.summary.client.PtlNewAgreementClient;
 import com.jzg.quotation.summary.service.*;
 import lombok.RequiredArgsConstructor;
 import org.aspectj.lang.JoinPoint;
@@ -64,6 +65,7 @@ public class QuoteVerificationAspect {
     private static final Logger log = LoggerFactory.getLogger("fee");
 
     private final BaseController baseController;
+    private final PtlNewAgreementClient ptlNewAgreementClient;
 
     @AfterReturning(pointcut = "@annotation(com.jzg.quotation.summary.aop.QuoteVerification)", returning = "result")
     public void doAfter(HttpResult<QuoteResultsVo> result) {
@@ -207,7 +209,9 @@ public class QuoteVerificationAspect {
 //            log.debug("费用因子备注:" + agreementProductCosts.get(i).getCostsDescription());
 //            logs.append("费用id:" + agreementProductCosts.get(i).getId() + "\n");
 //            logs.append("费用因子描述:" + agreementProductCosts.get(i).getCostsDescription() + "\n");
-            if (FactorMatch.judgements(agreementProductCosts.get(i).getPtlAgreementCostRuleList(),ruleAttrMappingVoList,undwrtRulesAttrList,logs)) {
+            List<PtlAgreementUndwrtRulesDictLabal> undwrtRulesDictList = ptlNewAgreementClient.getUndwrtRulesDictList();
+
+            if (FactorMatch.judgements(agreementProductCosts.get(i).getPtlAgreementCostRuleList(),ruleAttrMappingVoList,undwrtRulesAttrList,logs, undwrtRulesDictList)) {
                 return agreementProductCosts.get(i).getId();
             }
             log.debug("当前费用因子匹配结束\n");

+ 24 - 0
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/client/PtlNewAgreementClient.java

@@ -0,0 +1,24 @@
+package com.jzg.quotation.summary.client;
+
+import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesDictLabal;
+import com.jzg.quotation.summary.entity.Result;
+import com.jzg.quotation.summary.entity.dto.*;
+import com.jzg.quotation.summary.utils.FeignConfig;
+import jakarta.validation.Valid;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 调用生活服务平台client
+ */
+@FeignClient(value = "jzg-organization", configuration = FeignConfig.class)
+public interface PtlNewAgreementClient {
+    /**
+     * 获取字典列表
+     * @return
+     */
+    @PostMapping("/pltAgreement/attr/getUndwrtRulesDictList")
+    List<PtlAgreementUndwrtRulesDictLabal> getUndwrtRulesDictList();
+}

+ 11 - 0
tenant/organization/src/main/java/com/jzg/organization/controller/PtlNewAgreementController.java

@@ -5,7 +5,9 @@ import com.jzg.commons.core.page.HttpResult;
 import com.jzg.commons.entity.agreement.vo.PtlAgreementUndwrtRulesAttrQueryVo;
 import com.jzg.commons.entity.dto.RulesAttParam;
 import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttr;
+import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesDictLabal;
 import com.jzg.organization.service.PtlAgreementUndwrtRulesAttrService;
+import com.jzg.organization.service.PtlAgreementUndwrtRulesDictService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -25,6 +27,8 @@ public class PtlNewAgreementController {
 
     @Autowired
     private PtlAgreementUndwrtRulesAttrService ptlAgreementUndwrtRulesAttrService;
+    @Autowired
+    private PtlAgreementUndwrtRulesDictService ptlAgreementUndwrtRulesDictService;
 
     @Operation(summary = "协议承保规则属性列表")
     @GetMapping("/attr/list")
@@ -47,6 +51,13 @@ public class PtlNewAgreementController {
         return HttpResult.ok(ptlAgreementUndwrtRulesAttrService.attrGroup(param));
     }
 
+    @Operation(summary = "获取协议字典列表")
+    @PostMapping("/attr/getUndwrtRulesDictList")
+    public List<PtlAgreementUndwrtRulesDictLabal> getUndwrtRulesDictList() {
+        List<PtlAgreementUndwrtRulesDictLabal> undwrtRulesDictList = ptlAgreementUndwrtRulesDictService.getUndwrtRulesDictList();
+        return undwrtRulesDictList;
+    }
+
 
 
 }