From 4ab15ca2bb74d0d33d1325d849422635b9d415b1 Mon Sep 17 00:00:00 2001 From: 이민희 <mhlee@maprex.co.kr> Date: 월, 07 2월 2022 15:31:39 +0900 Subject: [PATCH] 업체 임포트 시 코드 보완 --- src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java | 115 +++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 78 insertions(+), 37 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 765ab69..8e87053 100644 --- a/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java +++ b/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java @@ -356,17 +356,17 @@ if(companyFields != null && companyFields.size() > 0) { for (Map<String, Object> companyField : companyFields) { CompanyFieldVo companyFieldVo = ConvertUtil.convertMapToClass(companyField, CompanyFieldVo.class); - if(useValue.equals(companyFieldVo.getUrl())) { + if(companyFieldVo.getUrl() != null && useValue.equals(companyFieldVo.getUrl())) { companyField.put("companyId", companyField.get("id")); issueCompanyFields.add(companyField); - if(companyFieldVo.getIspId() != null) { + if(companyFieldVo.getIspId() != null && companyFieldVo.getIspId() != -1) { 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) { + if(companyFieldVo.getHostingId() != null && companyFieldVo.getHostingId() != -1) { Map<String, Object> hostingField = this.hostingFieldService.find(companyFieldVo.getHostingId()); if (hostingField != null) { hostingField.put("hostingId", hostingField.get("id")); @@ -3204,37 +3204,46 @@ * @param issueForm IssueForm */ private void setIssuePartners(IssueForm issueForm, Issue issue) { + IssueCompany issueCompany = new IssueCompany(); + IssueIsp issueIsp = new IssueIsp(); + IssueHosting issueHosting = new IssueHosting(); //issueCompany �벑濡� if (issueForm.getIssueCompanyFields() != null && issueForm.getIssueCompanyFields().size() > 0) { for (Map<String, Object> issueCompanyMap : issueForm.getIssueCompanyFields()) { CompanyField companyField = ConvertUtil.convertMapToClass(issueCompanyMap, CompanyField.class); - IssueCompany issueCompany = ConvertUtil.convertMapToClass(issueCompanyMap, IssueCompany.class); + issueCompany = ConvertUtil.convertMapToClass(issueCompanyMap, IssueCompany.class, "id"); issueCompany.setCompanyField(companyField); issueCompany.setIssue(issue); this.issueCompanyRepository.saveAndFlush(issueCompany); - - // �뾽泥댁쓽 ISP媛� �엳�뒗 寃쎌슦 issueISP �벑濡� - if (companyField.getIspId() != null) { - IspField ispField = this.ispFieldService.getIsp(companyField.getIspId()); - IssueIsp issueIsp = ConvertUtil.copyProperties(ispField, IssueIsp.class); - issueIsp.setIspField(ispField); - issueIsp.setIssue(issue); - this.issueIspRepository.saveAndFlush(issueIsp); + + // �궗�슜�옄媛� ISP瑜� 吏곸젒 �엯�젰�븯吏� �븡�븯�쓣 寃쎌슦 �뾽泥댁뿉 �벑濡앸릺�뼱�엳�뒗 ISP �꽕�젙 + if (issueForm.getIssueIspFields() == null || issueForm.getIssueIspFields().size() < 1) { + // �뾽泥댁쓽 ISP媛� �엳�뒗 寃쎌슦 issueISP �벑濡� + if (companyField.getIspId() != null && companyField.getIspId() != -1) { + IspField ispField = this.ispFieldService.getIsp(companyField.getIspId()); + issueIsp = ConvertUtil.copyProperties(ispField, IssueIsp.class, "id"); + issueIsp.setIspField(ispField); + issueIsp.setIssue(issue); + this.issueIspRepository.saveAndFlush(issueIsp); + } } - // �뾽泥댁쓽 �샇�뒪�똿�씠 �엳�뒗 寃쎌슦 issueHosting �벑濡� - if (companyField.getHostingId() != null) { - HostingField hostingField = this.hostingFieldService.getHosting(companyField.getHostingId()); - IssueHosting issueHosting = ConvertUtil.copyProperties(hostingField, IssueHosting.class); - issueHosting.setHostingField(hostingField); - issueHosting.setIssue(issue); - this.issueHostingRepository.saveAndFlush(issueHosting); + // �궗�슜�옄媛� �샇�뒪�똿�쓣 吏곸젒 �엯�젰�븯吏� �븡�븯�쓣 寃쎌슦 �뾽泥댁뿉 �벑濡앸릺�뼱�엳�뒗 �샇�뒪�똿 �꽕�젙 + if (issueForm.getIssueHostingFields() == null || issueForm.getIssueHostingFields().size() < 1) { + // �뾽泥댁쓽 �샇�뒪�똿�씠 �엳�뒗 寃쎌슦 issueHosting �벑濡� + if (companyField.getHostingId() != null && companyField.getHostingId() != -1) { + HostingField hostingField = this.hostingFieldService.getHosting(companyField.getHostingId()); + issueHosting = ConvertUtil.copyProperties(hostingField, IssueHosting.class, "id"); + issueHosting.setHostingField(hostingField); + issueHosting.setIssue(issue); + this.issueHostingRepository.saveAndFlush(issueHosting); + } } } } //issueIsp �벑濡� if (issueForm.getIssueIspFields() != null && issueForm.getIssueIspFields().size() > 0) { for (Map<String, Object> issueIspMap : issueForm.getIssueIspFields()) { - IssueIsp issueIsp = ConvertUtil.convertMapToClass(issueIspMap, IssueIsp.class); + issueIsp = ConvertUtil.convertMapToClass(issueIspMap, IssueIsp.class, "id"); IspField ispField = ConvertUtil.convertMapToClass(issueIspMap, IspField.class); issueIsp.setIspField(ispField); issueIsp.setIssue(issue); @@ -3244,7 +3253,7 @@ //issueHosting �벑濡� if (issueForm.getIssueHostingFields() != null && issueForm.getIssueHostingFields().size() > 0) { for (Map<String, Object> issueHostingMap : issueForm.getIssueHostingFields()) { - IssueHosting issueHosting = ConvertUtil.convertMapToClass(issueHostingMap, IssueHosting.class); + issueHosting = ConvertUtil.convertMapToClass(issueHostingMap, IssueHosting.class, "id"); HostingField hostingField = ConvertUtil.convertMapToClass(issueHostingMap, HostingField.class); issueHosting.setHostingField(hostingField); issueHosting.setIssue(issue); @@ -3445,8 +3454,25 @@ * @param cell Cell * @return boolean */ - private Boolean cellNullCheck (Cell cell) { - return cell != null && cell.getStringCellValue() != null && cell.getCellType() != Cell.CELL_TYPE_BLANK; + private Boolean cellNullCheck (Cell cell, int rowIndex) { + boolean result = false; + + // 臾몄옄�삎�떇�씤吏� 泥댄겕 + if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK && cell.getCellType() != Cell.CELL_TYPE_STRING) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_NOT_STRING_TYPE, rowIndex)); + } + // 怨듬갚 �젣嫄� + if (cell != null && cell.getStringCellValue() != null) { + cell.setCellValue(cell.getStringCellValue().trim()); + } + + if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK && cell.getCellType() == cell.CELL_TYPE_STRING + && cell.getStringCellValue() != null && !cell.getStringCellValue().equals("")) { + result = true; + } + + return result; } // �뿊�� �븘�뱶�뿉 �엳�뒗 �젙蹂대�� �씠�뒋 form �쑝濡� �삷湲대떎. @@ -3469,7 +3495,7 @@ break; case 1: // �궡�슜 - if (cellNullCheck(cell)) { + if (cellNullCheck(cell, rowIndex)) { issueForm.setDescription(CommonUtil.convertExcelStringToCell(cell)); } else { // null �엯�젰 諛⑹� @@ -3493,31 +3519,31 @@ break;*/ case 4: // �떆�옉�씪�쓣 IssueForm �뿉 ���옣�븳�떎. - if (cellNullCheck(cell)) { + if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) { this.setIssueFormPeriod(cell, issueForm, true, rowIndex); } break; case 5: // 醫낅즺�씪�쓣 IssueForm �뿉 ���옣�븳�떎. - if (cellNullCheck(cell)) { + if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) { this.setIssueFormPeriod(cell, issueForm, false, rowIndex); } break; case 6: // �뾽泥대�� IssueForm �뿉 ���옣�븳�떎. - if (cellNullCheck(cell)) { + if (cellNullCheck(cell, rowIndex)) { this.setIssueFormCompanyField(cell, companyFieldMaps, issueForm, rowIndex); } break; case 7: // ISP瑜� IssueForm �뿉 ���옣�븳�떎. - if (cellNullCheck(cell)) { + if (cellNullCheck(cell, rowIndex)) { this.setIssueFormIspField(cell, ispFieldMaps, issueForm, rowIndex); } break; case 8: // �샇�뒪�똿�쓣 IssueForm �뿉 ���옣�븳�떎. - if (cellNullCheck(cell)) { + if (cellNullCheck(cell, rowIndex)) { this.setIssueFormHostingField(cell, hostingFieldMaps, issueForm, rowIndex); } break; @@ -3571,7 +3597,7 @@ // �씠�뒋 �젣紐⑹쓣 IssueForm �뿉 ���옣�븳�떎. private void setIssueFormTitle(Cell cell, IssueForm issueForm, int rowIndex) { - if (cell == null) { + if (!cellNullCheck(cell, rowIndex)) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_ISSUE_TITLE_IS_NULL, rowIndex)); } @@ -3619,7 +3645,7 @@ // �슦�꽑�닚�쐞瑜� IssueForm �뿉 ���옣�븳�떎. private void setIssueFormPriority(Cell cell, Map<String, Priority> priorityMaps, IssueForm issueForm, int rowIndex) { - if (cell == null) { + if (!cellNullCheck(cell, rowIndex)) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PRIORITY_IS_NULL, rowIndex)); } @@ -3636,7 +3662,7 @@ // 以묒슂�룄瑜� IssueForm �뿉 ���옣�븳�떎. private void setIssueFormSeverity(Cell cell, Map<String, Severity> severityMaps, IssueForm issueForm, int rowIndex) { - if (cell == null) { + if (!cellNullCheck(cell, rowIndex)) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_SEVERITY_IS_NULL, rowIndex)); } @@ -3672,8 +3698,13 @@ // 媛믪씠 怨듬갚�씠硫� 以묒� String cellValue = CommonUtil.convertExcelStringToCell(cell); - if (StringUtils.isEmpty(cellValue) || !cell.toString().equals("null")) { + if (StringUtils.isEmpty(cellValue) || cell.toString().equals("null")) { return; + } + + if (cell.toString().length() < 10 && cell.toString().contains("-")) { //�궇吏� �삎�떇 泥댄겕 + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PERIOD_NOT_DASH, rowIndex)); } Date startDate; @@ -3689,6 +3720,12 @@ issueForm.setStartDate(DateUtil.convertDateToStr(startDate, "yyyy-MM-dd")); } else { issueForm.setCompleteDate(DateUtil.convertDateToStr(startDate, "yyyy-MM-dd")); + + // 醫낅즺�씪留� �엯�젰 �뻽�쓣 寃쎌슦 + if (issueForm.getCompleteDate() != null && issueForm.getStartDate() == null) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PERIOD_NOT_VALIDITY_EMPTY_START, rowIndex)); + } try { // �궇吏� �쑀�슚�꽦 泥댄겕 @@ -3733,6 +3770,10 @@ } if (customField.getCustomFieldType() == DATETIME) { //DATETIME�씪 寃쎌슦 format 蹂�寃� + if (cell.toString().length() < 10 && cell.toString().contains("-")) { //�궇吏� �삎�떇 泥댄겕 + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_DATETIME_NOT_DASH, rowIndex)); + } Date date = cell.getDateCellValue(); cellValue = new SimpleDateFormat("yyyy-MM-dd H:mm:ss").format(date); } @@ -3842,7 +3883,7 @@ // �씠�뒋瑜� �뀥�뵆由우뿉 �뵲�씪 �뙆�듃�꼫 �떞�떦�옄�뿉寃� 硫붿씪濡� 諛쒖넚�븳�떎. @Override @Transactional(readOnly = true) - public void sendIssueEmailPartners(EmailTemplateForm emailTemplateForm) { + public void sendIssueEmailPartners(EmailTemplateForm emailTemplateForm, List<MultipartFile> multipartFiles) { if (emailTemplateForm.getSendEmails().size() < 1) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.ISSUE_NOT_SEND_USER)); @@ -3869,14 +3910,14 @@ for(int i=0; i < sendMails.length; i++) { sendMails[i] = CommonUtil.decryptAES128(sendMails[i]); } - this.systemEmailService.sendEmail(emailTemplateForm.getTitle(), emailTemplateForm.getTemplate(), sendMails, null); + this.systemEmailService.sendEmail(emailTemplateForm.getTitle(), emailTemplateForm.getTemplate(), sendMails, null, multipartFiles); this.issueHistoryService.detectSendIssueMail(IssueHistoryType.SEND, emailTemplateForm.getSendEmails(), sb); this.issueHistoryService.addIssueHistory(issue, IssueHistoryType.SEND, sb.toString()); } @Override - public void sendCommonEmail(EmailCommonForm emailCommonForm) { + public void sendCommonEmail(EmailCommonForm emailCommonForm, List<MultipartFile> multipartFiles) { if (emailCommonForm.getSendEmails().size() < 1) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.ISSUE_NOT_SEND_USER)); @@ -3900,7 +3941,7 @@ for(int i=0; i < sendMails.length; i++) { sendMails[i] = CommonUtil.decryptAES128(sendMails[i]); } - this.systemEmailService.sendEmail(emailCommonForm.getTitle(), emailCommonForm.getDescription(), sendMails, null); + this.systemEmailService.sendEmail(emailCommonForm.getTitle(), emailCommonForm.getDescription(), sendMails, null, multipartFiles); if (issue != null) { this.issueHistoryService.detectSendIssueMail(IssueHistoryType.SEND, emailCommonForm.getSendEmails(), sb); -- Gitblit v1.8.0