From 585da4b632706e41e37dfaef833c41be371a8a91 Mon Sep 17 00:00:00 2001
From: 许鹏程 <1821349743@qq.com>
Date: 星期三, 04 六月 2025 15:06:27 +0800
Subject: [PATCH] 更新

---
 src/main/java/com/product/mobile/core/service/FaceMobileService.java |  260 ++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 203 insertions(+), 57 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 592931a..8e30bb5 100644
--- a/src/main/java/com/product/mobile/core/service/FaceMobileService.java
+++ b/src/main/java/com/product/mobile/core/service/FaceMobileService.java
@@ -1,13 +1,14 @@
 package com.product.mobile.core.service;
 
 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.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.drew.metadata.Face;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import com.product.common.lang.StringUtils;
 import com.product.core.cache.DataPoolCacheImpl;
@@ -16,19 +17,18 @@
 import com.product.core.entity.FieldSetEntity;
 import com.product.core.exception.BaseException;
 import com.product.core.service.support.AbstractBaseService;
+import com.product.face.entity.FaceListEntity;
+import com.product.face.service.FaceApplyService;
+import com.product.face.util.FaceUtil;
 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;
 import com.product.util.BaseUtil;
-
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.io.File;
-import java.nio.charset.Charset;
 import java.util.*;
 
 /**
@@ -44,6 +44,8 @@
 
 	@Autowired
 	public BaseDao baseDao;
+	@Autowired
+	private FaceApplyService faceApplyService;
 
 	///鑾峰彇琛ㄥ崟鎬诲叆鍙�
 	/**
@@ -51,7 +53,7 @@
 	 * @param fse浼犲叆琛ㄥ悕锛屾垨 琛║UID
 	 * @return
 	 */
-	public List<FaceFieldEntity> getFaceConfig(FieldSetEntity fse) {
+	public Object getFaceConfig(FieldSetEntity fse) {
 
 		String tableUuid = fse.getString("table_uuid");
 		if (tableUuid == null && StringUtils.isNotEmpty(fse.getString("uuid"))
@@ -82,7 +84,11 @@
 			}
 		}
 
-		List<FaceFieldEntity> ls = getFaceFieldByTable(fse);
+		Object o = getFaceFieldByTable(fse);
+		if (o instanceof FaceListEntity) {
+			return o;
+		}
+		List<FaceFieldEntity> ls = (List<FaceFieldEntity>) o;
 		if (ls == null) ls = new ArrayList<FaceFieldEntity>();
 		addproperty(tableUuid, fse.getString("table_name"), ls);
 		//鎵�鏈夎〃鍗晆uid鑷姩娣诲姞锛屽苟涓篽idden
@@ -120,6 +126,16 @@
 								!StringUtils.isEmpty(dt.getFieldSetEntity(0).getString("field_show_name"))) {
 							ls.get(i).setName(dt.getFieldSetEntity(0).getString("field_show_name"));
 						}
+						if ("file".indexOf(ls.get(i).getComponentType()) != -1) {
+							//闄勪欢
+							//鑾峰彇瀛楁绫诲瀷
+							String fieldType = dt.getString(0, "field_type");
+							if ("file-image".equals(fieldType)) {
+								ls.get(i).putOtherParam("fieldType", "image");
+							} else {
+//								ls.get(i).putOtherParam("fieldType", "file");
+							}
+						}
 					}
 					ls.get(i).setTable(table_name);
 				} else {
@@ -141,6 +157,7 @@
 				uuid.setType("String");
 				uuid.setTable(table_name);
 				uuid.setHidden("1");
+				uuid.setDisabled("1");
 				ls.add(uuid);
 			}
 
@@ -173,12 +190,17 @@
 			FaceFieldEntity uuid = new FaceFieldEntity();
 			FieldSetEntity f = dte.getFieldSetEntity(j);
 			if ("pk".equals(f.getString("field_type"))
+//					|| "created_by".equals(f.getString("field_name"))
+//					|| "created_utc_datetime".equals(f.getString("field_name"))
 					|| "updated_by".equals(f.getString("field_name"))
-					|| "updated_utc_datetime".equals(f.getString("field_name"))) {
+					|| "updated_utc_datetime".equals(f.getString("field_name"))
+					|| "flowsign".equals(f.getString("field_type"))
+			) {
 				continue;
 			}
 			if ("uuid".equals(f.getString("field_name"))) {
 				uuid.setHidden("1");
+				uuid.setDisabled("1");
 			}
 			if ("userids".equals(f.getString("field_type")) || "orgUuids".equals(f.getString("field_type"))) {
 				uuid.setMultiple("1");
@@ -186,11 +208,18 @@
 				uuid.setMultiple("0");
 			}
 
+			if ("userids".equals(f.getString("field_type")) || "userid".equals(f.getString("field_type"))) {
+				uuid.setOrganizationType("5");
+			} else if ("orgUuids".equals(f.getString("field_type")) || "orgUuid".equals(f.getString("field_type"))) {
+				uuid.setOrganizationType("2");
+			}
+
 			uuid.setComponentType("");
 			uuid.setPrompt(f.getString("field_reference"));
 			uuid.setName(f.getString("field_show_name"));
 			uuid.setField(f.getString("field_name"));
 			uuid.setType(f.getString("field_type"));
+			uuid.setRequired(f.getString("is_required"));
 			uuid.setTable(table_name);
 			ls.add(uuid);
 		}
@@ -208,7 +237,7 @@
 		}
 	}
 
-	public List<FaceFieldEntity> getFaceFieldByTable(FieldSetEntity fse) {
+	public Object getFaceFieldByTable(FieldSetEntity fse) {
 		String tableUuid = fse.getString("table_uuid");
 		String tableName = fse.getString("table_name");
 		if (StringUtils.isEmpty(tableUuid) && !StringUtils.isEmpty(tableName)) {
@@ -220,8 +249,13 @@
 		if (StringUtils.isEmpty(tableUuid)) {
 			throw new BaseException(MobileCoreCode.SYSTEM_FORM_COUNT);
 		}
-		FieldSetEntity faceFse = getBaseDao().getFieldSetByFilter("product_sys_face", "table_uuid=? and face_type=2", new Object[]{tableUuid}, true);
+		String faceType = BaseUtil.ifNull(fse.getString("face_type"), "2");
+		FieldSetEntity faceFse = getBaseDao().getFieldSetByFilter("product_sys_face", "table_uuid=? and face_type=?", new Object[]{tableUuid, faceType}, true);
 		faceFse.setTableName(tableName);
+		if ("1".equals(faceType)) {
+			//鍒楄〃
+			return faceApplyService.getFaceListConf(faceFse);
+		}
 		return getFaceField(faceFse);
 	}
 
@@ -298,9 +332,9 @@
 		if (CollectionUtil.isEmpty(groupMap)) {
 			throw new BaseException(MobileCoreCode.GET_FACE_CONFIG_FAIL);
 		}
-
+		Map<String, Map<String, Object>> group = new HashMap<>();
 		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");
@@ -308,16 +342,96 @@
 				continue;
 			}
 			List<FieldSetEntity> fieldSetEntity = productSysFaceControlProperty.getFieldSetEntity(parentUuid);
-			if (CollectionUtil.isEmpty(fieldSetEntity)) {
-				continue;
-			}
+			int i = result.size();
+			to(groupMap, fieldSetEntity, subTableFieldMap, result, parentMap);
+			String parentUuid1 = fieldSetEntity.get(0).getString("parent_uuid");
+			if (!CollectionUtil.isEmpty(fieldSetEntity) && !StringUtils.isEmpty(parentUuid1)) {
+				if (i + 1 == result.size()) {
+					Map<String, Object> o = group.get(parentUuid1);
+					List<FieldSetEntity> configValueList = null;
+					if (o == null) {
+						List<FieldSetEntity> fieldSetEntity1 = productSysFaceControlProperty.getFieldSetEntity(parentUuid1);
+						List<FieldSetEntity> fieldSetEntity2 = productSysFaceControlProperty.getFieldSetEntity(fieldSetEntity1.get(0).getString("parent_uuid"));
+						List<FieldSetEntity> fieldSetEntities = groupMap.get(fieldSetEntity2.get(0).getString("group_uuid"));
+						//list杞琺ap
+						Map<String, Object> map = new HashMap<>();
+						String tabsChldren = null;
+						for (FieldSetEntity fieldSetEntity3 : fieldSetEntities) {
+							map.put(fieldSetEntity3.getString("property_name"), fieldSetEntity3.getString("property_value"));
+							if ("__config__".equals(fieldSetEntity3.getString("property_name"))) {
+								configValueList = parentMap.get(fieldSetEntity3.getString("uuid"));
+								map.put("__config__", configValueList);
+							}
+							if ("children".equals(fieldSetEntity3.getString("property_name"))) {
+								tabsChldren = fieldSetEntity3.getString("property_value");
+							}
+						}
+						if (map.get("tag") != null && "el-tabs".equals(map.get("tag"))) {
+							map.remove("label");
+							if (tabsChldren != null) {
 
-			to(groupMap, fieldSetEntity, subTableField, result, parentMap);
+							}
+						}
+						group.put(parentUuid1, map);
+						o = map;
+
+					} else {
+						configValueList = (List<FieldSetEntity>) o.get("__config__");
+					}
+					result.get(i).putOtherParam("parentContainerName", BaseUtil.ifNull(o.get("title"), o.get("label")));
+					result.get(i).putOtherParam("parentContainer", parentUuid1);
+					Map<String, Object> configValueMap = null;
+					if (configValueList != null) {
+
+						//鑾峰彇property_name=showComponentFilter
+						Optional<FieldSetEntity> showComponentFilter = configValueList.stream().filter(fieldSetEntity1 -> "showComponentFilter".equals(fieldSetEntity1.getString("property_name"))).findFirst();
+						if (showComponentFilter.isPresent()) {
+							String u = showComponentFilter.get().getString("uuid");
+							List<FieldSetEntity> fieldSetEntities = parentMap.get(u);
+							JSONArray arrFilter = null;
+							if (fieldSetEntities != null && !fieldSetEntities.isEmpty()) {
+								JSONObject propertyJson = FaceUtil.getPropertyJson(Lists.newArrayList(showComponentFilter.get()), parentMap);
+								arrFilter = propertyJson.getJSONArray("showComponentFilter");
+							}
+							if (arrFilter != null) {
+								if (result.get(i).getShowComponentFilter() == null) {
+									result.get(i).setShowComponentFilter(arrFilter);
+								} else {
+									result.get(i).getShowComponentFilter().addAll(arrFilter);
+								}
+							}
+						}
+					}
+					if (o.get("configValue") != null) {
+						configValueMap = (Map<String, Object>) o.get("configValue");
+					}
+					if ((configValueList != null || configValueMap != null) && StringUtils.isEmpty(BaseUtil.ifNull(o.get("title"), o.get("label")))) {
+						if (configValueMap == null) {
+							configValueMap = new HashMap<>();
+							for (FieldSetEntity fieldSetEntity4 : configValueList) {
+								configValueMap.put(fieldSetEntity4.getString("property_name"), fieldSetEntity4.getString("property_value"));
+							}
+						}
+						//tag
+						String tag = (String) configValueMap.get("tag");
+						if ("el-card".equals(tag)) {
+							result.get(i).putOtherParam("parentContainerName", configValueMap.get("label"));
+						} else if ("el-tabs".equals(tag)) {
+							System.out.println(1);
+						} else {
+							System.out.println(2);
+						}
+						o.put("configValue", configValueMap);
+					}
+				}
+			}
 		}
-		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);
@@ -363,6 +477,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)) {
@@ -372,6 +492,21 @@
 						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"));
+					} else if ("__config__".equals(propertyName)) {
+
+						String __config__ = setEntity.getUUID();
+						List<FieldSetEntity> fieldSetEntities2 = parentMap.get(__config__);
+						if (!CollectionUtil.isEmpty(fieldSetEntities2)) {
+							for (FieldSetEntity fieldSetEntity4 : fieldSetEntities2) {
+								if ("label".equals(fieldSetEntity4.getString("property_name"))) {
+									faceFieldEntity.setName(fieldSetEntity4.getString("property_value"));
+								} else if ("required".equals(fieldSetEntity4.getString("property_name"))) {
+									faceFieldEntity.setRequired(fieldSetEntity4.getBoolean("property_value") ? "1" : "0");
+								}
+							}
+						}
 					}
 				}
 				List<FaceFieldEntity> subFieldList = faceFieldEntity.getSubField();
@@ -379,50 +514,31 @@
 					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;
 	}
 
-	public static void main(String[] args) {
 
-		String textFilePath = "d:\\Desktop\\鏂板缓 鏂囨湰鏂囨。 (2).txt";
-
-		List<String> lines = FileUtil.readLines(new File(textFilePath), CharsetUtil.defaultCharset());
-		for (int i = 0; i < lines.size(); i++) {
-			//UPDATE `product_db_lift`.`product_sys_datamodel_table` SET `uuid` = '4503ea5c-1e10-40b6-a2b4-79760eea6474', `table_name` = 'product_deivce_failure_level_config', `table_description` = '璁惧鏁呴殰绛夌骇閰嶇疆', `table_primary_key` = NULL, `container_name` = NULL, `table_base_view` = NULL, `view_sql` = NULL, `org_level_uuid` = NULL, `is_international` = NULL, `table_type` = '1', `created_by` = '1', `created_utc_datetime` = '2024-08-09 00:00:00', `updated_by` = '1', `updated_utc_datetime` = '2024-08-09 00:00:00', `produce_msg` = NULL, `sequence` = 2, `view_status` = NULL WHERE `table_id` = 5300;
-			String line = lines.get(i);
-			line = line.replaceAll("`", "");
-			String start = line.substring(line.indexOf("SET") + 3, line.indexOf("WHERE"));
-			String[] split = start.split(",");
-			Map<String, String> map = new HashMap<>();
-			for (String s : split) {
-				String[] split1 = s.split("=");
-				String value = split1.length == 1 ? null : split1[1].trim();
-				if ("null".equalsIgnoreCase(value)) {
-					value = null;
-				}
-				map.put(split1[0].trim(), value);
-
-			}
-			lines.set(i, lines.get(i).substring(0, lines.get(i).indexOf("WHERE")) + " WHERE `uuid`=" + map.get("uuid") + ";");
-		}
-		FileUtil.writeLines(lines, textFilePath, CharsetUtil.defaultCharset());
-	}
-
-
-	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);
+		Map<String, List<FieldSetEntity>> oldParentMap = Maps.newHashMap(parentMap);
 		String groupUuid1 = parent.getString("group_uuid");
 		if (StringUtils.isEmpty(groupUuid1)) {
 			return;
@@ -435,12 +551,18 @@
 			for (FieldSetEntity setEntity : parentGroup) {
 				//鎵惧埌灞炴�у悕绉�= __vModel__
 				String propertyName = setEntity.getString("property_name");
-				if ("componentType".equals(propertyName)) {
+				if ("componentType".equals(propertyName) || "prompt".equals(propertyName)) {
 					continue;
 				}
 				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;
 				}
@@ -453,6 +575,17 @@
 					propertyName = "prompt";
 				} else if ("__config__".equals(propertyName)) {
 					__config__ = setEntity.getUUID();
+					List<FieldSetEntity> fieldSetEntities = oldParentMap.get(__config__);
+					if (!CollectionUtil.isEmpty(fieldSetEntities)) {
+						//鏌ヨshowComponentFilter
+						Optional<FieldSetEntity> propertyName1 = fieldSetEntities.stream().filter(item -> "showComponentFilter".equals(item.getString("property_name"))).findFirst();
+						if (propertyName1.isPresent()) {
+							JSONObject propertyJson = FaceUtil.getPropertyJson(Lists.newArrayList(propertyName1.get()), oldParentMap);
+							if (propertyJson != null && propertyJson.get("showComponentFilter") != null) {
+								faceFieldEntity.addShowComponentFilter(propertyJson.getJSONArray("showComponentFilter"));
+							}
+						}
+					}
 				}
 				if (!StringUtils.isAnyEmpty(__config__)) {
 					//璇诲彇瀛愯〃灞炴��
@@ -461,6 +594,9 @@
 					}
 				}
 				propertyName = StrUtil.toCamelCase(propertyName);
+				if ("defaultValue".equals(propertyName) && !"0".equals(setEntity.getString("property_value")) && !"1".equals(setEntity.getString("property_value"))) {
+					continue;
+				}
 				if (ReflectUtil.hasField(FaceFieldEntity.class, propertyName) && !"field".equals(setEntity.getString("property_name")) && !"prompt".equals(setEntity.getString("property_name"))) {
 					ReflectUtil.setFieldValue(faceFieldEntity, propertyName, setEntity.getObject("property_value"));
 
@@ -496,7 +632,7 @@
 		for (FieldSetEntity setEntity : configGroup) {
 			//鎵惧埌灞炴�у悕绉�= __vModel__
 			String propertyName = setEntity.getString("property_name");
-			if ("componentType".equals(propertyName)) {
+			if ("componentType".equals(propertyName) || "prompt".equals(propertyName)) {
 				continue;
 			}
 			if ("tag".equals(propertyName)) {
@@ -511,8 +647,18 @@
 				propertyName = "prompt";
 			}
 			propertyName = StrUtil.toCamelCase(propertyName);
+			if ("defaultValue".equals(propertyName) && !"0".equals(setEntity.getString("property_value")) && !"1".equals(setEntity.getString("property_value"))) {
+				continue;
+			}
+			Object propertyValue = setEntity.getObject("property_value");
+			if (oldParentMap != null && propertyValue == null && StringUtils.equalsAny(setEntity.getString("property_type"), "2", "3", "4")) {
+				JSONObject propertyJson = FaceUtil.getPropertyJson(Lists.newArrayList(setEntity), oldParentMap);
+				if (propertyJson != null && propertyJson.get(setEntity.getString("property_name")) != null) {
+					propertyValue = propertyJson.get(setEntity.getString("property_name"));
+				}
+			}
 			if (ReflectUtil.hasField(FaceFieldEntity.class, propertyName) && !"field".equals(setEntity.getString("property_name")) && !"prompt".equals(setEntity.getString("property_name"))) {
-				ReflectUtil.setFieldValue(faceFieldEntity, propertyName, setEntity.getObject("property_value"));
+				ReflectUtil.setFieldValue(faceFieldEntity, propertyName, propertyValue);
 			}
 		}
 	}

--
Gitblit v1.9.2