From 6aa3771424b2b947446ec679aa5648712e4742ae Mon Sep 17 00:00:00 2001
From: 许鹏程 <1821349743@qq.com>
Date: 星期一, 23 九月 2024 17:04:49 +0800
Subject: [PATCH] 移动端获取表单组件字段,修正子表获取字段
---
src/main/java/com/product/mobile/core/entity/FaceFieldEntity.java | 58 +++++++++++
src/main/java/com/product/mobile/core/config/MobileCoreConst.java | 4
src/main/java/com/product/mobile/core/service/FaceMobileService.java | 196 +++++++++++++++++++++++++++++++++------
3 files changed, 227 insertions(+), 31 deletions(-)
diff --git a/src/main/java/com/product/mobile/core/config/MobileCoreConst.java b/src/main/java/com/product/mobile/core/config/MobileCoreConst.java
index 0b6b652..0bc325f 100644
--- a/src/main/java/com/product/mobile/core/config/MobileCoreConst.java
+++ b/src/main/java/com/product/mobile/core/config/MobileCoreConst.java
@@ -1,5 +1,7 @@
package com.product.mobile.core.config;
+import com.product.core.config.CoreConst;
+
/**
* Copyright LX-BASE
*
@@ -9,7 +11,7 @@
* @Author: LiuChao
* @Description: 鏂囦欢绠$悊-甯搁噺
*/
-public class MobileCoreConst {
+public class MobileCoreConst extends CoreConst {
//鍏叡甯搁噺瀹氫箟
public static final String UUID = "uuid";
public static final String UPDATED_BY = "updated_by"; // 淇敼鑰�
diff --git a/src/main/java/com/product/mobile/core/entity/FaceFieldEntity.java b/src/main/java/com/product/mobile/core/entity/FaceFieldEntity.java
index 9064f2f..840e556 100644
--- a/src/main/java/com/product/mobile/core/entity/FaceFieldEntity.java
+++ b/src/main/java/com/product/mobile/core/entity/FaceFieldEntity.java
@@ -1,5 +1,8 @@
package com.product.mobile.core.entity;
+import java.util.List;
+import java.util.Map;
+
/**
* @Author cheng
* @Date 2024/8/15 11:12
@@ -67,6 +70,21 @@
private String serialNumber;
private String organizationType;
+
+ /**
+ * 瀛愯〃鍏佽鏂板
+ */
+ private Boolean allowAdd;
+ /**
+ * 瀛愯〃鍏佽鍒犻櫎
+ */
+ private Boolean allowDelete;
+ /**
+ * 瀛愯〃琛ㄥ悕 褰� component = 'subTable' 鐨勬椂鍊欐湁鍊�
+ */
+ private String subTableName;
+
+ private List<FaceFieldEntity> subField;
public String getFieldName() {
@@ -172,4 +190,44 @@
public void setSerialNumber(String serialNumber) {
this.serialNumber = serialNumber;
}
+
+ public String getOrganizationType() {
+ return organizationType;
+ }
+
+ public void setOrganizationType(String organizationType) {
+ this.organizationType = organizationType;
+ }
+
+ public Boolean getAllowAdd() {
+ return allowAdd;
+ }
+
+ public void setAllowAdd(Boolean allowAdd) {
+ this.allowAdd = allowAdd;
+ }
+
+ public Boolean getAllowDelete() {
+ return allowDelete;
+ }
+
+ public void setAllowDelete(Boolean allowDelete) {
+ this.allowDelete = allowDelete;
+ }
+
+ public String getSubTableName() {
+ return subTableName;
+ }
+
+ public void setSubTableName(String subTableName) {
+ this.subTableName = subTableName;
+ }
+
+ public List<FaceFieldEntity> getSubField() {
+ return subField;
+ }
+
+ public void setSubField(List<FaceFieldEntity> subField) {
+ this.subField = subField;
+ }
}
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 d9cfc21..d87f095 100644
--- a/src/main/java/com/product/mobile/core/service/FaceMobileService.java
+++ b/src/main/java/com/product/mobile/core/service/FaceMobileService.java
@@ -5,12 +5,16 @@
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.Sets;
import com.product.common.lang.StringUtils;
+import com.product.core.cache.DataPoolCacheImpl;
import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldSetEntity;
import com.product.core.exception.BaseException;
import com.product.core.service.support.AbstractBaseService;
import com.product.mobile.core.config.MobileCoreCode;
+import com.product.mobile.core.config.MobileCoreConst;
import com.product.mobile.core.entity.FaceFieldEntity;
import com.product.tool.flow.config.CmnConst;
import com.product.tool.flow.service.FlowDetailService;
@@ -33,8 +37,9 @@
public List<FaceFieldEntity> getFaceFieldByTable(FieldSetEntity fse) {
String tableUuid = fse.getString("table_uuid");
- if (StringUtils.isEmpty(tableUuid)) {
- FieldSetEntity tableInfo = BaseUtil.getSingleInfoByCache("鎵�鏈夎〃淇℃伅", new String[]{fse.getString("table_name")});
+ String tableName = fse.getString("table_name");
+ if (StringUtils.isEmpty(tableUuid) && !StringUtils.isEmpty(tableName)) {
+ FieldSetEntity tableInfo = BaseUtil.getSingleInfoByCache("鎵�鏈夎〃淇℃伅", new String[]{tableName});
if (!FieldSetEntity.isEmpty(tableInfo)) {
tableUuid = tableInfo.getString("uuid");
}
@@ -91,8 +96,18 @@
List<FieldSetEntity> tagFieldSetEntityList = new ArrayList<>();
//鏍规嵁group_uuid 鍒嗙粍
Map<String, List<FieldSetEntity>> groupMap = new HashMap<>();
+ Map<String, List<FieldSetEntity>> parentMap = new HashMap<>();
for (FieldSetEntity fieldSetEntity : productSysFaceControlProperty.getData()) {
String groupUuid = fieldSetEntity.getString("group_uuid");
+ String parentUuid = fieldSetEntity.getString("parent_uuid");
+ if (!StringUtils.isEmpty(parentUuid)) {
+ List<FieldSetEntity> fieldSetEntities = parentMap.get(parentUuid);
+ if (fieldSetEntities == null) {
+ fieldSetEntities = new ArrayList<>();
+ parentMap.put(parentUuid, fieldSetEntities);
+ }
+ fieldSetEntities.add(fieldSetEntity);
+ }
if ("tag".equals(fieldSetEntity.getString("property_name"))) {
tagFieldSetEntityList.add(fieldSetEntity);
}
@@ -110,6 +125,7 @@
}
List<FaceFieldEntity> result = new ArrayList<>();
+ List<List<FieldSetEntity>> subTableField = new ArrayList<>();
for (FieldSetEntity fs : tagFieldSetEntityList) {
String groupUuid = fs.getString("group_uuid");
String parentUuid = fs.getString("parent_uuid");
@@ -120,27 +136,130 @@
if (CollectionUtil.isEmpty(fieldSetEntity)) {
continue;
}
- FieldSetEntity parent = fieldSetEntity.get(0);
- String groupUuid1 = parent.getString("group_uuid");
- if (StringUtils.isEmpty(groupUuid1)) {
- continue;
+
+ to(groupMap, fieldSetEntity, subTableField, result,parentMap);
+ }
+ if (!CollectionUtil.isEmpty(subTableField)) {
+ //鏍规嵁瀛愯〃琛ㄥ悕瑁呰浇
+ Map<String, FaceFieldEntity> tableByFaceField = new HashMap<>();
+ for (List<FieldSetEntity> fieldSetEntities : subTableField) {
+ String parentUuid = fieldSetEntities.get(0).getString("parent_uuid");
+ //鍏堟壘鍒癱hildren
+ List<FieldSetEntity> fieldSetEntity = productSysFaceControlProperty.getFieldSetEntity(parentUuid);
+ if (CollectionUtil.isEmpty(fieldSetEntities)) {
+ continue;
+ }
+ //鎵惧埌浜哻hildren
+ FieldSetEntity fieldSetEntity1 = fieldSetEntity.get(0);
+ String p = fieldSetEntity1.getString("parent_uuid");
+ String cGroupUuid = fieldSetEntity1.getString("group_uuid");
+ if (StringUtils.isEmpty(p) || StringUtils.isEmpty(cGroupUuid)) {
+ continue;
+ }
+ List<FieldSetEntity> childrenGroup = groupMap.get(cGroupUuid);
+ List<FieldSetEntity> fieldSetEntity2 = productSysFaceControlProperty.getFieldSetEntity(p);
+ if (CollectionUtil.isEmpty(fieldSetEntity2) || CollectionUtil.isEmpty(childrenGroup)) {
+ continue;
+ }
+ //鎵惧埌浜� __config__
+ FieldSetEntity fieldSetEntity3 = fieldSetEntity2.get(0);
+ String groupUuid = fieldSetEntity3.getString("group_uuid");
+ if (StringUtils.isEmpty(groupUuid)) {
+ continue;
+ }
+ String uuid = fieldSetEntity3.getUUID();
+
+ FaceFieldEntity faceFieldEntity = tableByFaceField.get(uuid);
+ if (faceFieldEntity == null) {
+ faceFieldEntity = new FaceFieldEntity();
+ }
+ faceFieldEntity.setComponentType("subTable");
+ boolean isSub = CollectionUtil.isNotEmpty(faceFieldEntity.getSubField());
+ if (!isSub) {
+ for (FieldSetEntity setEntity : childrenGroup) {
+ String propertyName = setEntity.getString("property_name");
+ if ("tag".equals(propertyName) && "lx-form-sub-table".equals(setEntity.getString("property_value"))) {
+ isSub = true;
+ break;
+ }
+ }
+ }
+ if (!isSub) {
+ //涓嶆槸瀛愯〃缁勪欢
+ continue;
+ }
+ for (FieldSetEntity setEntity : groupMap.get(groupUuid)) {
+ String propertyName = setEntity.getString("property_name");
+ if ("subTableName".equals(propertyName)) {
+ faceFieldEntity.setSubTableName(setEntity.getString("property_value"));
+ tableByFaceField.put(faceFieldEntity.getSubTableName(), faceFieldEntity);
+ } else if ("add".equals(propertyName)) {
+ faceFieldEntity.setAllowAdd(setEntity.getBoolean("property_value"));
+ } else if ("delete".equals(propertyName)) {
+ faceFieldEntity.setAllowDelete(setEntity.getBoolean("property_value"));
+ }
+ }
+ List<FaceFieldEntity> subFieldList = faceFieldEntity.getSubField();
+ if (CollectionUtil.isEmpty(subFieldList)) {
+ 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;
+
}
- List<FieldSetEntity> parentGroup = groupMap.get(groupUuid1);
- FaceFieldEntity faceFieldEntity = new FaceFieldEntity();
+ }
+ return result;
+ }
+
+
+
+ private void to(Map<String, List<FieldSetEntity>> groupMap, List<FieldSetEntity> fieldSetEntity, List<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)) {
+ return;
+ }
+ List<FieldSetEntity> parentGroup = groupMap.get(groupUuid1);
+ FaceFieldEntity faceFieldEntity = new FaceFieldEntity();
+ boolean parentType = false;
+ String __config__ = null;
+ List<FieldSetEntity> other = null;
+ do {
for (FieldSetEntity setEntity : parentGroup) {
//鎵惧埌灞炴�у悕绉�= __vModel__
String propertyName = setEntity.getString("property_name");
+ if ("parentType".equals(propertyName) && "subTable".equals(setEntity.getString("property_value")) && subTableField != null) {
+ //瀛愯〃瀛楁
+ subTableField.add(parentGroup);
+ result.remove(faceFieldEntity);
+ break;
+ }
if ("__vModel__".equals(setEntity.getString("property_name"))) {
result.add(faceFieldEntity);
propertyName = "fieldName";
- }else if ("defaultNow".equals(propertyName)){
- propertyName="defaultValue";
+ } else if ("defaultNow".equals(propertyName)) {
+ propertyName = "defaultValue";
+ } else if ("__config__".equals(propertyName)) {
+ __config__ = setEntity.getUUID();
+ }
+ if (!StringUtils.isAnyEmpty(__config__) ) {
+ //璇诲彇瀛愯〃灞炴��
+ if (parentMap != null) {
+ other = parentMap.get(__config__);
+ }
}
propertyName = StrUtil.toCamelCase(propertyName);
if (ReflectUtil.hasField(FaceFieldEntity.class, propertyName)) {
if ("defaultValue".equals(propertyName)) {
ReflectUtil.setFieldValue(faceFieldEntity, propertyName, setEntity.getBoolean("property_value"));
- continue;
} else {
ReflectUtil.setFieldValue(faceFieldEntity, propertyName, setEntity.getObject("property_value"));
}
@@ -148,28 +267,45 @@
}
}
if (StringUtils.isEmpty(faceFieldEntity.getFieldName())) {
- result.remove(faceFieldEntity);
- continue;
+ return;
}
- List<FieldSetEntity> configGroup = groupMap.get(groupUuid);
- for (FieldSetEntity setEntity : configGroup) {
- //鎵惧埌灞炴�у悕绉�= __vModel__
- String propertyName = setEntity.getString("property_name");
- if ("tag".equals(propertyName)) {
- propertyName = "component_type";
- } else if ("field".equals(propertyName)) {
- propertyName = "fileField";
- } else if ("tableName".equals(propertyName)) {
- propertyName = "fileTableName";
- }
- propertyName = StrUtil.toCamelCase(propertyName);
- if (ReflectUtil.hasField(FaceFieldEntity.class, propertyName)) {
- ReflectUtil.setFieldValue(faceFieldEntity, propertyName, setEntity.getObject("property_value"));
- }
+ if (parentGroup == other) {
+ break;
}
-
+ if (other != null) {
+ parentGroup = other;
+ parentMap = null;
+ }
+ } while (other != null);
+ Set<FieldSetEntity> configGroup = Sets.newHashSet(groupMap.get(fieldSetEntity.get(0).getString("group_uuid")));
+ if (other != null) {
+ if (configGroup == null) {
+ configGroup = Sets.newHashSet(other);
+ } else {
+ configGroup.addAll(other);
+ }
}
- return result;
+ parentGroup = groupMap.get(groupUuid1);
+ if (configGroup != null && parentGroup != null) {
+ configGroup.addAll(parentGroup);
+ }
+
+ for (FieldSetEntity setEntity : configGroup) {
+ //鎵惧埌灞炴�у悕绉�= __vModel__
+ String propertyName = setEntity.getString("property_name");
+ if ("tag".equals(propertyName)) {
+ propertyName = "component_type";
+ } else if ("field".equals(propertyName)) {
+ propertyName = "fileField";
+ } else if ("tableName".equals(propertyName)) {
+ propertyName = "fileTableName";
+ }
+ propertyName = StrUtil.toCamelCase(propertyName);
+ if (ReflectUtil.hasField(FaceFieldEntity.class, propertyName)) {
+ ReflectUtil.setFieldValue(faceFieldEntity, propertyName, setEntity.getObject("property_value"));
+ }
+ }
+
}
}
--
Gitblit v1.9.2