use of com.ibeiliao.deployment.admin.vo.project.ProjectAccountRelation in project Corgi by kevinYin.
the class InitTestDataService method createProject.
private Project createProject(AdminAccount account) {
Project project = new Project();
project.setJoinerNames(account.getRealname());
project.setProjectName("测试项目");
project.setManagerId((int) account.getUid());
project.setProgramLanguage("java");
project.setManagerEmail(account.getAccount());
project.setManagerPhone(account.getMobileNo());
project.setProjectNo("test_project");
project.setManagerName(account.getRealname());
ProjectAccountRelation relation = new ProjectAccountRelation();
relation.setAccountId(account.getUid());
relation.setIsAdmin(Constants.TRUE);
// relation.setProjectId(newProject.getProjectId());
relation.setRealName(account.getRealname());
List<ProjectAccountRelation> relations = new ArrayList<>();
relations.add(relation);
project.setProjectAccountRelations(relations);
Project newProject = projectService.saveProject(account.getUid(), project);
Assert.notNull(projectService.getProject(newProject.getProjectId()));
List<ProjectAccountRelation> tmpList = projectAccountRelationService.getByProjectId(newProject.getProjectId());
Assert.notEmpty(tmpList);
Assert.isTrue(tmpList.size() == 1);
return newProject;
}
use of com.ibeiliao.deployment.admin.vo.project.ProjectAccountRelation in project Corgi by kevinYin.
the class ProjectServiceImpl method saveProjectRelations.
private void saveProjectRelations(Project project) {
List<ProjectAccountRelation> projectAccountRelations = project.getProjectAccountRelations();
for (ProjectAccountRelation relation : projectAccountRelations) {
relation.setProjectId(project.getProjectId());
}
relationService.deleteRelationByProjectId(project.getProjectId());
relationService.batchAddRelations(filterRedundantRelation(projectAccountRelations));
}
use of com.ibeiliao.deployment.admin.vo.project.ProjectAccountRelation in project Corgi by kevinYin.
the class ProjectServiceImpl method checkProjectAccountRelations.
private void checkProjectAccountRelations(List<ProjectAccountRelation> list) {
Assert.isTrue(!CollectionUtils.isEmpty(list), "项目至少要有一个成员");
int adminNum = 0;
for (ProjectAccountRelation relation : list) {
if (relation.getIsAdmin() == Constants.TRUE) {
adminNum++;
}
}
if (adminNum == 0) {
throw new IllegalArgumentException("项目至少要有一个管理员");
}
if (adminNum > 3) {
throw new IllegalArgumentException("项目最多只能有三个管理员");
}
}
use of com.ibeiliao.deployment.admin.vo.project.ProjectAccountRelation 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