From 2fed1ef270925f724ad69d675bc9a8a91a5128e9 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Thu, 8 May 2025 18:54:43 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF-itsm?= =?UTF-8?q?=E6=B5=81=E7=A8=8B-=E8=87=AA=E5=8A=A8=E5=8C=96=E8=8A=82?= =?UTF-8?q?=E7=82=B9&=E5=A4=96=E9=83=A8=E8=B0=83=E7=94=A8=E8=8A=82?= =?UTF-8?q?=E7=82=B9=20=E5=8F=82=E6=95=B0=E6=98=A0=E5=B0=84=E4=B8=8D?= =?UTF-8?q?=E5=81=9A=E8=A1=A8=E5=8D=95=E7=B1=BB=E5=9E=8B=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1416779639783424]后端-itsm流程-自动化节点&外部调用节点 参数映射不做表单类型限制 http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1416779639783424 --- .../IFormAttributeDataConversionHandler.java | 11 ++++ .../converter/RequestUrlConverter.java | 1 - .../neatlogic/framework/util/FormUtil.java | 63 +++++++++++++++++-- .../attribute/handler/CheckboxHandler.java | 5 ++ .../form/attribute/handler/RadioHandler.java | 5 ++ .../form/attribute/handler/SelectHandler.java | 5 ++ .../attribute/handler/SubassemblyHandler.java | 6 ++ .../handler/TableInputerHandler.java | 6 ++ .../handler/TableSelectorHandler.java | 6 ++ 9 files changed, 102 insertions(+), 6 deletions(-) diff --git a/src/main/java/neatlogic/framework/form/attribute/core/IFormAttributeDataConversionHandler.java b/src/main/java/neatlogic/framework/form/attribute/core/IFormAttributeDataConversionHandler.java index 606353d10..dcac8da5f 100644 --- a/src/main/java/neatlogic/framework/form/attribute/core/IFormAttributeDataConversionHandler.java +++ b/src/main/java/neatlogic/framework/form/attribute/core/IFormAttributeDataConversionHandler.java @@ -17,6 +17,7 @@ package neatlogic.framework.form.attribute.core; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.form.dto.AttributeDataVo; +import neatlogic.framework.form.dto.FormAttributeVo; /** * @Author:laiwt @@ -51,6 +52,16 @@ public interface IFormAttributeDataConversionHandler { return originalValue; } + /** + * 获取增强可读性值,注意用于表格选择组件、表格输入组件、表单子组件 + * @param originalValue + * @param formAttributeVo + * @return + */ + default Object getEnhanceReadabilityValue(Object originalValue, FormAttributeVo formAttributeVo) { + return originalValue; + } + /** * 通过简单值获取标准值,例如下拉框的简单值为a或A,返回标准值为{"value":"a", "text":"A"} * @param simpleValue diff --git a/src/main/java/neatlogic/framework/logback/converter/RequestUrlConverter.java b/src/main/java/neatlogic/framework/logback/converter/RequestUrlConverter.java index 9724a25a0..1c022a313 100644 --- a/src/main/java/neatlogic/framework/logback/converter/RequestUrlConverter.java +++ b/src/main/java/neatlogic/framework/logback/converter/RequestUrlConverter.java @@ -40,7 +40,6 @@ public class RequestUrlConverter extends ClassicConverter implements Serializabl public String convert(ILoggingEvent event) { RequestContext requestContext = RequestContext.get(); if (requestContext != null) { - System.out.println("RequestUrlConverter requestContext.getUrl() = " + requestContext.getUrl()); return requestContext.getUrl(); } else { Map map = event.getMDCPropertyMap(); diff --git a/src/main/java/neatlogic/framework/util/FormUtil.java b/src/main/java/neatlogic/framework/util/FormUtil.java index 335a54409..d54a499ea 100644 --- a/src/main/java/neatlogic/framework/util/FormUtil.java +++ b/src/main/java/neatlogic/framework/util/FormUtil.java @@ -21,7 +21,9 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.dependency.core.DependencyManager; +import neatlogic.framework.form.attribute.core.FormAttributeDataConversionHandlerFactory; import neatlogic.framework.form.attribute.core.FormAttributeHandlerFactory; +import neatlogic.framework.form.attribute.core.IFormAttributeDataConversionHandler; import neatlogic.framework.form.attribute.core.IFormAttributeHandler; import neatlogic.framework.form.constvalue.FormHandler; import neatlogic.framework.form.dto.AttributeDataVo; @@ -35,10 +37,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; public class FormUtil { @@ -323,6 +322,48 @@ public class FormUtil { return originalValue; } + public static Object getEnhanceReadabilityValue(Object originalValue, FormAttributeVo formAttributeVo) { + if (originalValue == null) { + return originalValue; + } + Map downwardFormAttributeMap = new HashMap<>(); + JSONObject componentObj = new JSONObject(); + componentObj.put("handler", formAttributeVo.getHandler()); + componentObj.put("uuid", formAttributeVo.getUuid()); + componentObj.put("label", formAttributeVo.getLabel()); + componentObj.put("config", formAttributeVo.getConfig()); + componentObj.put("type", formAttributeVo.getType()); + List downwardFormAttributeList = FormUtil.getFormAttributeList(componentObj, null); + if (CollectionUtils.isNotEmpty(downwardFormAttributeList)) { + for (FormAttributeVo downwardFormAttributeVo : downwardFormAttributeList) { + if (!downwardFormAttributeMap.containsKey(downwardFormAttributeVo.getUuid())) { + downwardFormAttributeMap.put(downwardFormAttributeVo.getUuid(), downwardFormAttributeVo); + } + } + } + JSONArray dataList = new JSONArray(); + JSONArray dataArray = JSONArray.parseArray(((JSONArray) originalValue).toJSONString()); + for (int i = 0; i < dataArray.size(); i++) { + JSONObject rowObj = dataArray.getJSONObject(i); + if (MapUtils.isNotEmpty(rowObj)) { + JSONObject newRowObj = new JSONObject(); + for (Map.Entry entry : rowObj.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + newRowObj.put(key, value); + FormAttributeVo downwardFormAttributeVo = downwardFormAttributeMap.get(key); + if (downwardFormAttributeVo != null) { + IFormAttributeDataConversionHandler handler = FormAttributeDataConversionHandlerFactory.getHandler(downwardFormAttributeVo.getHandler()); + Object enhanceReadabilityValue = handler.getEnhanceReadabilityValue(value, downwardFormAttributeVo); + newRowObj.put(downwardFormAttributeVo.getKey(), enhanceReadabilityValue); + newRowObj.put(downwardFormAttributeVo.getLabel(), enhanceReadabilityValue); + } + } + dataList.add(newRowObj); + } + } + return dataList; + } /** * 根据表单配置信息解析出表单的所有组件列表,包括子表单中的组件 * @param formConfig @@ -479,6 +520,16 @@ public class FormUtil { JSONArray tableList2 = formConfig.getJSONArray("tableList"); resultList.addAll(getAllFormAttributeList(tableList2, parent2)); } + } else { + JSONObject config = componentObj.getJSONObject("config"); + JSONObject formData2 = config.getJSONObject("formData"); + if (MapUtils.isNotEmpty(formData2)) { + JSONObject formConfig = formData2.getJSONObject("formConfig"); + if (MapUtils.isNotEmpty(formConfig)) { + JSONArray tableList2 = formConfig.getJSONArray("tableList"); + resultList.addAll(getAllFormAttributeList(tableList2, parent2)); + } + } } } else { JSONArray componentArray = componentObj.getJSONArray("component"); @@ -517,7 +568,9 @@ public class FormUtil { if (MapUtils.isNotEmpty(config)) { if (Objects.equals(handler, FormHandler.FORMSUBASSEMBLY.getHandler())) { JSONObject formData = componentObj.getJSONObject("formData"); - config.put("formData", formData); + if (MapUtils.isNotEmpty(formData)) { + config.put("formData", formData); + } } boolean isRequired = config.getBooleanValue("isRequired"); formAttributeVo.setRequired(isRequired); diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/CheckboxHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/CheckboxHandler.java index 5b02ed6b4..e1fe1adcd 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/CheckboxHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/CheckboxHandler.java @@ -89,6 +89,11 @@ public class CheckboxHandler extends FormHandlerBase { return formService.getSelectStandardValueBySimpleValue(simpleValue, configObj); } + @Override + public Object getEnhanceReadabilityValue(Object originalValue, FormAttributeVo formAttributeVo) { + return FormUtil.getFormSelectAttributeValueByOriginalValue(originalValue); + } + @Override public Object dataTransformationForEmail(AttributeDataVo attributeDataVo, JSONObject configObj) { JSONObject resultObj = getMyDetailedData(attributeDataVo, configObj); diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/RadioHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/RadioHandler.java index 6cb46bc09..8c4993d0b 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/RadioHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/RadioHandler.java @@ -106,6 +106,11 @@ public class RadioHandler extends FormHandlerBase { return formService.getSelectStandardValueBySimpleValue(simpleValue, configObj); } + @Override + public Object getEnhanceReadabilityValue(Object originalValue, FormAttributeVo formAttributeVo) { + return FormUtil.getFormSelectAttributeValueByOriginalValue(originalValue); + } + @Override public Object dataTransformationForEmail(AttributeDataVo attributeDataVo, JSONObject configObj) { JSONObject resultObj = getMyDetailedData(attributeDataVo, configObj); diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/SelectHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/SelectHandler.java index ebdb8f60b..3bfadb972 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/SelectHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/SelectHandler.java @@ -201,6 +201,11 @@ public class SelectHandler extends FormHandlerBase { return formService.getSelectStandardValueBySimpleValue(simpleValue, configObj); } + @Override + public Object getEnhanceReadabilityValue(Object originalValue, FormAttributeVo formAttributeVo) { + return FormUtil.getFormSelectAttributeValueByOriginalValue(originalValue); + } + @Override public Object dataTransformationForEmail(AttributeDataVo attributeDataVo, JSONObject configObj) { JSONObject resultObj = getMyDetailedData(attributeDataVo, configObj); diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/SubassemblyHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/SubassemblyHandler.java index 565dae65f..60c799421 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/SubassemblyHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/SubassemblyHandler.java @@ -11,6 +11,7 @@ import neatlogic.framework.form.constvalue.FormHandler; import neatlogic.framework.form.dto.AttributeDataVo; import neatlogic.framework.form.dto.FormAttributeVo; import neatlogic.framework.form.exception.AttributeValidException; +import neatlogic.framework.util.FormUtil; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Component; @@ -33,6 +34,11 @@ public class SubassemblyHandler extends FormHandlerBase { } } + @Override + public Object getEnhanceReadabilityValue(Object originalValue, FormAttributeVo formAttributeVo) { + return FormUtil.getEnhanceReadabilityValue(originalValue, formAttributeVo); + } + @Override public Object dataTransformationForEmail(AttributeDataVo attributeDataVo, JSONObject configObj) { return null; diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java index b48e69cb6..7aaab6b2b 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java @@ -26,6 +26,7 @@ import neatlogic.framework.form.dto.AttributeDataVo; import neatlogic.framework.form.dto.FormAttributeVo; import neatlogic.framework.form.exception.AttributeValidException; import neatlogic.framework.form.exception.FormExtendAttributeConfigIllegalException; +import neatlogic.framework.util.FormUtil; import neatlogic.framework.util.TableResultUtil; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; @@ -61,6 +62,11 @@ public class TableInputerHandler extends FormHandlerBase { } } + @Override + public Object getEnhanceReadabilityValue(Object originalValue, FormAttributeVo formAttributeVo) { + return FormUtil.getEnhanceReadabilityValue(originalValue, formAttributeVo); + } + @Override public Object dataTransformationForEmail(AttributeDataVo attributeDataVo, JSONObject configObj) { JSONObject resultObj = getMyDetailedData(attributeDataVo, configObj); diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/TableSelectorHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/TableSelectorHandler.java index f99e54ac0..5892e74e5 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/TableSelectorHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/TableSelectorHandler.java @@ -25,6 +25,7 @@ import neatlogic.framework.form.dto.AttributeDataVo; import neatlogic.framework.form.dto.FormAttributeVo; import neatlogic.framework.form.exception.AttributeValidException; import neatlogic.framework.form.exception.FormExtendAttributeConfigIllegalException; +import neatlogic.framework.util.FormUtil; import neatlogic.framework.util.TableResultUtil; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; @@ -64,6 +65,11 @@ public class TableSelectorHandler extends FormHandlerBase { } } + @Override + public Object getEnhanceReadabilityValue(Object originalValue, FormAttributeVo formAttributeVo) { + return FormUtil.getEnhanceReadabilityValue(originalValue, formAttributeVo); + } + @Override public Object dataTransformationForEmail(AttributeDataVo attributeDataVo, JSONObject configObj) { JSONObject resultObj = getMyDetailedData(attributeDataVo, configObj); -- Gitee