flowable 获取当前以及下一任务节点

/**
 * 获取任务节点
 *
 * @param node   查询节点选择
 * @param taskId 任务id
 */
public void nextFlowNode(String node, String taskId) {
    
    
    Task task = processEngine().getTaskService().createTaskQuery().taskId(taskId).singleResult();
    ExecutionEntity ee = (ExecutionEntity) processEngine().getRuntimeService().createExecutionQuery()
            .executionId(task.getExecutionId()).singleResult();
    // 当前审批节点
    String crruentActivityId = ee.getActivityId();
    BpmnModel bpmnModel = processEngine().getRepositoryService().getBpmnModel(task.getProcessDefinitionId());
    FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(crruentActivityId);
    // 输出连线
    List<SequenceFlow> outFlows = flowNode.getOutgoingFlows();
    for (SequenceFlow sequenceFlow : outFlows) {
    
    
        //当前审批节点
        if ("now".equals(node)) {
    
    
            FlowElement sourceFlowElement = sequenceFlow.getSourceFlowElement();
            System.out.println("当前节点: id=" + sourceFlowElement.getId() + ",name=" + sourceFlowElement.getName());
        } else if ("next".equals(node)) {
    
    
            // 下一个审批节点
            FlowElement targetFlow = sequenceFlow.getTargetFlowElement();
            if (targetFlow instanceof UserTask) {
    
    
                System.out.println("下一节点: id=" + targetFlow.getId() + ",name=" + targetFlow.getName());
            }
            // 如果下个审批节点为结束节点
            if (targetFlow instanceof EndEvent) {
    
    
                System.out.println("下一节点为结束节点:id=" + targetFlow.getId() + ",name=" + targetFlow.getName());
            }
        }


    }
}
————————————————
版权声明:本文为CSDN博主「FYRT」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_36760953/article/details/91410038

猜你喜欢

转载自blog.csdn.net/weixin_40816738/article/details/125680742