| | |
| | | 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.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 DepartmentService departmentService; |
| | | |
| | | @Autowired |
| | | private UserDepartmentService userDepartmentService; |
| | | private UserDepartmentRepository userDepartmentRepository; |
| | | |
| | | @Autowired |
| | | private ProjectRoleService projectRoleService; |
| | |
| | | } |
| | | } |
| | | |
| | | 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()) { |
| | | if (this.userWorkspaceService.checkWorkspaceManager(user) || user.getPermission() >= MngPermission.USER_PERMISSION_MNG_PROJECT_ALL) { |
| | | 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.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(); |
| | | |
| | | for (Map<String, Object> result : results) { |
| | |
| | | this.setProjectDepartment(projectVo); |
| | | |
| | | // 업무공간 담당자는 모든 프로젝트를 수정/삭제할 수 있어야 한다. |
| | | if (this.userWorkspaceService.checkWorkspaceManager()) { |
| | | if (this.userWorkspaceService.checkWorkspaceManager(user)) { |
| | | projectVo.setModifyPermissionCheck(true); |
| | | } |
| | | projectVos.add(projectVo); |
| | |
| | | // 프로젝트 참여 부서 |
| | | List<Long> existDepartmentIds = this.getIncludeProjectDepartment(project); |
| | | |
| | | User user = this.webAppUtil.getLoginUserObject(); |
| | | |
| | | // 워크스페이스에서 기본으로 제공되는 프로젝트에 대한 체크 |
| | | this.checkDefaultProject(project, projectForm); |
| | | // 수정 권한 체크 |
| | | this.checkModifyPermission(project.getId()); |
| | | this.checkModifyPermission(project.getId(), user); |
| | | // 관리자 변경 |
| | | Map<String, Object> changeProjectManagerNotifications = this.modifyProjectManagers(project, projectForm, ProjectRole.TYPE_MANAGER); |
| | | // 일반 사용자 변경 |
| | |
| | | } |
| | | |
| | | // 로그인한 사용자가 관리자 역할에 소속되어 있는지 확인한다. |
| | | 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; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | // 로그인한 사용자가 관리자 역할에 소속되어 있는지 확인한다. |
| | | this.checkModifyPermission(project.getId()); |
| | | this.checkModifyPermission(project.getId(), this.webAppUtil.getLoginUserObject()); |
| | | |
| | | List<String> sendEmails = Lists.newArrayList(); |
| | | Map<String, Object> params = new HashMap<>(); |
| | |
| | | @Override |
| | | @Transactional(readOnly = true) |
| | | public List<ProjectVo> findByIncludeProject(List<String> statuses, String projectType) { |
| | | User user = this.webAppUtil.getLoginUserObject(); |
| | | |
| | | 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)) { |
| | | results = this.projectMapper.findByWorkspaceManager(projectCondition); |
| | | } else { |
| | | results = this.projectMapper.findByWorkspaceIdAndIncludeProject(projectCondition); |
| | | } |
| | | List<ProjectVo> projectVos = this.makeProjectByVos(results); |
| | | this.setChildrenProject(projectVos); |
| | | this.setChildrenProject(projectVos, user); |
| | | |
| | | return projectVos; |
| | | } |
| | |
| | | projectCondition.setWorkspaceId(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId()); |
| | | List<Map<String, Object>> 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)); // 상태 |