Browse Source

ipqc导出修改

master^2
shenzhouyu 8 months ago
parent
commit
4326bd7873
  1. 2
      src/main/java/com/xujie/sys/config/MybatisPlusConfig.java
  2. 5
      src/main/java/com/xujie/sys/modules/pms/controller/QcReportController.java
  3. 8
      src/main/java/com/xujie/sys/modules/pms/service/Impl/QcReportServiceImpl.java

2
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;
}

5
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();
}
}

8
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<List<QcReportIPQCData>> future : futureList) {
try {
List<QcReportIPQCData> dataList = future.get(30, TimeUnit.SECONDS); // 单个任务超时
List<QcReportIPQCData> 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();
}

Loading…
Cancel
Save