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 |   59 ++++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 44 insertions(+), 15 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 62f8272..8e87053 100644
--- a/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
+++ b/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
@@ -3454,11 +3454,25 @@
      * @param cell Cell
      * @return boolean
      */
-    private Boolean cellNullCheck (Cell cell) {
-        if (cell != null && cell.getStringCellValue() != null) {
-            cell.setCellValue(cell.getStringCellValue().trim());//�� 媛� 怨듬갚 �젣嫄�
+    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));
         }
-        return cell != null && cell.getStringCellValue() != null && !cell.getStringCellValue().equals("") && cell.getCellType() != Cell.CELL_TYPE_BLANK;
+        //  怨듬갚 �젣嫄�
+        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 �쑝濡� �삷湲대떎.
@@ -3481,7 +3495,7 @@
                     break;
 
                 case 1:    //  �궡�슜
-                    if (cellNullCheck(cell)) {
+                    if (cellNullCheck(cell, rowIndex)) {
                         issueForm.setDescription(CommonUtil.convertExcelStringToCell(cell));
                     } else {
                         //  null �엯�젰 諛⑹�
@@ -3505,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;
@@ -3583,7 +3597,7 @@
 
     //  �씠�뒋 �젣紐⑹쓣 IssueForm �뿉 ���옣�븳�떎.
     private void setIssueFormTitle(Cell cell, IssueForm issueForm, int rowIndex) {
-        if (!cellNullCheck(cell)) {
+        if (!cellNullCheck(cell, rowIndex)) {
             throw new OwlRuntimeException(
                     this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_ISSUE_TITLE_IS_NULL, rowIndex));
         }
@@ -3631,7 +3645,7 @@
 
     //  �슦�꽑�닚�쐞瑜� IssueForm �뿉 ���옣�븳�떎.
     private void setIssueFormPriority(Cell cell, Map<String, Priority> priorityMaps, IssueForm issueForm, int rowIndex) {
-        if (!cellNullCheck(cell)) {
+        if (!cellNullCheck(cell, rowIndex)) {
             throw new OwlRuntimeException(
                     this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PRIORITY_IS_NULL, rowIndex));
         }
@@ -3648,7 +3662,7 @@
 
     //  以묒슂�룄瑜� IssueForm �뿉 ���옣�븳�떎.
     private void setIssueFormSeverity(Cell cell, Map<String, Severity> severityMaps, IssueForm issueForm, int rowIndex) {
-        if (!cellNullCheck(cell)) {
+        if (!cellNullCheck(cell, rowIndex)) {
             throw new OwlRuntimeException(
                     this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_SEVERITY_IS_NULL, rowIndex));
         }
@@ -3684,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;
@@ -3701,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 {
                     //  �궇吏� �쑀�슚�꽦 泥댄겕
@@ -3715,7 +3740,7 @@
 
     //  �궗�슜�옄 �젙�쓽 �븘�뱶 �젙蹂대�� IssueForm �뿉 ���옣�븳�떎.-
     private void setIssueFormCustomFieldValue(Cell cell, Map<String, CustomField> customFieldMaps, IssueForm issueForm, String customFieldName, int rowIndex) {
-        if (!cellNullCheck(cell)) {
+        if (cell != null) {
             String cellValue = CommonUtil.convertExcelStringToCell(cell);
             Map<String, Object> issueCustomFieldMap = new HashMap<>();
             CustomField customField = customFieldMaps.get(customFieldName);
@@ -3745,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