From 4990a48b2c5b3a52558490bcc401ecfce2aa7fba Mon Sep 17 00:00:00 2001 From: yangbin Date: Thu, 29 Oct 2026 09:16:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=83=E6=95=B0=E6=8D=AE=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=20excel=E5=AF=BC=E5=85=A5=20=205000=E6=9D=A1?= =?UTF-8?q?=E4=B8=8A=E9=99=90=E5=8F=96=E6=B6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resource/service/VersionResourceExcelService.java | 8 ++++---- frontend/src/api/resource.ts | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/com/banben/modules/resource/service/VersionResourceExcelService.java b/backend/src/main/java/com/banben/modules/resource/service/VersionResourceExcelService.java index 5394ad5..8d07779 100644 --- a/backend/src/main/java/com/banben/modules/resource/service/VersionResourceExcelService.java +++ b/backend/src/main/java/com/banben/modules/resource/service/VersionResourceExcelService.java @@ -29,8 +29,8 @@ public class VersionResourceExcelService { private final VersionResourceService versionResourceService; - /** 单次导入的最大数据行数,防止超大文件拖垮服务 */ - private static final int MAX_ROWS = 5000; + /** 下拉校验覆盖的行数;只影响模板中下拉框的作用范围,不限制导入行数 */ + private static final int DROPDOWN_ROWS = 5000; private record Column(String header, String field, BiConsumer setter, int maxLen, String hint) { @@ -215,7 +215,7 @@ public class VersionResourceExcelService { DataValidationHelper helper = sheet.getDataValidationHelper(); DataValidationConstraint constraint = helper.createExplicitListConstraint(options); - CellRangeAddressList range = new CellRangeAddressList(2, MAX_ROWS, colIndex, colIndex); + CellRangeAddressList range = new CellRangeAddressList(2, DROPDOWN_ROWS, colIndex, colIndex); DataValidation validation = helper.createValidation(constraint, range); validation.setSuppressDropDownArrow(true); validation.setShowErrorBox(true); @@ -267,7 +267,7 @@ public class VersionResourceExcelService { List parsed = new ArrayList<>(); List rowNums = new ArrayList<>(); - int last = Math.min(sheet.getLastRowNum(), startRow + MAX_ROWS); + int last = sheet.getLastRowNum(); for (int r = startRow; r <= last; r++) { Row row = sheet.getRow(r); if (row == null) continue; diff --git a/frontend/src/api/resource.ts b/frontend/src/api/resource.ts index 79a6bf3..0fc62fd 100644 --- a/frontend/src/api/resource.ts +++ b/frontend/src/api/resource.ts @@ -101,5 +101,6 @@ export interface ImportResult { export function importResource(file: File) { const form = new FormData() form.append('file', file) - return request.post('/resource/import', form) + // 大文件解析耗时较长,单独放宽超时(默认 30s) + return request.post('/resource/import', form, { timeout: 300000 }) }