执行以下代码以重新启动 Camunda 中的进程。但是对于新进程,案例实例 ID 为空。获取案例实例 ID 还需要什么?
List<HistoricTaskInstance> sql = processEngine.getHistoryService().createHistoricTaskInstanceQuery()
.processInstanceBusinessKey(caseId).orderByTaskName().desc().list();
HistoricTaskInstance historicTaskInstance = sql.get(0);
logger.info("{}", historicTaskInstance);
logger.info("{}", historicTaskInstance.getCaseInstanceId());
runtimeService.restartProcessInstances(historicTaskInstance.getProcessDefinitionId()).initialSetOfVariables()
.startBeforeActivity(historicTaskInstance.getTaskDefinitionKey())
.processInstanceIds(historicTaskInstance.getProcessInstanceId()).execute();