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