From 25653a0431301ec150bccaa4fe170a401fd918c6 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Wed, 20 Nov 2024 16:21:44 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF-?= =?UTF-8?q?=E5=AE=9A=E5=88=B6=E5=8C=96=E6=B5=81=E7=A8=8B=E8=8A=82=E7=82=B9?= =?UTF-8?q?-=E8=87=AA=E5=8A=A8=E5=8C=96=E6=9C=8D=E5=8A=A1=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1293522995478528]后端-定制化流程节点-自动化服务执行节点 http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1293522995478528 --- .../service/CreateAutoexecServiceJobApi.java | 322 ++---------------- .../process/dto/AutoexecJobBuilder.java | 18 +- .../process/dto/CreateJobConfigConfigVo.java | 20 ++ .../component/CreateJobProcessComponent.java | 84 ++++- .../process/util/CreateJobConfigUtil.java | 2 +- .../service/AutoexecServiceService.java | 33 ++ .../service/AutoexecServiceServiceImpl.java | 291 +++++++++++++++- 7 files changed, 438 insertions(+), 332 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 c1a28bf0..629227d6 100644 --- a/src/main/java/neatlogic/module/autoexec/api/service/CreateAutoexecServiceJobApi.java +++ b/src/main/java/neatlogic/module/autoexec/api/service/CreateAutoexecServiceJobApi.java @@ -23,42 +23,32 @@ import neatlogic.framework.autoexec.auth.AUTOEXEC_BASE; import neatlogic.framework.autoexec.constvalue.CombopOperationType; import neatlogic.framework.autoexec.constvalue.JobSource; import neatlogic.framework.autoexec.constvalue.JobTriggerType; -import neatlogic.framework.autoexec.constvalue.ServiceParamMappingMode; -import neatlogic.framework.autoexec.dto.AutoexecParamVo; -import neatlogic.framework.autoexec.dto.combop.*; +import neatlogic.framework.autoexec.dto.combop.AutoexecCombopExecuteNodeConfigVo; +import neatlogic.framework.autoexec.dto.combop.AutoexecCombopVersionVo; import neatlogic.framework.autoexec.dto.job.AutoexecJobVo; -import neatlogic.framework.autoexec.dto.service.AutoexecServiceConfigVo; import neatlogic.framework.autoexec.dto.service.AutoexecServiceSearchVo; import neatlogic.framework.autoexec.dto.service.AutoexecServiceVo; import neatlogic.framework.autoexec.exception.AutoexecCombopActiveVersionNotFoundException; -import neatlogic.framework.autoexec.exception.AutoexecJobParamNotExistException; import neatlogic.framework.autoexec.exception.AutoexecServiceConfigExpiredException; import neatlogic.framework.autoexec.exception.AutoexecServiceNotFoundException; import neatlogic.framework.common.constvalue.ApiParamType; import neatlogic.framework.dto.AuthenticationInfoVo; -import neatlogic.framework.exception.type.ParamNotExistsException; import neatlogic.framework.exception.type.PermissionDeniedException; -import neatlogic.framework.form.constvalue.FormHandler; -import neatlogic.framework.form.dao.mapper.FormMapper; -import neatlogic.framework.form.dto.FormAttributeVo; -import neatlogic.framework.form.dto.FormVersionVo; -import neatlogic.framework.form.exception.FormAttributeRequiredException; import neatlogic.framework.restful.annotation.*; import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; -import neatlogic.framework.util.FormUtil; import neatlogic.module.autoexec.dao.mapper.AutoexecCombopVersionMapper; import neatlogic.module.autoexec.dao.mapper.AutoexecServiceMapper; -import neatlogic.module.autoexec.service.AutoexecCombopService; +import neatlogic.module.autoexec.process.dto.AutoexecJobBuilder; import neatlogic.module.autoexec.service.AutoexecJobActionService; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.lang3.StringUtils; +import neatlogic.module.autoexec.service.AutoexecServiceService; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.*; +import java.util.Date; +import java.util.List; +import java.util.Objects; @Transactional @Service @@ -70,16 +60,13 @@ public class CreateAutoexecServiceJobApi extends PrivateApiComponentBase { private AutoexecServiceMapper autoexecServiceMapper; @Resource - private AutoexecCombopVersionMapper autoexecCombopVersionMapper; - - @Resource - private AutoexecJobActionService autoexecJobActionService; + private AutoexecServiceService autoexecServiceService; @Resource - private AutoexecCombopService autoexecCombopService; + private AutoexecCombopVersionMapper autoexecCombopVersionMapper; @Resource - private FormMapper formMapper; + private AutoexecJobActionService autoexecJobActionService; @Override public String getName() { @@ -133,285 +120,28 @@ public class CreateAutoexecServiceJobApi extends PrivateApiComponentBase { if (autoexecCombopVersionVo == null) { throw new AutoexecCombopActiveVersionNotFoundException(combopId); } - AutoexecCombopVersionConfigVo versionConfigVo = autoexecCombopVersionVo.getConfig(); - List lastRuntimeParamList = versionConfigVo.getRuntimeParamList(); - String triggerType = paramObj.getString("triggerType"); - Long planStartTime = paramObj.getLong("planStartTime"); - AutoexecJobVo autoexecJobVo = new AutoexecJobVo(); + String name = paramObj.getString("name"); + Long scenarioId = paramObj.getLong("scenarioId"); + JSONArray formAttributeDataList = paramObj.getJSONArray("formAttributeDataList"); + JSONArray hidecomponentList = paramObj.getJSONArray("hidecomponentList"); + Integer roundCount = paramObj.getInteger("roundCount"); + String executeUser = paramObj.getString("executeUser"); + 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); + AutoexecJobVo autoexecJobVo = autoexecJobBuilder.build(); autoexecJobVo.setOperationType(CombopOperationType.COMBOP.getValue()); - autoexecJobVo.setOperationId(combopId); - autoexecJobVo.setInvokeId(serviceId); - autoexecJobVo.setRouteId(serviceId.toString()); - autoexecJobVo.setCombopId(combopId); - autoexecJobVo.setName(paramObj.getString("name")); + autoexecJobVo.setInvokeId(autoexecServiceVo.getId()); + autoexecJobVo.setRouteId(autoexecServiceVo.getId().toString()); autoexecJobVo.setSource(JobSource.SERVICE.getValue()); + String triggerType = paramObj.getString("triggerType"); + Long planStartTime = paramObj.getLong("planStartTime"); autoexecJobVo.setTriggerType(triggerType); if (planStartTime != null) { autoexecJobVo.setPlanStartTime(new Date(planStartTime)); } - AutoexecServiceConfigVo config = autoexecServiceVo.getConfig(); - Long scenarioId = paramObj.getLong("scenarioId"); - if (scenarioId == null) { - scenarioId = config.getScenarioId(); - } - if (scenarioId != null) { - autoexecJobVo.setScenarioId(scenarioId); - } - - autoexecCombopService.needExecuteConfig(autoexecCombopVersionVo); - boolean needExecuteUser = autoexecCombopVersionVo.getNeedExecuteUser(); - boolean needExecuteNode = autoexecCombopVersionVo.getNeedExecuteNode(); - boolean needProtocol = autoexecCombopVersionVo.getNeedProtocol(); - boolean needRoundCount = autoexecCombopVersionVo.getNeedRoundCount(); - // 如果服务编辑页设置了表单,且分批数量、执行目标、连接协议、执行账号、作业参数是必填时,要么映射表单组件,要么映射常量(必填)。 - // 如果服务编辑页没有设置了表单,那么分批数量、执行目标、连接协议、执行账号、作业参数等可填也可不填,不填的话,在服务创建作业时再填。 - String formUuid = autoexecServiceVo.getFormUuid(); - if (StringUtils.isNotBlank(formUuid)) { - JSONArray formAttributeDataList = paramObj.getJSONArray("formAttributeDataList"); - JSONArray hidecomponentList = paramObj.getJSONArray("hidecomponentList"); - if (CollectionUtils.isEmpty(formAttributeDataList)) { - throw new ParamNotExistsException("formAttributeDataList"); - } - 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) { - continue; - } - String attributeUuid = formAttributeData.getString("attributeUuid"); - if (StringUtils.isBlank(attributeUuid)) { - continue; - } - Object dataList = formAttributeData.get("dataList"); - if (dataList == null) { - continue; - } - 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)) { - continue; - } - if (formAttributeDataMap.containsKey(uuid)) { - 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())) { - autoexecJobVo.setRoundCount((Integer) roundCountParamMappingVo.getValue()); - } else if (Objects.equals(roundCountParamMappingVo.getMappingMode(), ServiceParamMappingMode.FORMATTR.getValue())) { - Object value = formAttributeDataMap.get(roundCountParamMappingVo.getValue()); - if (value != null) { - autoexecJobVo.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) { - AutoexecCombopExecuteNodeConfigVo executeNodeConfigVo = JSONObject.toJavaObject((JSONObject) value, AutoexecCombopExecuteNodeConfigVo.class); - executeConfigVo.setExecuteNodeConfig(executeNodeConfigVo); - } - } - } - autoexecJobVo.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); - } - } - } - } - } - 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()); - } - } - autoexecJobVo.setParam(param); - } - } else { - if (config != null) { - ParamMappingVo roundCountParamMappingVo = config.getRoundCount(); - if (needRoundCount && roundCountParamMappingVo != null) { - if (roundCountParamMappingVo.getValue() != null) { - autoexecJobVo.setRoundCount((Integer) roundCountParamMappingVo.getValue()); - } else { - Integer roundCount = paramObj.getInteger("roundCount"); - if (roundCount != null) { - autoexecJobVo.setRoundCount(roundCount); - } else { - throw new ParamNotExistsException("roundCount"); - } - } - } - AutoexecCombopExecuteConfigVo executeConfigVo = new AutoexecCombopExecuteConfigVo(); - ParamMappingVo executeUserParamMappingVo = config.getExecuteUser(); - if (needExecuteUser && executeUserParamMappingVo != null) { - if (executeUserParamMappingVo.getValue() != null) { - executeConfigVo.setExecuteUser(executeUserParamMappingVo); - } else { - String executeUser = paramObj.getString("executeUser"); - if (executeUser != null) { - ParamMappingVo paramMappingVo = new ParamMappingVo(); - paramMappingVo.setMappingMode(ServiceParamMappingMode.CONSTANT.getValue()); - paramMappingVo.setValue(executeUser); - executeConfigVo.setExecuteUser(paramMappingVo); - } else { - throw new ParamNotExistsException("executeUser"); - } - } - } - ParamMappingVo protocolParamMappingVo = config.getProtocol(); - if (needProtocol && protocolParamMappingVo != null) { - if (protocolParamMappingVo.getValue() != null) { - executeConfigVo.setProtocolId((Long) protocolParamMappingVo.getValue()); - } else { - Long protocol = paramObj.getLong("protocol"); - if (protocol != null) { - executeConfigVo.setProtocolId(protocol); - } else { - throw new ParamNotExistsException("protocol"); - } - } - } - ParamMappingVo executeNodeParamMappingVo = config.getExecuteNodeConfig(); - if (needExecuteNode && executeNodeParamMappingVo != null) { - if (executeNodeParamMappingVo.getValue() != null) { - AutoexecCombopExecuteNodeConfigVo executeNodeConfig = JSONObject.toJavaObject((JSONObject) executeNodeParamMappingVo.getValue(), AutoexecCombopExecuteNodeConfigVo.class); - executeConfigVo.setExecuteNodeConfig(executeNodeConfig); - } else { - AutoexecCombopExecuteNodeConfigVo executeNodeConfig = paramObj.getObject("executeNodeConfig", AutoexecCombopExecuteNodeConfigVo.class); - if (executeNodeConfig.isNull()) { - throw new ParamNotExistsException("executeNodeConfig"); - } else { - executeConfigVo.setExecuteNodeConfig(executeNodeConfig); - } - } - } - autoexecJobVo.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); - } - } - } - JSONObject runtimeParamMap = paramObj.getJSONObject("runtimeParamMap"); - 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()); - } - } - autoexecJobVo.setParam(param); - } - } autoexecJobActionService.validateAndCreateJobFromCombop(autoexecJobVo); autoexecJobActionService.settingJobFireMode(autoexecJobVo); JSONObject resultObj = new JSONObject(); diff --git a/src/main/java/neatlogic/module/autoexec/process/dto/AutoexecJobBuilder.java b/src/main/java/neatlogic/module/autoexec/process/dto/AutoexecJobBuilder.java index d72c6433..a2a269c1 100644 --- a/src/main/java/neatlogic/module/autoexec/process/dto/AutoexecJobBuilder.java +++ b/src/main/java/neatlogic/module/autoexec/process/dto/AutoexecJobBuilder.java @@ -18,18 +18,13 @@ package neatlogic.module.autoexec.process.dto; import com.alibaba.fastjson.JSONObject; -import neatlogic.framework.autoexec.constvalue.CombopOperationType; import neatlogic.framework.autoexec.dto.combop.AutoexecCombopExecuteConfigVo; import neatlogic.framework.autoexec.dto.combop.ParamMappingVo; import neatlogic.framework.autoexec.dto.job.AutoexecJobVo; import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.common.constvalue.SystemUser; -import neatlogic.framework.process.constvalue.AutoExecJobProcessSource; import neatlogic.framework.restful.annotation.EntityField; public class AutoexecJobBuilder { - @EntityField(name = "工单步骤id", type = ApiParamType.LONG) - private final Long processTaskStepId; @EntityField(name = "组合工具id", type = ApiParamType.LONG) private final Long combopId; @EntityField(name = "作业名称(唯一标识)", type = ApiParamType.STRING) @@ -53,10 +48,6 @@ public class AutoexecJobBuilder { @EntityField(name = "作业参数数据", type = ApiParamType.JSONOBJECT) private JSONObject param; - public Long getProcessTaskStepId() { - return processTaskStepId; - } - public Long getCombopId() { return combopId; } @@ -117,8 +108,7 @@ public class AutoexecJobBuilder { this.param = param; } - public AutoexecJobBuilder(Long processTaskStepId, Long combopId) { - this.processTaskStepId = processTaskStepId; + public AutoexecJobBuilder(Long combopId) { this.combopId = combopId; } @@ -134,12 +124,6 @@ public class AutoexecJobBuilder { } jobVo.setName(jobName); jobVo.setOperationId(combopId); - jobVo.setInvokeId(processTaskStepId); - jobVo.setRouteId(processTaskStepId.toString()); - jobVo.setSource(AutoExecJobProcessSource.ITSM.getValue()); - jobVo.setOperationType(CombopOperationType.COMBOP.getValue()); - jobVo.setIsFirstFire(1); - jobVo.setAssignExecUser(SystemUser.SYSTEM.getUserUuid()); return jobVo; } } diff --git a/src/main/java/neatlogic/module/autoexec/process/dto/CreateJobConfigConfigVo.java b/src/main/java/neatlogic/module/autoexec/process/dto/CreateJobConfigConfigVo.java index 2cf3dd12..741ef0db 100644 --- a/src/main/java/neatlogic/module/autoexec/process/dto/CreateJobConfigConfigVo.java +++ b/src/main/java/neatlogic/module/autoexec/process/dto/CreateJobConfigConfigVo.java @@ -46,6 +46,10 @@ public class CreateJobConfigConfigVo { private List scenarioParamMappingGroupList; + private String type; + + private String formAttributeUuid; + public Long getCombopId() { return combopId; } @@ -133,4 +137,20 @@ public class CreateJobConfigConfigVo { public void setFormTag(String formTag) { this.formTag = formTag; } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getFormAttributeUuid() { + return formAttributeUuid; + } + + public void setFormAttributeUuid(String formAttributeUuid) { + this.formAttributeUuid = formAttributeUuid; + } } 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 3993bd35..c14c4c7c 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 @@ -20,13 +20,18 @@ package neatlogic.module.autoexec.process.stephandler.component; import com.alibaba.fastjson.*; import neatlogic.framework.asynchronization.threadlocal.UserContext; import neatlogic.framework.autoexec.constvalue.AutoexecNotifyTriggerType; +import neatlogic.framework.autoexec.constvalue.CombopOperationType; 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.job.AutoexecJobEnvVo; import neatlogic.framework.autoexec.dto.job.AutoexecJobVo; +import neatlogic.framework.autoexec.dto.service.AutoexecServiceVo; import neatlogic.framework.autoexec.exception.AutoexecCombopActiveVersionNotFoundException; import neatlogic.framework.autoexec.exception.AutoexecCombopVersionNotFoundException; +import neatlogic.framework.autoexec.exception.AutoexecServiceConfigExpiredException; +import neatlogic.framework.autoexec.exception.AutoexecServiceNotFoundException; import neatlogic.framework.common.constvalue.SystemUser; import neatlogic.framework.crossover.CrossoverServiceFactory; import neatlogic.framework.form.dto.AttributeDataVo; @@ -45,6 +50,7 @@ import neatlogic.framework.process.stephandler.core.ProcessStepHandlerFactory; import neatlogic.framework.process.stephandler.core.ProcessStepThread; import neatlogic.module.autoexec.constvalue.FailPolicy; import neatlogic.module.autoexec.dao.mapper.AutoexecCombopVersionMapper; +import neatlogic.module.autoexec.dao.mapper.AutoexecServiceMapper; import neatlogic.module.autoexec.process.constvalue.CreateJobProcessStepHandlerType; import neatlogic.module.autoexec.process.dto.AutoexecJobBuilder; import neatlogic.module.autoexec.process.dto.CreateJobConfigConfigVo; @@ -52,6 +58,7 @@ import neatlogic.module.autoexec.process.dto.CreateJobConfigVo; import neatlogic.module.autoexec.process.util.CreateJobConfigUtil; import neatlogic.module.autoexec.service.AutoexecCombopService; import neatlogic.module.autoexec.service.AutoexecJobActionService; +import neatlogic.module.autoexec.service.AutoexecServiceService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -82,6 +89,12 @@ public class CreateJobProcessComponent extends ProcessStepHandlerBase { @Resource private AutoexecCombopService autoexecCombopService; + @Resource + private AutoexecServiceMapper autoexecServiceMapper; + + @Resource + private AutoexecServiceService autoexecServiceService; + @Override public String getHandler() { @@ -183,17 +196,62 @@ public class CreateJobProcessComponent extends ProcessStepHandlerBase { if (createJobConfigConfigVo == null) { continue; } - Long activeVersionId = autoexecCombopVersionMapper.getAutoexecCombopActiveVersionIdByCombopId(createJobConfigConfigVo.getCombopId()); - if (activeVersionId == null) { - throw new AutoexecCombopActiveVersionNotFoundException(createJobConfigConfigVo.getCombopId()); - } - AutoexecCombopVersionVo autoexecCombopVersionVo = autoexecCombopService.getAutoexecCombopVersionById(activeVersionId); - if (autoexecCombopVersionVo == null) { - throw new AutoexecCombopVersionNotFoundException(activeVersionId); + if (Objects.equals(createJobConfigConfigVo.getType(), "service")) { + JSONObject paramObj = null; + Long processTaskId = currentProcessTaskStepVo.getProcessTaskId(); + // 如果工单有表单信息,则查询出表单配置及数据 + IProcessTaskCrossoverService processTaskCrossoverService = CrossoverServiceFactory.getApi(IProcessTaskCrossoverService.class); + List formAttributeList = processTaskCrossoverService.getFormAttributeListByProcessTaskIdAngTagNew(processTaskId, createJobConfigConfigVo.getFormTag()); + if (CollectionUtils.isNotEmpty(formAttributeList)) { + List processTaskFormAttributeDataList = processTaskCrossoverService.getProcessTaskFormAttributeDataListByProcessTaskIdAndTagNew(processTaskId, createJobConfigConfigVo.getFormTag()); + for (ProcessTaskFormAttributeDataVo attributeDataVo : processTaskFormAttributeDataList) { + if (Objects.equals(attributeDataVo.getAttributeUuid(), createJobConfigConfigVo.getFormAttributeUuid())) { + paramObj = (JSONObject) attributeDataVo.getDataObj(); + break; + } + } + } + if (MapUtils.isNotEmpty(paramObj)) { + Long serviceId = paramObj.getLong("serviceId"); + AutoexecServiceVo autoexecServiceVo = autoexecServiceMapper.getAutoexecServiceById(serviceId); + if (autoexecServiceVo == null) { + throw new AutoexecServiceNotFoundException(serviceId); + } + if (Objects.equals(autoexecServiceVo.getConfigExpired(), 1)) { + throw new AutoexecServiceConfigExpiredException(autoexecServiceVo.getName()); + } + Long combopId = autoexecServiceVo.getCombopId(); + AutoexecCombopVersionVo autoexecCombopVersionVo = autoexecCombopVersionMapper.getAutoexecCombopActiveVersionByCombopId(combopId); + if (autoexecCombopVersionVo == null) { + throw new AutoexecCombopActiveVersionNotFoundException(combopId); + } + String name = paramObj.getString("name"); + Long scenarioId = paramObj.getLong("scenarioId"); + JSONArray formAttributeDataList = paramObj.getJSONArray("formAttributeDataList"); + JSONArray hidecomponentList = paramObj.getJSONArray("hidecomponentList"); + Integer roundCount = paramObj.getInteger("roundCount"); + String executeUser = paramObj.getString("executeUser"); + 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); + if (autoexecJobBuilder != null) { + builderList.add(autoexecJobBuilder); + } + } + } else { + Long activeVersionId = autoexecCombopVersionMapper.getAutoexecCombopActiveVersionIdByCombopId(createJobConfigConfigVo.getCombopId()); + if (activeVersionId == null) { + throw new AutoexecCombopActiveVersionNotFoundException(createJobConfigConfigVo.getCombopId()); + } + AutoexecCombopVersionVo autoexecCombopVersionVo = autoexecCombopService.getAutoexecCombopVersionById(activeVersionId); + if (autoexecCombopVersionVo == null) { + throw new AutoexecCombopVersionNotFoundException(activeVersionId); + } + // 根据配置信息创建AutoexecJobBuilder对象 + List list = CreateJobConfigUtil.createAutoexecJobBuilderList(currentProcessTaskStepVo, createJobConfigConfigVo, autoexecCombopVersionVo); + builderList.addAll(list); } - // 根据配置信息创建AutoexecJobBuilder对象 - List list = CreateJobConfigUtil.createAutoexecJobBuilderList(currentProcessTaskStepVo, createJobConfigConfigVo, autoexecCombopVersionVo); - builderList.addAll(list); } if (CollectionUtils.isEmpty(builderList)) { @@ -204,6 +262,12 @@ public class CreateJobProcessComponent extends ProcessStepHandlerBase { List jobIdList = new ArrayList<>(); for (AutoexecJobBuilder builder : builderList) { AutoexecJobVo jobVo = builder.build(); + jobVo.setOperationType(CombopOperationType.COMBOP.getValue()); + jobVo.setInvokeId(currentProcessTaskStepVo.getId()); + jobVo.setRouteId(currentProcessTaskStepVo.getId().toString()); + jobVo.setSource(AutoExecJobProcessSource.ITSM.getValue()); + jobVo.setIsFirstFire(1); + jobVo.setAssignExecUser(SystemUser.SYSTEM.getUserUuid()); try { autoexecJobActionService.validateCreateJob(jobVo); autoexecJobMapper.insertAutoexecJobProcessTaskStep(jobVo.getId(), currentProcessTaskStepVo.getId()); 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 21d3165f..79962e53 100644 --- a/src/main/java/neatlogic/module/autoexec/process/util/CreateJobConfigUtil.java +++ b/src/main/java/neatlogic/module/autoexec/process/util/CreateJobConfigUtil.java @@ -190,7 +190,7 @@ public class CreateJobConfigUtil { JSONObject processTaskParam) { // 组合工具ID Long combopId = createJobConfigConfigVo.getCombopId(); - AutoexecJobBuilder builder = new AutoexecJobBuilder(currentProcessTaskStepVo.getId(), combopId); + AutoexecJobBuilder builder = new AutoexecJobBuilder(combopId); // 作业名称 String jobName = createJobConfigConfigVo.getJobName(); AutoexecCombopVersionConfigVo versionConfig = autoexecCombopVersionVo.getConfig(); diff --git a/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceService.java b/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceService.java index 8753a08f..02914009 100644 --- a/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceService.java +++ b/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceService.java @@ -16,7 +16,11 @@ along with this program. If not, see .*/ package neatlogic.module.autoexec.service; 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.service.AutoexecServiceVo; +import neatlogic.module.autoexec.process.dto.AutoexecJobBuilder; public interface AutoexecServiceService { /** @@ -26,4 +30,33 @@ public interface AutoexecServiceService { * @return 失效原因列表 */ JSONArray checkConfigExpired(AutoexecServiceVo serviceVo, boolean throwException); + + /** + * 根据配置信息创建AutoexecJobBuilder对象 + * + * @param autoexecServiceVo + * @param autoexecCombopVersionVo + * @param name + * @param scenarioId + * @param formAttributeDataList + * @param hidecomponentList + * @param roundCount + * @param executeUser + * @param protocol + * @param executeNodeConfig + * @param runtimeParamMap + * @return + */ + AutoexecJobBuilder getAutoexecJobBuilder( + AutoexecServiceVo autoexecServiceVo, + AutoexecCombopVersionVo autoexecCombopVersionVo, + String name, + Long scenarioId, + JSONArray formAttributeDataList, + JSONArray hidecomponentList, + Integer roundCount, + String executeUser, + Long protocol, + AutoexecCombopExecuteNodeConfigVo executeNodeConfig, + JSONObject runtimeParamMap); } diff --git a/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceServiceImpl.java b/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceServiceImpl.java index cdea2c41..12d12df5 100644 --- a/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceServiceImpl.java +++ b/src/main/java/neatlogic/module/autoexec/service/AutoexecServiceServiceImpl.java @@ -20,32 +20,31 @@ import com.alibaba.fastjson.JSONObject; import neatlogic.framework.autoexec.constvalue.ServiceParamMappingMode; import neatlogic.framework.autoexec.dao.mapper.AutoexecCombopMapper; import neatlogic.framework.autoexec.dto.AutoexecParamVo; -import neatlogic.framework.autoexec.dto.combop.AutoexecCombopVersionConfigVo; -import neatlogic.framework.autoexec.dto.combop.AutoexecCombopVersionVo; -import neatlogic.framework.autoexec.dto.combop.AutoexecCombopVo; -import neatlogic.framework.autoexec.dto.combop.ParamMappingVo; +import neatlogic.framework.autoexec.dto.combop.*; 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.dao.mapper.FormMapper; import neatlogic.framework.form.dto.FormAttributeVo; import neatlogic.framework.form.dto.FormVersionVo; import neatlogic.framework.form.dto.FormVo; import neatlogic.framework.form.exception.FormActiveVersionNotFoundExcepiton; 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 org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; @Service @@ -501,4 +500,280 @@ public class AutoexecServiceServiceImpl implements AutoexecServiceService { } return reasonList; } + + @Override + public AutoexecJobBuilder getAutoexecJobBuilder( + AutoexecServiceVo autoexecServiceVo, + AutoexecCombopVersionVo autoexecCombopVersionVo, + String name, + Long scenarioId, + JSONArray formAttributeDataList, + JSONArray hidecomponentList, + Integer roundCount, + String executeUser, + Long protocol, + AutoexecCombopExecuteNodeConfigVo executeNodeConfig, + JSONObject runtimeParamMap + ) { + AutoexecCombopVersionConfigVo versionConfigVo = autoexecCombopVersionVo.getConfig(); + List lastRuntimeParamList = versionConfigVo.getRuntimeParamList(); + AutoexecJobBuilder builder = new AutoexecJobBuilder(autoexecCombopVersionVo.getCombopId()); + builder.setJobName(name); + AutoexecServiceConfigVo config = autoexecServiceVo.getConfig(); + if (scenarioId == null) { + scenarioId = config.getScenarioId(); + } + if (scenarioId != null) { + builder.setScenarioId(scenarioId); + } + + autoexecCombopService.needExecuteConfig(autoexecCombopVersionVo); + boolean needExecuteUser = autoexecCombopVersionVo.getNeedExecuteUser(); + boolean needExecuteNode = autoexecCombopVersionVo.getNeedExecuteNode(); + boolean needProtocol = autoexecCombopVersionVo.getNeedProtocol(); + boolean needRoundCount = autoexecCombopVersionVo.getNeedRoundCount(); + // 如果服务编辑页设置了表单,且分批数量、执行目标、连接协议、执行账号、作业参数是必填时,要么映射表单组件,要么映射常量(必填)。 + // 如果服务编辑页没有设置了表单,那么分批数量、执行目标、连接协议、执行账号、作业参数等可填也可不填,不填的话,在服务创建作业时再填。 + String formUuid = autoexecServiceVo.getFormUuid(); + if (StringUtils.isNotBlank(formUuid)) { + if (CollectionUtils.isEmpty(formAttributeDataList)) { + throw new ParamNotExistsException("formAttributeDataList"); + } + 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) { + continue; + } + String attributeUuid = formAttributeData.getString("attributeUuid"); + if (StringUtils.isBlank(attributeUuid)) { + continue; + } + Object dataList = formAttributeData.get("dataList"); + if (dataList == null) { + continue; + } + 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)) { + continue; + } + if (formAttributeDataMap.containsKey(uuid)) { + 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) { + AutoexecCombopExecuteNodeConfigVo executeNodeConfigVo = JSONObject.toJavaObject((JSONObject) value, AutoexecCombopExecuteNodeConfigVo.class); + 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); + } + } + } + } + } + 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 (roundCountParamMappingVo.getValue() != null) { + builder.setRoundCount((Integer) roundCountParamMappingVo.getValue()); + } else { + if (roundCount != null) { + builder.setRoundCount(roundCount); + } else { + throw new ParamNotExistsException("roundCount"); + } + } + } + AutoexecCombopExecuteConfigVo executeConfigVo = new AutoexecCombopExecuteConfigVo(); + ParamMappingVo executeUserParamMappingVo = config.getExecuteUser(); + if (needExecuteUser && executeUserParamMappingVo != null) { + if (executeUserParamMappingVo.getValue() != null) { + executeConfigVo.setExecuteUser(executeUserParamMappingVo); + } else { + if (executeUser != null) { + ParamMappingVo paramMappingVo = new ParamMappingVo(); + paramMappingVo.setMappingMode(ServiceParamMappingMode.CONSTANT.getValue()); + paramMappingVo.setValue(executeUser); + executeConfigVo.setExecuteUser(paramMappingVo); + } else { + throw new ParamNotExistsException("executeUser"); + } + } + } + ParamMappingVo protocolParamMappingVo = config.getProtocol(); + if (needProtocol && protocolParamMappingVo != null) { + if (protocolParamMappingVo.getValue() != null) { + executeConfigVo.setProtocolId((Long) protocolParamMappingVo.getValue()); + } else { + if (protocol != null) { + executeConfigVo.setProtocolId(protocol); + } else { + throw new ParamNotExistsException("protocol"); + } + } + } + ParamMappingVo executeNodeParamMappingVo = config.getExecuteNodeConfig(); + if (needExecuteNode && executeNodeParamMappingVo != null) { + if (executeNodeParamMappingVo.getValue() != null) { + AutoexecCombopExecuteNodeConfigVo executeNodeConfig2 = JSONObject.toJavaObject((JSONObject) executeNodeParamMappingVo.getValue(), AutoexecCombopExecuteNodeConfigVo.class); + executeConfigVo.setExecuteNodeConfig(executeNodeConfig2); + } else { + if (executeNodeConfig.isNull()) { + throw new ParamNotExistsException("executeNodeConfig"); + } else { + executeConfigVo.setExecuteNodeConfig(executeNodeConfig); + } + } + } + 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); + } + } + } + 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; + } } -- Gitee