我想要获取我的流程实例在其中结束的结束事件的名称。我使用的是Activiti版本7(activit的spring boot starter )。有人能帮上忙吗?
发布于 2020-09-17 22:56:57
嗨,我也有类似的问题,我知道这是有点老了,但仍然…
你可以使用HistoryService来完成进程(假设你已经了解了它的一些id )
@Autowired
private HistoryService historyService;请考虑我的代码片段,它将由于路径结束而实际结束进程
Map<String, Object> params = new HashMap<>(); // Some params
Task task = taskService.createTaskQuery()
.processInstanceId(processId)
.singleResult();
taskService.complete(task.getId(), params); //params optional, this ends whole process
List<HistoricVariableInstance> allVars = historyService
.createHistoricVariableInstanceQuery()
.processInstanceId(navTask.getProcessId())
.list();
//return to user all filled in forms etc.
HistoricProcessInstance historicProcess = historyService.createHistoricProcessInstanceQuery().processInstanceId(navTask.getProcessId()).singleResult();
String endId = historicProcess.getEndActivityId(); //This returns ID where your process ended如果结束活动的id不够多,可以继续挖掘:
String procDefId = historicProcess.getProcessDefinitionId()
FlowElement flowEl = repositoryService.getBpmnModel(procDefId).getMainProcess().getFlowElements()
.stream()
.filter(flowElement -> flowElement.getId().equals("endId"))
.findFirst()
.orElseThrow(IllegalStateException::new)
flowEl.getName() //your name and other stuff you need 最重要的一点是:在我的例子中,历史记录没有持久化,必须使用spring.activiti.historyLevel=activity和spring.activiti.dbHistoryUsed=true更新应用程序属性
https://stackoverflow.com/questions/63558695
复制相似问题