fix(上架): Excel 品牌列剥掉 Brand: 标签前缀,止住脏值进 biz_publish_item

biz_publish_item.brand 实测 3,001/34,697 行以 "Brand: " 开头,是这批值流入
品牌检测后成批失败的源头(同一 payload 从工作站直连复现:value="NIKE" 回正常
密文,value="Brand: NIKE" 回 undefined field Brand)。上架 Excel 解析入口
toRow() 此前把第 4 列原样收下,normalize() 只处理空白,标签前缀就此入库;
用户再把这些行导出去做品牌检测,整单被 WIPO 按 Solr 字段限定符拒掉。

只剥开头一次:值中间的冒号属品牌自身内容,"Brands:" 也不是标签——测试里这两条
是排他断言,打死「无条件砍掉开头若干字符」的写法。存量 3,001 行的清洗属生产写,
未包含在本提交内。
This commit is contained in:
2026-10-08 22:57:55 +08:00
parent c216cd93fb
commit 15e0451191
2 changed files with 62 additions and 1 deletions
@@ -170,7 +170,7 @@ public class PublishWorkbookService {
row.setSourceId(values.get(0));
row.setAsin(values.get(1));
row.setCountry(values.get(2));
row.setBrand(values.get(3));
row.setBrand(stripBrandLabel(values.get(3)));
row.setPrice(values.get(4));
return row;
}
@@ -293,6 +293,22 @@ public class PublishWorkbookService {
return value.isBlank() ? "publish" : value;
}
/**
* 剥掉亚马逊 byline 残留的「Brand:」标签前缀。
*
* 这类值送进 WIPO 品牌查询会被当成 Solr 字段限定符,返回
* isError / status 500 / undefined field Brand(2026-10-08 主机 A 实测 19,247 次,
* 不带前缀的查询 0 次)。只剥开头一次:值中间的冒号属品牌自身内容,
* "Brands:" 也不是标签。
*/
private String stripBrandLabel(String value) {
if (value == null || value.isEmpty()) {
return value;
}
return value.replaceFirst(
"(?i)^\\s*(?:brand|品牌|marke|marca|marque|marka)\\s*[::]\\s*", "").trim();
}
private String normalize(String value) {
if (value == null) {
return "";