From 08d025f05576294faca59fb3e2b2925dd60e8205 Mon Sep 17 00:00:00 2001
From: 许鹏程 <1821349743@qq.com>
Date: 星期五, 18 十月 2024 16:58:07 +0800
Subject: [PATCH] defaultValue 被覆盖

---
 src/main/java/com/product/mobile/core/service/FaceMobileService.java |  193 +++++++++++++++++++++++++++++------------------
 1 files changed, 119 insertions(+), 74 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 79a39a4..96acaea 100644
--- a/src/main/java/com/product/mobile/core/service/FaceMobileService.java
+++ b/src/main/java/com/product/mobile/core/service/FaceMobileService.java
@@ -1,6 +1,8 @@
 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.ReflectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
@@ -25,6 +27,8 @@
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.io.File;
+import java.nio.charset.Charset;
 import java.util.*;
 
 /**
@@ -37,120 +41,122 @@
 
 	@Resource
 	FlowDetailService flowDetailService;
-	
+
 	@Autowired
 	public BaseDao baseDao;
-	
+
 	///鑾峰彇琛ㄥ崟鎬诲叆鍙�
 	/**
-	 * 
+	 *
 	 * @param fse浼犲叆琛ㄥ悕锛屾垨 琛║UID
 	 * @return
 	 */
 	public List<FaceFieldEntity> getFaceConfig(FieldSetEntity fse) {
-	
-		String tableUuid=fse.getString("table_uuid");
-		if (tableUuid==null && StringUtils.isNotEmpty(fse.getString("uuid"))
+
+		String tableUuid = fse.getString("table_uuid");
+		if (tableUuid == null && StringUtils.isNotEmpty(fse.getString("uuid"))
 				&& StringUtils.isEmpty(fse.getString("table_name"))) {
 			//閫氳繃涓氬姟琛ㄤ俊鎭煡琛ㄥ崟淇℃伅
 			FieldSetEntity detailFse = getBaseDao().getFieldSetEntity(CmnConst.TABLE_FLOW_DETAIL, fse.getString(CmnConst.FIELD_UUID), false);
-			if(detailFse!=null) {
+			if (detailFse != null) {
 				//鑾峰彇琛ㄥ悕
 				fse.setValue("table_name", detailFse.getString("table_name"));
 			}
-			
+
 		}
 		//閫氳繃瀹℃壒浠诲姟鐨剈uid鏉ユ煡琛ㄥ崟淇℃伅
-		if (tableUuid==null && StringUtils.isNotEmpty(fse.getString("table_name"))) {
+		if (tableUuid == null && StringUtils.isNotEmpty(fse.getString("table_name"))) {
 			FieldSetEntity tableInfo = BaseUtil.getSingleInfoByCache("鎵�鏈夎〃淇℃伅", new String[]{fse.getString("table_name")});
 			if (!FieldSetEntity.isEmpty(tableInfo)) {
 				tableUuid = tableInfo.getString("uuid");
 				fse.setValue("table_uuid", tableUuid);
 			}
 		}
-		
-		if(tableUuid!=null && fse.getString("table_name")==null) {
-			
+
+		if (tableUuid != null && fse.getString("table_name") == null) {
+
 			FieldSetEntity tableInfo = BaseUtil.getSingleInfoByCache("鎵�鏈夎〃淇℃伅(uuid)", new String[]{tableUuid});
 			if (!FieldSetEntity.isEmpty(tableInfo)) {
 				//鑾峰彇琛ㄥ悕
 				fse.setValue("table_name", tableInfo.getString("table_name"));
 			}
 		}
-		
-		List<FaceFieldEntity> ls=getFaceFieldByTable(fse);
-		if(ls==null)ls=new ArrayList<FaceFieldEntity>();
-		addproperty(tableUuid,fse.getString("table_name"),ls);
+
+		List<FaceFieldEntity> ls = getFaceFieldByTable(fse);
+		if (ls == null) ls = new ArrayList<FaceFieldEntity>();
+		addproperty(tableUuid, fse.getString("table_name"), ls);
 		//鎵�鏈夎〃鍗晆uid鑷姩娣诲姞锛屽苟涓篽idden
 		return ls;
-		
+
 	}
 	//閫掑綊鎶婁富琛ㄥ拰瀛愯〃鐨勫瓧娈靛睘鎬ф坊鍔犺繘鍘伙紝濡傛灉娌℃湁閰嶈〃鍗曪紝鍒欏彇琛ㄦ暟鎹粨鏋勮繘琛屽睍绀�
+
 	/**
-	 * 
+	 *
 	 * @param ls鏌ュ嚭鏉ョ殑琛ㄥ崟淇℃伅
 	 * @param tables 璁板綍鐨勬墍鏈夎〃锛屽搴旂殑琛ㄥ崟淇℃伅
 	 */
-	private void  addproperty(String table_uuid,String table_name,List<FaceFieldEntity> ls) {
-		if(ls.size()>0) {
-			for(int i=0;i<ls.size();i++) {
-				String subTableName=ls.get(i).getSubTableName();///鍙兘鏄瓙琛�
-				if(StringUtils.isEmpty(subTableName)) {///涓昏〃瀛楁
+	private void addproperty(String table_uuid, String table_name, List<FaceFieldEntity> ls) {
+		if (ls.size() > 0) {
+			for (int i = 0; i < ls.size(); i++) {
+				String subTableName = ls.get(i).getSubTableName();///鍙兘鏄瓙琛�
+				if (StringUtils.isEmpty(subTableName)) {///涓昏〃瀛楁
 					DataTableEntity dt = DataPoolCacheImpl.getInstance().getCacheData("琛ㄥ瓧娈典俊鎭�"
-							,new String[] {table_uuid,ls.get(i).getField()});
-					
-					if(!DataTableEntity.isEmpty(dt)) {
+							, new String[]{table_uuid, ls.get(i).getField()});
+
+					if (!DataTableEntity.isEmpty(dt)) {
 //						if(StringUtils.isEmpty(ls.get(i).getType())) {
 //							ls.get(i).setType(dt.getFieldSetEntity(0).getString("field_type"));
 //						}
-						if(StringUtils.isEmpty(ls.get(i).getPrompt()) && 
+						if (StringUtils.isEmpty(ls.get(i).getPrompt()) &&
 								!StringUtils.isEmpty(dt.getFieldSetEntity(0).getString("field_reference"))) {
 							ls.get(i).setPrompt(dt.getFieldSetEntity(0).getString("field_reference"));
 						}
-						if(StringUtils.isEmpty(ls.get(i).getRequired()) && 
+						if (StringUtils.isEmpty(ls.get(i).getRequired()) &&
 								!StringUtils.isEmpty(dt.getFieldSetEntity(0).getString("is_required"))) {
 							ls.get(i).setRequired(dt.getFieldSetEntity(0).getString("is_required"));
 						}
-						if(StringUtils.isEmpty(ls.get(i).getName()) && 
+						if (StringUtils.isEmpty(ls.get(i).getName()) &&
 								!StringUtils.isEmpty(dt.getFieldSetEntity(0).getString("field_show_name"))) {
 							ls.get(i).setName(dt.getFieldSetEntity(0).getString("field_show_name"));
 						}
 					}
 					ls.get(i).setTable(table_name);
-				}else {
+				} else {
 					//============鎶婂瓙琛ㄥ瓧娈典篃澶勭悊涓�涓�
 					//瀛愯〃
 					FieldSetEntity tableInfo = BaseUtil.getSingleInfoByCache("鎵�鏈夎〃淇℃伅", new String[]{subTableName});
 					if (!FieldSetEntity.isEmpty(tableInfo)) {
-						addproperty(tableInfo.getString("uuid"),tableInfo.getString("table_name"),ls.get(i).getSubField());
+						addproperty(tableInfo.getString("uuid"), tableInfo.getString("table_name"), ls.get(i).getSubField());
 					}
 				}
-				
+
 			}
-			DataTableEntity dt = DataPoolCacheImpl.getInstance().getCacheData("琛ㄥ瓧娈典俊鎭�",new String[] {table_uuid,"uuid"});
-			if(!DataTableEntity.isEmpty(dt)) {
-				FaceFieldEntity uuid=new FaceFieldEntity();
+			DataTableEntity dt = DataPoolCacheImpl.getInstance().getCacheData("琛ㄥ瓧娈典俊鎭�", new String[]{table_uuid, "uuid"});
+			if (!DataTableEntity.isEmpty(dt)) {
+				FaceFieldEntity uuid = new FaceFieldEntity();
 				uuid.setComponentType("uuid");
 				uuid.setField("uuid");
 				uuid.setName("缂�  鐮�");
 				uuid.setType("String");
 				uuid.setTable(table_name);
-				uuid.setHidden("1"); 
+				uuid.setHidden("1");
 				ls.add(uuid);
 			}
-			
-		}else {///浠ヨ〃鍗曡璁′负鍑嗭紝濡傛灉娌℃湁閰嶇疆琛ㄥ崟锛屽垯浠ユ暟鎹〃涓哄噯锛屽叏閮ㄤ繚鐣�
-			toConvertFace(table_uuid,table_name,ls,null);
+
+		} else {///浠ヨ〃鍗曡璁′负鍑嗭紝濡傛灉娌℃湁閰嶇疆琛ㄥ崟锛屽垯浠ユ暟鎹〃涓哄噯锛屽叏閮ㄤ繚鐣�
+			toConvertFace(table_uuid, table_name, ls, null);
 			//杩斿洖瀛愯〃
-			Object [][]sub=baseDao.getSubTableName(table_name);
-			if(sub!=null && sub.length>0&&sub[0].length>0) {
-				for(int i=0;i<sub[0].length;i++) {
-					toConvertFace(sub[0][i].toString(),sub[1][i].toString(),new ArrayList<FaceFieldEntity>(),ls);
+			Object[][] sub = baseDao.getSubTableName(table_name);
+			if (sub != null && sub.length > 0 && sub[0].length > 0) {
+				for (int i = 0; i < sub[0].length; i++) {
+					toConvertFace(sub[0][i].toString(), sub[1][i].toString(), new ArrayList<FaceFieldEntity>(), ls);
 				}
 			}
-			
+
 		}
 	}
+
 	/**
 	 * 鏁版嵁搴撹〃瀛楁瀹氫箟杞崲鎴愯〃鍗曞畾涔�
 	 * @param table_uuid
@@ -158,28 +164,28 @@
 	 * @param ls
 	 * @param pls 鐖剁晫闈�
 	 */
-	private void toConvertFace(String table_uuid,String table_name,List<FaceFieldEntity> ls,List<FaceFieldEntity> pls) {
-		if(ls==null) {
-			ls=new ArrayList<FaceFieldEntity>();
+	private void toConvertFace(String table_uuid, String table_name, List<FaceFieldEntity> ls, List<FaceFieldEntity> pls) {
+		if (ls == null) {
+			ls = new ArrayList<FaceFieldEntity>();
 		}
-		DataTableEntity dte = DataPoolCacheImpl.getInstance().getCacheData("鎵�鏈夊瓧娈典俊鎭苟鎸夎〃鍒嗙粍",new String[] {table_uuid});
-		for(int j=0;j<dte.getRows();j++) {
-			FaceFieldEntity uuid=new FaceFieldEntity();
-			FieldSetEntity f=dte.getFieldSetEntity(j);
-			if("pk".equals(f.getString("field_type")) 
-					||"updated_by".equals(f.getString("field_name"))
-					||"updated_utc_datetime".equals(f.getString("field_name"))) {
+		DataTableEntity dte = DataPoolCacheImpl.getInstance().getCacheData("鎵�鏈夊瓧娈典俊鎭苟鎸夎〃鍒嗙粍", new String[]{table_uuid});
+		for (int j = 0; j < dte.getRows(); j++) {
+			FaceFieldEntity uuid = new FaceFieldEntity();
+			FieldSetEntity f = dte.getFieldSetEntity(j);
+			if ("pk".equals(f.getString("field_type"))
+					|| "updated_by".equals(f.getString("field_name"))
+					|| "updated_utc_datetime".equals(f.getString("field_name"))) {
 				continue;
 			}
-			if("uuid".equals(f.getString("field_name"))) {
-				uuid.setHidden("1"); 
+			if ("uuid".equals(f.getString("field_name"))) {
+				uuid.setHidden("1");
 			}
-			if("userids".equals(f.getString("field_type")) ||"orgUuids".equals(f.getString("field_type")) ) {
+			if ("userids".equals(f.getString("field_type")) || "orgUuids".equals(f.getString("field_type"))) {
 				uuid.setMultiple("1");
-			}else {
+			} else {
 				uuid.setMultiple("0");
 			}
-				
+
 			uuid.setComponentType("");
 			uuid.setPrompt(f.getString("field_reference"));
 			uuid.setName(f.getString("field_show_name"));
@@ -188,9 +194,9 @@
 			uuid.setTable(table_name);
 			ls.add(uuid);
 		}
-		if(pls!=null) {
-			FaceFieldEntity uuid=new FaceFieldEntity();
-			uuid.setHidden(""); 
+		if (pls != null) {
+			FaceFieldEntity uuid = new FaceFieldEntity();
+			uuid.setHidden("");
 			uuid.setComponentType("subTable");
 			uuid.setPrompt("");
 			uuid.setName("");
@@ -201,7 +207,7 @@
 			pls.add(uuid);
 		}
 	}
-	
+
 	public List<FaceFieldEntity> getFaceFieldByTable(FieldSetEntity fse) {
 		String tableUuid = fse.getString("table_uuid");
 		String tableName = fse.getString("table_name");
@@ -214,7 +220,7 @@
 		if (StringUtils.isEmpty(tableUuid)) {
 			throw new BaseException(MobileCoreCode.SYSTEM_FORM_COUNT);
 		}
-		FieldSetEntity faceFse = getBaseDao().getFieldSetByFilter("product_sys_face", "table_uuid=?", new Object[]{tableUuid}, true);
+		FieldSetEntity faceFse = getBaseDao().getFieldSetByFilter("product_sys_face", "table_uuid=? and face_type=2", new Object[]{tableUuid}, true);
 		faceFse.setTableName(tableName);
 		return getFaceField(faceFse);
 	}
@@ -388,6 +394,32 @@
 		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) {
 		FieldSetEntity parent = fieldSetEntity.get(0);
@@ -403,6 +435,9 @@
 			for (FieldSetEntity setEntity : parentGroup) {
 				//鎵惧埌灞炴�у悕绉�= __vModel__
 				String propertyName = setEntity.getString("property_name");
+				if ("componentType".equals(propertyName) || "prompt".equals(propertyName)) {
+					continue;
+				}
 				if ("parentType".equals(propertyName) && "subTable".equals(setEntity.getString("property_value")) && subTableField != null) {
 					//瀛愯〃瀛楁
 					subTableField.add(parentGroup);
@@ -412,8 +447,10 @@
 				if ("__vModel__".equals(setEntity.getString("property_name"))) {
 					result.add(faceFieldEntity);
 					propertyName = "field";
-				} else if ("defaultNow".equals(propertyName)) {
-					propertyName = "defaultValue";
+				} else if ("label".equals(setEntity.getString("property_name"))) {
+					propertyName = "name";
+				} else if ("advanceName".equals(setEntity.getString("property_name"))) {
+					propertyName = "prompt";
 				} else if ("__config__".equals(propertyName)) {
 					__config__ = setEntity.getUUID();
 				}
@@ -424,12 +461,11 @@
 					}
 				}
 				propertyName = StrUtil.toCamelCase(propertyName);
-				if (ReflectUtil.hasField(FaceFieldEntity.class, propertyName)) {
-					if ("defaultValue".equals(propertyName)) {
-						ReflectUtil.setFieldValue(faceFieldEntity, propertyName, setEntity.getBoolean("property_value"));
-					} else {
-						ReflectUtil.setFieldValue(faceFieldEntity, propertyName, setEntity.getObject("property_value"));
-					}
+				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"));
 
 				} else if (!StringUtils.isEmpty(setEntity.getObject("property_value"))) {
 					//鍒ゆ柇鏄惁
@@ -463,19 +499,28 @@
 		for (FieldSetEntity setEntity : configGroup) {
 			//鎵惧埌灞炴�у悕绉�= __vModel__
 			String propertyName = setEntity.getString("property_name");
+			if ("componentType".equals(propertyName) || "prompt".equals(propertyName)) {
+				continue;
+			}
 			if ("tag".equals(propertyName)) {
 				propertyName = "component_type";
 			} else if ("field".equals(propertyName)) {
 				propertyName = "fileField";
 			} else if ("tableName".equals(propertyName)) {
 				propertyName = "fileTableName";
+			} else if ("label".equals(setEntity.getString("property_name"))) {
+				propertyName = "name";
+			} else if ("advanceName".equals(setEntity.getString("property_name"))) {
+				propertyName = "prompt";
 			}
 			propertyName = StrUtil.toCamelCase(propertyName);
-			if (ReflectUtil.hasField(FaceFieldEntity.class, 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"));
 			}
 		}
-
 	}
 
 }

--
Gitblit v1.9.2