fix(解析器): 表头行整行格式污染时列范围按「非空表头」收缩
用户 Excel 表头行被整行格式化(整行实例化成 16384 个空单元格)时,货源/外观专利/集采 三处解析器按最大单元格列号展开列范围,每行数据被填充 1.6 万个占位空值,142KB 的 xlsx 生成 2.3GB 载荷,建任务 500(2026-09-26 生产事故:货源没跑出来.xlsx)。 - SimilarAsinExcelParser / AppearancePatentExcelParser / CollectDataService:列范围改为 只统计非空表头的最大列号,尾部空列不再生成占位列(中间空列占位行为保持不变) - 新增三处回归测试 + 事故样本(原样 + 集采关键词变体)
This commit is contained in:
+14
-1
@@ -120,12 +120,25 @@ public class SimilarAsinExcelParser {
|
||||
// EasyExcel 回调给出 列号 → 表头文本,与 POI Row 遍历等价(缺列一般为 null/空串)
|
||||
Map<String, Integer> map = new LinkedHashMap<>();
|
||||
List<String> headerNames = new ArrayList<>();
|
||||
// 列范围只按「非空表头」计算:表头行被整行格式污染时(如 A1:XFD1 整行被实例化成
|
||||
// 16384 个空单元格,只有前几列有值),若按最大单元格列号展开,headers 会撑到 16384 列,
|
||||
// 每行数据都被填充上万条占位空值,payload 膨胀上千倍(2026-09-26 生产事故:142KB 的
|
||||
// xlsx 生成 2.3GB 载荷,建任务 500)。尾部空列不再生成占位列。
|
||||
int lastCol = -1;
|
||||
for (Map.Entry<Integer, String> e : headerMapRaw.entrySet()) {
|
||||
if (e.getKey() != null && e.getKey() > lastCol) {
|
||||
if (e.getKey() == null || e.getKey() < 0) {
|
||||
continue;
|
||||
}
|
||||
if (normalize(e.getValue()).isBlank()) {
|
||||
continue;
|
||||
}
|
||||
if (e.getKey() > lastCol) {
|
||||
lastCol = e.getKey();
|
||||
}
|
||||
}
|
||||
if (lastCol < 0) {
|
||||
throw new BusinessException("Excel 表头为空");
|
||||
}
|
||||
for (int i = 0; i <= lastCol; i++) {
|
||||
String val = normalize(headerMapRaw.getOrDefault(i, ""));
|
||||
headerNames.add(val.isBlank() ? "列" + (i + 1) : val);
|
||||
|
||||
Reference in New Issue
Block a user