activiti6节点跳转设计

这篇博客详细介绍了在工作流开发中,如何处理国内需求中流程节点的任意跳转问题。作者提供了一段代码实现普通流程节点的跳转,并针对并行网关的情况提出两种解决方案。其中,第一种方案涉及为每个出线创建新的任务和执行记录,而第二种方案限制并行网关内节点不允许驳回。此外,还分享了一个判断节点是否被并行网关包围的递归方法,虽然存在优化空间,但已能有效解决问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

简介:工作流开发过程中,因为国内的需求变态原因,会有流程图节点任意跳转的需求

一.普通的流程跳转设计

因为普通流程只需要根据连线进行节点跳转就行直接贴代码:


        //获取流程定义
        Process process = repositoryService.getBpmnModel(processDefinitionId).getMainProcess();
        //获取目标节点定义
        FlowNode targetNode = (FlowNode) process.getFlowElement(flowElementId);
        List<Execution> executionList = runtimeService.createExecutionQuery().parentId(taskList.get(0).getProcessInstanceId()).list();
        Execution newExecution = executionList.remove(0);
        //流程执行到来源节点
        managementService.executeCommand(new SetNodeAndGoCmd(targetNode, newExecution.getId()));
        if (CollectionUtil.isNotEmpty(executionList)) {
            List<String> ids = executionList.stream().map(Execution::getId).collect(Collectors.toList());
            managementService.executeCommand(new DeleteExecutionCmd(ids));
        }
        //删除当前运行任务
        for (Task currentTask : taskList) {
            managementService.executeCommand(new DeleteTaskCmd(currentTask.getId()));
        }
@Slf4j
public class SetNodeAndGoCmd implements Command<Void> {

    private FlowNode flowElement;
    private String executionId;
    private String executionName;
    private String startUserId;

    public SetNodeAndGoCmd(FlowNode flowElement, String executionId) {
        this.flowElement = flowElement;
        this.executionId = executionId;
    }

    publ
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值