From f367ca7772c3cad36a6f2aed5c4b278451fb4e7b Mon Sep 17 00:00:00 2001
From: cheng <1821349743@qq.com>
Date: 星期六, 13 五月 2023 17:03:04 +0800
Subject: [PATCH] 表单建模列表左侧树接口、删除接口
---
src/main/java/com/product/face/config/FaceConst.java | 4
src/main/java/com/product/face/service/FaceDesignService.java | 487 +++++++++++++++++++------------------
src/main/java/com/product/face/service/ide/IFaceDesignService.java | 41 +-
src/main/java/com/product/face/config/ErrorCode.java | 44 +-
src/main/java/com/product/face/controller/FaceDesignController.java | 162 ++++++++----
5 files changed, 414 insertions(+), 324 deletions(-)
diff --git a/src/main/java/com/product/face/config/ErrorCode.java b/src/main/java/com/product/face/config/ErrorCode.java
index b145308..f8c5676 100644
--- a/src/main/java/com/product/face/config/ErrorCode.java
+++ b/src/main/java/com/product/face/config/ErrorCode.java
@@ -14,32 +14,34 @@
*/
public enum ErrorCode implements IEnum {
- SAVE_FACE_FAIL("淇濆瓨琛ㄥ崟鍐呭澶辫触", 1),
- SAVE_EMPTY_FACE_FAIL("淇濆瓨琛ㄥ崟鍐呭澶辫触,琛ㄥ崟鍐呭涓嶈兘涓虹┖", 2),
+ SAVE_FACE_FAIL("淇濆瓨琛ㄥ崟鍐呭澶辫触", 1),
+ SAVE_EMPTY_FACE_FAIL("淇濆瓨琛ㄥ崟鍐呭澶辫触,琛ㄥ崟鍐呭涓嶈兘涓虹┖", 2),
- ;
+ DELETE_FACE_FAIL("鍒犻櫎琛ㄥ崟澶辫触", 3),
+
+ ;
- private String text;
- private int value;
+ private String text;
+ private int value;
- ErrorCode(String text, int value) {
- this.value = value;
- this.text = text;
- }
+ ErrorCode(String text, int value) {
+ this.value = value;
+ this.text = text;
+ }
- @Override
- public String getText() {
- return this.text;
- }
+ @Override
+ public String getText() {
+ return this.text;
+ }
- @Override
- public String getValue() {
- Format f1 = new DecimalFormat("000");
- return ModuleEnum.PRINT.getValue() + f1.format(this.value);
- }
+ @Override
+ public String getValue() {
+ Format f1 = new DecimalFormat("000");
+ return ModuleEnum.PRINT.getValue() + f1.format(this.value);
+ }
- public void throwException() {
- throw new BaseException(this);
- }
+ public void throwException() {
+ throw new BaseException(this);
+ }
}
diff --git a/src/main/java/com/product/face/config/FaceConst.java b/src/main/java/com/product/face/config/FaceConst.java
index 4d9b83b..ba88a9f 100644
--- a/src/main/java/com/product/face/config/FaceConst.java
+++ b/src/main/java/com/product/face/config/FaceConst.java
@@ -1,11 +1,13 @@
package com.product.face.config;
+import com.product.core.config.CoreConst;
+
/**
* @Author cheng
* @Date 2023/4/21 17:43
* @Desc 甯搁噺绫�
*/
-public class FaceConst {
+public class FaceConst extends CoreConst {
//瀛楁key
public static final String FACE_FIELD = "fields";
//琛ㄥ崟涓昏〃
diff --git a/src/main/java/com/product/face/controller/FaceDesignController.java b/src/main/java/com/product/face/controller/FaceDesignController.java
index 7280441..42829f9 100644
--- a/src/main/java/com/product/face/controller/FaceDesignController.java
+++ b/src/main/java/com/product/face/controller/FaceDesignController.java
@@ -1,5 +1,9 @@
package com.product.face.controller;
+import com.drew.metadata.Face;
+import com.product.core.cache.DataPoolCacheImpl;
+import com.product.core.config.CoreConst;
+import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldSetEntity;
import com.product.core.exception.BaseException;
import com.product.core.spring.context.SpringMVCContextHolder;
@@ -16,6 +20,7 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
+import java.util.*;
/**
* @Author cheng
@@ -26,61 +31,114 @@
@RequestMapping("/api/face-design")
public class FaceDesignController extends AbstractBaseController {
- @Resource
- private IFaceDesignService faceDesignService;
+ @Resource
+ private IFaceDesignService faceDesignService;
- /**
- * 鏌ヨ琛ㄥ崟璁捐鏁版嵁璇︽儏
- *
- * @param request
- * @return
- */
- @PostMapping("/find-face-config/{version}")
- @ApiVersion(1)
- public String findFaceConfig(HttpServletRequest request) {
- try {
- FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, FaceConst.TABLE_FACE_CONFIG);
- String uuid = fse.getUUID();
- return faceDesignService.getFaceConfigInfo(uuid);
- } catch (BaseException e) {
- e.printStackTrace();
- return error(e);
- } catch (Exception e) {
- e.printStackTrace();
- return error(ErrorCode.SAVE_FACE_FAIL, e);
- }
- }
+ /**
+ * 琛ㄥ崟鍒楄〃宸︿晶鏍�
+ *
+ * @return
+ */
+ @PostMapping("/tree-face/{version}")
+ @ApiVersion(1)
+ public String faceListTree() {
+ DataTableEntity tableInfoData = DataPoolCacheImpl.getInstance().getCacheData("鎵�鏈夎〃淇℃伅");
+ List<Map<String, Object>> resultList = new ArrayList<>();
+ if (!DataTableEntity.isEmpty(tableInfoData)) {
+ for (int i = 0; i < tableInfoData.getRows(); i++) {
+ FieldSetEntity fse = tableInfoData.getFieldSetEntity(i);
+ Map<String, Object> record = new HashMap<>();
+ String tableName = fse.getString(FaceConst.FIELD_TABLE_NAME);
+ String value = fse.getString(FaceConst.UUID);
+ String tableType = fse.getString(FaceConst.FIELD_TABLE_TYPE);
+ String tableDescription = fse.getString("table_description");
+ record.put("value", value);
+ record.put(FaceConst.FIELD_TABLE_NAME, tableName);
+ record.put(FaceConst.FIELD_TABLE_TYPE, tableType);
+ record.put("table_description", tableDescription);
+ resultList.add(record);
+ }
+ resultList.sort(Comparator.comparing(o -> o.get(FaceConst.FIELD_TABLE_TYPE).toString()));
+ }
+ return success(resultList);
+ }
- /**
- * 淇濆瓨琛ㄥ崟璁捐鏁版嵁
- *
- * @param request
- * @return
- */
- @PostMapping("/save-face/{version}")
- @ApiVersion(1)
- public String saveFaceData(HttpServletRequest request) {
- try {
- FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, FaceConst.TABLE_FACE_CONFIG);
- IFaceDesignService proxy = getProxy();
- return OK_List(proxy.saveFaceData(fse));
- } catch (BaseException e) {
- e.printStackTrace();
- return error(e);
- } catch (Exception e) {
- e.printStackTrace();
- return error(ErrorCode.SAVE_FACE_FAIL, e);
- }
- }
- /**
- * 鑾峰彇浜嬪姟浠g悊
- *
- * @return
- */
- private IFaceDesignService getProxy() {
- return (IFaceDesignService) getProxyInstance(faceDesignService);
- }
+ /**
+ * 鏌ヨ琛ㄥ崟璁捐鏁版嵁璇︽儏
+ *
+ * @param request
+ * @return
+ */
+ @PostMapping("/find-face-config/{version}")
+ @ApiVersion(1)
+ public String findFaceConfig(HttpServletRequest request) {
+ try {
+ FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, FaceConst.TABLE_FACE_CONFIG);
+ String uuid = fse.getUUID();
+ return faceDesignService.getFaceConfigInfo(uuid);
+ } catch (BaseException e) {
+ e.printStackTrace();
+ return error(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return error(ErrorCode.SAVE_FACE_FAIL, e);
+ }
+ }
+
+ /**
+ * 淇濆瓨琛ㄥ崟璁捐鏁版嵁
+ *
+ * @param request
+ * @return
+ */
+ @PostMapping("/save-face/{version}")
+ @ApiVersion(1)
+ public String saveFaceData(HttpServletRequest request) {
+ try {
+ FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, FaceConst.TABLE_FACE_CONFIG);
+ IFaceDesignService proxy = getProxy();
+ return OK_List(proxy.saveFaceData(fse));
+ } catch (BaseException e) {
+ e.printStackTrace();
+ return error(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return error(ErrorCode.SAVE_FACE_FAIL, e);
+ }
+ }
+
+ /**
+ * 鍒犻櫎琛ㄥ崟璁捐
+ *
+ * @param request
+ * @return
+ */
+ @PostMapping("/delete-face/{version}")
+ @ApiVersion(1)
+ public String deleteFace(HttpServletRequest request) {
+ try {
+ FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, FaceConst.TABLE_FACE_CONFIG);
+ IFaceDesignService proxy = getProxy();
+ proxy.deleteFace(fse);
+ return OK();
+ } catch (BaseException e) {
+ e.printStackTrace();
+ return error(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return error(ErrorCode.DELETE_FACE_FAIL, e);
+ }
+ }
+
+ /**
+ * 鑾峰彇浜嬪姟浠g悊
+ *
+ * @return
+ */
+ private IFaceDesignService getProxy() {
+ return (IFaceDesignService) getProxyInstance(faceDesignService);
+ }
}
diff --git a/src/main/java/com/product/face/service/FaceDesignService.java b/src/main/java/com/product/face/service/FaceDesignService.java
index 0e3f15f..ba3e436 100644
--- a/src/main/java/com/product/face/service/FaceDesignService.java
+++ b/src/main/java/com/product/face/service/FaceDesignService.java
@@ -8,6 +8,7 @@
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;
import com.product.core.entity.DataTableEntity;
@@ -23,6 +24,7 @@
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;
@@ -36,249 +38,266 @@
public class FaceDesignService extends AbstractBaseService implements IFaceDesignService {
- /**
- * 鑾峰彇琛ㄥ崟閰嶇疆璇︽儏
- *
- * @param uuid
- * @return
- * @throws BaseException
- */
- @Override
- public String getFaceConfigInfo(String uuid) throws BaseException {
- FieldSetEntity fse = getBaseDao().getFieldSetEntity(FaceConst.TABLE_FACE_CONFIG, uuid, true);
- DataTableEntity fieldPropertyDt = fse.getSubDataTable(FaceConst.TABLE_FACE_FIELD_CONTROL_PROPERTY);
- if (DataTableEntity.isEmpty(fieldPropertyDt)) {
- return null;
- }
- List<JSONObject> result = new ArrayList<>();
- List<FieldSetEntity> data = fieldPropertyDt.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)));
- System.out.println(result);
- Map<String, Object> other = new HashMap<>();
- other.put("drawingList", result);
- fse.getSubData().clear();
- return BaseUtil.success(fse, other);
- }
+ @Resource
+ private PublicService publicService;
- 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);
- 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));
- }
+ /**
+ * 鑾峰彇琛ㄥ崟閰嶇疆璇︽儏
+ *
+ * @param uuid
+ * @return
+ * @throws BaseException
+ */
+ @Override
+ public String getFaceConfigInfo(String uuid) throws BaseException {
+ FieldSetEntity fse = getBaseDao().getFieldSetEntity(FaceConst.TABLE_FACE_CONFIG, uuid, true);
+ DataTableEntity fieldPropertyDt = fse.getSubDataTable(FaceConst.TABLE_FACE_FIELD_CONTROL_PROPERTY);
+ if (DataTableEntity.isEmpty(fieldPropertyDt)) {
+ return null;
+ }
+ List<JSONObject> result = new ArrayList<>();
+ List<FieldSetEntity> data = fieldPropertyDt.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)));
+ System.out.println(result);
+ Map<String, Object> other = new HashMap<>();
+ other.put("drawingList", result);
+ fse.getSubData().clear();
+ return BaseUtil.success(fse, other);
+ }
+
+ 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);
+ 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;
- }
- }
- }
+ 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;
- }
+ 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;
+ }
- /**
- * 淇濆瓨琛ㄥ崟鍐呭鏁版嵁
- *
- * @param fse
- * @return
- * @throws BaseException
- */
- @Override
- @Transactional
- public FieldSetEntity saveFaceData(FieldSetEntity fse) throws BaseException {
- DataTableEntity fields = fse.getSubDataTable(FaceConst.FACE_FIELD);
- if (DataTableEntity.isEmpty(fields)) {
- ErrorCode.SAVE_EMPTY_FACE_FAIL.throwException();
- }
- List<FieldSetEntity> fieldSetEntityList = new ArrayList<>();
- for (int i = 0; i < fields.getRows(); i++) {
- fieldSetEntityList.addAll(controlTraverse(new JSONObject((Map) fields.getFieldSetEntity(i).getValues()), null, i));
- }
- fse.removeSubData(FaceConst.FACE_FIELD);
- BaseUtil.createCreatorAndCreationTime(fse);
- fields.setData(fieldSetEntityList);
- fse.addSubDataTable(fields);
- fse.setValue(FaceConst.FIELD_FACE_TYPE, 2);
- if (!StringUtils.isEmpty(fse.getUUID())) {
- getBaseDao().delete(FaceConst.TABLE_FACE_FIELD_CONTROL_PROPERTY, "master_uuid=?", new Object[]{fse.getUUID()});
- }
- getBaseDao().saveFieldSetEntity(fse);
- fse.getSubData().clear();
- return fse;
- }
+ /**
+ * 淇濆瓨琛ㄥ崟鍐呭鏁版嵁
+ *
+ * @param fse
+ * @return
+ * @throws BaseException
+ */
+ @Override
+ @Transactional
+ public FieldSetEntity saveFaceData(FieldSetEntity fse) throws BaseException {
+ DataTableEntity fields = fse.getSubDataTable(FaceConst.FACE_FIELD);
+ if (DataTableEntity.isEmpty(fields)) {
+ ErrorCode.SAVE_EMPTY_FACE_FAIL.throwException();
+ }
+ List<FieldSetEntity> fieldSetEntityList = new ArrayList<>();
+ for (int i = 0; i < fields.getRows(); i++) {
+ fieldSetEntityList.addAll(controlTraverse(new JSONObject((Map) fields.getFieldSetEntity(i).getValues()), null, i));
+ }
+ fse.removeSubData(FaceConst.FACE_FIELD);
+ BaseUtil.createCreatorAndCreationTime(fse);
+ fields.setData(fieldSetEntityList);
+ fse.addSubDataTable(fields);
+ fse.setValue(FaceConst.FIELD_FACE_TYPE, 2);
+ if (!StringUtils.isEmpty(fse.getUUID())) {
+ getBaseDao().delete(FaceConst.TABLE_FACE_FIELD_CONTROL_PROPERTY, "master_uuid=?", new Object[]{fse.getUUID()});
+ }
+ getBaseDao().saveFieldSetEntity(fse);
+ fse.getSubData().clear();
+ return fse;
+ }
- public List<FieldSetEntity> controlTraverse(Object o, String parentUuid, Integer sequence) {
- List<FieldSetEntity> fieldSetList = new ArrayList<>();
- try {
- if (o instanceof JSONArray) {
- //鏁扮粍
- JSONArray jsonArray = (JSONArray) o;
- try {
- for (int i = 0; i < jsonArray.size(); i++) {
- Object obj = jsonArray.get(i);
- fieldSetList.addAll(controlTraverse(obj, parentUuid, i));
- }
- } catch (Exception e) {
- e.printStackTrace();
- throw e;
- }
- } else {
- //json瀵硅薄
- JSONObject property = (JSONObject) o;
- String groupUuid = IdUtil.randomUUID();
- for (Map.Entry<String, Object> entry : property.entrySet()) {
+ public List<FieldSetEntity> controlTraverse(Object o, String parentUuid, Integer sequence) {
+ List<FieldSetEntity> fieldSetList = new ArrayList<>();
+ try {
+ if (o instanceof JSONArray) {
+ //鏁扮粍
+ JSONArray jsonArray = (JSONArray) o;
+ try {
+ for (int i = 0; i < jsonArray.size(); i++) {
+ Object obj = jsonArray.get(i);
+ fieldSetList.addAll(controlTraverse(obj, parentUuid, i));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ } else {
+ //json瀵硅薄
+ JSONObject property = (JSONObject) o;
+ String groupUuid = IdUtil.randomUUID();
+ for (Map.Entry<String, Object> entry : property.entrySet()) {
- FieldSetEntity fs = getTemplateFieldSet(entry.getKey(), entry.getValue(), groupUuid);
- if (fs != null) {
- int propertyType = fs.getInteger(FaceConst.FIELD_PROPERTY_TYPE).intValue();
- if ((4 == propertyType || 3 == propertyType) && (entry.getValue() instanceof JSONArray || entry.getValue() instanceof JSONObject)) {
- try {
- fieldSetList.addAll(controlTraverse(entry.getValue(), fs.getUUID(), null));
- fs.remove(FaceConst.FIELD_PROPERTY_VALUE);
- } catch (Exception e) {
- e.printStackTrace();
- throw e;
- }
- }
- fs.setValue(FaceConst.FIELD_PARENT_UUID, parentUuid);
- fieldSetList.add(fs);
- }
- }
- if (sequence != null) {
- FieldSetEntity fs = getTemplateFieldSet(FaceConst.CONTROL_SEQUENCE, sequence, groupUuid);
- fs.setValue(FaceConst.FIELD_PARENT_UUID, parentUuid);
- fieldSetList.add(fs);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- throw e;
- }
- return fieldSetList;
- }
+ FieldSetEntity fs = getTemplateFieldSet(entry.getKey(), entry.getValue(), groupUuid);
+ if (fs != null) {
+ int propertyType = fs.getInteger(FaceConst.FIELD_PROPERTY_TYPE).intValue();
+ if ((4 == propertyType || 3 == propertyType) && (entry.getValue() instanceof JSONArray || entry.getValue() instanceof JSONObject)) {
+ try {
+ fieldSetList.addAll(controlTraverse(entry.getValue(), fs.getUUID(), null));
+ fs.remove(FaceConst.FIELD_PROPERTY_VALUE);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+ fs.setValue(FaceConst.FIELD_PARENT_UUID, parentUuid);
+ fieldSetList.add(fs);
+ }
+ }
+ if (sequence != null) {
+ FieldSetEntity fs = getTemplateFieldSet(FaceConst.CONTROL_SEQUENCE, sequence, groupUuid);
+ fs.setValue(FaceConst.FIELD_PARENT_UUID, parentUuid);
+ fieldSetList.add(fs);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ return fieldSetList;
+ }
- /**
- * 鑾峰彇妯℃澘FieldSet
- *
- * @return
- */
- private FieldSetEntity getTemplateFieldSet(String propertyName, Object propertyValue, String groupUuid) {
- FieldSetEntity fse = new FieldSetEntity(FaceConst.TABLE_FACE_FIELD_CONTROL_PROPERTY);
- //璁剧疆鎿嶄綔绫诲瀷涓烘柊澧�
- fse.setValue(CoreConst.SYSTEM_DATA_OPERATE_TYPE, CoreConst.SYSTEM_DATA_OPERATE_ADD);
- //鎵嬪姩鐢熸垚uuid
- fse.setValue(CoreConst.UUID, IdUtil.randomUUID());
- fse.setValue("last_update_time", new Date());
- fse.setValue(FaceConst.FIELD_PROPERTY_NAME, propertyName);
- fse.setValue(FaceConst.FIELD_GROUP_UUID, groupUuid);
- int properType = 1;
- if (propertyValue instanceof JSONArray) {
- JSONArray array = (JSONArray) propertyValue;
- if (array == null || array.isEmpty()) {
- return null;
- }
- Object object = array.get(0);
- if (!(object instanceof JSONObject)) {
- //鏅�氭暟缁� 杞负瀛楃涓�
- fse.setValue(FaceConst.FIELD_PROPERTY_VALUE, ArrayUtil.join(array.toArray(), ","));//鏈夊瓙绾у璞�
- properType = 2;
- } else {
- //鏈夊瓙绾у璞�
- properType = 4;
- }
- } else if (propertyValue instanceof JSONObject) {
- //灞炴�у�兼槸瀵硅薄
- JSONObject value = (JSONObject) propertyValue;
- if (value == null || value.isEmpty()) {
- return null;
- }
- properType = 3;
- } else {
- if (propertyValue == null || StringUtils.isEmpty(propertyValue)) {
- return null;
- }
+ /**
+ * 鑾峰彇妯℃澘FieldSet
+ *
+ * @return
+ */
+ private FieldSetEntity getTemplateFieldSet(String propertyName, Object propertyValue, String groupUuid) {
+ FieldSetEntity fse = new FieldSetEntity(FaceConst.TABLE_FACE_FIELD_CONTROL_PROPERTY);
+ //璁剧疆鎿嶄綔绫诲瀷涓烘柊澧�
+ fse.setValue(CoreConst.SYSTEM_DATA_OPERATE_TYPE, CoreConst.SYSTEM_DATA_OPERATE_ADD);
+ //鎵嬪姩鐢熸垚uuid
+ fse.setValue(CoreConst.UUID, IdUtil.randomUUID());
+ fse.setValue("last_update_time", new Date());
+ fse.setValue(FaceConst.FIELD_PROPERTY_NAME, propertyName);
+ fse.setValue(FaceConst.FIELD_GROUP_UUID, groupUuid);
+ int properType = 1;
+ if (propertyValue instanceof JSONArray) {
+ JSONArray array = (JSONArray) propertyValue;
+ if (array == null || array.isEmpty()) {
+ return null;
+ }
+ Object object = array.get(0);
+ if (!(object instanceof JSONObject)) {
+ //鏅�氭暟缁� 杞负瀛楃涓�
+ fse.setValue(FaceConst.FIELD_PROPERTY_VALUE, ArrayUtil.join(array.toArray(), ","));//鏈夊瓙绾у璞�
+ properType = 2;
+ } else {
+ //鏈夊瓙绾у璞�
+ properType = 4;
+ }
+ } else if (propertyValue instanceof JSONObject) {
+ //灞炴�у�兼槸瀵硅薄
+ JSONObject value = (JSONObject) propertyValue;
+ if (value == null || value.isEmpty()) {
+ return null;
+ }
+ properType = 3;
+ } else {
+ if (propertyValue == null || StringUtils.isEmpty(propertyValue)) {
+ return null;
+ }
- if (propertyValue instanceof Boolean) {
- properType = 5;
- } else if (propertyValue instanceof Integer) {
- properType = 6;
- } else if (propertyValue instanceof Double) {
- properType = 7;
- }
- fse.setValue(FaceConst.FIELD_PROPERTY_VALUE, propertyValue);
- }
- fse.setValue(FaceConst.FIELD_PROPERTY_TYPE, properType);
- return fse;
- }
+ if (propertyValue instanceof Boolean) {
+ properType = 5;
+ } else if (propertyValue instanceof Integer) {
+ properType = 6;
+ } else if (propertyValue instanceof Double) {
+ properType = 7;
+ }
+ fse.setValue(FaceConst.FIELD_PROPERTY_VALUE, propertyValue);
+ }
+ fse.setValue(FaceConst.FIELD_PROPERTY_TYPE, properType);
+ return fse;
+ }
+
+
+ /**
+ * 鍒犻櫎琛ㄥ崟璁捐
+ *
+ * @param fse
+ * @throws BaseException
+ */
+ @Override
+ @Transactional
+ public void deleteFace(FieldSetEntity fse) throws BaseException {
+ publicService.delete(fse);
+ }
+
}
diff --git a/src/main/java/com/product/face/service/ide/IFaceDesignService.java b/src/main/java/com/product/face/service/ide/IFaceDesignService.java
index 35faae0..33b3a26 100644
--- a/src/main/java/com/product/face/service/ide/IFaceDesignService.java
+++ b/src/main/java/com/product/face/service/ide/IFaceDesignService.java
@@ -1,6 +1,7 @@
package com.product.face.service.ide;
import com.alibaba.fastjson.JSONObject;
+import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldSetEntity;
import com.product.core.exception.BaseException;
@@ -12,21 +13,29 @@
* @Desc 琛ㄥ崟璁捐鎺ュ彛
*/
public interface IFaceDesignService {
- /**
- * 鑾峰彇琛ㄥ崟閰嶇疆璇︽儏
- *
- * @param uuid
- * @return
- * @throws BaseException
- */
- String getFaceConfigInfo(String uuid) throws BaseException;
+ /**
+ * 鑾峰彇琛ㄥ崟閰嶇疆璇︽儏
+ *
+ * @param uuid
+ * @return
+ * @throws BaseException
+ */
+ String getFaceConfigInfo(String uuid) throws BaseException;
- /**
- * 淇濆瓨琛ㄥ崟鍐呭鏁版嵁
- *
- * @param fse
- * @return
- * @throws BaseException
- */
- FieldSetEntity saveFaceData(FieldSetEntity fse) throws BaseException;
+ /**
+ * 淇濆瓨琛ㄥ崟鍐呭鏁版嵁
+ *
+ * @param fse
+ * @return
+ * @throws BaseException
+ */
+ FieldSetEntity saveFaceData(FieldSetEntity fse) throws BaseException;
+
+ /**
+ * 鍒犻櫎琛ㄥ崟璁捐
+ * @param fse
+ * @throws BaseException
+ */
+ void deleteFace(FieldSetEntity fse) throws BaseException;
+
}
--
Gitblit v1.9.2