update - 调整 tenantId 的用法逻辑
This commit is contained in:
parent
78d54bfac9
commit
9c9046db5b
@ -188,19 +188,27 @@ public class BpmnProcessDefinitionServiceImpl implements BpmnProcessDefinitionSe
|
||||
|
||||
@Override
|
||||
public BpmnProcessDefinitionVO getActiveProcessDefinitionByKey(String key, String tenantId) {
|
||||
ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery()
|
||||
List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery()
|
||||
.processDefinitionKey(key)
|
||||
.latestVersion();
|
||||
if (StringUtils.hasLength(tenantId)) {
|
||||
query.processDefinitionTenantId(tenantId);
|
||||
} else {
|
||||
// 公共模型没有租户
|
||||
query.processDefinitionTenantId("");
|
||||
}
|
||||
ProcessDefinition processDefinition = query.singleResult();
|
||||
if (Objects.isNull(processDefinition)) {
|
||||
.list();
|
||||
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
throw new WorkflowEngineException(PROCESS_DEFINITION_KEY_NOT_EXISTS, key);
|
||||
}
|
||||
|
||||
ProcessDefinition processDefinition;
|
||||
List<ProcessDefinition> filterDefinitions = list.stream()
|
||||
.filter(i -> Objects.equals(tenantId, i.getTenantId()) || Objects.equals("", i.getTenantId()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(filterDefinitions)) {
|
||||
throw new WorkflowEngineException(PROCESS_DEFINITION_KEY_NOT_EXISTS, key);
|
||||
} else if (filterDefinitions.size() == 1) {
|
||||
processDefinition = filterDefinitions.get(0);
|
||||
} else {
|
||||
processDefinition = filterDefinitions.stream().filter(i -> Objects.equals(tenantId, i.getKey())).findFirst()
|
||||
.orElseThrow(() -> new WorkflowEngineException(PROCESS_DEFINITION_ID_NOT_EXISTS));
|
||||
}
|
||||
|
||||
return processDefinitionConverter.toVo(processDefinition);
|
||||
}
|
||||
|
||||
|
||||
@ -248,7 +248,7 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
|
||||
.businessKey(dto.getBusinessKey())
|
||||
.variables(dto.getVariables())
|
||||
.name(name)
|
||||
.tenantId(dto.getInitiator().getTenantId())
|
||||
.overrideProcessDefinitionTenantId(dto.getTenantId())
|
||||
.start();
|
||||
return instance.getProcessInstanceId();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user