From 6b87f11959dbb440255ee39cc7921bdf3b5c3493 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Mon, 14 Oct 2024 17:54:56 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E8=87=AA=E5=8A=A8=E5=8C=96=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E5=80=BC=E8=8E=B7=E5=8F=96=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1264572214771712]工单流程自动化表单值获取代码优化 http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1264572214771712 --- .../process/util/CreateJobConfigUtil.java | 375 +----------------- .../paramtype/ScriptParamTypeAccount.java | 7 + .../paramtype/ScriptParamTypeCheckbox.java | 5 + .../script/paramtype/ScriptParamTypeDate.java | 6 + .../paramtype/ScriptParamTypeDatetime.java | 6 + .../script/paramtype/ScriptParamTypeFile.java | 7 + .../paramtype/ScriptParamTypeFilePath.java | 6 + .../script/paramtype/ScriptParamTypeJson.java | 6 + .../paramtype/ScriptParamTypeMultiSelect.java | 5 + .../script/paramtype/ScriptParamTypeNode.java | 11 + .../paramtype/ScriptParamTypePassword.java | 6 + .../paramtype/ScriptParamTypePhase.java | 7 + .../paramtype/ScriptParamTypeRadio.java | 5 + .../paramtype/ScriptParamTypeRunnerGroup.java | 7 + .../ScriptParamTypeRunnerGroupTag.java | 7 + .../paramtype/ScriptParamTypeSelect.java | 5 + .../paramtype/ScriptParamTypeSwitch.java | 12 + .../script/paramtype/ScriptParamTypeText.java | 6 + .../paramtype/ScriptParamTypeTextarea.java | 6 + .../script/paramtype/ScriptParamTypeTime.java | 6 + .../paramtype/ScriptParamTypeUserSelect.java | 6 + 21 files changed, 139 insertions(+), 368 deletions(-) diff --git a/src/main/java/neatlogic/module/autoexec/process/util/CreateJobConfigUtil.java b/src/main/java/neatlogic/module/autoexec/process/util/CreateJobConfigUtil.java index b318cf3d..541009fc 100644 --- a/src/main/java/neatlogic/module/autoexec/process/util/CreateJobConfigUtil.java +++ b/src/main/java/neatlogic/module/autoexec/process/util/CreateJobConfigUtil.java @@ -21,19 +21,16 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.autoexec.constvalue.CombopNodeSpecify; -import neatlogic.framework.autoexec.constvalue.ParamType; import neatlogic.framework.autoexec.crossover.IAutoexecCombopCrossoverService; import neatlogic.framework.autoexec.dto.AutoexecParamVo; import neatlogic.framework.autoexec.dto.combop.*; import neatlogic.framework.autoexec.dto.node.AutoexecNodeVo; +import neatlogic.framework.autoexec.script.paramtype.IScriptParamType; +import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeFactory; import neatlogic.framework.cmdb.crossover.IResourceAccountCrossoverMapper; import neatlogic.framework.cmdb.dto.resourcecenter.AccountProtocolVo; -import neatlogic.framework.cmdb.dto.resourcecenter.AccountVo; import neatlogic.framework.common.constvalue.Expression; -import neatlogic.framework.common.constvalue.GroupSearch; import neatlogic.framework.crossover.CrossoverServiceFactory; -import neatlogic.framework.crossover.IFileCrossoverService; -import neatlogic.framework.file.dto.FileVo; import neatlogic.framework.form.attribute.core.FormAttributeDataConversionHandlerFactory; import neatlogic.framework.form.attribute.core.IFormAttributeDataConversionHandler; import neatlogic.framework.form.dto.FormAttributeVo; @@ -222,8 +219,11 @@ public class CreateJobConfigUtil { if (CollectionUtils.isEmpty(jsonArray)) { continue; } - Object value = convertDateType(autoexecParamVo, jsonArray); - param.put(mappingGroupVo.getKey(), value); + IScriptParamType handler = ScriptParamTypeFactory.getHandler(autoexecParamVo.getType()); + if (handler != null) { + Object value = handler.convertDataForProcessComponent(jsonArray); + param.put(mappingGroupVo.getKey(), value); + } } builder.setParam(param); } @@ -423,53 +423,6 @@ public class CreateJobConfigUtil { return null; } - private static Long getAccountId(JSONArray jsonArray) { - if (CollectionUtils.isEmpty(jsonArray)) { - return null; - } - IResourceAccountCrossoverMapper resourceAccountCrossoverMapper = CrossoverServiceFactory.getApi(IResourceAccountCrossoverMapper.class); - for (Object obj : jsonArray) { - if (obj == null) { - continue; - } - if (obj instanceof Long) { - Long accountId = (Long) obj; - AccountVo accountVo = resourceAccountCrossoverMapper.getAccountById(accountId); - if (accountVo != null) { - return accountId; - } - } else if (obj instanceof String) { - String account = (String) obj; - try { - Long accountId = Long.valueOf(account); - AccountVo accountVo = resourceAccountCrossoverMapper.getAccountById(accountId); - if (accountVo != null) { - return accountId; - } - } catch (NumberFormatException ex) { - AccountVo accountVo = resourceAccountCrossoverMapper.getPublicAccountByName(account); - if (accountVo != null) { - return accountVo.getId(); - } - } - } else if (obj instanceof JSONObject) { - JSONObject jsonObj = (JSONObject) obj; - Long accountId = jsonObj.getLong("accountId"); - AccountVo accountVo = resourceAccountCrossoverMapper.getAccountById(accountId); - if (accountVo != null) { - return accountId; - } - } else if (obj instanceof JSONArray) { - JSONArray array = (JSONArray) obj; - Long accountId = getAccountId(array); - if (accountId != null) { - return accountId; - } - } - } - return null; - } - private static AutoexecCombopExecuteNodeConfigVo getExecuteNodeConfig(JSONArray jsonArray) { if (CollectionUtils.isEmpty(jsonArray)) { return null; @@ -1068,109 +1021,6 @@ public class CreateJobConfigUtil { return stringBuilder.toString(); } - /** - * 把表单表格组件中某列数据集合转换成作业参数对应的数据 - * - * @param autoexecParamVo 作业参数信息 - * @param jsonArray 某列数据集合 - * @return - */ - private static Object convertDateType(AutoexecParamVo autoexecParamVo, JSONArray jsonArray) { - if (CollectionUtils.isEmpty(jsonArray)) { - return null; - } - String paramType = autoexecParamVo.getType(); - if (Objects.equals(paramType, ParamType.TEXT.getValue())) { - return String.join(",", getStringList(jsonArray)); - } else if (Objects.equals(paramType, ParamType.PASSWORD.getValue())) { - return String.join(",", getStringList(jsonArray)); - } else if (Objects.equals(paramType, ParamType.FILE.getValue())) { - // 多选 - return getFileInfo(jsonArray); - } else if (Objects.equals(paramType, ParamType.DATE.getValue())) { - return getFirstNotBlankString(jsonArray); - } else if (Objects.equals(paramType, ParamType.DATETIME.getValue())) { - return getFirstNotBlankString(jsonArray); - } else if (Objects.equals(paramType, ParamType.TIME.getValue())) { - return getFirstNotBlankString(jsonArray); - } else if (Objects.equals(paramType, ParamType.JSON.getValue())) { - return getJSONObjectOrJSONArray(jsonArray); - } else if (Objects.equals(paramType, ParamType.SELECT.getValue())) { - return getFirstNotNullObject(jsonArray); - } else if (Objects.equals(paramType, ParamType.MULTISELECT.getValue())) { - return getObjectList(jsonArray); - } else if (Objects.equals(paramType, ParamType.RADIO.getValue())) { - return getFirstNotNullObject(jsonArray); - } else if (Objects.equals(paramType, ParamType.CHECKBOX.getValue())) { - return getObjectList(jsonArray); - } else if (Objects.equals(paramType, ParamType.NODE.getValue())) { - List list = getInputNodeList(jsonArray); - JSONArray array = new JSONArray(list.size()); - array.addAll(list); - return array; - } else if (Objects.equals(paramType, ParamType.ACCOUNT.getValue())) { - // 账号id,单选 - return getAccountId(jsonArray); - } else if (Objects.equals(paramType, ParamType.USERSELECT.getValue())) { - // 单选或多选都是数组 - return getUserSelectInfo(jsonArray); - } else if (Objects.equals(paramType, ParamType.TEXTAREA.getValue())) { - return String.join(",", getStringList(jsonArray)); - } else if (Objects.equals(paramType, ParamType.PHASE.getValue())) { - // 阶段名称,单选 - return getFirstNotBlankString(jsonArray); - } else if (Objects.equals(paramType, ParamType.SWITCH.getValue())) { - // true或false - Boolean bool = getFirstNotNullBoolean(jsonArray); - if (Boolean.TRUE == bool) { - return Boolean.TRUE; - } else { - return Boolean.FALSE; - } - } else if (Objects.equals(paramType, ParamType.FILEPATH.getValue())) { - return getFirstNotBlankString(jsonArray); - } else if (Objects.equals(paramType, ParamType.RUNNERGROUP.getValue())) { - // 组id,单选 - return getFirstNotNullObject(jsonArray); - } else if (Objects.equals(paramType, ParamType.RUNNERGROUPTAG.getValue())) { - // 组id,单选 - return jsonArray; - } - return null; - } - - private static List getStringList(JSONArray jsonArray) { - List resultList = new ArrayList<>(); - for (Object obj : jsonArray) { - if (obj == null) { - continue; - } - if (obj instanceof JSONArray) { - JSONArray array = (JSONArray) obj; - resultList.addAll(getStringList(array)); - } else { - resultList.add(obj.toString()); - } - } - return resultList; - } - - private static List getObjectList(JSONArray jsonArray) { - List resultList = new ArrayList<>(); - for (Object obj : jsonArray) { - if (obj == null) { - continue; - } - if (obj instanceof JSONArray) { - JSONArray array = (JSONArray) obj; - resultList.addAll(getObjectList(array)); - } else { - resultList.add(obj); - } - } - return resultList; - } - private static Integer getFirstNotBlankInteger(JSONArray jsonArray) { for (Object obj : jsonArray) { if (obj == null) { @@ -1219,215 +1069,4 @@ public class CreateJobConfigUtil { return null; } - private static Object getFirstNotNullObject(JSONArray jsonArray) { - for (Object obj : jsonArray) { - if (obj == null) { - continue; - } - if (obj instanceof JSONArray) { - JSONArray array = (JSONArray) obj; - Object obj2 = getFirstNotNullObject(array); - if (obj2 != null) { - return obj2; - } - } else { - return obj; - } - } - return null; - } - - private static Boolean getFirstNotNullBoolean(JSONArray jsonArray) { - for (Object obj : jsonArray) { - if (obj == null) { - continue; - } - if (obj instanceof JSONArray) { - JSONArray array = (JSONArray) obj; - Boolean bool = getFirstNotNullBoolean(array); - if (bool != null) { - return bool; - } - } else if (obj instanceof Boolean) { - return (Boolean) obj; - } else { - String str = obj.toString(); - if (Objects.equals(str, Boolean.TRUE.toString())) { - return Boolean.TRUE; - } else if (Objects.equals(str, Boolean.FALSE.toString())) { - return Boolean.FALSE; - } - } - } - return null; - } - - private static Object getJSONObjectOrJSONArray(JSONArray jsonArray) { - JSONArray jsonList = new JSONArray(); - for (Object obj : jsonArray) { - if (obj == null) { - continue; - } - if (obj instanceof JSONObject) { - jsonList.add(obj); - } else if (obj instanceof JSONArray) { - jsonList.add(obj); - } else if (obj instanceof Number) { - jsonList.add(obj); - } else { - String str = obj.toString(); - if (str.startsWith("{") && str.endsWith("}")) { - JSONObject jsonObj = JSON.parseObject(str); - jsonList.add(jsonObj); - } else if (str.startsWith("[") && str.endsWith("]")) { - JSONArray array = JSON.parseArray(str); - jsonList.add(array); - } else { - jsonList.add(str); - } - } - } - if (jsonList.size() == 1) { - Object obj = jsonList.get(0); - if (obj instanceof JSONObject) { - return obj; - } else if (obj instanceof JSONArray) { - return obj; - } - } - return jsonList; - } - - private static JSONObject getFileInfo(JSONArray jsonArray) { - JSONObject resultObj = new JSONObject(); - JSONArray fileIdList = new JSONArray(); - JSONArray fileList = new JSONArray(); - IFileCrossoverService fileCrossoverService = CrossoverServiceFactory.getApi(IFileCrossoverService.class); - for (Object obj : jsonArray) { - if (obj == null) { - continue; - } - if (obj instanceof JSONObject) { - JSONObject jsonObj = (JSONObject) obj; - Long fileId = jsonObj.getLong("id"); - JSONArray fileIdArray = jsonObj.getJSONArray("fileIdList"); - JSONArray fileArray = jsonObj.getJSONArray("fileList"); - if (CollectionUtils.isNotEmpty(fileIdArray) && CollectionUtils.isNotEmpty(fileArray)) { - fileIdList.addAll(fileIdArray); - fileList.addAll(fileArray); - } else if (fileId != null) { - FileVo file = fileCrossoverService.getFileById(fileId); - if (file != null) { - fileIdList.add(fileId); - JSONObject fileObj = new JSONObject(); - fileObj.put("id", fileId); - fileObj.put("name", file.getName()); - fileList.add(fileObj); - } - } - } else if (obj instanceof JSONArray) { - JSONArray array = (JSONArray) obj; - JSONObject jsonObj = getFileInfo(array); - JSONArray fileIdArray = jsonObj.getJSONArray("fileIdList"); - if (CollectionUtils.isNotEmpty(fileIdArray)) { - fileIdList.addAll(fileIdArray); - } - JSONArray fileArray = jsonObj.getJSONArray("fileList"); - if (CollectionUtils.isNotEmpty(fileArray)) { - fileList.addAll(fileArray); - } - } else if (obj instanceof Long) { - Long fileId = (Long) obj; - FileVo file = fileCrossoverService.getFileById(fileId); - if (file != null) { - fileIdList.add(fileId); - JSONObject fileObj = new JSONObject(); - fileObj.put("id", fileId); - fileObj.put("name", file.getName()); - fileList.add(fileObj); - } - } else { - String str = obj.toString(); - if (str.startsWith("{") && str.endsWith("}")) { - JSONObject jsonObj = JSONObject.parseObject(str); - Long fileId = jsonObj.getLong("id"); - JSONArray fileIdArray = jsonObj.getJSONArray("fileIdList"); - JSONArray fileArray = jsonObj.getJSONArray("fileList"); - if (CollectionUtils.isNotEmpty(fileIdArray) && CollectionUtils.isNotEmpty(fileArray)) { - fileIdList.addAll(fileIdArray); - fileList.addAll(fileArray); - } else if (fileId != null) { - FileVo file = fileCrossoverService.getFileById(fileId); - if (file != null) { - fileIdList.add(fileId); - JSONObject fileObj = new JSONObject(); - fileObj.put("id", fileId); - fileObj.put("name", file.getName()); - fileList.add(fileObj); - } - } - } else if (str.startsWith("[") && str.endsWith("]")) { - JSONArray array = JSONArray.parseArray(str); - JSONObject jsonObj = getFileInfo(array); - JSONArray fileIdArray = jsonObj.getJSONArray("fileIdList"); - if (CollectionUtils.isNotEmpty(fileIdArray)) { - fileIdList.addAll(fileIdArray); - } - JSONArray fileArray = jsonObj.getJSONArray("fileList"); - if (CollectionUtils.isNotEmpty(fileArray)) { - fileList.addAll(fileArray); - } - } else { - try { - Long fileId = Long.valueOf(str); - FileVo file = fileCrossoverService.getFileById(fileId); - if (file != null) { - fileIdList.add(fileId); - JSONObject fileObj = new JSONObject(); - fileObj.put("id", fileId); - fileObj.put("name", file.getName()); - fileList.add(fileObj); - } - } catch (NumberFormatException e) { - - } - } - } - } - resultObj.put("fileIdList", fileIdList); - resultObj.put("fileList", fileList); - return resultObj; - } - - private static List getUserSelectInfo(JSONArray jsonArray) { - List resultList = new ArrayList<>(); - for (Object obj : jsonArray) { - if (obj == null) { - continue; - } - if (obj instanceof JSONArray) { - JSONArray array = (JSONArray) obj; - for (Object obj2 : array) { - String str = obj2.toString(); - if (str.length() == 37) { - if (str.startsWith(GroupSearch.USER.getValuePlugin()) - || str.startsWith(GroupSearch.TEAM.getValuePlugin()) - || str.startsWith(GroupSearch.ROLE.getValuePlugin())) { - resultList.add(str); - } - } - } - } else { - String str = obj.toString(); - if (str.length() == 37) { - if (str.startsWith(GroupSearch.USER.getValuePlugin()) - || str.startsWith(GroupSearch.TEAM.getValuePlugin()) - || str.startsWith(GroupSearch.ROLE.getValuePlugin())) { - resultList.add(str); - } - } - } - } - return resultList; - } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeAccount.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeAccount.java index 2f2da02b..b73813d4 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeAccount.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeAccount.java @@ -15,6 +15,7 @@ along with this program. If not, see .*/ package neatlogic.module.autoexec.script.paramtype; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.autoexec.constvalue.ParamType; import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeBase; @@ -132,4 +133,10 @@ public class ScriptParamTypeAccount extends ScriptParamTypeBase { } return valueStr; } + + @Override + public Object convertDataForProcessComponent(JSONArray jsonArray) { + // 账号id,单选 + return getAccountId(jsonArray); + } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeCheckbox.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeCheckbox.java index 9aa51abf..bbed9527 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeCheckbox.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeCheckbox.java @@ -103,4 +103,9 @@ public class ScriptParamTypeCheckbox extends ScriptParamTypeBase { } return value; } + + @Override + public Object convertDataForProcessComponent(JSONArray jsonArray) { + return getObjectList(jsonArray); + } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeDate.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeDate.java index 58df9e65..96c16237 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeDate.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeDate.java @@ -15,6 +15,7 @@ along with this program. If not, see .*/ package neatlogic.module.autoexec.script.paramtype; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.autoexec.constvalue.ParamType; import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeBase; @@ -81,4 +82,9 @@ public class ScriptParamTypeDate extends ScriptParamTypeBase { } }; } + + @Override + public Object convertDataForProcessComponent(JSONArray jsonArray) { + return getFirstNotBlankString(jsonArray); + } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeDatetime.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeDatetime.java index 6d4bc195..3e027b88 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeDatetime.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeDatetime.java @@ -15,6 +15,7 @@ along with this program. If not, see .*/ package neatlogic.module.autoexec.script.paramtype; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.autoexec.constvalue.ParamType; import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeBase; @@ -81,4 +82,9 @@ public class ScriptParamTypeDatetime extends ScriptParamTypeBase { } }; } + + @Override + public Object convertDataForProcessComponent(JSONArray jsonArray) { + return getFirstNotBlankString(jsonArray); + } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeFile.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeFile.java index 1a8bfe2d..93f030c8 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeFile.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeFile.java @@ -15,6 +15,7 @@ along with this program. If not, see .*/ package neatlogic.module.autoexec.script.paramtype; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.autoexec.constvalue.ParamType; import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeBase; @@ -95,4 +96,10 @@ public class ScriptParamTypeFile extends ScriptParamTypeBase { value = JSONObject.parseObject(value.toString()).getJSONArray("fileIdList"); return value; } + + @Override + public Object convertDataForProcessComponent(JSONArray jsonArray) { + // 多选 + return getFileInfo(jsonArray); + } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeFilePath.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeFilePath.java index e6468244..2d6ec2be 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeFilePath.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeFilePath.java @@ -15,6 +15,7 @@ along with this program. If not, see .*/ package neatlogic.module.autoexec.script.paramtype; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.autoexec.constvalue.OutputParamType; import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeBase; @@ -81,4 +82,9 @@ public class ScriptParamTypeFilePath extends ScriptParamTypeBase { } }; } + + @Override + public Object convertDataForProcessComponent(JSONArray jsonArray) { + return getFirstNotBlankString(jsonArray); + } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeJson.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeJson.java index af41911c..ae0e2031 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeJson.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeJson.java @@ -15,6 +15,7 @@ along with this program. If not, see .*/ package neatlogic.module.autoexec.script.paramtype; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.autoexec.constvalue.ParamType; import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeBase; @@ -80,4 +81,9 @@ public class ScriptParamTypeJson extends ScriptParamTypeBase { } }; } + + @Override + public Object convertDataForProcessComponent(JSONArray jsonArray) { + return getJSONObjectOrJSONArray(jsonArray); + } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeMultiSelect.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeMultiSelect.java index 5026ef70..63a3bd15 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeMultiSelect.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeMultiSelect.java @@ -104,4 +104,9 @@ public class ScriptParamTypeMultiSelect extends ScriptParamTypeBase { } return value; } + + @Override + public Object convertDataForProcessComponent(JSONArray jsonArray) { + return getObjectList(jsonArray); + } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeNode.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeNode.java index b68a6251..c6160e5e 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeNode.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeNode.java @@ -18,9 +18,12 @@ package neatlogic.module.autoexec.script.paramtype; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.autoexec.constvalue.ParamType; +import neatlogic.framework.autoexec.dto.node.AutoexecNodeVo; import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeBase; import org.springframework.stereotype.Service; +import java.util.List; + /** * @author lvzk * @since 2021/11/18 15:37 @@ -91,4 +94,12 @@ public class ScriptParamTypeNode extends ScriptParamTypeBase { } return nodeJsonArray; } + + @Override + public Object convertDataForProcessComponent(JSONArray jsonArray) { + List list = getInputNodeList(jsonArray); + JSONArray array = new JSONArray(list.size()); + array.addAll(list); + return array; + } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypePassword.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypePassword.java index f9f0809c..3a692cd9 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypePassword.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypePassword.java @@ -15,6 +15,7 @@ along with this program. If not, see .*/ package neatlogic.module.autoexec.script.paramtype; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.autoexec.constvalue.ParamType; import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeBase; @@ -94,4 +95,9 @@ public class ScriptParamTypePassword extends ScriptParamTypeBase { public Object getMyAutoexecParamByValue(Object value){ return getMyTextByValue(value, null); } + + @Override + public Object convertDataForProcessComponent(JSONArray jsonArray) { + return String.join(",", getStringList(jsonArray)); + } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypePhase.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypePhase.java index 726dabe0..0a9ec1e6 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypePhase.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypePhase.java @@ -15,6 +15,7 @@ along with this program. If not, see .*/ package neatlogic.module.autoexec.script.paramtype; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.autoexec.constvalue.ParamType; import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeBase; @@ -86,4 +87,10 @@ public class ScriptParamTypePhase extends ScriptParamTypeBase { public Boolean myNeedDataSource() { return false; } + + @Override + public Object convertDataForProcessComponent(JSONArray jsonArray) { + // 阶段名称,单选 + return getFirstNotBlankString(jsonArray); + } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeRadio.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeRadio.java index d74b38be..616c183d 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeRadio.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeRadio.java @@ -103,4 +103,9 @@ public class ScriptParamTypeRadio extends ScriptParamTypeBase { } return value; } + + @Override + public Object convertDataForProcessComponent(JSONArray jsonArray) { + return getFirstNotNullObject(jsonArray); + } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeRunnerGroup.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeRunnerGroup.java index f8ba51b3..b46d1893 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeRunnerGroup.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeRunnerGroup.java @@ -15,6 +15,7 @@ along with this program. If not, see .*/ package neatlogic.module.autoexec.script.paramtype; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.autoexec.constvalue.ParamType; import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeBase; @@ -123,4 +124,10 @@ public class ScriptParamTypeRunnerGroup extends ScriptParamTypeBase { } return valueStr; } + + @Override + public Object convertDataForProcessComponent(JSONArray jsonArray) { + // 组id,单选 + return getFirstNotNullObject(jsonArray); + } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeRunnerGroupTag.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeRunnerGroupTag.java index 94751cf5..dad09493 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeRunnerGroupTag.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeRunnerGroupTag.java @@ -15,6 +15,7 @@ along with this program. If not, see .*/ package neatlogic.module.autoexec.script.paramtype; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.autoexec.constvalue.ParamType; import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeBase; @@ -123,4 +124,10 @@ public class ScriptParamTypeRunnerGroupTag extends ScriptParamTypeBase { } return valueStr; } + + @Override + public Object convertDataForProcessComponent(JSONArray jsonArray) { + // 组id,单选 + return jsonArray; + } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeSelect.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeSelect.java index effa14f6..dea606f4 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeSelect.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeSelect.java @@ -104,4 +104,9 @@ public class ScriptParamTypeSelect extends ScriptParamTypeBase { } return value; } + + @Override + public Object convertDataForProcessComponent(JSONArray jsonArray) { + return getFirstNotNullObject(jsonArray); + } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeSwitch.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeSwitch.java index e7fb0422..b6414b00 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeSwitch.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeSwitch.java @@ -15,6 +15,7 @@ along with this program. If not, see .*/ package neatlogic.module.autoexec.script.paramtype; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.autoexec.constvalue.ParamType; import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeBase; @@ -84,4 +85,15 @@ public class ScriptParamTypeSwitch extends ScriptParamTypeBase { public Boolean myNeedDataSource() { return false; } + + @Override + public Object convertDataForProcessComponent(JSONArray jsonArray) { + // true或false + Boolean bool = getFirstNotNullBoolean(jsonArray); + if (Boolean.TRUE == bool) { + return Boolean.TRUE; + } else { + return Boolean.FALSE; + } + } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeText.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeText.java index 169e47f1..74992dd0 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeText.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeText.java @@ -15,6 +15,7 @@ along with this program. If not, see .*/ package neatlogic.module.autoexec.script.paramtype; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.autoexec.constvalue.ParamType; import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeBase; @@ -81,4 +82,9 @@ public class ScriptParamTypeText extends ScriptParamTypeBase { } }; } + + @Override + public Object convertDataForProcessComponent(JSONArray jsonArray) { + return String.join(",", getStringList(jsonArray)); + } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeTextarea.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeTextarea.java index c95365f0..e7617496 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeTextarea.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeTextarea.java @@ -15,6 +15,7 @@ along with this program. If not, see .*/ package neatlogic.module.autoexec.script.paramtype; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.autoexec.constvalue.ParamType; import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeBase; @@ -81,4 +82,9 @@ public class ScriptParamTypeTextarea extends ScriptParamTypeBase { } }; } + + @Override + public Object convertDataForProcessComponent(JSONArray jsonArray) { + return String.join(",", getStringList(jsonArray)); + } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeTime.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeTime.java index 4924a473..9799d7a9 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeTime.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeTime.java @@ -15,6 +15,7 @@ along with this program. If not, see .*/ package neatlogic.module.autoexec.script.paramtype; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.autoexec.constvalue.ParamType; import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeBase; @@ -81,4 +82,9 @@ public class ScriptParamTypeTime extends ScriptParamTypeBase { } }; } + + @Override + public Object convertDataForProcessComponent(JSONArray jsonArray) { + return getFirstNotBlankString(jsonArray); + } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeUserSelect.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeUserSelect.java index a81f1610..73ce9be4 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeUserSelect.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeUserSelect.java @@ -153,4 +153,10 @@ public class ScriptParamTypeUserSelect extends ScriptParamTypeBase { } return valueStr; } + + @Override + public Object convertDataForProcessComponent(JSONArray jsonArray) { + // 单选或多选都是数组 + return getUserSelectInfo(jsonArray); + } } -- Gitee