|
|
|
@ -54,6 +54,8 @@ import org.apache.poi.ss.usermodel.*; |
|
|
|
import org.apache.poi.xssf.streaming.SXSSFSheet; |
|
|
|
import org.apache.poi.xssf.streaming.SXSSFWorkbook; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.http.HttpHeaders; |
|
|
|
import org.springframework.http.MediaType; |
|
|
|
import org.springframework.http.ResponseEntity; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
@ -2684,6 +2686,9 @@ public class PatrolTaskController extends BaseController { |
|
|
|
private void exportExcelV2(HttpServletResponse response, List<PatrolData> dataList) throws Exception { |
|
|
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=\"task_export_" + System.currentTimeMillis() + ".xlsx\""); |
|
|
|
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); |
|
|
|
response.setHeader("Pragma", "no-cache"); |
|
|
|
response.setHeader("Expires", "0"); |
|
|
|
logger.info("[EXCEL]开始导出"); |
|
|
|
printMemoryInfo("开始导出"); |
|
|
|
|
|
|
|
@ -2733,17 +2738,15 @@ public class PatrolTaskController extends BaseController { |
|
|
|
pathMap = null; |
|
|
|
} |
|
|
|
|
|
|
|
response.setHeader("Transfer-Encoding", "chunked"); |
|
|
|
workbook.write(out); |
|
|
|
// 清理临时文件 |
|
|
|
workbook.dispose(); |
|
|
|
printMemoryInfo("结束导出"); |
|
|
|
} catch (IOException e) { |
|
|
|
logger.error("导出异常:{}", e); |
|
|
|
printMemoryInfo("导出异常"); |
|
|
|
} finally { |
|
|
|
Path start = Paths.get(TEMP_DIR); |
|
|
|
Files.walk(start) |
|
|
|
.filter(Files::isRegularFile) |
|
|
|
.sorted(Comparator.reverseOrder()) |
|
|
|
.forEach(path -> { |
|
|
|
try { |
|
|
|
Files.deleteIfExists(path); |
|
|
|
|