activity工作流判断下一节点的下一节点是否为结束节点

public boolean checkIsSetNextUser(String taskId){
    boolean isSetNextUser = false;
    Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
    String nodeId = task.getTaskDefinitionKey();
    //用户任务集合
    List<UserTask> userTasks = new ArrayList<>();
    String processDefinitionId = task.getProcessDefinitionId();
    BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
    List<Process> processes = bpmnModel.getProcesses();
    Process process = processes.get(0);
    Collection<FlowElement> flowElements = process.getFlowElements();

    //用户任务节点id
    List<String> usertaskNodelIdList = new ArrayList<>();

    //放置endEvent的nodeId
    AtomicReference<String> endEventId = new AtomicReference<>("");

    //将网关信息与用户任务进行分类存储(放于JVM堆中)
    flowElements.forEach(flowElement -> {
        if (flowElement instanceof UserTask) {
            usertaskNodelIdList.add(flowElement.getId());
            userTasks.add((UserTask) flowElement);
        }
        if (flowElement instanceof EndEvent) {
            endEventId.set(flowElement.getId());
        }
    });

    //变量所有的UserTask节点
    for (UserTask userTask : userTasks) {
        //获取UserTask节点的出线
        List<SequenceFlow> outgoingFlows = userTask.getOutgoingFlows();
        for (SequenceFlow outgoingFlow : outgoingFlows) {
            String sourceRef = outgoingFlow.getSourceRef();
            String targetRef = outgoingFlow.getTargetRef();
            //固定出线的(sourceRef)
            if (nodeId.equals(sourceRef)) {
                nodeId = targetRef;
                if (targetRef.equals(endEventId.get())){
                    isSetNextUser = true;
                }
            }
        }
    }

    return isSetNextUser;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值