Просмотр исходного кода

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

lixiaolong 1 месяц назад
Родитель
Сommit
7bb31fce0b

+ 28 - 89
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/aop/FactorMatch.java

@@ -25,6 +25,22 @@ public class FactorMatch {
 
     private static final Logger log = LoggerFactory.getLogger(FactorMatch.class);
 
+    private static final Map<String, String> plateFourCodeMap = new HashMap<>();
+
+    static {
+        plateFourCodeMap.put("晋D", "1404");
+        plateFourCodeMap.put("晋M", "1408");
+        plateFourCodeMap.put("晋J", "1411");
+        plateFourCodeMap.put("晋C", "1403");
+        plateFourCodeMap.put("晋K", "1407");
+        plateFourCodeMap.put("晋L", "1410");
+        plateFourCodeMap.put("晋B", "1402");
+        plateFourCodeMap.put("晋F", "1406");
+        plateFourCodeMap.put("晋A", "1401");
+        plateFourCodeMap.put("晋E", "1405");
+        plateFourCodeMap.put("晋H", "1409");
+    }
+
     /**
      * 因子比对
      * @param ptlAgreementCostRuleList
@@ -128,7 +144,7 @@ public class FactorMatch {
                 }
 
                 String val = codeToNameMap.getOrDefault(ruleAttrMappingVo.getValue(), StrUtil.EMPTY);
-                logs.append("传入的值:" + (StrUtil.isNotBlank(val) ? val : ruleAttrMappingVo.getValue()) + "\n");
+                logs.append("传入的值:" + displayRuleValue((StrUtil.isNotBlank(val) ? val : ruleAttrMappingVo.getValue()), codeToNameMap) + "\n");
 
                 if (CollUtil.isNotEmpty(collect)) {
                     logs.append("规则匹配失败:" + collect.get(0).getAttrName() + "\n");
@@ -282,11 +298,11 @@ public class FactorMatch {
 
                 } else {
                     String max = codeToNameMap.getOrDefault(ptlAgreementProductCostsAttrLink.getMax(), StrUtil.EMPTY);
-                    logs.append("检验的值:" + (StrUtil.isNotBlank(max) ? max : ptlAgreementProductCostsAttrLink.getMax()) + "\n");
+                    logs.append("检验的值:" + displayRuleValue((StrUtil.isNotBlank(max) ? max : ptlAgreementProductCostsAttrLink.getMax()), codeToNameMap) + "\n");
                 }
 
                 String val = codeToNameMap.getOrDefault(ruleAttrMappingVo.getValue(), StrUtil.EMPTY);
-                logs.append("传入的值:" + (StrUtil.isNotBlank(val) ? val : ruleAttrMappingVo.getValue()) + "\n");
+                logs.append("传入的值:" + displayRuleValue((StrUtil.isNotBlank(val) ? val : ruleAttrMappingVo.getValue()), codeToNameMap) + "\n");
 
                 if (CollUtil.isNotEmpty(collect)) {
                     logs.append("<span style=\"color:red;\">规则匹配失败:" + collect.get(0).getAttrName() + "</span>\n");
@@ -310,10 +326,6 @@ public class FactorMatch {
         if (CollUtil.isNotEmpty(nameToCodeMap) && nameToCodeMap.containsKey(v)) {
             return nameToCodeMap.get(v);
         }
-        String normalized = normalizeYesNo(v);
-        if (normalized != null && !normalized.equals(v)) {
-            return normalized;
-        }
         return v;
     }
 
@@ -381,12 +393,6 @@ public class FactorMatch {
             if (sp.trim().equals(value.trim())) {
                 return true;
             }
-            // 顺带支持是/否归一化
-            String n1 = normalizeYesNo(sp.trim());
-            String n2 = normalizeYesNo(value.trim());
-            if (!n1.equals(sp.trim()) && !n2.equals(value.trim()) && n1.equals(n2)) {
-                return true;
-            }
         }
         return false;
     }
@@ -462,24 +468,12 @@ public class FactorMatch {
             String [] options = ptlAgreementCostRule.getMin().split(",");
             for (String opt : options) {
                 if (opt.trim().equals(value.trim())) {
-                    return false;
-                }
-            }
-            return true;
-        } else {
-            // 修复:select 支持多选逗号分隔,所以正确做法是 split 后逐个 equals
-            String[] options = ptlAgreementCostRule.getMin().split(",");
-            for (String opt : options) {
-                if (opt.trim().equals(value.trim())) {
-                    return true;
-                }
-                // 顺带支持是/否归一化
-                String n1 = normalizeYesNo(opt.trim());
-                String n2 = normalizeYesNo(value.trim());
-                if (!n1.equals(opt.trim()) && !n2.equals(value.trim()) && n1.equals(n2)) {
                     return true;
                 }
             }
+            return false;
+        } else if (ptlAgreementCostRule.getMin() != null && ptlAgreementCostRule.getMin().contains(value)) {
+            return true;
         }
 
         return false;
@@ -487,73 +481,18 @@ public class FactorMatch {
 
     private static boolean radioEqual(PtlAgreementCostRule ptlAgreementCostRule, String value) {
         //新能源判断
-        if ("NewEnergy".equals(ptlAgreementCostRule.getAttrCode())) {
+        if ("NewEnergyMark".equals(ptlAgreementCostRule.getAttrCode())) {
             // 是否是新能源车
             boolean newEnergy = EnergyTypeCode.isNewEnergy(value);
-            if (newEnergy && "1".equals(normalizeYesNo(ptlAgreementCostRule.getMin()))) {
+            if (newEnergy && ptlAgreementCostRule.getMin().equals("1")) {
                 return true;
-            } else if (!newEnergy && "0".equals(normalizeYesNo(ptlAgreementCostRule.getMin()))) {
+            } else if (!newEnergy && ptlAgreementCostRule.getMin().equals("0")) {
                 return true;
             }
-            return false;
-        }
-
-        // ========== 修复:归一化 是/否 类的 value ==========
-        String ruleValue = (ptlAgreementCostRule.getMin() != null) ? ptlAgreementCostRule.getMin() : ptlAgreementCostRule.getMax();
-        String normalizedRule = normalizeYesNo(ruleValue);
-        String normalizedValue = normalizeYesNo(value);
-
-        String operator = ptlAgreementCostRule.getOperator();
-        if (operator == null) operator = "1"; // 默认 等于
-
-        switch (operator) {
-            case "1": // 等于(默认)
-                // 修复1:先归一化后比较(解决 N/0、Y/1 不一致的问题)
-                if (normalizedRule != null && normalizedValue != null
-                        && !normalizedRule.equals(ruleValue) && !normalizedValue.equals(value)) {
-                    // 两个都经过归一化翻译了,直接比归一化后的值
-                    return normalizedRule.equals(normalizedValue);
-                }
-                // 修复2:用 equals 代替 contains(避免 "10".contains("0") 的误判)
-                return (ruleValue != null && ruleValue.equals(value))
-                        || (normalizedRule != null && normalizedRule.equals(normalizedValue));
-
-            case "2": // 不等于
-                if (normalizedRule != null && normalizedValue != null
-                        && !normalizedRule.equals(ruleValue) && !normalizedValue.equals(value)) {
-                    return !normalizedRule.equals(normalizedValue);
-                }
-                return ruleValue == null || !ruleValue.equals(value);
-
-            case "3": case "4": case "5": // 其他运算符(radio 一般用不上,兜底)
-                return inputNumberEqual(ptlAgreementCostRule, value);
-
-            default:
-                return (ruleValue != null && ruleValue.equals(value));
-        }
-    }
-
-    /**
-     * 归一化"是/否"类的值,把各种表达方式统一成 1/0
-     * 是: "1", "Y", "y", "是", "true", "TRUE", "True" -> "1"
-     * 否: "0", "N", "n", "否", "false", "FALSE", "False" -> "0"
-     * 其他值原样返回
-     */
-    private static String normalizeYesNo(String value) {
-        if (value == null) return null;
-        String v = value.trim();
-        if (v.isEmpty()) return v;
-        // 是否的"是"
-        if ("1".equals(v) || "Y".equalsIgnoreCase(v) || "true".equalsIgnoreCase(v)
-                || "是".equals(v) || "T".equalsIgnoreCase(v) || "YES".equalsIgnoreCase(v)) {
-            return "1";
-        }
-        // 是否的"否"
-        if ("0".equals(v) || "N".equalsIgnoreCase(v) || "false".equalsIgnoreCase(v)
-                || "否".equals(v) || "F".equalsIgnoreCase(v) || "NO".equalsIgnoreCase(v)) {
-            return "0";
+        } else if (ptlAgreementCostRule.getMin().contains(value)) {
+            return true;
         }
-        return v;
+        return false;
     }
 
     public static boolean dateTimeEqual(PtlAgreementCostRule ptlAgreementCostRule, String value){

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

@@ -6,6 +6,8 @@ import com.alibaba.fastjson.JSONObject;
 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.agreement.dispatch.dto.PtlAgreementDispatchRulesAttrLink;
+import com.jzg.commons.entity.agreement.dispatch.vo.ValidateDispatchRuleVo;
 import com.jzg.commons.entity.orders.po.*;
 import com.jzg.commons.entity.po.*;
 import com.jzg.commons.entity.quote.vo.aggregated.UnderwritingVo;
@@ -24,12 +26,11 @@ import lombok.extern.slf4j.Slf4j;
 import org.aspectj.lang.JoinPoint;
 import org.aspectj.lang.annotation.Aspect;
 import org.aspectj.lang.annotation.Before;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Slf4j
@@ -62,6 +63,22 @@ public class AuditVerificationAspect {
 
     private final PtlNewAgreementClient ptlNewAgreementClient;
 
+    private static final Map<String, String> plateFourCodeMap = new HashMap<>();
+
+    static {
+        plateFourCodeMap.put("晋D", "1404");
+        plateFourCodeMap.put("晋M", "1408");
+        plateFourCodeMap.put("晋J", "1411");
+        plateFourCodeMap.put("晋C", "1403");
+        plateFourCodeMap.put("晋K", "1407");
+        plateFourCodeMap.put("晋L", "1410");
+        plateFourCodeMap.put("晋B", "1402");
+        plateFourCodeMap.put("晋F", "1406");
+        plateFourCodeMap.put("晋A", "1401");
+        plateFourCodeMap.put("晋E", "1405");
+        plateFourCodeMap.put("晋H", "1409");
+    }
+
 
 
     @Before("@annotation(com.jzg.quotation.summary.aop.AuditVerification)")
@@ -201,6 +218,12 @@ public class AuditVerificationAspect {
 
         log.info("=== 承保规则校验开始, 规则组数={}, 传入属性数={} ===", ruleGroups == null ? 0 : ruleGroups.size(), ruleAttrMappingVoList.size());
 
+        ruleAttrMappingVoList.forEach(ruleAttrMappingVo -> {
+            if ("LicenseNo".equals(ruleAttrMappingVo.getAttrCode()) && ruleAttrMappingVo.getValue().startsWith("晋")) {
+                ruleAttrMappingVo.setValue(plateFourCodeMap.getOrDefault(ruleAttrMappingVo.getValue(), ruleAttrMappingVo.getValue()));
+            }
+        });
+
         // 多条规则间为OR关系:只要任一条规则匹配即通过
         StringBuilder allErrorLogs = new StringBuilder();
         boolean anyRuleMatched = false;

+ 24 - 1
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlSchemeServiceImpl.java

@@ -112,6 +112,22 @@ public class PtlSchemeServiceImpl extends ServiceImpl<PtlSchemeMapper, PtlScheme
     @Autowired
     PtlAreaLicenseService ptlAreaLicenseService;
 
+    private static final Map<String, String> plateFourCodeMap = new HashMap<>();
+
+    static {
+        plateFourCodeMap.put("晋D", "1404");
+        plateFourCodeMap.put("晋M", "1408");
+        plateFourCodeMap.put("晋J", "1411");
+        plateFourCodeMap.put("晋C", "1403");
+        plateFourCodeMap.put("晋K", "1407");
+        plateFourCodeMap.put("晋L", "1410");
+        plateFourCodeMap.put("晋B", "1402");
+        plateFourCodeMap.put("晋F", "1406");
+        plateFourCodeMap.put("晋A", "1401");
+        plateFourCodeMap.put("晋E", "1405");
+        plateFourCodeMap.put("晋H", "1409");
+    }
+
     /**
      * 添加方案
      *
@@ -666,7 +682,14 @@ public class PtlSchemeServiceImpl extends ServiceImpl<PtlSchemeMapper, PtlScheme
                     if (attrLinks != null) {
                         attrLinks.forEach(attrLink -> {
                             if ("LicenseNo".equals(attrLink.getAttrCode()) && attrLink.getMin().substring(0, 1).matches("[\\u4e00-\\u9fa5]")) {
-                                attrLink.setMin(ptlAreaLicenseService.convertLicense2AreaNumber(attrLink.getMin()));
+                                // attrLink.setMin(ptlAreaLicenseService.convertLicense2AreaNumber(attrLink.getMin()));
+                                String minVal = attrLink.getMin();
+                                // 支持逗号分隔的多个车牌前缀,如 "晋A,晋B,晋C" → "1401,1402,1403"
+                                String result = Arrays.stream(minVal.split(","))
+                                        .map(String::trim)
+                                        .map(code -> plateFourCodeMap.getOrDefault(code, code))
+                                        .collect(Collectors.joining(","));
+                                attrLink.setMin(result);
                             }
                         });
                     }