From 99c693af3da1391d00872f89ebd18fcc85278200 Mon Sep 17 00:00:00 2001 From: 许鹏程 <1821349743@qq.com> Date: 星期一, 17 二月 2025 22:08:37 +0800 Subject: [PATCH] 归档支持自定义文件夹路径(多层级) --- src/main/java/com/product/face/util/FaceUtil.java | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 52 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/product/face/util/FaceUtil.java b/src/main/java/com/product/face/util/FaceUtil.java index 8dafdd4..6ddb6c3 100644 --- a/src/main/java/com/product/face/util/FaceUtil.java +++ b/src/main/java/com/product/face/util/FaceUtil.java @@ -23,7 +23,7 @@ public class FaceUtil { - public static List<JSONObject> getFaceControlList(DataTableEntity faceControlDt) { + public static List<JSONObject> getFaceControlList(FieldSetEntity face, DataTableEntity faceControlDt) { List<JSONObject> result = new ArrayList<>(); List<FieldSetEntity> data = faceControlDt.getData(); Map<String, List<FieldSetEntity>> collect = data.stream() @@ -33,15 +33,39 @@ 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))); //鍒嗙粍 + int maxFormId = 100; for (Map.Entry<String, List<FieldSetEntity>> entry : collect.entrySet()) { List<FieldSetEntity> propertyList = entry.getValue(); - result.add(getPropertyJson(propertyList, groupContainer)); + JSONObject propertyJson = getPropertyJson(propertyList, groupContainer); + Integer o = propertyJson.getInteger("~formId~"); + if (o != null && o > maxFormId) { + maxFormId = o; + } + propertyJson.remove("~formId~"); + Boolean eventProperty = propertyJson.getBoolean("event_property"); + if (eventProperty != null && eventProperty && propertyJson.get("event_array") != null) { + JSONArray eventArray = propertyJson.getJSONArray("event_array"); + for (int i = 0; i < eventArray.size(); i++) { + String params = eventArray.getJSONObject(i).getString("params"); + String[] paramsArray; + if (StringUtils.isEmpty(params)) { + paramsArray = new String[]{}; + } else { + paramsArray = params.split(","); + } + eventArray.getJSONObject(i).put("params", paramsArray); + } + face.setValue("events", eventArray); + continue; + } + result.add(propertyJson); } result.sort(Comparator.comparing(item -> item.getInteger(FaceConst.CONTROL_SEQUENCE))); + face.setValue("maxFormId", maxFormId); return result; } - private static JSONObject getPropertyJson(List<FieldSetEntity> propertyList, Map<String, List<FieldSetEntity>> groupContainer) { + public static JSONObject getPropertyJson(List<FieldSetEntity> propertyList, Map<String, List<FieldSetEntity>> groupContainer) { JSONObject property = new JSONObject(); String propertyValue = null; if (!CollectionUtil.isEmpty(propertyList)) { @@ -58,7 +82,8 @@ continue; } if ("layout".equals(propertyName)) { - property.put("defaultValue", null); + //褰卞搷琛ㄥ崟璁捐鍣ㄨ繕鍘焛nput閰嶇疆鐨勯粯璁ゅ�� 鏆傛椂鍏堟敞閲婃帀 +// property.put("defaultValue", null); } switch (propertyType) { case "1"://瀛楃涓� @@ -71,6 +96,16 @@ try { JSONObject propertyJson = getPropertyJson(groupContainer.get(groupUuid), groupContainer); property.put(propertyName, propertyJson); + if ("__config__".equals(propertyName)) { + String o = propertyJson.getString("formId"); + if (NumberUtil.isNumber(o)) { + Integer formId = property.getInteger("formId"); + if (formId == null || formId < NumberUtil.parseInt(o)) { + property.put("~formId~", NumberUtil.parseInt(o)); + } + } + propertyJson.remove("~formId~"); + } } catch (Exception e) { e.printStackTrace(); throw e; @@ -81,7 +116,19 @@ 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()); + .values().stream().map(item -> { + JSONObject propertyJson = getPropertyJson(item, groupContainer); + String o = propertyJson.getString("~formId~"); + if (NumberUtil.isNumber(o)) { + Integer formId = property.getInteger("formId"); + if (formId == null || formId < NumberUtil.parseInt(o)) { + property.put("~formId~", NumberUtil.parseInt(o)); + } + } + propertyJson.remove("~formId~"); + + return propertyJson; + }).sorted(Comparator.comparing(item -> item.getInteger(FaceConst.CONTROL_SEQUENCE))).collect(Collectors.toList()); property.put(propertyName, new JSONArray(array)); } -- Gitblit v1.9.2