From 12dacc875539dd37c2a34b03708074febe5daaf0 Mon Sep 17 00:00:00 2001 From: 许鹏程 <1821349743@qq.com> Date: 星期一, 18 十一月 2024 16:24:13 +0800 Subject: [PATCH] 多子表字段 --- src/main/java/com/product/mobile/core/service/FaceMobileService.java | 49 +++++++++++++++++++++++++++++++++++++------------ 1 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/product/mobile/core/service/FaceMobileService.java b/src/main/java/com/product/mobile/core/service/FaceMobileService.java index d2c9228..317aebc 100644 --- a/src/main/java/com/product/mobile/core/service/FaceMobileService.java +++ b/src/main/java/com/product/mobile/core/service/FaceMobileService.java @@ -3,11 +3,13 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ReflectUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.drew.metadata.Face; +import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.product.common.lang.StringUtils; import com.product.core.cache.DataPoolCacheImpl; @@ -30,6 +32,7 @@ import java.io.File; import java.nio.charset.Charset; import java.util.*; +import java.util.stream.Collectors; /** * @Author cheng @@ -311,7 +314,7 @@ } List<FaceFieldEntity> result = new ArrayList<>(); - List<List<FieldSetEntity>> subTableField = new ArrayList<>(); + Map<String, List<FieldSetEntity>> subTableFieldMap = new HashMap<>(); for (FieldSetEntity fs : tagFieldSetEntityList) { String groupUuid = fs.getString("group_uuid"); String parentUuid = fs.getString("parent_uuid"); @@ -323,12 +326,14 @@ continue; } - to(groupMap, fieldSetEntity, subTableField, result, parentMap); + to(groupMap, fieldSetEntity, subTableFieldMap, result, parentMap); } - if (!CollectionUtil.isEmpty(subTableField)) { + //鏍规嵁group_uuid 灏嗗瓙琛ㄥ瓧娈靛垎缁�5 + if (!CollectionUtil.isEmpty(subTableFieldMap)) { //鏍规嵁瀛愯〃琛ㄥ悕瑁呰浇 Map<String, FaceFieldEntity> tableByFaceField = new HashMap<>(); - for (List<FieldSetEntity> fieldSetEntities : subTableField) { + for (Map.Entry<String, List<FieldSetEntity>> entry : subTableFieldMap.entrySet()) { + List<FieldSetEntity> fieldSetEntities = entry.getValue(); String parentUuid = fieldSetEntities.get(0).getString("parent_uuid"); //鍏堟壘鍒癱hildren List<FieldSetEntity> fieldSetEntity = productSysFaceControlProperty.getFieldSetEntity(parentUuid); @@ -374,6 +379,12 @@ //涓嶆槸瀛愯〃缁勪欢 continue; } + List<FaceFieldEntity> fields = new ArrayList<>(); + for (FieldSetEntity setEntity : fieldSetEntities) { + to(groupMap, Lists.newArrayList(setEntity), null, fields, parentMap); + } + + faceFieldEntity.setSubField(fields); for (FieldSetEntity setEntity : groupMap.get(groupUuid)) { String propertyName = setEntity.getString("property_name"); if ("subTableName".equals(propertyName)) { @@ -383,6 +394,8 @@ faceFieldEntity.setAllowAdd(setEntity.getBoolean("property_value")); } else if ("delete".equals(propertyName)) { faceFieldEntity.setAllowDelete(setEntity.getBoolean("property_value")); + } else if ("control_sequence".equals(propertyName)) { + faceFieldEntity.putOtherParam("controlSequence", setEntity.getInteger("property_value")); } } List<FaceFieldEntity> subFieldList = faceFieldEntity.getSubField(); @@ -390,18 +403,24 @@ subFieldList = new ArrayList<>(); faceFieldEntity.setSubField(subFieldList); } - - for (List<FieldSetEntity> setEntities : subTableField) { - to(groupMap, setEntities, null, subFieldList, parentMap); - } if (!tableByFaceField.containsKey(uuid)) { tableByFaceField.put(uuid, faceFieldEntity); result.add(faceFieldEntity); } - break; - } + } + result.sort((item, item2) -> { + Object o = item.getOtherParams().get("controlSequence"); + if (o == null) { + return -1; + } + Object o1 = item2.getOtherParams().get("controlSequence"); + if (o1 == null) { + return 1; + } + return NumberUtil.parseInt(item.getOtherParams().get("controlSequence").toString()) - NumberUtil.parseInt(item2.getOtherParams().get("controlSequence").toString()); + }); return result; } @@ -432,7 +451,7 @@ } - private void to(Map<String, List<FieldSetEntity>> groupMap, List<FieldSetEntity> fieldSetEntity, List<List<FieldSetEntity>> subTableField, List<FaceFieldEntity> result, Map<String, List<FieldSetEntity>> parentMap) { + private void to(Map<String, List<FieldSetEntity>> groupMap, List<FieldSetEntity> fieldSetEntity, Map<String, List<FieldSetEntity>> subTableField, List<FaceFieldEntity> result, Map<String, List<FieldSetEntity>> parentMap) { FieldSetEntity parent = fieldSetEntity.get(0); String groupUuid1 = parent.getString("group_uuid"); if (StringUtils.isEmpty(groupUuid1)) { @@ -451,7 +470,13 @@ } if ("parentType".equals(propertyName) && "subTable".equals(setEntity.getString("property_value")) && subTableField != null) { //瀛愯〃瀛楁 - subTableField.add(parentGroup); + String parentUuid = setEntity.getString("parent_uuid"); + List<FieldSetEntity> fieldSetEntities = subTableField.get(parentUuid); + if (fieldSetEntities == null) { + fieldSetEntities = new ArrayList<>(); + subTableField.put(parentUuid, fieldSetEntities); + } + fieldSetEntities.add(setEntity); result.remove(faceFieldEntity); break; } -- Gitblit v1.9.2