应用迁移到团队应用里配置GIT
This commit is contained in:
parent
4f28a9d3e5
commit
d0538de830
@ -330,25 +330,36 @@ public class RepositoryProjectServiceImpl extends BaseServiceImpl<RepositoryProj
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. 收集所有仓库组的 repo_group_id(Git系统的组ID,不是数据库主键)
|
// 1. 收集所有仓库组的 repo_group_id 和 external_system_id
|
||||||
Set<Long> repoGroupIds = projects.stream()
|
Set<Long> repoGroupIds = projects.stream()
|
||||||
.map(RepositoryProjectDTO::getRepoGroupId)
|
.map(RepositoryProjectDTO::getRepoGroupId)
|
||||||
.filter(id -> id != null)
|
.filter(id -> id != null)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
// 2. 批量查询仓库组信息(根据 repo_group_id 字段查询,不是主键 id)
|
Set<Long> externalSystemIds = projects.stream()
|
||||||
Map<Long, RepositoryGroup> repoGroupMap = Collections.emptyMap();
|
.map(RepositoryProjectDTO::getExternalSystemId)
|
||||||
|
.filter(id -> id != null)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
// 2. 批量查询仓库组信息(需要同时匹配 repo_group_id 和 external_system_id)
|
||||||
|
Map<String, RepositoryGroup> repoGroupMap = Collections.emptyMap();
|
||||||
if (!repoGroupIds.isEmpty()) {
|
if (!repoGroupIds.isEmpty()) {
|
||||||
List<Long> repoGroupIdList = new ArrayList<>(repoGroupIds);
|
List<Long> repoGroupIdList = new ArrayList<>(repoGroupIds);
|
||||||
|
// 使用复合键:externalSystemId + "_" + repoGroupId 避免不同系统的 ID 冲突
|
||||||
repoGroupMap = repositoryGroupRepository.findByRepoGroupIdIn(repoGroupIdList).stream()
|
repoGroupMap = repositoryGroupRepository.findByRepoGroupIdIn(repoGroupIdList).stream()
|
||||||
.collect(Collectors.toMap(RepositoryGroup::getRepoGroupId, Function.identity()));
|
.filter(group -> externalSystemIds.contains(group.getExternalSystemId()))
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
group -> group.getExternalSystemId() + "_" + group.getRepoGroupId(),
|
||||||
|
Function.identity()
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 填充仓库组名称(使用 repo_group_id 作为 key)
|
// 3. 填充仓库组名称(使用复合键:externalSystemId + "_" + repoGroupId)
|
||||||
Map<Long, RepositoryGroup> finalRepoGroupMap = repoGroupMap;
|
Map<String, RepositoryGroup> finalRepoGroupMap = repoGroupMap;
|
||||||
projects.forEach(project -> {
|
projects.forEach(project -> {
|
||||||
if (project.getRepoGroupId() != null) {
|
if (project.getRepoGroupId() != null && project.getExternalSystemId() != null) {
|
||||||
RepositoryGroup group = finalRepoGroupMap.get(project.getRepoGroupId());
|
String key = project.getExternalSystemId() + "_" + project.getRepoGroupId();
|
||||||
|
RepositoryGroup group = finalRepoGroupMap.get(key);
|
||||||
if (group != null) {
|
if (group != null) {
|
||||||
project.setRepoGroupName(group.getName());
|
project.setRepoGroupName(group.getName());
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user