From b548d49284bc36f5016cba913bb6ac55d8a5e340 Mon Sep 17 00:00:00 2001 From: 이민희 <mhlee@maprex.co.kr> Date: 금, 28 1월 2022 17:40:12 +0900 Subject: [PATCH] 엑셀 임포트 시 코드 수정 --- src/main/java/kr/wisestone/owl/service/impl/CompanyFieldServiceImpl.java | 51 +++++++++++++++++++++++++++++---------------------- 1 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/main/java/kr/wisestone/owl/service/impl/CompanyFieldServiceImpl.java b/src/main/java/kr/wisestone/owl/service/impl/CompanyFieldServiceImpl.java index 06e4059..56499a8 100644 --- a/src/main/java/kr/wisestone/owl/service/impl/CompanyFieldServiceImpl.java +++ b/src/main/java/kr/wisestone/owl/service/impl/CompanyFieldServiceImpl.java @@ -83,8 +83,11 @@ public CompanyField addCompany(CompanyFieldForm companyFieldForm) { // �뾽泥대챸 以묐났 泥댄겕 this.verifyTitle(companyFieldForm.getName(), null); - // url �쑀�슚�꽦 泥댄겕 - this.verifyUrl(companyFieldForm.getUrl(), null); + + if (companyFieldForm.getUrl() != null) { + // url �쑀�슚�꽦 泥댄겕 + this.verifyUrl(companyFieldForm.getUrl(), null); + } if (companyFieldForm.getTelList() != null && companyFieldForm.getTelList().size() > 0) { String tels = companyFieldForm.getTelList().toString(); @@ -109,12 +112,11 @@ // url �쑀�슚�꽦 泥댄겕 private void verifyUrl(String url, Long id) { - if (StringUtils.isEmpty(url)) { + /*if (StringUtils.isEmpty(url)) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.COMPANY_NOT_URL)); - } + }*/ CompanyField companyField; - if(id == null){ companyField = this.companyFieldRepository.findByUrl(url); } else { @@ -222,8 +224,11 @@ public void modifyCompany(CompanyFieldForm companyFieldForm) { // �뾽泥대챸 �쑀�슚�꽦 泥댄겕 this.verifyTitle(companyFieldForm.getName(), companyFieldForm.getId()); - // url �쑀�슚�꽦 泥댄겕 - this.verifyUrl(companyFieldForm.getUrl(), companyFieldForm.getId()); + + if (companyFieldForm.getUrl() != null) { + // url �쑀�슚�꽦 泥댄겕 + this.verifyUrl(companyFieldForm.getUrl(), companyFieldForm.getId()); + } if (companyFieldForm.getTelList() != null && companyFieldForm.getTelList().size() > 0) { String tels = companyFieldForm.getTelList().toString(); @@ -438,7 +443,10 @@ * @return boolean */ private Boolean cellNullCheck (Cell cell) { - return cell != null && cell.getStringCellValue() != null && cell.getCellType() != Cell.CELL_TYPE_BLANK; + if (cell != null && cell.getStringCellValue() != null) { + cell.setCellValue(cell.getStringCellValue().trim());//�� 媛� 怨듬갚 �젣嫄� + } + return cell != null && cell.getStringCellValue() != null && !cell.getStringCellValue().equals("") && cell.getCellType() != Cell.CELL_TYPE_BLANK; } private void telTypeCheck (Cell cell, int rowIndex) { @@ -466,7 +474,9 @@ case 1: // url - this.setCompanyFormUrl(cell, companyFieldForm, rowIndex); + if (cellNullCheck(cell)) { + this.setCompanyFormUrl(cell, companyFieldForm, rowIndex); + } break; case 2: @@ -485,9 +495,8 @@ case 4: // �뿰�씫泥� - this.telTypeCheck(cell, rowIndex); // �뀓�뒪�듃 �삎�떇 泥댄겕 - if (cellNullCheck(cell)) { + this.telTypeCheck(cell, rowIndex); // �뀓�뒪�듃 �삎�떇 泥댄겕 this.setCompanyFormTel(cell, companyFieldForm, rowIndex); } break; @@ -674,7 +683,7 @@ } private void setCompanyFormName(Cell cell, CompanyFieldForm companyFieldForm, int rowIndex) { - if (cell == null) { + if (!cellNullCheck(cell)) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_COMPANY_NAME_IS_NULL, rowIndex)); } @@ -687,17 +696,15 @@ } private void setCompanyFormUrl(Cell cell, CompanyFieldForm companyFieldForm, int rowIndex) { - if (cell == null) { - throw new OwlRuntimeException( - this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_URL_IS_NULL, rowIndex)); - } - String url = CommonUtil.convertExcelStringToCell(cell); - if (url.contains(" ")) { - url = url.replace(" ", ""); - } - this.verifyUrl(url, null); //url �쑀�슚�꽦 寃��궗 + if (cell != null) { + String url = CommonUtil.convertExcelStringToCell(cell); + if (url.contains(" ")) { + url = url.replace(" ", ""); + } + this.verifyUrl(url, null); //url �쑀�슚�꽦 寃��궗 - companyFieldForm.setUrl(url); + companyFieldForm.setUrl(url); + } } // �뾽泥대챸 �쑀�슚�꽦 泥댄겕 -- Gitblit v1.8.0