Browse Source

fix 承保规则中费用规则排序问题

liub 1 tháng trước cách đây
mục cha
commit
7196694a2a

+ 21 - 24
tenant/organization/src/main/java/com/jzg/organization/component/BuildDescUtils.java

@@ -10,27 +10,16 @@ import java.util.stream.Collectors;
 public class BuildDescUtils {
 
 
-    public static final Map<String, String> CODE_TO_LICENSE_MAP = Map.ofEntries(
-            Map.entry("1401", "晋A"),
-            Map.entry("1402", "晋B"),
-            Map.entry("1403", "晋C"),
-            Map.entry("1404", "晋D"),
-            Map.entry("1405", "晋E"),
-            Map.entry("1406", "晋F"),
-            Map.entry("1407", "晋K"),
-            Map.entry("1408", "晋M"),
-            Map.entry("1409", "晋H"),
-            Map.entry("1410", "晋L"),
-            Map.entry("1411", "晋J")
-    );
-
     public static String buildDesc(String companyId, List<PtlAgreementUndwrtRulesAttr> linkList, List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList) {
-        StringJoiner desc = new StringJoiner(",","","");
+        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()));
+        // 这里进行排序,保证生成的承保规则描述是有序的
         linkList = linkList.stream().sorted(Comparator.comparing(PtlAgreementUndwrtRulesAttr::getAttrCode)).toList();
-        for (PtlAgreementUndwrtRulesAttr link : linkList) {
+        List<PtlAgreementUndwrtRulesAttr> sortedLinks = new ArrayList<>(linkList);
+
+        for (PtlAgreementUndwrtRulesAttr link : sortedLinks) {
             PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr = attrMap.get(link.getAttrCode());
             if (ptlAgreementUndwrtRulesAttr == null) {
                 continue;
@@ -39,24 +28,32 @@ public class BuildDescUtils {
             String attrType = ptlAgreementUndwrtRulesAttr.getAttrType();
 
             if ("inputNumber".equals(attrType)) {
-                desc.add(inputNumberIdentifying(ptlAgreementUndwrtRulesAttr, link));
+                desc.append(inputNumberIdentifying(ptlAgreementUndwrtRulesAttr, link)).append(",");
             } else if ("radio".equals(attrType)) {
-                desc.add(radioIdentifying(ptlAgreementUndwrtRulesAttr, link));
+                desc.append(radioIdentifying(ptlAgreementUndwrtRulesAttr, link)).append(",");
             } else if ("checkbox".equals(attrType) || "select".equals(attrType)) {
-                StringJoiner license = new StringJoiner(",", ptlAgreementUndwrtRulesAttr.getAttrName() + "包含" ,"");
                 if(link.getMinArray() != null && link.getMinArray().length > 0){
+                    desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("包含");
                     for (int k=0 ; k<link.getMinArray().length; k++){
-                        license.add(CODE_TO_LICENSE_MAP.get(link.getMinArray()[k]));
+                        PtlAgreementUndwrtRulesDictLabal ptlAgreementUndwrtRulesDictLabal = null;
+                        for (PtlAgreementUndwrtRulesDictLabal x : link.getDictLabal()) {
+                            if (Arrays.asList(link.getMinArray()).contains(x.getCode())) {
+                                ptlAgreementUndwrtRulesDictLabal = x;
+                                link.getMinArray()[k] = null;
+                                break;
+                            }
+                        }
+                        desc.append(null != ptlAgreementUndwrtRulesDictLabal ? ptlAgreementUndwrtRulesDictLabal.getName() : "").append(",");
                     }
+
                 }else {
-                    license.add(link.getMin());
+                    desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("包含").append(link.getMin()).append(",");
                 }
-                desc.add(license.toString());;
             } else if ("inputTag".equals(attrType)) {
                 if (link.getOperator() != null && "1".equals(link.getOperator())) {
-                    desc.add(ptlAgreementUndwrtRulesAttr.getAttrName() + "包含" + link.getMin());
+                    desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("包含").append(link.getMin()).append(",");
                 } else {
-                    desc.add(ptlAgreementUndwrtRulesAttr.getAttrName() + "不包含" + link.getMin());
+                    desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("不包含").append(link.getMin()).append(",");
                 }
             }
         }

+ 2 - 2
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementCostServiceImpl.java

@@ -20,11 +20,11 @@ import com.jzg.commons.entity.vo.CostsListVo;
 import com.jzg.commons.entity.vo.PtlAgreementCostRuleVo;
 import com.jzg.commons.entity.vo.PtlAgreementCostVo;
 import com.jzg.commons.exception.SystemException;
-import com.jzg.organization.component.BuildDescUtils;
 import com.jzg.commons.util.ListUtils;
 import com.jzg.commons.util.StringUtils;
 import com.jzg.commons.util.idgen.IdGenerate;
 import com.jzg.organization.client.EsmInsCompanyClient;
+import com.jzg.organization.component.BuildDescUtils;
 import com.jzg.organization.mapper.PtlAgreementCostMapper;
 import com.jzg.organization.mapper.PtlAgreementCostRuleMapper;
 import com.jzg.organization.mapper.PtlAgreementCostTypeMapper;
@@ -212,7 +212,7 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
             return null;
         }
         String desc = BuildDescUtils.buildDesc(companyId, BeanUtil.copyToList(list, PtlAgreementUndwrtRulesAttr.class), agreementUndwrtRulesAttrService.getUndwrtRulesAttrList());
-        // 两个及以上相邻的逗号(中文","或英文",")合并为一个逗号
+        // 两个及以上相邻的逗号(中文","或英文",")合并为一个分号
         return StringUtils.mergeAdjacentComma(desc);
     }
 

+ 16 - 20
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementUndwrtRulesServiceImpl.java

@@ -755,7 +755,6 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
         // 批量删除规则
         return baseMapper.deleteBatchIds(deleteRuleIds) > 0;
     }
-
     /**
      * 遍历费用属性描述文字
      *
@@ -764,11 +763,11 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
      * @return
      */
     private String buildDesc(List<PtlAgreementUndwrtRulesAttrLink> linkList, List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList) {
-        log.info("遍历费用属性描述文字: linkList=[{}]", JSONUtil.toJsonStr(linkList));
-        StringJoiner desc = new StringJoiner(",","","");
+        StringBuilder desc = new StringBuilder();
         // 这里进行排序,保证生成的承保规则描述是有序的
         linkList = linkList.stream().sorted(Comparator.comparing(PtlAgreementUndwrtRulesAttrLink::getAttrCode)).toList();
         List<PtlAgreementUndwrtRulesAttrLink> sortedLinks = new ArrayList<>(linkList);
+
         for (int i = 0; i < sortedLinks.size(); i++) {
             int finalI = i;
             PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr = undwrtRulesAttrList.stream()
@@ -777,26 +776,24 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
                     .get();
 
             //数值范围判断
+
             if ("inputNumber".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
-                desc.add(inputNumberIdentifying(ptlAgreementUndwrtRulesAttr, sortedLinks.get(i)));
+                desc.append(inputNumberIdentifying(ptlAgreementUndwrtRulesAttr, sortedLinks.get(i))).append(",");
             }
             if ("radio".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
-                desc.add(radioIdentifying(ptlAgreementUndwrtRulesAttr, sortedLinks.get(i)));
+                desc.append(radioIdentifying(ptlAgreementUndwrtRulesAttr, sortedLinks.get(i))).append(",");
+            }
+            if ("select".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
+                desc.append(selectIdentifying(ptlAgreementUndwrtRulesAttr, sortedLinks.get(i)));
             }
-//            if ("select".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
-//                desc.append(selectIdentifying(ptlAgreementUndwrtRulesAttr, linkList.get(i)));
-//            }
-//            if ("checkbox".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
-//                desc.append(checkBoxIdentifying(ptlAgreementUndwrtRulesAttr,linkList.get(i)));
-//            }
-            if ("checkbox".equals(ptlAgreementUndwrtRulesAttr.getAttrType()) || "select".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
-                desc.add(checkBoxIdentifying(ptlAgreementUndwrtRulesAttr,sortedLinks.get(i)));
+            if ("checkbox".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
+                desc.append(checkBoxIdentifying(ptlAgreementUndwrtRulesAttr, sortedLinks.get(i)));
             }
             if ("inputTag".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
                 if (sortedLinks.get(i).getOperator() != null && sortedLinks.get(i).getOperator().equals("1")) {
-                    desc.add(ptlAgreementUndwrtRulesAttr.getAttrName() + "包含" + sortedLinks.get(i).getMin());
+                    desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("包含").append(sortedLinks.get(i).getMin()).append(",");
                 } else {
-                    desc.add(ptlAgreementUndwrtRulesAttr.getAttrName() + "包含" + sortedLinks.get(i).getMin());
+                    desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("不包含").append(sortedLinks.get(i).getMin()).append(",");
                 }
             }
         }
@@ -840,8 +837,8 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
     }
 
     private String checkBoxIdentifying(PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr, PtlAgreementUndwrtRulesAttrLink linkList) {
-        StringJoiner returnMsg = new StringJoiner(",",ptlAgreementUndwrtRulesAttr.getAttrName() + "为", "");
-        returnMsg.setEmptyValue("");
+        StringBuilder returnMsg = new StringBuilder();
+        returnMsg.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("为");
         if (linkList.getMinArray() == null) {
             String minStr = linkList.getMin();
             if (minStr != null && minStr.length() > 0) {
@@ -857,15 +854,14 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
                     licenseInfo.append(linkList.getMinArray()[i]).append(",");
                 }else {
                     PtlAgreementUndwrtRulesDictLabal ptlAgreementUndwrtRulesDictLabal = ptlAgreementUndwrtRulesAttr.getDictLabal().stream().filter(x -> x.getCode().equals(linkList.getMinArray()[finalI])).findAny().get();
-                    returnMsg.add(ptlAgreementUndwrtRulesDictLabal.getName());
+                    returnMsg.append(ptlAgreementUndwrtRulesDictLabal.getName()).append(",");
                 }
             }
             if(StrUtil.isNotEmpty(licenseInfo.toString())){
                 String licenseName = ptlAreaLicenseService.convertAreaNumber2License(licenseInfo.toString());
-                returnMsg.add(licenseName);
+                returnMsg.append(licenseName).append(",");
             }
         }
-        log.info("承保规则描述:ptlAgreementUndwrtRulesAttr=[{}]. returnMsg=[{}]", JSONUtil.toJsonStr(ptlAgreementUndwrtRulesAttr), returnMsg.toString());
         return returnMsg.toString();
     }