activiti&flowable获取下一个审批节点

flowable抛弃了activiti的部分接口实现,实现方式有所区别,具体看代码对比:

       

@Test
    public void acvitivi()
    {
        String taskId = "65002";
        Task task = processEngine.getTaskService().createTaskQuery().taskId(taskId).singleResult();
        ProcessDefinitionEntity pde = (ProcessDefinitionEntity) processEngine.getRepositoryService()
                .getProcessDefinition(task.getProcessDefinitionId());
        String taskKey = task.getTaskDefinitionKey();
        ActivityImpl activityImpl = pde.findActivity(taskKey);
        List pvms = activityImpl.getOutgoingTransitions();
        for (PvmTransition pvm : pvms)
        {
            PvmActivity pvmActivity = pvm.getDestination();
            if (pvmActivity.getOutgoingTransitions().isEmpty())
            {
                System.out.println(pvmActivity.getId() + "," + pvmActivity.getProperty("name"));
            }

        }

    }

@Test
    public void flowable()
    {
        Task task = processEngine.getTaskService().createTaskQuery().taskId("80003").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 outFlows = flowNode.getOutgoingFlows();
        for (SequenceFlow sequenceFlow : outFlows)
        {
            // 下一个审批节点
            FlowElement targetFlow = sequenceFlow.getTargetFlowElement();
            if (targetFlow instanceof EndEvent)
            {// 如果下个审批节点为结束节点
                System.out.println(sequenceFlow.getId() + "," + sequenceFlow.getName() + ","
                        + sequenceFlow.getTargetFlowElement());
            }
        }
    }

你可能感兴趣的:(activiti&flowable获取下一个审批节点)