| | |
| | | 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 IssueRelationService issueRelationService; |
| | | |
| | | @Autowired |
| | | private IssueRelationRepository issueRelationRepository; |
| | | |
| | | @Autowired |
| | | private ExcelView excelView; |
| | | |
| | | @Autowired |
| | |
| | | |
| | | @Autowired |
| | | private SimpMessagingTemplate simpMessagingTemplate; |
| | | |
| | | @Autowired |
| | | private UserDepartmentRepository userDepartmentRepository; |
| | | |
| | | @Autowired |
| | | private WorkflowDepartmentRepository workflowDepartmentRepository; |
| | | |
| | | @Override |
| | | protected JpaRepository<Issue, Long> getRepository() { |
| | |
| | | issueForm.setSeverityId(issueApiDefault.getSeverity().getId()); |
| | | } |
| | | |
| | | // 중복 값 하위 이슈로 처리하기 |
| | | // 중복 값 상위 이슈의 하위 이슈로 처리하기 |
| | | CustomFieldApiOverlapForm customFieldApiOverlapForm = new CustomFieldApiOverlapForm(); |
| | | customFieldApiOverlapForm.setUserId(user.getId()); |
| | | customFieldApiOverlapForm.setIssueTypeId(issueForm.getIssueTypeId()); |
| | |
| | | return issues; |
| | | } |
| | | |
| | | // 상위 이슈 가져오기 |
| | | private IssueVo getParentIssueVo(Long parentIssueId) { |
| | | if (parentIssueId != null) { |
| | | Issue parentIssue = this.getIssue(parentIssueId); |
| | | return ConvertUtil.copyProperties(parentIssue, IssueVo.class); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | // 중복된 상위 이슈 검색 |
| | | private List<IssueVo> findIssue(IssueApiForm issueApiForm, List<CustomFieldApiOverlap> customFieldApiOverlaps, Long userId) { |
| | | |
| | | List<IssueVo> resultIssueVos = new ArrayList<>(); |
| | | |
| | | if (customFieldApiOverlaps != null && customFieldApiOverlaps.size() > 0) { |
| | | for (CustomFieldApiOverlap customFieldApiOverlap : customFieldApiOverlaps) { |
| | | for (IssueCustomFieldValueForm issueCustomFieldValue : issueApiForm.getIssueCustomFieldValues()) { |
| | | IssueCustomFieldValueCondition issueCustomFieldValueCondition = new IssueCustomFieldValueCondition(); |
| | | issueCustomFieldValueCondition.setUseParentIssueId(true); |
| | | if (customFieldApiOverlap.getCustomField().getId().equals(issueCustomFieldValue.getCustomFieldId())) { |
| | | issueCustomFieldValueCondition.setUseValue(issueCustomFieldValue.getUseValue()); |
| | | |
| | |
| | | // 날짜 유효성 체크 |
| | | this.checkStartCompleteDate(issueForm.getStartDate(), issueForm.getCompleteDate()); |
| | | // 담당 부서 유효성 체크 |
| | | this.verifyIssueDepartment(project, issueForm); |
| | | //this.verifyIssueDepartment(project, issueForm); |
| | | |
| | | // 이슈 상태 유형이 '대기' 인 이슈 상태 가져오기 |
| | | IssueStatus issueStatus = this.issueStatusService.findByIssueStatusTypeIsReady(issueType.getWorkflow()); |
| | |
| | | // 날짜 유효성 체크 |
| | | this.checkStartCompleteDate(issueForm.getStartDate(), issueForm.getCompleteDate()); |
| | | // 담당 부서 유효성 체크 |
| | | this.verifyIssueDepartment(project, issueForm); |
| | | //this.verifyIssueDepartment(project, issueForm); |
| | | |
| | | // 이슈 상태 유형이 '대기' 인 이슈 상태 가져오기 |
| | | IssueStatus issueStatus = this.issueStatusService.findByIssueStatusTypeIsReady(issueType.getWorkflow()); |
| | |
| | | } |
| | | } |
| | | |
| | | 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; |
| | | |
| | | if (this.userWorkspaceService.checkWorkspaceManager(user)) { |
| | | 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(); |
| | |
| | | // 이슈 아이디 초기화 |
| | | 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) { |
| | |
| | | @Override |
| | | @Transactional |
| | | public List<IssueVo> findIssue(IssueApiForm issueApiform) { |
| | | |
| | | List<IssueCustomFieldValueForm> issueCustomFieldValueForms = issueApiform.getIssueCustomFieldValues(); |
| | | List<IssueVo> resultIssueVos = new ArrayList<>(); |
| | | |
| | | IssueCustomFieldValueCondition issueCustomFieldValueCondition = new IssueCustomFieldValueCondition(); |
| | | issueCustomFieldValueCondition.setUseParentIssueId(false); |
| | | if (issueCustomFieldValueForms.size() > 0) { |
| | | for (IssueCustomFieldValueForm issueCustomFieldValueForm : issueCustomFieldValueForms) { |
| | | |
| | | CustomField customField = this.customFieldService.getCustomField(issueCustomFieldValueForm.getCustomFieldId()); |
| | | CustomFieldType customFieldType = CustomFieldType.DATETIME; |
| | | if (customFieldType.equals(customField.getCustomFieldType())) { |
| | | continue; |
| | | } |
| | | // issueCustomFieldValueCondition.addUseValue(issueCustomFieldValueForm.getUseValue()); |
| | | issueCustomFieldValueCondition.setUseValue(issueCustomFieldValueForm.getUseValue()); |
| | | List<Map<String, Object>> results = this.issueMapper.findByCustomFieldValue(issueCustomFieldValueCondition); |
| | |
| | | resultIssueVos.clear(); |
| | | for (Map<String, Object> result : results) { |
| | | IssueVo issueVo = ConvertUtil.convertMapToClass(result, IssueVo.class); |
| | | |
| | | issueVo.setParentIssueVo(this.getParentIssueVo(MapUtil.getLong(result, "parentIssueId"))); |
| | | |
| | | if (findIssueVos.size() == 0) { |
| | | resultIssueVos.add(issueVo); |
| | |
| | | } |
| | | |
| | | |
| | | // 하위 이슈가 모두 종료 처리 되었을 경우 상위이슈도 완료 처리 |
| | | private void setParentIssueComplete(Issue parentIssue) { |
| | | if (parentIssue != null) { |
| | | this.issueMapper.findNotCompleteByParentIssueId(parentIssue.getId()); |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | // 이슈를 수정한다(api용) |
| | | @Override |
| | | @Transactional |
| | |
| | | if (issueVos != null && issueVos.size() > 0) { |
| | | List<Issue> issue = Lists.newArrayList(); |
| | | for (IssueVo issueVo : issueVos) { |
| | | IssueVo parentIssueVo = issueVo.getParentIssueVo(); |
| | | issueForm.setId(issueVo.getId()); |
| | | issue.add(this.modifyIssueForApi(user, issueForm, files)); |
| | | |
| | | // 자동 종료 상태 설정이 되어 있지 않으면 오류발생 |
| | | 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) { |
| | | List<Map<String, Object>> results = this.issueMapper.findNotCompleteByParentIssueId(parentIssue.getId()); |
| | | // 하위 일감이 모두 종료 상태일때 상위 일감도 종료 처리 |
| | | if (results == null || results.size() == 0) { |
| | | parentIssue.setIssueStatus(issueType.getIssueStatus()); |
| | | } |
| | | } |
| | | |
| | | issue.add(modifyIssue); |
| | | } |
| | | return issue; |
| | | } else { |
| | |
| | | // 담당자 유효성 체크 |
| | | //this.verifyIssueAssignee(project, issueForm); |
| | | // 담당부서 유효성 체크 |
| | | this.verifyIssueDepartment(project, issueForm); |
| | | //this.verifyIssueDepartment(project, issueForm); |
| | | |
| | | CheckIssueData checkIssueData = new CheckIssueData(); |
| | | checkIssueData.setIssue(issue); |
| | |
| | | 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); |
| | | // 이슈 삭제 |