From 71ad848992bc420303edb278a44285fad658235a Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Tue, 17 Dec 2024 18:28:52 +0800 Subject: [PATCH 1/4] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E7=9B=AE=E5=BD=95-=E6=89=A7=E8=A1=8C=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1310909031481344]服务目录-执行作业失败 http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1310909031481344 --- .../service/AutoexecServiceServiceImpl.java | 443 ++++++++++-------- 1 file changed, 237 insertions(+), 206 deletions(-) diff --git a/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceServiceImpl.java b/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceServiceImpl.java index 54b145e6..7ab733b9 100644 --- a/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceServiceImpl.java +++ b/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceServiceImpl.java @@ -17,6 +17,7 @@ package neatlogic.module.autoexec.service; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.autoexec.constvalue.ParamMappingMode; import neatlogic.framework.autoexec.constvalue.ServiceParamMappingMode; import neatlogic.framework.autoexec.dao.mapper.AutoexecCombopMapper; import neatlogic.framework.autoexec.dto.AutoexecParamVo; @@ -25,7 +26,8 @@ import neatlogic.framework.autoexec.dto.service.AutoexecServiceConfigVo; import neatlogic.framework.autoexec.dto.service.AutoexecServiceVo; import neatlogic.framework.autoexec.exception.*; import neatlogic.framework.exception.type.ParamNotExistsException; -import neatlogic.framework.form.constvalue.FormHandler; +import neatlogic.framework.form.attribute.core.FormAttributeDataConversionHandlerFactory; +import neatlogic.framework.form.attribute.core.IFormAttributeDataConversionHandler; import neatlogic.framework.form.dao.mapper.FormMapper; import neatlogic.framework.form.dto.FormAttributeVo; import neatlogic.framework.form.dto.FormVersionVo; @@ -35,7 +37,6 @@ import neatlogic.framework.form.exception.FormAttributeNotFoundException; import neatlogic.framework.form.exception.FormAttributeRequiredException; import neatlogic.framework.form.exception.FormNotFoundException; import neatlogic.framework.util.$; -import neatlogic.framework.util.FormUtil; import neatlogic.module.autoexec.dao.mapper.AutoexecCombopVersionMapper; import neatlogic.module.autoexec.process.dto.AutoexecJobBuilder; import neatlogic.module.autoexec.process.util.CreateJobConfigUtil; @@ -45,7 +46,10 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; import java.util.stream.Collectors; @Service @@ -140,8 +144,8 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { reasonList.add(jsonObj); } } - ParamMappingVo roundCountMappingVo = serviceConfigVo.getRoundCount(); if (versionVo.getNeedRoundCount()) { + ParamMappingVo roundCountMappingVo = serviceConfigVo.getRoundCount(); if (roundCountMappingVo == null) { if (throwException) { throw new AutoexecRoundCountIsRequiredException(); @@ -200,8 +204,8 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { } } } - ParamMappingVo protocolMappingVo = serviceConfigVo.getProtocol(); if (versionVo.getNeedProtocol()) { + ParamMappingVo protocolMappingVo = serviceConfigVo.getProtocol(); if (protocolMappingVo == null) { if (throwException) { throw new AutoexecProtocolIsRequiredException(); @@ -212,8 +216,8 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { reasonList.add(jsonObj); } } else { - Object value = roundCountMappingVo.getValue(); - String mappingMode = roundCountMappingVo.getMappingMode(); + Object value = protocolMappingVo.getValue(); + String mappingMode = protocolMappingVo.getMappingMode(); if (Objects.equals(mappingMode, ServiceParamMappingMode.CONSTANT.getValue())) { if (value == null) { if (throwException) { @@ -260,8 +264,8 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { } } } - ParamMappingVo executeUserMappingVo = serviceConfigVo.getExecuteUser(); if (versionVo.getNeedExecuteUser()) { + ParamMappingVo executeUserMappingVo = serviceConfigVo.getExecuteUser(); if (executeUserMappingVo == null) { if (throwException) { throw new AutoexecExecuteUserIsRequiredException(); @@ -272,8 +276,8 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { reasonList.add(jsonObj); } } else { - Object value = roundCountMappingVo.getValue(); - String mappingMode = roundCountMappingVo.getMappingMode(); + Object value = executeUserMappingVo.getValue(); + String mappingMode = executeUserMappingVo.getMappingMode(); if (Objects.equals(mappingMode, ServiceParamMappingMode.CONSTANT.getValue())) { if (value == null) { if (throwException) { @@ -320,8 +324,8 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { } } } - ParamMappingVo executeNodeParamMappingVo = serviceConfigVo.getExecuteNodeConfig(); if (versionVo.getNeedExecuteNode()) { + ParamMappingVo executeNodeParamMappingVo = serviceConfigVo.getExecuteNodeConfig(); if (executeNodeParamMappingVo == null) { if (throwException) { throw new AutoexecExecuteNodeIsRequiredException(); @@ -332,8 +336,8 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { reasonList.add(jsonObj); } } else { - Object value = roundCountMappingVo.getValue(); - String mappingMode = roundCountMappingVo.getMappingMode(); + Object value = executeNodeParamMappingVo.getValue(); + String mappingMode = executeNodeParamMappingVo.getMappingMode(); if (Objects.equals(mappingMode, ServiceParamMappingMode.CONSTANT.getValue())) { if (value == null) { if (throwException) { @@ -384,7 +388,7 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { Map runtimeParamMap = new HashMap<>(); List runtimeParamList = versionConfigVo.getRuntimeParamList(); if (CollectionUtils.isNotEmpty(runtimeParamList)) { - runtimeParamMap = runtimeParamList.stream().collect(Collectors.toMap(e -> e.getKey(), e -> e)); + runtimeParamMap = runtimeParamList.stream().collect(Collectors.toMap(AutoexecParamVo::getKey, e -> e)); } List runtimeParamMappingList = serviceConfigVo.getRuntimeParamList(); if (CollectionUtils.isNotEmpty(runtimeParamMappingList)) { @@ -516,11 +520,10 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { AutoexecCombopExecuteNodeConfigVo executeNodeConfig, JSONObject runtimeParamMap ) { - AutoexecCombopVersionConfigVo versionConfigVo = autoexecCombopVersionVo.getConfig(); - List lastRuntimeParamList = versionConfigVo.getRuntimeParamList(); + AutoexecServiceConfigVo config = autoexecServiceVo.getConfig(); + mergeConfig(config, autoexecCombopVersionVo); AutoexecJobBuilder builder = new AutoexecJobBuilder(autoexecCombopVersionVo.getCombopId()); builder.setJobName(name); - AutoexecServiceConfigVo config = autoexecServiceVo.getConfig(); if (scenarioId == null) { scenarioId = config.getScenarioId(); } @@ -528,36 +531,32 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { builder.setScenarioId(scenarioId); } - AutoexecCombopExecuteConfigVo combopExecuteConfig = versionConfigVo.getExecuteConfig(); - if (combopExecuteConfig != null) { - // 执行器组 - ParamMappingVo runnerGroup = combopExecuteConfig.getRunnerGroup(); - if (runnerGroup != null) { - builder.setRunnerGroup(runnerGroup); - } + // 执行器组 + ParamMappingVo runnerGroup = config.getRunnerGroup(); + if (runnerGroup != null) { + builder.setRunnerGroup(runnerGroup); + } - // 执行器组标签 - ParamMappingVo runnerGroupTag = combopExecuteConfig.getRunnerGroupTag(); - if (runnerGroupTag != null) { - builder.setRunnerGroupTag(runnerGroupTag); - } + // 执行器组标签 + ParamMappingVo runnerGroupTag = config.getRunnerGroupTag(); + if (runnerGroupTag != null) { + builder.setRunnerGroupTag(runnerGroupTag); } - autoexecCombopService.needExecuteConfig(autoexecCombopVersionVo); - boolean needExecuteUser = autoexecCombopVersionVo.getNeedExecuteUser(); - boolean needExecuteNode = autoexecCombopVersionVo.getNeedExecuteNode(); - boolean needProtocol = autoexecCombopVersionVo.getNeedProtocol(); - boolean needRoundCount = autoexecCombopVersionVo.getNeedRoundCount(); - // 如果服务编辑页设置了表单,且分批数量、执行目标、连接协议、执行账号、作业参数是必填时,要么映射表单组件,要么映射常量(必填)。 - // 如果服务编辑页没有设置了表单,那么分批数量、执行目标、连接协议、执行账号、作业参数等可填也可不填,不填的话,在服务创建作业时再填。 + Map formAttributeDataMap = new HashMap<>(); String formUuid = autoexecServiceVo.getFormUuid(); if (StringUtils.isNotBlank(formUuid)) { if (CollectionUtils.isEmpty(formAttributeDataList)) { throw new ParamNotExistsException("formAttributeDataList"); } + + FormVersionVo formVersionVo = formMapper.getActionFormVersionByFormUuid(formUuid); + String mainSceneUuid = formVersionVo.getFormConfig().getString("uuid"); + formVersionVo.setSceneUuid(mainSceneUuid); + List formAttributeVoList = formVersionVo.getFormAttributeList(); + Map formAttributeVoMap = formAttributeVoList.stream().collect(Collectors.toMap(FormAttributeVo::getUuid, e -> e)); if (CollectionUtils.isEmpty(hidecomponentList)) { hidecomponentList = new JSONArray(); } - Map formAttributeDataMap = new HashMap<>(); for (int i = 0; i < formAttributeDataList.size(); i++) { JSONObject formAttributeData = formAttributeDataList.getJSONObject(i); if (formAttributeData == null) { @@ -571,139 +570,45 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { if (dataList == null) { continue; } - formAttributeDataMap.put(attributeUuid, dataList); + FormAttributeVo formAttributeVo = formAttributeVoMap.get(attributeUuid); + if (formAttributeVo == null) { + continue; + } + IFormAttributeDataConversionHandler handler = FormAttributeDataConversionHandlerFactory.getHandler(formAttributeVo.getHandler()); + if (handler != null) { + Object simpleValue = handler.getSimpleValue(dataList); + } else { + formAttributeDataMap.put(attributeUuid, dataList); + } } - Map attributeUuid2HandlerMap = new HashMap<>(); - FormVersionVo formVersionVo = formMapper.getActionFormVersionByFormUuid(formUuid); - String mainSceneUuid = formVersionVo.getFormConfig().getString("uuid"); - formVersionVo.setSceneUuid(mainSceneUuid); - List formAttributeVoList = formVersionVo.getFormAttributeList(); for (FormAttributeVo formAttributeVo : formAttributeVoList) { - String uuid = formAttributeVo.getUuid(); - attributeUuid2HandlerMap.put(uuid, formAttributeVo.getHandler()); if (formAttributeVo.isRequired()) { - if (hidecomponentList.contains(uuid)) { + if (hidecomponentList.contains(formAttributeVo.getUuid())) { continue; } - if (formAttributeDataMap.containsKey(uuid)) { + if (formAttributeDataMap.containsKey(formAttributeVo.getUuid())) { continue; } throw new FormAttributeRequiredException(formAttributeVo.getLabel()); } } - List formSelectAttributeList = new ArrayList<>(); - formSelectAttributeList.add(FormHandler.FORMSELECT.getHandler()); - formSelectAttributeList.add(FormHandler.FORMCHECKBOX.getHandler()); - formSelectAttributeList.add(FormHandler.FORMRADIO.getHandler()); - if (config != null) { - ParamMappingVo roundCountParamMappingVo = config.getRoundCount(); - if (needRoundCount && roundCountParamMappingVo != null) { - if (Objects.equals(roundCountParamMappingVo.getMappingMode(), ServiceParamMappingMode.CONSTANT.getValue())) { - builder.setRoundCount((Integer) roundCountParamMappingVo.getValue()); - } else if (Objects.equals(roundCountParamMappingVo.getMappingMode(), ServiceParamMappingMode.FORMATTR.getValue())) { - Object value = formAttributeDataMap.get(roundCountParamMappingVo.getValue()); - if (value != null) { - builder.setRoundCount((Integer) value); - } - } - } - AutoexecCombopExecuteConfigVo executeConfigVo = new AutoexecCombopExecuteConfigVo(); - ParamMappingVo executeUserParamMappingVo = config.getExecuteUser(); - if (needExecuteUser && executeUserParamMappingVo != null) { - if (Objects.equals(executeUserParamMappingVo.getMappingMode(), ServiceParamMappingMode.CONSTANT.getValue())) { - executeConfigVo.setExecuteUser(executeUserParamMappingVo); - } else if (Objects.equals(executeUserParamMappingVo.getMappingMode(), ServiceParamMappingMode.FORMATTR.getValue())) { - Object value = formAttributeDataMap.get(executeUserParamMappingVo.getValue()); - if (value != null) { - ParamMappingVo paramMappingVo = new ParamMappingVo(); - paramMappingVo.setMappingMode(ServiceParamMappingMode.CONSTANT.getValue()); - paramMappingVo.setValue(value); - executeConfigVo.setExecuteUser(paramMappingVo); - } - } - } - ParamMappingVo protocolParamMappingVo = config.getProtocol(); - if (needProtocol && protocolParamMappingVo != null) { - if (Objects.equals(protocolParamMappingVo.getMappingMode(), ServiceParamMappingMode.CONSTANT.getValue())) { - executeConfigVo.setProtocolId((Long) protocolParamMappingVo.getValue()); - } else if (Objects.equals(protocolParamMappingVo.getMappingMode(), ServiceParamMappingMode.FORMATTR.getValue())) { - Object value = formAttributeDataMap.get(protocolParamMappingVo.getValue()); - if (value != null) { - executeConfigVo.setProtocolId((Long) value); - } - } - } - ParamMappingVo executeNodeParamMappingVo = config.getExecuteNodeConfig(); - if (needExecuteNode && executeNodeParamMappingVo != null) { - if (Objects.equals(executeNodeParamMappingVo.getMappingMode(), ServiceParamMappingMode.CONSTANT.getValue())) { - AutoexecCombopExecuteNodeConfigVo executeNodeConfigVo = JSONObject.toJavaObject((JSONObject) executeNodeParamMappingVo.getValue(), AutoexecCombopExecuteNodeConfigVo.class); - executeConfigVo.setExecuteNodeConfig(executeNodeConfigVo); - } else if (Objects.equals(executeNodeParamMappingVo.getMappingMode(), ServiceParamMappingMode.FORMATTR.getValue())) { - Object value = formAttributeDataMap.get(executeNodeParamMappingVo.getValue()); - if (value != null) { - JSONArray jsonArray = new JSONArray(); - jsonArray.add(value); - AutoexecCombopExecuteNodeConfigVo executeNodeConfigVo = CreateJobConfigUtil.getExecuteNodeConfig(jsonArray); - executeConfigVo.setExecuteNodeConfig(executeNodeConfigVo); - } - } - } - builder.setExecuteConfig(executeConfigVo); - JSONObject param = new JSONObject(); - if (CollectionUtils.isNotEmpty(lastRuntimeParamList)) { - List runtimeParamList = config.getRuntimeParamList(); - if (CollectionUtils.isNotEmpty(runtimeParamList)) { - for (ParamMappingVo paramMappingVo : runtimeParamList) { - if (paramMappingVo == null) { - continue; - } - String key = paramMappingVo.getKey(); - if (StringUtils.isBlank(key)) { - continue; - } - Object value = paramMappingVo.getValue(); - if (value == null) { - continue; - } - if (Objects.equals(paramMappingVo.getMappingMode(), ServiceParamMappingMode.CONSTANT.getValue())) { - param.put(key, value); - } else if (Objects.equals(paramMappingVo.getMappingMode(), ServiceParamMappingMode.FORMATTR.getValue())) { - Object formAttrValue = formAttributeDataMap.get(value); - if (formAttrValue != null) { - if (formSelectAttributeList.contains(attributeUuid2HandlerMap.get(value))) { - Object valueObject = FormUtil.getFormSelectAttributeValueByOriginalValue(formAttrValue); - param.put(key, valueObject); - } else { - param.put(key, formAttrValue); - } - } + } + + // 如果服务编辑页设置了表单,且分批数量、执行目标、连接协议、执行账号、作业参数是必填时,要么映射表单组件,要么映射常量(必填)。 + // 如果服务编辑页没有设置了表单,那么分批数量、执行目标、连接协议、执行账号、作业参数等可填也可不填,不填的话,在服务创建作业时再填。 + if (autoexecCombopVersionVo.getNeedRoundCount()) { + ParamMappingVo roundCountParamMappingVo = config.getRoundCount(); + if (roundCountParamMappingVo != null) { + if (Objects.equals(roundCountParamMappingVo.getMappingMode(), ServiceParamMappingMode.CONSTANT.getValue()) && roundCountParamMappingVo.getValue() != null) { + builder.setRoundCount((Integer) roundCountParamMappingVo.getValue()); + } else { + if (StringUtils.isNotBlank(formUuid)) { + if (Objects.equals(roundCountParamMappingVo.getMappingMode(), ServiceParamMappingMode.FORMATTR.getValue())) { + Object value = formAttributeDataMap.get(roundCountParamMappingVo.getValue().toString()); + if (value != null) { + builder.setRoundCount((Integer) value); } } - } - if (MapUtils.isNotEmpty(runtimeParamMap)) { - param.putAll(runtimeParamMap); - } - for (AutoexecParamVo autoexecParamVo : lastRuntimeParamList) { - if (param.containsKey(autoexecParamVo.getKey())) { - continue; - } - if (!Objects.equals(autoexecParamVo.getIsRequired(), 1)) { - continue; - } - if(autoexecParamVo.getDefaultValue() != null) { - continue; - } - throw new AutoexecJobParamNotExistException(autoexecParamVo.getName(), autoexecParamVo.getKey()); - } - } - builder.setParam(param); - } - } else { - if (config != null) { - ParamMappingVo roundCountParamMappingVo = config.getRoundCount(); - if (needRoundCount && roundCountParamMappingVo != null) { - if (Objects.equals(roundCountParamMappingVo.getMappingMode(), ServiceParamMappingMode.CONSTANT.getValue()) && roundCountParamMappingVo.getValue() != null) { - builder.setRoundCount((Integer) roundCountParamMappingVo.getValue()); } else { if (roundCount != null) { builder.setRoundCount(roundCount); @@ -712,11 +617,25 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { } } } - AutoexecCombopExecuteConfigVo executeConfigVo = new AutoexecCombopExecuteConfigVo(); - ParamMappingVo executeUserParamMappingVo = config.getExecuteUser(); - if (needExecuteUser && executeUserParamMappingVo != null) { - if (Objects.equals(executeUserParamMappingVo.getMappingMode(), ServiceParamMappingMode.CONSTANT.getValue()) && executeUserParamMappingVo.getValue() != null) { - executeConfigVo.setExecuteUser(executeUserParamMappingVo); + } + } + AutoexecCombopExecuteConfigVo executeConfigVo = new AutoexecCombopExecuteConfigVo(); + if (autoexecCombopVersionVo.getNeedExecuteUser()) { + ParamMappingVo executeUserParamMappingVo = config.getExecuteUser(); + if (executeUserParamMappingVo != null) { + if (Objects.equals(executeUserParamMappingVo.getMappingMode(), ServiceParamMappingMode.CONSTANT.getValue())) { + executeConfigVo.setExecuteUser(executeUserParamMappingVo); + } else { + if (StringUtils.isNotBlank(formUuid)) { + if (Objects.equals(executeUserParamMappingVo.getMappingMode(), ServiceParamMappingMode.FORMATTR.getValue()) && executeUserParamMappingVo.getValue() != null) { + Object value = formAttributeDataMap.get(executeUserParamMappingVo.getValue().toString()); + if (value != null) { + ParamMappingVo paramMappingVo = new ParamMappingVo(); + paramMappingVo.setMappingMode(ServiceParamMappingMode.CONSTANT.getValue()); + paramMappingVo.setValue(value); + executeConfigVo.setExecuteUser(paramMappingVo); + } + } } else { if (executeUser != null) { ParamMappingVo paramMappingVo = new ParamMappingVo(); @@ -728,10 +647,21 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { } } } - ParamMappingVo protocolParamMappingVo = config.getProtocol(); - if (needProtocol && protocolParamMappingVo != null) { - if (Objects.equals(protocolParamMappingVo.getMappingMode(), ServiceParamMappingMode.CONSTANT.getValue()) && protocolParamMappingVo.getValue() != null) { - executeConfigVo.setProtocolId((Long) protocolParamMappingVo.getValue()); + } + } + if (autoexecCombopVersionVo.getNeedProtocol()) { + ParamMappingVo protocolParamMappingVo = config.getProtocol(); + if (protocolParamMappingVo != null) { + if (Objects.equals(protocolParamMappingVo.getMappingMode(), ServiceParamMappingMode.CONSTANT.getValue()) && protocolParamMappingVo.getValue() != null) { + executeConfigVo.setProtocolId((Long) protocolParamMappingVo.getValue()); + } else { + if (StringUtils.isNotBlank(formUuid)) { + if (Objects.equals(protocolParamMappingVo.getMappingMode(), ServiceParamMappingMode.FORMATTR.getValue())) { + Object value = formAttributeDataMap.get(protocolParamMappingVo.getValue().toString()); + if (value != null) { + executeConfigVo.setProtocolId((Long) value); + } + } } else { if (protocol != null) { executeConfigVo.setProtocolId(protocol); @@ -740,11 +670,25 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { } } } - ParamMappingVo executeNodeParamMappingVo = config.getExecuteNodeConfig(); - if (needExecuteNode && executeNodeParamMappingVo != null) { - if (Objects.equals(executeNodeParamMappingVo.getMappingMode(), ServiceParamMappingMode.CONSTANT.getValue()) && executeNodeParamMappingVo.getValue() != null) { - AutoexecCombopExecuteNodeConfigVo executeNodeConfig2 = JSONObject.toJavaObject((JSONObject) executeNodeParamMappingVo.getValue(), AutoexecCombopExecuteNodeConfigVo.class); - executeConfigVo.setExecuteNodeConfig(executeNodeConfig2); + } + } + if (autoexecCombopVersionVo.getNeedExecuteNode()) { + ParamMappingVo executeNodeParamMappingVo = config.getExecuteNodeConfig(); + if (executeNodeParamMappingVo != null) { + if (Objects.equals(executeNodeParamMappingVo.getMappingMode(), ServiceParamMappingMode.CONSTANT.getValue()) && executeNodeParamMappingVo.getValue() != null) { + AutoexecCombopExecuteNodeConfigVo executeNodeConfigVo = JSONObject.toJavaObject((JSONObject) executeNodeParamMappingVo.getValue(), AutoexecCombopExecuteNodeConfigVo.class); + executeConfigVo.setExecuteNodeConfig(executeNodeConfigVo); + } else { + if (StringUtils.isNotBlank(formUuid)) { + if (Objects.equals(executeNodeParamMappingVo.getMappingMode(), ServiceParamMappingMode.FORMATTR.getValue())) { + Object value = formAttributeDataMap.get(executeNodeParamMappingVo.getValue().toString()); + if (value != null) { + JSONArray jsonArray = new JSONArray(); + jsonArray.add(value); + AutoexecCombopExecuteNodeConfigVo executeNodeConfigVo = CreateJobConfigUtil.getExecuteNodeConfig(jsonArray); + executeConfigVo.setExecuteNodeConfig(executeNodeConfigVo); + } + } } else { if (executeNodeConfig.isNull()) { throw new ParamNotExistsException("executeNodeConfig"); @@ -753,47 +697,134 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { } } } - builder.setExecuteConfig(executeConfigVo); - JSONObject param = new JSONObject(); - if (CollectionUtils.isNotEmpty(lastRuntimeParamList)) { - List runtimeParamList = config.getRuntimeParamList(); - if (CollectionUtils.isNotEmpty(runtimeParamList)) { - for (ParamMappingVo paramMappingVo : runtimeParamList) { - if (paramMappingVo == null) { - continue; - } - String key = paramMappingVo.getKey(); - if (StringUtils.isBlank(key)) { - continue; - } - Object value = paramMappingVo.getValue(); - if (value == null) { - continue; - } - if (Objects.equals(paramMappingVo.getMappingMode(), ServiceParamMappingMode.CONSTANT.getValue())) { - param.put(key, value); - } - } + } + } + builder.setExecuteConfig(executeConfigVo); + AutoexecCombopVersionConfigVo versionConfigVo = autoexecCombopVersionVo.getConfig(); + List lastRuntimeParamList = versionConfigVo.getRuntimeParamList(); + JSONObject param = new JSONObject(); + if (CollectionUtils.isNotEmpty(lastRuntimeParamList)) { + List runtimeParamList = config.getRuntimeParamList(); + if (CollectionUtils.isNotEmpty(runtimeParamList)) { + for (ParamMappingVo paramMappingVo : runtimeParamList) { + if (paramMappingVo == null) { + continue; } - if (MapUtils.isNotEmpty(runtimeParamMap)) { - param.putAll(runtimeParamMap); + String key = paramMappingVo.getKey(); + if (StringUtils.isBlank(key)) { + continue; } - for (AutoexecParamVo autoexecParamVo : lastRuntimeParamList) { - if (param.containsKey(autoexecParamVo.getKey())) { - continue; - } - if (!Objects.equals(autoexecParamVo.getIsRequired(), 1)) { - continue; - } - if(autoexecParamVo.getDefaultValue() != null) { - continue; + Object value = paramMappingVo.getValue(); + if (value == null) { + continue; + } + if (Objects.equals(paramMappingVo.getMappingMode(), ServiceParamMappingMode.CONSTANT.getValue())) { + param.put(key, value); + } else { + if (StringUtils.isNotBlank(formUuid)) { + if (Objects.equals(paramMappingVo.getMappingMode(), ServiceParamMappingMode.FORMATTR.getValue())) { + Object formAttrValue = formAttributeDataMap.get(value.toString()); + if (formAttrValue != null) { + param.put(key, formAttrValue); + } + } } - throw new AutoexecJobParamNotExistException(autoexecParamVo.getName(), autoexecParamVo.getKey()); } } - builder.setParam(param); + } + if (MapUtils.isNotEmpty(runtimeParamMap)) { + param.putAll(runtimeParamMap); + } + for (AutoexecParamVo autoexecParamVo : lastRuntimeParamList) { + if (param.containsKey(autoexecParamVo.getKey())) { + continue; + } + if (!Objects.equals(autoexecParamVo.getIsRequired(), 1)) { + continue; + } + if(autoexecParamVo.getDefaultValue() != null) { + continue; + } + throw new AutoexecJobParamNotExistException(autoexecParamVo.getName(), autoexecParamVo.getKey()); } } + builder.setParam(param); return builder; } + + private void mergeConfig(AutoexecServiceConfigVo serviceConfig, AutoexecCombopVersionVo autoexecCombopVersionVo) { + autoexecCombopService.needExecuteConfig(autoexecCombopVersionVo); + AutoexecCombopVersionConfigVo versionConfig = autoexecCombopVersionVo.getConfig(); + AutoexecCombopExecuteConfigVo executeConfig = versionConfig.getExecuteConfig(); + if (executeConfig != null) { + if (autoexecCombopVersionVo.getNeedRoundCount()) { + if (executeConfig.getRoundCount() != null) { + ParamMappingVo roundCount = new ParamMappingVo(); + roundCount.setMappingMode(ParamMappingMode.CONSTANT.getValue()); + roundCount.setValue(executeConfig.getRoundCount()); + serviceConfig.setRoundCount(roundCount); + } + } else { + serviceConfig.setRoundCount(null); + } + if (autoexecCombopVersionVo.getNeedExecuteNode()) { + if (executeConfig.getExecuteNodeConfig() != null) { + ParamMappingVo executeNodeConfig = new ParamMappingVo(); + executeNodeConfig.setMappingMode(ParamMappingMode.CONSTANT.getValue()); + executeNodeConfig.setValue(executeConfig.getExecuteNodeConfig()); + serviceConfig.setExecuteNodeConfig(executeNodeConfig); + } + } else { + serviceConfig.setExecuteNodeConfig(null); + } + if (autoexecCombopVersionVo.getNeedProtocol()) { + if (executeConfig.getProtocolId() != null && serviceConfig.getProtocol() == null) { + ParamMappingVo protocol = new ParamMappingVo(); + protocol.setMappingMode(ParamMappingMode.CONSTANT.getValue()); + protocol.setValue(executeConfig.getProtocolId()); + serviceConfig.setProtocol(protocol); + } + } else { + serviceConfig.setProtocol(null); + } + if (autoexecCombopVersionVo.getNeedExecuteUser()) { + ParamMappingVo executeUser = executeConfig.getExecuteUser(); + if (executeUser != null) { + if (Objects.equals(executeUser.getMappingMode(), ParamMappingMode.CONSTANT.getValue())) { + if (serviceConfig.getExecuteUser() == null) { + serviceConfig.setExecuteUser(executeUser); + } + } else if (Objects.equals(executeUser.getMappingMode(), ParamMappingMode.RUNTIME_PARAM.getValue())) { + serviceConfig.setExecuteUser(executeUser); + } + } + } else { + serviceConfig.setExecuteUser(null); + } + ParamMappingVo runnerGroupTag = executeConfig.getRunnerGroupTag(); + if (runnerGroupTag != null) { + if (Objects.equals(runnerGroupTag.getMappingMode(), ParamMappingMode.CONSTANT.getValue())) { + if (serviceConfig.getRunnerGroupTag() == null) { + serviceConfig.setRunnerGroupTag(runnerGroupTag); + } + } else if (Objects.equals(runnerGroupTag.getMappingMode(), ParamMappingMode.RUNTIME_PARAM.getValue())) { + serviceConfig.setRunnerGroupTag(runnerGroupTag); + } + } + ParamMappingVo runnerGroup = executeConfig.getRunnerGroup(); + if (runnerGroup != null) { + if (Objects.equals(runnerGroup.getMappingMode(), ParamMappingMode.CONSTANT.getValue())) { + if (serviceConfig.getRunnerGroup() == null) { + serviceConfig.setRunnerGroup(runnerGroup); + } + } else if (Objects.equals(runnerGroup.getMappingMode(), ParamMappingMode.RUNTIME_PARAM.getValue())) { + serviceConfig.setRunnerGroup(runnerGroup); + } + } + } + + if (CollectionUtils.isEmpty(versionConfig.getScenarioList())) { + serviceConfig.setScenarioId(null); + } + } } -- Gitee From 9935a1f45d61af41ee9d33ba32af5779a7c9c0a7 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Tue, 17 Dec 2024 18:58:51 +0800 Subject: [PATCH 2/4] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E7=9B=AE=E5=BD=95-=E6=89=A7=E8=A1=8C=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1310909031481344]服务目录-执行作业失败 http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1310909031481344 --- .../autoexec/service/AutoexecServiceServiceImpl.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceServiceImpl.java b/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceServiceImpl.java index 7ab733b9..0c8b47a4 100644 --- a/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceServiceImpl.java +++ b/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceServiceImpl.java @@ -129,10 +129,9 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { return reasonList; } } - autoexecCombopService.needExecuteConfig(versionVo); AutoexecCombopVersionConfigVo versionConfigVo = versionVo.getConfig(); -// List list = new ArrayList<>(); AutoexecServiceConfigVo serviceConfigVo = serviceVo.getConfig(); + mergeConfig(serviceConfigVo, versionVo); Long scenarioId = serviceConfigVo.getScenarioId(); if (CollectionUtils.isNotEmpty(versionConfigVo.getScenarioList()) && scenarioId == null) { if (throwException) { @@ -613,7 +612,7 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { if (roundCount != null) { builder.setRoundCount(roundCount); } else { - throw new ParamNotExistsException("roundCount"); + throw new ParamNotExistsException("分批数量(roundCount)必须设置, 请联系管理员重新编辑该服务"); } } } @@ -643,7 +642,7 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { paramMappingVo.setValue(executeUser); executeConfigVo.setExecuteUser(paramMappingVo); } else { - throw new ParamNotExistsException("executeUser"); + throw new ParamNotExistsException("执行用户(executeUser)必须设置, 请联系管理员重新编辑该服务"); } } } @@ -666,7 +665,7 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { if (protocol != null) { executeConfigVo.setProtocolId(protocol); } else { - throw new ParamNotExistsException("protocol"); + throw new ParamNotExistsException("连接协议(protocol)必须设置, 请联系管理员重新编辑该服务"); } } } @@ -691,7 +690,7 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { } } else { if (executeNodeConfig.isNull()) { - throw new ParamNotExistsException("executeNodeConfig"); + throw new ParamNotExistsException("执行目标(executeNodeConfig)必须设置, 请联系管理员重新编辑该服务"); } else { executeConfigVo.setExecuteNodeConfig(executeNodeConfig); } -- Gitee From 7765df6013f54e9d086e5813c8f427a51a3cee0b Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Thu, 19 Dec 2024 17:30:07 +0800 Subject: [PATCH 3/4] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E7=9B=AE=E5=BD=95-=E6=89=A7=E8=A1=8C=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1310909031481344]服务目录-执行作业失败 http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1310909031481344 --- .../service/CreateAutoexecServiceJobApi.java | 44 ++++++++++++------- .../component/CreateJobProcessComponent.java | 13 +++++- .../service/AutoexecServiceService.java | 7 ++- .../service/AutoexecServiceServiceImpl.java | 14 ++++-- 4 files changed, 58 insertions(+), 20 deletions(-) diff --git a/src/main/java/neatlogic/module/autoexec/api/service/CreateAutoexecServiceJobApi.java b/src/main/java/neatlogic/module/autoexec/api/service/CreateAutoexecServiceJobApi.java index 629227d6..ebd02d83 100644 --- a/src/main/java/neatlogic/module/autoexec/api/service/CreateAutoexecServiceJobApi.java +++ b/src/main/java/neatlogic/module/autoexec/api/service/CreateAutoexecServiceJobApi.java @@ -25,6 +25,7 @@ import neatlogic.framework.autoexec.constvalue.JobSource; import neatlogic.framework.autoexec.constvalue.JobTriggerType; import neatlogic.framework.autoexec.dto.combop.AutoexecCombopExecuteNodeConfigVo; import neatlogic.framework.autoexec.dto.combop.AutoexecCombopVersionVo; +import neatlogic.framework.autoexec.dto.combop.ParamMappingVo; import neatlogic.framework.autoexec.dto.job.AutoexecJobVo; import neatlogic.framework.autoexec.dto.service.AutoexecServiceSearchVo; import neatlogic.framework.autoexec.dto.service.AutoexecServiceVo; @@ -42,6 +43,7 @@ import neatlogic.module.autoexec.dao.mapper.AutoexecServiceMapper; import neatlogic.module.autoexec.process.dto.AutoexecJobBuilder; import neatlogic.module.autoexec.service.AutoexecJobActionService; import neatlogic.module.autoexec.service.AutoexecServiceService; +import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -70,7 +72,7 @@ public class CreateAutoexecServiceJobApi extends PrivateApiComponentBase { @Override public String getName() { - return "作业创建(来自服务)"; + return "nmaas.createautoexecservicejobapi.getname"; } @Override @@ -79,22 +81,24 @@ public class CreateAutoexecServiceJobApi extends PrivateApiComponentBase { } @Input({ - @Param(name = "serviceId", type = ApiParamType.LONG, isRequired = true, desc = "服务ID"), - @Param(name = "name", type = ApiParamType.STRING, isRequired = true, desc = "作业名"), - @Param(name = "formAttributeDataList", type = ApiParamType.JSONARRAY, desc = "表单属性数据列表"), - @Param(name = "hidecomponentList", type = ApiParamType.JSONARRAY, desc = "隐藏表单属性列表"), - @Param(name = "scenarioId", type = ApiParamType.LONG, desc = "场景ID"), - @Param(name = "roundCount", type = ApiParamType.INTEGER, desc = "分批数量"), - @Param(name = "protocol", type = ApiParamType.LONG, desc = "协议ID"), - @Param(name = "executeUser", type = ApiParamType.STRING, desc = "执行用户"), - @Param(name = "executeNodeConfig", type = ApiParamType.JSONOBJECT, desc = "执行目标"), - @Param(name = "runtimeParamMap", type = ApiParamType.JSONOBJECT, desc = "作业参数"), - @Param(name = "planStartTime", type = ApiParamType.LONG, desc = "计划时间"), - @Param(name = "triggerType", type = ApiParamType.ENUM, member = JobTriggerType.class, desc = "触发方式") + @Param(name = "serviceId", type = ApiParamType.LONG, isRequired = true, desc = "common.serviceid"), + @Param(name = "name", type = ApiParamType.STRING, isRequired = true, desc = "nmaaja.createautoexecjobfromcombopapi.input.param.desc.name"), + @Param(name = "formAttributeDataList", type = ApiParamType.JSONARRAY, desc = "term.itsm.formattributedatalist"), + @Param(name = "hidecomponentList", type = ApiParamType.JSONARRAY, desc = "term.itsm.hidecomponentlist"), + @Param(name = "scenarioId", type = ApiParamType.LONG, desc = "term.autoexec.scenarioid"), + @Param(name = "roundCount", type = ApiParamType.INTEGER, desc = "term.autoexec.roundcount"), + @Param(name = "protocol", type = ApiParamType.LONG, desc = "term.cmdb.protocol"), + @Param(name = "executeUser", type = ApiParamType.STRING, desc = "term.autoexec.executeuser"), + @Param(name = "executeNodeConfig", type = ApiParamType.JSONOBJECT, desc = "term.autoexec.executeconfig"), + @Param(name = "runtimeParamMap", type = ApiParamType.JSONOBJECT, desc = "term.autoexec.jobparamlist"), + @Param(name = "runnerGroup", type = ApiParamType.JSONOBJECT, desc = "nfac.paramtype.runnergroup"), + @Param(name = "runnerGroupTag", type = ApiParamType.JSONOBJECT, desc = "nfac.paramtype.runnergrouptag"), + @Param(name = "planStartTime", type = ApiParamType.LONG, desc = "common.planstarttime"), + @Param(name = "triggerType", type = ApiParamType.ENUM, member = JobTriggerType.class, desc = "nmaaja.createautoexecjobfromcombopapi.input.param.desc.triggertype") }) @Output({ }) - @Description(desc = "作业创建(来自服务)") + @Description(desc = "nmaas.createautoexecservicejobapi.getname") @ResubmitInterval(value = 2) @Override public Object myDoService(JSONObject paramObj) throws Exception { @@ -129,8 +133,18 @@ public class CreateAutoexecServiceJobApi extends PrivateApiComponentBase { Long protocol = paramObj.getLong("protocol"); AutoexecCombopExecuteNodeConfigVo executeNodeConfig = paramObj.getObject("executeNodeConfig", AutoexecCombopExecuteNodeConfigVo.class); JSONObject runtimeParamMap = paramObj.getJSONObject("runtimeParamMap"); + ParamMappingVo runnerGroup = null; + JSONObject runnerGroupObj = paramObj.getJSONObject("runnerGroup"); + if (MapUtils.isNotEmpty(runnerGroupObj)) { + runnerGroup = runnerGroupObj.toJavaObject(ParamMappingVo.class); + } + ParamMappingVo runnerGroupTag = null; + JSONObject runnerGroupTagObj = paramObj.getJSONObject("runnerGroupTag"); + if (MapUtils.isNotEmpty(runnerGroupTagObj)) { + runnerGroupTag = runnerGroupTagObj.toJavaObject(ParamMappingVo.class); + } - AutoexecJobBuilder autoexecJobBuilder = autoexecServiceService.getAutoexecJobBuilder(autoexecServiceVo, autoexecCombopVersionVo, name, scenarioId, formAttributeDataList, hidecomponentList, roundCount, executeUser, protocol, executeNodeConfig, runtimeParamMap); + AutoexecJobBuilder autoexecJobBuilder = autoexecServiceService.getAutoexecJobBuilder(autoexecServiceVo, autoexecCombopVersionVo, name, scenarioId, formAttributeDataList, hidecomponentList, roundCount, executeUser, protocol, executeNodeConfig, runtimeParamMap, runnerGroup, runnerGroupTag); AutoexecJobVo autoexecJobVo = autoexecJobBuilder.build(); autoexecJobVo.setOperationType(CombopOperationType.COMBOP.getValue()); autoexecJobVo.setInvokeId(autoexecServiceVo.getId()); diff --git a/src/main/java/neatlogic/module/autoexec/process/stephandler/component/CreateJobProcessComponent.java b/src/main/java/neatlogic/module/autoexec/process/stephandler/component/CreateJobProcessComponent.java index 0e60f218..ba09e3c3 100644 --- a/src/main/java/neatlogic/module/autoexec/process/stephandler/component/CreateJobProcessComponent.java +++ b/src/main/java/neatlogic/module/autoexec/process/stephandler/component/CreateJobProcessComponent.java @@ -26,6 +26,7 @@ import neatlogic.framework.autoexec.constvalue.JobStatus; import neatlogic.framework.autoexec.dao.mapper.AutoexecJobMapper; import neatlogic.framework.autoexec.dto.combop.AutoexecCombopExecuteNodeConfigVo; import neatlogic.framework.autoexec.dto.combop.AutoexecCombopVersionVo; +import neatlogic.framework.autoexec.dto.combop.ParamMappingVo; import neatlogic.framework.autoexec.dto.job.AutoexecJobEnvVo; import neatlogic.framework.autoexec.dto.job.AutoexecJobVo; import neatlogic.framework.autoexec.dto.service.AutoexecServiceVo; @@ -241,7 +242,17 @@ public class CreateJobProcessComponent extends ProcessStepHandlerBase { Long protocol = paramObj.getLong("protocol"); AutoexecCombopExecuteNodeConfigVo executeNodeConfig = paramObj.getObject("executeNodeConfig", AutoexecCombopExecuteNodeConfigVo.class); JSONObject runtimeParamMap = paramObj.getJSONObject("runtimeParamMap"); - AutoexecJobBuilder autoexecJobBuilder = autoexecServiceService.getAutoexecJobBuilder(autoexecServiceVo, autoexecCombopVersionVo, name, scenarioId, formAttributeDataList, hidecomponentList, roundCount, executeUser, protocol, executeNodeConfig, runtimeParamMap); + ParamMappingVo runnerGroup = null; + JSONObject runnerGroupObj = paramObj.getJSONObject("runnerGroup"); + if (MapUtils.isNotEmpty(runnerGroupObj)) { + runnerGroup = runnerGroupObj.toJavaObject(ParamMappingVo.class); + } + ParamMappingVo runnerGroupTag = null; + JSONObject runnerGroupTagObj = paramObj.getJSONObject("runnerGroupTag"); + if (MapUtils.isNotEmpty(runnerGroupTagObj)) { + runnerGroupTag = runnerGroupTagObj.toJavaObject(ParamMappingVo.class); + } + AutoexecJobBuilder autoexecJobBuilder = autoexecServiceService.getAutoexecJobBuilder(autoexecServiceVo, autoexecCombopVersionVo, name, scenarioId, formAttributeDataList, hidecomponentList, roundCount, executeUser, protocol, executeNodeConfig, runtimeParamMap, runnerGroup, runnerGroupTag); if (autoexecJobBuilder != null) { builderList.add(autoexecJobBuilder); } diff --git a/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceService.java b/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceService.java index 02914009..c8a92069 100644 --- a/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceService.java +++ b/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceService.java @@ -19,6 +19,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.autoexec.dto.combop.AutoexecCombopExecuteNodeConfigVo; import neatlogic.framework.autoexec.dto.combop.AutoexecCombopVersionVo; +import neatlogic.framework.autoexec.dto.combop.ParamMappingVo; import neatlogic.framework.autoexec.dto.service.AutoexecServiceVo; import neatlogic.module.autoexec.process.dto.AutoexecJobBuilder; @@ -45,6 +46,8 @@ public interface AutoexecServiceService { * @param protocol * @param executeNodeConfig * @param runtimeParamMap + * @param runnerGroup + * @param runnerGroupTag * @return */ AutoexecJobBuilder getAutoexecJobBuilder( @@ -58,5 +61,7 @@ public interface AutoexecServiceService { String executeUser, Long protocol, AutoexecCombopExecuteNodeConfigVo executeNodeConfig, - JSONObject runtimeParamMap); + JSONObject runtimeParamMap, + ParamMappingVo runnerGroup, + ParamMappingVo runnerGroupTag); } diff --git a/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceServiceImpl.java b/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceServiceImpl.java index 0c8b47a4..599d0aa2 100644 --- a/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceServiceImpl.java +++ b/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceServiceImpl.java @@ -517,7 +517,9 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { String executeUser, Long protocol, AutoexecCombopExecuteNodeConfigVo executeNodeConfig, - JSONObject runtimeParamMap + JSONObject runtimeParamMap, + ParamMappingVo runnerGroup, + ParamMappingVo runnerGroupTag ) { AutoexecServiceConfigVo config = autoexecServiceVo.getConfig(); mergeConfig(config, autoexecCombopVersionVo); @@ -531,15 +533,21 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { } // 执行器组 - ParamMappingVo runnerGroup = config.getRunnerGroup(); if (runnerGroup != null) { builder.setRunnerGroup(runnerGroup); + } else { + if (config.getRunnerGroup() != null) { + builder.setRunnerGroup(config.getRunnerGroup()); + } } // 执行器组标签 - ParamMappingVo runnerGroupTag = config.getRunnerGroupTag(); if (runnerGroupTag != null) { builder.setRunnerGroupTag(runnerGroupTag); + } else { + if (config.getRunnerGroupTag() != null) { + builder.setRunnerGroupTag(config.getRunnerGroupTag()); + } } Map formAttributeDataMap = new HashMap<>(); String formUuid = autoexecServiceVo.getFormUuid(); -- Gitee From b384ccd7582bbdb37ecf7fdcd6b867b3d925cef7 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Thu, 19 Dec 2024 20:22:11 +0800 Subject: [PATCH 4/4] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E7=9B=AE=E5=BD=95-=E6=89=A7=E8=A1=8C=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1310909031481344]服务目录-执行作业失败 http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1310909031481344 --- .../service/AutoexecServiceServiceImpl.java | 53 +++++++++++-------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceServiceImpl.java b/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceServiceImpl.java index 599d0aa2..36f6ac2a 100644 --- a/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceServiceImpl.java +++ b/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceServiceImpl.java @@ -131,7 +131,7 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { } AutoexecCombopVersionConfigVo versionConfigVo = versionVo.getConfig(); AutoexecServiceConfigVo serviceConfigVo = serviceVo.getConfig(); - mergeConfig(serviceConfigVo, versionVo); + serviceConfigVo = mergeConfig(serviceConfigVo, versionVo); Long scenarioId = serviceConfigVo.getScenarioId(); if (CollectionUtils.isNotEmpty(versionConfigVo.getScenarioList()) && scenarioId == null) { if (throwException) { @@ -522,7 +522,7 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { ParamMappingVo runnerGroupTag ) { AutoexecServiceConfigVo config = autoexecServiceVo.getConfig(); - mergeConfig(config, autoexecCombopVersionVo); + config = mergeConfig(config, autoexecCombopVersionVo); AutoexecJobBuilder builder = new AutoexecJobBuilder(autoexecCombopVersionVo.getCombopId()); builder.setJobName(name); if (scenarioId == null) { @@ -683,8 +683,13 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { ParamMappingVo executeNodeParamMappingVo = config.getExecuteNodeConfig(); if (executeNodeParamMappingVo != null) { if (Objects.equals(executeNodeParamMappingVo.getMappingMode(), ServiceParamMappingMode.CONSTANT.getValue()) && executeNodeParamMappingVo.getValue() != null) { - AutoexecCombopExecuteNodeConfigVo executeNodeConfigVo = JSONObject.toJavaObject((JSONObject) executeNodeParamMappingVo.getValue(), AutoexecCombopExecuteNodeConfigVo.class); - executeConfigVo.setExecuteNodeConfig(executeNodeConfigVo); + Object value = executeNodeParamMappingVo.getValue(); + if (value instanceof AutoexecCombopExecuteNodeConfigVo) { + executeConfigVo.setExecuteNodeConfig((AutoexecCombopExecuteNodeConfigVo) value); + } else if (value instanceof JSONObject) { + AutoexecCombopExecuteNodeConfigVo executeNodeConfigVo = JSONObject.toJavaObject((JSONObject) executeNodeParamMappingVo.getValue(), AutoexecCombopExecuteNodeConfigVo.class); + executeConfigVo.setExecuteNodeConfig(executeNodeConfigVo); + } } else { if (StringUtils.isNotBlank(formUuid)) { if (Objects.equals(executeNodeParamMappingVo.getMappingMode(), ServiceParamMappingMode.FORMATTR.getValue())) { @@ -759,7 +764,8 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { return builder; } - private void mergeConfig(AutoexecServiceConfigVo serviceConfig, AutoexecCombopVersionVo autoexecCombopVersionVo) { + private AutoexecServiceConfigVo mergeConfig(AutoexecServiceConfigVo serviceConfig, AutoexecCombopVersionVo autoexecCombopVersionVo) { + AutoexecServiceConfigVo config = JSONObject.parseObject(JSONObject.toJSONString(serviceConfig), AutoexecServiceConfigVo.class); autoexecCombopService.needExecuteConfig(autoexecCombopVersionVo); AutoexecCombopVersionConfigVo versionConfig = autoexecCombopVersionVo.getConfig(); AutoexecCombopExecuteConfigVo executeConfig = versionConfig.getExecuteConfig(); @@ -769,69 +775,70 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { ParamMappingVo roundCount = new ParamMappingVo(); roundCount.setMappingMode(ParamMappingMode.CONSTANT.getValue()); roundCount.setValue(executeConfig.getRoundCount()); - serviceConfig.setRoundCount(roundCount); + config.setRoundCount(roundCount); } } else { - serviceConfig.setRoundCount(null); + config.setRoundCount(null); } if (autoexecCombopVersionVo.getNeedExecuteNode()) { if (executeConfig.getExecuteNodeConfig() != null) { ParamMappingVo executeNodeConfig = new ParamMappingVo(); executeNodeConfig.setMappingMode(ParamMappingMode.CONSTANT.getValue()); executeNodeConfig.setValue(executeConfig.getExecuteNodeConfig()); - serviceConfig.setExecuteNodeConfig(executeNodeConfig); + config.setExecuteNodeConfig(executeNodeConfig); } } else { - serviceConfig.setExecuteNodeConfig(null); + config.setExecuteNodeConfig(null); } if (autoexecCombopVersionVo.getNeedProtocol()) { - if (executeConfig.getProtocolId() != null && serviceConfig.getProtocol() == null) { + if (executeConfig.getProtocolId() != null && config.getProtocol() == null) { ParamMappingVo protocol = new ParamMappingVo(); protocol.setMappingMode(ParamMappingMode.CONSTANT.getValue()); protocol.setValue(executeConfig.getProtocolId()); - serviceConfig.setProtocol(protocol); + config.setProtocol(protocol); } } else { - serviceConfig.setProtocol(null); + config.setProtocol(null); } if (autoexecCombopVersionVo.getNeedExecuteUser()) { ParamMappingVo executeUser = executeConfig.getExecuteUser(); if (executeUser != null) { if (Objects.equals(executeUser.getMappingMode(), ParamMappingMode.CONSTANT.getValue())) { - if (serviceConfig.getExecuteUser() == null) { - serviceConfig.setExecuteUser(executeUser); + if (config.getExecuteUser() == null) { + config.setExecuteUser(executeUser); } } else if (Objects.equals(executeUser.getMappingMode(), ParamMappingMode.RUNTIME_PARAM.getValue())) { - serviceConfig.setExecuteUser(executeUser); + config.setExecuteUser(executeUser); } } } else { - serviceConfig.setExecuteUser(null); + config.setExecuteUser(null); } ParamMappingVo runnerGroupTag = executeConfig.getRunnerGroupTag(); if (runnerGroupTag != null) { if (Objects.equals(runnerGroupTag.getMappingMode(), ParamMappingMode.CONSTANT.getValue())) { - if (serviceConfig.getRunnerGroupTag() == null) { - serviceConfig.setRunnerGroupTag(runnerGroupTag); + if (config.getRunnerGroupTag() == null) { + config.setRunnerGroupTag(runnerGroupTag); } } else if (Objects.equals(runnerGroupTag.getMappingMode(), ParamMappingMode.RUNTIME_PARAM.getValue())) { - serviceConfig.setRunnerGroupTag(runnerGroupTag); + config.setRunnerGroupTag(runnerGroupTag); } } ParamMappingVo runnerGroup = executeConfig.getRunnerGroup(); if (runnerGroup != null) { if (Objects.equals(runnerGroup.getMappingMode(), ParamMappingMode.CONSTANT.getValue())) { - if (serviceConfig.getRunnerGroup() == null) { - serviceConfig.setRunnerGroup(runnerGroup); + if (config.getRunnerGroup() == null) { + config.setRunnerGroup(runnerGroup); } } else if (Objects.equals(runnerGroup.getMappingMode(), ParamMappingMode.RUNTIME_PARAM.getValue())) { - serviceConfig.setRunnerGroup(runnerGroup); + config.setRunnerGroup(runnerGroup); } } } if (CollectionUtils.isEmpty(versionConfig.getScenarioList())) { - serviceConfig.setScenarioId(null); + config.setScenarioId(null); } + return config; } } -- Gitee