Browse Source

fix 承保规则包含不包含问题处理

liub 6 ngày trước cách đây
mục cha
commit
0c56887f96

+ 22 - 26
tenant/organization/src/main/java/com/jzg/organization/component/BuildDescUtils.java

@@ -20,9 +20,7 @@ public class BuildDescUtils {
      */
     public static String buildDesc(String companyId, List<PtlAgreementUndwrtRulesAttr> linkList, List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList) {
         StringBuilder desc = new StringBuilder();
-        Map<String, PtlAgreementUndwrtRulesAttr> attrMap = undwrtRulesAttrList.stream()
-                .filter(attr -> "all".equals(attr.getCompanyIds()) || (attr.getCompanyIds() != null && attr.getCompanyIds().equals(companyId)))
-                .collect(Collectors.toMap(PtlAgreementUndwrtRulesAttr::getAttrCode, Function.identity()));
+        Map<String, PtlAgreementUndwrtRulesAttr> attrMap = undwrtRulesAttrList.stream().filter(attr -> "all".equals(attr.getCompanyIds()) || (attr.getCompanyIds() != null && attr.getCompanyIds().equals(companyId))).collect(Collectors.toMap(PtlAgreementUndwrtRulesAttr::getAttrCode, Function.identity()));
         // 这里进行排序,保证生成的承保规则描述是有序的
         linkList = linkList.stream().sorted(Comparator.comparing(PtlAgreementUndwrtRulesAttr::getAttrCode)).toList();
         List<PtlAgreementUndwrtRulesAttr> sortedLinks = new ArrayList<>(linkList);
@@ -43,13 +41,18 @@ public class BuildDescUtils {
                 if (link.getMinArray() != null && link.getMinArray().length > 0) {
                     // minArray 转 Set,避免循环内反复创建 List 做 contains 查找
                     Set<String> minCodes = Arrays.stream(link.getMinArray()).collect(Collectors.toSet());
-                    String names = Optional.ofNullable(link.getDictLabal()).orElse(Collections.emptyList()).stream()
-                            .filter(labal -> minCodes.contains(labal.getCode()))
-                            .map(PtlAgreementUndwrtRulesDictLabal::getName)
-                            .collect(Collectors.joining(","));
-                    desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("包含").append(names).append(";\t\t");
+                    String names = Optional.ofNullable(link.getDictLabal()).orElse(Collections.emptyList()).stream().filter(labal -> minCodes.contains(labal.getCode())).map(PtlAgreementUndwrtRulesDictLabal::getName).collect(Collectors.joining(","));
+                    if (link.getOperator() != null && "1".equals(link.getOperator())) {
+                        desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("包含").append(names).append(";\t\t");
+                    } else {
+                        desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("不包含").append(names).append(";\t\t");
+                    }
                 } else {
-                    desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("包含").append(link.getMin()).append(";\t\t");
+                    if (link.getOperator() != null && "1".equals(link.getOperator())) {
+                        desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("包含").append(link.getMin()).append(";\t\t");
+                    } else {
+                        desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("不包含").append(link.getMin()).append(";\t\t");
+                    }
                 }
             } else if ("inputTag".equals(attrType)) {
                 if (link.getOperator() != null && "1".equals(link.getOperator())) {
@@ -63,12 +66,9 @@ public class BuildDescUtils {
     }
 
     private static String radioIdentifying(PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr, PtlAgreementUndwrtRulesAttr link) {
-        Optional<PtlAgreementUndwrtRulesDictLabal> dictLabel = Optional.ofNullable(
-                        ptlAgreementUndwrtRulesAttr.getDictLabal())
-                .flatMap(list -> list.stream().filter(x -> x.getCode().equals(link.getMin())).findFirst());
+        Optional<PtlAgreementUndwrtRulesDictLabal> dictLabel = Optional.ofNullable(ptlAgreementUndwrtRulesAttr.getDictLabal()).flatMap(list -> list.stream().filter(x -> x.getCode().equals(link.getMin())).findFirst());
 
-        return dictLabel.map(dl -> ptlAgreementUndwrtRulesAttr.getAttrName() + "为" + dl.getName())
-                .orElse("");
+        return dictLabel.map(dl -> ptlAgreementUndwrtRulesAttr.getAttrName() + "为" + dl.getName()).orElse("");
     }
 
     private static String inputNumberIdentifying(PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr, PtlAgreementUndwrtRulesAttr link) {
@@ -105,10 +105,7 @@ public class BuildDescUtils {
 
         for (int i = 0; i < sortedLinks.size(); i++) {
             int finalI = i;
-            PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr = undwrtRulesAttrList.stream()
-                    .filter(x -> x.getAttrCode().equals(sortedLinks.get(finalI).getAttrCode()))
-                    .findAny()
-                    .get();
+            PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr = undwrtRulesAttrList.stream().filter(x -> x.getAttrCode().equals(sortedLinks.get(finalI).getAttrCode())).findAny().get();
 
             //数值范围判断
 
@@ -158,12 +155,13 @@ public class BuildDescUtils {
         if (link.getMinArray() != null && link.getMinArray().length > 0) {
             // minArray 转 Set,避免循环内反复创建 List 做 contains 查找
             Set<String> minCodes = Arrays.stream(link.getMinArray()).collect(Collectors.toSet());
-            String names = Optional.ofNullable(dictLabalList).orElse(Collections.emptyList()).stream()
-                    .filter(labal -> minCodes.contains(labal.getCode()))
-                    .map(PtlAgreementUndwrtRulesDictLabal::getName)
-                    .collect(Collectors.joining(","));
-            returnMsg.append(undwrtRulesAttr.getAttrName()).append("包含").append(names).append(",");
+            String names = Optional.ofNullable(dictLabalList).orElse(Collections.emptyList()).stream().filter(labal -> minCodes.contains(labal.getCode())).map(PtlAgreementUndwrtRulesDictLabal::getName).collect(Collectors.joining(","));
 
+            if (link.getOperator() != null && "1".equals(link.getOperator())) {
+                returnMsg.append(undwrtRulesAttr.getAttrName()).append("包含").append(names).append(",");
+            } else {
+                returnMsg.append(undwrtRulesAttr.getAttrName()).append("不包含").append(names).append(",");
+            }
         }
         return returnMsg.toString();
     }
@@ -182,9 +180,7 @@ public class BuildDescUtils {
             // 优先取 link 上的字典标签列表(JSONArray -> List),为空时回退到属性自带字典
             List<PtlAgreementUndwrtRulesDictLabal> dictLabalList = getDictLabalList(ptlAgreementUndwrtRulesAttr, linkList);
             // code -> 字典标签 映射,避免 O(n²) 循环匹配
-            Map<String, PtlAgreementUndwrtRulesDictLabal> dictLabalMap = dictLabalList.stream()
-                    .filter(x -> x.getCode() != null)
-                    .collect(Collectors.toMap(PtlAgreementUndwrtRulesDictLabal::getCode, Function.identity(), (oldItem, newItem) -> newItem));
+            Map<String, PtlAgreementUndwrtRulesDictLabal> dictLabalMap = dictLabalList.stream().filter(x -> x.getCode() != null).collect(Collectors.toMap(PtlAgreementUndwrtRulesDictLabal::getCode, Function.identity(), (oldItem, newItem) -> newItem));
             for (String code : linkList.getMinArray()) {
                 PtlAgreementUndwrtRulesDictLabal ptlAgreementUndwrtRulesDictLabal = dictLabalMap.get(code);
                 returnMsg.append(ptlAgreementUndwrtRulesDictLabal != null ? ptlAgreementUndwrtRulesDictLabal.getName() : "").append(",");