| | |
| | | import kr.wisestone.owl.util.CommonUtil; |
| | | import kr.wisestone.owl.util.ConvertUtil; |
| | | import kr.wisestone.owl.util.DateUtil; |
| | | import kr.wisestone.owl.util.MapUtil; |
| | | import kr.wisestone.owl.vo.*; |
| | | import kr.wisestone.owl.web.condition.ProjectCondition; |
| | | import kr.wisestone.owl.web.form.ProjectForm; |
| | |
| | | Map<String, Object> changeProjectManagerNotifications = this.modifyProjectManagers(project, projectForm, ProjectRole.TYPE_MANAGER); |
| | | // 일반 사용자 변경 |
| | | Map<String, Object> changeProjectUserNotifications = this.modifyProjectManagers(project, projectForm, ProjectRole.TYPE_DEFAULT); |
| | | Map<String, Object> changeProjectDepartmentNotifications = this.modifyProjectDepartments(project, projectForm); |
| | | ConvertUtil.copyProperties(projectForm, project, "id", "projectType"); |
| | | |
| | | this.projectRepository.saveAndFlush(project); |
| | |
| | | |
| | | } |
| | | |
| | | // 관리자를 변경한다. |
| | | private Map<String, Object> modifyProjectDepartments(Project project, ProjectForm projectForm) { |
| | | ProjectRole projectRole = this.projectRoleService.findByProjectIdAndRoleType(project.getId(), ProjectRole.TYPE_DEFAULT); |
| | | List<Department> oldDepartment = Lists.newArrayList(); |
| | | List<Department> newDepartment = Lists.newArrayList(); |
| | | Map<String, Object> results = new HashMap<>(); |
| | | |
| | | for (ProjectRoleDepartment projectRoleDepartment : projectRole.getProjectRoleDepartments()) { |
| | | Department department = projectRoleDepartment.getDepartment(); |
| | | oldDepartment.add(department); |
| | | department.removeProjectRole(projectRole); |
| | | } |
| | | projectRole.getProjectRoleDepartments().clear(); |
| | | |
| | | for (Long departmentId : projectForm.getDepartmentIds()) { |
| | | Department department = this.departmentService.getDepartment(departmentId); |
| | | department.addProjectRole(projectRole); |
| | | } |
| | | |
| | | // 제외 대상자 찾기, oldManager 에는 있는데 newManager 에 없으면 제외 대상 |
| | | List<String> excludeDepartments = this.systemEmailService.notificationDepartmentChange(oldDepartment, newDepartment); |
| | | // 참여 대상자 찾기, newManager 에는 있는데 oldManager 에 없으면 초대받은 대상 |
| | | List<String> includeDepartments = this.systemEmailService.notificationDepartmentChange(newDepartment, oldDepartment); |
| | | |
| | | results.put("excludeDepartments", excludeDepartments); |
| | | results.put("includeDepartments", includeDepartments); |
| | | |
| | | return results; |
| | | |
| | | } |
| | | |
| | | // 프로젝트 참여, 제외 통지 정보를 중복으로 나가지 않도록 체크한다. |
| | | private void notificationProjectRoleUser(Map<String, Object> changeProjectManagerNotifications, Map<String, Object> changeProjectUserNotifications, Project project) { |
| | | List<String> projectManagerExcludeUsers = (List<String>) changeProjectManagerNotifications.get("excludeUsers"); // 관리자 제외 사용자 |