@GetMapping("/exportMaterial")
public ResponseEntity<byte[]> export(HttpServletRequest request, Dim dim ){
try {
String uuid = UUID.randomUUID().toString().replace("-","");
String path = request.getServletContext().getRealPath("temp/"+uuid+".xls");
Material material=new Material();
material.setWmType(dim.getInventoryId());
material.setCode(dim.getKeyword());
List list=iMaterialService.query(material);
POI.getExcel(list,path);
File file = new File(path);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
String fileName = "原材料.xls";
headers.setContentDispositionFormData("attachment",java.net.URLEncoder.encode(fileName, "UTF-8"));
return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.OK);
}catch (Exception e){
log.error(e);
return null;
}
}