flowable 根据流程实例id查找流程定义id
时间: 2023-08-04 21:05:54 浏览: 123
可以使用 Flowable 的 `RepositoryService` 接口中的 `getProcessDefinitionIdByProcesInstanceId(String processInstanceId)` 方法来根据流程实例 ID 查找流程定义 ID。示例代码如下:
```
RepositoryService repositoryService = processEngine.getRepositoryService();
String processInstanceId = "12345";
String processDefinitionId = repositoryService.getProcessDefinitionIdByProcesInstanceId(processInstanceId);
```
需要注意的是,需要先创建 `ProcessEngine` 对象并获取 `RepositoryService` 对象,才能调用该方法。同时,需要替换 `processInstanceId` 的值为实际的流程实例 ID。
相关问题
flowable 根据流程实例id 查询参数nrOfCompletedInstances
可以通过调用 Flowable 的 API 来根据流程实例 ID 查询参数 nrOfCompletedInstances。具体的代码示例可以参考下面的 Java 代码:
```
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
.processInstanceId(processInstanceId)
.singleResult();
if (processInstance != null) {
int nrOfCompletedInstances = runtimeService.getVariable(processInstance.getId(), "nrOfCompletedInstances");
// 处理 nrOfCompletedInstances 的值
} else {
// 流程实例不存在的处理逻辑
}
```
其中,processInstanceId 是要查询的流程实例 ID,nrOfCompletedInstances 是要查询的参数名称。如果流程实例不存在,则会返回 null。
flowable 根据实例id查询流程实例
您好!根据实例id查询流程实例可以使用Flowable提供的查询API,如下所示:
```
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
.processInstanceId(instanceId)
.singleResult();
```
其中,`instanceId`为流程实例的ID。这个方法会返回一个`ProcessInstance`对象,您可以通过该对象获取流程实例的各种信息。如果找不到对应的流程实例,返回值为`null`。