fix(brand-label): 品牌标签清洗抽公共件,六模块读写两端统一过出口
PublishBrandLabel 从 publish 私有件搬入 common/util/BrandLabel(三条守卫尺子随迁: 唯一副本、实体写出不许绕过、解析端不许重复实现),品牌列的读入与出件两端都走这一处。 读入端接上:asincache 缓存落库、invalidasin 人工黑名单(先洗再判空——键对不上是静默失效, 比脏值出件更难发现)、appearancepatent resolveBrand(两条取值分支同一个串)、collectdata 入库、shopdatacrawl copyRow/sameRow/rowDedupKey(键与值分家会让同一行跨分片重复出件)、 撞款解析与 re-baseline、dedupe 按表头名只洗品牌列。 写出端接上:publish/similarasin×2/appearancepatent/collectdata/撞款 csv+xlsx/shopdatacrawl。 rows-snapshot golden 里品牌格去掉首尾空格:正本 strip 自 2026-10-08 就含 trim, Java/Python/MySQL 三处同形,不是这次新加的行为。 门禁:后端 mvn -o test 4594 例 0 红。BrandTaskService(含四张 sheet 出件与解析端匹配) 因同仓另一路在飞改动未动,见 docs/audit/BACKLOG.md B5。
This commit is contained in:
+33
@@ -29,6 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
*/
|
||||
class AppearancePatentRowOutcomeTest {
|
||||
|
||||
private static final int COL_BRAND = 4;
|
||||
private static final int COL_TITLE = 6;
|
||||
private static final int COL_URL = 7;
|
||||
private static final int COL_TITLE_RISK = 9;
|
||||
@@ -355,4 +356,36 @@ class AppearancePatentRowOutcomeTest {
|
||||
}
|
||||
throw new AssertionError("原因 sheet 里没有 ASIN=" + asin + " 的行");
|
||||
}
|
||||
|
||||
// ---------- 4. 品牌列只认洗过标签前缀的值 ----------
|
||||
|
||||
@Test
|
||||
void brandCellNeverCarriesTheAmazonBylinePrefix() throws Exception {
|
||||
// 品牌列有两个来源:用户上传表的「品牌」列(这里就是 "Brand: Acme")与客户端回传行的 Brand,
|
||||
// 详情页整行复制来的署名前缀既脏出件、又会在品牌库查询里被当字段限定符打成上游 500。
|
||||
List<AppearancePatentParsedRowVo> all = List.of(sheetRowOnlyId("1", "B0A"));
|
||||
AppearancePatentResultRowDto resultRow = judgedRow("1", "B0A", "T", "https://img/1.jpg");
|
||||
Map<String, AppearancePatentResultRowDto> byRowKey = new LinkedHashMap<>();
|
||||
byRowKey.put(AppearancePatentSheetBuilder.rowKey(all.get(0)), resultRow);
|
||||
|
||||
assertEquals("Acme", brandCell(all, byRowKey), "回传行没带品牌时,源表值也要剥掉标签");
|
||||
|
||||
resultRow.setBrand("Brand: Nike");
|
||||
assertEquals("Nike", brandCell(all, byRowKey));
|
||||
|
||||
// "Brands:" 是真实品牌写法、不是字段标签;值中间的冒号属于品牌本体,只能剥行首一次
|
||||
resultRow.setBrand("Brands: Nike");
|
||||
assertEquals("Brands: Nike", brandCell(all, byRowKey));
|
||||
|
||||
// 只剩标签的回传值等于这行没带品牌:回退源表列,而不是把洗出来的空串当成有效值写进格子
|
||||
resultRow.setBrand("Brand:");
|
||||
assertEquals("Acme", brandCell(all, byRowKey));
|
||||
}
|
||||
|
||||
private static String brandCell(List<AppearancePatentParsedRowVo> rows,
|
||||
Map<String, AppearancePatentResultRowDto> byRowKey) throws Exception {
|
||||
try (Workbook workbook = render(rows, byRowKey)) {
|
||||
return cell(workbook.getSheet("外观专利检测结果"), 1, COL_BRAND);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user