Parcourir la source

处理的核保规则匹配、费用匹配问题

lixiaolong il y a 3 semaines
Parent
commit
c8ab99eda3

+ 70 - 46
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/aop/FactorMatch.java

@@ -121,40 +121,49 @@ public class FactorMatch {
                         .filter(x -> x.getAttrCode().equals(ptlAgreementProductCostsAttrLink.getAttrCode()))
                         .toList();
 
-                Map<String, String> codeToNameMap = new HashMap<>();
-                if (CollUtil.isNotEmpty(undwrtRulesDictList) && ptlAgreementProductCostsAttrLink != null) {
-                    String minStr = ptlAgreementProductCostsAttrLink.getMin();
-                    if (minStr != null && !minStr.isEmpty()) {
-                        if (codeToNameMap.isEmpty() && ptlAgreementUndwrtRulesAttr != null && ptlAgreementUndwrtRulesAttr.getDictId() != null) {
-                            Integer dictId = ptlAgreementUndwrtRulesAttr.getDictId();
-                            for (PtlAgreementUndwrtRulesDictLabal label : undwrtRulesDictList) {
-                                if (Objects.equals(label.getDictId(), dictId)) {
-                                    codeToNameMap.put(label.getCode(), label.getName());
-                                }
-                            }
-                        }
-                    }
-                }
-
-                if (ptlAgreementProductCostsAttrLink.getMin() != null) {
-                    String min = ptlAgreementProductCostsAttrLink.getMin();
+                boolean isPlateAttr = "LicenseNo".equals(ptlAgreementProductCostsAttrLink.getAttrCode())
+                        || "LicenseArea".equals(ptlAgreementProductCostsAttrLink.getAttrCode());
+
+                // 检验的值
+                String ruleVal = ptlAgreementProductCostsAttrLink.getMin() != null
+                        ? ptlAgreementProductCostsAttrLink.getMin()
+                        : ptlAgreementProductCostsAttrLink.getMax();
+                if (isPlateAttr) {
                     StringBuilder str = new StringBuilder();
-                    for (String s : min.split(",")) {
+                    for (String s : ruleVal.split(",")) {
                         str.append(plateFourCodeMap.getOrDefault(s, s)).append(",");
                     }
                     logs.append("检验的值:").append(str.toString()).append("\n");
-
                 } else {
-                    String max = ptlAgreementProductCostsAttrLink.getMax();
-                    StringBuilder str = new StringBuilder();
-                    for (String s : max.split(",")) {
-                        str.append(plateFourCodeMap.getOrDefault(s, s)).append(",");
+                    Integer dictId = collect.get(0).getDictId();
+                    Map<String, String> codeToNameMap = new HashMap<>();
+                    if (dictId != null && CollUtil.isNotEmpty(undwrtRulesDictList)) {
+                        for (PtlAgreementUndwrtRulesDictLabal label : undwrtRulesDictList) {
+                            if (Objects.equals(label.getDictId(), dictId)) {
+                                codeToNameMap.put(label.getCode(), label.getName());
+                            }
+                        }
                     }
-                    logs.append("检验的值:").append(str.toString()).append("\n");
+                    logs.append("检验的值:").append(displayRuleValue(ruleVal, codeToNameMap)).append("\n");
                 }
 
-                String val = plateFourCodeMap.getOrDefault(ruleAttrMappingVo.getValue(), ruleAttrMappingVo.getValue());
-                logs.append("传入的值:" + val + "\n");
+                // 传入的值
+                String inVal = ruleAttrMappingVo.getValue();
+                if (isPlateAttr) {
+                    logs.append("传入的值:" + plateFourCodeMap.getOrDefault(inVal, inVal) + "\n");
+                } else {
+                    Integer dictId = collect.get(0).getDictId();
+                    Map<String, String> codeToNameMap = new HashMap<>();
+                    if (dictId != null && CollUtil.isNotEmpty(undwrtRulesDictList)) {
+                        for (PtlAgreementUndwrtRulesDictLabal label : undwrtRulesDictList) {
+                            if (Objects.equals(label.getDictId(), dictId)) {
+                                codeToNameMap.put(label.getCode(), label.getName());
+                            }
+                        }
+                    }
+                    String name = codeToNameMap.getOrDefault(inVal, inVal);
+                    logs.append("传入的值:" + (codeToNameMap.isEmpty() ? inVal : name) + "\n");
+                }
 
                 if (CollUtil.isNotEmpty(collect)) {
                     logs.append("规则匹配失败:" + collect.get(0).getAttrName() + "\n");
@@ -266,34 +275,49 @@ public class FactorMatch {
                 List<PtlAgreementUndwrtRulesAttr> collect = undwrtRulesAttrList.stream()
                         .filter(x -> x.getAttrCode().equals(ptlAgreementProductCostsAttrLink.getAttrCode()))
                         .toList();
-                Integer dictId = collect.get(0).getDictId();
-                Map<String, String> codeToNameMap = new HashMap<>();
-                if (CollUtil.isNotEmpty(undwrtRulesDictList)) {
-                    for (PtlAgreementUndwrtRulesDictLabal label : undwrtRulesDictList) {
-                        if (Objects.equals(label.getDictId(), dictId)) {
-                            codeToNameMap.put(label.getCode(), label.getName());
-                        }
-                    }
-                }
-                if (ptlAgreementProductCostsAttrLink.getMin() != null) {
-                    String min = ptlAgreementProductCostsAttrLink.getMin();
+                boolean isPlateAttr = "LicenseNo".equals(ptlAgreementProductCostsAttrLink.getAttrCode())
+                        || "LicenseArea".equals(ptlAgreementProductCostsAttrLink.getAttrCode());
+
+                // 检验的值
+                String ruleVal = ptlAgreementProductCostsAttrLink.getMin() != null
+                        ? ptlAgreementProductCostsAttrLink.getMin()
+                        : ptlAgreementProductCostsAttrLink.getMax();
+                if (isPlateAttr) {
                     StringBuilder str = new StringBuilder();
-                    for (String s : min.split(",")) {
+                    for (String s : ruleVal.split(",")) {
                         str.append(plateFourCodeMap.getOrDefault(s, s)).append(",");
                     }
                     logs.append("检验的值:").append(str.toString()).append("\n");
-
                 } else {
-                    String max = ptlAgreementProductCostsAttrLink.getMax();
-                    StringBuilder str = new StringBuilder();
-                    for (String s : max.split(",")) {
-                        str.append(plateFourCodeMap.getOrDefault(s, s)).append(",");
+                    Integer dictId = collect.get(0).getDictId();
+                    Map<String, String> codeToNameMap = new HashMap<>();
+                    if (dictId != null && CollUtil.isNotEmpty(undwrtRulesDictList)) {
+                        for (PtlAgreementUndwrtRulesDictLabal label : undwrtRulesDictList) {
+                            if (Objects.equals(label.getDictId(), dictId)) {
+                                codeToNameMap.put(label.getCode(), label.getName());
+                            }
+                        }
                     }
-                    logs.append("检验的值:").append(str.toString()).append("\n");
+                    logs.append("检验的值:").append(displayRuleValue(ruleVal, codeToNameMap)).append("\n");
                 }
 
-                String val = plateFourCodeMap.getOrDefault(ruleAttrMappingVo.getValue(), ruleAttrMappingVo.getValue());
-                logs.append("传入的值:" + val + "\n");
+                // 传入的值
+                String inVal = ruleAttrMappingVo.getValue();
+                if (isPlateAttr) {
+                    logs.append("传入的值:" + plateFourCodeMap.getOrDefault(inVal, inVal) + "\n");
+                } else {
+                    Integer dictId = collect.get(0).getDictId();
+                    Map<String, String> codeToNameMap = new HashMap<>();
+                    if (dictId != null && CollUtil.isNotEmpty(undwrtRulesDictList)) {
+                        for (PtlAgreementUndwrtRulesDictLabal label : undwrtRulesDictList) {
+                            if (Objects.equals(label.getDictId(), dictId)) {
+                                codeToNameMap.put(label.getCode(), label.getName());
+                            }
+                        }
+                    }
+                    String name = codeToNameMap.getOrDefault(inVal, inVal);
+                    logs.append("传入的值:" + (codeToNameMap.isEmpty() ? inVal : name) + "\n");
+                }
 
                 if (CollUtil.isNotEmpty(collect)) {
                     logs.append("<span style=\"color:red;\">规则匹配失败:" + collect.get(0).getAttrName() + "</span>\n");