From 398a4927e195755bd6a46be99337efd8dacc3dc2 Mon Sep 17 00:00:00 2001
From: 박지현 <jhpark@maprex.co.kr>
Date: 월, 07 3월 2022 18:08:13 +0900
Subject: [PATCH] Merge branch 'master' of http://maprex.iptime.org:9001/r/owl-kisa

---
 src/main/java/kr/wisestone/owl/service/impl/CompanyFieldServiceImpl.java |  565 ++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 404 insertions(+), 161 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 01602a2..9b50065 100644
--- a/src/main/java/kr/wisestone/owl/service/impl/CompanyFieldServiceImpl.java
+++ b/src/main/java/kr/wisestone/owl/service/impl/CompanyFieldServiceImpl.java
@@ -9,7 +9,6 @@
 import kr.wisestone.owl.util.MapUtil;
 import kr.wisestone.owl.web.condition.CompanyFieldCondition;
 import kr.wisestone.owl.web.form.CompanyFieldForm;
-import kr.wisestone.owl.web.form.IssueForm;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.ss.usermodel.*;
 import org.springframework.transaction.annotation.Transactional;
@@ -33,6 +32,7 @@
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.*;
+import java.util.regex.Pattern;
 
 @Service
 public class CompanyFieldServiceImpl extends AbstractServiceImpl<CompanyField, Long, JpaRepository<CompanyField, Long>> implements CompanyFieldService {
@@ -81,16 +81,33 @@
     // �뾽泥� 異붽�
     @Override
     public CompanyField addCompany(CompanyFieldForm companyFieldForm) {
-        //  url �쑀�슚�꽦 泥댄겕
-        this.verifyUrl(companyFieldForm.getUrl(), null);
+        //  �뾽泥대챸 以묐났 泥댄겕
+        this.verifyTitle(companyFieldForm.getName(), null);
+
+        if (companyFieldForm.getIpStart() != null && companyFieldForm.getIpEnd() != null) {
+            //  �븘�씠�뵾 �쑀�슚�꽦 泥댄겕
+            this.verifyIp(companyFieldForm.getIpStart(), companyFieldForm.getIpEnd());
+        }
+
+        if (companyFieldForm.getUrl() != null) {
+            //  url �쑀�슚�꽦 泥댄겕
+            this.verifyUrl(companyFieldForm.getUrl(), null);
+        }
 
         if (companyFieldForm.getTelList() != null && companyFieldForm.getTelList().size() > 0) {
-            String[] tels = ConvertUtil.ToArray(companyFieldForm.getTelList());
-            companyFieldForm.setTel(Arrays.toString(tels));
+            String tels = companyFieldForm.getTelList().toString();
+            if (tels.contains("[")) {
+                tels = tels.substring(1, tels.indexOf("]"));
+            }
+            companyFieldForm.setTel(tels.trim());
         }
         if (companyFieldForm.getEmailList() != null && companyFieldForm.getEmailList().size() > 0) {
-            String[] emails = ConvertUtil.ToArray(companyFieldForm.getEmailList());
-            companyFieldForm.setEmail(Arrays.toString(emails));
+            String emails = companyFieldForm.getEmailList().toString();
+            String email = "";
+            if (emails.contains("[")) {
+                email = emails.substring(1, emails.indexOf("]"));
+            }
+            companyFieldForm.setEmail(email.trim());
         }
 
         CompanyField companyField = ConvertUtil.copyProperties(companyFieldForm, CompanyField.class);
@@ -98,23 +115,66 @@
         return companyField;
     }
 
+    /**
+     * IP �쑀�슚�꽦 泥댄겕
+     * @param ip String
+     */
+    private void verifyIp(String ip, String ip2) {
+        if (ip2 == null) {
+            if (!StringUtils.isEmpty(ip)) {
+                if (!Pattern.matches("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\" +
+                        ".(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$", ip)) {
+                    throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.IP_NOT_INVALID));
+                }
+            }
+        } else {
+            if (!StringUtils.isEmpty(ip)) {
+                long ipStart = ConvertUtil.ipToLong(ip);
+                long ipEnd = ConvertUtil.ipToLong(ip2);
+                if (ipEnd < ipStart) {
+                    throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.IP_START_NOT_LARGER_THAN_END));
+                }
+            }
+        }
+    }
+
     //  url �쑀�슚�꽦 泥댄겕
     private void verifyUrl(String url, Long id) {
-        if (StringUtils.isEmpty(url)) {
+        /*if (StringUtils.isEmpty(url)) {
             throw new OwlRuntimeException(
-                    this.messageAccessor.getMessage(MsgConstants.COMPANYFIELD_NOT_URL));
-        }
-        CompanyField companyField;
+                    this.messageAccessor.getMessage(MsgConstants.COMPANY_NOT_URL));
+        }*/
+        if (!StringUtils.isEmpty(url)) {
+            List<CompanyField> companyFieldList = Lists.newArrayList();
+            CompanyFieldCondition condition = new CompanyFieldCondition();
+            String[] urlArr = null;
+            List<String> urls = Lists.newArrayList();
 
-        if(id == null){
-            companyField = this.companyFieldRepository.findByUrl(url);
-        } else {
-            companyField = this.companyFieldRepository.findByUrlAndIdNot(url,id);
-        }
+            if (url.contains(" ")) {
+                url = url.replace(" ","");
+            }
+            if (url.contains(",")) {
+                urlArr = url.split(",");
+                urls.addAll(Arrays.asList(urlArr));
+            } else {
+                urls.add(url);
+            }
 
-        if (companyField != null) {
-            throw new OwlRuntimeException(
-                    this.messageAccessor.getMessage(MsgConstants.COMPANYFIELD_USED_URL));
+            if (urls.size() > 0) {
+                condition.setUrl(urls);
+
+                if(id == null){
+                    companyFieldList = this.companyFieldMapper.findByUrls(condition);
+                } else {
+                    condition.setId(id);
+                    companyFieldList = this.companyFieldMapper.findByUrlsAndIdNot(condition);
+                }
+            }
+
+            if (companyFieldList != null && companyFieldList.size() > 0) {
+                throw new OwlRuntimeException(
+                        this.messageAccessor.getMessage(MsgConstants.COMPANY_USED_URL));
+            }
         }
     }
 
@@ -133,6 +193,50 @@
 
     public List<Map<String, Object>> find(CompanyFieldCondition condition) {
         return this.companyFieldMapper.find(condition);
+    }
+
+    //  紐⑤뱺 �뾽泥댁젙蹂대�� 議고쉶�븳�떎. �씠�뒋 �뿊�� import �뿉�꽌 �궗�슜
+    @Override
+    @Transactional(readOnly = true)
+    public List<CompanyField> findAll() {
+        return this.companyFieldRepository.findAll();
+    }
+
+    /**
+     * companyFieldCategory Name �꽕�젙
+     * @param companyFieldVo CompanyFieldVo
+     * @param companyField CompanyField
+     */
+    @Override
+    public CompanyFieldVo CreateCompanyFieldCategory(CompanyFieldVo companyFieldVo, CompanyField companyField) {
+        if (companyField.getCompanyTypeId() != null && companyField.getCompanyTypeId() != -1) {
+            CompanyFieldCategory companyType = this.companyFieldCategoryService.find(companyField.getCompanyTypeId());
+            if (companyType != null) {
+                companyFieldVo.setCompanyTypeName(companyType.getUseValue());
+            }
+        }
+        if (companyField.getParentSectorId() != null && companyField.getParentSectorId() != -1) {
+            CompanyFieldCategory parentSector = this.companyFieldCategoryService.find(companyField.getParentSectorId());
+            if (parentSector != null) {
+                companyFieldVo.setParentSectorName(parentSector.getUseValue());
+            }
+        }
+        if (companyField.getChildSectorId() != null && companyField.getChildSectorId() != -1) {
+            CompanyFieldCategory childSector = this.companyFieldCategoryService.find(companyField.getChildSectorId());
+            if (childSector != null) {
+                companyFieldVo.setChildSectorName(childSector.getUseValue());
+            }
+        }
+        if (companyField.getRegionId() != null && companyField.getRegionId() != -1) {
+            CompanyFieldCategory region = this.companyFieldCategoryService.find(companyField.getRegionId());
+            if (region != null) {
+                companyFieldVo.setRegionName(region.getUseValue());
+            }
+        }
+        if (companyField.getStatusName() != null && !companyField.getStatusName().equals("")) {
+            companyFieldVo.setStatusName(companyField.getStatusName());
+        }
+        return companyFieldVo;
     }
 
     // �뾽泥� �긽�꽭 議고쉶�븳�떎.
@@ -159,36 +263,7 @@
             ispFieldVo = ConvertUtil.copyProperties(ispField, IspFieldVo.class);
             hostingFieldVo = ConvertUtil.copyProperties(hostingField, HostingFieldVo.class);
 
-            if (companyField.getCompanyTypeId() != null && companyField.getCompanyTypeId() != -1) {
-                CompanyFieldCategory companyType = this.companyFieldCategoryService.find(companyField.getCompanyTypeId());
-                if (companyType != null) {
-                    companyFieldVo.setCompanyTypeName(companyType.getUseValue());
-                }
-            }
-            if (companyField.getParentSectorId() != null && companyField.getParentSectorId() != -1) {
-                CompanyFieldCategory parentSector = this.companyFieldCategoryService.find(companyField.getParentSectorId());
-                if (parentSector != null) {
-                    companyFieldVo.setParentSectorName(parentSector.getUseValue());
-                }
-            }
-            if (companyField.getChildSectorId() != null && companyField.getChildSectorId() != -1) {
-                CompanyFieldCategory childSector = this.companyFieldCategoryService.find(companyField.getChildSectorId());
-                if (childSector != null) {
-                    companyFieldVo.setChildSectorName(childSector.getUseValue());
-                }
-            }
-            if (companyField.getRegionId() != null && companyField.getRegionId() != -1) {
-                CompanyFieldCategory region = this.companyFieldCategoryService.find(companyField.getRegionId());
-                if (region != null) {
-                    companyFieldVo.setRegionName(region.getUseValue());
-                }
-            }
-            /*if (companyField.getStatusId() != null && companyField.getStatusId() != -1) {
-                CompanyFieldCategory status = this.companyFieldCategoryService.find(companyField.getStatusId());
-                if (status != null) {
-                    companyFieldVo.setStatusName(status.getUseValue());
-                }
-            }*/
+            CreateCompanyFieldCategory(companyFieldVo, companyField);
 
             companyFieldVo.setIspFieldVo(ispFieldVo);
             companyFieldVo.setHostingFieldVo(hostingFieldVo);
@@ -199,16 +274,35 @@
     // �뾽泥� �젙濡쒕�� �닔�젙�븳�떎.
     @Override
     public void modifyCompany(CompanyFieldForm companyFieldForm) {
-        //  url �쑀�슚�꽦 泥댄겕
-        this.verifyUrl(companyFieldForm.getUrl(), companyFieldForm.getId());
+        //  �뾽泥대챸 �쑀�슚�꽦 泥댄겕
+        this.verifyTitle(companyFieldForm.getName(), companyFieldForm.getId());
+
+        if (companyFieldForm.getUrl() != null) {
+            //  url �쑀�슚�꽦 泥댄겕
+            this.verifyUrl(companyFieldForm.getUrl(), companyFieldForm.getId());
+        }
 
         if (companyFieldForm.getTelList() != null && companyFieldForm.getTelList().size() > 0) {
-            String[] tels = ConvertUtil.ToArray(companyFieldForm.getTelList());
-            companyFieldForm.setTel(Arrays.toString(tels));
+            String tels = companyFieldForm.getTelList().toString();
+            if (tels.contains("[")) {
+                tels = tels.substring(1, tels.indexOf("]"));
+            }
+            companyFieldForm.setTel(tels.trim());
         }
         if (companyFieldForm.getEmailList() != null && companyFieldForm.getEmailList().size() > 0) {
-            String[] emails = ConvertUtil.ToArray(companyFieldForm.getEmailList());
-            companyFieldForm.setEmail(Arrays.toString(emails));
+            String emails = companyFieldForm.getEmailList().toString();
+            if (emails.contains("[")) {
+                emails = emails.substring(1, emails.indexOf("]"));
+            }
+            companyFieldForm.setEmail(emails.trim());
+        }
+
+        if (companyFieldForm.getChildSectorId() != null) {
+            CompanyFieldCategory companyFieldCategory = this.companyFieldCategoryService.find(companyFieldForm.getChildSectorId());
+            if (companyFieldCategory != null && !companyFieldCategory.getParentId().equals(companyFieldForm.getParentSectorId())) {
+                throw new OwlRuntimeException(
+                        this.messageAccessor.getMessage(MsgConstants.PARENT_SECTOR_NOT_EQUAL));
+            }
         }
 
         CompanyField companyField = ConvertUtil.copyProperties(companyFieldForm, CompanyField.class);
@@ -239,6 +333,8 @@
         excelInfo.setFileName(this.messageAccessor.message("common.registerExcelCompanyField")); // �뿊��濡� �뾽泥� �벑濡앺븯湲�
         excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("companyField.companyName"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // �뾽泥대챸
         excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("companyField.companyUrl"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // url
+        excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("companyField.companyIpStart"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // ip �떆�옉 二쇱냼
+        excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("companyField.companyIpEnd"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // ip 醫낅즺 二쇱냼
         excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("isp.ispName"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // isp紐�
         excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("Hosting.HostingName"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // �샇�뒪�똿紐�
         excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("companyField.companyTel"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // �뿰�씫泥�
@@ -311,7 +407,7 @@
         }
     }
 
-    //  �뿊�� import 濡� �씠�뒋瑜� �벑濡앺븳�떎.
+    //  �뿊�� import 濡� �뾽泥대�� �벑濡앺븳�떎.
     @Override
     @Transactional
     public void importExcel(MultipartFile multipartFile) throws Exception {
@@ -351,7 +447,7 @@
             for (int rowIndex = 0; rowIndex < lastRowNum; rowIndex++) {
                 //  0踰덉� �뿤�뜑�뒗 臾댁떆�븳�떎.
                 Row row = sheet.getRow(rowIndex);
-                //  �뿤�뜑 �젙蹂대�� 異붿텧�븳�떎 - �궗�슜�옄 �젙�쓽 �븘�뱶 �젙蹂대�� 媛��졇�삤湲� �쐞�빐
+                //  �뿤�뜑 �젙蹂대�� 異붿텧�븳�떎
                 if (rowIndex == 1) {
                     for (int cellIndex = 0; cellIndex < row.getLastCellNum(); cellIndex++) {
                         Cell cell = row.getCell(cellIndex);
@@ -375,6 +471,8 @@
                 if (rowIndex > 1) {
                     //  �뾽泥대줈 �벑濡앺븯湲� �쐞�빐 CompanyFieldForm �뿉 �뜲�씠�꽣瑜� �뀑�똿�븳�떎.
                     CompanyFieldForm newCompanyFieldForm = this.setCompanyFieldFormToExcelField(row, (rowIndex + 1), ispFieldMaps, hostingFieldMaps, companyTypeMaps, parentSectorMaps, childSectorMaps, regionMaps, statusMaps, headers);
+                    //  ip �쑀�슚�꽦 泥댄겕
+                    this.verifyIp(newCompanyFieldForm.getIpStart(), newCompanyFieldForm.getIpEnd());
 
                     companyFieldForms.add(newCompanyFieldForm);
                 }
@@ -395,6 +493,55 @@
         }
     }
 
+    /**
+     * cell String�쑝濡� 蹂��솚 �븿�닔
+     * @param cell Cell
+     * @param isNull boolean
+     * @return String
+     */
+    private String stringToCell (Cell cell, boolean isNull) {
+        String cellStr = "";
+        if (!isNull) {
+            cellStr = CommonUtil.convertExcelStringToCell(cell);
+            //  怨듬갚 �젣嫄�
+            cell.setCellValue(cellStr.trim());
+        } else {
+            cell.setCellValue(cellStr);
+        }
+        return cellStr;
+    }
+
+    /**
+     * cell NULL 泥댄겕 �븿�닔
+     * @param cell Cell
+     * @return boolean
+     */
+    private Boolean cellNullCheck (Cell cell) {
+        int cellType = cell.getCellType();
+        if (cellType < Cell.CELL_TYPE_BLANK) {
+            if (cellType == Cell.CELL_TYPE_STRING) {
+                if (cell.getStringCellValue() != null && !cell.getStringCellValue().equals("")) {
+                    return false;
+                }
+            } else {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * �쟾�솕踰덊샇 CellType 泥댄겕 �븿�닔
+     * @param cell Cell
+     * @param rowIndex int
+     */
+    private void telTypeCheck (Cell cell, int rowIndex) {
+        if (cell != null && cell.getCellType() != cell.CELL_TYPE_STRING) {
+            throw new OwlRuntimeException(
+                    this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_TEL_NOT_STRING_TYPE, rowIndex));
+        }
+    }
+
     //  �뿊�� �븘�뱶�뿉 �엳�뒗 �젙蹂대�� �뾽泥� form �쑝濡� �삷湲대떎.
     private CompanyFieldForm setCompanyFieldFormToExcelField(Row row, int rowIndex, Map<String, IspField> ispFieldMaps, Map<String, HostingField> hostingFieldMaps,
                                                              Map<String, Map<String, Object>> companyTypeMaps, Map<String, Map<String, Object>> parentSectorMaps,
@@ -403,120 +550,145 @@
         CompanyFieldForm companyFieldForm = new CompanyFieldForm();
         companyFieldForm.setRegisterId(this.webAppUtil.getLoginId());
 
-        //  �젣紐�, �궡�슜, �봽濡쒖젥�듃 �궎, �씠�뒋 ���엯, �슦�꽑�닚�쐞, 以묒슂�룄, �떞�떦�옄, �떆�옉�씪, 醫낅즺�씪, �궗�슜�옄 �젙�쓽 �븘�뱶
         for (int cellIndex = 0; cellIndex < headers.size(); cellIndex++) {
             Cell cell = row.getCell(cellIndex);
+
+            String cellStr = "";
+            boolean isNull = true;
+
+            if (cell != null) {
+                isNull = cellNullCheck(cell);
+                cellStr = stringToCell(cell, isNull); //cell�쓣 String�쑝濡� 蹂��솚
+            }
+
             switch (cellIndex) {
                 case 0:
                     //  �뾽泥대챸
-                    this.setCompanyFormName(cell, companyFieldForm, rowIndex);
+                    if (isNull) {
+                        throw new OwlRuntimeException(
+                                this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_COMPANY_NAME_IS_NULL, rowIndex));
+                    }
+                    this.setCompanyFormName(cellStr, companyFieldForm);
                     break;
 
                 case 1:
                     //  url
-                    this.setCompanyFormUrl(cell, companyFieldForm, rowIndex);
+                    this.setCompanyFormUrl(cellStr, companyFieldForm, isNull);
                     break;
 
                 case 2:
-                    // isp紐�
-                    if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
-                        this.setCompanyFormIspName(cell, ispFieldMaps, companyFieldForm, rowIndex);
-                    }
+                    //  ip�떆�옉二쇱냼
+                    this.setCompanyFormIpStart(cellStr, companyFieldForm, isNull);
                     break;
 
                 case 3:
-                    // �샇�뒪�똿紐�
-                    if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
-                        this.setCompanyFormHostingName(cell, hostingFieldMaps, companyFieldForm, rowIndex);
-                    }
+                    //  ip醫낅즺二쇱냼
+                    this.setCompanyFormIpEnd(cellStr, companyFieldForm, isNull);
                     break;
 
                 case 4:
-                    // �뿰�씫泥�
-                    if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
-                        this.setCompanyFormTel(cell, companyFieldForm, rowIndex);
-                    }
+                    // isp紐�
+                    this.setCompanyFormIspName(cellStr, ispFieldMaps, companyFieldForm, rowIndex, isNull);
                     break;
 
                 case 5:
-                    // �씠硫붿씪
-                    if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
-                        this.setCompanyFormEmail(cell, companyFieldForm, rowIndex);
-                    }
+                    // �샇�뒪�똿紐�
+                    this.setCompanyFormHostingName(cellStr, hostingFieldMaps, companyFieldForm, rowIndex, isNull);
                     break;
 
                 case 6:
-                    // �떞�떦�옄
-                    if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
-                        this.setCompanyFormManager(cell, companyFieldForm, rowIndex);
-                    }
+                    // �뿰�씫泥�
+                    telTypeCheck(cell, rowIndex);
+                    this.setCompanyFormTel(cellStr, companyFieldForm, isNull);
                     break;
 
                 case 7:
-                    // 湲곗뾽援щ텇
-                    if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
-                        this.setCompanyFormCompanyType(cell, companyTypeMaps, companyFieldForm, rowIndex);
-                    }
+                    // �씠硫붿씪
+                    this.setCompanyFormEmail(cellStr, companyFieldForm, isNull);
                     break;
 
                 case 8:
-                    // �뾽醫�(��遺꾨쪟)
-                    if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
-                        this.setCompanyFormParentSector(cell, parentSectorMaps, companyFieldForm, rowIndex);
-                    }
+                    // �떞�떦�옄
+                    this.setCompanyFormManager(cellStr, companyFieldForm, isNull);
                     break;
 
                 case 9:
-                    // �뾽醫�(以묐텇瑜�)
-                    if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
-                        this.setCompanyFormChildSector(cell, childSectorMaps, companyFieldForm, rowIndex);
-                    }
+                    // 湲곗뾽援щ텇
+                    this.setCompanyFormCompanyType(cellStr, companyTypeMaps, companyFieldForm, rowIndex, isNull);
                     break;
 
                 case 10:
-                    // 吏��뿭
-                    if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
-                        this.setCompanyFormRegion(cell, regionMaps, companyFieldForm, rowIndex);
-                    }
+                    // �뾽醫�(��遺꾨쪟)
+                    this.setCompanyFormParentSector(cellStr, parentSectorMaps, companyFieldForm, rowIndex, isNull);
                     break;
 
                 case 11:
-                    // �긽�깭
-                    if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
-                        this.setCompanyFormStatus(cell, statusMaps, companyFieldForm, rowIndex);
-                    }
+                    // �뾽醫�(以묐텇瑜�)
+                    this.setCompanyFormChildSector(cellStr, childSectorMaps, companyFieldForm, rowIndex, isNull);
+                    break;
 
                 case 12:
-                    // 鍮꾧퀬
-                    if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
-                        this.setCompanyFormMemo(cell, companyFieldForm, rowIndex);
-                    }
+                    // 吏��뿭
+                    this.setCompanyFormRegion(cellStr, regionMaps, companyFieldForm, rowIndex, isNull);
                     break;
+
+                case 13:
+                    // �긽�깭
+                    this.setCompanyFormStatus(cellStr, statusMaps, companyFieldForm, isNull);
+                    break;
+
+                case 14:
+                    // 鍮꾧퀬
+                    this.setCompanyFormMemo(cellStr, companyFieldForm, isNull);
             }
         }
 
         return companyFieldForm;
     }
 
-    private void setCompanyFormMemo(Cell cell, CompanyFieldForm companyFieldForm, int rowIndex) {
-        companyFieldForm.setMemo(CommonUtil.convertExcelStringToCell(cell));
+    private void setCompanyFormIpEnd(String ipEnd, CompanyFieldForm companyFieldForm, boolean isNull) {
+        if (!isNull) {
+            if (ipEnd.contains(" ")) {
+                ipEnd = ipEnd.replace(" ", "");
+            }
+            this.verifyIp(ipEnd, null); //ip �쑀�슚�꽦 寃��궗
+
+            companyFieldForm.setIpEnd(ipEnd);
+        }
     }
 
-    private void setCompanyFormStatus(Cell cell, Map<String, Map<String, Object>> statusMaps, CompanyFieldForm companyFieldForm, int rowIndex) {
-        if (cell != null) {
-            Map<String, Object> statusMap = statusMaps.get(CommonUtil.convertExcelStringToCell(cell));
+    private void setCompanyFormIpStart(String ipStart, CompanyFieldForm companyFieldForm, boolean isNull) {
+        if (!isNull) {
+            if (ipStart.contains(" ")) {
+                ipStart = ipStart.replace(" ", "");
+            }
+            this.verifyIp(ipStart, null); //ip �쑀�슚�꽦 寃��궗
+
+            companyFieldForm.setIpStart(ipStart);
+        }
+    }
+
+    private void setCompanyFormMemo(String cellStr, CompanyFieldForm companyFieldForm, boolean isNull) {
+        if (!isNull) {
+            companyFieldForm.setMemo(cellStr);
+        }
+    }
+
+    private void setCompanyFormStatus(String cellStr, Map<String, Map<String, Object>> statusMaps, CompanyFieldForm companyFieldForm, boolean isNull) {
+        if (!isNull) {
+            Map<String, Object> statusMap = statusMaps.get(cellStr);
             if (MapUtil.getLong(statusMap, "id") != null) {
                 companyFieldForm.setStatusId(MapUtil.getLong(statusMap, "id"));
             } else {
                 companyFieldForm.setStatusId(120L);
             }
-            companyFieldForm.setStatusName(CommonUtil.convertExcelStringToCell(cell));
+            companyFieldForm.setStatusName(cellStr);
         }
     }
 
-    private void setCompanyFormRegion(Cell cell, Map<String, Map<String, Object>> regionMaps, CompanyFieldForm companyFieldForm, int rowIndex) {
-        if (cell != null) {
-            Map<String, Object> regionMap = regionMaps.get(CommonUtil.convertExcelStringToCell(cell));
+    private void setCompanyFormRegion(String cellStr, Map<String, Map<String, Object>> regionMaps, CompanyFieldForm companyFieldForm, int rowIndex, boolean isNull) {
+        if (!isNull) {
+            Map<String, Object> regionMap = regionMaps.get(cellStr);
             if (regionMap == null) {
                 throw new OwlRuntimeException(
                         this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_REGION_NOT_EXIST, rowIndex));
@@ -525,20 +697,29 @@
         }
     }
 
-    private void setCompanyFormChildSector(Cell cell, Map<String, Map<String, Object>> childSectorMaps, CompanyFieldForm companyFieldForm, int rowIndex) {
-        if (cell != null) {
-            Map<String, Object> childSectorMap = childSectorMaps.get(CommonUtil.convertExcelStringToCell(cell));
+    private void setCompanyFormChildSector(String cellStr, Map<String, Map<String, Object>> childSectorMaps, CompanyFieldForm companyFieldForm, int rowIndex, boolean isNull) {
+        if (!isNull) {
+            Map<String, Object> childSectorMap = childSectorMaps.get(cellStr);
+
+            //  ��遺꾨쪟 �뾾�씠 以묐텇瑜섎쭔 �엯�젰�뻽�쓣寃쎌슦
+            if (companyFieldForm.getParentSectorId() == null) {
+                throw new OwlRuntimeException(
+                        this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PARENT_SECTOR_IS_NULL, rowIndex));
+            }
+
+            //  以묐텇瑜섍� ��遺꾨쪟�뿉 �냽�빐�엳吏� �븡�뒗 寃쎌슦
             if (!companyFieldForm.getParentSectorId().equals(MapUtil.getLong(childSectorMap, "parentId"))) {
                 throw new OwlRuntimeException(
                         this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PARENT_SECTOR_NOT_EQUAL, rowIndex));
             }
+
             companyFieldForm.setChildSectorId(MapUtil.getLong(childSectorMap, "id"));
         }
     }
 
-    private void setCompanyFormParentSector(Cell cell, Map<String, Map<String, Object>> parentSectorMaps, CompanyFieldForm companyFieldForm, int rowIndex) {
-        if (cell != null) {
-            Map<String, Object> parentSectorMap = parentSectorMaps.get(CommonUtil.convertExcelStringToCell(cell));
+    private void setCompanyFormParentSector(String cellStr, Map<String, Map<String, Object>> parentSectorMaps, CompanyFieldForm companyFieldForm, int rowIndex, boolean isNull) {
+        if (!isNull) {
+            Map<String, Object> parentSectorMap = parentSectorMaps.get(cellStr);
             if (parentSectorMap == null) {
                 throw new OwlRuntimeException(
                         this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PARENT_SECTOR_NOT_EXIST, rowIndex));
@@ -547,9 +728,9 @@
         }
     }
 
-    private void setCompanyFormCompanyType(Cell cell, Map<String, Map<String, Object>> companyTypeMaps, CompanyFieldForm companyFieldForm, int rowIndex) {
-        if (cell != null) {
-            Map<String, Object> companyTypeMap = companyTypeMaps.get(CommonUtil.convertExcelStringToCell(cell));
+    private void setCompanyFormCompanyType(String cellStr, Map<String, Map<String, Object>> companyTypeMaps, CompanyFieldForm companyFieldForm, int rowIndex, boolean isNull) {
+        if (!isNull) {
+            Map<String, Object> companyTypeMap = companyTypeMaps.get(cellStr);
             if (companyTypeMap == null) {
                 throw new OwlRuntimeException(
                         this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_COMPANY_TYPE_NOT_EXIST, rowIndex));
@@ -558,28 +739,68 @@
         }
     }
 
-    private void setCompanyFormManager(Cell cell, CompanyFieldForm companyFieldForm, int rowIndex) {
-        if (cell != null) {
-            companyFieldForm.setManager(CommonUtil.convertExcelStringToCell(cell));
+    private void setCompanyFormManager(String manager, CompanyFieldForm companyFieldForm, boolean isNull) {
+        if (!isNull) {
+            companyFieldForm.setManager(manager);
         }
     }
 
-    private void setCompanyFormEmail(Cell cell, CompanyFieldForm companyFieldForm, int rowIndex) {
-        if (cell != null) {
-            companyFieldForm.setEmail(CommonUtil.convertExcelStringToCell(cell));
+    private void setCompanyFormEmail(String email, CompanyFieldForm companyFieldForm, boolean isNull) {
+        if (!isNull) {
+            //  �씠硫붿씪 �쑀�슚�꽦 寃��궗
+            email = this.verifyEmail(email);
+            companyFieldForm.setEmail(email);
         }
     }
 
-    private void setCompanyFormTel(Cell cell, CompanyFieldForm companyFieldForm, int rowIndex) {
-        if (cell != null) {
-            companyFieldForm.setTel(CommonUtil.convertExcelStringToCell(cell));
+    /**
+     * �씠硫붿씪 �쑀�슚�꽦 寃��궗
+     * @param email String
+     * @return String
+     */
+    private String verifyEmail(String email) {
+        if (!Pattern.matches("^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$", email)) {
+            throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.EMAIL_NOT_INVALID));
+        }
+
+        if (email.contains(" ")) {
+            email = email.replace(" ", "");
+        }
+
+        return email;
+    }
+
+    private void setCompanyFormTel(String tel, CompanyFieldForm companyFieldForm, boolean isNull) {
+        if (!isNull) {
+            //  �뿰�씫泥� �쑀�슚�꽦 寃��궗
+            tel = this.verifyTel(tel);
+            companyFieldForm.setTel(tel);
         }
     }
 
-    private void setCompanyFormHostingName(Cell cell, Map<String, HostingField> hostingFieldMaps, CompanyFieldForm companyFieldForm, int rowIndex) {
-        if (cell != null) {
+    /**
+     * �뿰�씫泥� �쑀�슚�꽦 寃��궗
+     * @param tel String
+     * @return String
+     */
+    private String verifyTel(String tel) {
+        if (!Pattern.matches("^[0-9-]{2,20}$", tel)) {
+            throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.TEL_NOT_INVALID));
+        }
 
-            HostingField hostingField = hostingFieldMaps.get(CommonUtil.convertExcelStringToCell(cell));
+        if (tel.contains("-")) {
+            tel = tel.replace("-", "");
+        }
+        if (tel.contains(" ")) {
+            tel = tel.replace(" ", "");
+        }
+
+        return tel;
+    }
+
+    private void setCompanyFormHostingName(String cellStr, Map<String, HostingField> hostingFieldMaps, CompanyFieldForm companyFieldForm, int rowIndex, boolean isNull) {
+        if (!isNull) {
+            HostingField hostingField = hostingFieldMaps.get(cellStr);
             if (hostingField == null) {
                 throw new OwlRuntimeException(
                         this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_HOSTING_NOT_EXIST, rowIndex));
@@ -588,10 +809,9 @@
         }
     }
 
-    private void setCompanyFormIspName(Cell cell, Map<String, IspField> ispFieldMaps, CompanyFieldForm companyFieldForm, int rowIndex) {
-        if (cell != null) {
-
-            IspField ispField = ispFieldMaps.get(CommonUtil.convertExcelStringToCell(cell));
+    private void setCompanyFormIspName(String cellStr, Map<String, IspField> ispFieldMaps, CompanyFieldForm companyFieldForm, int rowIndex, boolean isNull) {
+        if (!isNull) {
+            IspField ispField = ispFieldMaps.get(cellStr);
             if (ispField == null) {
                 throw new OwlRuntimeException(
                         this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_ISP_NOT_EXIST, rowIndex));
@@ -600,40 +820,49 @@
         }
     }
 
-    private void setCompanyFormName(Cell cell, CompanyFieldForm companyFieldForm, int rowIndex) {
-        if (cell == null) {
-            throw new OwlRuntimeException(
-                    this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_COMPANY_NAME_IS_NULL, rowIndex));
-        }
-
-        String title = CommonUtil.convertExcelStringToCell(cell);
-
+    private void setCompanyFormName(String title, CompanyFieldForm companyFieldForm) {
         //  �뾽泥대챸 �쑀�슚�꽦 泥댄겕
-        this.verifyTitle(title);
+        this.verifyTitle(title, null);
         companyFieldForm.setName(title);
     }
 
-    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);
-        this.verifyUrl(url, null); //url �쑀�슚�꽦 寃��궗
+    private void setCompanyFormUrl(String url, CompanyFieldForm companyFieldForm, boolean isNull) {
+        if (!isNull) {
+            if (url.contains(" ")) {
+                url = url.replace(" ", "");
+            }
+            this.verifyUrl(url, null); //url �쑀�슚�꽦 寃��궗
 
-        companyFieldForm.setUrl(url);
+            companyFieldForm.setUrl(url);
+        }
     }
 
     //  �뾽泥대챸 �쑀�슚�꽦 泥댄겕
-    private void verifyTitle(String title) {
-        if (StringUtils.isEmpty(title)) {
+    private void verifyTitle(String title, Long id) {
+        List<CompanyField> companyFields = new ArrayList<>();
+
+        //  �뾽泥대챸 以묐났 泥댄겕
+
+        if (id != null) { //�닔�젙 �씪 寃쎌슦
+            companyFields = this.companyFieldRepository.findByNameAndIdNot(title, id);
+        } else { // 異붽� �씪 寃쎌슦
+            companyFields = this.companyFieldRepository.findByName(title);
+        }
+        if (companyFields != null && companyFields.size() > 0) {
             throw new OwlRuntimeException(
-                    this.messageAccessor.getMessage(MsgConstants.ISSUE_NO_TITLE));
+                    this.messageAccessor.getMessage(MsgConstants.COMPANY_NAME_ALREADY_IN_USE));
         }
 
+        //  �뾽泥대챸 鍮덇컪 泥댄겕
+        if (StringUtils.isEmpty(title)) {
+            throw new OwlRuntimeException(
+                    this.messageAccessor.getMessage(MsgConstants.COMPANY_NO_TITLE));
+        }
+
+        //  �뾽泥대챸 湲몄씠 泥댄겕
         if (title.length() > 300) {
             throw new OwlRuntimeException(
-                    this.messageAccessor.getMessage(MsgConstants.ISSUE_TITLE_MAX_LENGTH_OUT));
+                    this.messageAccessor.getMessage(MsgConstants.COMPANY_NAME_MAX_LENGTH_OUT));
         }
     }
 
@@ -654,6 +883,19 @@
 
         CompanyFieldCondition companyFieldCondition = CompanyFieldCondition.make(conditions);
         List<Map<String, Object>> results = this.companyFieldMapper.find(companyFieldCondition);
+        CompanyFieldVo companyFieldVo = new CompanyFieldVo();
+
+        if (results != null && results.size() > 0) {
+            for (Map<String, Object> result : results) {
+                CompanyField companyField = ConvertUtil.convertMapToClass(result, CompanyField.class);
+                CompanyFieldVo companyFieldVo2 = CreateCompanyFieldCategory(companyFieldVo, companyField);
+
+                result.put("companyTypeName", companyFieldVo2.getCompanyTypeName());
+                result.put("parentSectorName", companyFieldVo2.getParentSectorName());
+                result.put("childSectorName", companyFieldVo2.getChildSectorName());
+                result.put("regionName", companyFieldVo2.getRegionName());
+            }
+        }
         List<CompanyFieldVo> companyFieldVos = ConvertUtil.convertListToListClass(results, CompanyFieldVo.class);
 
         // code_ko_KR �뿉 code紐� �꽕�젙
@@ -664,6 +906,7 @@
         excelInfo.addAttrInfos(new ExportExcelAttrVo("tel", this.messageAccessor.message("companyField.companyTel"), 10, ExportExcelAttrVo.ALIGN_CENTER));
         excelInfo.addAttrInfos(new ExportExcelAttrVo("email", this.messageAccessor.message("companyField.companyEmail"), 10, ExportExcelAttrVo.ALIGN_CENTER));
         excelInfo.addAttrInfos(new ExportExcelAttrVo("url", this.messageAccessor.message("companyField.companyUrl"), 10, ExportExcelAttrVo.ALIGN_CENTER));
+        excelInfo.addAttrInfos(new ExportExcelAttrVo("ipRange", this.messageAccessor.message("companyField.companyIp"), 10, ExportExcelAttrVo.ALIGN_CENTER));
         excelInfo.addAttrInfos(new ExportExcelAttrVo("companyTypeName", this.messageAccessor.message("companyField.companyTypeName"), 10, ExportExcelAttrVo.ALIGN_CENTER));
         excelInfo.addAttrInfos(new ExportExcelAttrVo("parentSectorName", this.messageAccessor.message("companyField.parentSectorName"), 10, ExportExcelAttrVo.ALIGN_CENTER));
         excelInfo.addAttrInfos(new ExportExcelAttrVo("childSectorName", this.messageAccessor.message("companyField.childSectorName"), 10, ExportExcelAttrVo.ALIGN_CENTER));
@@ -752,13 +995,13 @@
     public CompanyField getCompany(Long id) {
         if (id == null) {
             throw new OwlRuntimeException(
-                    this.messageAccessor.getMessage(MsgConstants.COMPANYFIELD_NOT_EXIST));
+                    this.messageAccessor.getMessage(MsgConstants.COMPANY_NOT_EXIST));
         }
         CompanyField companyField = this.findOne(id);
 
         if (companyField == null) {
             throw new OwlRuntimeException(
-                    this.messageAccessor.getMessage(MsgConstants.COMPANYFIELD_NOT_EXIST));
+                    this.messageAccessor.getMessage(MsgConstants.COMPANY_NOT_EXIST));
         }
         return companyField;
     }

--
Gitblit v1.8.0