spring - Activiti - 结束进程实例结束的结束事件的名称
问题描述
我想获取我的流程实例结束的结束事件的名称。我正在使用 Activiti 版本 7(activit 的 spring boot starter)。有人可以帮忙吗?
解决方案
嗨,我也有类似的问题,我知道这现在有点老了,但仍然......
您可以使用 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
推荐阅读
- powerpoint - IBM Watson Discovery 是否支持“.PPT”格式的文档?
- java - 尝试制作自动类型的数组时出错
- c++ - QFile::copy 是否将源文件权限保留在复制的文件中?
- java - Kotlin 错误:“public”函数暴露了它的“public/*package*/”返回类型参数
- mocha.js - 测试混合的基于异步/承诺的代码和基于回调的代码
- codeigniter - 如何将设置规则中的多个参数发送到codeIgniter中的公共函数
- sql - 如何在 SQL 表的开头添加行号列?
- javascript - 获取在 ajax 函数之后动态加载的正确表单 id 格式
- php - 获取数据后创建文件'php'
- javascript - 有换行符时切断文本