当前位置:首页 > IT技术 > 其他 > 正文

flowable 获取当前以及下一任务节点
2022-09-06 22:50:03


/**
* 获取任务节点
*
* @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());
}
}


}
}


本文摘自 :https://blog.51cto.com/g

开通会员,享受整站包年服务立即开通 >