diff --git a/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/common/service/impl/PmsCommonAsyncServiceImpl.java b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/common/service/impl/PmsCommonAsyncServiceImpl.java index 816c6e7d9..cf8057434 100644 --- a/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/common/service/impl/PmsCommonAsyncServiceImpl.java +++ b/microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/common/service/impl/PmsCommonAsyncServiceImpl.java @@ -241,6 +241,12 @@ public class PmsCommonAsyncServiceImpl implements IPmsCommonAsyncService { return teamId; } + /** + * 同步Forge组织中成员到工作台中(未同步的用户需在Forge中移除) + * + * @param enterpriseId 企业id + * @param gitLinkUserToEnterpriseInputVoList 需要同步到企业的用户列表 + */ @Override public void syncGitlinkOrganizationUserToPmsEnterprise(Long enterpriseId, List gitLinkUserToEnterpriseInputVoList) { CustomExecutorFactory.threadPoolExecutor.execute(() -> { @@ -260,6 +266,25 @@ public class PmsCommonAsyncServiceImpl implements IPmsCommonAsyncService { Long pmsProjectAdminTeamId = getGitlinkOrgTeamIdByTeamKey(pmsEnterprise, PmsConstants.GITLINK_ORGANIZATION_TEAM_ADMIN); Long pmsUserTeamId = getGitlinkOrgTeamIdByTeamKey(pmsEnterprise, PmsConstants.GITLINK_ORGANIZATION_TEAM_WRITE); + // 获取原Owner团队中成员列表 + List oldOwnerUserList = pmsCommonService.getAllGitlinkUsersByOrgTeam(pmsEnterprise.getEnterpriseIdentifier(), ownerTeamId); + List newOwnerUserIdList = gitLinkUserToEnterpriseInputVoList + .stream() + .filter(x -> x.getRoleKey().equals(SystemRole.PMS_ORG_ADMIN.getRoleKey())) + .map(GitLinkUserToEnterpriseInputVo::getUserId) + .collect(Collectors.toList()); + + // 删除原Owner团队中不在新Owner团队中的成员 + List removeUserIdList = oldOwnerUserList + .stream() + .filter(x -> !newOwnerUserIdList.contains(x.getUserId())) + .collect(Collectors.toList()); + for (GitLinkUserSimpleInfoVo gitLinkUserSimpleInfoVo : removeUserIdList) { + gitLinkRequestHelper.doDelete( + PmsGitLinkRequestUrl.DELETE_USER_FROM_ORGANIZATION_TEAM(pmsEnterprise.getEnterpriseIdentifier(), ownerTeamId, gitLinkUserSimpleInfoVo.getUsername())); + } + + JSONObject addUserToTeam = new JSONObject(); // 将用户添加到微服务部门中并调整到对应团队中 for (GitLinkUserToEnterpriseInputVo gitLinkUserToEnterpriseInputVo : gitLinkUserToEnterpriseInputVoList) {