flowable6.5 根据流程实例id 查询当前多实例节点的完成数
时间: 2023-10-06 13:09:13 浏览: 82
可以使用 Flowable 的 HistoryService 中的 createHistoricActivityInstanceQuery 方法来查询当前多实例节点的完成数。具体步骤如下:
1. 获取 HistoryService 对象:
```
HistoryService historyService = processEngine.getHistoryService();
```
2. 构造 HistoricActivityInstanceQuery 对象:
```
HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery()
.processInstanceId(processInstanceId) // 流程实例id
.activityId(activityId) // 多实例节点id
.executionId(executionId) // 多实例节点执行id
.finished(); // 已完成的活动实例
```
其中,activityId 和 executionId 可以通过查询当前任务的 Task 对象获取。
3. 查询数量:
```
long count = query.count();
```
这样就可以获取当前多实例节点的完成数了。
相关问题
flowable6.5 根据流程实例id 查询当前多实例节点的实例数
可以使用 Flowable 的 RuntimeService 中的 createExecutionQuery 方法来查询当前多实例节点的实例数。具体步骤如下:
1. 获取 RuntimeService 对象:
```
RuntimeService runtimeService = processEngine.getRuntimeService();
```
2. 构造 ExecutionQuery 对象:
```
ExecutionQuery query = runtimeService.createExecutionQuery()
.processInstanceId(processInstanceId) // 流程实例id
.activityId(activityId) // 多实例节点id
.parentId(executionId); // 父执行id
```
其中,activityId 和 executionId 可以通过查询当前任务的 Task 对象获取。
3. 查询数量:
```
long count = query.count();
```
这样就可以获取当前多实例节点的实例数了。
flowable6.5 根据流程实例id获取当前多实例节点的nrOfCompletedInstances
可以通过以下代码获取当前多实例节点的 nrOfCompletedInstances:
```
List<Execution> executions = runtimeService.createExecutionQuery()
.processInstanceId(processInstanceId)
.activityId(activityId)
.list();
int nrOfCompletedInstances = 0;
for (Execution execution : executions) {
Integer completedInstances = (Integer) runtimeService.getVariable(execution.getId(), "nrOfCompletedInstances");
if (completedInstances != null) {
nrOfCompletedInstances += completedInstances;
}
}
```
其中,processInstanceId 为流程实例 ID,activityId 为多实例节点的 ID。首先通过 createExecutionQuery() 方法创建查询对象,然后设置 processInstanceId 和 activityId 进行筛选。接着遍历所有符合条件的执行对象,通过 getVariable() 方法获取 nrOfCompletedInstances 变量的值,并累加到 nrOfCompletedInstances 变量中。最后,得到的 nrOfCompletedInstances 就是当前多实例节点已完成的实例数。
阅读全文
相关推荐
![eddx](https://img-home.csdnimg.cn/images/20250102104920.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)