mirror of
https://github.com/suhf/No1WMS.git
synced 2026-02-04 19:54:00 +09:00
#수정
This commit is contained in:
@@ -160,54 +160,53 @@ public class VendorController {
|
||||
public String uploadExcel(@ModelAttribute("dto") VendorDto dto , RedirectAttributes redirectAttributes, final MultipartHttpServletRequest multiRequest,
|
||||
HttpServletRequest request, ModelMap model) {
|
||||
|
||||
Map<String, Object> resMap = new HashMap<>();
|
||||
|
||||
|
||||
try {
|
||||
|
||||
ExcelRequestManager em = new ExcelRequestManager();
|
||||
|
||||
// 멀티파트 요청 객체에서 파일 맵을 가져옴
|
||||
final Map<String, MultipartFile> files = multiRequest.getFileMap();
|
||||
//초기화
|
||||
List<HashMap<String,String>> apply =null;
|
||||
|
||||
//엑셀파일 가져와서 저장 및 읽기
|
||||
//변수는 멀티파트 요청 객체의 파일맵, 저장할 엑셀파일명 이름에 추가할 숫자(그냥 0으로 해도 됨)
|
||||
//마찬가지로 엑셀파일 명 이름에 추가할 문자열, uplode폴더에 들어갈 폴더명(카테고리같은 파트 이름으로 해주세요)
|
||||
//폴더가 없으면 자동생성되게 해뒀습니다.
|
||||
//마지막으로 HttpServletRequest
|
||||
apply = em.parseExcelSpringMultiPart(files, "테스트파일", 0, "", "category", request);
|
||||
|
||||
for (int i = 0; i < apply.size(); i++) {
|
||||
|
||||
|
||||
dto.setName(apply.get(i).get("nsme"));
|
||||
dto.setPresident_name(apply.get(i).get("president_name"));
|
||||
dto.setAddress(apply.get(i).get("address"));
|
||||
dto.setRegistration_number(apply.get(i).get("registration_number"));
|
||||
dto.setEmail(apply.get(i).get("email"));
|
||||
dto.setPresident_telephone(apply.get(i).get("president_telephone"));
|
||||
dto.setVendor_manager(apply.get(i).get("vendor_manager"));
|
||||
dto.setVendor_manager_telephone(apply.get(i).get("vendor_manager_telephone"));
|
||||
dto.setMain_product(apply.get(i).get("main_product"));
|
||||
dto.setManager_id(apply.get(i).get("manager_id"));
|
||||
dto.setActivation(true);
|
||||
|
||||
service.createProcess(dto);
|
||||
|
||||
}
|
||||
|
||||
resMap.put("res", "ok");
|
||||
resMap.put("msg", "업로드 성공");
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.toString());
|
||||
resMap.put("res", "error");
|
||||
resMap.put("msg", "업로드 실패");
|
||||
}
|
||||
|
||||
redirectAttributes.addFlashAttribute("resMap", resMap);
|
||||
|
||||
// Map<String, Object> resMap = new HashMap<>();
|
||||
//
|
||||
//
|
||||
// try {
|
||||
//
|
||||
// ExcelRequestManager em = new ExcelRequestManager();
|
||||
//
|
||||
// // 멀티파트 요청 객체에서 파일 맵을 가져옴
|
||||
// final Map<String, MultipartFile> files = multiRequest.getFileMap();
|
||||
// //초기화
|
||||
// List<HashMap<String,String>> apply =null;
|
||||
//
|
||||
// //엑셀파일 가져와서 저장 및 읽기
|
||||
// //변수는 멀티파트 요청 객체의 파일맵, 저장할 엑셀파일명 이름에 추가할 숫자(그냥 0으로 해도 됨)
|
||||
// //마찬가지로 엑셀파일 명 이름에 추가할 문자열, uplode폴더에 들어갈 폴더명(카테고리같은 파트 이름으로 해주세요)
|
||||
// //폴더가 없으면 자동생성되게 해뒀습니다.
|
||||
// //마지막으로 HttpServletRequest
|
||||
// apply = em.parseExcelSpringMultiPart(files, "거래처 데이터 입력 서식", 0, "", "vendor", request);
|
||||
//
|
||||
// for (int i = 0; i < apply.size(); i++) {
|
||||
//
|
||||
//
|
||||
// dto.setName(apply.get(i).get("cell_0"));
|
||||
// dto.setPresident_name(apply.get(i).get("cell_1"));
|
||||
// dto.setAddress(apply.get(i).get("cell_2"));
|
||||
// dto.setRegistration_number(apply.get(i).get("cell_3"));
|
||||
// dto.setEmail(apply.get(i).get("cell_4"));
|
||||
// dto.setPresident_telephone(apply.get(i).get("cell_5"));
|
||||
// dto.setVendor_manager(apply.get(i).get("cell_6"));
|
||||
// dto.setVendor_manager_telephone(apply.get(i).get("cell_7"));
|
||||
// dto.setMain_product(apply.get(i).get("cell_8"));
|
||||
// dto.setManager_id(manager_id);
|
||||
//
|
||||
//
|
||||
// service.createProcess(dto);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// resMap.put("res", "ok");
|
||||
// resMap.put("msg", "업로드 성공");
|
||||
// } catch (Exception e) {
|
||||
// System.out.println(e.toString());
|
||||
// resMap.put("res", "error");
|
||||
// resMap.put("msg", "업로드 실패");
|
||||
// }
|
||||
//
|
||||
// redirectAttributes.addFlashAttribute("resMap", resMap);
|
||||
return "redirect:/vendor/list";
|
||||
};
|
||||
}
|
||||
|
||||
10
src/main/webapp/WEB-INF/views/vendor/list.jsp
vendored
10
src/main/webapp/WEB-INF/views/vendor/list.jsp
vendored
@@ -12,6 +12,7 @@
|
||||
</div>
|
||||
<hr>
|
||||
<div class="body">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="col-12">
|
||||
<form>
|
||||
@@ -102,13 +103,13 @@
|
||||
|
||||
<form name="uplodeExcleForm" id="uplodeExcleForm" method="post" onsubmit="return _onSubmit();" action="/vendor/uplodeExcel" enctype="multipart/form-data" class="form-horizontal">
|
||||
<input type="file" name="file" id="file" accept=".xlsx, .xls"/>
|
||||
|
||||
<button type="submit" class="btn btn-success" id="uploadExcel">업로드</button>
|
||||
<%-- <input type='hidden' id="manager_id" value="${userData.id }">--%>
|
||||
</form><!-- uplodeExcleForm -->
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script>
|
||||
|
||||
@@ -189,7 +190,8 @@
|
||||
form.submit();
|
||||
|
||||
});
|
||||
|
||||
var msg = "${resMap.msg}";
|
||||
if (msg != "") alert(msg);
|
||||
|
||||
|
||||
});//ready
|
||||
|
||||
Reference in New Issue
Block a user