From 4326bd78735bc8b8ba827407ced715c966551770 Mon Sep 17 00:00:00 2001 From: shenzhouyu Date: Mon, 11 Aug 2025 09:57:17 +0800 Subject: [PATCH] =?UTF-8?q?ipqc=E5=AF=BC=E5=87=BA=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/xujie/sys/config/MybatisPlusConfig.java | 2 +- .../sys/modules/pms/controller/QcReportController.java | 5 ++--- .../sys/modules/pms/service/Impl/QcReportServiceImpl.java | 8 +++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/xujie/sys/config/MybatisPlusConfig.java b/src/main/java/com/xujie/sys/config/MybatisPlusConfig.java index 2cf9ebf..d034cbf 100644 --- a/src/main/java/com/xujie/sys/config/MybatisPlusConfig.java +++ b/src/main/java/com/xujie/sys/config/MybatisPlusConfig.java @@ -24,7 +24,7 @@ public class MybatisPlusConfig { // 当前页码大于总页数返回首页 paginationInterceptor.setOverflow(true); // 单页最大条数,默认 500;设为 -1 不做限制 - paginationInterceptor.setLimit(5000); + paginationInterceptor.setLimit(50000); return paginationInterceptor; } diff --git a/src/main/java/com/xujie/sys/modules/pms/controller/QcReportController.java b/src/main/java/com/xujie/sys/modules/pms/controller/QcReportController.java index 2a2d7f3..f191545 100644 --- a/src/main/java/com/xujie/sys/modules/pms/controller/QcReportController.java +++ b/src/main/java/com/xujie/sys/modules/pms/controller/QcReportController.java @@ -74,12 +74,11 @@ public class QcReportController { } @PostMapping("/downloadQcRecordMillion") - public R downloadQcRecordMillion(HttpServletResponse response, @RequestBody QcReportData data)throws Exception { + public void downloadQcRecordMillion(HttpServletResponse response, @RequestBody QcReportData data)throws Exception { try { qcReportService.downloadQcRecordMillion(response, data); - return R.ok(); } catch (IOException e) { - return R.error(e.getMessage()); + e.printStackTrace(); } } diff --git a/src/main/java/com/xujie/sys/modules/pms/service/Impl/QcReportServiceImpl.java b/src/main/java/com/xujie/sys/modules/pms/service/Impl/QcReportServiceImpl.java index 9ec02fe..d5d3a7f 100644 --- a/src/main/java/com/xujie/sys/modules/pms/service/Impl/QcReportServiceImpl.java +++ b/src/main/java/com/xujie/sys/modules/pms/service/Impl/QcReportServiceImpl.java @@ -141,6 +141,8 @@ public class QcReportServiceImpl implements QcReportService { // 4. 查询总数 int totalRowCount = this.qcReportMapper.getIPQCReportCountOptimized(data); + System.out.println("----------------------------"+totalRowCount); + if (totalRowCount <= 0) { // 处理空数据:写入空Excel(避免客户端收到损坏文件) writer = EasyExcel.write(out, QcReportIPQCData.class).autoCloseStream(false).build(); @@ -154,6 +156,7 @@ public class QcReportServiceImpl implements QcReportService { // 5. 分页参数 int pageSize = ExcelConstant.PER_WRITE_ROW_COUNT; int writeCount = (totalRowCount + pageSize - 1) / pageSize; // 优化分页计算 + System.out.println("-----------------"+writeCount); // 6. 线程池(明确配置,避免资源泄漏) executor = new ThreadPoolExecutor( @@ -187,7 +190,7 @@ public class QcReportServiceImpl implements QcReportService { // 9. 处理子线程结果(捕获异常) for (Future> future : futureList) { try { - List dataList = future.get(30, TimeUnit.SECONDS); // 单个任务超时 + List dataList = future.get(180, TimeUnit.SECONDS); // 单个任务超时 if (dataList != null) { writer.write(dataList, sheet); } @@ -203,13 +206,12 @@ public class QcReportServiceImpl implements QcReportService { out.flush(); } catch (Exception e) { - // 增强异常信息,便于排查 throw new RuntimeException("下载QC报表失败: " + e.getMessage(), e); } finally { // 10. 按顺序关闭资源(先关闭writer,再关闭流) if (writer != null) { try { - writer.finish(); // 确保最后关闭writer + writer.finish(); } catch (Exception e) { e.printStackTrace(); }