Flowable获取下一个节点审批人和审批组

@Override
	public void getNextStepList(String taskId, String processInstanceId) throws IllegalAccessException {
		// taskService、repositoryService 等容器对象获取省略...
		// 存储当前节点的下一环节的所有用户节点
		ArrayList<UserTask> userTaskList = new ArrayList<>();

		Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
		//获取流程定义id
		String 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());
			}
		}
	}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值