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/FaceDesignService.java |  112 +-------------------------------------------------------
 1 files changed, 2 insertions(+), 110 deletions(-)

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;
 	}
 
 

--
Gitblit v1.9.2