From 7baf145ac8ca6cff9177c50c8862ba38d274b484 Mon Sep 17 00:00:00 2001
From: 许鹏程 <1821349743@qq.com>
Date: 星期三, 24 五月 2023 11:34:32 +0800
Subject: [PATCH] 表单缓存、列表模糊搜索

---
 src/main/java/com/product/face/service/FaceCacheService.java      |  173 ++++++++++
 src/main/java/com/product/face/config/FaceConst.java              |    8 
 src/main/java/com/product/face/entity/FaceListEntity.java         |  346 +++++++++++++++++++++
 src/main/java/com/product/face/service/FaceApplyService.java      |   47 --
 src/main/java/com/product/face/service/FaceDesignService.java     |  112 ------
 src/main/java/com/product/face/service/FaceListSearchService.java |   59 +++
 src/main/java/com/product/face/entity/FaceEntity.java             |   36 ++
 src/main/java/com/product/face/util/FaceUtil.java                 |  128 ++++++++
 8 files changed, 758 insertions(+), 151 deletions(-)

diff --git a/src/main/java/com/product/face/config/FaceConst.java b/src/main/java/com/product/face/config/FaceConst.java
index 44c045a..a61fea7 100644
--- a/src/main/java/com/product/face/config/FaceConst.java
+++ b/src/main/java/com/product/face/config/FaceConst.java
@@ -44,4 +44,12 @@
 	//鎺т欢鎺掑簭灞炴��
 	public static final String CONTROL_SEQUENCE = "control_sequence";
 
+	/**
+	 * 缂撳瓨璧峰Key
+	 */
+	public static final String FACE_LIST_KEY = "face:fieldList:";
+
+	public static final String FACE_FORM_CACHE_KEY = "face:form:";
+
+
 }
diff --git a/src/main/java/com/product/face/entity/FaceEntity.java b/src/main/java/com/product/face/entity/FaceEntity.java
new file mode 100644
index 0000000..3bd5786
--- /dev/null
+++ b/src/main/java/com/product/face/entity/FaceEntity.java
@@ -0,0 +1,36 @@
+package com.product.face.entity;
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @Author cheng
+ * @Date 2023/5/24 10:31
+ * @Desc
+ */
+public class FaceEntity implements Serializable {
+
+	private static final long serialVersionUID = 2740417254150550879L;
+
+	private JSONObject data;
+
+	private List<JSONObject>  drawingList;
+
+	public JSONObject getData() {
+		return data;
+	}
+
+	public void setData(JSONObject data) {
+		this.data = data;
+	}
+
+	public List<JSONObject> getDrawingList() {
+		return drawingList;
+	}
+
+	public void setDrawingList(List<JSONObject> drawingList) {
+		this.drawingList = drawingList;
+	}
+}
diff --git a/src/main/java/com/product/face/entity/FaceListEntity.java b/src/main/java/com/product/face/entity/FaceListEntity.java
new file mode 100644
index 0000000..e2fbd06
--- /dev/null
+++ b/src/main/java/com/product/face/entity/FaceListEntity.java
@@ -0,0 +1,346 @@
+package com.product.face.entity;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.product.admin.config.CmnConst;
+import com.product.admin.service.DictService;
+import com.product.admin.service.SystemFaceService;
+import com.product.common.lang.StringUtils;
+import com.product.core.cache.DataPoolCacheImpl;
+import com.product.core.cache.util.RedisUtil;
+import com.product.core.config.CoreConst;
+import com.product.core.entity.DataTableEntity;
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.spring.context.SpringBeanUtil;
+import com.product.core.spring.context.SpringMVCContextHolder;
+import com.product.module.sys.entity.SystemUser;
+import com.product.util.BaseUtil;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Author cheng
+ * @Description 鍒楄〃瀛楁鎿嶄綔绫�
+ * @Date 2021/9/7 14:34
+ * @Version 1.0
+ */
+public class FaceListEntity implements Serializable {
+
+    private static final long serialVersionUID = -6777140406080679771L;
+    /**
+     * 琛╱uid
+     */
+    private String tableUuid;
+    /**
+     * face_uuid
+     */
+    private String uuid;
+    /**
+     * 琛ㄥ崟鍚�
+     */
+    private String faceName;
+    /**
+     * 鍔熻兘uuid
+     */
+    @Deprecated
+    private String functionUuid;
+    /**
+     * 瀛楁闆嗗悎
+     */
+    private List<FaceField> faceFields;
+    /**
+     * 琛ㄥ悕
+     */
+    private String tableName;
+
+    /**
+     * 鑾峰彇琛ㄥ悕
+     *
+     * @return
+     */
+    public String getTableName() {
+        if (this.tableName == null && this.tableUuid != null) {
+            //浠庣紦瀛樹腑鑾峰彇
+            DataTableEntity cacheData = DataPoolCacheImpl.getInstance().getCacheData("鎵�鏈夎〃淇℃伅(uuid)", new String[]{this.tableUuid});
+            if (cacheData != null && cacheData.getRows() > 0) {
+                String table_name = cacheData.getString(0, "table_name");
+                this.tableName = table_name;
+            }
+        }
+        return tableName;
+    }
+
+    /**
+     * 鏉′欢瀛楁
+     *
+     * @param fieldName      瀛楁鍚嶇О
+     * @param faceUuid       瀛楁uuid
+     * @param columnName     鍒楀悕
+     * @param columnWidth    鍒楀
+     * @param sequence       鎺掑簭
+     * @param fieldReference 鍙傜収
+     */
+    public void addField(String fieldName, String faceUuid, String columnName, String columnWidth, Integer sequence, String fieldReference) {
+        FaceField faceField = new FaceField();
+        faceField.setFieldName(fieldName);
+        faceField.setFieldUuid(faceUuid);
+        faceField.setColumnName(columnName);
+        faceField.setColumnWidth(columnWidth);
+        faceField.setSequence(sequence);
+        faceField.setFieldReference(fieldReference);
+        if (this.faceFields == null) {
+            this.faceFields = Lists.newArrayList();
+        }
+        this.faceFields.add(faceField);
+    }
+
+    /**
+     * 瀛楁鎺掑簭鏂规硶
+     */
+    public void sortField() {
+        if (this.faceFields != null && this.faceFields.size() > 0) {
+            this.faceFields.sort((a, b) -> {
+                return a.getSequence().compareTo(b.getSequence());
+            });
+        }
+    }
+
+    public String getTableUuid() {
+        return tableUuid;
+    }
+
+    public void setTableUuid(String tableUuid) {
+        this.tableUuid = tableUuid;
+    }
+
+    public String getUuid() {
+        return uuid;
+    }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+
+    public String getFaceName() {
+        return faceName;
+    }
+
+    public void setFaceName(String faceName) {
+        this.faceName = faceName;
+    }
+
+    public String getFunctionUuid() {
+        return functionUuid;
+    }
+
+    public void setFunctionUuid(String functionUuid) {
+        this.functionUuid = functionUuid;
+    }
+
+    public List<FaceField> getFaceFields() {
+        return faceFields;
+    }
+
+    public void setFaceFields(List<FaceField> faceFields) {
+        this.faceFields = faceFields;
+    }
+
+    /**
+     * 鑾峰彇鍙傜収鏉′欢
+     *
+     * @param fieldName
+     * @param dictName
+     * @return
+     */
+    private String getDictFilter(String fieldName, String dictName) {
+        StringBuilder filter = new StringBuilder();
+        DictService bean = SpringBeanUtil.getBean(DictService.class);
+        String manager_type = null;
+        SystemUser currentUser = SpringMVCContextHolder.getCurrentUser();
+        if (currentUser != null && currentUser.getCurrentManager() != null) {
+            manager_type = currentUser.getCurrentManager().getString(CmnConst.MANAGER_TYPE);
+        } else {
+            manager_type = null;
+        }
+        //鎷艰鏅�氬弬鐓ф煡璇㈡墍闇�鍙傛暟
+        FieldSetEntity fse = new FieldSetEntity();
+        fse.setTableName(CmnConst.PRODUCT_SYS_DICT);
+        fse.setValue(CmnConst.DICT_NAME, dictName);
+        fse.setValue(CoreConst.SYSTEM_CLIENT_TYPE_, currentUser.getClientType());
+        //鑾峰彇鍙傜収闆嗗悎
+        DataTableEntity dataTableEntity = bean.listDictByname(fse, manager_type);
+        if (!BaseUtil.dataTableIsEmpty(dataTableEntity)) {
+            //缁勬垚鏉′欢
+            Object[] uuids = dataTableEntity.getUuids();
+            filter.append(fieldName);
+            filter.append(" in  (SELECT  dict_value FROM product_sys_dict where ");
+            filter.append(BaseUtil.buildQuestionMarkFilter("uuid", uuids, true));
+            filter.append(" and dict_label like concat('%','~val~','%') ) ");
+        }
+        return filter.toString();
+    }
+
+    /**
+     * 鑾峰彇鏉′欢
+     *
+     * @param tableAlias 琛ㄥ埆鍚�
+     * @param aliasField 瀛楁鍒悕
+     * @return
+     */
+    public Map<String, List<String>> getFilters(String tableAlias, Map<String, List<String>> aliasField) {
+        DataPoolCacheImpl poolCache = null;
+        //鎵�鏈夊瓧娈甸泦鍚�
+        List<FaceField> faceFields = this.getFaceFields();
+        //鏅�氭ā绯婃煡璇㈠瓧娈甸泦鍚�
+        List<String> fieldNames = Lists.newArrayList();
+        //鍙傜収妯$硦鏌ヨ鏉′欢闆嗗悎
+        List<String> filters = Lists.newArrayList();
+        //杩斿洖鐨勭粨鏋滈泦
+        Map<String, List<String>> maps = Maps.newHashMap();
+        maps.put("fields", fieldNames);
+        maps.put("filter", filters);
+        for (int i = 0; i < faceFields.size(); i++) {
+            FaceField faceField = faceFields.get(i);
+            if (StringUtils.isEmpty(faceField.getFieldName()) || StringUtils.isEmpty(faceField.getFieldReference())) {
+                if (poolCache == null) {
+                    poolCache = DataPoolCacheImpl.getInstance();
+                }
+                DataTableEntity dt = poolCache.getCacheData("琛ㄥ瓧娈典俊鎭�", new String[]{getTableUuid(), faceField.getFieldName()});
+                if (BaseUtil.dataTableIsEmpty(dt)) {
+                } else {
+                    FieldSetEntity f = dt.getFieldSetEntity(0);
+                    faceField.setFieldName(f.getString(CmnConst.FIELD_NAME));
+                    faceField.setFieldReference(f.getString("field_reference"));
+                }
+            }
+            //瀛楁鍚嶇О
+            String fieldName = faceField.getFieldName();
+            if (aliasField != null && !StringUtils.isEmpty(fieldName)) {
+                List<String> fieldAlias = aliasField.get(getTableName() + "." + fieldName);
+                if (fieldAlias != null && fieldAlias.size() > 0) {
+                    String alias = fieldAlias.get(0);
+                    if (!StringUtils.isEmpty(alias)) {
+                        fieldName = alias;
+                    }
+                }
+            }
+            //鍙傜収澶勭悊
+            String field_reference = faceField.getFieldReference();
+            if (!StringUtils.isEmpty(field_reference)) {
+                if (field_reference.indexOf("銆�") == 0 && field_reference.indexOf("銆�") > 0) {
+                    //鏅�氬弬鐓�
+                    filters.add(getDictFilter(fieldName, field_reference.replace("銆�", "").replace("銆�", "")));
+                    continue;
+                } else {
+                    if (poolCache == null) {
+                        poolCache = DataPoolCacheImpl.getInstance();
+                    }
+                    //楂樼骇鍙傜収
+                    DataTableEntity prompt = poolCache.getCacheData("楂樼骇鍙傜収閰嶇疆淇℃伅", new String[]{field_reference});
+                    if (BaseUtil.dataTableIsEmpty(prompt)) {
+                        continue;
+                    }
+                    FieldSetEntity ff = prompt.getFieldSetEntity(0);
+                    StringBuilder p = new StringBuilder();
+                    p.append(fieldName).append(" in ").append(" ( SELECT ").append(ff.getString("value_field")).append(" FROM ").append(ff.getString("source_table"));
+                    p.append(" WHERE ").append(ff.getString("view_fields")).append(" like concat('%','~val~','%') )");
+                    filters.add(p.toString());
+                    continue;
+                }
+            }
+
+            if (!StringUtils.isEmpty(faceField.getFieldName())) {
+                fieldNames.add(StringUtils.isEmpty(tableAlias) ? faceField.getFieldName() : ("`" + tableAlias + "`.`" + fieldName + "`"));
+            }
+        }
+        //鑾峰彇redis 璧峰key
+        String faceListKey = SystemFaceService.FACE_LIST_KEY;
+        //閲嶆柊鏀惧叆redis
+        RedisUtil.set(faceListKey + getUuid(), this);
+        return maps;
+    }
+
+    /**
+     * 瀛楁瀹炰綋绫�
+     */
+    public class FaceField implements Serializable {
+
+        private static final long serialVersionUID = 3154509166818911568L;
+        /**
+         * 瀛楁鍚嶇О
+         */
+        private String fieldName;
+        /**
+         * 瀛楁uuid
+         */
+        private String fieldUuid;
+        /**
+         * 鍒楀悕
+         */
+        private String columnName;
+        /**
+         * 鍒楀
+         */
+        private String columnWidth;
+        /**
+         * 鎺掑簭
+         */
+        private Integer sequence;
+        /**
+         * 瀛楁鍙傜収
+         */
+        private String fieldReference;
+
+        public String getFieldReference() {
+            return fieldReference;
+        }
+
+        public void setFieldReference(String fieldReference) {
+            this.fieldReference = fieldReference;
+        }
+
+        public String getFieldName() {
+            return fieldName;
+        }
+
+        public void setFieldName(String fieldName) {
+            this.fieldName = fieldName;
+        }
+
+        public String getFieldUuid() {
+            return fieldUuid;
+        }
+
+        public void setFieldUuid(String fieldUuid) {
+            this.fieldUuid = fieldUuid;
+        }
+
+        public String getColumnName() {
+            return columnName;
+        }
+
+        public void setColumnName(String columnName) {
+            this.columnName = columnName;
+        }
+
+        public String getColumnWidth() {
+            return columnWidth;
+        }
+
+        public void setColumnWidth(String columnWidth) {
+            this.columnWidth = columnWidth;
+        }
+
+        public Integer getSequence() {
+            return sequence;
+        }
+
+        public void setSequence(Integer sequence) {
+            this.sequence = sequence;
+        }
+
+    }
+
+}
diff --git a/src/main/java/com/product/face/service/FaceApplyService.java b/src/main/java/com/product/face/service/FaceApplyService.java
index 689c4a8..b807fe8 100644
--- a/src/main/java/com/product/face/service/FaceApplyService.java
+++ b/src/main/java/com/product/face/service/FaceApplyService.java
@@ -3,8 +3,10 @@
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Lists;
+import com.product.admin.entity.FaceListEntity;
 import com.product.admin.service.SystemFaceService;
 import com.product.common.lang.StringUtils;
+import com.product.core.cache.util.RedisUtil;
 import com.product.core.entity.DataTableEntity;
 import com.product.core.entity.FieldSetEntity;
 import com.product.core.exception.BaseException;
@@ -12,6 +14,7 @@
 import com.product.face.config.ErrorCode;
 import com.product.face.config.FaceConst;
 import com.product.face.entity.TableColumn;
+import com.product.face.util.FaceUtil;
 import com.product.util.BaseUtil;
 import org.springframework.stereotype.Service;
 
@@ -19,7 +22,6 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.stream.Collectors;
 
 /**
  * @Author cheng
@@ -33,8 +35,7 @@
 	private SystemFaceService systemFaceService;
 
 	@Resource
-	private FaceDesignService designService;
-
+	private FaceCacheService faceCacheService;
 
 	public Object getFaceListConf(FieldSetEntity fse) {
 		String faceUuid = fse.getString(FaceConst.FIELD_FACE_UUID);
@@ -46,41 +47,13 @@
 		if (!StringUtils.isEmpty(faceUuid) && StringUtils.isEmpty(faceNumber)) {
 			return systemFaceService.getFaceFieldList(faceUuid);
 		}
-		//鏍规嵁琛ㄥ崟鍙锋煡璇�
-		FieldSetEntity faceConf = getBaseDao().getFieldSetByFilter(FaceConst.TABLE_FACE_CONFIG, "face_number=?", new Object[]{faceNumber}, true);
-		DataTableEntity fieldPropertyDt = faceConf.getSubDataTable(FaceConst.TABLE_FACE_FIELD_CONTROL_PROPERTY);
-		if (DataTableEntity.isEmpty(fieldPropertyDt)) {
-			throw new BaseException(ErrorCode.GET_FACE_CONFIG_FAIL);
-		}
-		List<JSONObject> faceControlList = designService.getFaceControlList(fieldPropertyDt);
-		JSONObject jsonObject = faceControlList.get(0);
-		if (jsonObject == null || jsonObject.isEmpty()) {
-			throw new BaseException(ErrorCode.GET_FACE_CONFIG_FAIL);
-		}
-		//琛ㄦ牸鍒�
-		JSONArray tableColumns = jsonObject.getJSONObject(FaceConst.FIELD_PROPERTY_CONFIG).getJSONArray(FaceConst.CHILDREN);
-		if (tableColumns == null || tableColumns.isEmpty()) {
-			throw new BaseException(ErrorCode.GET_FACE_CONFIG_FAIL);
-		}
-		List<TableColumn> result = Lists.newArrayList();
-		for (int i = 0; i < tableColumns.size(); i++) {
-			TableColumn tableColumn = new TableColumn();
-			JSONObject columnJson = tableColumns.getJSONObject(i);
-			String fieldName = columnJson.getString(FaceConst.FIELD_PROPERTY_VMODEL);
-			if (StringUtils.isEmpty(fieldName)) {
-				continue;
-			}
-			JSONObject config = columnJson.getJSONObject(FaceConst.FIELD_PROPERTY_CONFIG);
-			Object setWidth = config.get("setWidth");
-			if (!StringUtils.isEmpty(setWidth)) {
-				tableColumn.setColumnWidth(setWidth + "%");
-			}
-			tableColumn.setField(fieldName);
-			tableColumn.setTitle(config.getString(FaceConst.FIELD_PROPERTY_LABEL));
-			result.add(tableColumn);
+		final String redisKey = FaceConst.FACE_LIST_KEY + ":face-number" + faceNumber;
+		if (RedisUtil.exists(redisKey)) {
+			return RedisUtil.get(redisKey);
 		}
 
-		return result;
+
+		return null;
 	}
 
 	/**
@@ -101,7 +74,7 @@
 		if (DataTableEntity.isEmpty(fieldPropertyDt)) {
 			throw new BaseException(ErrorCode.GET_FACE_CONFIG_FAIL);
 		}
-		List<JSONObject> faceControlList = designService.getFaceControlList(fieldPropertyDt);
+		List<JSONObject> faceControlList = FaceUtil.getFaceControlList(fieldPropertyDt);
 		Map<String, Object> other = new HashMap<>();
 		other.put("drawingList", faceControlList);
 		faceConf.getSubData().clear();
diff --git a/src/main/java/com/product/face/service/FaceCacheService.java b/src/main/java/com/product/face/service/FaceCacheService.java
index 731c05c..edf1ce7 100644
--- a/src/main/java/com/product/face/service/FaceCacheService.java
+++ b/src/main/java/com/product/face/service/FaceCacheService.java
@@ -1,7 +1,23 @@
 package com.product.face.service;
 
+import cn.hutool.core.collection.CollectionUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.google.common.collect.Lists;
+import com.product.common.lang.StringUtils;
+import com.product.core.cache.util.RedisUtil;
+import com.product.core.entity.DataTableEntity;
+import com.product.core.entity.FieldSetEntity;
 import com.product.core.service.support.AbstractBaseService;
+import com.product.face.config.FaceConst;
+import com.product.face.entity.FaceEntity;
+import com.product.face.entity.FaceListEntity;
+import com.product.face.entity.TableColumn;
+import com.product.face.util.FaceUtil;
+import com.product.util.BaseUtil;
 import org.springframework.stereotype.Service;
+
+import java.util.List;
 
 /**
  * @Author cheng
@@ -11,13 +27,162 @@
 @Service
 public class FaceCacheService extends AbstractBaseService {
 
-	public final static String FACE_CACHE_KEY = "system:face:";
-
+	/**
+	 * 鍒锋柊琛ㄥ崟缂撳瓨(core璋冪敤锛�
+	 */
 	public void refreshCache() {
-
+		this.loadingCache(null);
 	}
 
+	/**
+	 * 鍒锋柊琛ㄥ崟缂撳瓨(core璋冪敤锛�
+	 *
+	 * @param uuid
+	 */
 	public void refreshCache(String uuid) {
-
+		this.loadingCache(uuid);
 	}
+
+	/**
+	 * 绯荤粺鍔犺浇琛ㄥ崟缂撳瓨
+	 *
+	 * @param uuid
+	 */
+	private void loadingCache(String uuid) {
+		String filter = BaseUtil.ifNotNull(uuid, (val) -> "uuid=?");
+		Object[] objects = null;
+		if (!StringUtils.isEmpty(uuid)) {
+			objects = new Object[]{uuid};
+		}
+		DataTableEntity dt = getBaseDao().listTable(FaceConst.TABLE_FACE_CONFIG, filter, objects);
+		if (!DataTableEntity.isEmpty(dt)) {
+			return;
+		}
+		for (FieldSetEntity fs : dt.getData()) {
+			String faceType = fs.getString(FaceConst.FIELD_FACE_TYPE);
+			if (StringUtils.isEmpty(faceType)) {
+				continue;
+			}
+			String faceNumber = fs.getString(FaceConst.FIELD_FACE_NUMBER);
+			if (StringUtils.isEmpty(faceNumber)) {
+				continue;
+			}
+			if ("2".equals(faceType)) {
+				//琛ㄥ崟
+				loadingFormCache(fs);
+			} else if ("1".equals(faceType)) {
+				//鍒楄〃
+				loadingListCache(fs);
+			}
+		}
+	}
+
+	/**
+	 * 鑾峰彇鍒楄〃缂撳瓨
+	 *
+	 * @param faceNumber
+	 * @return
+	 */
+	public FaceListEntity getFaceListCache(String faceNumber) {
+		if (StringUtils.isEmpty(faceNumber)) {
+			return null;
+		}
+		final String faceListKey = FaceConst.FACE_LIST_KEY + ":face-number" + faceNumber;
+		return (FaceListEntity) RedisUtil.get(faceListKey);
+	}
+
+	/**
+	 * 鑾峰彇琛ㄥ崟缂撳瓨
+	 *
+	 * @param faceNumber
+	 * @return
+	 */
+	public FaceEntity getFaceFormCache(String faceNumber) {
+		if (StringUtils.isEmpty(faceNumber)) {
+			return null;
+		}
+		final String faceFormKey = FaceConst.FACE_FORM_CACHE_KEY + ":face-number" + faceNumber;
+		return (FaceEntity) RedisUtil.get(faceFormKey);
+	}
+
+	/**
+	 * 鍔犺浇琛ㄥ崟缂撳瓨
+	 *
+	 * @param fse
+	 */
+	public void loadingFormCache(FieldSetEntity fse) {
+		DataTableEntity fieldPropertyDt = fse.getSubDataTable(FaceConst.TABLE_FACE_FIELD_CONTROL_PROPERTY);
+		if (DataTableEntity.isEmpty(fieldPropertyDt)) {
+			return;
+		}
+		fse.getSubData().clear();
+		String faceNumber = fse.getString(FaceConst.FIELD_FACE_NUMBER);
+		List<JSONObject> faceControlList = FaceUtil.getFaceControlList(fieldPropertyDt);
+		if (faceControlList != null) {
+			FaceEntity face = new FaceEntity();
+			face.setData(BaseUtil.fieldSetEntityToJson(fse));
+			face.setDrawingList(faceControlList);
+			RedisUtil.set(FaceConst.FACE_FORM_CACHE_KEY + faceNumber, face);
+		}
+	}
+
+	/**
+	 * 鍔犺浇鍒楄〃缂撳瓨
+	 *
+	 * @param fse
+	 */
+	public void loadingListCache(FieldSetEntity fse) {
+		DataTableEntity fieldPropertyDt = fse.getSubDataTable(FaceConst.TABLE_FACE_FIELD_CONTROL_PROPERTY);
+		if (DataTableEntity.isEmpty(fieldPropertyDt)) {
+			return;
+		}
+		List<JSONObject> faceControlList = FaceUtil.getFaceControlList(fieldPropertyDt);
+		JSONObject jsonObject = faceControlList.get(0);
+		if (jsonObject == null || jsonObject.isEmpty()) {
+			return;
+		}
+		//琛ㄦ牸鍒�
+		JSONArray tableColumns = jsonObject.getJSONObject(FaceConst.FIELD_PROPERTY_CONFIG).getJSONArray(FaceConst.CHILDREN);
+		if (tableColumns == null || tableColumns.isEmpty()) {
+			return;
+		}
+		String faceNumber = fse.getString(FaceConst.FIELD_FACE_NUMBER);
+		String tableUuid = fse.getString(FaceConst.FIELD_TABLE_UUID);
+		List<TableColumn> result = Lists.newArrayList();
+		FaceListEntity faceListEntity = new FaceListEntity();
+		faceListEntity.setFaceName(faceNumber);
+		faceListEntity.setTableUuid(tableUuid);
+		faceListEntity.setUuid(fse.getUUID());
+		for (int i = 0; i < tableColumns.size(); i++) {
+			TableColumn tableColumn = new TableColumn();
+			JSONObject columnJson = tableColumns.getJSONObject(i);
+			String fieldName = columnJson.getString(FaceConst.FIELD_PROPERTY_VMODEL);
+			if (StringUtils.isEmpty(fieldName)) {
+				continue;
+			}
+
+
+			JSONObject config = columnJson.getJSONObject(FaceConst.FIELD_PROPERTY_CONFIG);
+
+			Object setWidth = config.get("setWidth");
+			if (!StringUtils.isEmpty(setWidth)) {
+				tableColumn.setColumnWidth(setWidth + "%");
+			}
+			FieldSetEntity fieldInfo = BaseUtil.getSingleInfoByCache("琛ㄥ瓧娈典俊鎭�", new String[]{tableUuid, fieldName});
+			String label = config.getString(FaceConst.FIELD_PROPERTY_LABEL);
+			if (!FieldSetEntity.isEmpty(fieldInfo)) {
+				String fieldUuid = fieldInfo.getString(FaceConst.UUID);
+				String fieldReference = fieldInfo.getString(FaceConst.FIELD_FIELD_REFERENCE);
+				faceListEntity.addField(fieldName, fieldUuid, label, tableColumn.getColumnWidth(), i, fieldReference);
+			}
+			tableColumn.setField(fieldName);
+			tableColumn.setTitle(config.getString(FaceConst.FIELD_PROPERTY_LABEL));
+			result.add(tableColumn);
+		}
+		//楠岃瘉琛ㄥ崟涓殑瀛楁鏄惁瀛樺湪
+		if (faceListEntity != null && !CollectionUtil.isEmpty(faceListEntity.getFaceFields())) {
+			RedisUtil.set(FaceConst.FACE_LIST_KEY + ":face-number" + faceNumber, faceListEntity);
+		}
+	}
+
 }
diff --git a/src/main/java/com/product/face/service/FaceDesignService.java b/src/main/java/com/product/face/service/FaceDesignService.java
index ba68ba1..9eb1d40 100644
--- a/src/main/java/com/product/face/service/FaceDesignService.java
+++ b/src/main/java/com/product/face/service/FaceDesignService.java
@@ -1,13 +1,9 @@
 package com.product.face.service;
 
-import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.ArrayUtil;
 import cn.hutool.core.util.IdUtil;
-import cn.hutool.core.util.NumberUtil;
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.drew.metadata.Face;
 import com.product.admin.service.PublicService;
 import com.product.common.lang.StringUtils;
 import com.product.core.config.CoreConst;
@@ -16,18 +12,15 @@
 import com.product.core.exception.BaseException;
 import com.product.core.service.support.AbstractBaseService;
 import com.product.core.transfer.Transactional;
-import com.product.core.util.JsonUtil;
 import com.product.face.config.ErrorCode;
 import com.product.face.config.FaceConst;
 import com.product.face.service.ide.IFaceDesignService;
+import com.product.face.util.FaceUtil;
 import com.product.util.BaseUtil;
-import org.apache.logging.log4j.core.Core;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.io.File;
 import java.util.*;
-import java.util.stream.Collectors;
 
 /**
  * @Author cheng
@@ -55,112 +48,11 @@
 		if (DataTableEntity.isEmpty(fieldPropertyDt)) {
 			throw new BaseException(ErrorCode.GET_FACE_CONFIG_FAIL);
 		}
-		List<JSONObject> result = getFaceControlList(fieldPropertyDt);
+		List<JSONObject> result = FaceUtil.getFaceControlList(fieldPropertyDt);
 		Map<String, Object> other = new HashMap<>();
 		other.put("drawingList", result);
 		fse.getSubData().clear();
 		return BaseUtil.success(fse, other);
-	}
-
-	public List<JSONObject> getFaceControlList(DataTableEntity faceControlDt) {
-		List<JSONObject> result = new ArrayList<>();
-		List<FieldSetEntity> data = faceControlDt.getData();
-		Map<String, List<FieldSetEntity>> collect = data.stream()
-				.filter(item -> StringUtils.isEmpty(item.getString(FaceConst.FIELD_PARENT_UUID))) //杩囨护 鍙栫埗绾�
-//				.sorted(Comparator.comparing(item -> item.getInteger(FaceConst.CONTROL_SEQUENCE))) //鎺掑簭
-				.collect(Collectors.groupingBy(item -> item.getString(FaceConst.FIELD_GROUP_UUID))); //鍒嗙粍
-		Map<String, List<FieldSetEntity>> groupContainer = data.stream()
-				.filter(item -> !StringUtils.isEmpty(item.getString(FaceConst.FIELD_PARENT_UUID))) //杩囨护 鍙栧瓙绾�
-				.collect(Collectors.groupingBy(item -> item.getString(FaceConst.FIELD_PARENT_UUID))); //鍒嗙粍
-		for (Map.Entry<String, List<FieldSetEntity>> entry : collect.entrySet()) {
-			List<FieldSetEntity> propertyList = entry.getValue();
-			result.add(getPropertyJson(propertyList, groupContainer));
-		}
-		result.sort(Comparator.comparing(item -> item.getInteger(FaceConst.CONTROL_SEQUENCE)));
-		return result;
-	}
-
-	private JSONObject getPropertyJson(List<FieldSetEntity> propertyList, Map<String, List<FieldSetEntity>> groupContainer) {
-		JSONObject property = new JSONObject();
-		String propertyValue = null;
-		if (!CollectionUtil.isEmpty(propertyList)) {
-			for (FieldSetEntity fs : propertyList) {
-				//灞炴�х被鍨� 1
-				String groupUuid = fs.getUUID();
-				String propertyType = fs.getString(FaceConst.FIELD_PROPERTY_TYPE);
-				String propertyName = fs.getString(FaceConst.FIELD_PROPERTY_NAME);
-				propertyValue = fs.getString(FaceConst.FIELD_PROPERTY_VALUE);
-				if (StringUtils.equalsAny(propertyName, "renderKey", "formId")) {
-					propertyValue = fs.getString("id");
-				}
-				if ("componentType".equals(propertyName) && "design".equals(propertyValue)) {
-					continue;
-				}
-				if ("layout".equals(propertyName)) {
-					property.put("defaultValue", null);
-				}
-				switch (propertyType) {
-					case "1"://瀛楃涓�
-						property.put(propertyName, propertyValue);
-						break;
-					case "2"://鏁扮粍
-						property.put(propertyName, propertyValue.split(","));
-						break;
-					case "3"://瀛愮骇瀵硅薄
-						try {
-							JSONObject propertyJson = getPropertyJson(groupContainer.get(groupUuid), groupContainer);
-							property.put(propertyName, propertyJson);
-						} catch (Exception e) {
-							e.printStackTrace();
-							throw e;
-						}
-						break;
-					case "4"://瀛愮骇鏁扮粍瀵硅薄
-						List<FieldSetEntity> propertyListChild = groupContainer.get(groupUuid);
-						if (propertyListChild != null && !propertyListChild.isEmpty()) {
-							List<Object> array = propertyListChild.stream()
-									.collect(Collectors.groupingBy(item -> item.getString(FaceConst.FIELD_GROUP_UUID)))
-									.values().stream().map(item -> getPropertyJson(item, groupContainer)).sorted(Comparator.comparing(item -> item.getInteger(FaceConst.CONTROL_SEQUENCE))).collect(Collectors.toList());
-							property.put(propertyName, new JSONArray(array));
-						}
-
-//					groupContainer.put(groupUuid, array);
-						break;
-					case "5": //boolean 绫诲瀷
-						Boolean value = null;
-						if ("1".equals(propertyValue)) {
-							value = true;
-						} else if ("0".equals(propertyValue)) {
-							value = false;
-						}
-						property.put(propertyName, value);
-						break;
-					case "6":// int 绫诲瀷
-						if (NumberUtil.isNumber(propertyValue)) {
-							property.put(propertyName, NumberUtil.parseInt(propertyValue));
-						}
-						break;
-					case "7"://double 绫诲瀷
-						if (NumberUtil.isDouble(propertyValue)) {
-							property.put(propertyName, NumberUtil.parseDouble(propertyValue));
-						}
-						break;
-				}
-			}
-		}
-
-		if (!StringUtils.isEmpty(propertyValue)) {
-			Object o = groupContainer.get(propertyValue);
-			if (o != null) {
-				if (o instanceof JSONArray) {
-					((JSONArray) o).add(property);
-				} else {
-					((JSONObject) o).putAll(property);
-					groupContainer.remove(propertyValue);
-				}
-			}
-		}
-		return property;
 	}
 
 
diff --git a/src/main/java/com/product/face/service/FaceListSearchService.java b/src/main/java/com/product/face/service/FaceListSearchService.java
new file mode 100644
index 0000000..de1d08e
--- /dev/null
+++ b/src/main/java/com/product/face/service/FaceListSearchService.java
@@ -0,0 +1,59 @@
+package com.product.face.service;
+
+import com.product.common.lang.StringUtils;
+import com.product.core.cache.util.RedisUtil;
+import com.product.core.exception.BaseException;
+import com.product.core.service.support.AbstractBaseService;
+import com.product.face.config.FaceConst;
+import com.product.face.entity.FaceListEntity;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Author cheng
+ * @Date 2023/5/23 17:41
+ * @Desc 琛ㄥ崟鍒楄〃鎼滅储
+ */
+@Component
+public class FaceListSearchService extends AbstractBaseService {
+
+	public String getFaceListSearchFilter(Map<String, List<String>> aliasTable, Map<String, List<String>> aliasField, String faceUuid, String faceNumber, String val) throws BaseException {
+		if (StringUtils.isEmpty(val)) {
+			return "";
+		}
+		FaceListEntity face = null;
+		if (!StringUtils.isEmpty(faceNumber)) {
+			face = (FaceListEntity) RedisUtil.get(FaceConst.FACE_LIST_KEY + ":face-number" + faceNumber);
+		} else if (!StringUtils.isEmpty(faceUuid)){
+			face = (FaceListEntity) RedisUtil.get(FaceConst.FACE_LIST_KEY + faceUuid);
+		}
+		if (face != null) {
+			String tableAlias = null;
+			String tableName = face.getTableName();
+			List<String> t = aliasTable.get(tableName);
+			if (t != null && t.size() > 0) {
+				tableAlias = t.get(0);
+			}
+			Map<String, List<String>> params = face.getFilters(tableAlias, aliasField);
+			List<String> fieldNames = params.get("fields");
+			List<String> filters = params.get("filter");
+			String filter = "";
+			for (int i = 0; i < fieldNames.size(); i++) {
+				if (i > 0) {
+					filter += " or ";
+				}
+				filter += " " + fieldNames.get(i) + " LIKE BINARY concat('%','" + val + "','%')";
+			}
+			for (int i = 0; i < filters.size(); i++) {
+				if (!"".equals(filter)) {
+					filter += " or ";
+				}
+				filter += filters.get(i).replace("~val~", val);
+			}
+			return "".equals(filter) ? "" : "( " + filter + " )";
+		}
+		return "";
+	}
+}
diff --git a/src/main/java/com/product/face/util/FaceUtil.java b/src/main/java/com/product/face/util/FaceUtil.java
new file mode 100644
index 0000000..8dafdd4
--- /dev/null
+++ b/src/main/java/com/product/face/util/FaceUtil.java
@@ -0,0 +1,128 @@
+package com.product.face.util;
+
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.NumberUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.product.common.lang.StringUtils;
+import com.product.core.entity.DataTableEntity;
+import com.product.core.entity.FieldSetEntity;
+import com.product.face.config.FaceConst;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @Author cheng
+ * @Date 2023/5/24 10:42
+ * @Desc
+ */
+public class FaceUtil {
+
+
+	public static List<JSONObject> getFaceControlList(DataTableEntity faceControlDt) {
+		List<JSONObject> result = new ArrayList<>();
+		List<FieldSetEntity> data = faceControlDt.getData();
+		Map<String, List<FieldSetEntity>> collect = data.stream()
+				.filter(item -> StringUtils.isEmpty(item.getString(FaceConst.FIELD_PARENT_UUID))) //杩囨护 鍙栫埗绾�
+//				.sorted(Comparator.comparing(item -> item.getInteger(FaceConst.CONTROL_SEQUENCE))) //鎺掑簭
+				.collect(Collectors.groupingBy(item -> item.getString(FaceConst.FIELD_GROUP_UUID))); //鍒嗙粍
+		Map<String, List<FieldSetEntity>> groupContainer = data.stream()
+				.filter(item -> !StringUtils.isEmpty(item.getString(FaceConst.FIELD_PARENT_UUID))) //杩囨护 鍙栧瓙绾�
+				.collect(Collectors.groupingBy(item -> item.getString(FaceConst.FIELD_PARENT_UUID))); //鍒嗙粍
+		for (Map.Entry<String, List<FieldSetEntity>> entry : collect.entrySet()) {
+			List<FieldSetEntity> propertyList = entry.getValue();
+			result.add(getPropertyJson(propertyList, groupContainer));
+		}
+		result.sort(Comparator.comparing(item -> item.getInteger(FaceConst.CONTROL_SEQUENCE)));
+		return result;
+	}
+
+	private static JSONObject getPropertyJson(List<FieldSetEntity> propertyList, Map<String, List<FieldSetEntity>> groupContainer) {
+		JSONObject property = new JSONObject();
+		String propertyValue = null;
+		if (!CollectionUtil.isEmpty(propertyList)) {
+			for (FieldSetEntity fs : propertyList) {
+				//灞炴�х被鍨� 1
+				String groupUuid = fs.getUUID();
+				String propertyType = fs.getString(FaceConst.FIELD_PROPERTY_TYPE);
+				String propertyName = fs.getString(FaceConst.FIELD_PROPERTY_NAME);
+				propertyValue = fs.getString(FaceConst.FIELD_PROPERTY_VALUE);
+				if (StringUtils.equalsAny(propertyName, "renderKey", "formId")) {
+					propertyValue = fs.getString("id");
+				}
+				if ("componentType".equals(propertyName) && "design".equals(propertyValue)) {
+					continue;
+				}
+				if ("layout".equals(propertyName)) {
+					property.put("defaultValue", null);
+				}
+				switch (propertyType) {
+					case "1"://瀛楃涓�
+						property.put(propertyName, propertyValue);
+						break;
+					case "2"://鏁扮粍
+						property.put(propertyName, propertyValue.split(","));
+						break;
+					case "3"://瀛愮骇瀵硅薄
+						try {
+							JSONObject propertyJson = getPropertyJson(groupContainer.get(groupUuid), groupContainer);
+							property.put(propertyName, propertyJson);
+						} catch (Exception e) {
+							e.printStackTrace();
+							throw e;
+						}
+						break;
+					case "4"://瀛愮骇鏁扮粍瀵硅薄
+						List<FieldSetEntity> propertyListChild = groupContainer.get(groupUuid);
+						if (propertyListChild != null && !propertyListChild.isEmpty()) {
+							List<Object> array = propertyListChild.stream()
+									.collect(Collectors.groupingBy(item -> item.getString(FaceConst.FIELD_GROUP_UUID)))
+									.values().stream().map(item -> getPropertyJson(item, groupContainer)).sorted(Comparator.comparing(item -> item.getInteger(FaceConst.CONTROL_SEQUENCE))).collect(Collectors.toList());
+							property.put(propertyName, new JSONArray(array));
+						}
+
+//					groupContainer.put(groupUuid, array);
+						break;
+					case "5": //boolean 绫诲瀷
+						Boolean value = null;
+						if ("1".equals(propertyValue)) {
+							value = true;
+						} else if ("0".equals(propertyValue)) {
+							value = false;
+						}
+						property.put(propertyName, value);
+						break;
+					case "6":// int 绫诲瀷
+						if (NumberUtil.isNumber(propertyValue)) {
+							property.put(propertyName, NumberUtil.parseInt(propertyValue));
+						}
+						break;
+					case "7"://double 绫诲瀷
+						if (NumberUtil.isDouble(propertyValue)) {
+							property.put(propertyName, NumberUtil.parseDouble(propertyValue));
+						}
+						break;
+				}
+			}
+		}
+
+		if (!StringUtils.isEmpty(propertyValue)) {
+			Object o = groupContainer.get(propertyValue);
+			if (o != null) {
+				if (o instanceof JSONArray) {
+					((JSONArray) o).add(property);
+				} else {
+					((JSONObject) o).putAll(property);
+					groupContainer.remove(propertyValue);
+				}
+			}
+		}
+		return property;
+	}
+
+
+}

--
Gitblit v1.9.2