前言:之前实现的需求由于导出时需要的时间过于长,需要优化采用多线程的方式进行导出
更改之后的代码:
首先创建excel的临时文件,并写入。然后创建线程池,调用zipArchiveOutputStream来写入图片和excel
@PostMapping("/export3")
public void exportZip(HttpServletResponse response,
@RequestParam(value = "startTime",required = false)String startTime,
@RequestParam(value = "endTime",required = false)String endTime,
@RequestParam(value = "deviceName",required = false)String deviceName) throws IOException {
List<CutterImageVO> cutterImageVOList = cutterImageService.getCutterImageList(startTime,endTime,deviceName);
long start = System.currentTimeMillis();
String zipFileName = "豁口图片数据";
response.setCharacterEncoding("utf-8");