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

报价费用审核-费用规则尽量保持顺序一致

lipf 4 недель назад
Родитель
Сommit
f402df23d9

+ 3 - 2
commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementUndwrtRulesAttrLink.java

@@ -1,7 +1,6 @@
 package com.jzg.commons.entity.po;
 
-import java.io.Serializable;
-import java.util.Date;
+import java.io.Serial;
 
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.annotation.TableField;
@@ -17,6 +16,8 @@ import lombok.Data;
 @Data
 public class PtlAgreementUndwrtRulesAttrLink extends BaseModel {
 
+    @Serial
+    private static final long serialVersionUID = -3935263637863405461L;
     /** 主键/自增 */
     @Schema(description = "主键/自增")
     private String id;

+ 26 - 23
commons/src/main/java/com/jzg/commons/util/BuildDescUtils.java → tenant/organization/src/main/java/com/jzg/organization/component/BuildDescUtils.java

@@ -1,24 +1,35 @@
-package com.jzg.commons.util;
+package com.jzg.organization.component;
 
 import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttr;
 import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesDictLabal;
 
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
+import java.util.*;
 import java.util.function.Function;
 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) {
-        StringBuilder desc = new StringBuilder();
+        StringJoiner desc = new StringJoiner(",","","");
         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) {
             PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr = attrMap.get(link.getAttrCode());
             if (ptlAgreementUndwrtRulesAttr == null) {
@@ -28,32 +39,24 @@ public class BuildDescUtils {
             String attrType = ptlAgreementUndwrtRulesAttr.getAttrType();
 
             if ("inputNumber".equals(attrType)) {
-                desc.append(inputNumberIdentifying(ptlAgreementUndwrtRulesAttr, link)).append(",");
+                desc.add(inputNumberIdentifying(ptlAgreementUndwrtRulesAttr, link));
             } else if ("radio".equals(attrType)) {
-                desc.append(radioIdentifying(ptlAgreementUndwrtRulesAttr, link)).append(",");
+                desc.add(radioIdentifying(ptlAgreementUndwrtRulesAttr, link));
             } 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++){
-                        PtlAgreementUndwrtRulesDictLabal ptlAgreementUndwrtRulesDictLabal = null;
-                        for (PtlAgreementUndwrtRulesDictLabal x : ptlAgreementUndwrtRulesAttr.getDictLabal()) {
-                            if (Arrays.asList(link.getMinArray()).contains("select".equals(attrType) ? x.getName() : x.getCode())) {
-                                ptlAgreementUndwrtRulesDictLabal = x;
-                                link.getMinArray()[k] = null;
-                                break;
-                            }
-                        }
-                        desc.append(null != ptlAgreementUndwrtRulesDictLabal ? ptlAgreementUndwrtRulesDictLabal.getName() : "").append(",");
+                        license.add(CODE_TO_LICENSE_MAP.get(link.getMinArray()[k]));
                     }
-
                 }else {
-                    desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("包含").append(link.getMin()).append(",");
+                    license.add(link.getMin());
                 }
+                desc.add(license.toString());;
             } else if ("inputTag".equals(attrType)) {
                 if (link.getOperator() != null && "1".equals(link.getOperator())) {
-                    desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("包含").append(link.getMin()).append(",");
+                    desc.add(ptlAgreementUndwrtRulesAttr.getAttrName() + "包含" + link.getMin());
                 } else {
-                    desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("不包含").append(link.getMin()).append(",");
+                    desc.add(ptlAgreementUndwrtRulesAttr.getAttrName() + "不包含" + link.getMin());
                 }
             }
         }

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

@@ -1,7 +1,6 @@
 package com.jzg.organization.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
@@ -21,7 +20,7 @@ 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.commons.util.BuildDescUtils;
+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;
@@ -45,9 +44,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
-import java.time.LocalDate;
 import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.stream.Collectors;
 

+ 18 - 14
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementUndwrtRulesServiceImpl.java

@@ -731,30 +731,33 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
      * @return
      */
     private String buildDesc(List<PtlAgreementUndwrtRulesAttrLink> linkList, List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList) {
-        StringBuilder desc = new StringBuilder();
-        for (int i = 0; i < linkList.size(); i++) {
+        log.info("遍历费用属性描述文字: linkList=[{}]", JSONUtil.toJsonStr(linkList));
+        StringJoiner desc = new StringJoiner(",","","");
+        // 这里进行排序,保证生成的承保规则描述是有序的
+        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()
-                    .filter(x -> x.getAttrCode().equals(linkList.get(finalI).getAttrCode()))
+                    .filter(x -> x.getAttrCode().equals(sortedLinks.get(finalI).getAttrCode()))
                     .findAny()
                     .get();
 
             //数值范围判断
-
             if ("inputNumber".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
-                desc.append(inputNumberIdentifying(ptlAgreementUndwrtRulesAttr, linkList.get(i))).append(",");
+                desc.add(inputNumberIdentifying(ptlAgreementUndwrtRulesAttr, sortedLinks.get(i)));
             }
             if ("radio".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
-                desc.append(radioIdentifying(ptlAgreementUndwrtRulesAttr, linkList.get(i))).append(",");
+                desc.add(radioIdentifying(ptlAgreementUndwrtRulesAttr, sortedLinks.get(i)));
             }
             if ("checkbox".equals(ptlAgreementUndwrtRulesAttr.getAttrType()) || "select".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
-                desc.append(checkBoxIdentifying(ptlAgreementUndwrtRulesAttr,linkList.get(i)));
+                desc.add(checkBoxIdentifying(ptlAgreementUndwrtRulesAttr,sortedLinks.get(i)));
             }
             if ("inputTag".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
-                if (linkList.get(i).getOperator() != null && linkList.get(i).getOperator().equals("1")) {
-                    desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("包含").append(linkList.get(i).getMin()).append(",");
+                if (sortedLinks.get(i).getOperator() != null && sortedLinks.get(i).getOperator().equals("1")) {
+                    desc.add(ptlAgreementUndwrtRulesAttr.getAttrName() + "包含" + sortedLinks.get(i).getMin());
                 } else {
-                    desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("不包含").append(linkList.get(i).getMin()).append(",");
+                    desc.add(ptlAgreementUndwrtRulesAttr.getAttrName() + "包含" + sortedLinks.get(i).getMin());
                 }
             }
         }
@@ -767,8 +770,8 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
     }
 
     private String checkBoxIdentifying(PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr, PtlAgreementUndwrtRulesAttrLink linkList) {
-        StringBuilder returnMsg = new StringBuilder();
-        returnMsg.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("为");
+        StringJoiner returnMsg = new StringJoiner(",",ptlAgreementUndwrtRulesAttr.getAttrName() + "为", "");
+        returnMsg.setEmptyValue("");
         if (linkList.getMinArray() == null) {
             String minStr = linkList.getMin();
             if (minStr != null && minStr.length() > 0) {
@@ -784,14 +787,15 @@ 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.append(ptlAgreementUndwrtRulesDictLabal.getName()).append(",");
+                    returnMsg.add(ptlAgreementUndwrtRulesDictLabal.getName());
                 }
             }
             if(StrUtil.isNotEmpty(licenseInfo.toString())){
                 String licenseName = ptlAreaLicenseService.convertAreaNumber2License(licenseInfo.toString());
-                returnMsg.append(licenseName).append(",");
+                returnMsg.add(licenseName);
             }
         }
+        log.info("承保规则描述:ptlAgreementUndwrtRulesAttr=[{}]. returnMsg=[{}]", JSONUtil.toJsonStr(ptlAgreementUndwrtRulesAttr), returnMsg.toString());
         return returnMsg.toString();
     }