diff --git a/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisSettleInvoiceRecordController.java b/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisSettleInvoiceRecordController.java index 318ab3cbc..a713815d0 100644 --- a/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisSettleInvoiceRecordController.java +++ b/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisSettleInvoiceRecordController.java @@ -13,6 +13,9 @@ package com.xdadan.erp.web.emis; import java.util.List; import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import javax.servlet.http.HttpServletResponse; import com.xdadan.erp.emis.domain.exception.EmisBizError; @@ -113,6 +116,7 @@ public class EmisSettleInvoiceRecordController extends BaseController { /** * 定制导出开票记录表列表 + * 设置5分钟超时,超时后自动关闭 * */ @PreAuthorize("@ss.hasPermi('emis:emisSettleInvoiceRecord:customExport')") @@ -137,9 +141,44 @@ public class EmisSettleInvoiceRecordController extends BaseController { emisSettleInvoiceRecord.getParams().put("billCode", billCodeStr); } - List list = emisSettleInvoiceRecordService - .selectCustomExportList(emisSettleInvoiceRecord); - EmisSettleInvoiceRecordCustomExcelUtil.exportCustomExcel(response, list, "开票记录表定制导出数据_"+ UUID.randomUUID()); + CompletableFuture exportFuture = CompletableFuture.runAsync(() -> { + try { + List list = emisSettleInvoiceRecordService + .selectCustomExportList(emisSettleInvoiceRecord); + EmisSettleInvoiceRecordCustomExcelUtil.exportCustomExcel(response, list, + "开票记录表定制导出数据_" + UUID.randomUUID()); + } catch (Exception e) { + throw new RuntimeException("导出失败: " + e.getMessage(), e); + } + }); + + try { + // 设置5分钟超时 + exportFuture.get(5, TimeUnit.MINUTES); + } catch (TimeoutException e) { + // 超时后取消任务 + exportFuture.cancel(true); + try { + if (!response.isCommitted()) { + response.reset(); + response.setContentType("application/json;charset=utf-8"); + response.getWriter().write("{\"success\":false,\"message\":\"导出数据量过大导致超时,请缩小查询范围后重试\"}"); + } + } catch (Exception ex) { + // 忽略写入错误 + } + } catch (Exception e) { + try { + if (!response.isCommitted()) { + response.reset(); + response.setContentType("application/json;charset=utf-8"); + String errorMsg = e.getCause() != null ? e.getCause().getMessage() : e.getMessage(); + response.getWriter().write("{\"success\":false,\"message\":\"导出失败: " + errorMsg + "\"}"); + } + } catch (Exception ex) { + // 忽略写入错误 + } + } } /** diff --git a/emis-biz/src/main/resources/mapper/EmisTmsScanRecordMapper.xml b/emis-biz/src/main/resources/mapper/EmisTmsScanRecordMapper.xml index 5aaeed49d..ac7d31045 100644 --- a/emis-biz/src/main/resources/mapper/EmisTmsScanRecordMapper.xml +++ b/emis-biz/src/main/resources/mapper/EmisTmsScanRecordMapper.xml @@ -208,11 +208,13 @@ a.scan_man_code FROM emis_tms_scan_record a ,emis_waybill b + LEFT JOIN emis_trans_line k ON b.trans_line_type = k.line_code AND k.del_flag = '0' WHERE a.del_flag = '0' and b.del_flag='0' and a.bill_code = b.bill_code and b.bl_sign = '0' and b.bill_code NOT IN ( SELECT bill_code FROM emis_waybill_problem_info ewpi WHERE ewpi.del_flag = '0' AND ewpi.`problem_type` IN ( 151, 173, 170 ) ) + and NOT (b.customs_clear = 2 AND k.trans_type = 2) and a.scan_site_code=#{scanSiteCode} and a.scan_type=#{scanType}