| | |
| | | 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.constant.UseCompany; |
| | | import kr.wisestone.owl.constant.UsePartner; |
| | | import kr.wisestone.owl.domain.*; |
| | | import kr.wisestone.owl.domain.enumType.ProjectType; |
| | | 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 kr.wisestone.owl.util.MapUtil; |
| | | import kr.wisestone.owl.vo.*; |
| | | import kr.wisestone.owl.web.condition.IssueTypeCondition; |
| | | import kr.wisestone.owl.web.form.IssueTypeForm; |
| | |
| | | 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 { |
| | |
| | | private IssueTypeRepository issueTypeRepository; |
| | | |
| | | @Autowired |
| | | private ProjectRepository projectRepository; |
| | | |
| | | @Autowired |
| | | private WorkflowService workflowService; |
| | | |
| | | @Autowired |
| | | private WorkflowDepartmentService workflowDepartmentService; |
| | | |
| | | @Autowired |
| | | private ProjectService projectService; |
| | | |
| | | @Autowired |
| | | private ProjectRoleService projectRoleService; |
| | | |
| | | @Autowired |
| | | private WorkspaceService workspaceService; |
| | | |
| | | @Autowired |
| | | private CompanyFieldService companyFieldService; |
| | | |
| | | @Autowired |
| | | private IspFieldService ispFieldService; |
| | | |
| | | @Autowired |
| | | private HostingFieldService hostingFieldService; |
| | | private IssueStatusService issueStatusService; |
| | | |
| | | @Autowired |
| | | private IssueTypeMapper issueTypeMapper; |
| | |
| | | |
| | | @Autowired |
| | | private UserService userService; |
| | | |
| | | @Autowired |
| | | private ProjectClosureRepository projectClosureRepository; |
| | | |
| | | @Autowired |
| | | private ExcelView excelView; |
| | |
| | | |
| | | switch (projectType) { |
| | | case BTS_PROJECT: |
| | | issueTypes.add(new IssueType(workspace, workflow, "악성 도메인", "", "#ff5f99")); // 버그 |
| | | issueTypes.add(new IssueType(workspace, workflow, "경유지 대응", "", "#3598fe")); // 개선 |
| | | issueTypes.add(new IssueType(workspace, workflow, "악성 도메인", "", "#ff5f99", 0L, true)); // 버그 |
| | | issueTypes.add(new IssueType(workspace, workflow, "경유지 대응", "", "#3598fe", 0L, true)); // 개선 |
| | | break; |
| | | |
| | | case RMS_PROJECT: |
| | | issueTypes.add(new IssueType(workspace, workflow, "유포지 대응", "", "#3bcde2")); // 요구 사항 |
| | | issueTypes.add(new IssueType(workspace, workflow, "유포지 대응", "", "#3bcde2", 0L, true)); // 요구 사항 |
| | | break; |
| | | |
| | | case TCM_PROJECT: |
| | | issueTypes.add(new IssueType(workspace, workflow, "분석결과 대응", "", "#008ca7")); // 테스트 케이스, 실행 순서, 전제 조건, 기대 결과 |
| | | issueTypes.add(new IssueType(workspace, workflow, "분석결과 대응", "", "#008ca7", 0L, true)); // 테스트 케이스, 실행 순서, 전제 조건, 기대 결과 |
| | | break; |
| | | } |
| | | |
| | | this.issueTypeRepository.saveAll(issueTypes); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void addDefaultUsedProject(Workspace workspace) { |
| | | List<IssueType> issueTypes = this.issueTypeRepository.findByWorkspaceId(workspace.getId()); |
| | | List<Project> projects = this.projectRepository.findByWorkspaceId(workspace.getId()); |
| | | if(issueTypes != null && issueTypes.size() > 0){ |
| | | for(IssueType issueType : issueTypes){ |
| | | if(projects != null && projects.size()>0){ |
| | | for(Project project : projects){ |
| | | issueType.setProject(project); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | // 이슈 유형을 생성한다. |
| | |
| | | Project project = this.projectService.getProject(issueTypeForm.getProjectId()); |
| | | issueType.setProject(project); |
| | | |
| | | issueType.setUseCompany(issueTypeForm.getUseCompany()); |
| | | // 워크플로우의 담당부서와 동일하게 세팅 |
| | | this.setDepartmentOfProject(project, workflow); |
| | | |
| | | issueType.setUsePartner(issueTypeForm.getUsePartner()); |
| | | |
| | | issueType.setInheritPartners(issueTypeForm.getInheritPartners()); |
| | | |
| | | return this.issueTypeRepository.saveAndFlush(issueType); |
| | | } |
| | | |
| | | /** |
| | | * 워크플로우의 담당부서와 동일하게 세팅 |
| | | * @param project Project |
| | | * @param workflow Workflow |
| | | */ |
| | | private void setDepartmentOfProject(Project project, Workflow workflow) { |
| | | List<WorkflowDepartment> workflowDepartments = this.workflowDepartmentService.find(workflow.getId()); |
| | | |
| | | // 해당 워크플로우의 담당부서가 존재 할 경우 해당 프로젝트의 담당부서에도 추가 |
| | | if (workflowDepartments != null && workflowDepartments.size() > 0) { |
| | | ProjectRole projectRole = this.projectRoleService.findByProjectIdAndRoleType(project.getId(), ProjectRole.TYPE_DEFAULT); |
| | | |
| | | for (WorkflowDepartment workflowDepartment : workflowDepartments) { |
| | | // 프로젝트 담당부서로 추가 |
| | | projectRole.addDepartment(workflowDepartment.getDepartment()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 이름 유효성 체크 |
| | |
| | | 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"); |
| | | if (projectId != null) { |
| | | Project project = this.projectService.getProject(projectId); |
| | | ProjectVo projectVo = ConvertUtil.copyProperties(project, ProjectVo.class); |
| | | result.put("projectVo", projectVo); |
| | | |
| | | } |
| | | Long issueStatusId = MapUtil.getLong(result, "completeIssueStatusId"); |
| | | if (issueStatusId != null) { |
| | | IssueStatus issueStatus = this.issueStatusService.getIssueStatus(issueStatusId); |
| | | IssueStatusVo issueStatusVo = ConvertUtil.copyProperties(issueStatus, IssueStatusVo.class); |
| | | result.put("completeIssueStatusVo", issueStatusVo); |
| | | } |
| | | } |
| | | |
| | | Long totalCount = this.issueTypeMapper.count(condition); |
| | | int totalPage = (int) Math.ceil((totalCount - 1) / pageable.getPageSize()) + 1; |
| | | List<IssueTypeVo> issueTypeVos = ConvertUtil.convertListToListClass(results, IssueTypeVo.class); |
| | |
| | | } |
| | | |
| | | this.setUseIssueTypeByProject(issueTypeVos); |
| | | this.setUseIssueTypeByIssueStatus(issueTypeVos); |
| | | /*this.setUseIssueTypeByCompanyField(issueTypeVos); |
| | | this.setUseIssueTypeByIspField(issueTypeVos); |
| | | this.setUseIssueTypeByHostingField(issueTypeVos);*/ |
| | | this.setUsePartner(issueTypeVos); |
| | | |
| | | resJsonData.put(Constants.REQ_KEY_PAGE_VO, new ResPage(pageable.getPageNumber(), pageable.getPageSize(), |
| | | totalPage, totalCount)); |
| | |
| | | return issueTypeVos; |
| | | } |
| | | |
| | | // 이슈 유형 목록을 조회한다. |
| | | @Override |
| | | @Transactional(readOnly = true) |
| | | public List<IssueTypeVo> findIssueType(IssueTypeCondition condition) { |
| | | condition.setWorkspaceId(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId()); |
| | | List<Map<String, Object>> results = this.issueTypeMapper.find(condition); |
| | | return ConvertUtil.convertListToListClass(results, IssueTypeVo.class); |
| | | } |
| | | |
| | | // 이슈 유형에 연결된 워크플로우 정보를 셋팅한다. |
| | | private void setUseIssueTypeByWorkflow(List<IssueTypeVo> issueTypeVos) { |
| | | for (IssueTypeVo issueTypeVo : issueTypeVos) { |
| | | IssueType issueType = this.getIssueType(issueTypeVo.getId()); |
| | | issueTypeVo.setWorkflowVo(ConvertUtil.copyProperties(issueType.getWorkflow(), WorkflowVo.class)); |
| | | } |
| | | } |
| | | |
| | | // 이슈 유형에 연결된 파트너 정보를 셋팅한다. |
| | | private void setUsePartner(List<IssueTypeVo> issueTypeVos) { |
| | | for (IssueTypeVo issueTypeVo : issueTypeVos) { |
| | | List<UsePartnerVo> usePartnerVos = Lists.newArrayList(); |
| | | if (issueTypeVo.getUsePartners() != null) { |
| | | for (Integer usePartner : UsePartner.partners) {// 1 // 2 // 4 |
| | | UsePartnerVo usePartnerVo = UsePartner.checkUsePartner(issueTypeVo.getUsePartners(), usePartner);//3, 1 / 3, 2 / 3, 4 |
| | | if (usePartnerVo != null) { |
| | | usePartnerVos.add(usePartnerVo); |
| | | } |
| | | } |
| | | issueTypeVo.setUsePartnerVos(usePartnerVos); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | // 이슈 유형에 프로젝트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()); |
| | | |
| | | Set<IssueTypeApiEndStatus> issueTypeApiEndStatuses = issueType.getIssueTypeApiEndStatuses(); |
| | | if (issueTypeApiEndStatuses != null && issueTypeApiEndStatuses.size() > 0) { |
| | | IssueTypeApiEndStatus issueTypeApiEndStatus = issueTypeApiEndStatuses.iterator().next(); |
| | | |
| | | issueTypeVo.setCompleteIssueStatusVo(ConvertUtil.copyProperties(issueTypeApiEndStatus.getIssueStatus(), IssueStatusVo.class)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /*// 이슈 유형에 연결된 업체 정보를 셋팅한다. |
| | | private void setUseIssueTypeByCompanyField(List<IssueTypeVo> issueTypeVos) { |
| | | for (IssueTypeVo issueTypeVo : issueTypeVos){ |
| | |
| | | } |
| | | } |
| | | } |
| | | // 이슈 유형에 연결된 ISP 정보를 셋팅한다. |
| | | private void setUseIssueTypeByIspField(List<IssueTypeVo> issueTypeVos) { |
| | | for (IssueTypeVo issueTypeVo : issueTypeVos){ |
| | | IssueType issueType = this.getIssueType(issueTypeVo.getId()); |
| | | IspField ispField = issueType.getIspField(); |
| | | if(ispField != null){ |
| | | issueTypeVo.setIspFieldVo(ConvertUtil.copyProperties(issueType.getIspField(), IspFieldVo.class)); |
| | | } |
| | | } |
| | | } |
| | | // 이슈 유형에 연결된 호스팅 정보를 셋팅한다. |
| | | private void setUseIssueTypeByHostingField(List<IssueTypeVo> issueTypeVos) { |
| | | for (IssueTypeVo issueTypeVo : issueTypeVos){ |
| | | IssueType issueType = this.getIssueType(issueTypeVo.getId()); |
| | | HostingField hostingField = issueType.getHostingField(); |
| | | if(hostingField != null){ |
| | | issueTypeVo.setHostingFieldVo(ConvertUtil.copyProperties(issueType.getHostingField(), HostingFieldVo.class)); |
| | | } |
| | | } |
| | | }*/ |
| | | */ |
| | | |
| | | // 이슈 유형 상세 정보를 조회한다. |
| | | @Override |
| | |
| | | if (project != null) { |
| | | issueTypeVo.setProjectVo(ConvertUtil.copyProperties(issueType.getProject(), ProjectVo.class)); |
| | | } |
| | | Integer use = issueType.getUseCompany() != null ? issueType.getUseCompany().intValue() : 0; |
| | | Integer using = issueType.getUsePartner() != null ? issueType.getUsePartner().intValue() : 0; |
| | | |
| | | List<UseCompanyVo> useCompanyVos = Lists.newArrayList(); |
| | | for (Integer useCompany : UseCompany.useCompanies) { |
| | | UseCompanyVo useCompanyVo = UseCompany.checkUseCompany(use, useCompany); |
| | | List<UsePartnerVo> usePartnerVos = Lists.newArrayList(); |
| | | for (Integer usePartner : UsePartner.partners) {// 1 // 2 // 4 |
| | | UsePartnerVo usePartnerVo = UsePartner.checkUsePartner(using, usePartner);//3, 1 / 3, 2 / 3, 4 |
| | | |
| | | if (useCompanyVo != null) { |
| | | useCompanyVos.add(useCompanyVo); |
| | | if (usePartnerVo != null) { |
| | | usePartnerVos.add(usePartnerVo); |
| | | } |
| | | } |
| | | |
| | | issueTypeVo.setUseCompanyVos(useCompanyVos); |
| | | |
| | | /*CompanyField companyField = issueType.getCompanyField(); |
| | | if(companyField != null){ |
| | | issueTypeVo.setCompanyFieldVo(ConvertUtil.copyProperties(issueType.getCompanyField(), CompanyFieldVo.class)); |
| | | } |
| | | IspField ispField = issueType.getIspField(); |
| | | if (ispField != null){ |
| | | issueTypeVo.setIspFieldVo(ConvertUtil.copyProperties(issueType.getIspField(), IspFieldVo.class)); |
| | | } |
| | | HostingField hostingField = issueType.getHostingField(); |
| | | if (hostingField != null){ |
| | | issueTypeVo.setHostingFieldVo(ConvertUtil.copyProperties(issueType.getHostingField(), HostingFieldVo.class)); |
| | | }*/ |
| | | issueTypeVo.setUsePartnerVos(usePartnerVos); |
| | | } |
| | | |
| | | resJsonData.put(Constants.RES_KEY_CONTENTS, issueTypeVo); |
| | |
| | | Project project = this.projectService.getProject(issueTypeForm.getProjectId()); |
| | | issueType.setProject(project); |
| | | |
| | | issueType.setUseCompany(issueTypeForm.getUseCompany()); |
| | | // 워크플로우의 담당부서와 동일하게 세팅 |
| | | this.setDepartmentOfProject(project, workflow); |
| | | |
| | | issueType.setUsePartner(issueTypeForm.getUsePartner()); |
| | | |
| | | issueType.setInheritPartners(issueTypeForm.getInheritPartners()); |
| | | |
| | | /*if(issueTypeForm.getCompanyId() != null){ |
| | | CompanyField companyField = this.companyFieldService.getCompany(issueTypeForm.getCompanyId()); |
| | | issueType.setCompanyField(companyField); |
| | | } |
| | | if(issueTypeForm.getIspId() != null) { |
| | | IspField ispField = this.ispFieldService.getIsp(issueTypeForm.getIspId()); |
| | | issueType.setIspField(ispField); |
| | | } |
| | | if(issueTypeForm.getHostingId() != null) { |
| | | HostingField hostingField = this.hostingFieldService.getHosting(issueTypeForm.getHostingId()); |
| | | issueType.setHostingField(hostingField); |
| | | }*/ |
| | | // issueType.setCompanyYn(issueTypeForm.getCompanyYn()); |
| | | // issueType.setIspYn(issueTypeForm.getIspYn()); |
| | | // issueType.setHostingYn(issueTypeForm.getHostingYn()); |
| | | |
| | | this.issueTypeRepository.saveAndFlush(issueType); |
| | | |
| | |
| | | return this.issueTypeRepository.findByWorkspaceId(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId()); |
| | | } |
| | | |
| | | // 워크플로우 ID로 이슈 유형 조회 |
| | | @Override |
| | | @Transactional(readOnly = true) |
| | | public List<IssueType> findByWorkflowId(Long id) { |
| | | return this.issueTypeRepository.findByWorkflowId(id); |
| | | } |
| | | |
| | | // 이슈 타입 필드 목록을 엑셀로 다운로드 한다. |
| | | @Override |
| | | @Transactional |