From 2c273d1072424a9363314fb258265cbf487f0297 Mon Sep 17 00:00:00 2001 From: 이민희 <mhlee@maprex.co.kr> Date: 목, 16 12월 2021 17:48:46 +0900 Subject: [PATCH] - Excel Import 기능 담당부서도 들어가게 하기(기간 미지정 시에도 가능하도록 수정) - 이슈 통합검색 키워드에 업체,ISP,호스팅 정보도 포함 - 프로젝트에서 설정한 이슈유형만 보여주기 --- src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java | 226 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 208 insertions(+), 18 deletions(-) diff --git a/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java b/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java index c2d6601..549ac90 100644 --- a/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java +++ b/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java @@ -82,6 +82,15 @@ private ApiTokenService apiTokenService; @Autowired + private CompanyFieldService companyFieldService; + + @Autowired + private IspFieldService ispFieldService; + + @Autowired + private HostingFieldService hostingFieldService; + + @Autowired private CommonConfiguration configuration; @Autowired @@ -202,6 +211,15 @@ this.issueVersionService.addIssueVersion(issue); } + @Override + @Transactional + public void addIssueVersion(Long id, Long userId) { + Issue issue = this.getIssue(id); + User user = this.userService.getUser(userId); + // �씠�뒋 踰꾩쟾 �깮�꽦 + this.issueVersionService.addIssueVersion(issue, user); + } + private IssueForm convertToIssueForm(IssueApiForm issueApiForm, User user) { if (issueApiForm.getIssueTypeId() == null) { @@ -282,6 +300,8 @@ // �궗�슜�옄 �젙�쓽 �븘�뱶 �꽕�젙 issueForm.setIssueCustomFields(issueApiForm.getCustomFieldValues()); + // 媛숈� �룄硫붿씤 �뾽泥� 李얘린 + this.findCompanyField(issueForm); // api �엯�젰媛� �쟻�슜 ConvertUtil.copyProperties(issueApiForm, issueForm); @@ -290,6 +310,51 @@ } else { throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.API_USER_ERROR)); + } + } + + private void findCompanyField(IssueForm issueForm) { + if(issueForm.getIssueCustomFields() != null && issueForm.getIssueCustomFields().size() > 0) { + CompanyFieldCondition condition = new CompanyFieldCondition(); + List<Map<String, Object>> companyFields = this.companyFieldService.find(condition); + List<Map<String, Object>> issueCompanyFields = Lists.newArrayList(); + List<Map<String, Object>> issueIspFields = Lists.newArrayList(); + List<Map<String, Object>> issueHostingFields = Lists.newArrayList(); + + for (Map<String, Object> issueCustomField : issueForm.getIssueCustomFields()) { + int customFieldId = (Integer) issueCustomField.get("customFieldId"); + Long customId = (long) customFieldId; + CustomField customField = this.customFieldService.getCustomField(customId); + if(customField != null && customField.getCustomFieldType().toString().equals("SITE") && customField.getName().equals("�룄硫붿씤")) { + String useValue = issueCustomField.get("useValue").toString(); + if(companyFields != null && companyFields.size() > 0) { + for (Map<String, Object> companyField : companyFields) { + CompanyFieldVo companyFieldVo = ConvertUtil.convertMapToClass(companyField, CompanyFieldVo.class); + if(useValue.equals(companyFieldVo.getUrl())) { + companyField.put("companyId", companyField.get("id")); + issueCompanyFields.add(companyField); + if(companyFieldVo.getIspId() != null) { + Map<String, Object> ispField = this.ispFieldService.find(companyFieldVo.getIspId()); + if (ispField != null) { + ispField.put("ispId", ispField.get("id")); + issueIspFields.add(ispField); + } + } + if(companyFieldVo.getHostingId() != null) { + Map<String, Object> hostingField = this.hostingFieldService.find(companyFieldVo.getHostingId()); + if (hostingField != null) { + hostingField.put("hostingId", hostingField.get("id")); + issueHostingFields.add(hostingField); + } + } + } + } + } + } + issueForm.setIssueCompanyFields(issueCompanyFields); + issueForm.setIssueIspFields(issueIspFields); + issueForm.setIssueHostingFields(issueHostingFields); + } } } @@ -465,6 +530,91 @@ public Issue addRelIssue(IssueForm issueForm, List<MultipartFile> multipartFiles) { User user = this.webAppUtil.getLoginUserObject(); return addRelIssue(user, issueForm, multipartFiles); + } + + // �븯�쐞�씠�뒋瑜� �깮�꽦�븳�떎. + @Override + @Transactional + public Issue addDownIssue(IssueForm issueForm, List<MultipartFile> multipartFiles) { + User user = this.webAppUtil.getLoginUserObject(); + return addDownIssue(user, issueForm, multipartFiles); + } + + // �븯�쐞�씠�뒋瑜� �깮�꽦�븳�떎. + @Override + @Transactional + public Issue addDownIssue(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 媛앹껜濡� 蹂�寃쏀븳�떎. + 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; } // �뿰愿��씠�뒋瑜� �깮�꽦�븳�떎. @@ -2091,6 +2241,19 @@ this.verifyIssueModifyPermission(issue, user); IssueStatus issueStatus = this.issueStatusService.getIssueStatus(issueForm.getIssueStatusId()); + + if (issueStatus.getIssueStatusType().toString().equals("CLOSE")) { + List<String> downIssuesStatus = issueForm.getDownIssuesStatus(); + if (downIssuesStatus != null && downIssuesStatus.size() > 0) { + for (String downIssueStatus : downIssuesStatus) { + if (!downIssueStatus.equals("CLOSE")) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.ISSUE_NOT_MODIFY_STATUS)); + } + } + } + } + // �씠�뒋 �긽�깭瑜� 蹂�寃쏀븷 �븣 �꽑�깮�븳 �씠�뒋 �긽�깭濡� 蹂�寃쏀븷 �닔 �엳�뒗吏� �솗�씤�븳�떎. this.issueStatusService.checkNextIssueStatus(issue, issueStatus); // 蹂�寃� �씠�젰 �젙蹂� 異붿텧 @@ -2728,7 +2891,7 @@ Map<String, Priority> priorityMaps = new HashMap<>(); // �슦�꽑 �닚�쐞 紐⑥쓬 Map<String, Severity> severityMaps = new HashMap<>(); // 以묒슂�룄 紐⑥쓬 Map<String, Object> userMaps = new HashMap<>(); // �궗�슜�옄 紐⑥쓬 - Map<String, Object> departmentMaps = new HashMap<>(); // 遺��꽌 紐⑥쓬 + Map<String, DepartmentVo> departmentMaps = new HashMap<>(); // 遺��꽌 紐⑥쓬 Map<String, CustomField> customFieldMaps = new HashMap<>(); Map<String, IssueStatus> issueStatusReadyMaps = new HashMap<>(); // �긽�깭 �냽�꽦 '��湲�'�씤 �씠�뒋 �긽�깭 Map<Long, Long> issueNumberMaps = new HashMap<>(); // �씠�뒋 踰덊샇 紐⑥쓬 @@ -2778,7 +2941,7 @@ // 1踰� �뿤�뜑遺��꽣 �뜲�씠�꽣 �쁺�뿭 if (rowIndex > 1) { // �씠�뒋濡� �벑濡앺븯湲� �쐞�빐 IssueForm �뿉 �뜲�씠�꽣瑜� �뀑�똿�븳�떎. - issueForms.add(this.setIssueFormToExcelField(row, (rowIndex + 1), issueStatusReadyMaps, projectMaps, issueTypeMaps, priorityMaps, severityMaps, userMaps, customFieldMaps, issueNumberMaps, headers)); + issueForms.add(this.setIssueFormToExcelField(row, (rowIndex + 1), issueStatusReadyMaps, projectMaps, issueTypeMaps, priorityMaps, severityMaps, userMaps, departmentMaps, customFieldMaps, issueNumberMaps, headers)); } } @@ -2929,7 +3092,7 @@ // �씠�뒋�쓽 二쇱슂 �냽�꽦�쓣 map �뿉 ���옣�븯�뿬 �뿊�� import �뿉�꽌 吏��젙�븳 ���긽(�씠�뒋 �냽�꽦)�쓣 鍮좊Ⅴ寃� 李얠쓣 �닔 �엳寃� �븳�떎. private void IssueAttributeMapToList(Map<String, Project> projectMaps, Map<String, IssueType> issueTypeMaps, Map<String, Priority> priorityMaps, Map<String, Severity> severityMaps, - Map<String, Object> userMaps, Map<String, Object> departmentMaps, Map<String, CustomField> customFieldMaps, Map<Long, Long> issueNumberMaps, Map<String, Long> issueTypeCustomFieldMaps, Map<String, IssueStatus> issueStatusReadyMaps) { + Map<String, Object> userMaps, Map<String, DepartmentVo> departmentMaps, Map<String, CustomField> customFieldMaps, Map<Long, Long> issueNumberMaps, Map<String, Long> issueTypeCustomFieldMaps, Map<String, IssueStatus> issueStatusReadyMaps) { // �봽濡쒖젥�듃 �궎濡� 諛붾줈 李얠쓣 �닔 �엳寃� 以�鍮� List<Project> projects = this.projectService.findByWorkspaceId(); List<Long> projectIds = Lists.newArrayList(); @@ -2953,16 +3116,7 @@ for (Map<String, Object> user : users) { userMap.put(CommonUtil.decryptAES128(MapUtil.getString(user, "account")), MapUtil.getLong(user, "userId")); } - userMaps.put(project.getProjectKey(), userMap); - - // �봽濡쒖젥�듃�뿉 李몄뿬�븯�뒗 遺��꽌 �젙蹂� - List<Map<String, Object>> departments = this.departmentService.findProjectDepartment(project); - List<Long> departmentList = Lists.newArrayList(); - // 遺��꽌 �젙蹂대�� ���옣 - for (Map<String, Object> department : departments) { - departmentList.add(MapUtil.getLong(department, "departmentId")); - } } // �씠�뒋 �쑀�삎�쓣 諛붾줈 李얠쓣 �닔 �엳寃� 以�鍮� @@ -2972,6 +3126,13 @@ IssueStatus issueStatus = this.issueStatusService.findByIssueStatusTypeIsReady(issueType.getWorkflow()); issueStatusReadyMaps.put(issueType.getId().toString(), issueStatus); + + // �썙�겕�뵆濡쒖슦�뿉 �냽�빐�엳�뒗 遺��꽌 �젙蹂� + List<DepartmentVo> departments = this.departmentService.findWorkflowDepartment(issueType.getId()); + // 遺��꽌 �젙蹂대�� ���옣 + for (DepartmentVo department : departments) { + departmentMaps.put(department.getDepartmentName(), department); + } } // �슦�꽑�닚�쐞瑜� 諛붾줈 李얠쓣 �닔 �엳寃� 以�鍮� @@ -2995,7 +3156,7 @@ // �뿊�� �븘�뱶�뿉 �엳�뒗 �젙蹂대�� �씠�뒋 form �쑝濡� �삷湲대떎. private IssueForm setIssueFormToExcelField(Row row, int rowIndex, Map<String, IssueStatus> issueStatusReadyMaps, Map<String, Project> projectMaps, Map<String, IssueType> issueTypeMaps, Map<String, - Priority> priorityMaps, Map<String, Severity> severityMaps, Map<String, Object> userMaps, Map<String, CustomField> customFieldMaps, Map<Long, Long> issueNumberMaps, List<String> headers) { + Priority> priorityMaps, Map<String, Severity> severityMaps, Map<String, Object> userMaps, Map<String, DepartmentVo> departmentMaps, Map<String, CustomField> customFieldMaps, Map<Long, Long> issueNumberMaps, List<String> headers) { IssueForm issueForm = new IssueForm(); issueForm.setRegisterId(this.webAppUtil.getLoginId()); Project project = null; @@ -3039,9 +3200,13 @@ // 以묒슂�룄瑜� IssueForm �뿉 ���옣�븳�떎. this.setIssueFormSeverity(cell, severityMaps, issueForm, rowIndex); break; + /*case 6: + // �떞�떦�옄瑜� IssueForm �뿉 ���옣�븳�떎. + this.setIssueFormAssignee(cell, userMaps, issueForm, project); + break;*/ case 6: // �떞�떦遺��꽌瑜� IssueForm �뿉 ���옣�븳�떎. - this.setIssueFormAssignee(cell, userMaps, issueForm, project); + this.setIssueFormDepartment(cell, departmentMaps, issueForm, project); break; case 7: // �떆�옉�씪�쓣 IssueForm �뿉 ���옣�븳�떎. @@ -3052,7 +3217,7 @@ this.setIssueFormPeriod(cell, issueForm, false, rowIndex); break; default: - // 8踰� �씠�긽遺��꽣�뒗 �궗�슜�옄 �젙�쓽 �븘�뱶. �궗�슜�옄 �젙�쓽 �븘�뱶 �젙蹂대�� IssueForm �뿉 ���옣�븳�떎. + // 9踰� 遺��꽣�뒗 �궗�슜�옄 �젙�쓽 �븘�뱶. �궗�슜�옄 �젙�쓽 �븘�뱶 �젙蹂대�� IssueForm �뿉 ���옣�븳�떎. this.setIssueFormCustomFieldValue(cell, customFieldMaps, issueForm, headers.get(cellIndex), rowIndex); } } @@ -3181,20 +3346,39 @@ issueForm.setSeverityId(severity.getId()); } - // �떞�떦遺��꽌瑜� IssueForm �뿉 ���옣�븳�떎. private void setIssueFormAssignee(Cell cell, Map<String, Object> userMaps, IssueForm issueForm, Project project) { if (cell != null) { String[] splitAssignee = CommonUtil.convertExcelStringToCell(cell).split("#"); Map<String, Object> userMap = (Map<String, Object>) MapUtil.getObject(userMaps, project.getProjectKey()); - List<Long> departmentIds = Lists.newArrayList(); + List<Long> userIds = Lists.newArrayList(); for (String account : splitAssignee) { if (MapUtil.getLong(userMap, account) != null) { - departmentIds.add(MapUtil.getLong(userMap, account)); + userIds.add(MapUtil.getLong(userMap, account)); } } + issueForm.setUserIds(userIds); + } + } + // �떞�떦遺��꽌瑜� IssueForm �뿉 ���옣�븳�떎. + private void setIssueFormDepartment(Cell cell, Map<String, DepartmentVo> departmentMaps, IssueForm issueForm, Project project) { + if (cell != null) { + String[] splitDepartment = CommonUtil.convertExcelStringToCell(cell).split("#"); + + // 媛믪씠 怨듬갚�씠硫� 以묒� + String cellValue = CommonUtil.convertExcelStringToCell(cell); + if (StringUtils.isEmpty(cellValue)) { + return; + } + + List<Long> departmentIds = Lists.newArrayList(); + + for (String department : splitDepartment) { + DepartmentVo departmentVo = departmentMaps.get(department); + departmentIds.add(departmentVo.getId()); + } issueForm.setDepartmentIds(departmentIds); } } @@ -3203,6 +3387,12 @@ private void setIssueFormPeriod(Cell cell, IssueForm issueForm, Boolean checkStartDate, int rowIndex) { if (cell != null && !cell.toString().equals("")) { + // 媛믪씠 怨듬갚�씠硫� 以묒� + String cellValue = CommonUtil.convertExcelStringToCell(cell); + if (StringUtils.isEmpty(cellValue)) { + return; + } + Date startDate; try { -- Gitblit v1.8.0