| | |
| | | package kr.wisestone.owl.service.impl; |
| | | |
| | | import com.google.common.collect.Lists; |
| | | import com.sun.org.apache.bcel.internal.generic.NEW; |
| | | import kr.wisestone.owl.common.ExcelConditionCheck; |
| | | import kr.wisestone.owl.common.IssueCustomFieldValueFormComparator; |
| | | import kr.wisestone.owl.config.CommonConfiguration; |
| | | import kr.wisestone.owl.constant.Constants; |
| | | import kr.wisestone.owl.constant.ElasticSearchConstants; |
| | | import kr.wisestone.owl.constant.MsgConstants; |
| | | import kr.wisestone.owl.constant.UsePartner; |
| | | import kr.wisestone.owl.constant.*; |
| | | import kr.wisestone.owl.data.CheckIssueData; |
| | | import kr.wisestone.owl.domain.*; |
| | | import kr.wisestone.owl.domain.enumType.CustomFieldType; |
| | |
| | | import kr.wisestone.owl.exception.OwlRuntimeException; |
| | | import kr.wisestone.owl.mapper.IssueMapper; |
| | | import kr.wisestone.owl.mapper.ProjectMapper; |
| | | import kr.wisestone.owl.repository.IssueRelationRepository; |
| | | import kr.wisestone.owl.repository.IssueRepository; |
| | | import kr.wisestone.owl.repository.UserDepartmentRepository; |
| | | import kr.wisestone.owl.repository.WorkflowDepartmentRepository; |
| | | import kr.wisestone.owl.service.*; |
| | | import kr.wisestone.owl.util.*; |
| | | import kr.wisestone.owl.util.DateUtil; |
| | |
| | | |
| | | @Autowired |
| | | private ProjectService projectService; |
| | | |
| | | @Autowired |
| | | private IssueTableConfigService issueTableConfigService; |
| | | |
| | | @Autowired |
| | | private IssueStatusService issueStatusService; |
| | |
| | | private UserWorkspaceService userWorkspaceService; |
| | | |
| | | @Autowired |
| | | private UserLevelService userLevelService; |
| | | |
| | | @Autowired |
| | | private WorkflowDepartmentService workflowDepartmentService; |
| | | |
| | | @Autowired |
| | | private IssueRelationService issueRelationService; |
| | | |
| | | @Autowired |
| | | private IssueRelationRepository issueRelationRepository; |
| | | |
| | | @Autowired |
| | | private ExcelView excelView; |
| | |
| | | |
| | | @Autowired |
| | | private SimpMessagingTemplate simpMessagingTemplate; |
| | | |
| | | @Autowired |
| | | private UserDepartmentRepository userDepartmentRepository; |
| | | |
| | | @Autowired |
| | | private WorkflowDepartmentRepository workflowDepartmentRepository; |
| | | |
| | | @Override |
| | | protected JpaRepository<Issue, Long> getRepository() { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // 프로젝트 입력 |
| | | Project project = issueType.getProject(); |
| | | if (project == null){ |
| | |
| | | issueForm.setSeverityId(issueApiDefault.getSeverity().getId()); |
| | | } |
| | | |
| | | // 중복 값 하위 이슈로 처리하기 |
| | | // 중복 값 상위 이슈의 하위 이슈로 처리하기 |
| | | CustomFieldApiOverlapForm customFieldApiOverlapForm = new CustomFieldApiOverlapForm(); |
| | | customFieldApiOverlapForm.setUserId(user.getId()); |
| | | customFieldApiOverlapForm.setIssueTypeId(issueForm.getIssueTypeId()); |
| | | |
| | | IssueVo issueVo = this.findIssue(issueApiForm, user.getId()); |
| | | if (issueVo != null) { |
| | | issueForm.setParentIssueId(issueVo.getId()); |
| | | // 상위일감에 사용할 중복값 설정 |
| | | List<CustomFieldApiOverlap> customFieldApiOverlaps = this.customFieldApiOverlapService.find(user.getId(), issueApiForm.getIssueTypeId()); |
| | | for(int i=0; i < customFieldApiOverlaps.size() ; i++ ){ |
| | | CustomFieldApiOverlap customFieldApiOverlap = customFieldApiOverlaps.get(i); |
| | | issueApiForm.addUseIssueCustomFieldId(customFieldApiOverlap.getCustomField().getId()); |
| | | } |
| | | |
| | | List<IssueVo> issueVos = this.findIssue(issueApiForm, customFieldApiOverlaps, user.getId()); |
| | | int size = issueVos.size(); |
| | | if (size > 0) { |
| | | issueForm.setParentIssueId(issueVos.get(0).getId()); |
| | | } |
| | | |
| | | issueForm.setIsApi(Issue.IS_API_YES); |
| | |
| | | // API 를 통해 이슈 추가. |
| | | @Override |
| | | @Transactional |
| | | public Issue addApiIssue(IssueApiForm issueApiForm) { |
| | | public List<Issue> addApiIssue(IssueApiForm issueApiForm) throws CloneNotSupportedException { |
| | | User user = convertToUser(issueApiForm.getToken()); |
| | | IssueForm issueForm = this.convertToIssueForm(issueApiForm, user); |
| | | |
| | | return addIssue(user, issueForm, issueApiForm.getMultipartFiles()); |
| | | List<Issue> issues = Lists.newArrayList(); |
| | | if (issueForm.getParentIssueId() != null) { |
| | | issues.add(addIssue(user, issueForm, issueApiForm.getMultipartFiles())); |
| | | } else { |
| | | // 상위 이슈 추가 |
| | | IssueForm parentIssueForm = issueForm.clone(); |
| | | parentIssueForm.setUseIssueCustomFields(issueApiForm.getUseIssueCustomFieldIds()); |
| | | Issue issue = addIssue(user, parentIssueForm, null); |
| | | issues.add(issue); |
| | | // 하위 이슈 추가 |
| | | issueForm.setParentIssueId(issue.getId()); |
| | | issues.add(addIssue(user, issueForm, issueApiForm.getMultipartFiles())); |
| | | } |
| | | |
| | | return issues; |
| | | } |
| | | |
| | | |
| | | // 상위 이슈 가져오기 |
| | | private IssueVo getParentIssueVo(Long parentIssueId) { |
| | | if (parentIssueId != null) { |
| | | Issue parentIssue = this.getIssue(parentIssueId); |
| | | return ConvertUtil.copyProperties(parentIssue, IssueVo.class); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | // 중복된 상위 이슈 검색 |
| | | private IssueVo findIssue(IssueApiForm issueApiForm, Long userId) { |
| | | IssueCustomFieldValueCondition issueCustomFieldValueCondition = new IssueCustomFieldValueCondition(); |
| | | private List<IssueVo> findIssue(IssueApiForm issueApiform, List<CustomFieldApiOverlap> customFieldApiOverlaps, Long userId) { |
| | | List<IssueCustomFieldValueForm> issueCustomFieldValueForms = issueApiform.getIssueCustomFieldValues(); |
| | | List<IssueVo> resultIssueVos = Lists.newArrayList(); |
| | | String comma = ","; |
| | | |
| | | List<CustomFieldApiOverlap> customFieldApiOverlaps = this.customFieldApiOverlapService.find(userId, issueApiForm.getIssueTypeId()); |
| | | if (customFieldApiOverlaps != null && customFieldApiOverlaps.size() > 0) { |
| | | for (CustomFieldApiOverlap customFieldApiOverlap : customFieldApiOverlaps) { |
| | | for (IssueCustomFieldValueForm issueCustomFieldValue : issueApiForm.getIssueCustomFieldValues()) { |
| | | if (customFieldApiOverlap.getCustomField().getId().equals(issueCustomFieldValue.getCustomFieldId())) { |
| | | issueCustomFieldValueCondition.addUseValues(issueCustomFieldValue.getUseValue()); |
| | | if (issueCustomFieldValueForms.size() > 0) { |
| | | String concatUseValue = ""; |
| | | int useIdx = 0; |
| | | |
| | | IssueCustomFieldValueFormComparator comp = new IssueCustomFieldValueFormComparator(); |
| | | Collections.sort(issueCustomFieldValueForms, comp); |
| | | |
| | | for (IssueCustomFieldValueForm issueCustomFieldValueForm : issueCustomFieldValueForms) { |
| | | for(CustomFieldApiOverlap customFieldApiOverlap : customFieldApiOverlaps) { |
| | | if (customFieldApiOverlap.getCustomField().getId().equals(issueCustomFieldValueForm.getCustomFieldId())) { |
| | | if (useIdx > 0) { |
| | | concatUseValue = concatUseValue.concat(comma); |
| | | } |
| | | concatUseValue = concatUseValue.concat(issueCustomFieldValueForm.getUseValue()); |
| | | useIdx++; |
| | | } |
| | | } |
| | | } |
| | | |
| | | IssueCustomFieldValueCondition issueCustomFieldValueCondition = new IssueCustomFieldValueCondition(); |
| | | issueCustomFieldValueCondition.setUseValue(concatUseValue); |
| | | List<Map<String, Object>> results = this.issueMapper.findByCustomFieldValue(issueCustomFieldValueCondition); |
| | | if (results != null && results.size() > 0) { |
| | | IssueVo issueVo = new IssueVo(); |
| | | ConvertUtil.convertMapToObject(results.get(0), issueVo); |
| | | return issueVo; |
| | | for (Map<String, Object> result : results) { |
| | | resultIssueVos.add(ConvertUtil.convertMapToClass(result, IssueVo.class)); |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | return resultIssueVos; |
| | | } |
| | | |
| | | // 이슈를 생성한다. |
| | |
| | | // 날짜 유효성 체크 |
| | | this.checkStartCompleteDate(issueForm.getStartDate(), issueForm.getCompleteDate()); |
| | | // 담당 부서 유효성 체크 |
| | | this.verifyIssueDepartment(project, issueForm); |
| | | //this.verifyIssueDepartment(project, issueForm); |
| | | |
| | | // 이슈 상태 유형이 '대기' 인 이슈 상태 가져오기 |
| | | IssueStatus issueStatus = this.issueStatusService.findByIssueStatusTypeIsReady(issueType.getWorkflow()); |
| | |
| | | // HOSTING 정보 저장 |
| | | this.issueHostingService.modifyIssueHostingField(issue, issueForm.getIssueHostingFields()); |
| | | |
| | | |
| | | // 첨부 파일 저장 |
| | | // multipartFile 을 file Map List 객체로 변경한다. |
| | | List<Map<String, Object>> convertFileMaps = this.convertMultipartFileToFile(multipartFiles); |
| | | this.attachedFileService.addAttachedFile(convertFileMaps, issue, user.getAccount()); |
| | | |
| | | // 텍스트 에디터에 첨부한 파일을 이슈와 연결 |
| | | this.checkNotHaveIssueIdAttachedFile(issue, issueForm); |
| | | // 사용자 정의 필드 저장 |
| | | this.issueCustomFieldValueService.modifyIssueCustomFieldValue(issue, issueForm.getIssueCustomFields()); |
| | | // 이슈 이력 생성 |
| | | this.issueHistoryService.addIssueHistory(issue, user, IssueHistoryType.ADD, null); |
| | | // 이슈 위험 관리 생성 |
| | | this.issueRiskService.addIssueRisk(issue, project.getWorkspace()); |
| | | // 영속성 컨텍스트 비우기 |
| | | this.clear(); |
| | | // 이슈 생성, 삭제시 예약 이메일에 등록해놓는다. |
| | | this.reservationIssueEmail(issue, EmailType.ISSUE_ADD); |
| | | // 사용자 시스템 기능 사용 정보 수집 |
| | | |
| | | UserVo userVo = ConvertUtil.copyProperties(user, UserVo.class); |
| | | log.info(ElasticSearchUtil.makeUserActiveHistoryMessage(userVo, ElasticSearchConstants.ISSUE_ADD)); |
| | | |
| | | return issue; |
| | | } |
| | | |
| | | // 연관이슈를 생성한다. |
| | | @Override |
| | | @Transactional |
| | | public Issue addRelIssue(IssueForm issueForm, List<MultipartFile> multipartFiles) { |
| | | User user = this.webAppUtil.getLoginUserObject(); |
| | | return addRelIssue(user, issueForm, multipartFiles); |
| | | } |
| | | |
| | | // 연관이슈를 생성한다. |
| | | @Override |
| | | @Transactional |
| | | public Issue addRelIssue(User user, IssueForm issueForm, List<MultipartFile> multipartFiles) { |
| | | // 사용하고 있는 업무 공간이 활성 상태인지 확인한다. 사용 공간에서 로그인한 사용자가 비활성인지 확인한다. |
| | | Workspace workspace = this.workspaceService.checkUseWorkspace(user, user.getLastWorkspaceId()); |
| | | // 프로젝트 유효성 체크 |
| | | Project project = this.projectService.getProject(issueForm.getProjectId()); |
| | | // 이슈 유형 유효성 체크 |
| | | IssueType issueType = this.issueTypeService.getIssueType(issueForm.getIssueTypeId()); |
| | | // 우선순위 유효성 체크 |
| | | Priority priority = this.priorityService.getPriority(issueForm.getPriorityId()); |
| | | // 중요도 유효성 체크 |
| | | Severity severity = this.severityService.getSeverity(issueForm.getSeverityId()); |
| | | |
| | | // 제목 유효성 체크 |
| | | this.verifyTitle(issueForm.getTitle()); |
| | | // 날짜 유효성 체크 |
| | | this.checkStartCompleteDate(issueForm.getStartDate(), issueForm.getCompleteDate()); |
| | | // 담당 부서 유효성 체크 |
| | | //this.verifyIssueDepartment(project, issueForm); |
| | | |
| | | // 이슈 상태 유형이 '대기' 인 이슈 상태 가져오기 |
| | | IssueStatus issueStatus = this.issueStatusService.findByIssueStatusTypeIsReady(issueType.getWorkflow()); |
| | | |
| | | Issue issue = ConvertUtil.copyProperties(issueForm, Issue.class); |
| | | issue.setProject(project); |
| | | issue.setIssueStatus(issueStatus); |
| | | issue.setIssueType(issueType); |
| | | issue.setPriority(priority); |
| | | issue.setSeverity(severity); |
| | | if (issueForm.getParentIssueId() != null){ |
| | | Issue parentIssue = this.getIssue(issueForm.getParentIssueId()); |
| | | issue.setParentIssue(parentIssue); |
| | | } |
| | | |
| | | issue.setIssueNumber(this.issueNumberGeneratorService.generateIssueNumber(project)); // 각 프로젝트의 고유 이슈 번호 생성 |
| | | |
| | | issue = this.issueRepository.saveAndFlush(issue); |
| | | |
| | | issue.setReverseIndex(issue.getId() * -1); // 쿼리 속도 개선을 위해 리버스 인덱스 생성 |
| | | // 담당자 지정 |
| | | //this.issueUserService.modifyIssueUser(issue, project.getWorkspace(), issueForm.getUserIds()); |
| | | // 담당부서 지정 |
| | | this.issueDepartmentService.modifyIssueDepartment(issue, user, project.getWorkspace(), issueForm.getDepartmentIds()); |
| | | // 업체 정보 저장 |
| | | this.issueCompanyService.modifyIssueCompanyField(issue, issueForm.getIssueCompanyFields()); |
| | | // ISP 정보 저장 |
| | | this.issueIspService.modifyIssueIspField(issue, issueForm.getIssueIspFields()); |
| | | // HOSTING 정보 저장 |
| | | this.issueHostingService.modifyIssueHostingField(issue, issueForm.getIssueHostingFields()); |
| | | |
| | | // 첨부 파일 저장 |
| | | // multipartFile 을 file Map List 객체로 변경한다. |
| | |
| | | } |
| | | } |
| | | |
| | | void SetMyDepartmentId(IssueCondition issueCondition){ |
| | | Long loginId = issueCondition.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()); |
| | | } |
| | | } |
| | | issueCondition.setMyDepartmentIds(myDepartmentIds); |
| | | } |
| | | |
| | | void SetWorkflowDepartment(List<IssueVo> issueVos){ |
| | | for(IssueVo issueVo : issueVos){ |
| | | Long issueTypeId = issueVo.getIssueTypeId(); |
| | | IssueType issueType = this.issueTypeService.getIssueType(issueTypeId); |
| | | Long workflowId = issueType.getWorkflow().getId(); |
| | | List<WorkflowDepartment> workflowDepartmentList = this.workflowDepartmentRepository.findByWorkflowId(workflowId); |
| | | List<Long> workflowDepartmentIds = Lists.newArrayList(); |
| | | if(workflowDepartmentList != null && workflowDepartmentList.size()>0){ |
| | | for(WorkflowDepartment workflowDepartment : workflowDepartmentList){ |
| | | workflowDepartmentIds.add(workflowDepartment.getDepartment().getId()); |
| | | } |
| | | } |
| | | if(issueVo.getIssueTypeId().equals(issueTypeId)){ |
| | | issueVo.setWorkflowDepartmentIds(workflowDepartmentIds); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 이슈 목록을 조회한다. |
| | | @Override |
| | | @Transactional(readOnly = true) |
| | | public List<IssueVo> findIssue(Map<String, Object> resJsonData, |
| | | IssueCondition issueCondition, Pageable pageable) { |
| | | public List<IssueVo> findIssue(Map<String, Object> resJsonData, IssueCondition issueCondition, Pageable pageable) { |
| | | |
| | | // 검색 조건을 만든다 |
| | | if (!this.makeIssueSearchCondition(issueCondition, Lists.newArrayList("01", "02", "03"), pageable)) { |
| | |
| | | List<String> issueKeys = Lists.newArrayList(issueIds); |
| | | issueCondition.setIssueIds(issueKeys); |
| | | |
| | | List<Map<String, Object>> results = this.issueMapper.find(issueCondition); |
| | | issueCondition.setLoginUserId(this.webAppUtil.getLoginId()); |
| | | issueCondition.setWorkspaceId(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId()); |
| | | User user = this.webAppUtil.getLoginUserObject(); |
| | | |
| | | |
| | | List<Map<String, Object>> results = Lists.newArrayList(); |
| | | Long totalCount = 0L; |
| | | UserLevel userLevel = this.userLevelService.getUserLevel(user.getUserLevel().getId()); |
| | | |
| | | if (this.userWorkspaceService.checkWorkspaceManager(user) |
| | | || MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_ISSUE_ALL)) { |
| | | results = this.issueMapper.find(issueCondition); |
| | | totalCount = this.issueMapper.count(issueCondition); |
| | | } else{ |
| | | this.SetMyDepartmentId(issueCondition); |
| | | results = this.issueMapper.findByDepartment(issueCondition); |
| | | totalCount = this.issueMapper.countByDepartment(issueCondition); |
| | | } |
| | | |
| | | |
| | | // 튜닝 전 - 0.8, 0.9, 0.9, 0.9, 0.9 |
| | | /*StopWatch serviceStart = new StopWatch(); |
| | | serviceStart.start();*/ |
| | | Long totalCount = this.issueMapper.count(issueCondition); |
| | | // 튜닝 전 - 1.1, 1.1, 1.3, 1.2 |
| | | |
| | | /*serviceStart.stop(); |
| | |
| | | |
| | | int totalPage = (int) Math.ceil((totalCount - 1) / pageable.getPageSize()) + 1; |
| | | // 이슈 아이디 초기화 |
| | | issueCondition.setIsApi(issueCondition.getIsApi()); |
| | | issueCondition.setIssueIds(Lists.newArrayList()); |
| | | // Map 에 있는 데이터를 IssueVo 데이터로 변환한다. |
| | | User user = this.webAppUtil.getLoginUserObject(); |
| | | this.setMapToIssueVo(results, issueVos, issueCondition, user); |
| | | |
| | | this.setCountDownIssues(results, issueVos); |
| | | this.SetWorkflowDepartment(issueVos); //워크플로우에 설정한 담당부서 가져오기 |
| | | |
| | | resJsonData.put(Constants.RES_KEY_CONTENTS, issueVos); |
| | | resJsonData.put(Constants.REQ_KEY_PAGE_VO, new ResPage(pageable.getPageNumber(), pageable.getPageSize(), |
| | |
| | | return issueVos; |
| | | } |
| | | |
| | | private void setCountDownIssues(List<Map<String, Object>> results, List<IssueVo> issueVos) { |
| | | @Override |
| | | @Transactional(readOnly = true) |
| | | public void setCountDownIssues(List<Map<String, Object>> results, List<IssueVo> issueVos) { |
| | | for (Map<String, Object> result : results){ |
| | | List<Issue> downIssues = this.issueRepository.findByParentIssueId((Long) result.get("id")); //하위이슈 가져오기 |
| | | if(downIssues != null && downIssues.size() > 0){ //상위이슈 가지고 있는 애들이 있으면 |
| | | int downIssueCount = 0; |
| | | int downIssueAllCount = 0;// 하위이슈 전체 카운트 |
| | | int downIssueCount = 0;// 하위이슈 미완료 카운트 |
| | | for(Issue downIssue : downIssues){ |
| | | downIssueCount ++; |
| | | downIssueAllCount ++; |
| | | Long parentIssueId = downIssue.getParentIssue().getId(); |
| | | Issue parentIssue = this.getIssue(parentIssueId); |
| | | IssueVo parentIssueVo = ConvertUtil.copyProperties(parentIssue, IssueVo.class); |
| | | parentIssueVo.setDownIssueCount(downIssueCount); |
| | | parentIssueVo.setDownIssueAllCount(downIssueAllCount); |
| | | |
| | | IssueStatus downIssueStatus = this.issueStatusService.getIssueStatus(downIssue.getIssueStatus().getId()); |
| | | IssueVo downIssueVo = ConvertUtil.copyProperties(downIssue, IssueVo.class); |
| | | downIssueVo.setIssueStatusType(downIssueStatus.getIssueStatusType().toString()); |
| | | |
| | | if(!downIssueVo.getIssueStatusType().equals("CLOSE")){ //미완료 하위이슈 체크 |
| | | downIssueCount ++; |
| | | } |
| | | |
| | | for(IssueVo issueVo : issueVos){ |
| | | if(issueVo.getId().equals(parentIssueVo.getId())){ |
| | | issueVo.setDownIssueCount(parentIssueVo.getDownIssueCount()); |
| | | issueVo.setDownIssueCount(downIssueCount); |
| | | issueVo.setDownIssueAllCount(parentIssueVo.getDownIssueAllCount()); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | case "02": // 프로젝트, 이슈 유형, 이슈 상태, 우선순위, 중요도, 담당자, 첨부파일, 사용자 정의 필드 정보, 댓글, 기록을 셋팅한다. |
| | | this.setIssueDetail(issueVo, issue); // 이슈 상세 정보를 셋팅한다. |
| | | this.setIssueTableConfigs(issue, issueVo); |
| | | issueVo.setProjectVo(ConvertUtil.copyProperties(issue.getProject(), ProjectVo.class)); |
| | | break; |
| | | } |
| | |
| | | resJsonData.put(Constants.RES_KEY_CONTENTS, issueVo); |
| | | } |
| | | |
| | | // 테이블 설정 셋팅 |
| | | private void setIssueTableConfigs(Issue issue, IssueVo issueVo) { |
| | | Long IssueTypeId = issue.getIssueType().getId(); |
| | | |
| | | for (int tableConfigType : IssueTableConfig.IssueTableTypes) { |
| | | if (tableConfigType != IssueTableConfig.ISSUE_TABLE_TYPE_MAIN) { |
| | | issueVo.addIssueTableConfigVo(createIssueTableConfigVo(IssueTypeId, tableConfigType)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private IssueTableConfigVo createIssueTableConfigVo(Long issueTypeId, int tableConfigType) { |
| | | IssueTableConfig issueTableConfig = this.issueTableConfigService.findByUserIdAndWorkspaceIdAndIssueTypeIdAndIssueTableType(issueTypeId, tableConfigType); |
| | | if (issueTableConfig != null) { |
| | | return ConvertUtil.copyProperties(issueTableConfig, IssueTableConfigVo.class); |
| | | } |
| | | return new IssueTableConfigVo(); |
| | | } |
| | | |
| | | |
| | | // 하위 이슈 정보를 셋팅한다 |
| | | private void setDownIssues(Issue issue, IssueVo issueVo) { |
| | | List<Issue> downIssues = this.issueRepository.findByParentIssueId(issue.getId()); |
| | | /*if(issueVo != null && downIssues.size()>0){ |
| | | for(Issue downIssue : downIssues){ |
| | | IssueVo downIssueVo = ConvertUtil.copyProperties(downIssue, IssueVo.class); |
| | | IssueDownVo issueDownVo = ConvertUtil.copyProperties(downIssueVo, IssueDownVo.class); |
| | | issueDownVo.setIssueDown(downIssueVo); |
| | | issueDownVo.setTitle(downIssue.getTitle()); |
| | | issueDownVo.setIssueTypeVo(ConvertUtil.copyProperties(downIssue.getIssueType(), IssueTypeVo.class)); |
| | | issueDownVo.setPriorityVo(ConvertUtil.copyProperties(downIssue.getPriority(), PriorityVo.class)); |
| | | issueDownVo.setSeverityVo(ConvertUtil.copyProperties(downIssue.getSeverity(), SeverityVo.class)); |
| | | this.setRegister(downIssue, downIssueVo); // 등록자 |
| | | this.setIssueDepartment(downIssue, downIssueVo); // 담당부서 정보 셋팅 |
| | | this.setIssueCustomFields(downIssue, downIssueVo); // 사용자정의필드 정보 세팅 |
| | | issueVo.addIssueDownVo(issueDownVo); |
| | | } |
| | | }*/ |
| | | |
| | | List<IssueVo> downIssueVos = ConvertUtil.convertObjectsToClasses(downIssues, IssueVo.class); |
| | | List<IssueVo> resultList = new ArrayList<>(); |
| | | if(downIssueVos != null && downIssueVos.size()>0){ |
| | | for(IssueVo downIssueVo : downIssueVos){ |
| | | if(downIssues != null && downIssues.size()>0){ |
| | | List<IssueVo> resultList = new ArrayList<>(); |
| | | for(Issue downIssue : downIssues){ |
| | | IssueVo downIssueVo = ConvertUtil.copyProperties(downIssue, IssueVo.class); |
| | | downIssueVo.setIssueTypeVo(ConvertUtil.copyProperties(downIssue.getIssueType(), IssueTypeVo.class)); |
| | | downIssueVo.setPriorityVo(ConvertUtil.copyProperties(downIssue.getPriority(), PriorityVo.class)); |
| | | downIssueVo.setSeverityVo(ConvertUtil.copyProperties(downIssue.getSeverity(), SeverityVo.class)); |
| | | //이슈 상태 추가 |
| | | IssueStatusVo issueStatusVo = ConvertUtil.copyProperties(downIssue.getIssueStatus(), IssueStatusVo.class, "issueStatusType"); |
| | | issueStatusVo.setIssueStatusType(downIssue.getIssueStatus().getIssueStatusType().toString()); |
| | | downIssueVo.setIssueStatusVo(issueStatusVo); |
| | | |
| | | this.setRegister(downIssue, downIssueVo); // 등록자 |
| | | this.setIssueDepartment(downIssue, downIssueVo); // 담당부서 정보 셋팅 |
| | | this.setIssueCustomFields(downIssue, downIssueVo); // 사용자정의필드 정보 세팅 |
| | | |
| | | resultList.add(downIssueVo); |
| | | } |
| | | resultList.add(downIssueVo); |
| | | issueVo.setIssueDownVos(resultList); |
| | | } |
| | | issueVo.setIssueDownVos(resultList); |
| | | } |
| | | } |
| | | |
| | | // 이슈 상세 정보를 셋팅한다. |
| | |
| | | issueRelationVo.setIssueTypeVo(ConvertUtil.copyProperties(relationIssue.getIssueType(), IssueTypeVo.class)); |
| | | issueRelationVo.setPriorityVo(ConvertUtil.copyProperties(relationIssue.getPriority(), PriorityVo.class)); |
| | | issueRelationVo.setSeverityVo(ConvertUtil.copyProperties(relationIssue.getSeverity(), SeverityVo.class)); |
| | | //이슈 상태 추가 |
| | | IssueStatusVo issueStatusVo = ConvertUtil.copyProperties(relationIssue.getIssueStatus(), IssueStatusVo.class, "issueStatusType"); |
| | | issueStatusVo.setIssueStatusType(relationIssue.getIssueStatus().getIssueStatusType().toString()); |
| | | issueRelationVo.setIssueStatusVo(issueStatusVo); |
| | | |
| | | this.setRegister(relationIssue, relIssueVo); // 등록자 |
| | | this.setIssueDepartment(relationIssue, relIssueVo); // 담당부서 정보 셋팅 |
| | | this.setIssueCustomFields(relationIssue, relIssueVo); // 사용자정의필드 정보 세팅 |
| | |
| | | } |
| | | |
| | | // 이슈(이슈 유형)에 연결된 사용자 정의 필드 정보를 셋팅한다. |
| | | private void setIssueCustomFields(Issue issue, IssueVo issueVo) { |
| | | private IssueVo setIssueCustomFields(Issue issue, IssueVo issueVo) { |
| | | |
| | | // 해당 프로젝트의 이슈 유형에 연결된 사용자 정의 필드 정보를 가져온다. |
| | | IssueTypeCustomFieldCondition issueTypeCustomFieldCondition = new IssueTypeCustomFieldCondition(); |
| | |
| | | // 이슈에서 사용된 사용자 정의 필드 값을 가져온다. |
| | | List<IssueCustomFieldValueVo> issueCustomFieldValueVos = this.issueCustomFieldValueService.findByIssueId(issue.getId()); |
| | | issueVo.setIssueCustomFieldValueVos(issueCustomFieldValueVos); |
| | | |
| | | return issueVo; |
| | | } |
| | | |
| | | // 이슈에 등록된 댓글 정보를 셋팅한다. |
| | |
| | | @Override |
| | | @Transactional |
| | | public List<IssueVo> findIssue(IssueApiForm issueApiform) { |
| | | |
| | | List<IssueCustomFieldValueForm> issueCustomFieldValueForms = issueApiform.getIssueCustomFieldValues(); |
| | | IssueCustomFieldValueCondition issueCustomFieldValueCondition = new IssueCustomFieldValueCondition(); |
| | | if (issueCustomFieldValueForms != null && issueCustomFieldValueForms.size() > 0) { |
| | | for (IssueCustomFieldValueForm issueCustomFieldValueForm : issueCustomFieldValueForms) { |
| | | issueCustomFieldValueCondition.addUseValues(issueCustomFieldValueForm.getUseValue()); |
| | | List<IssueVo> resultIssueVos = Lists.newArrayList(); |
| | | String comma = ","; |
| | | |
| | | if (issueCustomFieldValueForms.size() > 0) { |
| | | String concatUseValue = ""; |
| | | for (int i = 0; i < issueCustomFieldValueForms.size(); i++) { |
| | | IssueCustomFieldValueForm issueCustomFieldValueForm = issueCustomFieldValueForms.get(i); |
| | | if (i > 0) { |
| | | concatUseValue = concatUseValue.concat(comma); |
| | | } |
| | | concatUseValue = concatUseValue.concat(issueCustomFieldValueForm.getUseValue()); |
| | | } |
| | | |
| | | IssueCustomFieldValueCondition issueCustomFieldValueCondition = new IssueCustomFieldValueCondition(); |
| | | issueCustomFieldValueCondition.setUseValue(concatUseValue); |
| | | List<Map<String, Object>> results = this.issueMapper.findByCustomFieldValue(issueCustomFieldValueCondition); |
| | | if (results != null && results.size() > 0) { |
| | | for (Map<String, Object> result : results) { |
| | | resultIssueVos.add(ConvertUtil.convertMapToClass(result, IssueVo.class)); |
| | | } |
| | | } |
| | | } |
| | | List<Map<String, Object>> results = this.issueMapper.findByCustomFieldValue(issueCustomFieldValueCondition); |
| | | List<IssueVo> issueVos = Lists.newArrayList(); |
| | | if (results != null && results.size() > 0) { |
| | | issueVos.add(ConvertUtil.convertMapToClass(results.get(0), IssueVo.class)); |
| | | } |
| | | |
| | | return issueVos; |
| | | return resultIssueVos; |
| | | } |
| | | |
| | | // 리스트에서 해당 아이디를 가지고 있는 이슈 검색 |
| | | private IssueVo findIssueVo(List<IssueVo> list, Long id) { |
| | | for (IssueVo issueVo : list) { |
| | | if (id.equals(issueVo.getId())) { |
| | | return issueVo; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | |
| | | IssueForm issueForm = this.convertToIssueForm(issueApiForm, user); |
| | | |
| | | List<IssueVo> issueVos = this.findIssue(issueApiForm); |
| | | List<Issue> issue = Lists.newArrayList(); |
| | | for (IssueVo issueVo : issueVos) { |
| | | issueForm.setId(issueVo.getId()); |
| | | issue.add(this.modifyIssueForApi(user, issueForm, files)); |
| | | } |
| | | if (issueVos != null && issueVos.size() > 0) { |
| | | List<Issue> issue = Lists.newArrayList(); |
| | | for (IssueVo issueVo : issueVos) { |
| | | IssueVo parentIssueVo = issueVo.getParentIssueVo(); |
| | | issueForm.setId(issueVo.getId()); |
| | | |
| | | return issue; |
| | | // 자동 종료 상태 설정이 되어 있지 않으면 오류발생 |
| | | Issue modifyIssue = this.modifyIssueForApi(user, issueForm, files); |
| | | Issue parentIssue = modifyIssue.getParentIssue(); |
| | | IssueType issueType = modifyIssue.getIssueType(); |
| | | IssueStatus issueStatus = issueType.getIssueStatus(); |
| | | if (issueStatus == null) { |
| | | throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.API_COMPLETE_ISSUE_STATUS_NOT_EXIST)); |
| | | } |
| | | |
| | | if (parentIssue != null) { |
| | | IssueCondition issueCondition = new IssueCondition(issueVo.getId(), parentIssue.getId()); |
| | | List<Map<String, Object>> results = this.issueMapper.findNotCompleteByParentIssueId(issueCondition); |
| | | // 하위 일감이 모두 종료 상태일때 상위 일감도 종료 처리 |
| | | if (results == null || results.size() == 0) { |
| | | parentIssue.setIssueStatus(issueType.getIssueStatus()); |
| | | this.issueRepository.saveAndFlush(parentIssue); |
| | | } |
| | | } |
| | | |
| | | issue.add(modifyIssue); |
| | | } |
| | | return issue; |
| | | } else { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.API_ISSUE_NOT_EXIST)); |
| | | } |
| | | } |
| | | |
| | | // 이슈를 수정한다. |
| | |
| | | // 담당자 유효성 체크 |
| | | //this.verifyIssueAssignee(project, issueForm); |
| | | // 담당부서 유효성 체크 |
| | | this.verifyIssueDepartment(project, issueForm); |
| | | //this.verifyIssueDepartment(project, issueForm); |
| | | |
| | | CheckIssueData checkIssueData = new CheckIssueData(); |
| | | checkIssueData.setIssue(issue); |
| | |
| | | this.issueHistoryService.detectIssueStatus(issue, issueForm, detectIssueChange, oldIssueStatus, issueStatus); |
| | | } |
| | | |
| | | // db에 저장 |
| | | issue = this.saveIssue(issueForm, checkIssueData); |
| | | |
| | | // 이슈 이력 등록 |
| | |
| | | //hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.ASSIGNEE, issueVo, issueUserVos); |
| | | // 담당자가 없으면 모든 사용자가 수정 권한을 갖는다. |
| | | |
| | | hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.ALL_ISSUE_MANAGER, issueVo, null, null, user); |
| | | hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.ALL_PROJECT_MANAGER, issueVo, null, null, user); |
| | | |
| | | return hasPermission; |
| | | } |
| | | |
| | |
| | | List<Issue> removeIssues = Lists.newArrayList(); |
| | | |
| | | for (Long issueId : issueForm.getRemoveIds()) { |
| | | //하위이슈 체크 |
| | | List<Issue> downIssues = this.issueRepository.findByParentIssueId(issueId); |
| | | if(downIssues != null && downIssues.size() > 0){ |
| | | for(Issue downIssue : downIssues){ |
| | | if(downIssue.getParentIssue() != null){ |
| | | downIssue.setParentIssue(null); |
| | | } |
| | | } |
| | | } |
| | | |
| | | Issue issue = this.issueRemoves(issueId, user); |
| | | removeIssues.add(issue); |
| | | } |
| | | |
| | | if (removeIssues.size() > 0) { |
| | | //this.issueRepository.deleteAll(removeIssues); |
| | | } |
| | | /*if (removeIssues.size() > 0) { |
| | | this.issueRepository.deleteAll(removeIssues); |
| | | }*/ |
| | | |
| | | // 사용자 시스템 기능 사용 정보 수집 |
| | | log.info(ElasticSearchUtil.makeUserActiveHistoryMessage(this.webAppUtil.getLoginUser(), ElasticSearchConstants.ISSUE_REMOVE)); |
| | | } |
| | | |
| | | // 이슈를 삭제한다. |
| | | @Override |
| | | @Transactional |
| | | public void removeAllIssues(IssueForm issueForm) { |
| | | // 사용하고 있는 업무 공간이 활성 상태인지 확인한다. 사용 공간에서 로그인한 사용자가 비활성인지 확인한다. |
| | | User user = this.webAppUtil.getLoginUserObject(); |
| | | this.workspaceService.checkUseWorkspace(); |
| | | |
| | | if (issueForm.getRemoveIds().size() < 1) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.ISSUE_REMOVE_NOT_SELECT)); |
| | | } |
| | | |
| | | List<Issue> removeIssues = Lists.newArrayList(); |
| | | |
| | | for (Long issueId : issueForm.getRemoveIds()) { |
| | | //하위이슈 체크 |
| | | List<Issue> downIssues = this.issueRepository.findByParentIssueId(issueId); |
| | | if(downIssues != null && downIssues.size() > 0){ |
| | | for(Issue downIssue : downIssues){ |
| | | Long downIssueId = downIssue.getId(); |
| | | downIssue = this.issueRemoves(downIssueId, user); |
| | | removeIssues.add(downIssue); |
| | | } |
| | | } |
| | | Issue issue = this.issueRemoves(issueId, user); |
| | | removeIssues.add(issue); |
| | | } |
| | | // 사용자 시스템 기능 사용 정보 수집 |
| | | log.info(ElasticSearchUtil.makeUserActiveHistoryMessage(this.webAppUtil.getLoginUser(), ElasticSearchConstants.ISSUE_REMOVE)); |
| | | } |
| | | |
| | | // 하위이슈를 삭제한다. |
| | | @Override |
| | | @Transactional |
| | | public void removeDownIssues(IssueForm issueForm) { |
| | | // 사용하고 있는 업무 공간이 활성 상태인지 확인한다. 사용 공간에서 로그인한 사용자가 비활성인지 확인한다. |
| | | User user = this.webAppUtil.getLoginUserObject(); |
| | | this.workspaceService.checkUseWorkspace(); |
| | | |
| | | if (issueForm.getRemoveIds().size() < 1) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.ISSUE_REMOVE_NOT_SELECT)); |
| | | } |
| | | |
| | | List<Issue> removeIssues = Lists.newArrayList(); |
| | | Long downIssueId = 0L; |
| | | for (Long issueId : issueForm.getRemoveIds()) { |
| | | //삭제 할 이슈의 하위이슈 체크 |
| | | List<Issue> downIssues = this.issueRepository.findByParentIssueId(issueId); |
| | | if(downIssues != null && downIssues.size() > 0){ |
| | | for(Issue downIssue : downIssues){ |
| | | downIssueId = downIssue.getId(); |
| | | } |
| | | } |
| | | Issue issue = this.issueRemoves(downIssueId, user); |
| | | removeIssues.add(issue); |
| | | } |
| | | // 사용자 시스템 기능 사용 정보 수집 |
| | | log.info(ElasticSearchUtil.makeUserActiveHistoryMessage(this.webAppUtil.getLoginUser(), ElasticSearchConstants.ISSUE_REMOVE)); |
| | | } |
| | | |
| | | private Issue issueRemoves(Long issueId, User user) { |
| | | Issue issue = this.getIssue(issueId); |
| | | Issue issue = null; |
| | | if(issueId != null){ |
| | | issue = this.getIssue(issueId); |
| | | } |
| | | // 이슈 수정 권한을 갖고 있는지 확인 |
| | | this.verifyIssueModifyPermission(issue, user); |
| | | |
| | |
| | | this.attachedFileService.removeAttachedFiles(attachedFileIds); |
| | | } |
| | | |
| | | // 지울 이슈가 연관이슈인지 체크 후 연관이슈 테이블에서도 삭제한다. |
| | | List<IssueRelation> issueRelationList = this.issueRelationRepository.findByRelationIssueId(issueId); |
| | | if (issueRelationList != null && issueRelationList.size() > 0) { |
| | | for(IssueRelation issueRelation : issueRelationList){ |
| | | StringBuilder sb = new StringBuilder(); |
| | | issueHistoryService.detectRelationIssue(IssueHistoryType.DELETE, issueRelation, sb); |
| | | issueHistoryService.addIssueHistory(issueRelation.getIssue(), IssueHistoryType.MODIFY, sb.toString()); |
| | | this.issueRelationRepository.delete(issueRelation); |
| | | } |
| | | } |
| | | |
| | | // 이슈 생성, 삭제시 예약 이메일에 등록해놓는다. |
| | | this.reservationIssueEmail(issue, EmailType.ISSUE_REMOVE); |
| | | // 이슈 삭제 |