diff --git a/src/main/java/neatlogic/module/autoexec/api/job/GetAutoexecJobCreatePayloadApi.java b/src/main/java/neatlogic/module/autoexec/api/job/GetAutoexecJobCreatePayloadApi.java index 5b4adfd5374ac124d66bf6527ef8924a68d81712..c6b56d04c82abb52f3228d300bcaf17e5097eef9 100644 --- a/src/main/java/neatlogic/module/autoexec/api/job/GetAutoexecJobCreatePayloadApi.java +++ b/src/main/java/neatlogic/module/autoexec/api/job/GetAutoexecJobCreatePayloadApi.java @@ -83,7 +83,7 @@ public class GetAutoexecJobCreatePayloadApi extends PrivateApiComponentBase { } IAutoexecJobSourceTypeHandler autoexecJobSourceHandler = AutoexecJobSourceTypeHandlerFactory.getAction(jobSource.getType()); try { - autoexecJobSourceHandler.executeAuthCheck(jobVo, false); + autoexecJobSourceHandler.executeAuthCheck(jobVo); }catch (DeployJobCannotExecuteException exception){ throw new PermissionDeniedException(exception.getMessage()); } diff --git a/src/main/java/neatlogic/module/autoexec/api/job/action/AbortAutoexecJobApi.java b/src/main/java/neatlogic/module/autoexec/api/job/action/AbortAutoexecJobApi.java index ccf606bf13b200a0154969521c49ef91bd533523..36ad692b59494f824a66bc66e24c36a9b56c5b54 100644 --- a/src/main/java/neatlogic/module/autoexec/api/job/action/AbortAutoexecJobApi.java +++ b/src/main/java/neatlogic/module/autoexec/api/job/action/AbortAutoexecJobApi.java @@ -80,7 +80,6 @@ public class AbortAutoexecJobApi extends PrivateApiComponentBase { autoexecJobService.getAllSubJobList(jobVo.getId(), autoexecJobVos); for (AutoexecJobVo job : autoexecJobVos) { job.setAction(jobVo.getAction()); - job.setIsTakeOver(jobVo.getIsTakeOver()); autoexecJobService.abortOrPause(job, JobAction.ABORT.getValue(), JobStatus.ABORTING.getValue()); } return null; diff --git a/src/main/java/neatlogic/module/autoexec/api/job/action/CreateAutoexecCombopJobPublicApi.java b/src/main/java/neatlogic/module/autoexec/api/job/action/CreateAutoexecCombopJobPublicApi.java index c6778650e6970f51f9dc7581641bb0cca9d652db..65b9f0b354fb80aa8dfd5246ac73de746c119e28 100644 --- a/src/main/java/neatlogic/module/autoexec/api/job/action/CreateAutoexecCombopJobPublicApi.java +++ b/src/main/java/neatlogic/module/autoexec/api/job/action/CreateAutoexecCombopJobPublicApi.java @@ -37,7 +37,6 @@ import neatlogic.framework.common.constvalue.ApiParamType; import neatlogic.framework.common.constvalue.systemuser.SystemUser; import neatlogic.framework.crossover.CrossoverServiceFactory; import neatlogic.framework.dao.mapper.UserMapper; -import neatlogic.framework.dao.mapper.runner.RunnerMapper; import neatlogic.framework.dto.AuthenticationInfoVo; import neatlogic.framework.dto.UserVo; import neatlogic.framework.exception.user.UserNotFoundException; @@ -83,9 +82,6 @@ public class CreateAutoexecCombopJobPublicApi extends PrivateApiComponentBase { @Resource private AuthenticationInfoService authenticationInfoService; - @Resource - private RunnerMapper runnerMapper; - @Override public String getName() { return "nmaaja.createautoexecjobfromcomboppublicapi.getname"; @@ -119,6 +115,27 @@ public class CreateAutoexecCombopJobPublicApi extends PrivateApiComponentBase { @ResubmitInterval(value = 2) @Override public Object myDoService(JSONObject jsonObj) throws Exception { + String execUserUuid = jsonObj.getString("assignExecUser"); + if (StringUtils.isBlank(execUserUuid)) { + execUserUuid = UserContext.get().getUserUuid(); + } + UserVo execUser; + AuthenticationInfoVo authenticationInfoVo; + if (Objects.equals(SystemUser.SYSTEM.getUserUuid(), execUserUuid)) { + execUser = SystemUser.SYSTEM.getUserVo(); + authenticationInfoVo = SystemUser.SYSTEM.getAuthenticationInfoVo(); + } else if (Objects.equals(neatlogic.framework.autoexec.constvalue.SystemUser.AUTOEXEC.getUserUuid(), execUserUuid)) { + //autoexec脚本用的是autoexec虚拟用户 + execUser = neatlogic.framework.autoexec.constvalue.SystemUser.AUTOEXEC.getUserVo(); + authenticationInfoVo = neatlogic.framework.autoexec.constvalue.SystemUser.AUTOEXEC.getAuthenticationInfoVo(); + } else { + execUser = userMapper.getUserByUser(execUserUuid); + if (execUser == null) { + throw new UserNotFoundException(execUserUuid); + } + authenticationInfoVo = authenticationInfoService.getAuthenticationInfo(execUserUuid); + } + UserContext.init(execUser, authenticationInfoVo, SystemUser.SYSTEM.getTimezone()); String combopName = jsonObj.getString("combopName"); AutoexecCombopVo combopVo = combopMapper.getAutoexecCombopByName(combopName); if (combopVo == null) { @@ -134,21 +151,9 @@ public class CreateAutoexecCombopJobPublicApi extends PrivateApiComponentBase { } AutoexecCombopVersionConfigVo versionConfig = autoexecCombopVersionVo.getConfig(); - String assignExecUser = UserContext.get().getUserUuid(); - String assignExecUserParam = jsonObj.getString("assignExecUser"); - if (StringUtils.isNotBlank(assignExecUserParam)) { - UserVo assignUserTmp = userMapper.getUserByUser(assignExecUserParam); - if (assignUserTmp != null) { - assignExecUser = assignUserTmp.getUuid(); - AuthenticationInfoVo authenticationInfo = authenticationInfoService.getAuthenticationInfo(assignExecUser); - UserContext.init(assignUserTmp, authenticationInfo, SystemUser.SYSTEM.getTimezone()); - } else { - throw new UserNotFoundException(assignExecUserParam); - } - } JSONObject param = jsonObj.getJSONObject("param"); jsonObj.put("param", initParam(param, versionConfig)); - jsonObj.put("assignExecUser", assignExecUser); + jsonObj.put("execUser", execUserUuid); jsonObj.put("operationType", CombopOperationType.COMBOP.getValue()); jsonObj.put("source", JobSource.COMBOP.getValue()); jsonObj.put("operationId", combopVo.getId()); diff --git a/src/main/java/neatlogic/module/autoexec/api/job/action/PauseAutoexecJobApi.java b/src/main/java/neatlogic/module/autoexec/api/job/action/PauseAutoexecJobApi.java index a6ca432c962c1faf20972f5a340e2de5fc808e2c..ea486687fa09c376c59f852bf1005e86527dd164 100644 --- a/src/main/java/neatlogic/module/autoexec/api/job/action/PauseAutoexecJobApi.java +++ b/src/main/java/neatlogic/module/autoexec/api/job/action/PauseAutoexecJobApi.java @@ -80,7 +80,6 @@ public class PauseAutoexecJobApi extends PrivateApiComponentBase { autoexecJobService.getAllSubJobList(jobVo.getId(), autoexecJobVos); for (AutoexecJobVo job : autoexecJobVos) { job.setAction(jobVo.getAction()); - job.setIsTakeOver(jobVo.getIsTakeOver()); autoexecJobService.abortOrPause(jobVo,JobAction.PAUSE.getValue(), JobStatus.PAUSING.getValue()); } return null; diff --git a/src/main/java/neatlogic/module/autoexec/api/job/action/TakeOverAutoexecJobApi.java b/src/main/java/neatlogic/module/autoexec/api/job/action/TakeOverAutoexecJobApi.java index f487077f7d0b01cb78ba6a7b8f3cd285b8fc83f3..e8b4dc5b3e433af8354fa4b740f637b3b4f3eedb 100644 --- a/src/main/java/neatlogic/module/autoexec/api/job/action/TakeOverAutoexecJobApi.java +++ b/src/main/java/neatlogic/module/autoexec/api/job/action/TakeOverAutoexecJobApi.java @@ -78,7 +78,6 @@ public class TakeOverAutoexecJobApi extends PrivateApiComponentBase { return null; } jobVo.setAction(JobAction.TAKE_OVER.getValue()); - jobVo.setIsTakeOver(1); autoexecJobService.batchExecuteJobAction(jobVo, JobAction.TAKE_OVER); return null; } diff --git a/src/main/java/neatlogic/module/autoexec/job/source/action/AutoexecJobSourceTypeHandler.java b/src/main/java/neatlogic/module/autoexec/job/source/action/AutoexecJobSourceTypeHandler.java index 37f6f156b88697d7e1fc402461de50f918a5e96f..2140e402f7d8d92791279ef38183ee31efc420cb 100644 --- a/src/main/java/neatlogic/module/autoexec/job/source/action/AutoexecJobSourceTypeHandler.java +++ b/src/main/java/neatlogic/module/autoexec/job/source/action/AutoexecJobSourceTypeHandler.java @@ -543,16 +543,15 @@ public class AutoexecJobSourceTypeHandler extends AutoexecJobSourceTypeHandlerBa //先校验有没有组合工具权限 if (Objects.equals(jobVo.getOperationType(), CombopOperationType.COMBOP.getValue())) { AutoexecCombopVo combopVo = autoexecCombopMapper.getAutoexecCombopById(jobVo.getOperationId()); - if (combopVo == null && jobVo.getIsTakeOver() == 0) { + if (combopVo == null) { throw new AutoexecCombopNotFoundException(jobVo.getOperationId()); } - if (combopVo != null && !Objects.equals(combopVo.getOwner(), jobVo.getExecUser()) && !autoexecCombopService.checkOperableButton(combopVo, CombopAuthorityAction.EXECUTE)) { + if (!Objects.equals(combopVo.getOwner(), jobVo.getExecUser()) && !autoexecCombopService.checkOperableButton(combopVo, CombopAuthorityAction.EXECUTE)) { throw new AutoexecJobCanNotCreateException(combopVo.getName()); } - } else if (Arrays.asList(CombopOperationType.SCRIPT.getValue(), CombopOperationType.TOOL.getValue()).contains(jobVo.getOperationType())) { - if (!AuthActionChecker.check(AUTOEXEC_SCRIPT_MODIFY.class.getSimpleName())) { - throw new AutoexecScriptJobCanNotExecuteException(jobVo.getId()); - } + } else if (Arrays.asList(CombopOperationType.SCRIPT.getValue(), CombopOperationType.TOOL.getValue()).contains(jobVo.getOperationType()) + && Boolean.FALSE.equals(AuthActionChecker.check(AUTOEXEC_SCRIPT_MODIFY.class.getSimpleName()))) { + throw new AutoexecScriptJobCanNotExecuteException(jobVo.getId()); } } @@ -566,7 +565,7 @@ public class AutoexecJobSourceTypeHandler extends AutoexecJobSourceTypeHandlerBa if (Objects.equals(jobVo.getSource(), JobSource.TEST.getValue()) || Objects.equals(jobVo.getSource(), JobSource.SCRIPT_TEST.getValue()) || Objects.equals(jobVo.getSource(), JobSource.TOOL_TEST.getValue())) { - if (AuthActionChecker.check(AUTOEXEC_SCRIPT_MODIFY.class)) { + if (Boolean.TRUE.equals(AuthActionChecker.check(AUTOEXEC_SCRIPT_MODIFY.class))) { if (UserContext.get().getUserUuid().equals(jobVo.getExecUser())) { jobVo.setIsCanExecute(1); } else { 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 2a26daad19a73ba8da24d6ea6b8c31971ad41bb2..b5c97e1835efd3b8da51a88778e92fc5832c6de8 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 @@ -292,21 +292,21 @@ public class CreateJobProcessComponent extends ProcessStepHandlerBase { processTaskStepComplete(processTaskStepVo.getId()); return; } - String assignExecUser = SystemUser.SYSTEM.getUserUuid(); + String execUser = SystemUser.SYSTEM.getUserUuid(); IProcessStepHandlerCrossoverUtil processStepHandlerCrossoverUtil = CrossoverServiceFactory.getApi(IProcessStepHandlerCrossoverUtil.class); ProcessTaskStepAssignVo processTaskStepAssignVo = processStepHandlerCrossoverUtil.analysisAssignConfig(processTaskStepVo); List finalStepWorkerList = processTaskStepAssignVo.getFinalStepWorkerList(); if (CollectionUtils.isNotEmpty(finalStepWorkerList)) { for (ProcessTaskStepWorkerVo processTaskStepWorkerVo : finalStepWorkerList) { if (Objects.equals(processTaskStepWorkerVo.getType(), GroupSearch.USER.getValue())) { - assignExecUser = processTaskStepWorkerVo.getUuid(); + execUser = processTaskStepWorkerVo.getUuid(); break; } } } UserContext userContext = null; // 如果作业的执行用户不是当前用户,创建作业的时候会切换用户上下文,这里先复制一份当前的用户上下文,等作业创建完成后再切回当前用户上下文 - if (!Objects.equals(assignExecUser, UserContext.get().getUserUuid())) { + if (!Objects.equals(execUser, UserContext.get().getUserUuid())) { userContext = UserContext.get().copy(); } JSONArray errorMessageList = new JSONArray(); @@ -318,7 +318,7 @@ public class CreateJobProcessComponent extends ProcessStepHandlerBase { jobVo.setInvokeId(processTaskStepVo.getId()); jobVo.setRouteId(processTaskStepVo.getId().toString()); jobVo.setSource(AutoExecJobProcessSource.ITSM.getValue()); - jobVo.setAssignExecUser(assignExecUser); + jobVo.setExecUser(execUser); try { autoexecJobActionService.validateCreateJob(jobVo); autoexecJobMapper.insertAutoexecJobProcessTaskStep(jobVo.getId(), processTaskStepVo.getId()); diff --git a/src/main/java/neatlogic/module/autoexec/schedule/plugin/AutoexecScheduleJob.java b/src/main/java/neatlogic/module/autoexec/schedule/plugin/AutoexecScheduleJob.java index 3fd328f6b0f5ef0ae3c8cf9ae2af07fd4e1c824c..558a29f8ddaf801b07938ffdf24a9ac90d54ff3f 100644 --- a/src/main/java/neatlogic/module/autoexec/schedule/plugin/AutoexecScheduleJob.java +++ b/src/main/java/neatlogic/module/autoexec/schedule/plugin/AutoexecScheduleJob.java @@ -41,8 +41,11 @@ import neatlogic.framework.service.AuthenticationInfoService; import neatlogic.module.autoexec.service.AutoexecCombopService; import neatlogic.module.autoexec.service.AutoexecJobActionService; import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; import org.quartz.DisallowConcurrentExecution; import org.quartz.JobExecutionContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import javax.annotation.Resource; @@ -56,7 +59,7 @@ import java.util.Objects; @Component @DisallowConcurrentExecution public class AutoexecScheduleJob extends JobBase { - + static Logger logger = LoggerFactory.getLogger(AutoexecScheduleJob.class); @Resource private AutoexecScheduleMapper autoexecScheduleMapper; @Resource @@ -153,10 +156,19 @@ public class AutoexecScheduleJob extends JobBase { jobVo.setInvokeId(autoexecScheduleVo.getId()); jobVo.setRouteId(autoexecScheduleVo.getId().toString()); jobVo.setOperationType(CombopOperationType.COMBOP.getValue()); - UserVo lcuVo = userMapper.getUserByUuid(autoexecScheduleVo.getLcu()); + String execUserUuid = autoexecScheduleVo.getLcu(); + if (jobObject.isTest() == 1 && StringUtils.isNotBlank(jobObject.getTestUserUuid())) { + execUserUuid = jobObject.getTestUserUuid(); + } + UserVo execUser = userMapper.getUserBaseInfoByUuid(execUserUuid); + if (execUser == null) { + schedulerManager.unloadJob(jobObject); + logger.error("execUser: {} not exist!", execUserUuid); + return; + } AuthenticationInfoVo authenticationInfoVo = authenticationInfoService.getAuthenticationInfo(autoexecScheduleVo.getFcu()); - UserContext.init(lcuVo, authenticationInfoVo, SystemUser.SYSTEM.getTimezone()); - UserContext.get().setToken("GZIP_" + LoginAuthHandlerBase.buildJwt(lcuVo).getCc()); + UserContext.init(execUser, authenticationInfoVo, SystemUser.SYSTEM.getTimezone()); + UserContext.get().setToken("GZIP_" + LoginAuthHandlerBase.buildJwt(execUser).getCc()); autoexecJobActionService.validateAndCreateJobFromCombop(jobVo); jobVo.setAction(JobAction.FIRE.getValue()); IAutoexecJobActionHandler fireAction = AutoexecJobActionHandlerFactory.getAction(JobAction.FIRE.getValue()); diff --git a/src/main/java/neatlogic/module/autoexec/service/AutoexecJobActionServiceImpl.java b/src/main/java/neatlogic/module/autoexec/service/AutoexecJobActionServiceImpl.java index 658a12238464bd9951f9cb457bb707ba9f6cae48..6629e5f7fa5cf7910a6e197af99a021dfef942c4 100644 --- a/src/main/java/neatlogic/module/autoexec/service/AutoexecJobActionServiceImpl.java +++ b/src/main/java/neatlogic/module/autoexec/service/AutoexecJobActionServiceImpl.java @@ -459,7 +459,7 @@ public class AutoexecJobActionServiceImpl implements AutoexecJobActionService, I IAutoexecJobSourceTypeHandler autoexecJobSourceActionHandler = AutoexecJobSourceTypeHandlerFactory.getAction(jobSource.getType()); AutoexecCombopVo combopVo = autoexecJobSourceActionHandler.getAutoexecCombop(autoexecJobParam); //作业执行权限校验 - autoexecJobSourceActionHandler.executeAuthCheck(autoexecJobParam, false); + autoexecJobSourceActionHandler.executeAuthCheck(autoexecJobParam); //设置作业执行节点 AutoexecCombopConfigVo config = combopVo.getConfig(); if (config == null) { @@ -564,10 +564,10 @@ public class AutoexecJobActionServiceImpl implements AutoexecJobActionService, I validateAndCreateJobFromCombop(jobParam); UserVo user = SystemUser.SYSTEM.getUserVo(); AuthenticationInfoVo authenticationInfo = SystemUser.SYSTEM.getAuthenticationInfoVo(); - if (!Objects.equals(jobParam.getAssignExecUser(), SystemUser.SYSTEM.getUserUuid())) { - user = userMapper.getUserByUuid(jobParam.getAssignExecUser()); + if (!Objects.equals(jobParam.getExecUser(), SystemUser.SYSTEM.getUserUuid())) { + user = userMapper.getUserByUuid(jobParam.getExecUser()); if (user == null) { - throw new UserNotFoundException(jobParam.getAssignExecUser()); + throw new UserNotFoundException(jobParam.getExecUser()); } authenticationInfo = authenticationInfoService.getAuthenticationInfo(user.getUuid()); } diff --git a/src/main/java/neatlogic/module/autoexec/service/AutoexecJobService.java b/src/main/java/neatlogic/module/autoexec/service/AutoexecJobService.java index 0bc53d797335723635936177716153cc0ca81890..98081b5bbf390648711693a916801292985935c5 100644 --- a/src/main/java/neatlogic/module/autoexec/service/AutoexecJobService.java +++ b/src/main/java/neatlogic/module/autoexec/service/AutoexecJobService.java @@ -341,4 +341,6 @@ public interface AutoexecJobService { String updatePartialNodeJobAndPhaseWithRunnerId(AutoexecJobPhaseVo jobPhaseVo, Long runnerId, AutoexecJobVo jobVo, String currentPhaseStatus, Integer phaseRunnerWarnCount); + + } diff --git a/src/main/java/neatlogic/module/autoexec/service/AutoexecJobServiceImpl.java b/src/main/java/neatlogic/module/autoexec/service/AutoexecJobServiceImpl.java index c4b2087aa0d3bc2cb00830b2d64d9da837bea636..504d789e8cd6a0ae30cb46014e61b22897969e84 100644 --- a/src/main/java/neatlogic/module/autoexec/service/AutoexecJobServiceImpl.java +++ b/src/main/java/neatlogic/module/autoexec/service/AutoexecJobServiceImpl.java @@ -1810,9 +1810,8 @@ public class AutoexecJobServiceImpl implements AutoexecJobService, IAutoexecJobC getAllSubJobList(jobVo.getId(), autoexecJobVos); for (AutoexecJobVo job : autoexecJobVos) { job.setAction(jobVo.getAction()); - job.setIsTakeOver(jobVo.getIsTakeOver()); - IAutoexecJobActionHandler refireAction = AutoexecJobActionHandlerFactory.getAction(jobAction.getValue()); - refireAction.doService(job); + IAutoexecJobActionHandler batchAction = AutoexecJobActionHandlerFactory.getAction(jobAction.getValue()); + batchAction.doService(job); } } diff --git a/src/main/java/neatlogic/module/autoexec/stephandler/component/AutoexecProcessComponent.java b/src/main/java/neatlogic/module/autoexec/stephandler/component/AutoexecProcessComponent.java deleted file mode 100644 index 0819dba1fd8a3525cb2f6920e6e71e04d909a271..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/module/autoexec/stephandler/component/AutoexecProcessComponent.java +++ /dev/null @@ -1,1714 +0,0 @@ -/*Copyright (C) $today.year 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.module.autoexec.stephandler.component; - -import com.alibaba.fastjson.*; -import neatlogic.framework.asynchronization.threadlocal.UserContext; -import neatlogic.framework.autoexec.constvalue.*; -import neatlogic.framework.autoexec.dao.mapper.AutoexecJobMapper; -import neatlogic.framework.autoexec.dto.combop.AutoexecCombopExecuteConfigVo; -import neatlogic.framework.autoexec.dto.combop.AutoexecCombopExecuteNodeConfigVo; -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.node.AutoexecNodeVo; -import neatlogic.framework.autoexec.dto.scenario.AutoexecScenarioVo; -import neatlogic.framework.cmdb.crossover.IResourceAccountCrossoverMapper; -import neatlogic.framework.cmdb.dto.resourcecenter.AccountProtocolVo; -import neatlogic.framework.cmdb.enums.FormHandler; -import neatlogic.framework.common.constvalue.Expression; -import neatlogic.framework.common.constvalue.systemuser.SystemUser; -import neatlogic.framework.crossover.CrossoverServiceFactory; -import neatlogic.framework.dao.mapper.runner.RunnerMapper; -import neatlogic.framework.dto.runner.RunnerGroupVo; -import neatlogic.framework.file.dao.mapper.FileMapper; -import neatlogic.framework.file.dto.FileVo; -import neatlogic.framework.form.attribute.core.FormAttributeDataConversionHandlerFactory; -import neatlogic.framework.form.attribute.core.IFormAttributeDataConversionHandler; -import neatlogic.framework.form.dto.AttributeDataVo; -import neatlogic.framework.form.dto.FormAttributeVo; -import neatlogic.framework.notify.core.INotifyParamHandler; -import neatlogic.framework.notify.core.NotifyParamHandlerFactory; -import neatlogic.framework.process.condition.core.ProcessTaskConditionFactory; -import neatlogic.framework.process.constvalue.*; -import neatlogic.framework.process.crossover.*; -import neatlogic.framework.process.dto.ProcessTaskFormAttributeDataVo; -import neatlogic.framework.process.dto.ProcessTaskStepDataVo; -import neatlogic.framework.process.dto.ProcessTaskStepVo; -import neatlogic.framework.process.dto.ProcessTaskStepWorkerVo; -import neatlogic.framework.process.exception.processtask.ProcessTaskException; -import neatlogic.framework.process.exception.processtask.ProcessTaskNoPermissionException; -import neatlogic.framework.process.notify.constvalue.ProcessTaskNotifyParam; -import neatlogic.framework.process.notify.constvalue.ProcessTaskStepNotifyParam; -import neatlogic.framework.process.notify.constvalue.ProcessTaskStepNotifyTriggerType; -import neatlogic.framework.process.stephandler.core.IProcessStepHandler; -import neatlogic.framework.process.stephandler.core.ProcessStepHandlerBase; -import neatlogic.framework.process.stephandler.core.ProcessStepHandlerFactory; -import neatlogic.framework.process.stephandler.core.ProcessStepThread; -import neatlogic.framework.util.FormUtil; -import neatlogic.framework.util.FreemarkerUtil; -import neatlogic.module.autoexec.constvalue.FailPolicy; -import neatlogic.module.autoexec.dao.mapper.AutoexecScenarioMapper; -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 org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.annotation.Resource; -import java.util.*; -import java.util.stream.Collectors; - -/** - * @author linbq - * @since 2021/9/2 14:22 - **/ -//@Service -@Deprecated -public class AutoexecProcessComponent extends ProcessStepHandlerBase { - - private final static Logger logger = LoggerFactory.getLogger(AutoexecProcessComponent.class); - -// private final String FORM_EXTEND_ATTRIBUTE_TAG = "common"; - @Resource - private AutoexecJobMapper autoexecJobMapper; - - @Resource - private AutoexecJobActionService autoexecJobActionService; - - @Resource - private AutoexecScenarioMapper autoexecScenarioMapper; - - @Resource - private RunnerMapper runnerMapper; - - @Resource - private FileMapper fileMapper; - - - @Override - public String getHandler() { - return AutoexecProcessStepHandlerType.AUTOEXEC.getHandler(); - } - - @Override - public JSONObject getChartConfig() { - return new JSONObject() { - { - this.put("icon", "tsfont-zidonghua"); - this.put("shape", "L-rectangle:R-rectangle"); - this.put("width", 68); - this.put("height", 40); - } - }; - } - - @Override - public String getType() { - return AutoexecProcessStepHandlerType.AUTOEXEC.getType(); - } - - @Override - public ProcessStepMode getMode() { - return ProcessStepMode.MT; - } - - @Override - public String getName() { - return AutoexecProcessStepHandlerType.AUTOEXEC.getName(); - } - - @Override - public int getSort() { - return 10; - } - - @Override - public boolean isAsync() { - return false; - } - - @Override - public Boolean isAllowStart() { - return false; - } - - @Override - protected int myActive(ProcessTaskStepVo currentProcessTaskStepVo) throws ProcessTaskException { - IProcessTaskCrossoverMapper processTaskCrossoverMapper = CrossoverServiceFactory.getApi(IProcessTaskCrossoverMapper.class); - ISelectContentByHashCrossoverMapper selectContentByHashCrossoverMapper = CrossoverServiceFactory.getApi(ISelectContentByHashCrossoverMapper.class); - IProcessTaskStepDataCrossoverMapper processTaskStepDataCrossoverMapper = CrossoverServiceFactory.getApi(IProcessTaskStepDataCrossoverMapper.class); - try { - String configHash = currentProcessTaskStepVo.getConfigHash(); - if (StringUtils.isBlank(configHash)) { - ProcessTaskStepVo processTaskStepVo = processTaskCrossoverMapper.getProcessTaskStepBaseInfoById(currentProcessTaskStepVo.getId()); - configHash = processTaskStepVo.getConfigHash(); - currentProcessTaskStepVo.setProcessStepUuid(processTaskStepVo.getProcessStepUuid()); - } - // 获取工单当前步骤配置信息 - String config = selectContentByHashCrossoverMapper.getProcessTaskStepConfigByHash(configHash); -// if (StringUtils.isNotBlank(config)) { -// JSONObject autoexecConfig = (JSONObject) JSONPath.read(config, "autoexecConfig"); -// if (MapUtils.isNotEmpty(autoexecConfig)) { -// AutoexecJobVo jobVo = createAutoexecJobVo(currentProcessTaskStepVo, autoexecConfig); -// Long autoexecJobId = autoexecJobMapper.getJobIdByInvokeIdLimitOne(currentProcessTaskStepVo.getId()); -// //如果工单步骤ID没有绑定自动化作业ID,则需要创建自动化作业 -// if (autoexecJobId == null) { -// try { -// autoexecJobActionService.validateCreateJob(jobVo); -// } catch (Exception e) { -// logger.error(e.getMessage(), e); -// String failPolicy = autoexecConfig.getString("failPolicy"); -// if (FailPolicy.KEEP_ON.getValue().equals(failPolicy)) { -// processTaskStepComplete(currentProcessTaskStepVo.getId(), null); -// } -// } -// } else {//否则重新刷新作业运行参数,以及节点后,需人工干预重跑作业 -// autoexecJobService.refreshJobParam(autoexecJobId, jobVo.getParam()); -// autoexecJobService.refreshJobNodeList(autoexecJobId, jobVo.getExecuteConfig()); -// } -// } -// } - if (StringUtils.isBlank(config)) { - processTaskStepComplete(currentProcessTaskStepVo.getId(), null); - return 0; - } - JSONObject autoexecConfig = (JSONObject) JSONPath.read(config, "autoexecConfig"); - if (MapUtils.isEmpty(autoexecConfig)) { - processTaskStepComplete(currentProcessTaskStepVo.getId(), null); - return 0; - } - // rerunStepToCreateNewJob为1时表示重新激活自动化步骤时创建新作业,rerunStepToCreateNewJob为0时表示重新激活自动化步骤时不创建新作业,也不重跑旧作业,即什么都不做 - Integer rerunStepToCreateNewJob = autoexecConfig.getInteger("rerunStepToCreateNewJob"); - if (!Objects.equals(rerunStepToCreateNewJob, 1)) { - Long autoexecJobId = autoexecJobMapper.getJobIdByInvokeIdLimitOne(currentProcessTaskStepVo.getId()); - if (autoexecJobId != null) { - processTaskStepComplete(currentProcessTaskStepVo.getId(), null); - return 1; - } - } - autoexecJobMapper.deleteAutoexecJobByProcessTaskStepId(currentProcessTaskStepVo.getId()); - // 删除上次创建作业的报错信息 - ProcessTaskStepDataVo processTaskStepData = new ProcessTaskStepDataVo(); - processTaskStepData.setProcessTaskId(currentProcessTaskStepVo.getProcessTaskId()); - processTaskStepData.setProcessTaskStepId(currentProcessTaskStepVo.getId()); - processTaskStepData.setType("autoexecCreateJobError"); - processTaskStepDataCrossoverMapper.deleteProcessTaskStepData(processTaskStepData); - JSONArray configList = autoexecConfig.getJSONArray("configList"); - if (CollectionUtils.isEmpty(configList)) { - processTaskStepComplete(currentProcessTaskStepVo.getId(), null); - return 0; - } - JSONArray errorMessageList = new JSONArray(); - boolean flag = false; - List jobIdList = new ArrayList<>(); - for (int i = 0; i < configList.size(); i++) { - JSONObject configObj = configList.getJSONObject(i); - if (MapUtils.isEmpty(configObj)) { - continue; - } - // 根据配置信息创建AutoexecJobVo对象 - List autoexecJobList = createAutoexecJobList(currentProcessTaskStepVo, configObj); - if (CollectionUtils.isEmpty(autoexecJobList)) { - continue; - } - for (AutoexecJobVo jobVo : autoexecJobList) { - try { - autoexecJobActionService.validateCreateJob(jobVo); - autoexecJobMapper.insertAutoexecJobProcessTaskStep(jobVo.getId(), currentProcessTaskStepVo.getId()); - jobIdList.add(jobVo.getId()); - } catch (Exception e) { - // 增加提醒 - logger.error(e.getMessage(), e); - JSONObject jobObj = new JSONObject(); - jobObj.put("param", jobVo.getParam()); - jobObj.put("scenarioId", jobVo.getScenarioId()); - jobObj.put("executeConfig", jobVo.getExecuteConfig()); - jobObj.put("runnerGroup", jobVo.getRunnerGroup()); - jobObj.put("id", jobVo.getId()); - jobObj.put("name", jobVo.getName()); - jobObj.put("source", jobVo.getSource()); - jobObj.put("roundCount", jobVo.getRoundCount()); - jobObj.put("operationId", jobVo.getOperationId()); - jobObj.put("operationType", jobVo.getOperationType()); - jobObj.put("invokeId", jobVo.getInvokeId()); - jobObj.put("routeId", jobVo.getRouteId()); - jobObj.put("assignExecUser", jobVo.getAssignExecUser()); - logger.error(jobObj.toJSONString()); - JSONObject errorMessageObj = new JSONObject(); - errorMessageObj.put("jobId", jobVo.getId()); - errorMessageObj.put("jobName", jobVo.getName()); - errorMessageObj.put("error", e.getMessage() + " jobVo=" + jobObj.toJSONString()); - errorMessageList.add(errorMessageObj); - flag = true; - } - } - } - - // 如果有一个作业创建有异常,则根据失败策略执行操作 - if (flag) { - ProcessTaskStepDataVo processTaskStepDataVo = new ProcessTaskStepDataVo(); - processTaskStepDataVo.setProcessTaskId(currentProcessTaskStepVo.getProcessTaskId()); - processTaskStepDataVo.setProcessTaskStepId(currentProcessTaskStepVo.getId()); - processTaskStepDataVo.setType("autoexecCreateJobError"); - JSONObject dataObj = new JSONObject(); - dataObj.put("errorList", errorMessageList); - processTaskStepDataVo.setData(dataObj.toJSONString()); - processTaskStepDataVo.setFcu(UserContext.get().getUserUuid()); - processTaskStepDataCrossoverMapper.replaceProcessTaskStepData(processTaskStepDataVo); - String failPolicy = autoexecConfig.getString("failPolicy"); - if (FailPolicy.KEEP_ON.getValue().equals(failPolicy)) { - if (CollectionUtils.isNotEmpty(jobIdList)) { - int running = 0; - List autoexecJobList = autoexecJobMapper.getJobListByIdList(jobIdList); - for (AutoexecJobVo autoexecJobVo : autoexecJobList) { - if (JobStatus.isRunningStatus(autoexecJobVo.getStatus())) { - running++; - } - } - if (running == 0) { - processTaskStepComplete(currentProcessTaskStepVo.getId(), null); - } - } else { - processTaskStepComplete(currentProcessTaskStepVo.getId(), null); - } - } else { - IProcessStepHandler processStepHandler = ProcessStepHandlerFactory.getHandler(currentProcessTaskStepVo.getHandler()); - if (processStepHandler != null) { - try { - processStepHandler.assign(currentProcessTaskStepVo); - } catch (ProcessTaskException e) { - logger.error(e.getMessage(), e); - } - } - } - IProcessStepHandlerCrossoverUtil processStepHandlerCrossoverUtil = CrossoverServiceFactory.getApi(IProcessStepHandlerCrossoverUtil.class); - /* 触发通知 **/ - processStepHandlerCrossoverUtil.notify(currentProcessTaskStepVo, AutoexecNotifyTriggerType.CREATE_JOB_FAILED); - } else if (CollectionUtils.isEmpty(jobIdList)) { - processTaskStepComplete(currentProcessTaskStepVo.getId(), null); - } - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new ProcessTaskException(e); - } - return 1; - } - - /** - * 根据工单步骤配置信息创建AutoexecJobVo对象 - * - * @param currentProcessTaskStepVo - * @param autoexecConfig - * @return - */ - private List createAutoexecJobList(ProcessTaskStepVo currentProcessTaskStepVo, JSONObject autoexecConfig) { - IProcessTaskCrossoverMapper processTaskCrossoverMapper = CrossoverServiceFactory.getApi(IProcessTaskCrossoverMapper.class); - ISelectContentByHashCrossoverMapper selectContentByHashCrossoverMapper = CrossoverServiceFactory.getApi(ISelectContentByHashCrossoverMapper.class); - Map processTaskFormAttributeDataMap = new HashMap<>(); - Map formAttributeMap = new HashMap<>(); - Long processTaskId = currentProcessTaskStepVo.getProcessTaskId(); - // 如果工单有表单信息,则查询出表单配置及数据 -// ProcessTaskFormVo processTaskFormVo = processTaskCrossoverMapper.getProcessTaskFormByProcessTaskId(processTaskId); -// if (processTaskFormVo != null) { -// String formContent = selectContentByHashCrossoverMapper.getProcessTaskFromContentByHash(processTaskFormVo.getFormContentHash()); -// FormVersionVo formVersionVo = new FormVersionVo(); -// formVersionVo.setFormUuid(processTaskFormVo.getFormUuid()); -// formVersionVo.setFormName(processTaskFormVo.getFormName()); -// formVersionVo.setFormConfig(JSON.parseObject(formContent)); -// List formAttributeList = formVersionVo.getFormAttributeList(); -// if (CollectionUtils.isNotEmpty(formAttributeList)) { -// formAttributeMap = formAttributeList.stream().collect(Collectors.toMap(e -> e.getUuid(), e -> e)); -// } -// IProcessTaskCrossoverService processTaskCrossoverService = CrossoverServiceFactory.getApi(IProcessTaskCrossoverService.class); -// List processTaskFormAttributeDataList = processTaskCrossoverService.getProcessTaskFormAttributeDataListByProcessTaskId(processTaskId); -// if (CollectionUtils.isNotEmpty(processTaskFormAttributeDataList)) { -// processTaskFormAttributeDataMap = processTaskFormAttributeDataList.stream().collect(Collectors.toMap(e -> e.getAttributeUuid(), e -> e)); -// } -// } - String formTag = autoexecConfig.getString("formTag"); - IProcessTaskCrossoverService processTaskCrossoverService = CrossoverServiceFactory.getApi(IProcessTaskCrossoverService.class); -// List formAttributeList = processTaskCrossoverService.getFormAttributeListByProcessTaskIdAngTag(processTaskId, FORM_EXTEND_ATTRIBUTE_TAG); - List formAttributeList = processTaskCrossoverService.getFormAttributeListByProcessTaskIdAngTagNew(processTaskId, formTag); - if (CollectionUtils.isNotEmpty(formAttributeList)) { -// List processTaskFormAttributeDataList = processTaskCrossoverService.getProcessTaskFormAttributeDataListByProcessTaskIdAndTag(processTaskId, FORM_EXTEND_ATTRIBUTE_TAG); - List processTaskFormAttributeDataList = processTaskCrossoverService.getProcessTaskFormAttributeDataListByProcessTaskIdAndTagNew(processTaskId, formTag); - // 添加表格组件中的子组件到组件列表中 - for (FormAttributeVo formAttributeVo : formAttributeList) { - formAttributeMap.put(formAttributeVo.getUuid(), formAttributeVo); - JSONObject componentObj = new JSONObject(); - componentObj.put("handler", formAttributeVo.getHandler()); - componentObj.put("uuid", formAttributeVo.getUuid()); - componentObj.put("label", formAttributeVo.getLabel()); - componentObj.put("config", formAttributeVo.getConfig()); - componentObj.put("type", formAttributeVo.getType()); - List downwardFormAttributeList = FormUtil.getFormAttributeList(componentObj, null); - for (FormAttributeVo downwardFormAttribute : downwardFormAttributeList) { - if (Objects.equals(formAttributeVo.getUuid(), downwardFormAttribute.getUuid())) { - continue; - } - formAttributeMap.put(downwardFormAttribute.getUuid(), downwardFormAttribute); - } - } - for (ProcessTaskFormAttributeDataVo attributeDataVo : processTaskFormAttributeDataList) { - FormAttributeVo formAttributeVo = formAttributeMap.get(attributeDataVo.getAttributeUuid()); - if (formAttributeVo != null) { - IFormAttributeDataConversionHandler formAttributeDataConversionHandler = FormAttributeDataConversionHandlerFactory.getHandler(formAttributeVo.getHandler()); - if (formAttributeDataConversionHandler != null) { - Object simpleValue = formAttributeDataConversionHandler.getSimpleValue(attributeDataVo.getDataObj()); - attributeDataVo.setDataObj(simpleValue); - } - } - } - processTaskFormAttributeDataMap = processTaskFormAttributeDataList.stream().collect(Collectors.toMap(e -> e.getAttributeUuid(), e -> e)); - } - - JSONObject processTaskParam = ProcessTaskConditionFactory.getConditionParamData(Arrays.stream(ConditionProcessTaskOptions.values()).map(ConditionProcessTaskOptions::getValue).collect(Collectors.toList()), currentProcessTaskStepVo); - // 作业策略createJobPolicy为single时表示单次创建作业,createJobPolicy为batch时表示批量创建作业 - String createJobPolicy = autoexecConfig.getString("createJobPolicy"); - if (Objects.equals(createJobPolicy, "single")) { - AutoexecJobVo jobVo = createSingleAutoexecJobVo(currentProcessTaskStepVo, autoexecConfig, formAttributeMap, processTaskFormAttributeDataMap, processTaskParam); - jobVo.setRunnerGroup(getRunnerGroup(jobVo.getParam(), autoexecConfig)); - List resultList = new ArrayList<>(); - resultList.add(jobVo); - return resultList; - } else if (Objects.equals(createJobPolicy, "batch")) { - List jobVoList = createBatchAutoexecJobVo(currentProcessTaskStepVo, autoexecConfig, formAttributeMap, processTaskFormAttributeDataMap, processTaskParam); - if (CollectionUtils.isNotEmpty(jobVoList)) { - jobVoList.forEach(jobVo -> jobVo.setRunnerGroup(getRunnerGroup(jobVo.getParam(), autoexecConfig))); - } - return jobVoList; - } else { - return null; - } - } - - /** - * 获取执行器组的值 - * - * @param jobParamJson 作业参数的值 - * @param autoexecConfig 流程自动化节点配置 - */ - private ParamMappingVo getRunnerGroup(JSONObject jobParamJson, JSONObject autoexecConfig) { - //执行器组 - ParamMappingVo runnerGroup = new ParamMappingVo(); - JSONObject runnerGroupJson = autoexecConfig.getJSONObject("runnerGroup"); - if (MapUtils.isNotEmpty(runnerGroupJson)) { - String mappingMode = runnerGroupJson.getString("mappingMode"); - String mappingValue = runnerGroupJson.getString("value"); - long runnerGroupId = -1L; - runnerGroup.setMappingMode(ParamMappingMode.CONSTANT.getValue()); - if (Objects.equals(mappingMode, "runtimeparam")) { - mappingValue = jobParamJson.getString(mappingValue); - try { - JSONObject jsonObject = JSON.parseObject(mappingValue); - mappingValue = jsonObject.getString("value"); - } catch (RuntimeException ignored) { - } - } - try { - runnerGroupId = Long.parseLong(mappingValue); - RunnerGroupVo runnerGroupVo = runnerMapper.getRunnerGroupById(runnerGroupId); - if (runnerGroupVo == null) { - runnerGroupVo = runnerMapper.getRunnerGroupByName(mappingValue); - if (runnerGroupVo != null) { - runnerGroupId = runnerGroupVo.getId(); - } - } - } catch (NumberFormatException ex) { - RunnerGroupVo runnerGroupVo = runnerMapper.getRunnerGroupByName(mappingValue); - if (runnerGroupVo != null) { - runnerGroupId = runnerGroupVo.getId(); - } - } - runnerGroup.setValue(runnerGroupId); - } - return runnerGroup; - } - - /** - * 单次创建作业 - * - * @param currentProcessTaskStepVo - * @param autoexecConfig - * @param formAttributeMap - * @param processTaskFormAttributeDataMap - * @param processTaskParam - * @return - */ - private AutoexecJobVo createSingleAutoexecJobVo( - ProcessTaskStepVo currentProcessTaskStepVo, - JSONObject autoexecConfig, - Map formAttributeMap, - Map processTaskFormAttributeDataMap, - JSONObject processTaskParam) { - AutoexecJobVo jobVo = new AutoexecJobVo(); - // 组合工具ID - Long combopId = autoexecConfig.getLong("autoexecCombopId"); - // 作业名称 - String jobName = autoexecConfig.getString("jobName"); - String jobNamePrefixKey = autoexecConfig.getString("jobNamePrefix"); - // 场景 - JSONArray scenarioParamList = autoexecConfig.getJSONArray("scenarioParamList"); - if (CollectionUtils.isNotEmpty(scenarioParamList)) { - Long scenarioId = getScenarioId(scenarioParamList.getJSONObject(0), null, formAttributeMap, processTaskFormAttributeDataMap); - jobVo.setScenarioId(scenarioId); - } - // 作业参数赋值列表 - JSONArray runtimeParamList = autoexecConfig.getJSONArray("runtimeParamList"); - if (CollectionUtils.isNotEmpty(runtimeParamList)) { - JSONObject param = getParam(currentProcessTaskStepVo, runtimeParamList, formAttributeMap, processTaskFormAttributeDataMap, processTaskParam); - jobVo.setParam(param); - } - // 目标参数赋值列表 - JSONArray executeParamList = autoexecConfig.getJSONArray("executeParamList"); - if (CollectionUtils.isNotEmpty(executeParamList)) { - AutoexecCombopExecuteConfigVo executeConfig = getAutoexecCombopExecuteConfig(executeParamList, formAttributeMap, processTaskFormAttributeDataMap); - jobVo.setExecuteConfig(executeConfig); - } - - String jobNamePrefixValue = getJobNamePrefixValue(jobNamePrefixKey, jobVo.getExecuteConfig(), jobVo.getParam()); - jobVo.setSource(AutoExecJobProcessSource.ITSM.getValue()); - jobVo.setOperationId(combopId); - jobVo.setName(jobNamePrefixValue + jobName); - jobVo.setOperationType(CombopOperationType.COMBOP.getValue()); - jobVo.setInvokeId(currentProcessTaskStepVo.getId()); - jobVo.setRouteId(currentProcessTaskStepVo.getId().toString()); - jobVo.setAssignExecUser(SystemUser.SYSTEM.getUserUuid()); - return jobVo; - } - - /** - * 批量创建作业 - * - * @param currentProcessTaskStepVo - * @param autoexecConfig - * @param formAttributeMap - * @param processTaskFormAttributeDataMap - * @param processTaskParam - * @return - */ - private List createBatchAutoexecJobVo( - ProcessTaskStepVo currentProcessTaskStepVo, - JSONObject autoexecConfig, - Map formAttributeMap, - Map processTaskFormAttributeDataMap, - JSONObject processTaskParam) { - // 组合工具ID - Long combopId = autoexecConfig.getLong("autoexecCombopId"); - // 作业名称 - String jobName = autoexecConfig.getString("jobName"); - String jobNamePrefixKey = autoexecConfig.getString("jobNamePrefix"); - List resultList = new ArrayList<>(); - // 批量遍历表格 - JSONObject batchJobDataSource = autoexecConfig.getJSONObject("batchJobDataSource"); - if (MapUtils.isEmpty(batchJobDataSource)) { - return resultList; - } - String attributeUuid = batchJobDataSource.getString("attributeUuid"); - ProcessTaskFormAttributeDataVo formAttributeDataVo = processTaskFormAttributeDataMap.get(attributeUuid); - JSONArray filterList = batchJobDataSource.getJSONArray("filterList"); - JSONArray tbodyList = getTbodyList(formAttributeDataVo, filterList, formAttributeMap); - if (CollectionUtils.isEmpty(tbodyList)) { - return resultList; - } - // 遍历表格数据,创建AutoexecJobVo对象列表 - for (int index = 0; index < tbodyList.size(); index++) { - AutoexecJobVo jobVo = new AutoexecJobVo(); - jobVo.setSource(AutoExecJobProcessSource.ITSM.getValue()); - jobVo.setOperationId(combopId); - jobVo.setOperationType(CombopOperationType.COMBOP.getValue()); - jobVo.setInvokeId(currentProcessTaskStepVo.getId()); - jobVo.setRouteId(currentProcessTaskStepVo.getId().toString()); - jobVo.setAssignExecUser(SystemUser.SYSTEM.getUserUuid()); - JSONObject tbodyObj = tbodyList.getJSONObject(index); - // 场景 - JSONArray scenarioParamList = autoexecConfig.getJSONArray("scenarioParamList"); - if (CollectionUtils.isNotEmpty(scenarioParamList)) { - Long scenarioId = getScenarioId(scenarioParamList.getJSONObject(0), tbodyObj, formAttributeMap, processTaskFormAttributeDataMap); - jobVo.setScenarioId(scenarioId); - } - // 目标参数赋值列表 - JSONArray executeParamList = autoexecConfig.getJSONArray("executeParamList"); - if (CollectionUtils.isNotEmpty(executeParamList)) { - AutoexecCombopExecuteConfigVo executeConfig = getAutoexecCombopExecuteConfig(executeParamList, tbodyObj, formAttributeMap, processTaskFormAttributeDataMap); - jobVo.setExecuteConfig(executeConfig); - } - // 作业参数赋值列表 - JSONArray runtimeParamList = autoexecConfig.getJSONArray("runtimeParamList"); - if (CollectionUtils.isNotEmpty(runtimeParamList)) { - JSONObject param = getParam(currentProcessTaskStepVo, runtimeParamList, tbodyObj, formAttributeMap, processTaskFormAttributeDataMap, processTaskParam); - jobVo.setParam(param); - } - String jobNamePrefixValue = getJobNamePrefixValue(jobNamePrefixKey, jobVo.getExecuteConfig(), jobVo.getParam()); - jobVo.setName(jobNamePrefixValue + jobName); - resultList.add(jobVo); - } - return resultList; - } - - /** - * 获取场景ID - * - * @param scenarioParamObj - * @param tbodyObj - * @param formAttributeMap - * @param processTaskFormAttributeDataMap - * @return - */ - private Long getScenarioId(JSONObject scenarioParamObj, - JSONObject tbodyObj, - Map formAttributeMap, - Map processTaskFormAttributeDataMap) { - String key = scenarioParamObj.getString("key"); - if (StringUtils.isBlank(key)) { - return null; - } - Object value = scenarioParamObj.get("value"); - if (value == null) { - return null; - } - Object scenario = null; - String type = scenarioParamObj.getString("type"); - String mappingMode = scenarioParamObj.getString("mappingMode"); - if (Objects.equals(mappingMode, "formTableComponent")) { - String column = scenarioParamObj.getString("column"); - if (tbodyObj != null) { - String columnValue = tbodyObj.getString(column); - scenario = columnValue; - } else { - FormAttributeVo formAttributeVo = formAttributeMap.get(value); - ProcessTaskFormAttributeDataVo attributeDataVo = processTaskFormAttributeDataMap.get(value); - JSONArray filterList = scenarioParamObj.getJSONArray("filterList"); - JSONArray tbodyList = getTbodyList(attributeDataVo, filterList, formAttributeMap); - List list = parseFormTableComponentMappingValue(formAttributeVo, tbodyList, column); - scenario = convertDateType(type, list); - } - } else if (Objects.equals(mappingMode, "formCommonComponent")) { - ProcessTaskFormAttributeDataVo attributeDataVo = processTaskFormAttributeDataMap.get(value); - if (attributeDataVo != null) { - List formTextAttributeList = new ArrayList<>(); - formTextAttributeList.add(neatlogic.framework.form.constvalue.FormHandler.FORMTEXT.getHandler()); - formTextAttributeList.add(neatlogic.framework.form.constvalue.FormHandler.FORMTEXTAREA.getHandler()); - if (formTextAttributeList.contains(attributeDataVo.getHandler())) { - scenario = convertDateType(type, (String) attributeDataVo.getDataObj()); - } else { - scenario = attributeDataVo.getDataObj(); - } - } - } else if (Objects.equals(mappingMode, "constant")) { - scenario = value; - } - if (scenario != null) { - if (scenario instanceof List) { - List scenarioList = (List) scenario; - if (CollectionUtils.isNotEmpty(scenarioList)) { - scenario = scenarioList.get(0); - } - } - if (scenario instanceof String) { - String scenarioName = (String) scenario; - AutoexecScenarioVo scenarioVo = autoexecScenarioMapper.getScenarioByName(scenarioName); - if (scenarioVo != null) { - return scenarioVo.getId(); - } else { - try { - Long scenarioId = Long.valueOf(scenarioName); - if (autoexecScenarioMapper.checkScenarioIsExistsById(scenarioId) > 0) { - return scenarioId; - } - } catch (NumberFormatException ignored) { - - } - } - } else if (scenario instanceof Long) { - Long scenarioId = (Long) scenario; - if (autoexecScenarioMapper.checkScenarioIsExistsById(scenarioId) > 0) { - return scenarioId; - } - } - } - return null; - } - - /** - * 根据设置找到作业名称前缀值 - * - * @param jobNamePrefixKey 作业名称前缀key - * @param executeConfig 目标参数 - * @param param 作业参数 - * @return 返回作业名称前缀值 - */ - private String getJobNamePrefixValue(String jobNamePrefixKey, AutoexecCombopExecuteConfigVo executeConfig, JSONObject param) { - String jobNamePrefixValue = StringUtils.EMPTY; - if (StringUtils.isBlank(jobNamePrefixKey)) { - return jobNamePrefixValue; - } - if (Objects.equals(jobNamePrefixKey, "executeNodeConfig")) { - AutoexecCombopExecuteNodeConfigVo executeNodeConfig = executeConfig.getExecuteNodeConfig(); - List inputNodeList = executeNodeConfig.getInputNodeList(); - List selectNodeList = executeNodeConfig.getSelectNodeList(); - List paramList = executeNodeConfig.getParamList(); - if (CollectionUtils.isNotEmpty(inputNodeList)) { - List list = new ArrayList<>(); - for (AutoexecNodeVo node : inputNodeList) { - list.add(node.toString()); - } - jobNamePrefixValue = String.join("", list); - } else if (CollectionUtils.isNotEmpty(selectNodeList)) { - List list = new ArrayList<>(); - for (AutoexecNodeVo node : selectNodeList) { - list.add(node.toString()); - } - jobNamePrefixValue = String.join("", list); - } else if (CollectionUtils.isNotEmpty(paramList)) { - List list = new ArrayList<>(); - for (String paramKey : paramList) { - Object value = param.get(paramKey); - if (value != null) { - if (value instanceof String) { - list.add((String) value); - } else { - list.add(JSONObject.toJSONString(value)); - } - } - } - jobNamePrefixValue = String.join("", list); - } - } else if (Objects.equals(jobNamePrefixKey, "executeUser")) { - ParamMappingVo executeUser = executeConfig.getExecuteUser(); - if (executeUser != null) { - Object value = executeUser.getValue(); - if (value != null) { - if (Objects.equals(executeUser.getMappingMode(), "runtimeparam")) { - value = param.get(value); - } - if (value != null) { - if (value instanceof String) { - jobNamePrefixValue = (String) value; - } else { - jobNamePrefixValue = JSONObject.toJSONString(value); - } - } - } - } - } else if (Objects.equals(jobNamePrefixKey, "protocolId")) { - Long protocolId = executeConfig.getProtocolId(); - if (protocolId != null) { - jobNamePrefixValue = protocolId.toString(); - } - } else if (Objects.equals(jobNamePrefixKey, "roundCount")) { - Integer roundCount = executeConfig.getRoundCount(); - if (roundCount != null) { - jobNamePrefixValue = roundCount.toString(); - } - } else { - Object jobNamePrefixObj = param.get(jobNamePrefixKey); - if (jobNamePrefixObj instanceof String) { - jobNamePrefixValue = (String) jobNamePrefixObj; - } else { - jobNamePrefixValue = JSONObject.toJSONString(jobNamePrefixObj); - } - } - if (StringUtils.isBlank(jobNamePrefixValue)) { - return StringUtils.EMPTY; - } else if (jobNamePrefixValue.length() > 32) { - return jobNamePrefixValue.substring(0, 32); - } - return jobNamePrefixValue; - } - - private JSONArray getTbodyList(ProcessTaskFormAttributeDataVo formAttributeDataVo, JSONArray filterList, Map formAttributeMap) { - JSONArray tbodyList = new JSONArray(); - if (formAttributeDataVo == null) { - return tbodyList; - } - if (!Objects.equals(formAttributeDataVo.getHandler(), neatlogic.framework.form.constvalue.FormHandler.FORMTABLEINPUTER.getHandler()) - && !Objects.equals(formAttributeDataVo.getHandler(), neatlogic.framework.form.constvalue.FormHandler.FORMTABLESELECTOR.getHandler())) { - return tbodyList; - } - if (formAttributeDataVo.getDataObj() == null) { - return tbodyList; - } - JSONArray dataList = new JSONArray(); - JSONArray tempList = (JSONArray) formAttributeDataVo.getDataObj(); - for (int i = 0; i < tempList.size(); i++) { - JSONObject newRowData = new JSONObject(); - JSONObject rowData = tempList.getJSONObject(i); - for (Map.Entry entry : rowData.entrySet()) { - FormAttributeVo formAttributeVo = formAttributeMap.get(entry.getKey()); - if (formAttributeVo != null) { - IFormAttributeDataConversionHandler formAttributeDataConversionHandler = FormAttributeDataConversionHandlerFactory.getHandler(formAttributeVo.getHandler()); - if (formAttributeDataConversionHandler != null) { - newRowData.put(entry.getKey(), formAttributeDataConversionHandler.getSimpleValue(entry.getValue())); - } else { - newRowData.put(entry.getKey(), entry.getValue()); - } - } else { - newRowData.put(entry.getKey(), entry.getValue()); - } - } - dataList.add(newRowData); - } - // 数据过滤 - if (CollectionUtils.isNotEmpty(filterList)) { - for (int i = 0; i < dataList.size(); i++) { - JSONObject data = dataList.getJSONObject(i); - if (MapUtils.isEmpty(data)) { - continue; - } - boolean flag = true; - for (int j = 0; j < filterList.size(); j++) { - JSONObject filterObj = filterList.getJSONObject(j); - if (MapUtils.isEmpty(filterObj)) { - continue; - } - String column = filterObj.getString("column"); - if (StringUtils.isBlank(column)) { - continue; - } - String expression = filterObj.getString("expression"); - if (StringUtils.isBlank(expression)) { - continue; - } - String value = filterObj.getString("value"); - if (StringUtils.isBlank(value)) { - continue; - } - if (Objects.equals(expression, Expression.EQUAL.getExpression())) { - if (!Objects.equals(value, data.getString(column))) { - flag = false; - break; - } - } else if (Objects.equals(expression, Expression.UNEQUAL.getExpression())) { - if (Objects.equals(value, data.getString(column))) { - flag = false; - break; - } - } else if (Objects.equals(expression, Expression.LIKE.getExpression())) { - String columnValue = data.getString(column); - if (StringUtils.isBlank(columnValue)) { - flag = false; - break; - } - if (!columnValue.contains(value)) { - flag = false; - break; - } - } else if (Objects.equals(expression, Expression.NOTLIKE.getExpression())) { - String columnValue = data.getString(column); - if (StringUtils.isBlank(columnValue)) { - continue; - } - if (columnValue.contains(value)) { - flag = false; - break; - } - } - } - if (flag) { - tbodyList.add(data); - } - } - } else { - tbodyList = dataList; - } - return tbodyList; - } - - private JSONObject getParam( - ProcessTaskStepVo currentProcessTaskStepVo, - JSONArray runtimeParamList, - Map formAttributeMap, - Map processTaskFormAttributeDataMap, - JSONObject processTaskParam) { - return getParam(currentProcessTaskStepVo, runtimeParamList, null, formAttributeMap, processTaskFormAttributeDataMap, processTaskParam); - } - - private JSONObject getParam( - ProcessTaskStepVo currentProcessTaskStepVo, - JSONArray runtimeParamList, - JSONObject tbodyObj, - Map formAttributeMap, - Map processTaskFormAttributeDataMap, - JSONObject processTaskParam) { - List formSelectAttributeList = new ArrayList<>(); - formSelectAttributeList.add(neatlogic.framework.form.constvalue.FormHandler.FORMSELECT.getHandler()); - formSelectAttributeList.add(neatlogic.framework.form.constvalue.FormHandler.FORMCHECKBOX.getHandler()); - formSelectAttributeList.add(neatlogic.framework.form.constvalue.FormHandler.FORMRADIO.getHandler()); - List formTextAttributeList = new ArrayList<>(); - formTextAttributeList.add(neatlogic.framework.form.constvalue.FormHandler.FORMTEXT.getHandler()); - formTextAttributeList.add(neatlogic.framework.form.constvalue.FormHandler.FORMTEXTAREA.getHandler()); - - List needFreemarkerReplaceKeyList = new ArrayList<>(); - JSONObject param = new JSONObject(); - for (int i = 0; i < runtimeParamList.size(); i++) { - JSONObject runtimeParamObj = runtimeParamList.getJSONObject(i); - if (MapUtils.isEmpty(runtimeParamObj)) { - continue; - } - String key = runtimeParamObj.getString("key"); - if (StringUtils.isBlank(key)) { - continue; - } - Object value = runtimeParamObj.get("value"); - if (value == null) { - continue; - } - String type = runtimeParamObj.getString("type"); - String mappingMode = runtimeParamObj.getString("mappingMode"); - if (Objects.equals(mappingMode, "formTableComponent")) { - String column = runtimeParamObj.getString("column"); - if (tbodyObj != null) { - String columnValue = tbodyObj.getString(column); - param.put(key, convertDateType(type, columnValue)); - } else { - FormAttributeVo formAttributeVo = formAttributeMap.get(value); - ProcessTaskFormAttributeDataVo attributeDataVo = processTaskFormAttributeDataMap.get(value); - JSONArray filterList = runtimeParamObj.getJSONArray("filterList"); - JSONArray tbodyList = getTbodyList(attributeDataVo, filterList, formAttributeMap); - List list = parseFormTableComponentMappingValue(formAttributeVo, tbodyList, column); - param.put(key, convertDateType(type, list)); - } - } else if (Objects.equals(mappingMode, "formCommonComponent")) { - ProcessTaskFormAttributeDataVo attributeDataVo = processTaskFormAttributeDataMap.get(value); - if (attributeDataVo != null) { - if (formTextAttributeList.contains(attributeDataVo.getHandler())) { - param.put(key, convertDateType(type, (String) attributeDataVo.getDataObj())); - } else if (formSelectAttributeList.contains(attributeDataVo.getHandler())) { - if (attributeDataVo.getDataObj() instanceof String) { - param.put(key, convertDateType(type, (String) attributeDataVo.getDataObj())); - } else if (attributeDataVo.getDataObj() instanceof JSONArray) { - param.put(key, convertDateType(type, JSONObject.toJSONString(attributeDataVo.getDataObj()))); - } - } else if (Objects.equals(attributeDataVo.getHandler(), neatlogic.framework.form.constvalue.FormHandler.FORMUSERSELECT.getHandler()) && Objects.equals(type, ParamType.USERSELECT.getValue())) { - Object dataObj = attributeDataVo.getDataObj(); - if (dataObj instanceof JSONArray) { - param.put(key, dataObj); - } else { - JSONArray array = new JSONArray(); - array.add(dataObj); - param.put(key, array); - } - } else if (Objects.equals(type, ParamType.FILE.getValue())) { - param.put(key, convertDateTypeForFile(attributeDataVo.getDataObj())); - } - else { - param.put(key, attributeDataVo.getDataObj()); - } - } - } else if (Objects.equals(mappingMode, "constant")) { - param.put(key, value); - } else if (Objects.equals(mappingMode, "processTaskParam")) { - param.put(key, processTaskParam.get(value)); - } else if (Objects.equals(mappingMode, "expression")) { - if (value instanceof JSONArray) { - param.put(key, parseExpression((JSONArray) value, tbodyObj, processTaskFormAttributeDataMap, processTaskParam)); - } else { - param.put(key, value); - } - } - - if (Objects.equals(type, ParamType.TEXT.getValue()) || Objects.equals(type, ParamType.TEXTAREA.getValue())) { - Object obj = param.get(key); - if (obj != null) { - String str = obj.toString(); - if (str.contains("${DATA.stepId}") || str.contains("${DATA.stepWorker}") || str.contains("${DATA.serialNumber}")) { - needFreemarkerReplaceKeyList.add(key); - } - } - } - } - // 通过freemarker语法替换参数${DATA.stepId}、${DATA.stepWorker}、${DATA.serialNumber} - if (CollectionUtils.isNotEmpty(needFreemarkerReplaceKeyList)) { - for (String key : needFreemarkerReplaceKeyList) { - JSONObject paramObj = new JSONObject(); - { - INotifyParamHandler notifyParamHandler = NotifyParamHandlerFactory.getHandler(ProcessTaskStepNotifyParam.STEPWORKER.getValue()); - if (notifyParamHandler != null) { - Object stepWorker = notifyParamHandler.getText(currentProcessTaskStepVo, ProcessTaskStepNotifyTriggerType.SUCCEED); - paramObj.put(ProcessTaskStepNotifyParam.STEPWORKER.getValue(), stepWorker); - } - } - { - INotifyParamHandler notifyParamHandler = NotifyParamHandlerFactory.getHandler(ProcessTaskStepNotifyParam.STEPID.getValue()); - if (notifyParamHandler != null) { - Object stepId = notifyParamHandler.getText(currentProcessTaskStepVo, ProcessTaskStepNotifyTriggerType.SUCCEED); - paramObj.put(ProcessTaskStepNotifyParam.STEPID.getValue(), stepId); - } - } - { - INotifyParamHandler notifyParamHandler = NotifyParamHandlerFactory.getHandler(ProcessTaskNotifyParam.SERIALNUMBER.getValue()); - if (notifyParamHandler != null) { - Object serialnumber = notifyParamHandler.getText(currentProcessTaskStepVo, null); - paramObj.put(ProcessTaskNotifyParam.SERIALNUMBER.getValue(), serialnumber); - } - } - Object obj = param.get(key); - if (obj == null) { - continue; - } - String str = obj.toString(); - if (str.contains("${DATA.stepId}") || str.contains("${DATA.stepWorker}") || str.contains("${DATA.serialNumber}")) { - param.put(key, FreemarkerUtil.transform(paramObj, str)); - } - } - } - return param; - } - - /** - * 解析出表达式的值 - * @param valueList - * @param tbodyObj - * @param processTaskFormAttributeDataMap - * @param processTaskParam - * @return - */ - private String parseExpression(JSONArray valueList, JSONObject tbodyObj, Map processTaskFormAttributeDataMap, JSONObject processTaskParam) { - StringBuilder stringBuilder = new StringBuilder(); - for (int i = 0; i < valueList.size(); i++) { - JSONObject valueObj = valueList.getJSONObject(i); - if (MapUtils.isEmpty(valueObj)) { - continue; - } - String value = valueObj.getString("value"); - String mappingMode = valueObj.getString("mappingMode"); - if (Objects.equals(mappingMode, "formTableComponent")) { - if (tbodyObj != null) { - String column = valueObj.getString("column"); - Object valueObject = tbodyObj.get(column); - if (valueObject == null) { - continue; - } - if (valueObject instanceof JSONArray) { - List list = new ArrayList<>(); - JSONArray valueObjectArray = (JSONArray) valueObject; - for (int j = 0; j < valueObjectArray.size(); j++) { - list.add(valueObjectArray.getString(j)); - } - stringBuilder.append(String.join(",", list)); - } else { - stringBuilder.append(valueObject); - } - } - } else if (Objects.equals(mappingMode, "formCommonComponent")) { - ProcessTaskFormAttributeDataVo attributeDataVo = processTaskFormAttributeDataMap.get(value); - if (attributeDataVo != null && attributeDataVo.getDataObj() != null) { - Object dataObject = attributeDataVo.getDataObj(); - if (dataObject instanceof JSONArray) { - List list = new ArrayList<>(); - JSONArray dataObjectArray = (JSONArray) dataObject; - for (int j = 0; j < dataObjectArray.size(); j++) { - list.add(dataObjectArray.getString(j)); - } - stringBuilder.append(String.join(",", list)); - } else { - stringBuilder.append(dataObject); - } - } - } else if (Objects.equals(mappingMode, "constant")) { - stringBuilder.append(value); - } else if (Objects.equals(mappingMode, "processTaskParam")) { - stringBuilder.append(processTaskParam.get(value)); - } - } - return stringBuilder.toString(); - } - - private AutoexecCombopExecuteConfigVo getAutoexecCombopExecuteConfig( - JSONArray executeParamList, - Map formAttributeMap, - Map processTaskFormAttributeDataMap) { - return getAutoexecCombopExecuteConfig(executeParamList, null, formAttributeMap, processTaskFormAttributeDataMap); - } - - private AutoexecCombopExecuteConfigVo getAutoexecCombopExecuteConfig( - JSONArray executeParamList, - JSONObject tbodyObj, - Map formAttributeMap, - Map processTaskFormAttributeDataMap) { - List formTextAttributeList = new ArrayList<>(); - formTextAttributeList.add(neatlogic.framework.form.constvalue.FormHandler.FORMTEXT.getHandler()); - formTextAttributeList.add(neatlogic.framework.form.constvalue.FormHandler.FORMTEXTAREA.getHandler()); - JSONObject executeConfig = new JSONObject(); - for (int i = 0; i < executeParamList.size(); i++) { - JSONObject executeParamObj = executeParamList.getJSONObject(i); - if (MapUtils.isEmpty(executeParamObj)) { - continue; - } - String key = executeParamObj.getString("key"); - if (StringUtils.isBlank(key)) { - continue; - } - String mappingMode = executeParamObj.getString("mappingMode"); - Object value = executeParamObj.get("value"); - if (Objects.equals(mappingMode, "formTableComponent")) { - // 映射模式为表单表格组件 - if (Objects.equals(key, "executeNodeConfig")) { - AutoexecCombopExecuteNodeConfigVo executeNodeConfigVo = new AutoexecCombopExecuteNodeConfigVo(); - String column = executeParamObj.getString("column"); - if (tbodyObj != null) { - String columnValue = tbodyObj.getString(column); - if (StringUtils.isNotBlank(columnValue)) { - List inputNodeList = new ArrayList<>(); - inputNodeList.add(new AutoexecNodeVo(columnValue)); - executeNodeConfigVo.setInputNodeList(inputNodeList); - } - } else { - FormAttributeVo formAttributeVo = formAttributeMap.get(value); - ProcessTaskFormAttributeDataVo attributeDataVo = processTaskFormAttributeDataMap.get(value); - JSONArray filterList = executeParamObj.getJSONArray("filterList"); - JSONArray tbodyList = getTbodyList(attributeDataVo, filterList, formAttributeMap); - List list = parseFormTableComponentMappingValue(formAttributeVo, tbodyList, column); - if (CollectionUtils.isNotEmpty(list)) { - List inputNodeList = new ArrayList<>(); - for (String str : list) { - inputNodeList.add(new AutoexecNodeVo(str)); - } - executeNodeConfigVo.setInputNodeList(inputNodeList); - } - } - executeConfig.put(key, executeNodeConfigVo); - } - } else if (Objects.equals(mappingMode, "formCommonComponent")) { - // 映射模式为表单普通组件 - if (Objects.equals(key, "executeUser")) { - // 执行用户 - ParamMappingVo paramMappingVo = new ParamMappingVo(); - paramMappingVo.setMappingMode("constant"); - ProcessTaskFormAttributeDataVo attributeDataVo = processTaskFormAttributeDataMap.get(value); - if (attributeDataVo != null) { - paramMappingVo.setValue(attributeDataVo.getDataObj()); - } - executeConfig.put(key, paramMappingVo); - } else if (Objects.equals(key, "executeNodeConfig")) { - // 执行目标 - AutoexecCombopExecuteNodeConfigVo executeNodeConfigVo = new AutoexecCombopExecuteNodeConfigVo(); - ProcessTaskFormAttributeDataVo attributeDataVo = processTaskFormAttributeDataMap.get(value); - if (attributeDataVo != null) { - Object dataObj = attributeDataVo.getDataObj(); - if (dataObj != null) { - if (Objects.equals(attributeDataVo.getHandler(), FormHandler.FORMRESOURECES.getHandler())) { - // 映射的表单组件是执行目标 - executeNodeConfigVo = ((JSONObject) dataObj).toJavaObject(AutoexecCombopExecuteNodeConfigVo.class); - } else if (formTextAttributeList.contains(attributeDataVo.getHandler())) { - // 映射的表单组件是文本框 - String dataStr = dataObj.toString(); - try { - List inputNodeList = new ArrayList<>(); - JSONArray array = JSONArray.parseArray(dataStr); - for (int j = 0; j < array.size(); j++) { - String str = array.getString(j); - inputNodeList.add(new AutoexecNodeVo(str)); - } - executeNodeConfigVo.setInputNodeList(inputNodeList); - } catch (JSONException e) { - List inputNodeList = new ArrayList<>(); - inputNodeList.add(new AutoexecNodeVo(dataObj.toString())); - executeNodeConfigVo.setInputNodeList(inputNodeList); - } - } else { - // 映射的表单组件不是执行目标 - List inputNodeList = new ArrayList<>(); - inputNodeList.add(new AutoexecNodeVo(dataObj.toString())); - executeNodeConfigVo.setInputNodeList(inputNodeList); - } - } - } - executeConfig.put(key, executeNodeConfigVo); - } else if (Objects.equals(key, "protocolId")) { - ProcessTaskFormAttributeDataVo attributeDataVo = processTaskFormAttributeDataMap.get(value); - Object formData = attributeDataVo.getDataObj(); - try { - executeConfig.put(key, Long.valueOf(formData.toString())); - } catch (NumberFormatException ex) { - IResourceAccountCrossoverMapper resourceAccountCrossoverMapper = CrossoverServiceFactory.getApi(IResourceAccountCrossoverMapper.class); - AccountProtocolVo protocolVo = resourceAccountCrossoverMapper.getAccountProtocolVoByProtocolName(formData.toString()); - if (protocolVo != null) { - executeConfig.put(key, protocolVo.getId()); - } - } - } else { - ProcessTaskFormAttributeDataVo attributeDataVo = processTaskFormAttributeDataMap.get(value); - if (attributeDataVo != null) { - executeConfig.put(key, attributeDataVo.getDataObj()); - } - } - } else if (Objects.equals(mappingMode, "constant")) { - // 映射模式为常量 - if (Objects.equals(key, "executeUser")) { - ParamMappingVo paramMappingVo = new ParamMappingVo(); - paramMappingVo.setMappingMode("constant"); - paramMappingVo.setValue(value); - executeConfig.put(key, paramMappingVo); - } else { - executeConfig.put(key, value); - } - } else if (Objects.equals(mappingMode, "runtimeparam")) { - // 映射模式为作业参数,只读 - if (Objects.equals(key, "executeUser")) { - ParamMappingVo paramMappingVo = new ParamMappingVo(); - paramMappingVo.setMappingMode("runtimeparam"); - paramMappingVo.setValue(value); - executeConfig.put(key, paramMappingVo); - } - } - } - return executeConfig.toJavaObject(AutoexecCombopExecuteConfigVo.class); - } - - private List parseFormTableComponentMappingValue(FormAttributeVo formAttributeVo, JSONArray tbodyList, String column) { - List resultList = new ArrayList<>(); - if (CollectionUtils.isEmpty(tbodyList)) { - return resultList; - } - for (int i = 0; i < tbodyList.size(); i++) { - JSONObject tbodyObj = tbodyList.getJSONObject(i); - if (MapUtils.isEmpty(tbodyObj)) { - continue; - } - String columnValue = tbodyObj.getString(column); - if (StringUtils.isBlank(columnValue)) { - continue; - } - resultList.add(columnValue); - } - return resultList; - } - - private AutoexecJobVo createAutoexecJobVo(ProcessTaskStepVo currentProcessTaskStepVo, JSONObject autoexecConfig) { - AutoexecJobVo jobVo = new AutoexecJobVo(); - Long combopId = autoexecConfig.getLong("autoexecCombopId"); - jobVo.setCombopId(combopId); - JSONArray runtimeParamList = autoexecConfig.getJSONArray("runtimeParamList"); - JSONObject param = new JSONObject(); - if (CollectionUtils.isNotEmpty(runtimeParamList)) { - for (int i = 0; i < runtimeParamList.size(); i++) { - JSONObject runtimeParamObj = runtimeParamList.getJSONObject(i); - if (MapUtils.isNotEmpty(runtimeParamObj)) { - String key = runtimeParamObj.getString("key"); - if (StringUtils.isNotBlank(key)) { - Object value = runtimeParamObj.get("value"); - if (value != null) { - String mappingMode = runtimeParamObj.getString("mappingMode"); - param.put(key, parseMappingValue(currentProcessTaskStepVo, mappingMode, value)); - } else { - param.put(key, value); - } - } - } - } - jobVo.setParam(param); - } - JSONArray executeParamList = autoexecConfig.getJSONArray("executeParamList"); - JSONObject executeConfig = new JSONObject(); - if (CollectionUtils.isNotEmpty(executeParamList)) { - for (int i = 0; i < executeParamList.size(); i++) { - JSONObject executeParamObj = executeParamList.getJSONObject(i); - if (MapUtils.isNotEmpty(executeParamObj)) { - String key = executeParamObj.getString("key"); - Object value = executeParamObj.get("value"); - String mappingMode = executeParamObj.getString("mappingMode"); - if (Objects.equals(key, "executeUser")) { - ParamMappingVo paramMappingVo = new ParamMappingVo(); - if (Objects.equals(mappingMode, "runtimeparam") || Objects.equals(mappingMode, "constant")) { - paramMappingVo.setMappingMode(mappingMode); - paramMappingVo.setValue(value); - } else { - paramMappingVo.setMappingMode("constant"); - paramMappingVo.setValue(parseMappingValue(currentProcessTaskStepVo, mappingMode, value)); - } - executeConfig.put(key, paramMappingVo); - } else { - executeConfig.put(key, parseMappingValue(currentProcessTaskStepVo, mappingMode, value)); - } - } - } - jobVo.setExecuteConfig(executeConfig.toJavaObject(AutoexecCombopExecuteConfigVo.class)); - } - jobVo.setSource(AutoExecJobProcessSource.ITSM.getValue()); - jobVo.setOperationId(combopId); - jobVo.setOperationType(CombopOperationType.COMBOP.getValue()); - jobVo.setInvokeId(currentProcessTaskStepVo.getId()); - jobVo.setRouteId(currentProcessTaskStepVo.getId().toString()); - jobVo.setAssignExecUser(SystemUser.SYSTEM.getUserUuid()); - return jobVo; - } - - private void processTaskStepComplete(Long processTaskStepId, Long autoexecJobId) { - IProcessTaskCrossoverMapper processTaskCrossoverMapper = CrossoverServiceFactory.getApi(IProcessTaskCrossoverMapper.class); - ISelectContentByHashCrossoverMapper selectContentByHashCrossoverMapper = CrossoverServiceFactory.getApi(ISelectContentByHashCrossoverMapper.class); - List toProcessTaskStepIdList = processTaskCrossoverMapper.getToProcessTaskStepIdListByFromIdAndType(processTaskStepId, ProcessFlowDirection.FORWARD.getValue()); - if (toProcessTaskStepIdList.size() == 1) { - Long nextStepId = toProcessTaskStepIdList.get(0); - IProcessStepHandler handler = ProcessStepHandlerFactory.getHandler(AutoexecProcessStepHandlerType.AUTOEXEC.getHandler()); - if (handler != null) { - try { - List hidecomponentList = new ArrayList<>(); - JSONArray formAttributeDataList = new JSONArray(); - ProcessTaskStepVo processTaskStepVo = processTaskCrossoverMapper.getProcessTaskStepBaseInfoById(processTaskStepId); - String config = selectContentByHashCrossoverMapper.getProcessTaskStepConfigByHash(processTaskStepVo.getConfigHash()); - if (StringUtils.isNotBlank(config)) { - JSONArray formAttributeList = (JSONArray) JSONPath.read(config, "autoexecConfig.formAttributeList"); - if (CollectionUtils.isNotEmpty(formAttributeList)) { - Map autoexecJobEnvMap = new HashMap<>(); - if (autoexecJobId != null) { - List autoexecJobEnvList = autoexecJobMapper.getAutoexecJobEnvListByJobId(autoexecJobId); - for (AutoexecJobEnvVo autoexecJobEnvVo : autoexecJobEnvList) { - autoexecJobEnvMap.put(autoexecJobEnvVo.getName(), autoexecJobEnvVo.getValue()); - } - } - Map formAttributeNewDataMap = new HashMap<>(); - for (int i = 0; i < formAttributeList.size(); i++) { - JSONObject formAttributeObj = formAttributeList.getJSONObject(i); - String key = formAttributeObj.getString("key"); - String value = formAttributeObj.getString("value"); - formAttributeNewDataMap.put(key, autoexecJobEnvMap.get(value)); - } - IProcessTaskCrossoverService processTaskCrossoverService = CrossoverServiceFactory.getApi(IProcessTaskCrossoverService.class); - List processTaskFormAttributeDataList = processTaskCrossoverService.getProcessTaskFormAttributeDataListByProcessTaskId(processTaskStepVo.getProcessTaskId()); - for (ProcessTaskFormAttributeDataVo processTaskFormAttributeDataVo : processTaskFormAttributeDataList) { - JSONObject formAttributeDataObj = new JSONObject(); - String attributeUuid = processTaskFormAttributeDataVo.getAttributeUuid(); - formAttributeDataObj.put("attributeUuid", attributeUuid); - formAttributeDataObj.put("handler", processTaskFormAttributeDataVo.getHandler()); - Object newData = formAttributeNewDataMap.get(attributeUuid); - if (newData != null) { - formAttributeDataObj.put("dataList", newData); - } else { - formAttributeDataObj.put("dataList", processTaskFormAttributeDataVo.getDataObj()); - hidecomponentList.add(attributeUuid); - } - formAttributeDataList.add(formAttributeDataObj); - } - } - } - JSONObject paramObj = processTaskStepVo.getParamObj(); - paramObj.put("nextStepId", nextStepId); - paramObj.put("action", ProcessTaskStepOperationType.STEP_COMPLETE.getValue()); - if (CollectionUtils.isNotEmpty(formAttributeDataList)) { - paramObj.put("formAttributeDataList", formAttributeDataList); - } - if (CollectionUtils.isNotEmpty(hidecomponentList)) { - paramObj.put("hidecomponentList", hidecomponentList); - } - /* 自动处理 **/ - doNext(ProcessTaskStepOperationType.STEP_COMPLETE, new ProcessStepThread(processTaskStepVo) { - @Override - public void myExecute() { - UserContext.init(SystemUser.SYSTEM); - handler.autoComplete(processTaskStepVo); - } - }); - } catch (ProcessTaskNoPermissionException e) { - logger.error(e.getMessage(), e); - } - } - } else { - ProcessTaskStepVo processTaskStepVo = processTaskCrossoverMapper.getProcessTaskStepBaseInfoById(processTaskStepId); - IProcessStepHandler processStepHandler = ProcessStepHandlerFactory.getHandler(processTaskStepVo.getHandler()); - if (processStepHandler != null) { - try { - processStepHandler.assign(processTaskStepVo); - } catch (ProcessTaskException e) { - logger.error(e.getMessage(), e); - } - } - } - } - - private Object parseMappingValue(ProcessTaskStepVo currentProcessTaskStepVo, String mappingMode, Object value) { - if ("form".equals(mappingMode)) { - IProcessTaskCrossoverService processTaskCrossoverService = CrossoverServiceFactory.getApi(IProcessTaskCrossoverService.class); - List processTaskFormAttributeDataVoList = processTaskCrossoverService.getProcessTaskFormAttributeDataListByProcessTaskId(currentProcessTaskStepVo.getProcessTaskId()); - for (ProcessTaskFormAttributeDataVo attributeDataVo : processTaskFormAttributeDataVoList) { - if (Objects.equals(value, attributeDataVo.getAttributeUuid())) { - return attributeDataVo.getDataObj(); - } - } - return null; - } else if ("prestepexportparam".equals(mappingMode)) { - return getPreStepExportParamValue(currentProcessTaskStepVo.getProcessTaskId(), (String) value); - } - return value; - } - - private String getPreStepExportParamValue(Long processTaskId, String paramKey) { - IProcessTaskCrossoverMapper processTaskCrossoverMapper = CrossoverServiceFactory.getApi(IProcessTaskCrossoverMapper.class); - String[] split = paramKey.split("&&", 2); - String processStepUuid = split[0]; - ProcessTaskStepVo processTaskStepVo = processTaskCrossoverMapper.getProcessTaskStepBaseInfoByProcessTaskIdAndProcessStepUuid(processTaskId, processStepUuid); - if (processTaskStepVo != null) { - Long autoexecJobId = autoexecJobMapper.getJobIdByInvokeIdLimitOne(processTaskStepVo.getId()); - if (autoexecJobId != null) { - String paramName = split[1]; - AutoexecJobEnvVo autoexecJobEnvVo = new AutoexecJobEnvVo(); - autoexecJobEnvVo.setJobId(autoexecJobId); - autoexecJobEnvVo.setName(paramName); - return autoexecJobMapper.getAutoexecJobEnvValueByJobIdAndName(autoexecJobEnvVo); - } - } - return null; - } - - /** - * 把表单表格组件中某列数据集合转换成作业参数对应的数据 - * - * @param paramType 作业参数类型 - * @param sourceList 某列数据集合 - * @return - */ - private Object convertDateType(String paramType, List sourceList) { - if (Objects.equals(paramType, ParamType.NODE.getValue())) { - if (CollectionUtils.isNotEmpty(sourceList)) { - JSONArray inputNodeList = new JSONArray(); - for (String str : sourceList) { - if (StringUtils.isNotBlank(str)) { - JSONArray inputNodeArray = (JSONArray) convertDateType(paramType, str); - inputNodeList.addAll(inputNodeArray); - } - } - return inputNodeList; - } - } - return sourceList; - } - - /** - * 把表单文本框组件数据转换成作业参数对应的数据 - * - * @param paramType 作业参数类型 - * @param source 数据 - * @return Object - */ - private Object convertDateType(String paramType, String source) { - if (Objects.equals(paramType, ParamType.NODE.getValue())) { - if (StringUtils.isNotBlank(source)) { - JSONArray inputNodeList = new JSONArray(); - if (source.startsWith("[") && source.endsWith("]")) { - JSONArray array = JSON.parseArray(source); - for (int i = 0; i < array.size(); i++) { - String str = array.getString(i); - inputNodeList.add(new AutoexecNodeVo(str)); - } - } else if (source.contains("\n")) { - String[] split = source.split("\n"); - for (String str : split) { - inputNodeList.add(new AutoexecNodeVo(str)); - } - } else { - inputNodeList.add(new AutoexecNodeVo(source)); - } - return inputNodeList; - } - } - return source; - } - - /** - * 将数据转换成文件类型参数需要的格式 - * @param dataObj - * @return - */ - private JSONObject convertDateTypeForFile(Object dataObj) { - if (dataObj == null) { - return null; - } - if (dataObj instanceof JSONObject) { - JSONObject jsonObject = (JSONObject) dataObj; - Long fileId = jsonObject.getLong("id"); - return convertDateTypeForFile(fileId); - } else if (dataObj instanceof JSONArray) { - JSONArray jsonArray = (JSONArray) dataObj; - if (!jsonArray.isEmpty()) { - JSONObject resultObj = new JSONObject(); - JSONArray fileIdList = new JSONArray(); - JSONArray fileList = new JSONArray(); - for (Object obj : jsonArray) { - JSONObject jsonObj = convertDateTypeForFile(obj); - if (jsonObj != null) { - JSONArray fileIdArray = jsonObj.getJSONArray("fileIdList"); - fileIdList.addAll(fileIdArray); - JSONArray fileArray = jsonObj.getJSONArray("fileList"); - fileList.addAll(fileArray); - } - } - resultObj.put("fileIdList", fileIdList); - resultObj.put("fileList", fileList); - return resultObj; - } - } else if (dataObj instanceof Long) { - Long fileId = (Long) dataObj; - FileVo file = fileMapper.getFileById(fileId); - if (file != null) { - JSONObject resultObj = new JSONObject(); - JSONArray fileIdList = new JSONArray(); - fileIdList.add(fileId); - JSONArray fileList = new JSONArray(); - JSONObject fileObj = new JSONObject(); - fileObj.put("id", fileId); - fileObj.put("name", file.getName()); - fileList.add(fileObj); - resultObj.put("fileIdList", fileIdList); - resultObj.put("fileList", fileList); - return resultObj; - } - } else { - String str = dataObj.toString(); - try { - Long fileId = Long.valueOf(str); - return convertDateTypeForFile(fileId); - } catch (NumberFormatException e) { - - } - } - return null; - } - @Override - protected int myAssign(ProcessTaskStepVo currentProcessTaskStepVo, Set workerSet) throws ProcessTaskException { - return defaultAssign(currentProcessTaskStepVo, workerSet); - } - - @Override - protected int myHang(ProcessTaskStepVo currentProcessTaskStepVo) { - return 0; - } - - @Override - protected int myHandle(ProcessTaskStepVo currentProcessTaskStepVo) throws ProcessTaskException { - return 0; - } - - @Override - protected int myStart(ProcessTaskStepVo currentProcessTaskStepVo) throws ProcessTaskException { - return 0; - } - - @Override - protected int myComplete(ProcessTaskStepVo currentProcessTaskStepVo) throws ProcessTaskException { - return 10; - } - - @Override - protected int myBeforeComplete(ProcessTaskStepVo currentProcessTaskStepVo) throws ProcessTaskException { - IProcessTaskCrossoverMapper processTaskCrossoverMapper = CrossoverServiceFactory.getApi(IProcessTaskCrossoverMapper.class); - ISelectContentByHashCrossoverMapper selectContentByHashCrossoverMapper = CrossoverServiceFactory.getApi(ISelectContentByHashCrossoverMapper.class); - Long processTaskStepId = currentProcessTaskStepVo.getId(); - ProcessTaskStepVo processTaskStepVo = processTaskCrossoverMapper.getProcessTaskStepBaseInfoById(processTaskStepId); - String config = selectContentByHashCrossoverMapper.getProcessTaskStepConfigByHash(processTaskStepVo.getConfigHash()); - if (StringUtils.isBlank(config)) { - return 0; - } - JSONArray configList = (JSONArray) JSONPath.read(config, "autoexecConfig.configList"); - if (CollectionUtils.isEmpty(configList)) { - return 0; - } - List jobIdList = autoexecJobMapper.getJobIdListByProcessTaskStepId(processTaskStepId); - if (CollectionUtils.isEmpty(jobIdList)) { - return 0; - } - List autoexecJobEnvVoList = autoexecJobMapper.getAutoexecJobEnvListByJobIdList(jobIdList); - - Map> autoexecJobEnvMap = new HashMap<>(); - for (AutoexecJobEnvVo autoexecJobEnvVo : autoexecJobEnvVoList) { - autoexecJobEnvMap.computeIfAbsent(autoexecJobEnvVo.getName(), k -> new ArrayList<>()).add(autoexecJobEnvVo.getValue()); - } - Map> formAttributeNewDataMap = new HashMap<>(); - for (int j = 0; j < configList.size(); j++) { - JSONObject configObj = configList.getJSONObject(j); - if (MapUtils.isEmpty(configObj)) { - continue; - } - JSONArray formAttributeList = configObj.getJSONArray("formAttributeList"); - if (CollectionUtils.isEmpty(formAttributeList)) { - continue; - } - for (int i = 0; i < formAttributeList.size(); i++) { - JSONObject formAttributeObj = formAttributeList.getJSONObject(i); - String key = formAttributeObj.getString("key"); - if (StringUtils.isBlank(key)) { - continue; - } - String value = formAttributeObj.getString("value"); - if (StringUtils.isBlank(value)) { - continue; - } - List newValue = autoexecJobEnvMap.get(value); - if (newValue != null) { - formAttributeNewDataMap.put(key, newValue); - } - } - } - if (MapUtils.isEmpty(formAttributeNewDataMap)) { - return 0; - } - IProcessTaskCrossoverService processTaskCrossoverService = CrossoverServiceFactory.getApi(IProcessTaskCrossoverService.class); - List formAttributeList = processTaskCrossoverService.getFormAttributeListByProcessTaskId(processTaskStepVo.getProcessTaskId()); - if (CollectionUtils.isEmpty(formAttributeList)) { - return 0; - } - - - Map formAttributeMap = formAttributeList.stream().collect(Collectors.toMap(FormAttributeVo::getUuid, e -> e)); - JSONObject paramObj = currentProcessTaskStepVo.getParamObj(); - JSONArray formAttributeDataList = paramObj.getJSONArray("formAttributeDataList"); - if (formAttributeDataList == null) { - formAttributeDataList = new JSONArray(); - List hidecomponentList = formAttributeList.stream().map(FormAttributeVo::getUuid).collect(Collectors.toList()); - paramObj.put("hidecomponentList", hidecomponentList); - List processTaskFormAttributeDataList = processTaskCrossoverService.getProcessTaskFormAttributeDataListByProcessTaskId(processTaskStepVo.getProcessTaskId()); - Map processTaskFormAttributeDataMap = processTaskFormAttributeDataList.stream().collect(Collectors.toMap(AttributeDataVo::getAttributeUuid, e -> e)); - for (Map.Entry entry : processTaskFormAttributeDataMap.entrySet()) { - ProcessTaskFormAttributeDataVo processTaskFormAttributeDataVo = entry.getValue(); - JSONObject formAttributeDataObj = new JSONObject(); - formAttributeDataObj.put("attributeUuid", processTaskFormAttributeDataVo.getAttributeUuid()); - formAttributeDataObj.put("handler", processTaskFormAttributeDataVo.getHandler()); - formAttributeDataObj.put("dataList", processTaskFormAttributeDataVo.getDataObj()); - formAttributeDataList.add(formAttributeDataObj); - } - } - - for (Map.Entry> entry : formAttributeNewDataMap.entrySet()) { - String attributeUuid = entry.getKey(); - FormAttributeVo formAttributeVo = formAttributeMap.get(attributeUuid); - if (formAttributeVo == null) { - continue; - } - List newDataList = entry.getValue(); - if (CollectionUtils.isEmpty(newDataList)) { - continue; - } - - JSONObject formAttributeDataObj = null; - for (int i = 0; i < formAttributeDataList.size(); i++) { - JSONObject tempObj = formAttributeDataList.getJSONObject(i); - if (Objects.equals(tempObj.getString("attributeUuid"), attributeUuid)) { - formAttributeDataObj = tempObj; - } - } - if (formAttributeDataObj == null) { - formAttributeDataObj = new JSONObject(); - formAttributeDataList.add(formAttributeDataObj); - } - formAttributeDataObj.put("attributeUuid", attributeUuid); - formAttributeDataObj.put("handler", formAttributeVo.getHandler()); - if (newDataList.size() == 1) { - // 如果只有一个元素,把唯一的元素取出来赋值给表单组件 - formAttributeDataObj.put("dataList", newDataList.get(0)); - } else { - // 如果有多个元素,分为两种情况 - // 1.元素也是一个数组,需要把所有元素(数组)平摊成一个大一维数组 - // 2.元素不是一个数组,不需要特殊处理 - JSONArray newDataArray = new JSONArray(); - for (String newData : newDataList) { - try { - JSONArray array = JSON.parseArray(newData); - newDataArray.addAll(array); - } catch (JSONException e) { - newDataArray.add(newData); - } - } - formAttributeDataObj.put("dataList", JSON.toJSONString(newDataArray)); - } - } - paramObj.put("formAttributeDataList", formAttributeDataList); - return 0; - } - - @Override - protected int myCompleteAudit(ProcessTaskStepVo currentProcessTaskStepVo) { - if (StringUtils.isNotBlank(currentProcessTaskStepVo.getError())) { - currentProcessTaskStepVo.getParamObj().put(ProcessTaskAuditDetailType.CAUSE.getParamName(), currentProcessTaskStepVo.getError()); - } - /** 处理历史记录 **/ - String action = currentProcessTaskStepVo.getParamObj().getString("action"); - IProcessStepHandlerCrossoverUtil processStepHandlerCrossoverUtil = CrossoverServiceFactory.getApi(IProcessStepHandlerCrossoverUtil.class); - processStepHandlerCrossoverUtil.audit(currentProcessTaskStepVo, ProcessTaskAuditType.getProcessTaskAuditType(action)); - return 1; - } - - @Override - protected int myReapproval(ProcessTaskStepVo currentProcessTaskStepVo) throws ProcessTaskException { - return 0; - } - - @Override - protected int myReapprovalAudit(ProcessTaskStepVo currentProcessTaskStepVo) { - return 0; - } - - @Override - protected int myRetreat(ProcessTaskStepVo currentProcessTaskStepVo) throws ProcessTaskException { - return 0; - } - - @Override - protected int myAbort(ProcessTaskStepVo currentProcessTaskStepVo) { - return 0; - } - - @Override - protected int myRecover(ProcessTaskStepVo currentProcessTaskStepVo) { - return 0; - } - - @Override - protected int myPause(ProcessTaskStepVo currentProcessTaskStepVo) throws ProcessTaskException { - return 0; - } - - @Override - protected int myTransfer(ProcessTaskStepVo currentProcessTaskStepVo, List workerList) throws ProcessTaskException { - return 0; - } - - @Override - protected int myBack(ProcessTaskStepVo currentProcessTaskStepVo) throws ProcessTaskException { - return 0; - } - - @Override - protected int mySaveDraft(ProcessTaskStepVo processTaskStepVo) throws ProcessTaskException { - return 0; - } - - @Override - protected int myStartProcess(ProcessTaskStepVo processTaskStepVo) throws ProcessTaskException { - return 0; - } - - @Override - protected Set myGetNext(ProcessTaskStepVo currentProcessTaskStepVo, List nextStepIdList, Long nextStepId) throws ProcessTaskException { - return defaultGetNext(nextStepIdList, nextStepId); - } - - @Override - protected int myRedo(ProcessTaskStepVo currentProcessTaskStepVo) throws ProcessTaskException { - return 0; - } - - @Override - public boolean disableAssign() { - return true; - } - - @Override - public boolean allowDispatchStepWorker() { - return false; - } -} diff --git a/src/main/java/neatlogic/module/autoexec/stephandler/utilhandler/AutoexecProcessUtilHandler.java b/src/main/java/neatlogic/module/autoexec/stephandler/utilhandler/AutoexecProcessUtilHandler.java deleted file mode 100644 index da936674dbf09065b841191b6105d7eac1a26cd3..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/module/autoexec/stephandler/utilhandler/AutoexecProcessUtilHandler.java +++ /dev/null @@ -1,509 +0,0 @@ -/*Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.module.autoexec.stephandler.utilhandler; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import neatlogic.framework.autoexec.constvalue.JobStatus; -import neatlogic.framework.autoexec.dao.mapper.AutoexecJobMapper; -import neatlogic.framework.autoexec.dto.job.AutoexecJobPhaseVo; -import neatlogic.framework.autoexec.dto.job.AutoexecJobVo; -import neatlogic.framework.crossover.CrossoverServiceFactory; -import neatlogic.framework.process.constvalue.AutoexecProcessStepHandlerType; -import neatlogic.framework.process.crossover.IProcessTaskStepDataCrossoverMapper; -import neatlogic.framework.process.dto.ProcessTaskStepDataVo; -import neatlogic.framework.process.dto.ProcessTaskStepVo; -import neatlogic.framework.process.stephandler.core.ProcessStepInternalHandlerBase; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.MapUtils; - -import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author linbq - * @since 2021/9/2 14:30 - **/ -//@Service -@Deprecated -public class AutoexecProcessUtilHandler extends ProcessStepInternalHandlerBase { - - @Resource - private AutoexecJobMapper autoexecJobMapper; - - @Override - public String getHandler() { - return AutoexecProcessStepHandlerType.AUTOEXEC.getHandler(); - } - - @Override - public Object getStartStepInfo(ProcessTaskStepVo currentProcessTaskStepVo) { - return getNonStartStepInfo(currentProcessTaskStepVo); - } - - @Override - public Object getNonStartStepInfo(ProcessTaskStepVo currentProcessTaskStepVo) { - JSONObject resultObj = new JSONObject(); -// List jobIdList = autoexecJobMapper.getJobIdListByInvokeId(currentProcessTaskStepVo.getId()); - List jobIdList = autoexecJobMapper.getJobIdListByProcessTaskStepId(currentProcessTaskStepVo.getId()); - if (CollectionUtils.isNotEmpty(jobIdList)) { - int completed = 0, failed = 0, running = 0; - Map> jobIdToAutoexecJobPhaseListMap = new HashMap<>(); - List jobPhaseList = autoexecJobMapper.getJobPhaseListWithGroupByJobIdList(jobIdList); - for (AutoexecJobPhaseVo autoexecJobPhaseVo : jobPhaseList) { - jobIdToAutoexecJobPhaseListMap.computeIfAbsent(autoexecJobPhaseVo.getJobId(), key -> new ArrayList<>()).add(autoexecJobPhaseVo); - } - List autoexecJobList = autoexecJobMapper.getJobListByIdList(jobIdList); - for (AutoexecJobVo autoexecJobVo : autoexecJobList) { - List jobPhaseVoList = jobIdToAutoexecJobPhaseListMap.get(autoexecJobVo.getId()); - autoexecJobVo.setPhaseList(jobPhaseVoList); - if (JobStatus.isRunningStatus(autoexecJobVo.getStatus())) { - running++; - } else if (JobStatus.isCompletedStatus(autoexecJobVo.getStatus())) { - completed++; - } else if (JobStatus.isFailedStatus(autoexecJobVo.getStatus())) { - failed++; - } - } - - if (running > 0) { - resultObj.put("status", JobStatus.RUNNING.getValue()); - } else if (failed > 0) { - resultObj.put("status", JobStatus.FAILED.getValue()); - } else if (completed > 0) { - resultObj.put("status", JobStatus.COMPLETED.getValue()); - } - resultObj.put("jobList", autoexecJobList); - } - IProcessTaskStepDataCrossoverMapper processTaskStepDataCrossoverMapper = CrossoverServiceFactory.getApi(IProcessTaskStepDataCrossoverMapper.class); - ProcessTaskStepDataVo searchVo = new ProcessTaskStepDataVo(); - searchVo.setProcessTaskId(currentProcessTaskStepVo.getProcessTaskId()); - searchVo.setProcessTaskStepId(currentProcessTaskStepVo.getId()); - searchVo.setType("autoexecCreateJobError"); - ProcessTaskStepDataVo processTaskStepDataVo = processTaskStepDataCrossoverMapper.getProcessTaskStepData(searchVo); - if (processTaskStepDataVo != null) { - JSONObject dataObj = processTaskStepDataVo.getData(); - if (MapUtils.isNotEmpty(dataObj)) { - JSONArray errorList = dataObj.getJSONArray("errorList"); - if (CollectionUtils.isNotEmpty(errorList)) { - resultObj.put("errorList", errorList); - } - } - } - return resultObj; - } - - - @Override - public void updateProcessTaskStepUserAndWorker(Long processTaskId, Long processTaskStepId) { - - } - -// @Override -// public JSONObject makeupConfig(JSONObject configObj) { -// if (configObj == null) { -// configObj = new JSONObject(); -// } -// JSONObject resultObj = new JSONObject(); -// -// /* 授权 **/ -// IOperationType[] stepActions = { -// ProcessTaskStepOperationType.STEP_VIEW, -// ProcessTaskStepOperationType.STEP_TRANSFER -// }; -// JSONArray authorityList = configObj.getJSONArray("authorityList"); -// JSONArray authorityArray = ProcessConfigUtil.regulateAuthorityList(authorityList, stepActions); -// resultObj.put("authorityList", authorityArray); -// -// /* 按钮映射 **/ -// IOperationType[] stepButtons = { -// ProcessTaskStepOperationType.STEP_COMPLETE, -// ProcessTaskStepOperationType.STEP_BACK, -// ProcessTaskOperationType.PROCESSTASK_TRANSFER, -// ProcessTaskStepOperationType.STEP_ACCEPT -// }; -// JSONArray customButtonList = configObj.getJSONArray("customButtonList"); -// JSONArray customButtonArray = ProcessConfigUtil.regulateCustomButtonList(customButtonList, stepButtons); -// resultObj.put("customButtonList", customButtonArray); -// /* 状态映射列表 **/ -// JSONArray customStatusList = configObj.getJSONArray("customStatusList"); -// JSONArray customStatusArray = ProcessConfigUtil.regulateCustomStatusList(customStatusList); -// resultObj.put("customStatusList", customStatusArray); -// -// /* 可替换文本列表 **/ -// resultObj.put("replaceableTextList", ProcessConfigUtil.regulateReplaceableTextList(configObj.getJSONArray("replaceableTextList"))); -// return resultObj; -// } -// -// @Override -// public JSONObject regulateProcessStepConfig(JSONObject configObj) { -// if (configObj == null) { -// configObj = new JSONObject(); -// } -// JSONObject resultObj = new JSONObject(); -// -// /* 授权 **/ -// IOperationType[] stepActions = { -// ProcessTaskStepOperationType.STEP_VIEW, -// ProcessTaskStepOperationType.STEP_TRANSFER -// }; -// JSONArray authorityList = null; -// Integer enableAuthority = configObj.getInteger("enableAuthority"); -// if (Objects.equals(enableAuthority, 1)) { -// authorityList = configObj.getJSONArray("authorityList"); -// } else { -// enableAuthority = 0; -// } -// resultObj.put("enableAuthority", enableAuthority); -// JSONArray authorityArray = ProcessConfigUtil.regulateAuthorityList(authorityList, stepActions); -// resultObj.put("authorityList", authorityArray); -// -// /* 通知 **/ -// JSONObject notifyPolicyConfig = configObj.getJSONObject("notifyPolicyConfig"); -// INotifyServiceCrossoverService notifyServiceCrossoverService = CrossoverServiceFactory.getApi(INotifyServiceCrossoverService.class); -// InvokeNotifyPolicyConfigVo invokeNotifyPolicyConfigVo = notifyServiceCrossoverService.regulateNotifyPolicyConfig(notifyPolicyConfig, AutoexecNotifyPolicyHandler.class); -// resultObj.put("notifyPolicyConfig", invokeNotifyPolicyConfigVo); -// -// /** 动作 **/ -// JSONObject actionConfig = configObj.getJSONObject("actionConfig"); -// ActionConfigVo actionConfigVo = JSONObject.toJavaObject(actionConfig, ActionConfigVo.class); -// if (actionConfigVo == null) { -// actionConfigVo = new ActionConfigVo(); -// } -// actionConfigVo.setHandler(AutoexecNotifyPolicyHandler.class.getName()); -// resultObj.put("actionConfig", actionConfigVo); -// -// /* 按钮映射列表 **/ -// IOperationType[] stepButtons = { -// ProcessTaskStepOperationType.STEP_COMPLETE, -// ProcessTaskStepOperationType.STEP_BACK, -// ProcessTaskOperationType.PROCESSTASK_TRANSFER, -// ProcessTaskStepOperationType.STEP_ACCEPT -// }; -// JSONArray customButtonList = configObj.getJSONArray("customButtonList"); -// JSONArray customButtonArray = ProcessConfigUtil.regulateCustomButtonList(customButtonList, stepButtons); -// resultObj.put("customButtonList", customButtonArray); -// /* 状态映射列表 **/ -// JSONArray customStatusList = configObj.getJSONArray("customStatusList"); -// JSONArray customStatusArray = ProcessConfigUtil.regulateCustomStatusList(customStatusList); -// resultObj.put("customStatusList", customStatusArray); -// -// /* 可替换文本列表 **/ -// resultObj.put("replaceableTextList", ProcessConfigUtil.regulateReplaceableTextList(configObj.getJSONArray("replaceableTextList"))); -// -// /* 自动化配置 **/ -// JSONObject autoexecConfig = configObj.getJSONObject("autoexecConfig"); -// JSONObject autoexecObj = regulateAutoexecConfig(autoexecConfig); -// resultObj.put("autoexecConfig", autoexecObj); -// -// /** 分配处理人 **/ -// JSONObject workerPolicyConfig = configObj.getJSONObject("workerPolicyConfig"); -// JSONObject workerPolicyObj = ProcessConfigUtil.regulateWorkerPolicyConfig(workerPolicyConfig); -// resultObj.put("workerPolicyConfig", workerPolicyObj); -// -// JSONArray tagList = configObj.getJSONArray("tagList"); -// if (tagList == null) { -// tagList = new JSONArray(); -// } -// resultObj.put("tagList", tagList); -// /** 表单场景 **/ -// String formSceneUuid = configObj.getString("formSceneUuid"); -// String formSceneName = configObj.getString("formSceneName"); -// resultObj.put("formSceneUuid", formSceneUuid == null ? "" : formSceneUuid); -// resultObj.put("formSceneName", formSceneName == null ? "" : formSceneName); -// return resultObj; -// } -// -// private JSONObject regulateAutoexecConfig(JSONObject autoexecConfig) { -// JSONObject autoexecObj = new JSONObject(); -// if (autoexecConfig == null) { -// autoexecConfig = new JSONObject(); -// } -// // 失败策略 -// String failPolicy = autoexecConfig.getString("failPolicy"); -// if (failPolicy == null) { -// failPolicy = StringUtils.EMPTY; -// } -// autoexecObj.put("failPolicy", failPolicy); -// // 回退步骤新建作业 -// Integer rerunStepToCreateNewJob = autoexecConfig.getInteger("rerunStepToCreateNewJob"); -// if (rerunStepToCreateNewJob == null) { -// rerunStepToCreateNewJob = 0; -// } -// autoexecObj.put("rerunStepToCreateNewJob", rerunStepToCreateNewJob); -// JSONArray configArray = new JSONArray(); -// JSONArray configList = autoexecConfig.getJSONArray("configList"); -// if (CollectionUtils.isNotEmpty(configList)) { -// for (int i = 0; i < configList.size(); i++) { -// JSONObject config = configList.getJSONObject(i); -// if (MapUtils.isEmpty(config)) { -// continue; -// } -// String createJobPolicy = config.getString("createJobPolicy"); -// if (createJobPolicy == null) { -// continue; -// } -// JSONObject configObj = new JSONObject(); -// configObj.put("createJobPolicy", createJobPolicy); -// Long id = config.getLong("id"); -// if (id == null) { -// id = SnowflakeUtil.uniqueLong(); -// } -// configObj.put("id", id); -// String formTag = config.getString("formTag"); -// if (StringUtils.isBlank(formTag)) { -// formTag = StringUtils.EMPTY; -// } -// configObj.put("formTag", formTag); -// Long autoexecCombopId = config.getLong("autoexecCombopId"); -// if (autoexecCombopId != null) { -// configObj.put("autoexecCombopId", autoexecCombopId); -// } -// String jobName = config.getString("jobName"); -// if (jobName == null) { -// jobName = StringUtils.EMPTY; -// } -// configObj.put("jobName", jobName); -// String jobNamePrefix = config.getString("jobNamePrefix"); -// if (jobNamePrefix == null) { -// jobNamePrefix = StringUtils.EMPTY; -// } -// configObj.put("jobNamePrefix", jobNamePrefix); -// Boolean isShow = config.getBoolean("isShow"); -// if (isShow == null) { -// isShow = false; -// } -// configObj.put("isShow", isShow); -// // 批量创建作业 -// if (Objects.equals(createJobPolicy, "batch")) { -// JSONObject batchJobDataSourceObj = new JSONObject(); -// JSONObject batchJobDataSource = config.getJSONObject("batchJobDataSource"); -// if (MapUtils.isNotEmpty(batchJobDataSource)) { -// String attributeUuid = batchJobDataSource.getString("attributeUuid"); -// if (attributeUuid == null) { -// attributeUuid = StringUtils.EMPTY; -// } -// batchJobDataSourceObj.put("attributeUuid", attributeUuid); -// JSONArray filterArray = new JSONArray(); -// JSONArray filterList = batchJobDataSource.getJSONArray("filterList"); -// if (CollectionUtils.isNotEmpty(filterList)) { -// for (int j = 0; j < filterList.size(); j++) { -// JSONObject filter = filterList.getJSONObject(j); -// if (MapUtils.isEmpty(filter)) { -// continue; -// } -// JSONObject filterObj = new JSONObject(); -// filterObj.put("column", filter.getString("column")); -// filterObj.put("expression", filter.getString("expression")); -// filterObj.put("value", filter.getString("value")); -// filterArray.add(filterObj); -// } -// } -// batchJobDataSourceObj.put("filterList", filterArray); -// } -// configObj.put("batchJobDataSource", batchJobDataSourceObj); -// } -// JSONArray scenarioParamList = config.getJSONArray("scenarioParamList"); -// if (scenarioParamList != null) { -// JSONArray scenarioParamArray = new JSONArray(); -// for (int j = 0; j < scenarioParamList.size(); j++) { -// JSONObject scenarioParamObj = scenarioParamList.getJSONObject(j); -// if (MapUtils.isNotEmpty(scenarioParamObj)) { -// JSONObject scenarioParam = new JSONObject(); -// scenarioParam.put("key", scenarioParamObj.getString("key")); -// scenarioParam.put("name", scenarioParamObj.getString("name")); -// scenarioParam.put("mappingMode", scenarioParamObj.getString("mappingMode")); -// scenarioParam.put("value", scenarioParamObj.get("value")); -// scenarioParam.put("column", scenarioParamObj.getString("column")); -// scenarioParam.put("filterList", scenarioParamObj.getJSONArray("filterList")); -// scenarioParam.put("isRequired", scenarioParamObj.getInteger("isRequired")); -// scenarioParamArray.add(scenarioParam); -// } -// } -// configObj.put("scenarioParamList", scenarioParamArray); -// } -// // 作业参数赋值列表 -// JSONArray runtimeParamList = config.getJSONArray("runtimeParamList"); -// if (runtimeParamList != null) { -// JSONArray runtimeParamArray = new JSONArray(); -// for (int j = 0; j < runtimeParamList.size(); j++) { -// JSONObject runtimeParamObj = runtimeParamList.getJSONObject(j); -// if (MapUtils.isNotEmpty(runtimeParamObj)) { -// JSONObject runtimeParam = new JSONObject(); -// runtimeParam.put("key", runtimeParamObj.getString("key")); -// runtimeParam.put("name", runtimeParamObj.getString("name")); -// runtimeParam.put("mappingMode", runtimeParamObj.getString("mappingMode")); -// runtimeParam.put("value", runtimeParamObj.get("value")); -// runtimeParam.put("column", runtimeParamObj.getString("column")); -// runtimeParam.put("filterList", runtimeParamObj.getJSONArray("filterList")); -// runtimeParam.put("isRequired", runtimeParamObj.getInteger("isRequired")); -// runtimeParam.put("type", runtimeParamObj.getString("type")); -// runtimeParam.put("config", runtimeParamObj.getJSONObject("config")); -// runtimeParamArray.add(runtimeParam); -// } -// } -// configObj.put("runtimeParamList", runtimeParamArray); -// } -// // 目标参数赋值列表 -// JSONArray executeParamList = config.getJSONArray("executeParamList"); -// if (executeParamList != null) { -// JSONArray executeParamArray = new JSONArray(); -// for (int j = 0; j < executeParamList.size(); j++) { -// JSONObject executeParamObj = executeParamList.getJSONObject(j); -// if (MapUtils.isNotEmpty(executeParamObj)) { -// JSONObject executeParam = new JSONObject(); -// executeParam.put("key", executeParamObj.getString("key")); -// executeParam.put("name", executeParamObj.getString("name")); -// executeParam.put("mappingMode", executeParamObj.getString("mappingMode")); -// executeParam.put("value", executeParamObj.get("value")); -// executeParam.put("column", executeParamObj.getString("column")); -// executeParam.put("filterList", executeParamObj.getJSONArray("filterList")); -// executeParam.put("isRequired", executeParamObj.getInteger("isRequired")); -// executeParamArray.add(executeParam); -// } -// } -// configObj.put("executeParamList", executeParamArray); -// } -// // 导出参数列表 -// JSONArray exportParamList = config.getJSONArray("exportParamList"); -// if (exportParamList != null) { -// JSONArray exportParamArray = new JSONArray(); -// for (int j = 0; j < exportParamList.size(); j++) { -// JSONObject exportParamObj = exportParamList.getJSONObject(j); -// if (MapUtils.isNotEmpty(exportParamObj)) { -// JSONObject exportParam = new JSONObject(); -// exportParam.put("value", exportParamObj.getString("value")); -// exportParam.put("text", exportParamObj.getString("text")); -// exportParamArray.add(exportParam); -// } -// } -// configObj.put("exportParamList", exportParamArray); -// } -// // 表单赋值列表 -// JSONArray formAttributeList = config.getJSONArray("formAttributeList"); -// if (formAttributeList != null) { -// JSONArray formAttributeArray = new JSONArray(); -// for (int j = 0; j < formAttributeList.size(); j++) { -// JSONObject formAttributeObj = formAttributeList.getJSONObject(j); -// if (MapUtils.isNotEmpty(formAttributeObj)) { -// JSONObject formAttribute = new JSONObject(); -// formAttribute.put("key", formAttributeObj.getString("key")); -// formAttribute.put("name", formAttributeObj.getString("name")); -// formAttribute.put("value", formAttributeObj.get("value")); -// formAttributeArray.add(formAttribute); -// } -// } -// configObj.put("formAttributeList", formAttributeArray); -// } -// -// //执行器组 -// configObj.put("runnerGroup", config.getJSONObject("runnerGroup")); -// configArray.add(configObj); -// } -// } -// autoexecObj.put("configList", configArray); -// return autoexecObj; -// } -// -// private JSONObject getAutoexecConfig(JSONObject autoexecConfig) { -// JSONObject autoexecObj = new JSONObject(); -// if (autoexecConfig == null) { -// autoexecConfig = new JSONObject(); -// } -// String failPolicy = autoexecConfig.getString("failPolicy"); -// if (failPolicy == null) { -// failPolicy = ""; -// } -// autoexecObj.put("failPolicy", failPolicy); -// Long autoexecTypeId = autoexecConfig.getLong("autoexecTypeId"); -// if (autoexecTypeId != null) { -// autoexecObj.put("autoexecTypeId", autoexecTypeId); -// } -// Long autoexecCombopId = autoexecConfig.getLong("autoexecCombopId"); -// if (autoexecCombopId != null) { -// autoexecObj.put("autoexecCombopId", autoexecCombopId); -// } -// JSONArray runtimeParamList = autoexecConfig.getJSONArray("runtimeParamList"); -// if (runtimeParamList != null) { -// JSONArray runtimeParamArray = new JSONArray(); -// for (int i = 0; i < runtimeParamList.size(); i++) { -// JSONObject runtimeParamObj = runtimeParamList.getJSONObject(i); -// if (MapUtils.isNotEmpty(runtimeParamObj)) { -// JSONObject runtimeParam = new JSONObject(); -// runtimeParam.put("key", runtimeParamObj.getString("key")); -// runtimeParam.put("name", runtimeParamObj.getString("name")); -// runtimeParam.put("mappingMode", runtimeParamObj.getString("mappingMode")); -// runtimeParam.put("value", runtimeParamObj.get("value")); -// runtimeParam.put("isRequired", runtimeParamObj.getInteger("isRequired")); -// runtimeParam.put("type", runtimeParamObj.getString("type")); -// runtimeParam.put("config", runtimeParamObj.get("config")); -// runtimeParamArray.add(runtimeParam); -// } -// } -// autoexecObj.put("runtimeParamList", runtimeParamArray); -// } -// JSONArray executeParamList = autoexecConfig.getJSONArray("executeParamList"); -// if (executeParamList != null) { -// JSONArray executeParamArray = new JSONArray(); -// for (int i = 0; i < executeParamList.size(); i++) { -// JSONObject executeParamObj = executeParamList.getJSONObject(i); -// if (MapUtils.isNotEmpty(executeParamObj)) { -// JSONObject executeParam = new JSONObject(); -// executeParam.put("key", executeParamObj.getString("key")); -// executeParam.put("name", executeParamObj.getString("name")); -// executeParam.put("mappingMode", executeParamObj.getString("mappingMode")); -// executeParam.put("value", executeParamObj.get("value")); -// executeParam.put("isRequired", executeParamObj.getInteger("isRequired")); -// executeParamArray.add(executeParam); -// } -// } -// autoexecObj.put("executeParamList", executeParamArray); -// } -// JSONArray exportParamList = autoexecConfig.getJSONArray("exportParamList"); -// if (exportParamList != null) { -// JSONArray exportParamArray = new JSONArray(); -// for (int i = 0; i < exportParamList.size(); i++) { -// JSONObject exportParamObj = exportParamList.getJSONObject(i); -// if (MapUtils.isNotEmpty(exportParamObj)) { -// JSONObject exportParam = new JSONObject(); -// exportParam.put("value", exportParamObj.getString("value")); -// exportParam.put("text", exportParamObj.getString("text")); -// exportParamArray.add(exportParam); -// } -// } -// autoexecObj.put("exportParamList", exportParamArray); -// } -// JSONArray formAttributeList = autoexecConfig.getJSONArray("formAttributeList"); -// if (formAttributeList != null) { -// JSONArray formAttributeArray = new JSONArray(); -// for (int i = 0; i < formAttributeList.size(); i++) { -// JSONObject formAttributeObj = formAttributeList.getJSONObject(i); -// if (MapUtils.isNotEmpty(formAttributeObj)) { -// JSONObject formAttribute = new JSONObject(); -// formAttribute.put("key", formAttributeObj.getString("key")); -// formAttribute.put("name", formAttributeObj.getString("name")); -// formAttribute.put("value", formAttributeObj.get("value")); -// formAttributeArray.add(formAttribute); -// } -// } -// autoexecObj.put("formAttributeList", formAttributeArray); -// } -// return autoexecObj; -// } -}