src/main/java/kr/wisestone/owl/constant/MsgConstants.java
@@ -181,6 +181,17 @@ public static final String EXCEL_CUSTOM_FIELD_VALUE_NOT_VALIDITY = "EXCEL_CUSTOM_FIELD_VALUE_NOT_VALIDITY"; // 다음 엑셀 라인에서 입력한 사용자 정의 필드 값이 유효하지 않습니다. public static final String EXCEL_IMPORT_HEADER_CUSTOM_FIELD_NOT_EXIST = "EXCEL_IMPORT_HEADER_CUSTOM_FIELD_NOT_EXIST"; // 등록하려는 사용자 정의 필드를 찾을 수 없습니다. 해당 사용자 정의필드의 이름이 변경되었거나 삭제되었습니다. public static final String EXCEL_IMPORT_COMPANY_NAME_IS_NULL = "EXCEL_IMPORT_COMPANY_NAME_IS_NULL"; // 다음 엑셀 라인에서 업체명이 입력지 않았습니다. public static final String EXCEL_IMPORT_URL_IS_NULL = "EXCEL_IMPORT_URL_IS_NULL"; // 다음 엑셀 라인에서 URL이 입력지 않았습니다. public static final String EXCEL_IMPORT_ISP_NOT_EXIST = "EXCEL_IMPORT_ISP_NOT_EXIST"; // 다음 엑셀 라인에서 입력된 ISP명으로 검색되는 ISP가 없습니다. public static final String EXCEL_IMPORT_HOSTING_NOT_EXIST = "EXCEL_IMPORT_HOSTING_NOT_EXIST"; // 다음 엑셀 라인에서 입력된 호스팅명으로 검색되는 호스팅이 없습니다. public static final String EXCEL_IMPORT_PARENT_SECTOR_NOT_EQUAL = "EXCEL_IMPORT_PARENT_SECTOR_NOT_EQUAL"; // 다음 엑셀 라인에서 입력된 업종(중분류)은 업종(대분류)에 속해있지 않습니다. public static final String EXCEL_IMPORT_COMPANY_TYPE_NOT_EXIST = "EXCEL_IMPORT_COMPANY_TYPE_NOT_EXIST"; // 다음 엑셀 라인에서 입력된 기업구분명으로 검색되는 기업구분이 없습니다 public static final String EXCEL_IMPORT_PARENT_SECTOR_NOT_EXIST = "EXCEL_IMPORT_PARENT_SECTOR_NOT_EXIST"; // 다음 엑셀 라인에서 입력된 업종명으로 검색되는 업종(대분류)이 없습니다 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 DOWN_ISSUE_NOT_EXIST = "DOWN_ISSUE_NOT_EXIST"; // 하위 이슈 찾을수 없음 public static final String NOTICE_NOT_EXIST = "NOTICE_NOT_EXIST"; // 공지사항이 존재하지 않습니다. src/main/java/kr/wisestone/owl/service/CompanyFieldCategoryService.java
@@ -1,17 +1,11 @@ package kr.wisestone.owl.service; import kr.wisestone.owl.domain.CompanyField; import kr.wisestone.owl.domain.CompanyFieldCategory; import kr.wisestone.owl.domain.enumType.CompanyFieldCategoryType; import kr.wisestone.owl.vo.CompanyFieldCategoryVo; import kr.wisestone.owl.vo.CompanyFieldVo; import kr.wisestone.owl.web.condition.CompanyFieldCategoryCondition; import kr.wisestone.owl.web.condition.CompanyFieldCondition; import kr.wisestone.owl.web.form.CompanyFieldForm; import org.springframework.data.domain.Pageable; import org.springframework.ui.Model; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import java.util.List; import java.util.Map; @@ -19,4 +13,6 @@ List<CompanyFieldCategoryVo> find(Map<String, Object> resJsonData, CompanyFieldCategoryCondition condition, Pageable pageable); CompanyFieldCategory find(Long id); List<Map<String, Object>> findByType(CompanyFieldCategoryType categoryType); } src/main/java/kr/wisestone/owl/service/CompanyFieldService.java
@@ -4,8 +4,10 @@ import kr.wisestone.owl.vo.CompanyFieldVo; import kr.wisestone.owl.web.condition.CompanyFieldCondition; import kr.wisestone.owl.web.form.CompanyFieldForm; import kr.wisestone.owl.web.form.IssueForm; 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; @@ -32,4 +34,8 @@ void removeCompany(CompanyFieldForm make); ModelAndView downloadExcel(HttpServletRequest request, Model model); ModelAndView downloadExcelTemplate(HttpServletRequest request, Model model); void importExcel(MultipartFile multipartFile) throws Exception; } src/main/java/kr/wisestone/owl/service/HostingFieldService.java
@@ -1,6 +1,7 @@ package kr.wisestone.owl.service; import kr.wisestone.owl.domain.HostingField; import kr.wisestone.owl.domain.IspField; import kr.wisestone.owl.vo.HostingFieldVo; import kr.wisestone.owl.web.condition.HostingFieldCondition; import kr.wisestone.owl.web.form.HostingFieldForm; @@ -29,4 +30,6 @@ ModelAndView downloadExcel(HttpServletRequest request, Model model); List<HostingField> findAll(); } src/main/java/kr/wisestone/owl/service/IspFieldService.java
@@ -28,4 +28,6 @@ void remove(IspFieldForm make); ModelAndView downloadExcel(HttpServletRequest request, Model model); List<IspField> findAll(); } src/main/java/kr/wisestone/owl/service/impl/CompanyFieldCategoryServiceImpl.java
@@ -1,39 +1,22 @@ package kr.wisestone.owl.service.impl; import com.google.common.collect.Lists; import kr.wisestone.owl.common.ExcelConditionCheck; import kr.wisestone.owl.constant.Constants; import kr.wisestone.owl.constant.MsgConstants; import kr.wisestone.owl.domain.CompanyField; import kr.wisestone.owl.domain.CompanyFieldCategory; import kr.wisestone.owl.domain.HostingField; import kr.wisestone.owl.domain.IspField; import kr.wisestone.owl.domain.enumType.CompanyFieldCategoryType; import kr.wisestone.owl.exception.OwlRuntimeException; import kr.wisestone.owl.mapper.CompanyFieldCategoryMapper; import kr.wisestone.owl.mapper.CompanyFieldMapper; import kr.wisestone.owl.repository.CompanyFieldCategoryRepository; import kr.wisestone.owl.repository.CompanyFieldRepository; import kr.wisestone.owl.repository.HostingFieldRepository; import kr.wisestone.owl.repository.IspFieldRepository; import kr.wisestone.owl.service.*; import kr.wisestone.owl.util.ConvertUtil; import kr.wisestone.owl.vo.*; import kr.wisestone.owl.web.condition.CompanyFieldCategoryCondition; import kr.wisestone.owl.web.condition.CompanyFieldCondition; import kr.wisestone.owl.web.condition.HostingFieldCondition; import kr.wisestone.owl.web.form.CompanyFieldForm; import kr.wisestone.owl.web.view.ExcelView; import org.apache.commons.lang3.StringUtils; 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.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -76,6 +59,28 @@ return this.companyFieldCategoryMapper.findById(id); } public List<Map<String, Object>> findByType(CompanyFieldCategoryType categoryType) { CompanyFieldCategoryCondition condition = new CompanyFieldCategoryCondition(); switch (categoryType) { case COMPANYTYPE: condition.setTypeCategory("COMPANYTYPE"); break; case PARENTSECTOR: condition.setTypeCategory("PARENTSECTOR"); break; case CHILDSECTOR: condition.setTypeCategory("CHILDSECTOR"); break; case REGION: condition.setTypeCategory("REGION"); break; case STATUS: condition.setTypeCategory("STATUS"); break; } return this.companyFieldCategoryMapper.find(condition); } // 검색 결과를 Vo 로 변환한다. private List<CompanyFieldCategoryVo> convertCompanyFieldCategoryVoToMap(List<Map<String, Object>> results, Long totalCount, Pageable pageable, Map<String, Object> resJsonData) { List<CompanyFieldCategoryVo> companyFieldCategoryVos = Lists.newArrayList(); src/main/java/kr/wisestone/owl/service/impl/CompanyFieldServiceImpl.java
@@ -1,14 +1,17 @@ package kr.wisestone.owl.service.impl; import kr.wisestone.owl.domain.*; import kr.wisestone.owl.domain.enumType.CompanyFieldCategoryType; import kr.wisestone.owl.repository.HostingFieldRepository; import kr.wisestone.owl.repository.IspFieldRepository; import kr.wisestone.owl.service.*; import kr.wisestone.owl.util.CommonUtil; import kr.wisestone.owl.web.condition.CompanyFieldCategoryCondition; import kr.wisestone.owl.util.MapUtil; import kr.wisestone.owl.web.condition.CompanyFieldCondition; import kr.wisestone.owl.web.form.CompanyFieldForm; import kr.wisestone.owl.web.form.IssueForm; import org.apache.commons.lang3.StringUtils; import org.apache.poi.ss.usermodel.*; import org.springframework.transaction.annotation.Transactional; import org.springframework.ui.Model; import com.google.common.collect.Lists; @@ -25,6 +28,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; @@ -70,6 +74,9 @@ protected JpaRepository<CompanyField, Long> getRepository() { return this.companyFieldRepository; } private static final int EXCEL_DOWNLOAD_MAX_ROWS = 10000; // excel download 제한 private static final int EXCEL_IMPORT_MAX_ROWS = 10000; // excel import 제한 // 업체 추가 @Override @@ -222,6 +229,414 @@ } } // 업체 Import 용 엑셀 템플릿 다운로드 @Override @Transactional public ModelAndView downloadExcelTemplate(HttpServletRequest request, Model model) { ExportExcelVo excelInfo = new ExportExcelVo(); excelInfo.setHideCount(true); excelInfo.setFileName(this.messageAccessor.message("common.registerExcelCompanyField")); // 엑셀로 업체 등록하기 excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("companyField.companyName"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // 업체명 excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("companyField.companyUrl"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // url excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("isp.ispName"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // isp명 excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("Hosting.HostingName"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // 호스팅명 excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("companyField.companyTel"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // 연락처 excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("companyField.companyEmail"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // 이메일 excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("companyField.companyManager"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // 담당자 excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("companyField.companyTypeName"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // 기업구분 excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("companyField.parentSectorName"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // 업종(대분류) excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("companyField.childSectorName"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // 업종(중분류) excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("companyField.regionName"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // 지역 excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("companyField.statusName"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // 상태 excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("companyField.companyMemo"), 40, ExportExcelAttrVo.ALIGN_CENTER)); // 비고 // 엑셀에 넣을 데이터 - CompanyFieldVos 데이터를 엑셀에서 표시할 수 있는 데이터로 변경한다. excelInfo.setDatas(Lists.newArrayList(new CompanyFieldVo())); 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)); } } // 업체의 주요 속성을 map 에 저장하여 엑셀 import 에서 지정한 대상(업체 속성)을 빠르게 찾을 수 있게 한다. private void CompanyFieldAttributeMapToList(Map<String, IspField> ispFieldMaps, Map<String, HostingField> hostingFieldMaps, Map<String, Map<String, Object>> companyTypeMaps, Map<String, Map<String, Object>> parentSectorMaps, Map<String, Map<String, Object>> childSectorMaps, Map<String, Map<String, Object>> regionMaps, Map<String, Map<String, Object>> statusMaps) { List<IspField> ispFields = this.ispFieldService.findAll(); for (IspField ispField : ispFields) { ispFieldMaps.put(ispField.getName(), ispField); } List<HostingField> hostingFields = this.hostingFieldService.findAll(); for (HostingField hostingField : hostingFields) { hostingFieldMaps.put(hostingField.getName(), hostingField); } List<Map<String, Object>> companyTypes = this.companyFieldCategoryService.findByType(CompanyFieldCategoryType.COMPANYTYPE); for (Map<String, Object> companyType : companyTypes) { companyTypeMaps.put(MapUtil.getString(companyType, "useValue"), companyType); } List<Map<String, Object>> parentSectors = this.companyFieldCategoryService.findByType(CompanyFieldCategoryType.PARENTSECTOR); for (Map<String, Object> parentSector : parentSectors) { parentSectorMaps.put(MapUtil.getString(parentSector, "useValue"), parentSector); } List<Map<String, Object>> childSectors = this.companyFieldCategoryService.findByType(CompanyFieldCategoryType.CHILDSECTOR); for (Map<String, Object> childSector : childSectors) { childSectorMaps.put(MapUtil.getString(childSector, "useValue"), childSector); } List<Map<String, Object>> regions = this.companyFieldCategoryService.findByType(CompanyFieldCategoryType.REGION); for (Map<String, Object> region : regions) { regionMaps.put(MapUtil.getString(region, "useValue"), region); } List<Map<String, Object>> statuses = this.companyFieldCategoryService.findByType(CompanyFieldCategoryType.STATUS); for (Map<String, Object> status : statuses) { statusMaps.put(MapUtil.getString(status, "useValue"), status); } } // 엑셀 import 로 이슈를 등록한다. @Override @Transactional public void importExcel(MultipartFile multipartFile) throws Exception { // 사용하고 있는 업무 공간이 활성 상태인지 확인한다. 사용 공간에서 로그인한 사용자가 비활성인지 확인한다. this.workspaceService.checkUseWorkspace(); if (multipartFile != null) { // 업로드 파일 확장자 체크 this.verifyMultipartFileExtension(multipartFile); Map<String, IspField> ispFieldMaps = new HashMap<>(); // ISP 모음 Map<String, HostingField> hostingFieldMaps = new HashMap<>(); // 호스팅 모음 Map<String, Map<String, Object>> companyTypeMaps = new HashMap<>(); // 카테고리 모음 Map<String, Map<String, Object>> parentSectorMaps = new HashMap<>(); // 카테고리 모음 Map<String, Map<String, Object>> childSectorMaps = new HashMap<>(); // 카테고리 모음 Map<String, Map<String, Object>> regionMaps = new HashMap<>(); // 카테고리 모음 Map<String, Map<String, Object>> statusMaps = new HashMap<>(); // 카테고리 모음 // 업체의 주요 속성을 map 에 저장하여 엑셀 import 에서 지정한 대상(이슈 속성)을 빠르게 찾을 수 있게 한다. this.CompanyFieldAttributeMapToList(ispFieldMaps, hostingFieldMaps, companyTypeMaps, parentSectorMaps, childSectorMaps, regionMaps, statusMaps); // 0.237 - 0.230 List<CompanyFieldForm> companyFieldForms = 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) { // 업체로 등록하기 위해 CompanyFieldForm 에 데이터를 셋팅한다. CompanyFieldForm newCompanyFieldForm = this.setCompanyFieldFormToExcelField(row, (rowIndex + 1), ispFieldMaps, hostingFieldMaps, companyTypeMaps, parentSectorMaps, childSectorMaps, regionMaps, statusMaps, headers); companyFieldForms.add(newCompanyFieldForm); } } if (companyFieldForms.size() < 1) { return; } for (CompanyFieldForm saveCompanyFieldForm : companyFieldForms) { CompanyField companyField = new CompanyField(); ConvertUtil.copyProperties(saveCompanyFieldForm, companyField); companyField = this.companyFieldRepository.saveAndFlush(companyField); saveCompanyFieldForm.setId(companyField.getId()); } } } // 엑셀 필드에 있는 정보를 업체 form 으로 옮긴다. private CompanyFieldForm setCompanyFieldFormToExcelField(Row row, int rowIndex, Map<String, IspField> ispFieldMaps, Map<String, HostingField> hostingFieldMaps, Map<String, Map<String, Object>> companyTypeMaps, Map<String, Map<String, Object>> parentSectorMaps, Map<String, Map<String, Object>> childSectorMaps, Map<String, Map<String, Object>> regionMaps, Map<String, Map<String, Object>> statusMaps, List<String> headers) { CompanyFieldForm companyFieldForm = new CompanyFieldForm(); companyFieldForm.setRegisterId(this.webAppUtil.getLoginId()); // 제목, 내용, 프로젝트 키, 이슈 타입, 우선순위, 중요도, 담당자, 시작일, 종료일, 사용자 정의 필드 for (int cellIndex = 0; cellIndex < headers.size(); cellIndex++) { Cell cell = row.getCell(cellIndex); switch (cellIndex) { case 0: // 업체명 this.setCompanyFormName(cell, companyFieldForm, rowIndex); break; case 1: // url this.setCompanyFormUrl(cell, companyFieldForm, rowIndex); break; case 2: // isp명 if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) { this.setCompanyFormIspName(cell, ispFieldMaps, companyFieldForm, rowIndex); } break; case 3: // 호스팅명 if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) { this.setCompanyFormHostingName(cell, hostingFieldMaps, companyFieldForm, rowIndex); } break; case 4: // 연락처 if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) { this.setCompanyFormTel(cell, companyFieldForm, rowIndex); } break; case 5: // 이메일 if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) { this.setCompanyFormEmail(cell, companyFieldForm, rowIndex); } break; case 6: // 담당자 if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) { this.setCompanyFormManager(cell, companyFieldForm, rowIndex); } break; case 7: // 기업구분 if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) { this.setCompanyFormCompanyType(cell, companyTypeMaps, companyFieldForm, rowIndex); } break; case 8: // 업종(대분류) if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) { this.setCompanyFormParentSector(cell, parentSectorMaps, companyFieldForm, rowIndex); } break; case 9: // 업종(중분류) if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) { this.setCompanyFormChildSector(cell, childSectorMaps, companyFieldForm, rowIndex); } break; case 10: // 지역 if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) { this.setCompanyFormRegion(cell, regionMaps, companyFieldForm, rowIndex); } break; case 11: // 상태 if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) { this.setCompanyFormStatus(cell, statusMaps, companyFieldForm, rowIndex); } case 12: // 비고 if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) { this.setCompanyFormMemo(cell, companyFieldForm, rowIndex); } break; } } return companyFieldForm; } private void setCompanyFormMemo(Cell cell, CompanyFieldForm companyFieldForm, int rowIndex) { companyFieldForm.setMemo(CommonUtil.convertExcelStringToCell(cell)); } 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)); if (MapUtil.getLong(statusMap, "id") != null) { companyFieldForm.setStatusId(MapUtil.getLong(statusMap, "id")); } else { companyFieldForm.setStatusId(120L); } companyFieldForm.setStatusName(CommonUtil.convertExcelStringToCell(cell)); } } 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)); if (regionMap == null) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_REGION_NOT_EXIST, rowIndex)); } companyFieldForm.setRegionId(MapUtil.getLong(regionMap, "id")); } } 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)); if (!companyFieldForm.getParentSectorId().equals(MapUtil.getLong(childSectorMap, "parentId"))) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PARENT_SECTOR_NOT_EQUAL, rowIndex)); } companyFieldForm.setChildSectorId(MapUtil.getLong(childSectorMap, "id")); } } private void setCompanyFormParentSector(Cell cell, Map<String, Map<String, Object>> parentSectorMaps, CompanyFieldForm companyFieldForm, int rowIndex) { if (cell != null) { Map<String, Object> parentSectorMap = parentSectorMaps.get(CommonUtil.convertExcelStringToCell(cell)); if (parentSectorMap == null) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PARENT_SECTOR_NOT_EXIST, rowIndex)); } companyFieldForm.setParentSectorId(MapUtil.getLong(parentSectorMap, "id")); } } 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)); if (companyTypeMap == null) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_COMPANY_TYPE_NOT_EXIST, rowIndex)); } companyFieldForm.setCompanyTypeId(MapUtil.getLong(companyTypeMap, "id")); } } private void setCompanyFormManager(Cell cell, CompanyFieldForm companyFieldForm, int rowIndex) { if (cell != null) { companyFieldForm.setManager(CommonUtil.convertExcelStringToCell(cell)); } } private void setCompanyFormEmail(Cell cell, CompanyFieldForm companyFieldForm, int rowIndex) { if (cell != null) { companyFieldForm.setEmail(CommonUtil.convertExcelStringToCell(cell)); } } private void setCompanyFormTel(Cell cell, CompanyFieldForm companyFieldForm, int rowIndex) { if (cell != null) { companyFieldForm.setTel(CommonUtil.convertExcelStringToCell(cell)); } } private void setCompanyFormHostingName(Cell cell, Map<String, HostingField> hostingFieldMaps, CompanyFieldForm companyFieldForm, int rowIndex) { if (cell != null) { HostingField hostingField = hostingFieldMaps.get(CommonUtil.convertExcelStringToCell(cell)); if (hostingField == null) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_HOSTING_NOT_EXIST, rowIndex)); } companyFieldForm.setHostingId(hostingField.getId()); } } private void setCompanyFormIspName(Cell cell, Map<String, IspField> ispFieldMaps, CompanyFieldForm companyFieldForm, int rowIndex) { if (cell != null) { IspField ispField = ispFieldMaps.get(CommonUtil.convertExcelStringToCell(cell)); if (ispField == null) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_ISP_NOT_EXIST, rowIndex)); } companyFieldForm.setIspId(ispField.getId()); } } private void setCompanyFormName(Cell cell, CompanyFieldForm companyFieldForm, int rowIndex) { if (cell == null) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_COMPANY_NAME_IS_NULL, rowIndex)); } String title = CommonUtil.convertExcelStringToCell(cell); // 업체명 유효성 체크 this.verifyTitle(title); companyFieldForm.setName(title); } private void setCompanyFormUrl(Cell cell, CompanyFieldForm companyFieldForm, int rowIndex) { if (cell == null) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_URL_IS_NULL, rowIndex)); } String url = CommonUtil.convertExcelStringToCell(cell); this.verifyUrl(url, null); //url 유효성 검사 companyFieldForm.setUrl(url); } // 업체명 유효성 체크 private void verifyTitle(String title) { if (StringUtils.isEmpty(title)) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.ISSUE_NO_TITLE)); } if (title.length() > 300) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.ISSUE_TITLE_MAX_LENGTH_OUT)); } } // 업체 목록을 엑셀로 다운로드 한다. @Override public ModelAndView downloadExcel(HttpServletRequest request, Model model) { src/main/java/kr/wisestone/owl/service/impl/HostingFieldServiceImpl.java
@@ -6,6 +6,7 @@ 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; @@ -25,6 +26,7 @@ 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.servlet.ModelAndView; @@ -145,6 +147,12 @@ this.hostingFieldRepository.flush(); } @Override @Transactional(readOnly = true) public List<HostingField> findAll() { return this.hostingFieldRepository.findAll(); } // Hosting 목록을 엑셀로 다운로드 한다. @Override public ModelAndView downloadExcel(HttpServletRequest request, Model model) { src/main/java/kr/wisestone/owl/service/impl/IspFieldServiceImpl.java
@@ -6,6 +6,7 @@ import kr.wisestone.owl.constant.MsgConstants; import kr.wisestone.owl.domain.CompanyField; import kr.wisestone.owl.domain.IspField; import kr.wisestone.owl.domain.Priority; import kr.wisestone.owl.exception.OwlRuntimeException; import kr.wisestone.owl.mapper.IspFieldMapper; import kr.wisestone.owl.repository.IspFieldRepository; @@ -25,6 +26,7 @@ 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.servlet.ModelAndView; @@ -147,6 +149,12 @@ this.ispFieldRepository.flush(); } @Override @Transactional(readOnly = true) public List<IspField> findAll() { return this.ispFieldRepository.findAll(); } // Isp 목록을 엑셀로 다운로드 한다. @Override public ModelAndView downloadExcel(HttpServletRequest request, Model model) { src/main/java/kr/wisestone/owl/web/controller/CompanyFieldController.java
@@ -3,8 +3,10 @@ import kr.wisestone.owl.constant.Constants; import kr.wisestone.owl.service.CompanyFieldService; import kr.wisestone.owl.util.ConvertUtil; import kr.wisestone.owl.web.condition.CompanyFieldCondition; import kr.wisestone.owl.web.form.CompanyFieldForm; import kr.wisestone.owl.web.form.IssueForm; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Pageable; import org.springframework.http.MediaType; @@ -14,6 +16,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; @@ -93,5 +96,21 @@ public ModelAndView downloadExcel(HttpServletRequest request, Model model) { return this.companyFieldService.downloadExcel(request, model); } // 업체 Import 용 엑셀 템플릿 다운로드 @RequestMapping(value = "/companyField/downloadExcelTemplate", method = RequestMethod.POST) public ModelAndView downloadExcelImport(HttpServletRequest request, Model model) { return this.companyFieldService.downloadExcelTemplate(request, model); } // 업체 엑셀 등록 @RequestMapping(value = "/companyField/importExcel", method = RequestMethod.POST) public @ResponseBody Map<String, Object> importExcel(MultipartHttpServletRequest request) throws Exception { Map<String, Object> resJsonData = new HashMap<>(); this.companyFieldService.importExcel(request.getFile("file")); return this.setSuccessMessage(resJsonData); } } src/main/java/kr/wisestone/owl/web/form/CompanyFieldForm.java
@@ -22,6 +22,8 @@ private Long statusId; private String statusName; private Long registerId; // 등록자 아이디 - insert batch 에서 사용 private List<Long> removeIds = Lists.newArrayList(); public CompanyFieldForm() { @@ -146,4 +148,12 @@ public void setStatusName(String statusName) { this.statusName = statusName; } public Long getRegisterId() { return registerId; } public void setRegisterId(Long registerId) { this.registerId = registerId; } } src/main/webapp/WEB-INF/i18n/code_ko_KR.properties
@@ -39,6 +39,7 @@ common.typeErrorDownloadWidget=\uB2E4\uC6B4\uB85C\uB4DC \uC704\uC82F \uC720\uD615 \uC624\uB958 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.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 src/main/webapp/WEB-INF/i18n/messages_ko_KR.properties
@@ -167,7 +167,7 @@ EXCEL_CONDITIONS_NOT_EXIST = \uC5D1\uC140 \uB2E4\uC6B4\uB85C\uB4DC\uC5D0 \uD544\uC694\uD55C \uAC80\uC0C9 \uC870\uAC74\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. EXCEL_EMPTY_CELL = \uC5D1\uC140 \uD5E4\uB354 \uBD80\uBD84 \uC140\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. \uC5D1\uC140 \uC791\uC131 \uC591\uC2DD\uC5D0 \uBB38\uC81C\uAC00 \uC788\uC2B5\uB2C8\uB2E4. EXCEL_HEADER_EMPTY_CELL = \uC5D1\uC140 \uD5E4\uB354\uC5D0 \uBE48 \uC140\uC774 \uC788\uC2B5\uB2C8\uB2E4. EXCEL_IMPORT_ISSUE_TITLE_IS_NULL=\uB2E4\uC74C \uC5D1\uC140 \uB77C\uC778\uC5D0\uC11C \uC774\uC288 \uC81C\uBAA9\uC774 \uC785\uB825\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4. \n \uB77C\uC778 \uC815\uBCF4 : {0} EXCEL_IMPORT_ISSUE_TITLE_IS_NULL=\uB2E4\uC74C \uC5D1\uC140 \uB77C\uC778\uC5D0\uC11C \uC774\uC288 \uC81C\uBAA9\uC774 \uC785\uB825\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4. \n \uB77C\uC778 \uC815\uBCF4 : {0} EXCEL_IMPORT_PROJECT_KEY_IS_NULL=\uB2E4\uC74C \uC5D1\uC140 \uB77C\uC778\uC5D0\uC11C \uD504\uB85C\uC81D\uD2B8 \uD0A4\uAC00 \uC785\uB825\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4. \n \uB77C\uC778 \uC815\uBCF4 : {0} EXCEL_IMPORT_PROJECT_NOT_EXIST=\uB2E4\uC74C \uC5D1\uC140 \uB77C\uC778\uC5D0\uC11C \uC785\uB825\uB41C \uD504\uB85C\uC81D\uD2B8 \uD0A4\uB85C \uAC80\uC0C9\uB418\uB294 \uD504\uB85C\uC81D\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4. \n \uB77C\uC778 \uC815\uBCF4 : {0} EXCEL_IMPORT_ISSUE_TYPE_IS_NULL=\uB2E4\uC74C \uC5D1\uC140 \uB77C\uC778\uC5D0\uC11C \uC774\uC288 \uD0C0\uC785 \uBA85\uC774 \uC785\uB825\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4. \n \uB77C\uC778 \uC815\uBCF4 : {0} @@ -184,6 +184,16 @@ RESERVATION_EMAIL_TITLE=[OWL ITS] \uC5B4\uC81C \uC774\uC288 \uBC0F \uD65C\uB3D9 \uD604\uD669\uC785\uB2C8\uB2E4. REALTIME_EMAIL_TITLE=[OWL ITS] \uC2E4\uC2DC\uAC04 \uC774\uC288 \uBC0F \uD65C\uB3D9 \uD604\uD669\uC785\uB2C8\uB2E4. EXCEL_IMPORT_COMPANY_NAME_IS_NULL=\uB2E4\uC74C \uC5D1\uC140 \uB77C\uC778\uC5D0\uC11C \uC5C5\uCCB4\uBA85\uC774 \uC785\uB825\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4. \n \uB77C\uC778 \uC815\uBCF4 : {0} EXCEL_IMPORT_URL_IS_NULL=\uB2E4\uC74C \uC5D1\uC140 \uB77C\uC778\uC5D0\uC11C URL\uC774 \uC785\uB825\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4. \n \uB77C\uC778 \uC815\uBCF4 : {0} EXCEL_IMPORT_ISP_NOT_EXIST=\uB2E4\uC74C \uC5D1\uC140 \uB77C\uC778\uC5D0\uC11C \uC785\uB825\uB41C ISP\uBA85\uC73C\uB85C \uAC80\uC0C9\uB418\uB294 ISP\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4. \n \uB77C\uC778 \uC815\uBCF4 : {0} EXCEL_IMPORT_HOSTING_NOT_EXIST=\uB2E4\uC74C \uC5D1\uC140 \uB77C\uC778\uC5D0\uC11C \uC785\uB825\uB41C \uD638\uC2A4\uD305\uBA85\uC73C\uB85C \uAC80\uC0C9\uB418\uB294 \uD638\uC2A4\uD305\uC774 \uC5C6\uC2B5\uB2C8\uB2E4. \n \uB77C\uC778 \uC815\uBCF4 : {0} EXCEL_IMPORT_PARENT_SECTOR_NOT_EQUAL=\uB2E4\uC74C \uC5D1\uC140 \uB77C\uC778\uC5D0\uC11C \uC785\uB825\uB41C \uC5C5\uC885(\uC911\uBD84\uB958)\uC740 \uC5C5\uC885(\uB300\uBD84\uB958)\uC5D0 \uC18D\uD574\uC788\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \n \uB77C\uC778 \uC815\uBCF4 : {0} EXCEL_IMPORT_COMPANY_TYPE_NOT_EXIST=\uB2E4\uC74C \uC5D1\uC140 \uB77C\uC778\uC5D0\uC11C \uC785\uB825\uB41C \uAE30\uC5C5\uAD6C\uBD84\uBA85\uC73C\uB85C \uAC80\uC0C9\uB418\uB294 \uAE30\uC5C5\uAD6C\uBD84\uC774 \uC5C6\uC2B5\uB2C8\uB2E4. \n \uB77C\uC778 \uC815\uBCF4 : {0} EXCEL_IMPORT_PARENT_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(\uB300\uBD84\uB958)\uC774 \uC5C6\uC2B5\uB2C8\uB2E4. \n \uB77C\uC778 \uC815\uBCF4 : {0} 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} 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. src/main/webapp/i18n/ko/global.json
@@ -994,7 +994,10 @@ "enterSpecialCharacters": "업체 이름에는 특수 문자를 입력 할 수 없습니다.", "invalidTelFormat": "전화번호 형식이 맞지 않습니다. xxx-xxx-xxxx 형식으로 입력하세요.", "writeCompanyTel": "전화번호를 입력해주세요.", "writeTel": "전화번호를 입력하셔야 추가할수 있습니다." "writeTel": "전화번호를 입력하셔야 추가할수 있습니다.", "registerExcelCompanyFields": "엑셀로 업체 등록하기", "registerExcelUploadCompanyField": "엑셀 업로드 업체 등록", "succeededCompanyFieldRegistration": "업체 등록 성공" }, "ispField" : { "info": "ISP정보", src/main/webapp/scripts/app/companyField/companyField.js
@@ -33,7 +33,7 @@ loadController : ["$q", function ($q) { var deferred = $q.defer(); require(["companyFieldListController", 'jsTable', 'tableColumnGenerator', 'companyFieldService', 'modalFormAutoScroll' , 'companyFieldAddController', 'companyFieldModifyController' , 'companyFieldAddController', 'companyFieldModifyController', 'companyFieldImportExcelController' , 'formSubmit', 'jsShortCut', 'inputRegex'], function () { deferred.resolve(); }); src/main/webapp/scripts/app/companyField/companyFieldImportExcel.controller.js
New file @@ -0,0 +1,80 @@ /** * Created by wisestone on 2018-01-17. */ 'use strict'; define([ 'app', 'angular' ], function (app, angular) { app.controller('companyFieldImportExcelController', ['$scope', '$rootScope', '$log', '$resourceProvider', '$uibModalInstance', '$injector', '$controller', '$tableProvider', 'CompanyField', 'SweetAlert', '$filter', '$timeout', function ($scope, $rootScope, $log, $resourceProvider, $uibModalInstance, $injector, $controller, $tableProvider, CompanyField, 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; CompanyField.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")("companyField.succeededCompanyFieldRegistration"), result.data.message.message); // 등록 성공 $scope.fn.cancel(); $rootScope.$broadcast("getCompanyFieldList"); }, 1000); } else { SweetAlert.error($filter("translate")("companyField.failedCompanyFieldRegistration"), result.data.message.message); // 등록 실패 } $rootScope.spinner = false; }); } function cancel() { $rootScope.$broadcast("closeLayer"); // 팝업이 열리고 나서 js-multi, js-single 등에서 body 이벤트가 날아가는 현상 수정 $uibModalInstance.dismiss('cancel'); } }]); }); src/main/webapp/scripts/app/companyField/companyFieldList.controller.js
@@ -19,6 +19,7 @@ add : add, //업체 생성 makeSearchConditions : makeSearchConditions, //엑셀 다운로드 removes : removes, //업체 삭제 importExcel : importExcel, // 엑셀 import 기능 팝업 호출 }; // 변수 @@ -45,6 +46,11 @@ // 업체 관리 리스트 불러오기 $scope.$on("getPageList", function () { $scope.fn.getPageList(0); }); // 업체 목록 데이터 갱신 $scope.$on("getCompanyFieldList", function () { $scope.fn.getPageList(0); }); @@ -157,24 +163,28 @@ // 전화번호 조회시 하이픈 추가 해서 조회 result.data.data.forEach(function (data) { if (data.tel != null && data.tel !== "") { var tels = data.tel.substr(1, data.tel.indexOf("]")-1); var telArr = tels.split(","); if (data.tel.indexOf("[") !== -1){ var tels = data.tel.substr(1, data.tel.indexOf("]")-1); var telArr = tels.split(","); for (var i = 0; i < telArr.length; i++) { let hyphen = telArr[i].trim(); telArr[i] = hyphen.replace(/(^02.{0}|^01.{1}|[0-9]{3})([0-9]+)([0-9]{4})/, "$1-$2-$3"); if (telArr[i] === "") { telArr.splice(i,1); for (var i = 0; i < telArr.length; i++) { let hyphen = telArr[i].trim(); telArr[i] = hyphen.replace(/(^02.{0}|^01.{1}|[0-9]{3})([0-9]+)([0-9]{4})/, "$1-$2-$3"); if (telArr[i] === "") { telArr.splice(i,1); } } data.tel = telArr.join(); } data.tel = telArr.join(); } }); // 이메일 조회시 배열 형태 제거 result.data.data.forEach(function (data) { if (data.email != null && data.email !== "") { data.email = data.email.substr(1, data.email.indexOf("]")-1); if (data.email.indexOf("[") !== -1){ data.email = data.email.substr(1, data.email.indexOf("]")-1); } } }); @@ -219,6 +229,16 @@ }); } // 엑셀 import 팝업 호출 function importExcel() { $uibModal.open({ templateUrl : 'views/companyField/companyFieldExcelImport.html', size : "lg", controller : 'companyFieldImportExcelController', backdrop : 'static' }); } // 업체 삭제 function removes() { var removeIds = []; src/main/webapp/scripts/components/companyField/companyField.service.js
@@ -6,7 +6,7 @@ define([ 'app' ], function (app) { app.factory("CompanyField", ['$http', '$log', function ($http, $log) { app.factory("CompanyField", ['$http', '$log', '$upload', function ($http, $log, $upload) { return { find : function (conditions) { return $http.post("companyField/find", conditions).then(function (response) { @@ -32,6 +32,13 @@ return response; }); }, importExcel : function (conditions) { conditions.url = "companyField/importExcel"; return $upload.upload(conditions).then(function (response) { $log.debug("업체 Import 결과 : ", response); return response; }); }, removes : function (conditions) { return $http.post("companyField/remove", conditions).then(function (response) { $log.debug("업체 삭제 결과 : ", response); src/main/webapp/scripts/main.js
@@ -354,6 +354,7 @@ 'companyFieldListController' : 'app/companyField/companyFieldList.controller', // 업체 목록 컨트롤러 'companyFieldAddController' : 'app/companyField/companyFieldAdd.controller', // 업체 생성 컨트롤러 'companyFieldModifyController' : 'app/companyField/companyFieldModify.controller', // 업체 수정 컨트롤러 'companyFieldImportExcelController' : 'app/companyField/companyFieldImportExcel.controller', // 업체 엑셀 임포트 컨트롤러 'companyFieldCategoryService' : 'components/companyFieldCategory/companyFieldCategory.service', // 업체 카테고리 src/main/webapp/views/companyField/companyFieldExcelImport.html
New file @@ -0,0 +1,83 @@ <div class="formModal"> <div class="modal-header faded smaller"> <div class="modal-title"> <strong translate="companyField.registerExcelCompanyFields">엑셀로 업체 등록하기</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="companyFieldExcelImportForm"> <!--<div class="row"> <div class="col-lg-5">--> <button type="button" class="btn btn-success" form-submit="companyFieldExcelImportForm" 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="companyField.registerExcelUploadCompanyField">엑셀 업로드 업체 등록</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="/companyField/downloadExcelTemplate" name="companyFieldExcelImportForm"> <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> src/main/webapp/views/companyField/companyFieldList.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="companyFieldListForm" 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> src/main/webapp/views/issue/issueExcelImport.html
@@ -9,7 +9,7 @@ </div> <div class="modal-body"> <form role="form" name="issueExcelImportFrom"> <form role="form" name="issueExcelImportForm"> <div class="row"> <div class="col-lg-5"> <div class="form-group"> @@ -39,9 +39,9 @@ type : '', maxlength : 200, autoResize : true, stopRemoveBodyEvent : true }"></js-autocomplete-single> <div class="form-group mt-5"> <label for="issueExcelImportFrom3"> <span translate="issue.issueType">이슈 타입</span> <code <label for="issueExcelImportForm3"> <span translate="issue.issueType">이슈 타입</span> <code class="highlighter-rouge">*</code></label> <select id="issueExcelImportFrom3" <select id="issueExcelImportForm3" name="issueType" class="form-control input-sm" ng-model="vm.form.issueTypeId"