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 b318cf3dab0c946e4a4a8add174c7b8fe2476073..541009fc281e954ffa0fb89cbc958729c9d9e5e7 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 2f2da02bcafc1033fe67104c8e1456a979c8ff5f..b73813d463d55eb9a0aa011168525cfc232089e9 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 9aa51abfc0e5bec8ac7c0fbea366db321c7c1299..bbed9527a79d95d8d1a290d0c947075a0b6e5b09 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 58df9e65ab43df3acb6dd141028cfc04e57de6a5..96c16237aa70d4301fb13c6d86fd08ea04e9ecc4 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 6d4bc1955ea224ee98209cad9f597cc7cd7b2310..3e027b88d2253a3ab40e762ed2fa2152131be5ab 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 1a8bfe2d83bf1af78ec9ff792f7f9bcffa94cd58..93f030c8e0f5cb2bceeefe231f817bfc1d8a3c00 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 e646824419f4f2bdc0ed8aa1b1483678e134d142..2d6ec2be596beca7fa8e38b15d4e3a00fcb1a2af 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 af41911c1c1fe965a98bd709eb750a50e9757f13..ae0e20317c4e9de7a34e63c510a687b2c869e201 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 5026ef70e2baf4b92b6625a48be082c602c8a40c..63a3bd15b2cbb800d4df0a0561c8e2f471d18d21 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 b68a62518260ff80ae2db6d388abc624aeecff23..c6160e5e3f68b0e25088768b5e0bdde62c52c906 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 f9f0809c531c983d23aa95c3dcc8fcb513a19e13..3a692cd992dbac63e3ced6788d1bbd7dc94f5b63 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 726dabe02da27bd112daccf6d75bb3aa3a7e0055..0a9ec1e6f58417764cf5b4d01a4303da0fdd5bc7 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 d74b38be491023adbd1027a373ed63593f02a04a..616c183d13d1be86d58cfd9eb5486c814216ca74 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 f8ba51b33d49afeb567725c8ee4d7727d272c9c7..b46d1893a8601369cd9bdcf39a08048dbe61f0e9 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 94751cf53ed0ef60bd549bec135694894f01b572..dad0949373f3b73c4dbd1eea64f5365f29669315 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 effa14f6258e028edf891bfd7eabc479fae4d975..dea606f46987c8209ab137126c485e6ba391b233 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 e7fb0422532d99f92fa768add5c747328364f413..b6414b00b354e52edd2673cdaf55086c47a57d1b 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 169e47f1f73c8290619599933029bcf939854a44..74992dd030cf2a05637321299e9779e8aa2ab7ed 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 c95365f030c1042189a4ed0805c98a0baf4fc89b..e7617496dfd0527ad981bd00518f58e25afc5f4b 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 4924a473c76ad7cfe557011d5aae74e49a88be8b..9799d7a98682cfc21dc3cacca93182777be637bd 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 a81f1610bca4a6fb23b3973991bb561c5ee6fc99..73ce9be44ce177c49903c4ce693c9ca558686c3f 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); + } }