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 | 58 +++++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 45 insertions(+), 13 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 dd99a3d..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,7 +356,7 @@ 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 && companyFieldVo.getIspId() != -1) { @@ -3454,8 +3454,25 @@ * @param cell Cell * @return boolean */ - private Boolean cellNullCheck (Cell cell) { - return cell != null && cell.getStringCellValue() != null && !cell.getStringCellValue().equals("") && 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 �쑝濡� �삷湲대떎. @@ -3478,7 +3495,7 @@ break; case 1: // �궡�슜 - if (cellNullCheck(cell)) { + if (cellNullCheck(cell, rowIndex)) { issueForm.setDescription(CommonUtil.convertExcelStringToCell(cell)); } else { // null �엯�젰 諛⑹� @@ -3502,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; @@ -3580,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)); } @@ -3628,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)); } @@ -3645,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)); } @@ -3681,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; @@ -3698,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 { // �궇吏� �쑀�슚�꽦 泥댄겕 @@ -3742,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); } -- Gitblit v1.8.0