直接贴代码,不懂可说明:
/**
* 获取下一个节点的信息测试
*/
@Test
public void testNextTasks() {
//流程实例id
String processInstanceId = "5b945750-81db-11e9-a576-1a73f8e23adc";
//当前任务信息
Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();
//获取流程发布Id信息
String definitionId = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult().getProcessDefinitionId();
//获取bpm对象
BpmnModel bpmnModel = repositoryService.getBpmnModel(definitionId);
//传节点定义key 获取当前节点
FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(task.getTaskDefinitionKey());
//输出连线
List<SequenceFlow> outgoingFlows = flowNode.getOutgoingFlows();
//遍历返回下一个节点信息
for (SequenceFlow outgoingFlow : outgoingFlows) {
//类型自己判断
FlowElement targetFlowElement = outgoingFlow.getTargetFlowElement();
//用户任务
if (targetFlowElement instanceof UserTask) {
//。。。
}
else if (targetFlowElement instanceof ExclusiveGateway) {
setExclusiveGateway(targetFlowElement);
}
}
}
private void setExclusiveGateway(FlowElement targetFlow) {
//排他网关,获取连线信息
List<SequenceFlow> targetFlows = ((ExclusiveGateway) targetFlow).getOutgoingFlows();
for (SequenceFlow sequenceFlow : targetFlows) {
//目标节点信息
FlowElement targetFlowElement = sequenceFlow.getTargetFlowElement();
if (targetFlowElement instanceof UserTask) {
// do something
} else if (targetFlowElement instanceof EndEvent) {
// do something
} else if (targetFlowElement instanceof ServiceTask) {
// do something
} else if (targetFlowElement instanceof ExclusiveGateway) {
//递归寻找
setExclusiveGateway(targetFlowElement);
} else if (targetFlowElement instanceof SubProcess) {
// do something
}
}
}
//获取所有节点信息:
https://blog.youkuaiyun.com/double_hll123/article/details/97111583
activiti&flowable获取下一个节点信息
于 2019-05-30 15:44:33 首次发布
博客涉及Flowable、Activity和BPMN相关内容,虽未给出具体内容,但这些均为信息技术领域中工作流管理相关概念。Flowable是开源工作流引擎,Activity是流程中的活动,BPMN是业务流程建模符号,用于业务流程可视化。

9635

被折叠的 条评论
为什么被折叠?



