| | |
| | | import kr.wisestone.owl.exception.OwlRuntimeException; |
| | | import kr.wisestone.owl.mapper.IssueTypeMapper; |
| | | import kr.wisestone.owl.repository.IssueTypeRepository; |
| | | import kr.wisestone.owl.repository.ProjectClosureRepository; |
| | | import kr.wisestone.owl.repository.ProjectRepository; |
| | | import kr.wisestone.owl.service.*; |
| | | import kr.wisestone.owl.util.ConvertUtil; |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | @Service |
| | | public class IssueTypeServiceImpl extends AbstractServiceImpl<IssueType, Long, JpaRepository<IssueType, Long>> implements IssueTypeService { |
| | |
| | | |
| | | @Autowired |
| | | private UserService userService; |
| | | |
| | | @Autowired |
| | | private ProjectClosureRepository projectClosureRepository; |
| | | |
| | | @Autowired |
| | | private ExcelView excelView; |
| | |
| | | public List<IssueTypeVo> findIssueType(Map<String, Object> resJsonData, |
| | | IssueTypeCondition condition, Pageable pageable) { |
| | | |
| | | List<Long> downProjectIds = Lists.newArrayList(); |
| | | List<Long> allProjectIds = Lists.newArrayList(); |
| | | List<ProjectClosure> projectClosures = Lists.newArrayList(); |
| | | |
| | | condition.setPage(pageable.getPageNumber() * pageable.getPageSize()); |
| | | condition.setPageSize(pageable.getPageSize()); |
| | | condition.setWorkspaceId(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId()); |
| | | |
| | | |
| | | if (condition.getProjectId() == null) { |
| | | List<ProjectVo> projectVos = this.projectService.findByIncludeProject(Lists.newArrayList("01", "02", "03"), ProjectType.BTS_PROJECT.toString()); |
| | | if (projectVos != null && projectVos.size() > 0) { |
| | | for (ProjectVo projectVo : projectVos) { |
| | | allProjectIds.add(projectVo.getId()); |
| | | projectClosures = this.projectClosureRepository.findByParentProjectId(projectVo.getId()); |
| | | if (projectClosures != null && projectClosures.size() > 0) { |
| | | for (ProjectClosure projectClosure : projectClosures) { |
| | | allProjectIds.add(projectClosure.getProject().getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }else { |
| | | projectClosures = this.projectClosureRepository.findByParentProjectId(condition.getProjectId()); |
| | | } |
| | | |
| | | if (projectClosures != null && projectClosures.size() > 0) { |
| | | for (ProjectClosure projectClosure : projectClosures) { |
| | | Long downProjectId = projectClosure.getProject().getId(); |
| | | downProjectIds.add(downProjectId); |
| | | allProjectIds.add(downProjectId); |
| | | } |
| | | } |
| | | condition.setDownProjectIds(downProjectIds); |
| | | if (condition.getProjectId() == null) { |
| | | condition.setAllProjectIds(allProjectIds); |
| | | } |
| | | List<Map<String, Object>> results = this.issueTypeMapper.find(condition); |
| | | for (Map<String, Object> result : results) { |
| | | Long projectId = MapUtil.getLong(result, "projectId"); |
| | |
| | | } |
| | | } |
| | | |
| | | // 이슈 유형에 프로젝트ID로 조회 |
| | | public List<IssueType> findByProjectId(Long projectId) { |
| | | return this.issueTypeRepository.findByProjectId(projectId); |
| | | } |
| | | |
| | | private void setUseIssueTypeByIssueStatus(List<IssueTypeVo> issueTypeVos) { |
| | | for (IssueTypeVo issueTypeVo : issueTypeVos) { |
| | | IssueType issueType = this.getIssueType(issueTypeVo.getId()); |
| | | |
| | | IssueStatus issueStatus = issueType.getIssueStatus(); |
| | | if (issueStatus != null) { |
| | | issueTypeVo.setCompleteIssueStatusVo(ConvertUtil.copyProperties(issueType.getIssueStatus(), IssueStatusVo.class)); |
| | | Set<IssueTypeApiEndStatus> issueTypeApiEndStatuses = issueType.getIssueTypeApiEndStatuses(); |
| | | if (issueTypeApiEndStatuses != null && issueTypeApiEndStatuses.size() > 0) { |
| | | IssueTypeApiEndStatus issueTypeApiEndStatus = issueTypeApiEndStatuses.iterator().next(); |
| | | |
| | | issueTypeVo.setCompleteIssueStatusVo(ConvertUtil.copyProperties(issueTypeApiEndStatus.getIssueStatus(), IssueStatusVo.class)); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | resJsonData.put(Constants.RES_KEY_CONTENTS, issueTypeVo); |
| | | } |
| | | |
| | | // 이슈 유형을 수정한다. 자동 종료 설정만 수정 |
| | | @Override |
| | | @Transactional |
| | | public IssueType modifyIssueTypeCompleteIssueStatus(IssueTypeForm issueTypeForm) { |
| | | // 사용하고 있는 업무 공간이 활성 상태인지 확인한다. 사용 공간에서 로그인한 사용자가 비활성인지 확인한다. |
| | | this.workspaceService.checkUseWorkspace(); |
| | | |
| | | IssueType issueType = this.getIssueType(issueTypeForm.getId()); |
| | | if (issueTypeForm.getCompleteIssueStatusId() != null) { |
| | | // api에서 사용하는 자동 종료 이슈 상태 |
| | | IssueStatus issueStatus = this.issueStatusService.getIssueStatus(issueTypeForm.getCompleteIssueStatusId()); |
| | | issueType.setIssueStatus(issueStatus); |
| | | }else { |
| | | issueType.setIssueStatus(null); |
| | | } |
| | | |
| | | this.issueTypeRepository.saveAndFlush(issueType); |
| | | return issueType; |
| | | } |
| | | |
| | | // 이슈 유형을 수정한다. |