fix(brand-label): 品牌检测链读写两端接上 BrandLabel,解析处单点清洗
onRow 落 row map 时就把品牌列的标签前缀剥掉:查询集 uniqueBrands、与执行方回传值的匹配、 结果文件里那一格必须是同一个字符串。只在写出端剥会让比对两边分家——判为"不符合"的行剔不掉, 用户把没通过的行当成已通过上架。纯标签值("Brand:")洗完即空,与"这行没填品牌"走同一条路径, 不再送给上游当 Solr 字段限定符(2026-10-08 单日 19,247 次 undefined field Brand 的起点)。 normalizeBrandSet 与 normalizeBrandSetFromInvalids 也归一:执行方刻意回传原值(失败清单要能对 得上用户表里那一行),服务端两侧同口径才命中,legacy 脏分片照样剔得掉。 「不符合品牌」与「查询失败品牌」两张 sheet 的写出各兜一次——后者本身就是被打回的品牌清单, 用户改完直接再传,这一格不洗就把同一个脏值原样送回链路。 BrandTaskServiceResultRowsTest 里 "Brand: CC" 那条出件断言按新口径改为 "CC"(那张表用户会再传), 另加一条钉住"查询集与出件同口径、纯标签行不算品牌"。 门禁:隔离 worktree(HEAD + 本笔两文件)跑 mvn -o test 全量 4595 例 0 红。本仓工作树此刻另有 一路在飞的 brand/support 抽取(NotificationDispatchService 签名未接完),全量读数只在隔离树取。
This commit is contained in:
+20
-7
@@ -11,6 +11,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.nanri.aiimage.common.exception.BusinessException;
|
||||
import com.nanri.aiimage.common.security.AdminAuthSupport;
|
||||
import com.nanri.aiimage.common.service.DistributedJobLockService;
|
||||
import com.nanri.aiimage.common.util.BrandLabel;
|
||||
import com.nanri.aiimage.common.util.ExcelStreamReader;
|
||||
import com.nanri.aiimage.config.BrandProgressProperties;
|
||||
import com.nanri.aiimage.config.HttpClientPool;
|
||||
@@ -816,7 +817,7 @@ public class BrandTaskService {
|
||||
handled.addAll(normalizeBrandSet(aggregate.getQueryFailedBrands()));
|
||||
LinkedHashSet<String> undetected = new LinkedHashSet<>();
|
||||
for (Map<String, Object> rowData : sourceRows) {
|
||||
String brand = normalizeCellText(Objects.toString(rowData.getOrDefault("品牌", ""), ""));
|
||||
String brand = BrandLabel.strip(normalizeCellText(Objects.toString(rowData.getOrDefault("品牌", ""), "")));
|
||||
if (!brand.isBlank() && !handled.contains(brand)) {
|
||||
undetected.add(brand);
|
||||
}
|
||||
@@ -1147,7 +1148,15 @@ public class BrandTaskService {
|
||||
String value = index == null ? "" : normalizeCellText(rowMap.get(index));
|
||||
rowData.put(column, value);
|
||||
}
|
||||
String brand = normalizeCellText(Objects.toString(rowData.getOrDefault("品牌", ""), ""));
|
||||
String brand = BrandLabel.strip(normalizeCellText(Objects.toString(rowData.getOrDefault("品牌", ""), "")));
|
||||
if (rowData.containsKey("品牌")) {
|
||||
// 品牌列在解析落 row map 这一处就洗,而不是等出件那一格:查询集 uniqueBrands、
|
||||
// 与执行方回传值的匹配、结果文件里那一格必须拿到同一个字符串。只在写出端剥会让
|
||||
// 比对两边分家——判为"不符合"的行剔不掉,用户把没通过的行当成已通过上架。
|
||||
// 纯标签值("Brand:")洗完即空,与"这行没填品牌"走同一条路径,不再送给上游
|
||||
// 当 Solr 字段限定符(2026-10-08 单日 19,247 次 500 的起点就是这个)。
|
||||
rowData.put("品牌", brand);
|
||||
}
|
||||
if (brand.isBlank()) {
|
||||
rowData.put("__rowIndex", rowIndex + 1);
|
||||
rows.add(rowData);
|
||||
@@ -1232,7 +1241,7 @@ public class BrandTaskService {
|
||||
List<Map<String, Object>> sourceRows = outputRows == null ? List.of() : outputRows;
|
||||
int writeRowIndex = 1;
|
||||
for (Map<String, Object> rowData : sourceRows) {
|
||||
String brand = normalizeCellText(Objects.toString(rowData.getOrDefault("品牌", ""), ""));
|
||||
String brand = BrandLabel.strip(normalizeCellText(Objects.toString(rowData.getOrDefault("品牌", ""), "")));
|
||||
if (!brand.isBlank() && invalidBrandSet.contains(brand)) {
|
||||
continue;
|
||||
}
|
||||
@@ -1273,7 +1282,7 @@ public class BrandTaskService {
|
||||
for (int i = 0; i < invalidBrands.size(); i++) {
|
||||
var row = invalidSheet.createRow(i + 1);
|
||||
BrandInvalidBrandDto item = invalidBrands.get(i);
|
||||
row.createCell(0).setCellValue(blankToDefault(item.getBrand(), ""));
|
||||
row.createCell(0).setCellValue(BrandLabel.strip(blankToDefault(item.getBrand(), "")));
|
||||
row.createCell(1).setCellValue(blankToDefault(item.getCountry(), ""));
|
||||
row.createCell(2).setCellValue(blankToDefault(item.getStatus(), ""));
|
||||
}
|
||||
@@ -1286,7 +1295,9 @@ public class BrandTaskService {
|
||||
String nowText = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yy-MM-dd HH:mm:ss"));
|
||||
for (int i = 0; i < queryFailedBrands.size(); i++) {
|
||||
var row = queryFailedSheet.createRow(i + 1);
|
||||
row.createCell(0).setCellValue(blankToDefault(queryFailedBrands.get(i), ""));
|
||||
// 这张表本身就是"被打回的品牌"清单,用户改完往往直接再传一次:
|
||||
// 这一格不剥前缀,下一次上传就把同一个脏值原样送回查询链路,清洗脚本的账也作废。
|
||||
row.createCell(0).setCellValue(BrandLabel.strip(blankToDefault(queryFailedBrands.get(i), "")));
|
||||
row.createCell(1).setCellValue(nowText);
|
||||
}
|
||||
|
||||
@@ -1332,7 +1343,9 @@ public class BrandTaskService {
|
||||
if (invalidBrand == null) {
|
||||
continue;
|
||||
}
|
||||
String normalized = normalizeCellText(invalidBrand.getBrand());
|
||||
// 执行方刻意回传原值(失败清单要能对得上用户表里那一行),所以匹配键这一侧必须
|
||||
// 与服务端解析后的品牌取同一个口径:两边都过 BrandLabel,legacy 脏值回传照样命中。
|
||||
String normalized = BrandLabel.strip(normalizeCellText(invalidBrand.getBrand()));
|
||||
if (!normalized.isBlank()) {
|
||||
result.add(normalized);
|
||||
}
|
||||
@@ -1346,7 +1359,7 @@ public class BrandTaskService {
|
||||
return result;
|
||||
}
|
||||
for (String brand : brands) {
|
||||
String normalized = normalizeCellText(brand);
|
||||
String normalized = BrandLabel.strip(normalizeCellText(brand));
|
||||
if (!normalized.isBlank()) {
|
||||
result.add(normalized);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user