liub 1 месяц назад
Родитель
Сommit
b9441807c7

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

@@ -3,6 +3,7 @@ package com.jzg.organization.service.impl;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -631,6 +632,15 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
         String newParentId = IdGenerate.nextId();
         List<RulesGroupParam> groups = new ArrayList<>();
 
+        // LicenseNo/LicenseArea 属性的字典选项来自 ptl_area_license 表,复制时用于回填 link 的 dictLabal
+        List<PtlAreaLicense> areaLicenses = ptlAreaLicenseService.queryAllAreaLicense();
+        JSONArray licenseDictLabal = CollUtil.isEmpty(areaLicenses) ? null : new JSONArray(areaLicenses.stream()
+                .map(area -> buildAreaDictLabal(area.getLicense(), area.getAreaNumber()))
+                .collect(Collectors.toList()));
+        JSONArray areaNameDictLabal = CollUtil.isEmpty(areaLicenses) ? null : new JSONArray(areaLicenses.stream()
+                .map(area -> buildAreaDictLabal(area.getAreaName(), area.getAreaNumber()))
+                .collect(Collectors.toList()));
+
         // 获取属性映射(用于组装返回结果)
         PtlAgreement agreement = ptlAgreementService.getById(rules.getAgreementId());
         Map<String, PtlAgreementUndwrtRulesAttr> attrMap = undwrtRulesAttrList.stream()
@@ -655,6 +665,25 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
 
             // 复制属性链接,关联到新规则ID
             List<PtlAgreementUndwrtRulesAttrLink> newAttrLinks = processAndAttrs(sourceLinkList, undwrtRulesAttrList, newRuleId);
+            // dictLabal 为非持久化字段,queryLinkList 查询不会加载;复制后回填,避免返回数据丢失字典标签
+            if (CollUtil.isNotEmpty(newAttrLinks)) {
+                // 普通属性:从属性元数据回填
+                Map<String, List<PtlAgreementUndwrtRulesDictLabal>> dictLabalMap = undwrtRulesAttrList.stream()
+                        .filter(attr -> CollUtil.isNotEmpty(attr.getDictLabal()))
+                        .collect(Collectors.toMap(PtlAgreementUndwrtRulesAttr::getAttrCode, PtlAgreementUndwrtRulesAttr::getDictLabal, (oldVal, newVal) -> oldVal));
+                newAttrLinks.forEach(link -> {
+                    if ("LicenseNo".equals(link.getAttrCode()) && licenseDictLabal != null) {
+                        link.setDictLabal(licenseDictLabal);
+                    } else if ("LicenseArea".equals(link.getAttrCode()) && areaNameDictLabal != null) {
+                        link.setDictLabal(areaNameDictLabal);
+                    } else {
+                        List<PtlAgreementUndwrtRulesDictLabal> dictLabal = dictLabalMap.get(link.getAttrCode());
+                        if (CollUtil.isNotEmpty(dictLabal)) {
+                            link.setDictLabal(new JSONArray(dictLabal));
+                        }
+                    }
+                });
+            }
             if (CollUtil.isNotEmpty(newAttrLinks)) {
                 agreementUndwrtRulesAttrLinkMapper.insert(newAttrLinks);
             }
@@ -684,8 +713,15 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
         return rulesVo;
     }
 
-
-
+    /**
+     * 构建地区字典标签:code 为地区编码,name 为展示名(车牌前缀或地区名称)
+     */
+    private PtlAgreementUndwrtRulesDictLabal buildAreaDictLabal(String name, String areaNumber) {
+        PtlAgreementUndwrtRulesDictLabal dictLabal = new PtlAgreementUndwrtRulesDictLabal();
+        dictLabal.setName(name);
+        dictLabal.setCode(areaNumber);
+        return dictLabal;
+    }
 
     /**
      * 将属性链接丰富为完整的属性对象