flowable中 获取流程中任务节点的方法有好几种
1.这种是常见的一种
获取流程 正在激活 中任务节点
List<HistoricActivityInstance> historicActivityInstanceList = historyService.createHistoricActivityInstanceQuery()
.processInstanceId(procInsId)
.activityTypes(CollUtil.newHashSet(BpmnXMLConstants.ELEMENT_EVENT_START, BpmnXMLConstants.ELEMENT_EVENT_END, BpmnXMLConstants.ELEMENT_TASK_USER))
.orderByHistoricActivityInstanceStartTime().desc()
.orderByHistoricActivityInstanceEndTime().desc()
.list();
// 构建查询条件
HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery()
.processInstanceId(procInsId);
List<HistoricActivityInstance> allActivityInstanceList = query.list();
一般是 未完成审核流程 所处当前节点 之前所有节点及 下一个节点
2.获取流程 所有 任务节点
List<HistoricActivityInstance> historicActivityInstanceList = historyService.createHistoricActivityInstanceQuery()
.processInstanceId(procInsId)
.orderByHistoricActivityInstanceStartTime().desc()
.orderByHistoricActivityInstanceEndTime().desc()
.list();
HistoricProcessInstance historicProcIns = historyService.createHistoricProcessInstanceQuery()
.processInstanceId(procInsId)
.includeProcessVariables()
.singleResult();
// 获取Bpmn模型信息
InputStream inputStream = repositoryService.getProcessModel(historicProcIns.getProcessDefinitionId());
String bpmnXmlStr = StrUtil.utf8Str(IoUtil.readBytes(inputStream, false));
BpmnModel bpmnModel = ModelUtils.getBpmnModel(bpmnXmlStr);
System.out.println(bpmnModel);
// Activity_02nvulp
// bpmnModel.getProcesses().get(0).getFlowElements().forEach(item -> System.out.println(item.getName()));
if(ObjectUtil.isNotEmpty(taskId)){
// 获取当前节点
// String currentTaskId = taskId;
// 获取当前节点的连线
List<SequenceFlow> outgoingFlows = ModelUtils.getElementOutgoingFlows(ModelUtils.getFlowElementById(bpmnModel, taskId));
事实上就是解析流程 bpmn xml文件 获取到所有节点