@RequestMapping(value="/iv/outInStoreUploadExcel", method = RequestMethod.POST)
public @ResponseBody
LayerData<Map<String,Object>> uploadExcel(@RequestParam("file") MultipartFile file,
HttpServletRequest request) {
String contentType = file.getContentType();
String fileName = file.getOriginalFilename();
String filePath = request.getSession().getServletContext().getRealPath("imgupload/");
LayerData<Map<String,Object>> layerData = new LayerData<>();
List<String[]> dataList;
List<Map<String,Object>> matList = new ArrayList<>();
try {
FileUtil.uploadFile(file.getBytes(), filePath, fileName);
dataList = ExcelUtil.read(filePath + "\\" + fileName).get(0);
for (int i = 1; i < dataList.size(); i++) {
Map<String,Object> map =new HashMap<>();
map.put("matNo",dataList.get(i)[1]);
map.put("matName",dataList.get(i)[2]);
map.put("matTypeName",dataList.get(i)[3]);
map.put("rawnatureName",dataList.get(i)[4]);
map.put("minStockQty",dataList.get(i)[5]);
map.put("batchQty",dataList.get(i)[6]);
map.put("procureStyle",dataList.get(i)[7]);
map.put("isQc",dataList.get(i)[8]);
map.put("unitNo",dataList.get(i)[9]);
map.put("spec",dataList.get(i)[10]);
map.put("shape",dataList.get(i)[11]);
map.put("planPrice",dataList.get(i)[12]);
map.put("storeHouseName",dataList.get(i)[13]);
map.put("binName",dataList.get(i)[14]);
map.put("stockQty",dataList.get(i)[15]);
map.put("stockWeight",dataList.get(i)[16]);
map.put("stockPrice",dataList.get(i)[17]);
matList.add(map);
}
layerData.setData(matList);
} catch (Exception e) {
e.printStackTrace();
}
//返回json
return layerData;
}
excl导入
最新推荐文章于 2024-05-24 15:41:39 发布