@Overridepublic void getNextStepList(String taskId, String processInstanceId) throws IllegalAccessException {// taskService、repositoryService 等容器对象获取省略...// 存储当前节点的下一环节的所有用户节点ArrayList<UserTask> userTaskList = new ArrayList<>();Task task = taskService.createTaskQuery().taskId(taskId).singleResult();//获取流程定义idString definitionId = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult().getProcessDefinitionId();//获取bpmn对象BpmnModel bpmnModel = repositoryService.getBpmnModel(definitionId);//遍历返回下一个环节所有用户节点getNextUserTaskList(userTaskList, bpmnModel, task.getTaskDefinitionKey());//输出for (UserTask userTask : userTaskList) {System.out.println("下一个节点id:" + userTask.getId() + " 下一个节点名称:" + userTask.getName()+" 下一个节点审批人:" + userTask.getAssignee()+" 下一个节点候选组:" + (userTask.getCandidateGroups()!=null?userTask.getCandidateGroups().get(0):""));}}private void getNextUserTaskList(ArrayList<UserTask> userTaskList, BpmnModel bpmnModel, String currentId) {//通过节点定义id获取当前节点FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(currentId);//当前节点所有输出顺序流List<SequenceFlow> outgoingFlows = flowNode.getOutgoingFlows();FlowElement targetFlowElement = null;for (SequenceFlow outgoingFlow : outgoingFlows) {// 忽略非正常流转的节点,"${pass}"为自定义的流转表达式if (outgoingFlow.getConditionExpression() != null && !"${pass}".equals(outgoingFlow.getConditionExpression())) {continue;}targetFlowElement = outgoingFlow.getTargetFlowElement();//用户节点if (targetFlowElement instanceof UserTask) {userTaskList.add((UserTask) targetFlowElement);} else if (targetFlowElement instanceof EndEvent) {// 结束节点}else {// 没有找到用户节点,且下一节点不是最后一个节点,继续查找getNextUserTaskList(userTaskList, bpmnModel, targetFlowElement.getId());}}}