@Log(title = “任务管理”, businessType = BusinessType.EXPORT)
@ApiOperation(value = “抽检计划-导出”)
@PostMapping(“/exportSpotCheck”)
public ResponseEntity exportSpotCheck(@RequestBody Map map) {
try {
AjaxResult result = spotcheckPlanService.exportSpotcheckPlan((List) map.get(“ids”), 1);
if (String.valueOf(result.get(“code”)).equals(“200”)) {
String path = String.valueOf(result.get(“msg”));
String fileName = path.substring(path.lastIndexOf(File.separatorChar) + 1);
File file = new File(path);
ByteArrayResource resource = new ByteArrayResource(Files.readAllBytes(Paths.get(file.getAbsolutePath())));
return ResponseEntity.ok().header(“Content-Disposition”, “attachment;filename=” + URLEncoder.encode(fileName, “UTF-8”))
.contentLength(file.length()).contentType(MediaType.parseMediaType(“application/octet-stream”))
.body(resource);
}
} catch (Exception e) {
return null;
}
return null;
}