From 6c05919c8fdaeca34a81bf0a84e5ae12dc99d1e0 Mon Sep 17 00:00:00 2001 From: jhjang <jhjang@maprex.co.kr> Date: 월, 07 2월 2022 17:58:13 +0900 Subject: [PATCH] - 임포트 로직 수정중 - 인터넷진흥원 설정파일 수정 --- src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java | 329 +++++++++++++++++++++++++----------------------------- 1 files changed, 155 insertions(+), 174 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 8e87053..45418f0 100644 --- a/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java +++ b/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java @@ -46,6 +46,7 @@ import javax.servlet.http.HttpServletRequest; import java.io.IOException; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; @@ -867,15 +868,28 @@ } } - // �궇吏� �쑀�슚�꽦 泥댄겕 + /** + * �궇吏� �쑀�슚�꽦 泥댄겕 + * @param startDate �떆�옉 �씪�옄(臾몄옄) + * @param completeDate 醫낅즺 �씪�옄(臾몄옄) + */ private void checkStartCompleteDate(String startDate, String completeDate) { if (!StringUtils.isEmpty(startDate) && !StringUtils.isEmpty(completeDate)) { Date start = DateUtil.convertStrToDate(startDate, "yy-MM-dd"); Date end = DateUtil.convertStrToDate(completeDate, "yy-MM-dd"); - if (start.getTime() > end.getTime()) { - throw new OwlRuntimeException( - this.messageAccessor.getMessage(MsgConstants.DATE_PICKER_NOT_AVAILABLE)); - } + checkStartCompleteDate(start, end); + } + } + + /** + * �궇吏� �쑀�슚�꽦 泥댄겕 + * @param start �떆�옉 �씪�옄 + * @param end 醫낅즺 �씪�옄 + */ + private void checkStartCompleteDate(Date start, Date end) { + if (start.getTime() > end.getTime()) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.DATE_PICKER_NOT_AVAILABLE)); } } @@ -3451,36 +3465,30 @@ /** * cell NULL 泥댄겕 �븿�닔 + * 臾몄옄�삎�떇 cell 泥댄겕 * @param cell Cell * @return boolean */ - 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)); + private Boolean cellNullCheck (Cell cell) { + if (cell != null ) { + if (cell.getCellType() != Cell.CELL_TYPE_BLANK) { + if (cell.getCellType() == Cell.CELL_TYPE_STRING && cell.getStringCellValue() != null) { + return false; + } + } } - // 怨듬갚 �젣嫄� - 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; + return true; } + + + // �뿊�� �븘�뱶�뿉 �엳�뒗 �젙蹂대�� �씠�뒋 form �쑝濡� �삷湲대떎. private IssueForm setIssueFormToExcelField(Row row, int rowIndex, Map<String, Priority> priorityMaps, Map<String, Severity> severityMaps, Map<String, DepartmentVo> departmentMaps, Map<String, CustomField> customFieldMaps, Map<String, CompanyField> companyFieldMaps, Map<String, IspField> ispFieldMaps, Map<String, HostingField> hostingFieldMaps, - List<String> headers) { + List<String> headers) throws ParseException { IssueForm issueForm = new IssueForm(); issueForm.setRegisterId(this.webAppUtil.getLoginId()); Project project = null; @@ -3488,30 +3496,48 @@ // �젣紐�, �궡�슜, �봽濡쒖젥�듃 �궎, �씠�뒋 ���엯, �슦�꽑�닚�쐞, 以묒슂�룄, �떞�떦�옄, �떆�옉�씪, 醫낅즺�씪, �궗�슜�옄 �젙�쓽 �븘�뱶 for (int cellIndex = 0; cellIndex < headers.size(); cellIndex++) { Cell cell = row.getCell(cellIndex); + boolean isNull = cellNullCheck(cell); + + String cellStr = ""; + if (!isNull) { + cellStr = CommonUtil.convertExcelStringToCell(cell); + + // 怨듬갚 �젣嫄� + cell.setCellValue(cellStr.trim()); + } else { + cell.setCellValue(cellStr); + } + switch (cellIndex) { case 0: // �씠�뒋 �젣紐⑹쓣 IssueForm �뿉 ���옣�븳�떎. - this.setIssueFormTitle(cell, issueForm, rowIndex); + if (isNull) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_ISSUE_TITLE_IS_NULL, rowIndex)); + } + this.setIssueFormTitle(cellStr, issueForm, rowIndex); break; case 1: // �궡�슜 - if (cellNullCheck(cell, rowIndex)) { - issueForm.setDescription(CommonUtil.convertExcelStringToCell(cell)); - } else { - // null �엯�젰 諛⑹� - issueForm.setDescription(""); - } - + issueForm.setDescription(cellStr); break; case 2: // �슦�꽑�닚�쐞瑜� IssueForm �뿉 ���옣�븳�떎. - this.setIssueFormPriority(cell, priorityMaps, issueForm, rowIndex); + if (isNull) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PRIORITY_IS_NULL, rowIndex)); + } + this.setIssueFormPriority(cellStr, priorityMaps, issueForm, rowIndex); break; case 3: // 以묒슂�룄瑜� IssueForm �뿉 ���옣�븳�떎. - this.setIssueFormSeverity(cell, severityMaps, issueForm, rowIndex); + if (isNull) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_SEVERITY_IS_NULL, rowIndex)); + } + this.setIssueFormSeverity(cellStr, severityMaps, issueForm, rowIndex); break; /*case 6: // �떞�떦�옄瑜� IssueForm �뿉 ���옣�븳�떎. @@ -3519,47 +3545,37 @@ break;*/ case 4: // �떆�옉�씪�쓣 IssueForm �뿉 ���옣�븳�떎. - if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) { - this.setIssueFormPeriod(cell, issueForm, true, rowIndex); - } + this.setIssueFormPeriod(cellStr, issueForm, true, rowIndex, isNull); break; case 5: // 醫낅즺�씪�쓣 IssueForm �뿉 ���옣�븳�떎. - if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) { - this.setIssueFormPeriod(cell, issueForm, false, rowIndex); - } + this.setIssueFormPeriod(cellStr, issueForm, false, rowIndex, isNull); break; case 6: // �뾽泥대�� IssueForm �뿉 ���옣�븳�떎. - if (cellNullCheck(cell, rowIndex)) { - this.setIssueFormCompanyField(cell, companyFieldMaps, issueForm, rowIndex); - } + this.setIssueFormCompanyField(cellStr, companyFieldMaps, issueForm, rowIndex); break; case 7: // ISP瑜� IssueForm �뿉 ���옣�븳�떎. - if (cellNullCheck(cell, rowIndex)) { - this.setIssueFormIspField(cell, ispFieldMaps, issueForm, rowIndex); - } + this.setIssueFormIspField(cellStr, ispFieldMaps, issueForm, rowIndex); break; case 8: // �샇�뒪�똿�쓣 IssueForm �뿉 ���옣�븳�떎. - if (cellNullCheck(cell, rowIndex)) { - this.setIssueFormHostingField(cell, hostingFieldMaps, issueForm, rowIndex); - } + this.setIssueFormHostingField(cellStr, hostingFieldMaps, issueForm, rowIndex); break; default: // 9踰� 遺��꽣�뒗 �궗�슜�옄 �젙�쓽 �븘�뱶. �궗�슜�옄 �젙�쓽 �븘�뱶 �젙蹂대�� IssueForm �뿉 ���옣�븳�떎. - this.setIssueFormCustomFieldValue(cell, customFieldMaps, issueForm, headers.get(cellIndex), rowIndex); + this.setIssueFormCustomFieldValue(cellStr, customFieldMaps, issueForm, headers.get(cellIndex), rowIndex); } } return issueForm; } - private void setIssueFormHostingField(Cell cell, Map<String, HostingField> hostingFieldMaps, IssueForm issueForm, int rowIndex) { - if (cell != null) { + private void setIssueFormHostingField(String cell, Map<String, HostingField> hostingFieldMaps, IssueForm issueForm, int rowIndex) { + if (cell.length() > 0) { Map<String, Object> issueHostingFields = new HashMap<>(); - HostingField hostingFieldMap = hostingFieldMaps.get(CommonUtil.convertExcelStringToCell(cell)); + HostingField hostingFieldMap = hostingFieldMaps.get(cell); if (hostingFieldMap == null) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_HOSTING_NOT_EXIST, rowIndex)); @@ -3569,10 +3585,10 @@ } } - private void setIssueFormIspField(Cell cell, Map<String, IspField> ispFieldMaps, IssueForm issueForm, int rowIndex) { - if (cell != null) { + private void setIssueFormIspField(String cell, Map<String, IspField> ispFieldMaps, IssueForm issueForm, int rowIndex) { + if (cell.length() > 0) { Map<String, Object> issueIspFields = new HashMap<>(); - IspField ispFieldMap = ispFieldMaps.get(CommonUtil.convertExcelStringToCell(cell)); + IspField ispFieldMap = ispFieldMaps.get(cell); if (ispFieldMap == null) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_ISP_NOT_EXIST, rowIndex)); @@ -3582,10 +3598,10 @@ } } - private void setIssueFormCompanyField(Cell cell, Map<String, CompanyField> companyFieldMaps, IssueForm issueForm, int rowIndex) { - if (cell != null) { + private void setIssueFormCompanyField(String cell, Map<String, CompanyField> companyFieldMaps, IssueForm issueForm, int rowIndex) { + if (cell.length() > 0) { Map<String, Object> issueCompanyFields = new HashMap<>(); - CompanyField companyFieldMap = companyFieldMaps.get(CommonUtil.convertExcelStringToCell(cell)); + CompanyField companyFieldMap = companyFieldMaps.get(cell); if (companyFieldMap == null) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_COMPANY_NOT_EXIST, rowIndex)); @@ -3596,14 +3612,7 @@ } // �씠�뒋 �젣紐⑹쓣 IssueForm �뿉 ���옣�븳�떎. - private void setIssueFormTitle(Cell cell, IssueForm issueForm, int rowIndex) { - if (!cellNullCheck(cell, rowIndex)) { - throw new OwlRuntimeException( - this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_ISSUE_TITLE_IS_NULL, rowIndex)); - } - - String title = CommonUtil.convertExcelStringToCell(cell); - + private void setIssueFormTitle(String title, IssueForm issueForm, int rowIndex) { // �젣紐� �쑀�슚�꽦 泥댄겕 this.verifyTitle(title); issueForm.setTitle(title); @@ -3644,13 +3653,8 @@ // �슦�꽑�닚�쐞瑜� IssueForm �뿉 ���옣�븳�떎. - private void setIssueFormPriority(Cell cell, Map<String, Priority> priorityMaps, IssueForm issueForm, int rowIndex) { - if (!cellNullCheck(cell, rowIndex)) { - throw new OwlRuntimeException( - this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PRIORITY_IS_NULL, rowIndex)); - } - - Priority priority = priorityMaps.get(CommonUtil.convertExcelStringToCell(cell)); + private void setIssueFormPriority(String priorityStr, Map<String, Priority> priorityMaps, IssueForm issueForm, int rowIndex) { + Priority priority = priorityMaps.get(priorityStr); if (priority == null) { throw new OwlRuntimeException( @@ -3661,13 +3665,8 @@ } // 以묒슂�룄瑜� IssueForm �뿉 ���옣�븳�떎. - private void setIssueFormSeverity(Cell cell, Map<String, Severity> severityMaps, IssueForm issueForm, int rowIndex) { - if (!cellNullCheck(cell, rowIndex)) { - throw new OwlRuntimeException( - this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_SEVERITY_IS_NULL, rowIndex)); - } - - Severity severity = severityMaps.get(CommonUtil.convertExcelStringToCell(cell)); + private void setIssueFormSeverity(String strSeverity, Map<String, Severity> severityMaps, IssueForm issueForm, int rowIndex) { + Severity severity = severityMaps.get(strSeverity); if (severity == null) { throw new OwlRuntimeException( @@ -3693,33 +3692,19 @@ } } // �떆�옉�씪, 醫낅즺�씪�쓣 IssueForm �뿉 ���옣�븳�떎. - private void setIssueFormPeriod(Cell cell, IssueForm issueForm, Boolean checkStartDate, int rowIndex) { - if (cell != null && !cell.toString().equals("")) { + private void setIssueFormPeriod(String periodDate, IssueForm issueForm, Boolean checkStartDate, int rowIndex, boolean isNull) throws ParseException { + if (!isNull) { - // 媛믪씠 怨듬갚�씠硫� 以묒� - String cellValue = CommonUtil.convertExcelStringToCell(cell); - 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; - - try { - startDate = cell.getDateCellValue(); - } catch (Exception e) { + Date startDate = DateUtil.convertStrToDateOnly(periodDate); + if (startDate == null) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PERIOD_NOT_VALIDITY_EMPTY, rowIndex)); } if (checkStartDate) { - issueForm.setStartDate(DateUtil.convertDateToStr(startDate, "yyyy-MM-dd")); + issueForm.setStartDate(periodDate); } else { - issueForm.setCompleteDate(DateUtil.convertDateToStr(startDate, "yyyy-MM-dd")); + issueForm.setCompleteDate(periodDate); // 醫낅즺�씪留� �엯�젰 �뻽�쓣 寃쎌슦 if (issueForm.getCompleteDate() != null && issueForm.getStartDate() == null) { @@ -3739,93 +3724,89 @@ } // �궗�슜�옄 �젙�쓽 �븘�뱶 �젙蹂대�� IssueForm �뿉 ���옣�븳�떎.- - private void setIssueFormCustomFieldValue(Cell cell, Map<String, CustomField> customFieldMaps, IssueForm issueForm, String customFieldName, int rowIndex) { - if (cell != null) { - String cellValue = CommonUtil.convertExcelStringToCell(cell); - Map<String, Object> issueCustomFieldMap = new HashMap<>(); - CustomField customField = customFieldMaps.get(customFieldName); + private void setIssueFormCustomFieldValue(String cellValue, Map<String, CustomField> customFieldMaps, IssueForm issueForm, String customFieldName, int rowIndex) { + Map<String, Object> issueCustomFieldMap = new HashMap<>(); + CustomField customField = customFieldMaps.get(customFieldName); - if (customField == null) { - throw new OwlRuntimeException( - this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_HEADER_CUSTOM_FIELD_NOT_EXIST, rowIndex)); - } - // �궗�슜�옄 �젙�쓽 �븘�뱶 媛믪씠 怨듬갚�씠硫� 以묒� - if (StringUtils.isEmpty(cellValue)) { - return; - } + if (customField == null) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_HEADER_CUSTOM_FIELD_NOT_EXIST, rowIndex)); + } + // �궗�슜�옄 �젙�쓽 �븘�뱶 媛믪씠 怨듬갚�씠硫� 以묒� + if (StringUtils.isEmpty(cellValue)) { + return; + } - boolean validity = false; + boolean validity = false; - switch (customField.getCustomFieldType()) { - case INPUT: - case NUMBER: - case DATETIME: - case IP_ADDRESS: - case EMAIL: - case SITE: - case TEL: - if (customField.getCustomFieldType() != INPUT && cellValue.length() > 100) { //INPUT ���엯�� 100�옄 �젣�븳 �뾾�쓬 + switch (customField.getCustomFieldType()) { + case INPUT: + case NUMBER: + case DATETIME: + case IP_ADDRESS: + case EMAIL: + case SITE: + case TEL: + if (customField.getCustomFieldType() != INPUT && cellValue.length() > 100) { //INPUT ���엯�� 100�옄 �젣�븳 �뾾�쓬 + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.CUSTOM_FIELD_TEXT_TYPE_MAX_LENGTH_OUT)); + } + + if (customField.getCustomFieldType() == DATETIME) { //DATETIME�씪 寃쎌슦 format 蹂�寃� + Date date = DateUtil.convertStrToDate(cellValue); + if (date == null) { throw new OwlRuntimeException( - this.messageAccessor.getMessage(MsgConstants.CUSTOM_FIELD_TEXT_TYPE_MAX_LENGTH_OUT)); + this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_DATETIME_NOT_DASH, rowIndex)); } + } - 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); + issueCustomFieldMap.put("customFieldId", customField.getId()); + issueCustomFieldMap.put("useValue", cellValue); + issueForm.addIssueCustomFields(issueCustomFieldMap); + break; + case SINGLE_SELECT: + // 媛� �쑀�슚�꽦 泥댄겕 + for (CustomFieldValue customFieldValue : customField.getCustomFieldValues()) { + if (customFieldValue.getValue().equals(cellValue)) { + validity = true; + break; } + } - issueCustomFieldMap.put("customFieldId", customField.getId()); - issueCustomFieldMap.put("useValue", cellValue); - issueForm.addIssueCustomFields(issueCustomFieldMap); - break; - case SINGLE_SELECT: - // 媛� �쑀�슚�꽦 泥댄겕 + if (!validity) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.EXCEL_CUSTOM_FIELD_VALUE_NOT_VALIDITY, rowIndex)); + } + + issueCustomFieldMap.put("customFieldId", customField.getId()); + issueCustomFieldMap.put("useValue", cellValue); + issueForm.addIssueCustomFields(issueCustomFieldMap); + + break; + case MULTI_SELECT: + // 媛� �쑀�슚�꽦 泥댄겕 + String[] useValues = cellValue.split("#"); + // �빐, �떖 + for (String useValue : useValues) { for (CustomFieldValue customFieldValue : customField.getCustomFieldValues()) { - if (customFieldValue.getValue().equals(cellValue)) { + + if (customFieldValue.getValue().equals(useValue)) { validity = true; - break; + Map<String, Object> multiValueMap = new HashMap<>(); + multiValueMap.put("customFieldId", customField.getId()); + multiValueMap.put("useValue", useValue); + issueForm.addIssueCustomFields(multiValueMap); } + } + } - if (!validity) { - throw new OwlRuntimeException( - this.messageAccessor.getMessage(MsgConstants.EXCEL_CUSTOM_FIELD_VALUE_NOT_VALIDITY, rowIndex)); - } + if (!validity) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.EXCEL_CUSTOM_FIELD_VALUE_NOT_VALIDITY, rowIndex)); + } - issueCustomFieldMap.put("customFieldId", customField.getId()); - issueCustomFieldMap.put("useValue", cellValue); - issueForm.addIssueCustomFields(issueCustomFieldMap); - - break; - case MULTI_SELECT: - // 媛� �쑀�슚�꽦 泥댄겕 - String[] useValues = cellValue.split("#"); - // �빐, �떖 - for (String useValue : useValues) { - for (CustomFieldValue customFieldValue : customField.getCustomFieldValues()) { - - if (customFieldValue.getValue().equals(useValue)) { - validity = true; - Map<String, Object> multiValueMap = new HashMap<>(); - multiValueMap.put("customFieldId", customField.getId()); - multiValueMap.put("useValue", useValue); - issueForm.addIssueCustomFields(multiValueMap); - } - - } - } - - if (!validity) { - throw new OwlRuntimeException( - this.messageAccessor.getMessage(MsgConstants.EXCEL_CUSTOM_FIELD_VALUE_NOT_VALIDITY, rowIndex)); - } - - break; - } + break; } } -- Gitblit v1.8.0