元数据模板导出 excel导入 5000条上限取消

This commit is contained in:
2026-10-29 09:16:18 +08:00
parent 3e3a1b8465
commit 4990a48b2c
2 changed files with 6 additions and 5 deletions
@@ -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<VersionResource, String> 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<VersionResource> parsed = new ArrayList<>();
List<Integer> 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;
+2 -1
View File
@@ -101,5 +101,6 @@ export interface ImportResult {
export function importResource(file: File) {
const form = new FormData()
form.append('file', file)
return request.post<never, ImportResult>('/resource/import', form)
// 大文件解析耗时较长,单独放宽超时(默认 30s)
return request.post<never, ImportResult>('/resource/import', form, { timeout: 300000 })
}