| | |
| | | import com.google.common.collect.Lists; |
| | | import kr.wisestone.owl.common.ExcelConditionCheck; |
| | | import kr.wisestone.owl.constant.Constants; |
| | | import kr.wisestone.owl.constant.MngPermission; |
| | | import kr.wisestone.owl.constant.MsgConstants; |
| | | import kr.wisestone.owl.domain.*; |
| | | import kr.wisestone.owl.domain.enumType.EmailType; |
| | |
| | | import kr.wisestone.owl.mapper.ProjectMapper; |
| | | import kr.wisestone.owl.repository.ProjectClosureRepository; |
| | | import kr.wisestone.owl.repository.ProjectRepository; |
| | | import kr.wisestone.owl.repository.UserDepartmentRepository; |
| | | import kr.wisestone.owl.service.*; |
| | | 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.condition.WidgetCondition; |
| | | import kr.wisestone.owl.web.form.ProjectForm; |
| | | import kr.wisestone.owl.web.view.ExcelView; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | private UserService userService; |
| | | |
| | | @Autowired |
| | | private DepartmentService departmentService; |
| | | |
| | | @Autowired |
| | | private UserDepartmentRepository userDepartmentRepository; |
| | | |
| | | @Autowired |
| | | private ProjectRoleService projectRoleService; |
| | | |
| | | @Autowired |
| | |
| | | private UserWorkspaceService userWorkspaceService; |
| | | |
| | | @Autowired |
| | | private IssueTypeService issueTypeService; |
| | | |
| | | @Autowired |
| | | private UserLevelService userLevelService; |
| | | |
| | | @Autowired |
| | | private SystemEmailService systemEmailService; |
| | | |
| | | @Autowired |
| | | private ProjectRoleUserService projectRoleUserService; |
| | | |
| | | @Autowired |
| | | private ProjectRoleDepartmentService projectRoleDepartmentService; |
| | | |
| | | @Autowired |
| | | private AttachedFileService attachedFileService; |
| | |
| | | |
| | | @Autowired |
| | | private IssueUserService issueUserService; |
| | | |
| | | @Autowired |
| | | private IssueDepartmentService issueDepartmentService; |
| | | |
| | | @Autowired |
| | | private IssueNumberGeneratorService issueNumberGeneratorService; |
| | |
| | | project.setDefaultYn(true); |
| | | this.projectRepository.saveAndFlush(project); |
| | | // 프로젝트 기본 역할과 관리자 역할을 생성한다. 관리자는 생성한 사용자 |
| | | this.projectRoleService.addDefaultProjectRole(project, Lists.newArrayList(user), Lists.newArrayList()); |
| | | this.projectRoleService.addDefaultProjectRoleUser(project, Lists.newArrayList(user), Lists.newArrayList()); |
| | | // 각 프로젝트의 이슈 번호를 자동으로 생성한다. |
| | | this.issueNumberGeneratorService.generateIssueNumber(project); |
| | | |
| | |
| | | // 상태 체크 |
| | | this.verifyProjectStatus(projectForm.getStatus()); |
| | | // 날짜 유효성 체크 |
| | | this.checkStartEndDate(projectForm.getStartDate(), projectForm.getEndDate()); |
| | | //this.checkStartEndDate(projectForm.getStartDate(), projectForm.getEndDate()); |
| | | // 관리자 유효성 체크 |
| | | this.verifyManager(projectForm.getManagerIds()); |
| | | |
| | |
| | | // 각 프로젝트의 이슈 번호를 자동으로 생성한다. |
| | | this.issueNumberGeneratorService.generateIssueNumber(project); |
| | | // 일반 사용자 및 관리자를 등록하고 사용자들에게 해당 역할을 배정한다. |
| | | this.registerManagerAndUser(projectForm, project); |
| | | //this.registerManagerAndUser(projectForm, project); |
| | | this.registerManagerAndDepartment(projectForm, project); |
| | | |
| | | // 프로젝트 유형에 따른 워크플로우 생성 |
| | | this.workflowStatusService.addDefaultWorkflowStatus(project, ProjectType.valueOf(projectForm.getProjectType())); |
| | |
| | | } |
| | | |
| | | // 기본, 관리자 프로젝트 역할을 생성하고 사용자를 해당 역할에 배정한다. |
| | | this.projectRoleService.addDefaultProjectRole(project, managers, users); |
| | | this.projectRoleService.addDefaultProjectRoleUser(project, managers, users); |
| | | |
| | | // 프로젝트 참여자들에게 이메일 발송을 예약한다. |
| | | Map<String, Object> projectMap = new HashMap<>(); |
| | |
| | | |
| | | projectMap.put("projectManagerName", stringBuilder.toString()); |
| | | // 프로젝트 일반 참여 메일 발송 예약 |
| | | this.systemEmailService.reservationEmail(sendEmails.toArray(new String[sendEmails.size()]), EmailType.PROJECT_DEFAULT_INCLUDE, projectMap); |
| | | } |
| | | |
| | | private void registerManagerAndDepartment(ProjectForm projectForm, Project project) { |
| | | List<User> managers = Lists.newArrayList(); |
| | | // 관리자 등록 |
| | | for (Long managerId : projectForm.getManagerIds()) { |
| | | User user = this.userService.getUser(managerId); |
| | | managers.add(user); |
| | | } |
| | | |
| | | List<Department> departments = Lists.newArrayList(); |
| | | List<String> sendEmails = Lists.newArrayList(); // 메일 대상자 |
| | | // 부서 등록 |
| | | for (Long departmentId : projectForm.getDepartmentIds()) { |
| | | Department department = this.departmentService.getDepartment(departmentId); |
| | | /*List<UserDepartment> userDepartments = this.userDepartmentService.getUserDepartments(departmentId); |
| | | if(userDepartments != null){ |
| | | for (UserDepartment userDepartment : userDepartments){ |
| | | User user = this.userService.getUser(userDepartment.getUserId()); |
| | | sendEmails.add(user.getAccount()); |
| | | } |
| | | }*/ |
| | | departments.add(department); |
| | | } |
| | | |
| | | // 기본, 관리자 프로젝트 역할을 생성하고 담당부서를 해당 역할에 배정한다. |
| | | this.projectRoleService.addDefaultProjectRoleDepartment(project, managers, departments); |
| | | |
| | | // 프로젝트 참여자들에게 이메일 발송을 예약한다. |
| | | Map<String, Object> projectMap = new HashMap<>(); |
| | | projectMap.put("workspaceName", project.getWorkspace().getName()); |
| | | projectMap.put("projectName", project.getName()); |
| | | projectMap.put("registerDate", DateUtil.convertDateToStr(new Date())); |
| | | |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | stringBuilder.append(managers.get(0).getName()); |
| | | stringBuilder.append("("); |
| | | stringBuilder.append(CommonUtil.decryptAES128(managers.get(0).getAccount())); |
| | | stringBuilder.append(")"); |
| | | |
| | | projectMap.put("projectManagerName", stringBuilder.toString()); |
| | | // 프로젝트 담당부서 메일 발송 예약 |
| | | this.systemEmailService.reservationEmail(sendEmails.toArray(new String[sendEmails.size()]), EmailType.PROJECT_DEFAULT_INCLUDE, projectMap); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | void SetMyDepartmentId(ProjectCondition projectCondition){ |
| | | Long loginId = projectCondition.getLoginUserId(); |
| | | List<Long> myDepartmentIds = Lists.newArrayList(); |
| | | List<UserDepartment> myDepartments = this.userDepartmentRepository.findByUserId(loginId); |
| | | |
| | | if(myDepartments != null && myDepartments.size() > 0){ |
| | | for(UserDepartment myDepartment : myDepartments){ |
| | | myDepartmentIds.add(myDepartment.getDepartmentId()); |
| | | } |
| | | } |
| | | projectCondition.setMyDepartmentIds(myDepartmentIds); |
| | | } |
| | | |
| | | // 프로젝트 목록을 조회한다. |
| | | @Override |
| | | @Transactional(readOnly = true) |
| | |
| | | List<Map<String, Object>> results; |
| | | Long totalCount; |
| | | |
| | | User user = this.webAppUtil.getLoginUserObject(); |
| | | |
| | | if (condition.getWorkspaceManager()) { |
| | | // 업무공간 관리자일 경우 모든 프로젝트가 표시되어야 한다. |
| | | // 관리자일 때 |
| | | if (this.userWorkspaceService.checkWorkspaceManager()) { |
| | | UserLevel userLevel = this.userLevelService.getUserLevel(user.getUserLevel().getId()); |
| | | if (this.userWorkspaceService.checkWorkspaceManager(user) |
| | | || MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_PROJECT)) { |
| | | results = this.projectMapper.findByWorkspaceManager(condition); |
| | | totalCount = this.projectMapper.countByWorkspaceManager(condition); |
| | | } |
| | | else { |
| | | this.SetMyDepartmentId(condition); |
| | | results = this.projectMapper.find(condition); |
| | | totalCount = this.projectMapper.count(condition); |
| | | } |
| | |
| | | |
| | | int totalPage = (int) Math.ceil((totalCount - 1) / pageable.getPageSize()) + 1; |
| | | // 프로젝트 조회 결과를 ProjectVos 로 변환한다. - 관리자, 일반 사용자 정보 추가 |
| | | List<ProjectVo> projectVos = this.makeProjectVos(results); |
| | | this.setChildrenProject(projectVos); |
| | | List<ProjectVo> projectVos = this.makeProjectVos(results, user); |
| | | this.setParentProject(projectVos); |
| | | this.setChildrenProject(projectVos, user); |
| | | |
| | | resJsonData.put(Constants.RES_KEY_CONTENTS, projectVos); |
| | | resJsonData.put(Constants.REQ_KEY_PAGE_VO, new ResPage(pageable.getPageNumber(), pageable.getPageSize(), |
| | |
| | | return projectVos; |
| | | } |
| | | |
| | | void setChildrenProject(List<ProjectVo> projectVos) { |
| | | void setChildrenProject(List<ProjectVo> projectVos, User user) { |
| | | int projectCount = projectVos.size(); |
| | | for (int i=0; i< projectCount; i++) { |
| | | ProjectVo projectVo = projectVos.get(i); |
| | | List<Map<String, Object>> children = this.projectMapper.findChildrenProject(projectVo.getId()); |
| | | |
| | | if (children != null && children.size() > 0) { |
| | | List<ProjectVo> childrenVo = this.makeProjectVos(children); |
| | | List<ProjectVo> childrenVo = this.makeProjectVos(children, user); |
| | | projectVo.setChildProjects(childrenVo); |
| | | setChildrenProject(childrenVo); |
| | | setChildrenProject(childrenVo, user); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | // 프로젝트 조회 결과를 ProjectVos 로 변환한다. - 관리자, 일반 사용자 정보 추가 |
| | | private List<ProjectVo> makeProjectVos(List<Map<String, Object>> results) { |
| | | private List<ProjectVo> makeProjectVos(List<Map<String, Object>> results, User user) { |
| | | List<ProjectVo> projectVos = Lists.newArrayList(); |
| | | UserLevel userLevel = this.userLevelService.getUserLevel(user.getUserLevel().getId()); |
| | | |
| | | for (Map<String, Object> result : results) { |
| | | ProjectVo projectVo = ConvertUtil.convertMapToClass(result, ProjectVo.class); |
| | | // 프로젝트에 참여하는 사용자를 셋팅한다. - 관리자 / 일반 사용자 |
| | | this.setProjectUser(projectVo, true); |
| | | this.setProjectUser(projectVo, false); |
| | | |
| | | // 프로젝트에 참여하는 부서 세팅 |
| | | this.setProjectDepartment(projectVo); |
| | | |
| | | // 업무공간 담당자는 모든 프로젝트를 수정/삭제할 수 있어야 한다. |
| | | if (this.userWorkspaceService.checkWorkspaceManager()) { |
| | | if (this.userWorkspaceService.checkWorkspaceManager(user) |
| | | || MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_PROJECT)) { |
| | | projectVo.setModifyPermissionCheck(true); |
| | | } |
| | | projectVos.add(projectVo); |
| | | } |
| | | |
| | | return projectVos; |
| | | } |
| | | |
| | | // 상위 프로젝트를 찾아준다. |
| | | private void setParentProject(List<ProjectVo> projectVos) { |
| | | for (ProjectVo projectVo : projectVos) { |
| | | ProjectClosure projectClosure = this.projectClosureRepository.findByProjectId(projectVo.getId()); |
| | | if (projectClosure != null) { |
| | | Project parentProject = this.getProject(projectClosure.getParentProject().getId()); |
| | | ProjectVo parentProjectVo = ConvertUtil.copyProperties(parentProject, ProjectVo.class); |
| | | parentProjectVo.setParentYn(true); |
| | | ConvertUtil.copyProperties(parentProjectVo, projectVo); |
| | | this.setProjectDepartment(projectVo); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 관리자, 일반 사용자를 조건에 따라 찾아준다. |
| | |
| | | } |
| | | } |
| | | |
| | | // 담당부서를 조건에 따라 찾아준다. |
| | | private void setProjectDepartment(ProjectVo projectVo) { |
| | | Map<String, Object> projectRoleDepartmentMap = new HashMap<>(); |
| | | projectRoleDepartmentMap.put("id", projectVo.getId()); |
| | | |
| | | // 부서 정보 셋팅 |
| | | List<Map<String, Object>> projectRoleDepartments = this.projectRoleDepartmentService.findProjectRoleDepartment(projectRoleDepartmentMap); |
| | | |
| | | if (projectRoleDepartments != null && !projectRoleDepartments.isEmpty()) { |
| | | List<DepartmentVo> departmentVos = Lists.newArrayList(); |
| | | |
| | | for (Map<String, Object> projectRoleDepartment : projectRoleDepartments) { |
| | | DepartmentVo departmentVo = ConvertUtil.convertMapToClass(projectRoleDepartment, DepartmentVo.class); |
| | | departmentVo.setByName(departmentVo.getDepartmentName()); |
| | | departmentVos.add(departmentVo); |
| | | } |
| | | projectVo.setProjectDepartmentVos(departmentVos); |
| | | } |
| | | } |
| | | |
| | | |
| | | // 프로젝트 상세 정보를 조회한다. |
| | | @Override |
| | |
| | | case "01": // 프로젝트에 참여하는 사용자, 관리자 정보를 셋팅한다. |
| | | this.setProjectUser(projectVo, true); |
| | | this.setProjectUser(projectVo, false); |
| | | this.setProjectDepartment(projectVo); //부서 정보 세팅 |
| | | break; |
| | | } |
| | | } |
| | |
| | | // 상태 체크 |
| | | this.verifyProjectStatus(projectForm.getStatus()); |
| | | // 날짜 유효성 체크 |
| | | this.checkStartEndDate(projectForm.getStartDate(), projectForm.getEndDate()); |
| | | //this.checkStartEndDate(projectForm.getStartDate(), projectForm.getEndDate()); |
| | | // 관리자 유효성 체크 |
| | | this.verifyManager(projectForm.getManagerIds()); |
| | | |
| | | Project project = this.getProject(projectForm.getId()); |
| | | // 프로젝트 참여 사용자 |
| | | List<Long> existUserIds = this.getIncludeProjectUser(project); |
| | | // 프로젝트 참여 부서 |
| | | List<Long> existDepartmentIds = this.getIncludeProjectDepartment(project); |
| | | |
| | | User user = this.webAppUtil.getLoginUserObject(); |
| | | |
| | | // 워크스페이스에서 기본으로 제공되는 프로젝트에 대한 체크 |
| | | this.checkDefaultProject(project, projectForm); |
| | | //this.checkDefaultProject(project, projectForm); |
| | | // 수정 권한 체크 |
| | | this.checkModifyPermission(project.getId()); |
| | | this.checkModifyPermission(project.getId(), user); |
| | | // 관리자 변경 |
| | | 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); |
| | |
| | | // 해당 프로젝트에 참여하는 모든 사용자 조회 |
| | | // 빠진 사람이 관리하는 이슈 전체 조회 후 데이터 삭제 |
| | | List<Long> changeUserIds = this.getIncludeProjectUser(project); |
| | | List<Long> changeDepartmentIds = this.getIncludeProjectDepartment(project); |
| | | |
| | | // 참여에서 제외된 사용자를 찾고 담당하고 있던 이슈에서 제외한다. |
| | | this.checkExcludeUserAndRemoveIssueAssignee(project, existUserIds, changeUserIds); |
| | | this.checkExcludeDepartmentAndRemoveIssueDepartment(project, existDepartmentIds, changeDepartmentIds); |
| | | |
| | | // 관리자/일반 사용자 변경 내역을 통지한다. |
| | | this.notificationProjectRoleUser(changeProjectManagerNotifications, changeProjectUserNotifications, project); |
| | | //this.notificationProjectRoleUser(changeProjectManagerNotifications, changeProjectUserNotifications, project); |
| | | // 관리자/담당부서 변경 내역을 통지한다. |
| | | this.notificationProjectRoleDepartment(changeProjectManagerNotifications, changeProjectDepartmentNotifications, project); |
| | | |
| | | return project; |
| | | } |
| | |
| | | return Lists.newArrayList(includeUserIds); |
| | | } |
| | | |
| | | // 프로젝트 참여 부서 |
| | | private List<Long> getIncludeProjectDepartment(Project project) { |
| | | Set<Long> includeDepartmentIds = new HashSet<>(); |
| | | |
| | | for (ProjectRole projectRole : project.getProjectRoles()) { |
| | | List<ProjectRoleDepartment> projectRoleDepartments = this.projectRoleDepartmentService.findByProjectRoleId(projectRole.getId()); |
| | | |
| | | for (ProjectRoleDepartment projectRoleDepartment : projectRoleDepartments) { |
| | | includeDepartmentIds.add(projectRoleDepartment.getDepartment().getId()); |
| | | } |
| | | } |
| | | return Lists.newArrayList(includeDepartmentIds); |
| | | } |
| | | |
| | | // 참여에서 제외된 사용자를 찾고 담당하고 있던 이슈에서 제외한다. |
| | | private void checkExcludeUserAndRemoveIssueAssignee(Project project, List<Long> existUserIds, List<Long> changeUserIds) { |
| | | List<Long> excludeUserIds = CommonUtil.searchChangeList(changeUserIds, existUserIds); |
| | |
| | | } |
| | | } |
| | | |
| | | // 참여에서 제외된 부서를 찾고 담당하고 있던 이슈에서 제외한다. |
| | | private void checkExcludeDepartmentAndRemoveIssueDepartment(Project project, List<Long> existDepartmentIds, List<Long> changeDepartmentIds) { |
| | | List<Long> excludeDepartmentIds = CommonUtil.searchChangeList(changeDepartmentIds, existDepartmentIds); |
| | | |
| | | if (excludeDepartmentIds.size() > 0) { |
| | | this.issueDepartmentService.removeIssueDepartment(project.getId(), excludeDepartmentIds); |
| | | } |
| | | } |
| | | |
| | | // 기본 제공되는 프로젝트의 관리자는 워크스페이스 관리자가 포함되어 있어야 한다. |
| | | private void checkDefaultProject(Project project, ProjectForm projectForm) { |
| | |
| | | } |
| | | } |
| | | |
| | | private void checkUsingIssueType(Long projectId) { |
| | | Boolean del = Boolean.FALSE; |
| | | |
| | | List<IssueType> usingIssueTypes = this.issueTypeService.findByProjectId(projectId); |
| | | if (usingIssueTypes == null || usingIssueTypes.isEmpty()) { |
| | | del = true; |
| | | } |
| | | |
| | | if (!del) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.PROJECT_NOT_DELETE)); |
| | | } |
| | | } |
| | | |
| | | // 로그인한 사용자가 관리자 역할에 소속되어 있는지 확인한다. |
| | | private void checkModifyPermission(Long projectId) { |
| | | private void checkModifyPermission(Long projectId, User user) { |
| | | Boolean hasPermission = Boolean.FALSE; |
| | | |
| | | // 해당 업무 공간의 관리자일 경우 권한 체크를 하지 않는다. |
| | | if (this.userWorkspaceService.checkWorkspaceManager()) { |
| | | if (this.userWorkspaceService.checkWorkspaceManager(user)) { |
| | | return; |
| | | } |
| | | |
| | |
| | | projectRoleUserMap.put("statuses", Lists.newArrayList("02")); // 관리자 조회 |
| | | |
| | | List<Map<String, Object>> projectUsers = this.projectRoleUserService.findProjectRoleUser(projectRoleUserMap); |
| | | UserLevel userLevel = this.userLevelService.getUserLevel(user.getUserLevel().getId()); |
| | | // 현재 로그인 사용자가 관리자인지 확인 |
| | | if (projectUsers != null && !projectUsers.isEmpty()) { |
| | | for (Map<String, Object> projectUser : projectUsers) { |
| | | UserVo userVo = ConvertUtil.convertMapToClass(projectUser, UserVo.class); |
| | | if (userVo.getId().equals(this.webAppUtil.getLoginId())) { |
| | | if (userVo.getId().equals(this.webAppUtil.getLoginId()) |
| | | || MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_PROJECT)) { |
| | | hasPermission = true; |
| | | break; |
| | | } |
| | |
| | | |
| | | results.put("excludeUsers", excludeUsers); |
| | | results.put("includeUsers", includeUsers); |
| | | |
| | | return results; |
| | | |
| | | } |
| | | |
| | | // 담당부서를 변경한다. |
| | | 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); |
| | | } |
| | | |
| | | // 제외 대상자 찾기, oldDepartment 에는 있는데 newDepartment 에 없으면 제외 대상 |
| | | List<String> excludeDepartments = this.systemEmailService.notificationDepartmentChange(oldDepartment, newDepartment); |
| | | // 참여 대상자 찾기, newDepartment 에는 있는데 oldDepartment 에 없으면 초대받은 대상 |
| | | List<String> includeDepartments = this.systemEmailService.notificationDepartmentChange(newDepartment, oldDepartment); |
| | | |
| | | results.put("excludeDepartments", excludeDepartments); |
| | | results.put("includeDepartments", includeDepartments); |
| | | |
| | | return results; |
| | | |
| | |
| | | this.sendEmailProjectRoleChange(this.checkDuplicationEmails(projectUserExcludeUsers, excludeManagerAndIncludeUser, excludeUserAndIncludeManager), EmailType.PROJECT_DEFAULT_EXCLUDE, projectMap); |
| | | // 일반 사용자 참여 메일 최종 |
| | | this.sendEmailProjectRoleChange(this.checkDuplicationEmails(projectUserIncludeUsers, excludeManagerAndIncludeUser, excludeUserAndIncludeManager), EmailType.PROJECT_DEFAULT_INCLUDE, projectMap); |
| | | } |
| | | |
| | | // 프로젝트 참여, 제외 통지 정보 체크 |
| | | private void notificationProjectRoleDepartment(Map<String, Object> changeProjectManagerNotifications, Map<String, Object> changeProjectDepartmentNotifications, Project project) { |
| | | List<String> projectManagerExcludeUsers = (List<String>) changeProjectManagerNotifications.get("excludeUsers"); // 관리자 제외 사용자 |
| | | List<String> projectManagerIncludeUsers = (List<String>) changeProjectManagerNotifications.get("includeUsers"); // 관리자 참여 사용자 |
| | | List<String> projectDepartmentExcludeDepartments = (List<String>) changeProjectDepartmentNotifications.get("excludeDepartments"); // 제외된 담당 부서 |
| | | List<String> projectDepartmentIncludeDepartments = (List<String>) changeProjectDepartmentNotifications.get("includeDepartments"); // 참여된 담당 부서 |
| | | Map<String, Object> projectMap = new HashMap<>(); |
| | | projectMap.put("workspaceName", project.getWorkspace().getName()); |
| | | projectMap.put("projectName", project.getName()); |
| | | projectMap.put("registerDate", DateUtil.convertDateToStr(new Date())); |
| | | |
| | | Map<String, Object> projectRoleManagerMap = new HashMap<>(); |
| | | projectRoleManagerMap.put("id", project.getId()); |
| | | projectRoleManagerMap.put("statuses", Lists.newArrayList("02")); // 관리자 조회 |
| | | |
| | | // 관리자 정보 셋팅 |
| | | List<Map<String, Object>> projectRoleManagers = this.projectRoleUserService.findProjectRoleUser(projectRoleManagerMap); |
| | | |
| | | if (projectRoleManagers != null && !projectRoleManagers.isEmpty()) { |
| | | for (Map<String, Object> projectRoleManager : projectRoleManagers) { |
| | | UserVo userVo = ConvertUtil.convertMapToClass(projectRoleManager, UserVo.class); |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | stringBuilder.append(userVo.getName()); |
| | | stringBuilder.append("("); |
| | | stringBuilder.append(CommonUtil.decryptAES128(userVo.getAccount())); |
| | | stringBuilder.append(")"); |
| | | |
| | | projectMap.put("projectManagerName", stringBuilder.toString()); |
| | | } |
| | | } |
| | | |
| | | // 관리자 제외 메일 |
| | | this.sendEmailProjectRoleChange(projectManagerExcludeUsers, EmailType.PROJECT_MANAGER_EXCLUDE, projectMap); |
| | | // 관리차 참여 메일 |
| | | this.sendEmailProjectRoleChange(projectManagerIncludeUsers, EmailType.PROJECT_MANAGER_INCLUDE, projectMap); |
| | | // 담당 부서 제외 메일 |
| | | this.sendEmailProjectRoleChange(projectDepartmentExcludeDepartments, EmailType.PROJECT_DEFAULT_EXCLUDE, projectMap); |
| | | // 담당 부서 참여 메일 |
| | | this.sendEmailProjectRoleChange(projectDepartmentIncludeDepartments, EmailType.PROJECT_DEFAULT_INCLUDE, projectMap); |
| | | } |
| | | |
| | | // 중복으로 나가는 메일이 있는지 체크한다. |
| | |
| | | private void removeProjects(Long projectId) { |
| | | Project project = this.getProject(projectId); |
| | | // 기본 프로젝트는 삭제 금지 |
| | | if (project.getDefaultYn()) { |
| | | /*if (project.getDefaultYn()) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.DEFAULT_PROJECT_NOT_REMOVE)); |
| | | } |
| | | }*/ |
| | | this.checkUsingIssueType(project.getId()); |
| | | |
| | | // 로그인한 사용자가 관리자 역할에 소속되어 있는지 확인한다. |
| | | this.checkModifyPermission(project.getId()); |
| | | this.checkModifyPermission(project.getId(), this.webAppUtil.getLoginUserObject()); |
| | | |
| | | List<String> sendEmails = Lists.newArrayList(); |
| | | Map<String, Object> params = new HashMap<>(); |
| | |
| | | projectCondition.setWorkspaceId(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId()); |
| | | projectCondition.setProjectType(projectType); |
| | | projectCondition.setStatuses(statuses); |
| | | |
| | | this.SetMyDepartmentId(projectCondition); |
| | | return this.projectMapper.findByWorkspaceIdAndIncludeProject(projectCondition); |
| | | } |
| | | |
| | |
| | | public List<Map<String, Object>> findByWorkspaceIdAndIncludeProject(ProjectCondition projectCondition) { |
| | | projectCondition.setLoginUserId(this.webAppUtil.getLoginId()); |
| | | projectCondition.setWorkspaceId(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId()); |
| | | this.SetMyDepartmentId(projectCondition); |
| | | return this.projectMapper.findByWorkspaceIdAndIncludeProject(projectCondition); |
| | | } |
| | | |
| | |
| | | public List<Map<String, Object>> findByWorkspaceIdAndIncludeProjectAll(ProjectCondition projectCondition) { |
| | | projectCondition.setLoginUserId(this.webAppUtil.getLoginId()); |
| | | projectCondition.setWorkspaceId(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId()); |
| | | return this.projectMapper.findByWorkspaceIdAndIncludeProjectAll(projectCondition); |
| | | |
| | | UserWorkspace userWorkspace = this.userWorkspaceService.findWorkspaceManager(this.webAppUtil.getLoginId()); |
| | | List<Map<String, Object>> results = Lists.newArrayList(); |
| | | if(userWorkspace != null) {// 워크스페이스 관리자일경우 |
| | | results = this.projectMapper.findByWorkspaceIdAndProjectAll(projectCondition); |
| | | } else { |
| | | results = this.projectMapper.findByWorkspaceIdAndIncludeProjectAll(projectCondition); |
| | | } |
| | | return results; |
| | | } |
| | | |
| | | // 현재 접근한 업무공간에서 참여하고 있는 프로젝트를 조회한다. - 상단 프로젝트 목록에서 사용 |
| | | @Override |
| | | @Transactional(readOnly = true) |
| | | public List<ProjectVo> findByIncludeProject(List<String> statuses, String projectType) { |
| | | User user = this.webAppUtil.getLoginUserObject(); |
| | | UserLevel userLevel = this.userLevelService.getUserLevel(user.getUserLevel().getId()); |
| | | |
| | | ProjectCondition projectCondition = new ProjectCondition(); |
| | | projectCondition.setLoginUserId(this.webAppUtil.getLoginId()); |
| | | projectCondition.setWorkspaceId(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId()); |
| | | projectCondition.setLoginUserId(user.getId()); |
| | | projectCondition.setWorkspaceId(user.getLastWorkspaceId()); |
| | | projectCondition.setProjectType(projectType); |
| | | projectCondition.setStatuses(statuses); |
| | | |
| | | List<Map<String, Object>> results; |
| | | |
| | | if (this.userWorkspaceService.checkWorkspaceManager()) { |
| | | if (this.userWorkspaceService.checkWorkspaceManager(user) |
| | | || MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_PROJECT)) { |
| | | results = this.projectMapper.findByWorkspaceManager(projectCondition); |
| | | } else { |
| | | this.SetMyDepartmentId(projectCondition); |
| | | results = this.projectMapper.findByWorkspaceIdAndIncludeProject(projectCondition); |
| | | } |
| | | List<ProjectVo> projectVos = this.makeProjectByVos(results); |
| | | this.setChildrenProject(projectVos); |
| | | this.setChildrenProject(projectVos, user); |
| | | |
| | | return projectVos; |
| | | } |
| | |
| | | ProjectCondition projectCondition = ProjectCondition.make(conditions); |
| | | projectCondition.setLoginUserId(this.webAppUtil.getLoginId()); |
| | | projectCondition.setWorkspaceId(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId()); |
| | | List<Map<String, Object>> results = this.projectMapper.find(projectCondition); |
| | | |
| | | User user = this.webAppUtil.getLoginUserObject(); |
| | | List<Map<String, Object>> results; |
| | | UserLevel userLevel = this.userLevelService.getUserLevel(user.getUserLevel().getId()); |
| | | |
| | | if (this.userWorkspaceService.checkWorkspaceManager(user) |
| | | || MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_PROJECT)) { |
| | | results = this.projectMapper.findByWorkspaceManager(projectCondition); |
| | | } |
| | | else { |
| | | this.SetMyDepartmentId(projectCondition); |
| | | results = this.projectMapper.find(projectCondition); |
| | | } |
| | | // 프로젝트 조회 결과를 ProjectVos 로 변환한다. - 관리자, 일반 사용자 정보 추가 |
| | | List<ProjectVo> projectVos = this.makeProjectVos(results); |
| | | List<ProjectVo> projectVos = this.makeProjectVos(results, this.webAppUtil.getLoginUserObject()); |
| | | ExportExcelVo excelInfo = new ExportExcelVo(); |
| | | excelInfo.setFileName(this.messageAccessor.message("common.projectList")); // 프로젝트 목록 |
| | | excelInfo.addAttrInfos(new ExportExcelAttrVo("statusName", this.messageAccessor.message("common.status"), 6, ExportExcelAttrVo.ALIGN_CENTER)); // 상태 |
| | | excelInfo.addAttrInfos(new ExportExcelAttrVo("name", this.messageAccessor.message("common.project"), 40, ExportExcelAttrVo.ALIGN_LEFT)); // 프로젝트 |
| | | excelInfo.addAttrInfos(new ExportExcelAttrVo("manager", this.messageAccessor.message("common.admin"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // 관리자 |
| | | excelInfo.addAttrInfos(new ExportExcelAttrVo("members", this.messageAccessor.message("common.teamMember"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // 팀원 |
| | | //excelInfo.addAttrInfos(new ExportExcelAttrVo("members", this.messageAccessor.message("common.teamMember"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // 팀원 |
| | | excelInfo.addAttrInfos(new ExportExcelAttrVo("departments", this.messageAccessor.message("common.teamDepartment"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // 팀원 |
| | | excelInfo.addAttrInfos(new ExportExcelAttrVo("period", this.messageAccessor.message("common.period"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // 기간 |
| | | excelInfo.addAttrInfos(new ExportExcelAttrVo("projectKey", this.messageAccessor.message("common.projectKey"), 6, ExportExcelAttrVo.ALIGN_CENTER)); // 프로젝트 키 |
| | | // 엑셀에 넣을 데이터 - ProjectVos 데이터를 엑셀에서 표시할 수 있는 데이터로 변경한다. |
| | |
| | | } |
| | | |
| | | result.put("manager", stringBuilderManager.toString()); |
| | | result.put("members", CommonUtil.convertUserVosToString(projectVo.getProjectUserVos())); |
| | | //result.put("members", CommonUtil.convertUserVosToString(projectVo.getProjectUserVos())); |
| | | result.put("departments", CommonUtil.convertDepartmentVosToString(projectVo.getProjectDepartmentVos())); |
| | | result.put("projectKey", projectVo.getProjectKey()); |
| | | result.put("period", projectVo.getStartDate() + " - " + projectVo.getEndDate()); |
| | | results.add(result); |
| | |
| | | resJsonData.put(Constants.RES_KEY_CONTENTS, ConvertUtil.copyProperties(project, ProjectVo.class)); |
| | | } |
| | | |
| | | } |
| | | } |