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

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


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


}
}


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

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