use of com.ibeiliao.deployment.admin.vo.account.AdminAccount in project Corgi by kevinYin.
the class ProjectServiceImpl method fillJoinerNamesIntoProject.
private void fillJoinerNamesIntoProject(List<Project> projects) {
if (CollectionUtils.isEmpty(projects)) {
return;
}
// 创建项目和账户关系
ArrayList<Integer> projectIds = Lists.newArrayList();
for (Project project : projects) {
projectIds.add(project.getProjectId());
}
List<ProjectAccountRelation> relations = relationService.getByProjectIds(projectIds);
Map<String, ProjectAccountRelation> acntProId2RelationMap = buildAccount2RelationMap(relations);
ArrayList<Long> accountIds = Lists.newArrayList();
for (ProjectAccountRelation relation : relations) {
accountIds.add(relation.getAccountId());
}
ArrayListMultimap<Integer, Long> projectId2RelationPOsMap = ArrayListMultimap.create();
for (ProjectAccountRelation relation : relations) {
projectId2RelationPOsMap.put(relation.getProjectId(), relation.getAccountId());
}
// 账户和名字map
List<AdminAccount> accountList = adminAccountService.findByAccountIds(accountIds);
HashMap<Long, String> accountId2RealNameMap = Maps.newHashMap();
for (AdminAccount account : accountList) {
accountId2RealNameMap.put(account.getUid(), account.getRealname());
}
for (Project project : projects) {
List<Long> joinerAccountIds = projectId2RelationPOsMap.get(project.getProjectId());
List<String> projectJoiners = Lists.newArrayList();
List<String> projectManagers = Lists.newArrayList();
for (Long joinerAccountId : joinerAccountIds) {
if (acntProId2RelationMap.get(joinerAccountId + "-" + project.getProjectId()).getIsAdmin() == Constants.TRUE) {
projectManagers.add(accountId2RealNameMap.get(joinerAccountId));
} else {
projectJoiners.add(accountId2RealNameMap.get(joinerAccountId));
}
}
project.setJoinerNames(StringUtils.join(projectJoiners, ","));
project.setManagers(StringUtils.join(projectManagers, ","));
}
}
Aggregations