Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b24c5e3849 | |||
| 4990a48b2c |
+4
-4
@@ -29,8 +29,8 @@ public class VersionResourceExcelService {
|
|||||||
|
|
||||||
private final VersionResourceService versionResourceService;
|
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,
|
private record Column(String header, String field,
|
||||||
BiConsumer<VersionResource, String> setter, int maxLen, String hint) {
|
BiConsumer<VersionResource, String> setter, int maxLen, String hint) {
|
||||||
@@ -215,7 +215,7 @@ public class VersionResourceExcelService {
|
|||||||
DataValidationHelper helper = sheet.getDataValidationHelper();
|
DataValidationHelper helper = sheet.getDataValidationHelper();
|
||||||
DataValidationConstraint constraint =
|
DataValidationConstraint constraint =
|
||||||
helper.createExplicitListConstraint(options);
|
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);
|
DataValidation validation = helper.createValidation(constraint, range);
|
||||||
validation.setSuppressDropDownArrow(true);
|
validation.setSuppressDropDownArrow(true);
|
||||||
validation.setShowErrorBox(true);
|
validation.setShowErrorBox(true);
|
||||||
@@ -267,7 +267,7 @@ public class VersionResourceExcelService {
|
|||||||
List<VersionResource> parsed = new ArrayList<>();
|
List<VersionResource> parsed = new ArrayList<>();
|
||||||
List<Integer> rowNums = 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++) {
|
for (int r = startRow; r <= last; r++) {
|
||||||
Row row = sheet.getRow(r);
|
Row row = sheet.getRow(r);
|
||||||
if (row == null) continue;
|
if (row == null) continue;
|
||||||
|
|||||||
@@ -101,5 +101,6 @@ export interface ImportResult {
|
|||||||
export function importResource(file: File) {
|
export function importResource(file: File) {
|
||||||
const form = new FormData()
|
const form = new FormData()
|
||||||
form.append('file', file)
|
form.append('file', file)
|
||||||
return request.post<never, ImportResult>('/resource/import', form)
|
// 大文件解析耗时较长,单独放宽超时(默认 30s)
|
||||||
|
return request.post<never, ImportResult>('/resource/import', form, { timeout: 300000 })
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user