From a227dd7df7f84a5cfb7218042a6f844991dcfb96 Mon Sep 17 00:00:00 2001 From: 이민희 <mhlee@maprex.co.kr> Date: 수, 09 2월 2022 14:53:41 +0900 Subject: [PATCH] - isp, 호스팅 엑셀 import 기능 추가 --- src/main/webapp/views/hostingField/hostingFieldExcelImport.html | 83 +++ src/main/webapp/scripts/app/ispField/ispFieldImportExcel.controller.js | 80 +++ src/main/webapp/views/ispField/ispFieldList.html | 1 src/main/webapp/scripts/components/HostingField/hostingField.service.js | 11 src/main/java/kr/wisestone/owl/service/IspFieldService.java | 5 src/main/webapp/scripts/app/hostingField/hostingFieldImportExcel.controller.js | 80 +++ src/main/java/kr/wisestone/owl/service/impl/IspFieldServiceImpl.java | 327 ++++++++++++ src/main/java/kr/wisestone/owl/web/form/HostingFieldForm.java | 10 src/main/webapp/scripts/app/hostingField/hostingFieldList.controller.js | 18 src/main/webapp/scripts/app/ispField/ispFieldList.controller.js | 18 src/main/webapp/scripts/main.js | 2 src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java | 53 + src/main/webapp/scripts/app/hostingField/hostingField.js | 2 src/main/webapp/scripts/components/ispField/ispField.service.js | 9 src/main/webapp/views/hostingField/hostingFieldList.html | 1 src/main/java/kr/wisestone/owl/service/HostingFieldService.java | 5 src/main/java/kr/wisestone/owl/repository/IspFieldRepository.java | 6 src/main/java/kr/wisestone/owl/constant/MsgConstants.java | 17 src/main/webapp/WEB-INF/i18n/messages_ko_KR.properties | 20 src/main/webapp/scripts/app/ispField/ispField.js | 2 src/main/java/kr/wisestone/owl/web/controller/IspFieldController.java | 30 src/main/webapp/views/ispField/ispFieldExcelImport.html | 83 +++ src/main/java/kr/wisestone/owl/repository/HostingFieldRepository.java | 6 src/main/java/kr/wisestone/owl/service/impl/CompanyFieldServiceImpl.java | 209 ++++---- src/main/java/kr/wisestone/owl/web/controller/HostingFieldController.java | 30 src/main/java/kr/wisestone/owl/web/form/IspFieldForm.java | 10 src/main/java/kr/wisestone/owl/service/impl/HostingFieldServiceImpl.java | 322 ++++++++++++ src/main/java/kr/wisestone/owl/web/form/CompanyFieldForm.java | 2 src/main/webapp/i18n/ko/global.json | 13 src/main/webapp/WEB-INF/i18n/code_ko_KR.properties | 2 30 files changed, 1,278 insertions(+), 179 deletions(-) diff --git a/src/main/java/kr/wisestone/owl/constant/MsgConstants.java b/src/main/java/kr/wisestone/owl/constant/MsgConstants.java index cfa94ca..bb2aed3 100644 --- a/src/main/java/kr/wisestone/owl/constant/MsgConstants.java +++ b/src/main/java/kr/wisestone/owl/constant/MsgConstants.java @@ -202,6 +202,12 @@ public static final String EXCEL_IMPORT_CHILD_SECTOR_NOT_EXIST = "EXCEL_IMPORT_CHILD_SECTOR_NOT_EXIST"; // �떎�쓬 �뿊�� �씪�씤�뿉�꽌 �엯�젰�맂 �뾽醫낅챸�쑝濡� 寃��깋�릺�뒗 �뾽醫�(以묐텇瑜�)�씠 �뾾�뒿�땲�떎 public static final String EXCEL_IMPORT_REGION_NOT_EXIST = "EXCEL_IMPORT_REGION_NOT_EXIST"; // �떎�쓬 �뿊�� �씪�씤�뿉�꽌 �엯�젰�맂 吏��뿭紐낆쑝濡� 寃��깋�릺�뒗 吏��뿭�씠 �뾾�뒿�땲�떎 + public static final String EXCEL_IMPORT_ISP_NAME_IS_NULL = "EXCEL_IMPORT_ISP_NAME_IS_NULL"; // �떎�쓬 �뿊�� �씪�씤�뿉�꽌 ISP紐낆씠 �엯�젰�릺吏� �븡�븯�뒿�땲�떎. + public static final String EXCEL_IMPORT_ISP_CODE_IS_NULL = "EXCEL_IMPORT_ISP_CODE_IS_NULL"; // �떎�쓬 �뿊�� �씪�씤�뿉�꽌 肄붾뱶媛� �엯�젰�릺吏� �븡�븯�뒿�땲�떎. + + public static final String EXCEL_IMPORT_HOSTING_NAME_IS_NULL = "EXCEL_IMPORT_HOSTING_NAME_IS_NULL"; // �떎�쓬 �뿊�� �씪�씤�뿉�꽌 �샇�뒪�똿紐낆씠 �엯�젰�릺吏� �븡�븯�뒿�땲�떎. + public static final String EXCEL_IMPORT_HOSTING_CODE_IS_NULL = "EXCEL_IMPORT_HOSTING_CODE_IS_NULL"; // �떎�쓬 �뿊�� �씪�씤�뿉�꽌 肄붾뱶媛� �엯�젰�릺吏� �븡�븯�뒿�땲�떎. + public static final String DOWN_ISSUE_NOT_EXIST = "DOWN_ISSUE_NOT_EXIST"; // �븯�쐞 �씠�뒋 李얠쓣�닔 �뾾�쓬 public static final String NOTICE_NOT_EXIST = "NOTICE_NOT_EXIST"; // 怨듭��궗�빆�씠 議댁옱�븯吏� �븡�뒿�땲�떎. @@ -258,15 +264,22 @@ public static final String COMPANY_USED_URL = "COMPANY_USED_URL"; // URL�씠 �씠誘� �궗�슜�릺怨� �엳�뒿�땲�떎. public static final String COMPANY_NAME_MAX_LENGTH_OUT = "COMPANY_NAME_MAX_LENGTH_OUT"; // �뾽泥대챸�� 理쒕� 300湲��옄源뚯� �엯�젰�븷 �닔 �엳�뒿�땲�떎. - public static final String HOSTING_NOT_EXIST = "HOSTING_NOT_EXIST"; // �샇�뒪�똿�씠 議댁옱�븯吏� �븡�뒿�땲�떎. + public static final String HOSTING_NO_TITLE = "HOSTING_NO_TITLE"; // �샇�뒪�똿紐낆씠 �엯�젰�릺吏� �븡�븯�뒿�땲�떎. public static final String HOSTING_CODE_NOT_ENTER = "HOSTING_CODE_NOT_ENTER"; // �샇�뒪�똿�쓽 肄붾뱶�뒗 �븘�닔 �엯�젰 媛믪엯�땲�떎. public static final String HOSTING_REMOVE_NOT_SELECT = "HOSTING_REMOVE_NOT_SELECT"; // �궘�젣�븷 �샇�뒪�똿�씠 �꽑�깮�릺吏� �븡�븯�뒿�땲�떎. + public static final String HOSTING_NOT_EXIST = "HOSTING_NOT_EXIST"; // �샇�뒪�똿�씠 議댁옱�븯吏� �븡�뒿�땲�떎. + public static final String HOSTING_NAME_MAX_LENGTH_OUT = "HOSTING_NAME_MAX_LENGTH_OUT"; // �샇�뒪�똿紐낆� 理쒕� 300湲��옄源뚯� �엯�젰�븷 �닔 �엳�뒿�땲�떎. + public static final String HOSTING_NAME_ALREADY_IN_USE = "HOSTING_NAME_ALREADY_IN_USE"; // �빐�떦 �샇�뒪�똿紐낆� �씠誘� �벑濡앸릺�뼱 �엳�뒿�땲�떎. public static final String HOSTING_EXIST_COMPANY = "HOSTING_EXIST_COMPANY"; // �뾽泥댁뿉 �꽕�젙�릺�뼱�엳�뒗 �샇�뒪�똿�씠 議댁옱�빀�땲�떎. - public static final String ISP_NOT_EXIST = "ISP_NOT_EXIST"; // ISP媛� 議댁옱�븯吏� �븡�뒿�땲�떎. + public static final String ISP_NO_TITLE = "ISP_NO_TITLE"; // ISP紐낆씠 �엯�젰�릺吏� �븡�븯�뒿�땲�떎. public static final String ISP_CODE_NOT_ENTER = "ISP_CODE_NOT_ENTER"; // ISP�쓽 肄붾뱶�뒗 �븘�닔 �엯�젰 媛믪엯�땲�떎. public static final String ISP_REMOVE_NOT_SELECT = "ISP_REMOVE_NOT_SELECT"; // �궘�젣�븷 ISP媛� �꽑�깮�릺吏� �븡�븯�뒿�땲�떎. + public static final String ISP_NOT_EXIST = "ISP_NOT_EXIST"; // ISP媛� 議댁옱�븯吏� �븡�뒿�땲�떎. + public static final String ISP_NAME_MAX_LENGTH_OUT = "ISP_NAME_MAX_LENGTH_OUT"; // ISP紐낆� 理쒕� 300湲��옄源뚯� �엯�젰�븷 �닔 �엳�뒿�땲�떎. + public static final String ISP_NAME_ALREADY_IN_USE = "ISP_NAME_ALREADY_IN_USE"; // �빐�떦 ISP紐낆� �씠誘� �벑濡앸릺�뼱 �엳�뒿�땲�떎. public static final String ISP_EXIST_COMPANY = "ISP_EXIST_COMPANY"; // �뾽泥댁뿉 �꽕�젙�릺�뼱�엳�뒗 ISP媛� 議댁옱�빀�땲�떎. + public static final String PROJECT_NOT_INCLUDE_DEPARTMENT = "PROJECT_NOT_INCLUDE_DEPARTMENT"; // �꽑�깮�븳 遺��꽌 以� �봽濡쒖젥�듃�뿉 李몄뿬�븯怨� �엳吏� �븡�� 遺��꽌媛� �엳�뒿�땲�떎. public static final String EMAIL_TEMPLATE_NOT_EXIST = "EMAIL_TEMPLATE_NOT_EXIST"; // �씠硫붿씪 �뀥�뵆由우쓣 李얠쓣�닔 �뾾�뒿�땲�떎. diff --git a/src/main/java/kr/wisestone/owl/repository/HostingFieldRepository.java b/src/main/java/kr/wisestone/owl/repository/HostingFieldRepository.java index 528ac5a..617f8e5 100644 --- a/src/main/java/kr/wisestone/owl/repository/HostingFieldRepository.java +++ b/src/main/java/kr/wisestone/owl/repository/HostingFieldRepository.java @@ -6,8 +6,14 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.repository.query.Param; +import java.util.List; + public interface HostingFieldRepository extends JpaRepository<HostingField, Long> { HostingField findByUrl(@Param("url") String url); HostingField findByUrlAndIdNot(@Param("url") String url, @Param("id") Long id); + + List<HostingField> findByNameAndIdNot(@Param("name") String name, @Param("id") Long id); + + List<HostingField> findByName(@Param("name") String name); } diff --git a/src/main/java/kr/wisestone/owl/repository/IspFieldRepository.java b/src/main/java/kr/wisestone/owl/repository/IspFieldRepository.java index 8b4a52c..1ce0852 100644 --- a/src/main/java/kr/wisestone/owl/repository/IspFieldRepository.java +++ b/src/main/java/kr/wisestone/owl/repository/IspFieldRepository.java @@ -5,8 +5,14 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.repository.query.Param; +import java.util.List; + public interface IspFieldRepository extends JpaRepository<IspField, Long> { IspField findByUrl(@Param("url") String url); IspField findByUrlAndIdNot(@Param("url") String url, @Param("id") Long id); + + List<IspField> findByNameAndIdNot(@Param("name") String name, @Param("id") Long id); + + List<IspField> findByName(@Param("name") String name); } diff --git a/src/main/java/kr/wisestone/owl/service/HostingFieldService.java b/src/main/java/kr/wisestone/owl/service/HostingFieldService.java index a17b08d..3a6da5c 100644 --- a/src/main/java/kr/wisestone/owl/service/HostingFieldService.java +++ b/src/main/java/kr/wisestone/owl/service/HostingFieldService.java @@ -7,6 +7,7 @@ import kr.wisestone.owl.web.form.HostingFieldForm; import org.springframework.data.domain.Pageable; import org.springframework.ui.Model; +import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; @@ -30,6 +31,10 @@ ModelAndView downloadExcel(HttpServletRequest request, Model model); + ModelAndView downloadExcelTemplate(HttpServletRequest request, Model model); + + void importExcel(MultipartFile multipartFile) throws Exception; + List<HostingField> findAll(); } diff --git a/src/main/java/kr/wisestone/owl/service/IspFieldService.java b/src/main/java/kr/wisestone/owl/service/IspFieldService.java index 57ab94c..0c0b5c8 100644 --- a/src/main/java/kr/wisestone/owl/service/IspFieldService.java +++ b/src/main/java/kr/wisestone/owl/service/IspFieldService.java @@ -6,6 +6,7 @@ import kr.wisestone.owl.web.form.IspFieldForm; import org.springframework.data.domain.Pageable; import org.springframework.ui.Model; +import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; @@ -29,5 +30,9 @@ ModelAndView downloadExcel(HttpServletRequest request, Model model); + ModelAndView downloadExcelTemplate(HttpServletRequest request, Model model); + + void importExcel(MultipartFile multipartFile) throws Exception; + List<IspField> findAll(); } 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 f0b018b..32d6003 100644 --- a/src/main/java/kr/wisestone/owl/service/impl/CompanyFieldServiceImpl.java +++ b/src/main/java/kr/wisestone/owl/service/impl/CompanyFieldServiceImpl.java @@ -355,7 +355,7 @@ } } - // �뿊�� import 濡� �씠�뒋瑜� �벑濡앺븳�떎. + // �뿊�� import 濡� �뾽泥대�� �벑濡앺븳�떎. @Override @Transactional public void importExcel(MultipartFile multipartFile) throws Exception { @@ -440,38 +440,53 @@ } /** + * 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 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) { + 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; + } } - - // 怨듬갚 �젣嫄� - if (cell != null && cell.getCellType() == cell.CELL_TYPE_STRING && 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; } - /*private void telTypeCheck (Cell cell, int rowIndex) { + /** + * �쟾�솕踰덊샇 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, @@ -483,121 +498,111 @@ 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 - if (cellNullCheck(cell, rowIndex)) { - this.setCompanyFormUrl(cell, companyFieldForm, rowIndex); - } + this.setCompanyFormUrl(cellStr, companyFieldForm, isNull); break; case 2: // isp紐� - if (cellNullCheck(cell, rowIndex)) { - this.setCompanyFormIspName(cell, ispFieldMaps, companyFieldForm, rowIndex); - } + this.setCompanyFormIspName(cellStr, ispFieldMaps, companyFieldForm, rowIndex, isNull); break; case 3: // �샇�뒪�똿紐� - if (cellNullCheck(cell, rowIndex)) { - this.setCompanyFormHostingName(cell, hostingFieldMaps, companyFieldForm, rowIndex); - } + this.setCompanyFormHostingName(cellStr, hostingFieldMaps, companyFieldForm, rowIndex, isNull); break; case 4: // �뿰�씫泥� - if (cellNullCheck(cell, rowIndex)) { - //this.telTypeCheck(cell, rowIndex); - this.setCompanyFormTel(cell, companyFieldForm, rowIndex); - } + telTypeCheck(cell, rowIndex); + this.setCompanyFormTel(cellStr, companyFieldForm, isNull); break; case 5: // �씠硫붿씪 - if (cellNullCheck(cell, rowIndex)) { - this.setCompanyFormEmail(cell, companyFieldForm, rowIndex); - } + this.setCompanyFormEmail(cellStr, companyFieldForm, isNull); break; case 6: // �떞�떦�옄 - if (cellNullCheck(cell, rowIndex)) { - this.setCompanyFormManager(cell, companyFieldForm, rowIndex); - } + this.setCompanyFormManager(cellStr, companyFieldForm, isNull); break; case 7: // 湲곗뾽援щ텇 - if (cellNullCheck(cell, rowIndex)) { - this.setCompanyFormCompanyType(cell, companyTypeMaps, companyFieldForm, rowIndex); - } + this.setCompanyFormCompanyType(cellStr, companyTypeMaps, companyFieldForm, rowIndex, isNull); break; case 8: // �뾽醫�(��遺꾨쪟) - if (cellNullCheck(cell, rowIndex)) { - this.setCompanyFormParentSector(cell, parentSectorMaps, companyFieldForm, rowIndex); - } + this.setCompanyFormParentSector(cellStr, parentSectorMaps, companyFieldForm, rowIndex, isNull); break; case 9: // �뾽醫�(以묐텇瑜�) - if (cellNullCheck(cell, rowIndex)) { - this.setCompanyFormChildSector(cell, childSectorMaps, companyFieldForm, rowIndex); - } + this.setCompanyFormChildSector(cellStr, childSectorMaps, companyFieldForm, rowIndex, isNull); break; case 10: // 吏��뿭 - if (cellNullCheck(cell, rowIndex)) { - this.setCompanyFormRegion(cell, regionMaps, companyFieldForm, rowIndex); - } + this.setCompanyFormRegion(cellStr, regionMaps, companyFieldForm, rowIndex, isNull); break; case 11: // �긽�깭 - if (cellNullCheck(cell, rowIndex)) { - this.setCompanyFormStatus(cell, statusMaps, companyFieldForm, rowIndex); - } + this.setCompanyFormStatus(cellStr, statusMaps, companyFieldForm, isNull); break; case 12: // 鍮꾧퀬 - if (cellNullCheck(cell, rowIndex)) { - this.setCompanyFormMemo(cell, companyFieldForm, rowIndex); - } - break; + this.setCompanyFormMemo(cellStr, companyFieldForm, isNull); } } return companyFieldForm; } - private void setCompanyFormMemo(Cell cell, CompanyFieldForm companyFieldForm, int rowIndex) { - companyFieldForm.setMemo(CommonUtil.convertExcelStringToCell(cell)); + private void setCompanyFormMemo(String cellStr, CompanyFieldForm companyFieldForm, boolean isNull) { + if (!isNull) { + companyFieldForm.setMemo(cellStr); + } } - 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 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)); @@ -606,9 +611,9 @@ } } - 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) { @@ -626,9 +631,9 @@ } } - 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)); @@ -637,9 +642,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)); @@ -648,25 +653,23 @@ } } - 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) { - String email = CommonUtil.convertExcelStringToCell(cell); - if (CommonUtil.convertExcelStringToCell(cell).contains(" ")) { - email = CommonUtil.convertExcelStringToCell(cell).replace(" ", ""); + private void setCompanyFormEmail(String email, CompanyFieldForm companyFieldForm, boolean isNull) { + if (!isNull) { + if (email.contains(" ")) { + email = email.replace(" ", ""); } companyFieldForm.setEmail(email); } } - private void setCompanyFormTel(Cell cell, CompanyFieldForm companyFieldForm, int rowIndex) { - if (cell != null) { - String tel = CommonUtil.convertExcelStringToCell(cell); + private void setCompanyFormTel(String tel, CompanyFieldForm companyFieldForm, boolean isNull) { + if (!isNull) { if (tel.contains("-")) { tel = tel.replace("-", ""); } @@ -677,9 +680,9 @@ } } - private void setCompanyFormHostingName(Cell cell, Map<String, HostingField> hostingFieldMaps, CompanyFieldForm companyFieldForm, int rowIndex) { - if (cell != null) { - HostingField hostingField = hostingFieldMaps.get(CommonUtil.convertExcelStringToCell(cell)); + 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)); @@ -688,9 +691,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)); @@ -699,22 +702,14 @@ } } - private void setCompanyFormName(Cell cell, CompanyFieldForm companyFieldForm, int rowIndex) { - if (!cellNullCheck(cell, rowIndex)) { - 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, null); companyFieldForm.setName(title); } - private void setCompanyFormUrl(Cell cell, CompanyFieldForm companyFieldForm, int rowIndex) { - if (cell != null) { - String url = CommonUtil.convertExcelStringToCell(cell); + private void setCompanyFormUrl(String url, CompanyFieldForm companyFieldForm, boolean isNull) { + if (!isNull) { if (url.contains(" ")) { url = url.replace(" ", ""); } diff --git a/src/main/java/kr/wisestone/owl/service/impl/HostingFieldServiceImpl.java b/src/main/java/kr/wisestone/owl/service/impl/HostingFieldServiceImpl.java index 9ae3495..38ad53c 100644 --- a/src/main/java/kr/wisestone/owl/service/impl/HostingFieldServiceImpl.java +++ b/src/main/java/kr/wisestone/owl/service/impl/HostingFieldServiceImpl.java @@ -6,35 +6,31 @@ import kr.wisestone.owl.constant.MsgConstants; import kr.wisestone.owl.domain.CompanyField; import kr.wisestone.owl.domain.HostingField; -import kr.wisestone.owl.domain.IspField; import kr.wisestone.owl.exception.OwlRuntimeException; import kr.wisestone.owl.mapper.HostingFieldMapper; import kr.wisestone.owl.repository.HostingFieldRepository; import kr.wisestone.owl.service.CompanyFieldService; import kr.wisestone.owl.service.HostingFieldService; import kr.wisestone.owl.service.WorkspaceService; +import kr.wisestone.owl.util.CommonUtil; import kr.wisestone.owl.util.ConvertUtil; -import kr.wisestone.owl.vo.HostingFieldVo; -import kr.wisestone.owl.vo.ExportExcelAttrVo; -import kr.wisestone.owl.vo.ExportExcelVo; -import kr.wisestone.owl.vo.ResPage; +import kr.wisestone.owl.vo.*; import kr.wisestone.owl.web.condition.HostingFieldCondition; import kr.wisestone.owl.web.form.HostingFieldForm; import kr.wisestone.owl.web.view.ExcelView; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.ui.Model; +import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; @Service public class HostingFieldServiceImpl extends AbstractServiceImpl<HostingField, Long, JpaRepository<HostingField, Long>> implements HostingFieldService { @@ -62,9 +58,13 @@ return this.hostingFieldRepository; } + private static final int EXCEL_IMPORT_MAX_ROWS = 10000; // excel import �젣�븳 + // Hosting 異붽� @Override public HostingField add(HostingFieldForm HostingFieldForm) { + // �샇�뒪�똿紐� �쑀�슚�꽦 泥댄겕 + //this.verifyTitle(title, null); if (HostingFieldForm.getTelList() != null && HostingFieldForm.getTelList().size() > 0) { String tels = HostingFieldForm.getTelList().toString(); if (tels.contains("[")) { @@ -122,6 +122,8 @@ // Hosting �젙濡쒕�� �닔�젙�븳�떎. @Override public void modify(HostingFieldForm HostingFieldForm) { + // �샇�뒪�똿紐� �쑀�슚�꽦 泥댄겕 + //this.verifyTitle(title, null); if (HostingFieldForm.getTelList() != null && HostingFieldForm.getTelList().size() > 0) { String tels = HostingFieldForm.getTelList().toString(); if (tels.contains("[")) { @@ -202,6 +204,308 @@ return new ModelAndView(this.excelView); } + // �샇�뒪�똿 Import �슜 �뿊�� �뀥�뵆由� �떎�슫濡쒕뱶 + @Override + @Transactional + public ModelAndView downloadExcelTemplate(HttpServletRequest request, Model model) { + + ExportExcelVo excelInfo = new ExportExcelVo(); + excelInfo.setHideCount(true); + excelInfo.setFileName(this.messageAccessor.message("common.registerExcelHostingField")); // �뿊��濡� �샇�뒪�똿 �벑濡앺븯湲� + excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("Hosting.HostingName"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // �샇�뒪�똿紐� + excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("Hosting.HostingCode"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // 肄붾뱶 + excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("Hosting.HostingManager"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // �떞�떦�옄 + excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("Hosting.HostingTel"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // �뿰�씫泥� + excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("Hosting.HostingEmail"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // �씠硫붿씪 + excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("Hosting.HostingUrl"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // url + excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("Hosting.HostingMemo"), 40, ExportExcelAttrVo.ALIGN_CENTER)); // 鍮꾧퀬 + + // �뿊���뿉 �꽔�쓣 �뜲�씠�꽣 - HostingFieldVo �뜲�씠�꽣瑜� �뿊���뿉�꽌 �몴�떆�븷 �닔 �엳�뒗 �뜲�씠�꽣濡� 蹂�寃쏀븳�떎. + excelInfo.setDatas(Lists.newArrayList(new HostingFieldVo())); + + model.addAttribute(Constants.EXCEL, excelInfo); + return new ModelAndView(this.excelView); + } + + // �뾽濡쒕뱶 �뙆�씪 �솗�옣�옄 泥댄겕 + private void verifyMultipartFileExtension(MultipartFile multipartFile) { + multipartFile.getOriginalFilename(); + + int pos = multipartFile.getOriginalFilename().lastIndexOf("."); + String ext = multipartFile.getOriginalFilename().substring(pos + 1); + + if (!ext.equals("xlsx")) { + throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.EXCEL_NOT_EXTENSION)); + } + } + + // �뿊�� import 濡� �샇�뒪�똿�쓣 �벑濡앺븳�떎. + @Override + @Transactional + public void importExcel(MultipartFile multipartFile) throws Exception { + // �궗�슜�븯怨� �엳�뒗 �뾽臾� 怨듦컙�씠 �솢�꽦 �긽�깭�씤吏� �솗�씤�븳�떎. �궗�슜 怨듦컙�뿉�꽌 濡쒓렇�씤�븳 �궗�슜�옄媛� 鍮꾪솢�꽦�씤吏� �솗�씤�븳�떎. + this.workspaceService.checkUseWorkspace(); + + if (multipartFile != null) { + // �뾽濡쒕뱶 �뙆�씪 �솗�옣�옄 泥댄겕 + this.verifyMultipartFileExtension(multipartFile); + + List<HostingFieldForm> hostingFieldForms = Lists.newArrayList(); + List<String> headers = Lists.newArrayList(); + + Workbook workbook; + + workbook = WorkbookFactory.create(multipartFile.getInputStream()); + Sheet sheet = workbook.getSheetAt(0); + int lastRowNum = sheet.getLastRowNum() + 1; + + // 2嫄� - �젣紐�, �뿤�뜑 - �꽦�뒫�쓣 �쐞�빐 理쒕� 1留뚭굔�쑝濡� �젣�븳 + if (lastRowNum > (EXCEL_IMPORT_MAX_ROWS + 2)) { + throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_MAX_ROWS_OVER)); + } + + 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); + + if (cell == null) { + throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.EXCEL_EMPTY_CELL)); + } + + // �뿊�� import �뜲�씠�꽣�뿉�꽌 cell 媛믪쓣 臾몄옄�뿴濡� 蹂��솚�븳�떎. + String cellValue = CommonUtil.convertExcelStringToCell(cell); + + if (StringUtils.isEmpty(cellValue)) { + throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.EXCEL_HEADER_EMPTY_CELL)); + } + + headers.add(cellValue); + } + } + + // 1踰� �뿤�뜑遺��꽣 �뜲�씠�꽣 �쁺�뿭 + if (rowIndex > 1) { + // �샇�뒪�똿�쑝濡� �벑濡앺븯湲� �쐞�빐 newHostingFieldForm �뿉 �뜲�씠�꽣瑜� �뀑�똿�븳�떎. + HostingFieldForm newHostingFieldForm = this.setHostingFieldFormToExcelField(row, (rowIndex + 1), headers); + + hostingFieldForms.add(newHostingFieldForm); + } + } + + if (hostingFieldForms.size() < 1) { + return; + } + + for (HostingFieldForm saveHostingFieldForm : hostingFieldForms) { + HostingField hostingField = new HostingField(); + ConvertUtil.copyProperties(saveHostingFieldForm, hostingField); + + hostingField = this.hostingFieldRepository.saveAndFlush(hostingField); + + saveHostingFieldForm.setId(hostingField.getId()); + } + } + } + + /** + * 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)); + } + } + + // �뿊�� �븘�뱶�뿉 �엳�뒗 �젙蹂대�� HOSTING form �쑝濡� �삷湲대떎. + private HostingFieldForm setHostingFieldFormToExcelField(Row row, int rowIndex, List<String> headers) { + HostingFieldForm hostingFieldForm = new HostingFieldForm(); + hostingFieldForm.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: + // �샇�뒪�똿紐� + if (isNull) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_HOSTING_NAME_IS_NULL, rowIndex)); + } + this.setHostingFormName(cellStr, hostingFieldForm); + break; + + case 1: + // 肄붾뱶 + if (isNull) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_HOSTING_CODE_IS_NULL, rowIndex)); + } + this.setHostingFormCode(cellStr, hostingFieldForm); + break; + + case 2: + // �떞�떦�옄 + this.setHostingFormManager(cellStr, hostingFieldForm, isNull); + break; + + case 3: + // �뿰�씫泥� + telTypeCheck(cell, rowIndex); + this.setHostingFormTel(cellStr, hostingFieldForm, isNull); + break; + + case 4: + // �씠硫붿씪 + this.setHostingFormEmail(cellStr, hostingFieldForm, isNull); + break; + + case 5: + // url + this.setHostingFormUrl(cellStr, hostingFieldForm, isNull); + break; + + case 6: + // 鍮꾧퀬 + this.setHostingFormMemo(cellStr, hostingFieldForm, isNull); + } + } + + return hostingFieldForm; + } + + private void setHostingFormMemo(String memo, HostingFieldForm hostingFieldForm, boolean isNull) { + if (!isNull) { + hostingFieldForm.setMemo(memo); + } + } + + private void setHostingFormUrl(String url, HostingFieldForm hostingFieldForm, boolean isNull) { + if (!isNull) { + if (url.contains(" ")) { + url = url.replace(" ", ""); + } + hostingFieldForm.setUrl(url); + } + } + + private void setHostingFormEmail(String email, HostingFieldForm hostingFieldForm, boolean isNull) { + if (!isNull) { + if (email.contains(" ")) { + email = email.replace(" ", ""); + } + hostingFieldForm.setEmail(email); + } + } + + private void setHostingFormTel(String tel, HostingFieldForm hostingFieldForm, boolean isNull) { + if (!isNull) { + if (tel.contains("-")) { + tel = tel.replace("-", ""); + } + if (tel.contains(" ")) { + tel = tel.replace(" ", ""); + } + hostingFieldForm.setTel(tel); + } + } + + private void setHostingFormManager(String manager, HostingFieldForm hostingFieldForm, boolean isNull) { + if (!isNull) { + hostingFieldForm.setManager(manager); + } + } + + private void setHostingFormCode(String code, HostingFieldForm hostingFieldForm) { + //肄붾뱶 �쑀�슚�꽦 泥댄겕 + hostingFieldForm.setCode(code); + } + + private void setHostingFormName(String title, HostingFieldForm hostingFieldForm) { + // �샇�뒪�똿紐� �쑀�슚�꽦 泥댄겕 + //this.verifyTitle(title, null); + hostingFieldForm.setName(title); + } + + // �샇�뒪�똿紐� �쑀�슚�꽦 泥댄겕 + private void verifyTitle(String title, Long id) { + List<HostingField> hostingFields = new ArrayList<>(); + + // �샇�뒪�똿紐� 以묐났 泥댄겕 + if (id != null) { //�닔�젙 �씪 寃쎌슦 + hostingFields = this.hostingFieldRepository.findByNameAndIdNot(title, id); + } else { // 異붽� �씪 寃쎌슦 + hostingFields = this.hostingFieldRepository.findByName(title); + } + if (hostingFields != null && hostingFields.size() > 0) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.HOSTING_NAME_ALREADY_IN_USE)); + } + + // �샇�뒪�똿紐� 鍮덇컪 泥댄겕 + if (StringUtils.isEmpty(title)) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.HOSTING_NO_TITLE)); + } + + // �샇�뒪�똿紐� 湲몄씠 泥댄겕 + if (title.length() > 300) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.HOSTING_NAME_MAX_LENGTH_OUT)); + } + } + // 寃��깋 寃곌낵瑜� HostingVo 濡� 蹂��솚�븳�떎. private List<HostingFieldVo> convertHostingVoToMap(List<Map<String, Object>> results, Long totalHostingCount, Pageable pageable, Map<String, Object> resJsonData) { List<HostingFieldVo> hostingFieldVos = Lists.newArrayList(); diff --git a/src/main/java/kr/wisestone/owl/service/impl/IspFieldServiceImpl.java b/src/main/java/kr/wisestone/owl/service/impl/IspFieldServiceImpl.java index 95d5d2b..073e233 100644 --- a/src/main/java/kr/wisestone/owl/service/impl/IspFieldServiceImpl.java +++ b/src/main/java/kr/wisestone/owl/service/impl/IspFieldServiceImpl.java @@ -13,28 +13,26 @@ import kr.wisestone.owl.service.CompanyFieldService; import kr.wisestone.owl.service.IspFieldService; import kr.wisestone.owl.service.WorkspaceService; +import kr.wisestone.owl.util.CommonUtil; import kr.wisestone.owl.util.ConvertUtil; -import kr.wisestone.owl.vo.IspFieldVo; -import kr.wisestone.owl.vo.ExportExcelAttrVo; -import kr.wisestone.owl.vo.ExportExcelVo; -import kr.wisestone.owl.vo.ResPage; +import kr.wisestone.owl.vo.*; import kr.wisestone.owl.web.condition.IspFieldCondition; +import kr.wisestone.owl.web.form.CompanyFieldForm; import kr.wisestone.owl.web.form.IspFieldForm; import kr.wisestone.owl.web.view.ExcelView; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.ui.Model; +import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; @Service public class IspFieldServiceImpl extends AbstractServiceImpl<IspField, Long, JpaRepository<IspField, Long>> implements IspFieldService { @@ -62,9 +60,14 @@ return this.ispFieldRepository; } + private static final int EXCEL_IMPORT_MAX_ROWS = 10000; // excel import �젣�븳 + // Isp 異붽� @Override public IspField add(IspFieldForm IspFieldForm) { + // ISP紐� 以묐났 泥댄겕 + //this.verifyTitle(IspFieldForm.getName(), null); + if (IspFieldForm.getTelList() != null && IspFieldForm.getTelList().size() > 0) { String tels = IspFieldForm.getTelList().toString(); if (tels.contains("[")) { @@ -122,6 +125,9 @@ // Isp �젙濡쒕�� �닔�젙�븳�떎. @Override public void modify(IspFieldForm IspFieldForm) { + // ISP紐� �쑀�슚�꽦 泥댄겕 + //this.verifyTitle(IspFieldForm.getName(), IspFieldForm.getId()); + if (IspFieldForm.getTelList() != null && IspFieldForm.getTelList().size() > 0) { String tels = IspFieldForm.getTelList().toString(); if (tels.contains("[")) { @@ -204,6 +210,309 @@ return new ModelAndView(this.excelView); } + // ISP Import �슜 �뿊�� �뀥�뵆由� �떎�슫濡쒕뱶 + @Override + @Transactional + public ModelAndView downloadExcelTemplate(HttpServletRequest request, Model model) { + + ExportExcelVo excelInfo = new ExportExcelVo(); + excelInfo.setHideCount(true); + excelInfo.setFileName(this.messageAccessor.message("common.registerExcelIspField")); // �뿊��濡� ISP �벑濡앺븯湲� + excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("isp.ispName"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // ISP紐� + excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("isp.ispCode"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // 肄붾뱶 + excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("isp.ispManager"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // �떞�떦�옄 + excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("isp.ispTel"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // �뿰�씫泥� + excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("isp.ispEmail"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // �씠硫붿씪 + excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("isp.ispUrl"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // url + excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("isp.ispMemo"), 40, ExportExcelAttrVo.ALIGN_CENTER)); // 鍮꾧퀬 + + // �뿊���뿉 �꽔�쓣 �뜲�씠�꽣 - IspFieldVo �뜲�씠�꽣瑜� �뿊���뿉�꽌 �몴�떆�븷 �닔 �엳�뒗 �뜲�씠�꽣濡� 蹂�寃쏀븳�떎. + excelInfo.setDatas(Lists.newArrayList(new IspFieldVo())); + + model.addAttribute(Constants.EXCEL, excelInfo); + return new ModelAndView(this.excelView); + } + + // �뾽濡쒕뱶 �뙆�씪 �솗�옣�옄 泥댄겕 + private void verifyMultipartFileExtension(MultipartFile multipartFile) { + multipartFile.getOriginalFilename(); + + int pos = multipartFile.getOriginalFilename().lastIndexOf("."); + String ext = multipartFile.getOriginalFilename().substring(pos + 1); + + if (!ext.equals("xlsx")) { + throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.EXCEL_NOT_EXTENSION)); + } + } + + // �뿊�� import 濡� ISP瑜� �벑濡앺븳�떎. + @Override + @Transactional + public void importExcel(MultipartFile multipartFile) throws Exception { + // �궗�슜�븯怨� �엳�뒗 �뾽臾� 怨듦컙�씠 �솢�꽦 �긽�깭�씤吏� �솗�씤�븳�떎. �궗�슜 怨듦컙�뿉�꽌 濡쒓렇�씤�븳 �궗�슜�옄媛� 鍮꾪솢�꽦�씤吏� �솗�씤�븳�떎. + this.workspaceService.checkUseWorkspace(); + + if (multipartFile != null) { + // �뾽濡쒕뱶 �뙆�씪 �솗�옣�옄 泥댄겕 + this.verifyMultipartFileExtension(multipartFile); + + List<IspFieldForm> ispFieldForms = Lists.newArrayList(); + List<String> headers = Lists.newArrayList(); + + Workbook workbook; + + workbook = WorkbookFactory.create(multipartFile.getInputStream()); + Sheet sheet = workbook.getSheetAt(0); + int lastRowNum = sheet.getLastRowNum() + 1; + + // 2嫄� - �젣紐�, �뿤�뜑 - �꽦�뒫�쓣 �쐞�빐 理쒕� 1留뚭굔�쑝濡� �젣�븳 + if (lastRowNum > (EXCEL_IMPORT_MAX_ROWS + 2)) { + throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_MAX_ROWS_OVER)); + } + + 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); + + if (cell == null) { + throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.EXCEL_EMPTY_CELL)); + } + + // �뿊�� import �뜲�씠�꽣�뿉�꽌 cell 媛믪쓣 臾몄옄�뿴濡� 蹂��솚�븳�떎. + String cellValue = CommonUtil.convertExcelStringToCell(cell); + + if (StringUtils.isEmpty(cellValue)) { + throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.EXCEL_HEADER_EMPTY_CELL)); + } + + headers.add(cellValue); + } + } + + // 1踰� �뿤�뜑遺��꽣 �뜲�씠�꽣 �쁺�뿭 + if (rowIndex > 1) { + // ISP濡� �벑濡앺븯湲� �쐞�빐 ispFieldForm �뿉 �뜲�씠�꽣瑜� �뀑�똿�븳�떎. + IspFieldForm newIspFieldForm = this.setIspFieldFormToExcelField(row, (rowIndex + 1), headers); + + ispFieldForms.add(newIspFieldForm); + } + } + + if (ispFieldForms.size() < 1) { + return; + } + + for (IspFieldForm saveIspFieldForm : ispFieldForms) { + IspField ispField = new IspField(); + ConvertUtil.copyProperties(saveIspFieldForm, ispField); + + ispField = this.ispFieldRepository.saveAndFlush(ispField); + + saveIspFieldForm.setId(ispField.getId()); + } + } + } + + /** + * 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)); + } + } + + // �뿊�� �븘�뱶�뿉 �엳�뒗 �젙蹂대�� ISP form �쑝濡� �삷湲대떎. + private IspFieldForm setIspFieldFormToExcelField(Row row, int rowIndex, List<String> headers) { + IspFieldForm ispFieldForm = new IspFieldForm(); + ispFieldForm.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: + // ISP紐� + if (isNull) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_ISP_NAME_IS_NULL, rowIndex)); + } + this.setIspFormName(cellStr, ispFieldForm); + break; + + case 1: + // 肄붾뱶 + if (isNull) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_ISP_CODE_IS_NULL, rowIndex)); + } + this.setIspFormCode(cellStr, ispFieldForm); + break; + + case 2: + // �떞�떦�옄 + this.setIspFormManager(cellStr, ispFieldForm, isNull); + break; + + case 3: + // �뿰�씫泥� + telTypeCheck(cell, rowIndex); + this.setIspFormTel(cellStr, ispFieldForm, rowIndex, isNull); + break; + + case 4: + // �씠硫붿씪 + this.setIspFormEmail(cellStr, ispFieldForm, isNull); + break; + + case 5: + // url + this.setIspFormUrl(cellStr, ispFieldForm, isNull); + break; + + case 6: + // 鍮꾧퀬 + this.setIspFormMemo(cellStr, ispFieldForm, isNull); + } + } + + return ispFieldForm; + } + + private void setIspFormMemo(String memo, IspFieldForm ispFieldForm, boolean isNull) { + if (!isNull) { + ispFieldForm.setMemo(memo); + } + } + + private void setIspFormUrl(String url, IspFieldForm ispFieldForm, boolean isNull) { + if (!isNull) { + if (url.contains(" ")) { + url = url.replace(" ", ""); + } + ispFieldForm.setUrl(url); + } + } + + private void setIspFormEmail(String email, IspFieldForm ispFieldForm, boolean isNull) { + if (!isNull) { + if (email.contains(" ")) { + email = email.replace(" ", ""); + } + ispFieldForm.setEmail(email); + } + } + + private void setIspFormTel(String tel, IspFieldForm ispFieldForm, int rowIndex, boolean isNull) { + if (!isNull) { + if (tel.contains("-")) { + tel = tel.replace("-", ""); + } + if (tel.contains(" ")) { + tel = tel.replace(" ", ""); + } + ispFieldForm.setTel(tel); + } + } + + private void setIspFormManager(String manager, IspFieldForm ispFieldForm, boolean isNull) { + if (!isNull) { + ispFieldForm.setManager(manager); + } + } + + private void setIspFormCode(String code, IspFieldForm ispFieldForm) { + //肄붾뱶 �쑀�슚�꽦 泥댄겕 + ispFieldForm.setCode(code); + } + + private void setIspFormName(String title, IspFieldForm ispFieldForm) { + // ISP紐� �쑀�슚�꽦 泥댄겕 + //this.verifyTitle(title, null); + ispFieldForm.setName(title); + } + + // ISP紐� �쑀�슚�꽦 泥댄겕 + private void verifyTitle(String title, Long id) { + List<IspField> ispFields = new ArrayList<>(); + + // ISP紐� 以묐났 泥댄겕 + + if (id != null) { //�닔�젙 �씪 寃쎌슦 + ispFields = this.ispFieldRepository.findByNameAndIdNot(title, id); + } else { // 異붽� �씪 寃쎌슦 + ispFields = this.ispFieldRepository.findByName(title); + } + if (ispFields != null && ispFields.size() > 0) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.ISP_NAME_ALREADY_IN_USE)); + } + + // ISP紐� 鍮덇컪 泥댄겕 + if (StringUtils.isEmpty(title)) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.ISP_NO_TITLE)); + } + + // ISP紐� 湲몄씠 泥댄겕 + if (title.length() > 300) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.ISP_NAME_MAX_LENGTH_OUT)); + } + } + // 寃��깋 寃곌낵瑜� IspVo 濡� 蹂��솚�븳�떎. private List<IspFieldVo> convertIspVoToMap(List<Map<String, Object>> results, Long totalIspCount, Pageable pageable, Map<String, Object> resJsonData) { List<IspFieldVo> ispFieldVos = Lists.newArrayList(); @@ -238,4 +547,6 @@ } return IspField; } + + } 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 12306c7..ba2f863 100644 --- a/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java +++ b/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java @@ -3126,7 +3126,7 @@ // 1踰� �뿤�뜑遺��꽣 �뜲�씠�꽣 �쁺�뿭 if (rowIndex > 1) { // �씠�뒋濡� �벑濡앺븯湲� �쐞�빐 IssueForm �뿉 �뜲�씠�꽣瑜� �뀑�똿�븳�떎. - IssueForm newIssueForm = this.setIssueFormToExcelField(row, (rowIndex + 1), priorityMaps, severityMaps, departmentMaps, customFieldMaps, + IssueForm newIssueForm = this.setIssueFormToExcelField(row, (rowIndex + 1), priorityMaps, severityMaps, customFieldMaps, companyFieldMaps, ispFieldMaps, hostingFieldMaps, headers); ConvertUtil.copyProperties(issueForm, newIssueForm); @@ -3470,23 +3470,38 @@ } /** + * 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 泥댄겕 �븿�닔 * 鍮� 媛믪씠 �븘�땶 cell 泥댄겕 * @param cell Cell * @return boolean */ private Boolean cellNullCheck (Cell cell) { - if (cell != null ) { - 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 { + 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; @@ -3494,32 +3509,22 @@ // �뿊�� �븘�뱶�뿉 �엳�뒗 �젙蹂대�� �씠�뒋 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, + Map<String, Severity> severityMaps, Map<String, CustomField> customFieldMaps, + Map<String, CompanyField> companyFieldMaps, Map<String, IspField> ispFieldMaps, Map<String, HostingField> hostingFieldMaps, List<String> headers) throws ParseException { IssueForm issueForm = new IssueForm(); issueForm.setRegisterId(this.webAppUtil.getLoginId()); - Project project = null; // �젣紐�, �궡�슜, �봽濡쒖젥�듃 �궎, �씠�뒋 ���엯, �슦�꽑�닚�쐞, 以묒슂�룄, �떞�떦�옄, �떆�옉�씪, 醫낅즺�씪, �궗�슜�옄 �젙�쓽 �븘�뱶 for (int cellIndex = 0; cellIndex < headers.size(); cellIndex++) { Cell cell = row.getCell(cellIndex); - boolean isNull = true; String cellStr = ""; + boolean isNull = true; if (cell != null) { isNull = cellNullCheck(cell); - - if (!isNull) { - cellStr = CommonUtil.convertExcelStringToCell(cell); - - // 怨듬갚 �젣嫄� - cell.setCellValue(cellStr.trim()); - } else { - cell.setCellValue(cellStr); - } + cellStr = stringToCell(cell, isNull); //cell�쓣 String�쑝濡� 蹂��솚 } switch (cellIndex) { diff --git a/src/main/java/kr/wisestone/owl/web/controller/HostingFieldController.java b/src/main/java/kr/wisestone/owl/web/controller/HostingFieldController.java index 51f8a3b..bcd8df0 100644 --- a/src/main/java/kr/wisestone/owl/web/controller/HostingFieldController.java +++ b/src/main/java/kr/wisestone/owl/web/controller/HostingFieldController.java @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; @@ -26,7 +27,7 @@ @Autowired private HostingFieldService HostingFieldService; - // �뾽泥� �깮�꽦 + // �샇�뒪�똿 �깮�꽦 @RequestMapping(value = "/hostingField/add", method = RequestMethod.POST) public @ResponseBody @@ -38,7 +39,7 @@ return this.setSuccessMessage(resJsonData); } - // �뾽泥� 議고쉶 + // �샇�뒪�똿 議고쉶 @RequestMapping(value = "/hostingField/find", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody @@ -51,7 +52,7 @@ return this.setSuccessMessage(resJsonData); } - // �뾽泥� �긽�꽭 議고쉶 + // �샇�뒪�똿 �긽�꽭 議고쉶 @RequestMapping(value = "/hostingField/detail", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody @@ -62,7 +63,7 @@ return this.setSuccessMessage(resJsonData); } - // �뾽泥� �닔�젙 + // �샇�뒪�똿 �닔�젙 @RequestMapping(value = "/hostingField/modify", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody @@ -74,7 +75,7 @@ return this.setSuccessMessage(resJsonData); } - // �뾽泥� �궘�젣 + // �샇�뒪�똿 �궘�젣 @RequestMapping(value = "/hostingField/remove", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody @@ -98,11 +99,26 @@ return this.setSuccessMessage(resJsonData); } - - // �뾽泥� �뿊�� �떎�슫濡쒕뱶 + // �샇�뒪�똿 �뿊�� �떎�슫濡쒕뱶 @RequestMapping(value = "/hostingField/downloadExcel", method = RequestMethod.POST) public ModelAndView downloadExcel(HttpServletRequest request, Model model) { return this.HostingFieldService.downloadExcel(request, model); } + + // �샇�뒪�똿 Import �슜 �뿊�� �뀥�뵆由� �떎�슫濡쒕뱶 + @RequestMapping(value = "/hostingField/downloadExcelTemplate", method = RequestMethod.POST) + public ModelAndView downloadExcelImport(HttpServletRequest request, Model model) { + return this.HostingFieldService.downloadExcelTemplate(request, model); + } + + // �샇�뒪�똿 �뿊�� �벑濡� + @RequestMapping(value = "/hostingField/importExcel", method = RequestMethod.POST) + public @ResponseBody Map<String, Object> importExcel(MultipartHttpServletRequest request) throws Exception { + Map<String, Object> resJsonData = new HashMap<>(); + + this.HostingFieldService.importExcel(request.getFile("file")); + + return this.setSuccessMessage(resJsonData); + } } diff --git a/src/main/java/kr/wisestone/owl/web/controller/IspFieldController.java b/src/main/java/kr/wisestone/owl/web/controller/IspFieldController.java index 539fb5e..450be62 100644 --- a/src/main/java/kr/wisestone/owl/web/controller/IspFieldController.java +++ b/src/main/java/kr/wisestone/owl/web/controller/IspFieldController.java @@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; @@ -25,7 +26,7 @@ @Autowired private IspFieldService IspFieldService; - // �뾽泥� �깮�꽦 + // ISP �깮�꽦 @RequestMapping(value = "/ispField/add", method = RequestMethod.POST) public @ResponseBody @@ -37,7 +38,7 @@ return this.setSuccessMessage(resJsonData); } - // �뾽泥� 議고쉶 + // ISP 議고쉶 @RequestMapping(value = "/ispField/find", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody @@ -50,7 +51,7 @@ return this.setSuccessMessage(resJsonData); } - // �뾽泥� �긽�꽭 議고쉶 + // ISP �긽�꽭 議고쉶 @RequestMapping(value = "/ispField/detail", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody @@ -61,7 +62,7 @@ return this.setSuccessMessage(resJsonData); } - // �뾽泥� �닔�젙 + // ISP �닔�젙 @RequestMapping(value = "/ispField/modify", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody @@ -73,7 +74,7 @@ return this.setSuccessMessage(resJsonData); } - // �뾽泥� �궘�젣 + // ISP �궘�젣 @RequestMapping(value = "/ispField/remove", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody @@ -86,11 +87,26 @@ return this.setSuccessMessage(resJsonData); } - - // �뾽泥� �뿊�� �떎�슫濡쒕뱶 + // ISP �뿊�� �떎�슫濡쒕뱶 @RequestMapping(value = "/ispField/downloadExcel", method = RequestMethod.POST) public ModelAndView downloadExcel(HttpServletRequest request, Model model) { return this.IspFieldService.downloadExcel(request, model); } + + // ISP Import �슜 �뿊�� �뀥�뵆由� �떎�슫濡쒕뱶 + @RequestMapping(value = "/ispField/downloadExcelTemplate", method = RequestMethod.POST) + public ModelAndView downloadExcelImport(HttpServletRequest request, Model model) { + return this.IspFieldService.downloadExcelTemplate(request, model); + } + + // ISP �뿊�� �벑濡� + @RequestMapping(value = "/ispField/importExcel", method = RequestMethod.POST) + public @ResponseBody Map<String, Object> importExcel(MultipartHttpServletRequest request) throws Exception { + Map<String, Object> resJsonData = new HashMap<>(); + + this.IspFieldService.importExcel(request.getFile("file")); + + return this.setSuccessMessage(resJsonData); + } } diff --git a/src/main/java/kr/wisestone/owl/web/form/CompanyFieldForm.java b/src/main/java/kr/wisestone/owl/web/form/CompanyFieldForm.java index 756dfd9..92f6634 100644 --- a/src/main/java/kr/wisestone/owl/web/form/CompanyFieldForm.java +++ b/src/main/java/kr/wisestone/owl/web/form/CompanyFieldForm.java @@ -26,7 +26,7 @@ private String regionName; private String statusName; - private Long registerId; // �벑濡앹옄 �븘�씠�뵒 - insert batch �뿉�꽌 �궗�슜 + private Long registerId; // �벑濡앹옄 �븘�씠�뵒 - excel import �뿉�꽌 �궗�슜 private List<Long> removeIds = Lists.newArrayList(); diff --git a/src/main/java/kr/wisestone/owl/web/form/HostingFieldForm.java b/src/main/java/kr/wisestone/owl/web/form/HostingFieldForm.java index aed6f5e..0e205a5 100644 --- a/src/main/java/kr/wisestone/owl/web/form/HostingFieldForm.java +++ b/src/main/java/kr/wisestone/owl/web/form/HostingFieldForm.java @@ -15,6 +15,8 @@ private String memo; private List<Long> removeIds = Lists.newArrayList(); + private Long registerId; // �벑濡앹옄 �븘�씠�뵒 - excel import �뿉�꽌 �궗�슜 + public HostingFieldForm() { } public static HostingFieldForm make(Map<String, Object> params) { @@ -81,4 +83,12 @@ public void setUrl(String url) { this.url = url; } + + public Long getRegisterId() { + return registerId; + } + + public void setRegisterId(Long registerId) { + this.registerId = registerId; + } } diff --git a/src/main/java/kr/wisestone/owl/web/form/IspFieldForm.java b/src/main/java/kr/wisestone/owl/web/form/IspFieldForm.java index 54013ef..6f934f5 100644 --- a/src/main/java/kr/wisestone/owl/web/form/IspFieldForm.java +++ b/src/main/java/kr/wisestone/owl/web/form/IspFieldForm.java @@ -15,6 +15,8 @@ private String memo; private List<Long> removeIds = Lists.newArrayList(); + private Long registerId; // �벑濡앹옄 �븘�씠�뵒 - excel import �뿉�꽌 �궗�슜 + public IspFieldForm() { } public static IspFieldForm make(Map<String, Object> params) { @@ -82,4 +84,12 @@ public void setUrl(String url) { this.url = url; } + + public Long getRegisterId() { + return registerId; + } + + public void setRegisterId(Long registerId) { + this.registerId = registerId; + } } diff --git a/src/main/webapp/WEB-INF/i18n/code_ko_KR.properties b/src/main/webapp/WEB-INF/i18n/code_ko_KR.properties index 5f04771..666dc4c 100644 --- a/src/main/webapp/WEB-INF/i18n/code_ko_KR.properties +++ b/src/main/webapp/WEB-INF/i18n/code_ko_KR.properties @@ -43,6 +43,8 @@ common.inProgressProjectStatus=\uC9C4\uD589 \uC911\uC778 \uD504\uB85C\uC81D\uD2B8 \uD604\uD669 common.registerExcelIssue=\uC5D1\uC140\uB85C \uC774\uC288 \uB4F1\uB85D\uD558\uAE30 common.registerExcelCompanyField=\uC5D1\uC140\uB85C \uC5C5\uCCB4 \uB4F1\uB85D\uD558\uAE30 +common.registerExcelIspField=\uC5D1\uC140\uB85C ISP \uB4F1\uB85D\uD558\uAE30 +common.registerExcelHostingField=\uC5D1\uC140\uB85C \uD638\uC2A4\uD305 \uB4F1\uB85D\uD558\uAE30 common.assignedToMeIssue=\uB098\uC5D0\uAC8C \uD560\uB2F9\uB41C \uC774\uC288 common.managementRisk=\uC704\uD5D8 \uAD00\uB9AC common.registeredByMeIssue=\uB0B4\uAC00 \uB4F1\uB85D\uD55C \uC774\uC288 \uD604\uD669 diff --git a/src/main/webapp/WEB-INF/i18n/messages_ko_KR.properties b/src/main/webapp/WEB-INF/i18n/messages_ko_KR.properties index 17789f2..d4fc072 100644 --- a/src/main/webapp/WEB-INF/i18n/messages_ko_KR.properties +++ b/src/main/webapp/WEB-INF/i18n/messages_ko_KR.properties @@ -202,8 +202,14 @@ EXCEL_IMPORT_CHILD_SECTOR_NOT_EXIST=\uB2E4\uC74C \uC5D1\uC140 \uB77C\uC778\uC5D0\uC11C \uC785\uB825\uB41C \uC5C5\uC885\uBA85\uC73C\uB85C \uAC80\uC0C9\uB418\uB294 \uC5C5\uC885(\uC911\uBD84\uB958)\uC774 \uC5C6\uC2B5\uB2C8\uB2E4. \n \uB77C\uC778 \uC815\uBCF4 : {0} EXCEL_IMPORT_REGION_NOT_EXIST=\uB2E4\uC74C \uC5D1\uC140 \uB77C\uC778\uC5D0\uC11C \uC785\uB825\uB41C \uC9C0\uC5ED\uBA85\uC73C\uB85C \uAC80\uC0C9\uB418\uB294 \uC9C0\uC5ED\uC774 \uC5C6\uC2B5\uB2C8\uB2E4. \n \uB77C\uC778 \uC815\uBCF4 : {0} EXCEL_IMPORT_PARENT_SECTOR_IS_NULL=\uB2E4\uC74C \uC5D1\uC140 \uB77C\uC778\uC5D0\uC11C \uC5C5\uC885(\uC911\uBD84\uB958)\uB9CC \uC785\uB825 \uD588\uC2B5\uB2C8\uB2E4. \n \uC5C5\uC885(\uB300\uBD84\uB958)\uB3C4 \uC785\uB825\uC774 \uD544\uC694\uD569\uB2C8\uB2E4. \n \uB77C\uC778 \uC815\uBCF4 : {0} -EXCEL_IMPORT_TEL_NOT_STRING_TYPE=\uB2E4\uC74C \uC5D1\uC140 \uB77C\uC778\uC5D0\uC11C \uC785\uB825\uB41C \uC5F0\uB77D\uCC98\uC758 \uD615\uC2DD\uC774 \uC798\uBABB \uB418\uC5C8\uC2B5\uB2C8\uB2E4. \n \uB77C\uC778 \uC815\uBCF4 : {0} +EXCEL_IMPORT_TEL_NOT_STRING_TYPE=\uB2E4\uC74C \uC5D1\uC140 \uB77C\uC778\uC5D0\uC11C \uC785\uB825\uB41C \uC5F0\uB77D\uCC98\uC758 \uD615\uC2DD\uC774 \uC798\uBABB \uB418\uC5C8\uC2B5\uB2C8\uB2E4. \uBB38\uC790\uC5F4 \uD615\uC2DD(\uD14D\uC2A4\uD2B8)\uC73C\uB85C \uC785\uB825 \uD574\uC8FC\uC138\uC694. \n \uB77C\uC778 \uC815\uBCF4 : {0} EXCEL_IMPORT_NOT_STRING_TYPE=\uB2E4\uC74C \uC5D1\uC140 \uB77C\uC778\uC5D0\uC11C \uC785\uB825\uB41C \uC140 \uC11C\uC2DD\uC758 \uD615\uC2DD\uC774 \uBB38\uC790 \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4. \n \uB77C\uC778 \uC815\uBCF4 : {0} + +EXCEL_IMPORT_ISP_NAME_IS_NULL=\uB2E4\uC74C \uC5D1\uC140 \uB77C\uC778\uC5D0\uC11C ISP\uBA85\uC774 \uC785\uB825\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4. \n \uB77C\uC778 \uC815\uBCF4 : {0} +EXCEL_IMPORT_ISP_CODE_IS_NULL=\uB2E4\uC74C \uC5D1\uC140 \uB77C\uC778\uC5D0\uC11C \uCF54\uB4DC\uAC00 \uC785\uB825\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4. \n \uB77C\uC778 \uC815\uBCF4 : {0} + +EXCEL_IMPORT_HOSTING_NAME_IS_NULL=\uB2E4\uC74C \uC5D1\uC140 \uB77C\uC778\uC5D0\uC11C ISP\uBA85\uC774 \uC785\uB825\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4. \n \uB77C\uC778 \uC815\uBCF4 : {0} +EXCEL_IMPORT_HOSTING_CODE_IS_NULL=\uB2E4\uC74C \uC5D1\uC140 \uB77C\uC778\uC5D0\uC11C \uCF54\uB4DC\uAC00 \uC785\uB825\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4. \n \uB77C\uC778 \uC815\uBCF4 : {0} ISSUE_RESERVATION_VALUE_INVALID=\uC774\uC288 \uBC1C\uC0DD \uC608\uC57D\uC77C\uC774 \uC798\uBABB\uB418\uC5C8\uC2B5\uB2C8\uB2E4. ISSUE_RESERVATION_NOT_EXIST=\uC774\uC288 \uBC1C\uC0DD \uC608\uC57D \uC815\uBCF4\uAC00 \uC874\uC7AC\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. @@ -239,12 +245,18 @@ COMPANY_NAME_MAX_LENGTH_OUT = \uC5C5\uCCB4\uBA85\uC740 \uCD5C\uB300 300\uAE00\uC790\uAE4C\uC9C0 \uC785\uB825\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4. COMPANY_NAME_ALREADY_IN_USE = \uD574\uB2F9 \uC5C5\uCCB4\uBA85\uC740 \uC774\uBBF8 \uB4F1\uB85D\uB418\uC5B4 \uC788\uC2B5\uB2C8\uB2E4. -HOSTING_NOT_EXIST = \uD638\uC2A4\uD305\uC774 \uC874\uC7AC\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. +HOSTING_NO_TITLE = \uD638\uC2A4\uD305\uC774 \uC785\uB825\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4. HOSTING_CODE_NOT_ENTER = \uD638\uC2A4\uD305\uC758 \uCF54\uB4DC\uB294 \uD544\uC218 \uC785\uB825 \uAC12\uC785\uB2C8\uB2E4. HOSTING_REMOVE_NOT_SELECT = \uC0AD\uC81C\uD560 \uD638\uC2A4\uD305\uC774 \uC120\uD0DD\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4. +HOSTING_NOT_EXIST = \uD638\uC2A4\uD305\uC774 \uC874\uC7AC\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. +HOSTING_NAME_MAX_LENGTH_OUT = \uD638\uC2A4\uD305\uBA85\uC740 \uCD5C\uB300 300\uAE00\uC790\uAE4C\uC9C0 \uC785\uB825\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4. +HOSTING_NAME_ALREADY_IN_USE=\uD574\uB2F9 \uD638\uC2A4\uD305\uBA85\uC740 \uC774\uBBF8 \uB4F1\uB85D\uB418\uC5B4 \uC788\uC2B5\uB2C8\uB2E4. HOSTING_EXIST_COMPANY = \uC5C5\uCCB4\uC5D0 \uC124\uC815\uB418\uC5B4\uC788\uB294 \uD638\uC2A4\uD305\uC774 \uC874\uC7AC\uD569\uB2C8\uB2E4. -ISP_NOT_EXIST = ISP\uAC00 \uC874\uC7AC\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. +ISP_NO_TITLE = ISP\uBA85\uC774 \uC785\uB825\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4. ISP_CODE_NOT_ENTER = ISP\uC758 \uCF54\uB4DC\uB294 \uD544\uC218 \uC785\uB825 \uAC12\uC785\uB2C8\uB2E4. +ISP_REMOVE_NOT_SELECT = \uC0AD\uC81C\uD560 ISP\uAC00 \uC120\uD0DD\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4. +ISP_NOT_EXIST = ISP\uAC00 \uC874\uC7AC\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. +ISP_NAME_MAX_LENGTH_OUT = ISP\uBA85\uC740 \uCD5C\uB300 300\uAE00\uC790\uAE4C\uC9C0 \uC785\uB825\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4. +ISP_NAME_ALREADY_IN_USE=\uD574\uB2F9 ISP\uBA85\uC740 \uC774\uBBF8 \uB4F1\uB85D\uB418\uC5B4 \uC788\uC2B5\uB2C8\uB2E4. ISP_EXIST_COMPANY = \uC5C5\uCCB4\uC5D0 \uC124\uC815\uB418\uC5B4\uC788\uB294 ISP\uAC00 \uC874\uC7AC\uD569\uB2C8\uB2E4. -ISP_REMOVE_NOT_SELECT = \uC0AD\uC81C\uD560 ISP\uAC00 \uC120\uD0DD\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4. \ No newline at end of file diff --git a/src/main/webapp/i18n/ko/global.json b/src/main/webapp/i18n/ko/global.json index 01db0f7..72f798b 100644 --- a/src/main/webapp/i18n/ko/global.json +++ b/src/main/webapp/i18n/ko/global.json @@ -1022,6 +1022,7 @@ "ispName" : "ISP紐�", "manager" : "�떞�떦�옄", "tel" : "�뿰�씫泥�", + "url" : "url", "code" : "肄붾뱶", "email" : "�씠硫붿씪", "memo" : "鍮꾧퀬", @@ -1032,17 +1033,20 @@ "failedToDetailIspFieldModify" : "ISP �긽�꽭 �젙蹂� 議고쉶 �떎�뙣", "pleaseEnterIspFieldName": "ISP �씠由꾩쓣 �엯�젰�븯�꽭�슂.", "enterSpecialCharacters": "ISP �씠由꾩뿉�뒗 �듅�닔 臾몄옄瑜� �엯�젰 �븷 �닔 �뾾�뒿�땲�떎.", - "invalidCodeFormat": "肄붾뱶紐낆뿉�뒗 �듅�닔 臾몄옄瑜� �엯�젰 �븷 �닔 �뾾�뒿�땲�떎." + "invalidCodeFormat": "肄붾뱶紐낆뿉�뒗 �듅�닔 臾몄옄瑜� �엯�젰 �븷 �닔 �뾾�뒿�땲�떎.", + "registerExcelIspFields": "�뿊��濡� ISP �벑濡앺븯湲�", + "registerExcelUploadIspField": "�뿊�� �뾽濡쒕뱶 ISP �벑濡�", + "succeededIspFieldRegistration": "ISP �벑濡� �꽦怨�" }, "hostingField" : { "info": "�샇�뒪�똿�젙蹂�", "select": "�샇�뒪�똿 �꽑�깮", "add" : "�샇�뒪�똿�깮�꽦", "name" : "�샇�뒪�똿�씠由�", - "manager" : "�샇�뒪�똿�씠由�", "hostingName" : "�샇�뒪�똿紐�", "manager" : "�떞�떦�옄", "tel" : "�뿰�씫泥�", + "url" : "url", "code" : "肄붾뱶", "email" : "�씠硫붿씪", "memo" : "鍮꾧퀬", @@ -1053,6 +1057,9 @@ "failedToDetailHostingFieldModify" : "�샇�뒪�똿 �긽�꽭 �젙蹂� 議고쉶 �떎�뙣", "pleaseEnterHostingFieldName": "�샇�뒪�똿 �씠由꾩쓣 �엯�젰�븯�꽭�슂.", "enterSpecialCharacters": "�샇�뒪�똿 �씠由꾩뿉�뒗 �듅�닔 臾몄옄瑜� �엯�젰 �븷 �닔 �뾾�뒿�땲�떎.", - "invalidCodeFormat": "肄붾뱶紐낆뿉�뒗 �듅�닔 臾몄옄瑜� �엯�젰 �븷 �닔 �뾾�뒿�땲�떎." + "invalidCodeFormat": "肄붾뱶紐낆뿉�뒗 �듅�닔 臾몄옄瑜� �엯�젰 �븷 �닔 �뾾�뒿�땲�떎.", + "registerExcelHostingFields": "�뿊��濡� �샇�뒪�똿 �벑濡앺븯湲�", + "registerExcelUploadHostingField": "�뿊�� �뾽濡쒕뱶 �샇�뒪�똿 �벑濡�", + "succeededHostingFieldRegistration": "�샇�뒪�똿 �벑濡� �꽦怨�" } } \ No newline at end of file diff --git a/src/main/webapp/scripts/app/hostingField/hostingField.js b/src/main/webapp/scripts/app/hostingField/hostingField.js index c6145d2..79d2dd2 100644 --- a/src/main/webapp/scripts/app/hostingField/hostingField.js +++ b/src/main/webapp/scripts/app/hostingField/hostingField.js @@ -33,7 +33,7 @@ loadController : ["$q", function ($q) { var deferred = $q.defer(); require(["hostingFieldListController", 'jsTable', 'tableColumnGenerator', 'hostingFieldService', 'modalFormAutoScroll' - , 'hostingFieldAddController', 'hostingFieldModifyController' + , 'hostingFieldAddController', 'hostingFieldModifyController', 'hostingFieldImportExcelController' , 'formSubmit', 'jsShortCut', 'inputRegex'], function () { deferred.resolve(); }); diff --git a/src/main/webapp/scripts/app/hostingField/hostingFieldImportExcel.controller.js b/src/main/webapp/scripts/app/hostingField/hostingFieldImportExcel.controller.js new file mode 100644 index 0000000..f949206 --- /dev/null +++ b/src/main/webapp/scripts/app/hostingField/hostingFieldImportExcel.controller.js @@ -0,0 +1,80 @@ +/** + * Created by wisestone on 2018-01-17. + */ +'use strict'; + +define([ + 'app', + 'angular' + ], + function (app, angular) { + app.controller('hostingFieldImportExcelController', ['$scope', '$rootScope', '$log', '$resourceProvider', '$uibModalInstance', '$injector', '$controller', '$tableProvider', 'HostingField', 'SweetAlert', '$filter', '$timeout', + function ($scope, $rootScope, $log, $resourceProvider, $uibModalInstance, $injector, $controller, $tableProvider, HostingField, SweetAlert, $filter, $timeout) { + + $scope.fn = { + cancel : cancel, // �뙘�뾽 李� �떕湲� + formSubmit : formSubmit, // �뤌 �쟾�넚 + formCheck : formCheck, // �뤌 泥댄겕 + onFileSelect : onFileSelect, // �뙆�씪 �뾽濡쒕뱶 + }; + + $scope.vm = { + form : { + file : "", // �뾽濡쒕뱶�븯�뒗 Excel File + fileName : "" + }, + tab : "VIDEO" + }; + + // �뙆�씪 �뾽濡쒕뱶 + function onFileSelect($files) { + $scope.vm.form.file = $files; + + if ($files.length > 0) { + $scope.vm.form.fileName = $files[0].name; + } + else { + $scope.vm.form.fileName = ""; + } + } + + // �뤌 泥댄겕 + function formCheck() { + if ($scope.vm.form.file.length < 1) { + return true; + } + return false; + } + + // �뤌 �쟾�넚 + function formSubmit() { + $rootScope.spinner = true; + + HostingField.importExcel({ + method : "POST", + file : $scope.vm.form.file, + // data �냽�꽦�쑝濡� 蹂꾨룄�쓽 �뜲�씠�꽣 �쟾�넚 + fileFormDataName : "file" + }) + .then(function (result) { + if (result.data.message.status === "success") { + $timeout(function () { + SweetAlert.success($filter("translate")("hostingField.succeededHostingFieldRegistration"), result.data.message.message); // �벑濡� �꽦怨� + $scope.fn.cancel(); + $rootScope.$broadcast("getHostingFieldList"); + $rootScope.spinner = false; + }, 1000); + } + else { + SweetAlert.error($filter("translate")("hostingField.failedToSelectHostingFieldFullList"), result.data.message.message); // �벑濡� �떎�뙣 + $rootScope.spinner = false; + } + }); + } + + function cancel() { + $rootScope.$broadcast("closeLayer"); // �뙘�뾽�씠 �뿴由ш퀬 �굹�꽌 js-multi, js-single �벑�뿉�꽌 body �씠踰ㅽ듃媛� �궇�븘媛��뒗 �쁽�긽 �닔�젙 + $uibModalInstance.dismiss('cancel'); + } + }]); + }); diff --git a/src/main/webapp/scripts/app/hostingField/hostingFieldList.controller.js b/src/main/webapp/scripts/app/hostingField/hostingFieldList.controller.js index 886b2ab..175cd43 100644 --- a/src/main/webapp/scripts/app/hostingField/hostingFieldList.controller.js +++ b/src/main/webapp/scripts/app/hostingField/hostingFieldList.controller.js @@ -19,7 +19,8 @@ initSearch : initSearch, //寃��깋 議곌굔 珥덇린�솕 add : add, //�샇�뒪�똿 �깮�꽦 removes : removes, //�샇�뒪�똿 �궘�젣 - makeSearchConditions : makeSearchConditions //�뿊�� �떎�슫濡쒕뱶 + makeSearchConditions : makeSearchConditions, //�뿊�� �떎�슫濡쒕뱶 + importExcel : importExcel, // �뿊�� import 湲곕뒫 �뙘�뾽 �샇異� }; // 蹂��닔 @@ -46,6 +47,11 @@ // �샇�뒪�똿 愿�由� 由ъ뒪�듃 遺덈윭�삤湲� $scope.$on("getPageList", function () { + $scope.fn.getPageList(0); + }); + + // �샇�뒪�똿 紐⑸줉 �뜲�씠�꽣 媛깆떊 + $scope.$on("getHostingFieldList", function () { $scope.fn.getPageList(0); }); @@ -271,6 +277,16 @@ }); } + // �뿊�� import �뙘�뾽 �샇異� + function importExcel() { + $uibModal.open({ + templateUrl : 'views/hostingField/hostingFieldExcelImport.html', + size : "lg", + controller : 'hostingFieldImportExcelController', + backdrop : 'static' + }); + } + function makeSearchConditions() { var conditions = { name: $scope.vm.search.name diff --git a/src/main/webapp/scripts/app/ispField/ispField.js b/src/main/webapp/scripts/app/ispField/ispField.js index 0c46982..9f8e252 100644 --- a/src/main/webapp/scripts/app/ispField/ispField.js +++ b/src/main/webapp/scripts/app/ispField/ispField.js @@ -33,7 +33,7 @@ loadController : ["$q", function ($q) { var deferred = $q.defer(); require(["ispFieldListController", "ispFieldAddController", 'jsTable', 'tableColumnGenerator', 'ispFieldService', 'modalFormAutoScroll' - , 'ispFieldAddController', 'ispFieldModifyController' + , 'ispFieldAddController', 'ispFieldModifyController', 'ispFieldImportExcelController' , 'formSubmit', 'jsShortCut', 'inputRegex'], function () { deferred.resolve(); }); diff --git a/src/main/webapp/scripts/app/ispField/ispFieldImportExcel.controller.js b/src/main/webapp/scripts/app/ispField/ispFieldImportExcel.controller.js new file mode 100644 index 0000000..8886b9a --- /dev/null +++ b/src/main/webapp/scripts/app/ispField/ispFieldImportExcel.controller.js @@ -0,0 +1,80 @@ +/** + * Created by wisestone on 2018-01-17. + */ +'use strict'; + +define([ + 'app', + 'angular' + ], + function (app, angular) { + app.controller('ispFieldImportExcelController', ['$scope', '$rootScope', '$log', '$resourceProvider', '$uibModalInstance', '$injector', '$controller', '$tableProvider', 'IspField', 'SweetAlert', '$filter', '$timeout', + function ($scope, $rootScope, $log, $resourceProvider, $uibModalInstance, $injector, $controller, $tableProvider, IspField, SweetAlert, $filter, $timeout) { + + $scope.fn = { + cancel : cancel, // �뙘�뾽 李� �떕湲� + formSubmit : formSubmit, // �뤌 �쟾�넚 + formCheck : formCheck, // �뤌 泥댄겕 + onFileSelect : onFileSelect, // �뙆�씪 �뾽濡쒕뱶 + }; + + $scope.vm = { + form : { + file : "", // �뾽濡쒕뱶�븯�뒗 Excel File + fileName : "" + }, + tab : "VIDEO" + }; + + // �뙆�씪 �뾽濡쒕뱶 + function onFileSelect($files) { + $scope.vm.form.file = $files; + + if ($files.length > 0) { + $scope.vm.form.fileName = $files[0].name; + } + else { + $scope.vm.form.fileName = ""; + } + } + + // �뤌 泥댄겕 + function formCheck() { + if ($scope.vm.form.file.length < 1) { + return true; + } + return false; + } + + // �뤌 �쟾�넚 + function formSubmit() { + $rootScope.spinner = true; + + IspField.importExcel({ + method : "POST", + file : $scope.vm.form.file, + // data �냽�꽦�쑝濡� 蹂꾨룄�쓽 �뜲�씠�꽣 �쟾�넚 + fileFormDataName : "file" + }) + .then(function (result) { + if (result.data.message.status === "success") { + $timeout(function () { + SweetAlert.success($filter("translate")("ispField.succeededIspFieldRegistration"), result.data.message.message); // �벑濡� �꽦怨� + $scope.fn.cancel(); + $rootScope.$broadcast("getIspFieldList"); + $rootScope.spinner = false; + }, 1000); + } + else { + SweetAlert.error($filter("translate")("ispField.failedIspFieldRegistration"), result.data.message.message); // �벑濡� �떎�뙣 + $rootScope.spinner = false; + } + }); + } + + function cancel() { + $rootScope.$broadcast("closeLayer"); // �뙘�뾽�씠 �뿴由ш퀬 �굹�꽌 js-multi, js-single �벑�뿉�꽌 body �씠踰ㅽ듃媛� �궇�븘媛��뒗 �쁽�긽 �닔�젙 + $uibModalInstance.dismiss('cancel'); + } + }]); + }); diff --git a/src/main/webapp/scripts/app/ispField/ispFieldList.controller.js b/src/main/webapp/scripts/app/ispField/ispFieldList.controller.js index 21b6a3e..d7df780 100644 --- a/src/main/webapp/scripts/app/ispField/ispFieldList.controller.js +++ b/src/main/webapp/scripts/app/ispField/ispFieldList.controller.js @@ -19,7 +19,8 @@ initSearch : initSearch, //寃��깋 議곌굔 珥덇린�솕 add : add, //ISP �깮�꽦 removes : removes, //ISP �궘�젣 - makeSearchConditions : makeSearchConditions //�뿊�� �떎�슫濡쒕뱶 + makeSearchConditions : makeSearchConditions, //�뿊�� �떎�슫濡쒕뱶 + importExcel : importExcel, // �뿊�� import 湲곕뒫 �뙘�뾽 �샇異� }; // 蹂��닔 @@ -46,6 +47,11 @@ // iSP 愿�由� 由ъ뒪�듃 遺덈윭�삤湲� $scope.$on("getPageList", function () { + $scope.fn.getPageList(0); + }); + + // iSP 紐⑸줉 �뜲�씠�꽣 媛깆떊 + $scope.$on("getIspFieldList", function () { $scope.fn.getPageList(0); }); @@ -271,6 +277,16 @@ }); } + // �뿊�� import �뙘�뾽 �샇異� + function importExcel() { + $uibModal.open({ + templateUrl : 'views/ispField/ispFieldExcelImport.html', + size : "lg", + controller : 'ispFieldImportExcelController', + backdrop : 'static' + }); + } + function makeSearchConditions() { var conditions = { name: $scope.vm.search.name diff --git a/src/main/webapp/scripts/components/HostingField/hostingField.service.js b/src/main/webapp/scripts/components/HostingField/hostingField.service.js index 46ad84e..690e842 100644 --- a/src/main/webapp/scripts/components/HostingField/hostingField.service.js +++ b/src/main/webapp/scripts/components/HostingField/hostingField.service.js @@ -6,7 +6,7 @@ define([ 'app' ], function (app) { - app.factory("HostingField", ['$http', '$log', function ($http, $log) { + app.factory("HostingField", ['$http', '$log', '$upload', function ($http, $log, $upload) { return { find : function (conditions) { return $http.post("hostingField/find", conditions).then(function (response) { @@ -38,13 +38,20 @@ return response; }); }, + importExcel : function (conditions) { + conditions.url = "hostingField/importExcel"; + return $upload.upload(conditions).then(function (response) { + $log.debug("hostingField Import 寃곌낵 : ", response); + return response; + }); + }, // �뾽泥�/ISP/�샇�뒪�똿 議고쉶 getPartnerList : function (conditions) { return $http.post("company/getPartnerList", conditions).then(function (response) { $log.debug("�뾽泥�/isp/�샇�뒪�똿 紐⑸줉 議고쉶 寃곌낵 : ", response); return response; }); - } + }, } } diff --git a/src/main/webapp/scripts/components/ispField/ispField.service.js b/src/main/webapp/scripts/components/ispField/ispField.service.js index 242b06e..af75847 100644 --- a/src/main/webapp/scripts/components/ispField/ispField.service.js +++ b/src/main/webapp/scripts/components/ispField/ispField.service.js @@ -6,7 +6,7 @@ define([ 'app' ], function (app) { - app.factory("IspField", ['$http', '$log', function ($http, $log) { + app.factory("IspField", ['$http', '$log', '$upload', function ($http, $log, $upload) { return { find : function (conditions) { return $http.post("ispField/find", conditions).then(function (response) { @@ -37,6 +37,13 @@ $log.debug("IspField �궘�젣 寃곌낵 : ", response); return response; }); + }, + importExcel : function (conditions) { + conditions.url = "ispField/importExcel"; + return $upload.upload(conditions).then(function (response) { + $log.debug("ispField Import 寃곌낵 : ", response); + return response; + }); } } } diff --git a/src/main/webapp/scripts/main.js b/src/main/webapp/scripts/main.js index 9cde43c..14ab853 100644 --- a/src/main/webapp/scripts/main.js +++ b/src/main/webapp/scripts/main.js @@ -364,6 +364,7 @@ 'ispFieldListController' : 'app/ispField/ispFieldList.controller', // ISP 紐⑸줉 而⑦듃濡ㅻ윭 'ispFieldAddController' : 'app/ispField/ispFieldAdd.controller', // ISP �깮�꽦 而⑦듃濡ㅻ윭 'ispFieldModifyController' : 'app/ispField/ispFieldModify.controller', // ISP �닔�젙 而⑦듃濡ㅻ윭 + 'ispFieldImportExcelController' : 'app/ispField/ispFieldImportExcel.controller', // ISP �뿊�� �엫�룷�듃 而⑦듃濡ㅻ윭 /* �샇�뒪�똿 */ 'hostingFieldRoute' : 'app/hostingField/hostingField', // �샇�뒪�똿 route �젙蹂� @@ -371,6 +372,7 @@ 'hostingFieldListController' : 'app/hostingField/hostingFieldList.controller', // �샇�뒪�똿 紐⑸줉 而⑦듃濡ㅻ윭 'hostingFieldAddController' : 'app/hostingField/hostingFieldAdd.controller', // �샇�뒪�똿 �깮�꽦 而⑦듃濡ㅻ윭 'hostingFieldModifyController' : 'app/hostingField/hostingFieldModify.controller', // �샇�뒪�똿 �닔�젙 而⑦듃濡ㅻ윭 + 'hostingFieldImportExcelController' : 'app/hostingField/hostingFieldImportExcel.controller', // �샇�뒪�똿 �엫�룷�듃 而⑦듃濡ㅻ윭 /* �씠硫붿씪 �뀥�뵆由�*/ 'emailTemplateService' : 'components/emailTemplate/emailTemplate.service', // �샇�뒪�똿 愿��젴�맂 �넻�떊 �떞�떦 diff --git a/src/main/webapp/views/hostingField/hostingFieldExcelImport.html b/src/main/webapp/views/hostingField/hostingFieldExcelImport.html new file mode 100644 index 0000000..d531955 --- /dev/null +++ b/src/main/webapp/views/hostingField/hostingFieldExcelImport.html @@ -0,0 +1,83 @@ +<div class="formModal"> + <div class="modal-header faded smaller"> + <div class="modal-title"> + <strong translate="hostingField.registerExcelHostingFields">�뿊��濡� �샇�뒪�똿 �벑濡앺븯湲�</strong> + </div> + <button aria-label="Close" class="close" type="button" ng-click="fn.cancel()"> + <span aria-hidden="true"> ×</span> + </button> + </div> + + <div class="modal-body"> + <form role="form" name="hostingFieldExcelImportForm"> + <!--<div class="row"> + <div class="col-lg-5">--> + + <button type="button" + class="btn btn-success" + form-submit="hostingFieldExcelImportForm" make-search-conditions="fn.makeSearchConditions()" + style="width:100%;"><i class="fa fa-file-excel-o"></i> <span + translate="common.downloadExcel">�뿊�� �떎�슫濡쒕뱶</span> + </button> + + <div class="form-group pdt10"> + <div class="filebox input-group"> + <input class="upload-name form-control" + placeholder="{{'users.pleaseSelectFile' | translate}}" + tabindex="-1" + disabled="disabled" + ng-model="vm.form.fileName"> + <label for="uploadFileField"><span translate="common.uploadExcel">�뿊�� �뾽濡쒕뱶</span></label> + <input id="uploadFileField" + class="form-control" + type="file" + ng-file-select="fn.onFileSelect($files)"/> + </div> + </div> + + <button type="button" class="btn btn-md btn-primary bold" + ng-show="$root.isDefined(vm.form.file)" + style="width:100%;" + ng-disabled="fn.formCheck()" + ng-click="fn.formSubmit()"><span + translate="hostingField.registerExcelUploadHostingField">�뿊�� �뾽濡쒕뱶 �샇�뒪�똿 �벑濡�</span> + </button> + <!--</div>--> + + <!--<div class="col-lg-7 bdl1"> + <div class="os-tabs-w"> + <div class="os-tabs-controls"> + <ul class="nav nav-tabs smaller"> + <li class="nav-item cursor"> + <a class="nav-link" ng-class="{ 'active' : vm.tab == 'VIDEO' }" + ng-click="vm.tab = 'VIDEO'"><span + translate="issue.videoExample">�룞�쁺�긽 �삁�젣</span></a> + </li> + </ul> + </div> + + <div class="tab-content"> + <div ng-show="vm.tab == 'VIDEO'"> + <video style="width:100%;" width="100%" height="300px" + src="/excelTemplate/excelExample_new.mp4" controls autoplay loop muted + preload="auto"></video> + </div> + </div> + </div> + </div>--> + <!--</div>--> + </form> + <!-- �샇�뒪�똿 Excel Import �뀥�뵆由� �떎�슫濡쒕뱶 �뤌 --> + <form class="form-inline justify-content-sm-end" + method="post" + action="/hostingField/downloadExcelTemplate" + name="hostingFieldExcelImportForm"> + <input type="hidden" name="conditions"> + </form> + </div> + + <div class="modal-footer buttons-on-right"> + <button type="button" class="btn btn-md btn-grey" ng-click="fn.cancel()"><span + translate="common.close">�떕湲�</span></button> + </div> +</div> diff --git a/src/main/webapp/views/hostingField/hostingFieldList.html b/src/main/webapp/views/hostingField/hostingFieldList.html index a8e8893..5441814 100644 --- a/src/main/webapp/views/hostingField/hostingFieldList.html +++ b/src/main/webapp/views/hostingField/hostingFieldList.html @@ -76,6 +76,7 @@ </button> <div aria-labelledby="dropdownMenuButton2" class="dropdown-menu left-menu" x-placement="bottom-start"> + <a class="dropdown-item cursor" ng-click="fn.importExcel()"> <span translate="common.importExcel">Excel Import</span></a> <a class="dropdown-item cursor" form-submit="hostingFieldListForm" make-search-conditions="fn.makeSearchConditions()"><span translate="common.allDownloadExcel">�뿊�� �떎�슫濡쒕뱶</span></a> <a class="dropdown-item cursor" ng-click="fn.removes()"> <span translate="common.selectDelete">�궘�젣</span></a> </div> diff --git a/src/main/webapp/views/ispField/ispFieldExcelImport.html b/src/main/webapp/views/ispField/ispFieldExcelImport.html new file mode 100644 index 0000000..6a5235b --- /dev/null +++ b/src/main/webapp/views/ispField/ispFieldExcelImport.html @@ -0,0 +1,83 @@ +<div class="formModal"> + <div class="modal-header faded smaller"> + <div class="modal-title"> + <strong translate="ispField.registerExcelIspFields">�뿊��濡� �뾽泥� �벑濡앺븯湲�</strong> + </div> + <button aria-label="Close" class="close" type="button" ng-click="fn.cancel()"> + <span aria-hidden="true"> ×</span> + </button> + </div> + + <div class="modal-body"> + <form role="form" name="ispFieldExcelImportForm"> + <!--<div class="row"> + <div class="col-lg-5">--> + + <button type="button" + class="btn btn-success" + form-submit="ispFieldExcelImportForm" make-search-conditions="fn.makeSearchConditions()" + style="width:100%;"><i class="fa fa-file-excel-o"></i> <span + translate="common.downloadExcel">�뿊�� �떎�슫濡쒕뱶</span> + </button> + + <div class="form-group pdt10"> + <div class="filebox input-group"> + <input class="upload-name form-control" + placeholder="{{'users.pleaseSelectFile' | translate}}" + tabindex="-1" + disabled="disabled" + ng-model="vm.form.fileName"> + <label for="uploadFileField"><span translate="common.uploadExcel">�뿊�� �뾽濡쒕뱶</span></label> + <input id="uploadFileField" + class="form-control" + type="file" + ng-file-select="fn.onFileSelect($files)"/> + </div> + </div> + + <button type="button" class="btn btn-md btn-primary bold" + ng-show="$root.isDefined(vm.form.file)" + style="width:100%;" + ng-disabled="fn.formCheck()" + ng-click="fn.formSubmit()"><span + translate="ispField.registerExcelUploadIspField">�뿊�� �뾽濡쒕뱶 ISP �벑濡�</span> + </button> + <!--</div>--> + + <!--<div class="col-lg-7 bdl1"> + <div class="os-tabs-w"> + <div class="os-tabs-controls"> + <ul class="nav nav-tabs smaller"> + <li class="nav-item cursor"> + <a class="nav-link" ng-class="{ 'active' : vm.tab == 'VIDEO' }" + ng-click="vm.tab = 'VIDEO'"><span + translate="issue.videoExample">�룞�쁺�긽 �삁�젣</span></a> + </li> + </ul> + </div> + + <div class="tab-content"> + <div ng-show="vm.tab == 'VIDEO'"> + <video style="width:100%;" width="100%" height="300px" + src="/excelTemplate/excelExample_new.mp4" controls autoplay loop muted + preload="auto"></video> + </div> + </div> + </div> + </div>--> + <!--</div>--> + </form> + <!-- �뾽泥� Excel Import �뀥�뵆由� �떎�슫濡쒕뱶 �뤌 --> + <form class="form-inline justify-content-sm-end" + method="post" + action="/ispField/downloadExcelTemplate" + name="ispFieldExcelImportForm"> + <input type="hidden" name="conditions"> + </form> + </div> + + <div class="modal-footer buttons-on-right"> + <button type="button" class="btn btn-md btn-grey" ng-click="fn.cancel()"><span + translate="common.close">�떕湲�</span></button> + </div> +</div> diff --git a/src/main/webapp/views/ispField/ispFieldList.html b/src/main/webapp/views/ispField/ispFieldList.html index bb01173..00e4485 100644 --- a/src/main/webapp/views/ispField/ispFieldList.html +++ b/src/main/webapp/views/ispField/ispFieldList.html @@ -76,6 +76,7 @@ </button> <div aria-labelledby="dropdownMenuButton2" class="dropdown-menu left-menu" x-placement="bottom-start"> + <a class="dropdown-item cursor" ng-click="fn.importExcel()"> <span translate="common.importExcel">Excel Import</span></a> <a class="dropdown-item cursor" form-submit="ispFieldListForm" make-search-conditions="fn.makeSearchConditions()"><span translate="common.allDownloadExcel">�뿊�� �떎�슫濡쒕뱶</span></a> <a class="dropdown-item cursor" ng-click="fn.removes()"> <span translate="common.selectDelete">�궘�젣</span></a> </div> -- Gitblit v1.8.0