當(dāng)前位置:首頁 > IT技術(shù) > 其他 > 正文

flowable 獲取當(dāng)前以及下一任務(wù)節(jié)點
2022-09-06 22:50:03


/**
* 獲取任務(wù)節(jié)點
*
* @param node 查詢節(jié)點選擇
* @param taskId 任務(wù)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();
// 當(dāng)前審批節(jié)點
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) {
//當(dāng)前審批節(jié)點
if ("now".equals(node)) {
FlowElement sourceFlowElement = sequenceFlow.getSourceFlowElement();
System.out.println("當(dāng)前節(jié)點: id=" + sourceFlowElement.getId() + ",name=" + sourceFlowElement.getName());
} else if ("next".equals(node)) {
// 下一個審批節(jié)點
FlowElement targetFlow = sequenceFlow.getTargetFlowElement();
if (targetFlow instanceof UserTask) {
System.out.println("下一節(jié)點: id=" + targetFlow.getId() + ",name=" + targetFlow.getName());
}
// 如果下個審批節(jié)點為結(jié)束節(jié)點
if (targetFlow instanceof EndEvent) {
System.out.println("下一節(jié)點為結(jié)束節(jié)點:id=" + targetFlow.getId() + ",name=" + targetFlow.getName());
}
}


}
}


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

開通會員,享受整站包年服務(wù)立即開通 >