| | |
| | | import kr.wisestone.owl.util.*; |
| | | import kr.wisestone.owl.util.DateUtil; |
| | | import kr.wisestone.owl.vo.*; |
| | | import kr.wisestone.owl.web.condition.IssueCondition; |
| | | import kr.wisestone.owl.web.condition.IssueCustomFieldValueCondition; |
| | | import kr.wisestone.owl.web.condition.IssueTypeCustomFieldCondition; |
| | | import kr.wisestone.owl.web.condition.ProjectCondition; |
| | | import kr.wisestone.owl.web.condition.*; |
| | | import kr.wisestone.owl.web.form.*; |
| | | import kr.wisestone.owl.web.view.ExcelView; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | private UserWorkspaceService userWorkspaceService; |
| | | |
| | | @Autowired |
| | | private WorkflowDepartmentService workflowDepartmentService; |
| | | |
| | | @Autowired |
| | | private IssueRelationService issueRelationService; |
| | | |
| | | @Autowired |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | // API 를 통해 이슈 추가. |
| | | @Override |
| | | @Transactional |
| | | public Issue addApiIssue(IssueApiForm issueApiForm) { |
| | | private IssueForm convertToIssueForm(IssueApiForm issueApiForm, User user) { |
| | | if (issueApiForm.getIssueTypeId() == null) { |
| | | throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.API_PARAMETER_ISSUE_TYPE_ERROR)); |
| | | } |
| | |
| | | throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.API_PARAMETER_ISSUE_TYPE_ERROR)); |
| | | } |
| | | |
| | | Workflow workflow = issueType.getWorkflow(); |
| | | |
| | | // 이슈 상태가 지정되어 있지 않을 경우 초기값으로 지정 |
| | | if (issueApiForm.getIssueStatusId() == null) { |
| | | List<IssueStatusVo> issueStatusVos = issueStatusService.findByWorkflowId(workflow.getId()); |
| | | IssueStatusVo issueStatusVo = issueStatusVos.get(0); |
| | | issueApiForm.setIssueStatusId(issueStatusVo.getId()); |
| | | } |
| | | |
| | | // 워크플로우 상태에 따른 담당부서 가져오기 |
| | | if (issueApiForm.getIssueStatusId() != null) { |
| | | WorkflowDepartmentCondition workflowDepartmentCondition = new WorkflowDepartmentCondition(); |
| | | workflowDepartmentCondition.setIssueStatusId(issueApiForm.getIssueStatusId()); |
| | | workflowDepartmentCondition.setWorkflowId(workflow.getId()); |
| | | List<WorkflowDepartmentVo> workflowDepartmentVos = this.workflowDepartmentService.find(workflowDepartmentCondition); |
| | | |
| | | for (WorkflowDepartmentVo workflowDepartmentVo : workflowDepartmentVos) { |
| | | issueForm.addDepartmentId(workflowDepartmentVo.getDepartmentVo().getId()); |
| | | } |
| | | } |
| | | |
| | | |
| | | // 프로젝트 입력 |
| | | Project project = issueType.getProject(); |
| | | if (project == null){ |
| | |
| | | } |
| | | issueForm.setProjectId(project.getId()); |
| | | |
| | | // 토큰으로 유저 정보 가져오기 |
| | | String token = issueApiForm.getToken(); |
| | | UserVo userVo = this.apiTokenService.certification(token); |
| | | |
| | | // 해당 유저 정보가 현재 db에 있는지 확인 |
| | | User user = this.userService.getUser(userVo.getId()); |
| | | if (user != null) { |
| | | |
| | | // 기본값 입력하기 |
| | | IssueApiDefaultForm issueApiDefaultForm = new IssueApiDefaultForm(); |
| | | issueApiDefaultForm.setUserId(user.getId()); |
| | |
| | | IssueApiDefault issueApiDefault = this.issueApiDefaultService.find(issueApiDefaultForm); |
| | | if (issueApiDefault != null) { |
| | | ConvertUtil.copyProperties(issueApiDefault, issueForm); |
| | | issueForm.setId(null); |
| | | issueForm.setPriorityId(issueApiDefault.getPriority().getId()); |
| | | issueForm.setSeverityId(issueApiDefault.getSeverity().getId()); |
| | | } |
| | |
| | | // api 입력값 적용 |
| | | ConvertUtil.copyProperties(issueApiForm, issueForm); |
| | | |
| | | return addIssue(user, issueForm, issueApiForm.getMultipartFiles()); |
| | | return issueForm; |
| | | |
| | | } else { |
| | | throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.API_USER_ERROR)); |
| | | } |
| | | } |
| | | |
| | | private User convertToUser(String token) { |
| | | // 토큰으로 유저 정보 가져오기 |
| | | UserVo userVo = this.apiTokenService.certification(token); |
| | | |
| | | // 해당 유저 정보가 현재 db에 있는지 확인 |
| | | return this.userService.getUser(userVo.getId()); |
| | | } |
| | | |
| | | |
| | | // API 를 통해 이슈 추가. |
| | | @Override |
| | | @Transactional |
| | | public Issue addApiIssue(IssueApiForm issueApiForm) { |
| | | User user = convertToUser(issueApiForm.getToken()); |
| | | IssueForm issueForm = this.convertToIssueForm(issueApiForm, user); |
| | | |
| | | return addIssue(user, issueForm, issueApiForm.getMultipartFiles()); |
| | | } |
| | | |
| | | |
| | | |
| | | // 중복된 상위 이슈 검색 |
| | | private IssueVo findIssue(IssueApiForm issueApiForm, Long userId) { |
| | |
| | | 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)); // 각 프로젝트의 고유 이슈 번호 생성 |
| | | |
| | |
| | | // 담당자 지정 |
| | | //this.issueUserService.modifyIssueUser(issue, project.getWorkspace(), issueForm.getUserIds()); |
| | | // 담당부서 지정 |
| | | this.issueDepartmentService.modifyIssueDepartment(issue, project.getWorkspace(), issueForm.getDepartmentIds()); |
| | | this.issueDepartmentService.modifyIssueDepartment(issue, user, project.getWorkspace(), issueForm.getDepartmentIds()); |
| | | // 업체 정보 저장 |
| | | this.issueCompanyService.modifyIssueCompanyField(issue, issueForm.getIssueCompanyFields()); |
| | | // ISP 정보 저장 |
| | |
| | | } |
| | | |
| | | private void setCountDownIssues(List<Map<String, Object>> results, List<IssueVo> issueVos) { |
| | | int downIssueCount = 0; |
| | | for (Map<String, Object> result : results){ |
| | | List<Issue> downIssues = this.issueRepository.findByParentIssueId((Long) result.get("id")); //하위이슈 가져오기 |
| | | if(downIssues != null && downIssues.size() > 0){ //상위이슈 가지고 있는 애들이 있으면 |
| | | for(Issue downIssue : downIssues){ |
| | | downIssueCount ++; |
| | | Long parentIssueId = downIssue.getParentIssue().getId(); |
| | | int downIssueCount = 1; |
| | | Issue parentIssue = this.getIssue(parentIssueId); |
| | | IssueVo parentIssueVo = ConvertUtil.copyProperties(parentIssue, IssueVo.class); |
| | | parentIssueVo.setDownIssueCount(downIssueCount); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // 이슈 목록을 조회한다(차트용 - 연관일감포함) |
| | | @Override |
| | | @Transactional(readOnly = true) |
| | | public void findApiIssue(ApiMonitorCondition apiMonitorCondition, Map<String, Object> resJsonData) { |
| | | |
| | | IssueTypeCondition issueTypeCondition = new IssueTypeCondition(); |
| | | List<IssueTypeVo> issueTypes = this.issueTypeService.findIssueType(issueTypeCondition); |
| | | |
| | | // 값이 없을 경우 초기값 입력 |
| | | if (StringUtils.isEmpty(apiMonitorCondition.getSearchPeriod())) { |
| | | apiMonitorCondition.setSearchPeriod(DateUtil.LAST_SEVEN_DAYS); |
| | | } |
| | | |
| | | // 검색 일자를 구한다. |
| | | List<Date> searchDates = CommonUtil.findSearchPeriod(apiMonitorCondition.getSearchPeriod()); |
| | | |
| | | // 날짜가 검색되지 않았으면 오류 |
| | | if (searchDates.size() < 1) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.WIDGET_SEARCH_DATE_NOT_FOUND)); |
| | | } |
| | | |
| | | Long index = 1L; |
| | | List<ApiMonitorVo> apiMonitorVos = Lists.newArrayList(); |
| | | for (Date date : searchDates) { |
| | | |
| | | String onlyDate = DateUtil.convertDateToYYYYMMDD(date); |
| | | issueTypeCondition.setStartDate(onlyDate + " 00:00:00"); |
| | | issueTypeCondition.setEndDate(onlyDate + " 23:59:59"); |
| | | |
| | | ApiMonitorVo apiMonitorVo = new ApiMonitorVo(); |
| | | apiMonitorVo.setId(index); |
| | | for (IssueTypeVo issueTypeVo : issueTypes) { |
| | | issueTypeCondition.setId(issueTypeVo.getId()); |
| | | apiMonitorVo.addIssueTypeCount(this.issueMapper.countByIssueTypeIdAndDate(issueTypeCondition)); |
| | | apiMonitorVo.setIsApi(Issue.IS_API_YES); |
| | | |
| | | apiMonitorVos.add(apiMonitorVo); |
| | | } |
| | | index++; |
| | | } |
| | | Map<String, Object> data = new HashMap<>(); |
| | | data.put("issueTypeVos", issueTypes); |
| | | data.put("apiMonitorVos", apiMonitorVos); |
| | | resJsonData.put(Constants.RES_KEY_CONTENTS, data); |
| | | } |
| | | |
| | | |
| | | // 이슈 목록을 조회한다(차트용 - 연관일감포함) |
| | | @Override |
| | |
| | | private void setMapToIssueVo(List<Map<String, Object>> results, List<IssueVo> issueVos, IssueCondition issueCondition) { |
| | | for (Map<String, Object> result : results) { |
| | | IssueVo issueVo = ConvertUtil.convertMapToClass(result, IssueVo.class); |
| | | /*Issue downIssue = this.getIssue((Long) result.get("id")); |
| | | if(downIssue.getParentIssue() != null){ //상위 이슈가 있으면 |
| | | Long parentIssueId = downIssue.getParentIssue().getId(); |
| | | |
| | | int downIssueCount = 1; |
| | | Issue parentIssue = this.getIssue(parentIssueId); |
| | | IssueVo parentIssueVo = ConvertUtil.copyProperties(parentIssue, IssueVo.class); |
| | | parentIssueVo.setDownIssueCount(downIssueCount); |
| | | |
| | | issueVos.add(parentIssueVo); |
| | | }*/ |
| | | issueVos.add(issueVo); |
| | | issueCondition.addIssueIds(String.valueOf(issueVo.getId())); |
| | | } |
| | |
| | | if(downIssues != null && downIssueVos.size()>0){ |
| | | for(IssueVo downIssueVo : downIssueVos){ |
| | | for(Issue downIssue : downIssues){ |
| | | downIssueVo.setTitle(downIssue.getTitle()); |
| | | downIssueVo.setIssueTypeVo(ConvertUtil.copyProperties(downIssue.getIssueType(), IssueTypeVo.class)); |
| | | downIssueVo.setPriorityVo(ConvertUtil.copyProperties(downIssue.getPriority(), PriorityVo.class)); |
| | | downIssueVo.setSeverityVo(ConvertUtil.copyProperties(downIssue.getSeverity(), SeverityVo.class)); |
| | |
| | | issueVo.setIssueHistoryVos(this.issueHistoryService.findIssueHistory(issue.getId())); |
| | | } |
| | | |
| | | // 이슈를 수정한다 |
| | | @Override |
| | | public Issue modifyIssue(IssueApiForm issueApiForm, List<MultipartFile> files) { |
| | | User user = this.convertToUser(issueApiForm.getToken()); |
| | | IssueForm issueForm = this.convertToIssueForm(issueApiForm, user); |
| | | |
| | | return this.modifyIssue(user, issueForm, files); |
| | | } |
| | | |
| | | // 이슈를 수정한다. |
| | | @Override |
| | | @Transactional |
| | | public Issue modifyIssue(IssueForm issueForm, List<MultipartFile> multipartFiles) { |
| | | User user = this.webAppUtil.getLoginUserObject(); |
| | | return modifyIssue(user, issueForm, multipartFiles); |
| | | } |
| | | |
| | | // 이슈를 수정한다. |
| | | @Override |
| | | @Transactional |
| | | public Issue modifyIssue(User user, IssueForm issueForm, List<MultipartFile> multipartFiles) { |
| | | // 사용하고 있는 업무 공간이 활성 상태인지 확인한다. 사용 공간에서 로그인한 사용자가 비활성인지 확인한다. |
| | | this.workspaceService.checkUseWorkspace(); |
| | | this.workspaceService.checkUseWorkspace(user, user.getLastWorkspaceId()); |
| | | // 이슈 수정 권한 체크 |
| | | this.verifyIssueModifyPermission(issueForm.getId()); |
| | | // 프로젝트 유효성 체크 |
| | |
| | | //this.issueUserService.modifyIssueUser(issue, project.getWorkspace(), issueForm.getUserIds()); |
| | | // 담당부서 지정 |
| | | if(issueForm.getDepartmentIds().size()>0){ |
| | | this.issueDepartmentService.modifyIssueDepartment(issue, project.getWorkspace(), issueForm.getDepartmentIds()); |
| | | this.issueDepartmentService.modifyIssueDepartment(issue, user, project.getWorkspace(), issueForm.getDepartmentIds()); |
| | | } |
| | | |
| | | // multipartFile 을 file Map List 객체로 변경한다. |
| | | List<Map<String, Object>> convertFileMaps = this.convertMultipartFileToFile(multipartFiles); |
| | | |
| | | // 첨부 파일 저장 - 비동기로 작동 |
| | | this.attachedFileService.addAttachedFile(convertFileMaps, issue, this.webAppUtil.getLoginUser().getAccount()); |
| | | this.attachedFileService.addAttachedFile(convertFileMaps, issue, user.getAccount()); |
| | | // 삭제된 첨부파일 처리 |
| | | this.attachedFileService.removeAttachedFiles(issueForm.getRemoveFiles()); |
| | | // 텍스트 에디터에 첨부한 파일을 이슈와 연결 |
| | |
| | | this.issueCustomFieldValueService.modifyIssueCustomFieldValue(issue, issueForm.getIssueCustomFields()); |
| | | // 이슈 이력 등록 |
| | | if (!StringUtils.isEmpty(detectIssueChange.toString())) { |
| | | this.issueHistoryService.addIssueHistory(issue, IssueHistoryType.MODIFY, detectIssueChange.toString()); |
| | | this.issueHistoryService.addIssueHistory(issue, user, IssueHistoryType.MODIFY, detectIssueChange.toString()); |
| | | } |
| | | // 사용자 시스템 기능 사용 정보 수집 |
| | | log.info(ElasticSearchUtil.makeUserActiveHistoryMessage(this.webAppUtil.getLoginUser(), ElasticSearchConstants.ISSUE_MODIFY)); |
| | |
| | | resJsonData.put(Constants.RES_KEY_CONTENTS, usePartnerVos); |
| | | } |
| | | } |
| | | } |
| | | } |