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:
2026-10-20 22:35:25 +08:00
parent e855801237
commit cdef922251
34 changed files with 456 additions and 49 deletions
@@ -1,19 +1,23 @@
package com.nanri.aiimage.modules.publish.service;
package com.nanri.aiimage.common.util;
import java.util.regex.Pattern;
/**
* 上架链路上品牌值的唯一清洗出口:剥掉 {@code Brand: } 这类"字段标签 + 冒号"前缀。
* 品牌值的唯一清洗出口:剥掉 {@code Brand: } 这类"字段标签 + 冒号"前缀。全仓只此一份,
* 读入(解析上传的 Excel、接收客户端回传的行)与写出(出件写 cell)两端都走它。
*
* <p>亚马逊详情页把卖家名渲染成 "Brand: XXX",用户从页面复制进 Excel 就会带上前缀。
* 该值进 WIPO 品牌库查询时会被当 Solr 字段限定符({@code undefined field Brand} → 上游 500),
* 10-08 单日被顶着重跑 30 轮、连带把品牌全局锁持到 1h45m,压死 11 个别的用户的任务。
*
* <p>清洗必须落在这里而不是某个调用点:{@code biz_publish_item.brand} 有两个写入来源
* <p>清洗必须落在这一处而不是某个调用点:{@code biz_publish_item.brand} 有两个写入来源
* (服务端 Excel 解析、客户端结果分片回传 {@code replaceRows}),历史上只堵了前者,
* 后者在任务完成时整表删后重插,把脏值又写回去。
*
* <p>读写两端都要过一遍,是因为干净值不等于干净文件:出件是用户的下一份上传物,
* 任何一个出件漏剥,用户下载再上传就把脏值送回链路里,清洗脚本的账也随之作废。
*/
public final class PublishBrandLabel {
public final class BrandLabel {
/**
* 只剥行首的一个标签,且要求冒号紧跟其后:{@code Brands: NIKE} 与 {@code Brand: NIKE: X}
@@ -22,7 +26,7 @@ public final class PublishBrandLabel {
private static final Pattern LABEL_PREFIX = Pattern.compile(
"(?i)^\\s*(?:brand|品牌|marke|marca|marque|marka)\\s*[::]\\s*");
private PublishBrandLabel() {
private BrandLabel() {
}
public static String strip(String value) {
@@ -1,5 +1,6 @@
package com.nanri.aiimage.modules.appearancepatent.service.support;
import com.nanri.aiimage.common.util.BrandLabel;
import com.nanri.aiimage.modules.appearancepatent.model.dto.AppearancePatentResultRowDto;
import com.nanri.aiimage.modules.appearancepatent.model.vo.AppearancePatentParsedRowVo;
import org.apache.poi.ss.usermodel.Cell;
@@ -231,10 +232,17 @@ public final class AppearancePatentSheetBuilder {
return "";
}
/**
* 品牌列的唯一取值出口:回传行优先、退回用户上传表的原始列,两条来源都在这里过一遍
* {@link BrandLabel}。清洗必须落在这处而不是 cell 那一行——亚马逊把卖家名渲染成
* "Brand: XXX",用户复制进 Excel 或客户端原样回传就带着标签前缀,带着它去查品牌库会被
* 当 Solr 字段限定符打成上游 500。回传值只剩标签("Brand:")时按"这一行没带品牌"处理,
* 继续回退到源表的品牌列,而不是把一个空标签洗出来的空串当成有效值写进格子。
*/
public static String resolveBrand(AppearancePatentResultRowDto resultRow, AppearancePatentParsedRowVo parsedRow) {
String pythonBrand = resultRow == null ? "" : resultRow.getBrand();
String pythonBrand = resultRow == null ? "" : BrandLabel.strip(resultRow.getBrand());
if (pythonBrand != null && !pythonBrand.isBlank()) {
return pythonBrand.trim();
return pythonBrand;
}
if (parsedRow == null || parsedRow.getValues() == null) {
return "";
@@ -242,7 +250,7 @@ public final class AppearancePatentSheetBuilder {
for (Map.Entry<String, String> entry : parsedRow.getValues().entrySet()) {
String header = entry.getKey() == null ? "" : entry.getKey().trim().toLowerCase(Locale.ROOT);
if (header.contains("品牌") || header.contains("brand")) {
return entry.getValue() == null ? "" : entry.getValue();
return firstNonBlank(BrandLabel.strip(entry.getValue()), "");
}
}
return "";
@@ -1,6 +1,7 @@
package com.nanri.aiimage.modules.asincache.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.nanri.aiimage.common.util.BrandLabel;
import com.nanri.aiimage.modules.asincache.mapper.AsinResultCacheMapper;
import com.nanri.aiimage.modules.asincache.model.dto.AsinCacheWriteRowDto;
import com.nanri.aiimage.modules.asincache.model.entity.AsinResultCacheEntity;
@@ -260,7 +261,9 @@ public class AsinResultCacheService {
entity.setAsin(asin);
entity.setAvailability(availability);
entity.setPrice(clip(row.getPrice(), MAX_PRICE_LENGTH));
entity.setBrand(clip(row.getBrand(), MAX_BRAND_LENGTH));
// 缓存行来自客户端回传的采集结果,品牌那格常常是详情页署名行原样("Brand: XXX"):
// 这一列洗不洗决定了后面多少个任务从缓存里读到脏值,落库前剥一次比在每个下游各剥一次可靠
entity.setBrand(clip(BrandLabel.strip(row.getBrand()), MAX_BRAND_LENGTH));
entity.setDeliveryMethod(clip(row.getDeliveryMethod(), MAX_DELIVERY_LENGTH));
entity.setSellerName(clip(row.getSellerName(), MAX_SELLER_NAME_LENGTH));
entity.setSellerId(clip(row.getSellerId(), MAX_SELLER_ID_LENGTH));
@@ -1,5 +1,6 @@
package com.nanri.aiimage.modules.collectdata.service;
import com.nanri.aiimage.common.util.BrandLabel;
import com.nanri.aiimage.common.util.UserMessages;
import com.nanri.aiimage.common.exception.BusinessException;
import com.nanri.aiimage.common.util.SxssfWorkbookWriter;
@@ -140,7 +141,9 @@ public class CollectDataExcelAssemblyService {
continue;
}
Row row = sheet.createRow((int) state[0]++);
SxssfWorkbookWriter.setText(row, 0, item.getBrand());
// 出件这一端也要过一遍:干净值不等于干净文件——这份 Excel 是用户的下一份上传物,
// 而改口径之前落库的历史明细 payload 里仍可能带着标签前缀。
SxssfWorkbookWriter.setText(row, 0, BrandLabel.strip(item.getBrand()));
SxssfWorkbookWriter.setText(row, 1, item.getAsin());
SxssfWorkbookWriter.setText(row, 2, item.getPrice());
SxssfWorkbookWriter.setText(row, 3, item.getSellerName());
@@ -9,6 +9,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.nanri.aiimage.common.exception.BusinessCodes;
import com.nanri.aiimage.common.exception.BusinessException;
import com.nanri.aiimage.common.util.BrandLabel;
import com.nanri.aiimage.common.util.ExcelStreamReader;
import com.nanri.aiimage.modules.asincache.service.AsinResultCacheService;
import com.nanri.aiimage.modules.collectdata.mapper.CollectDataCountryPrefMapper;
@@ -971,7 +972,9 @@ public class CollectDataService extends AbstractFileTaskPipeline<CollectDataResu
continue;
}
CollectDataResultRowVo row = new CollectDataResultRowVo();
row.setBrand(normalize(raw.getBrand()));
// 品牌在前端复制自亚马逊详情页的署名行("Brand: XXX"),客户端原样回传就带着标签前缀:
// 带着它去查品牌库会被当 Solr 字段限定符打成上游 500。剥标签只认 BrandLabel 这一处口径。
row.setBrand(BrandLabel.strip(normalize(raw.getBrand())));
row.setAsin(normalizeAsin(raw.getAsin()));
row.setPrice(normalize(raw.getPrice()));
row.setSellerName(normalize(raw.getSellerName()));
@@ -10,6 +10,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.nanri.aiimage.common.exception.BusinessException;
import com.nanri.aiimage.common.service.CompanyScopeSupport;
import com.nanri.aiimage.common.service.NodeSharedStore;
import com.nanri.aiimage.common.util.BrandLabel;
import com.nanri.aiimage.common.util.ExcelStreamReader;
import com.nanri.aiimage.config.InstanceMetadata;
import com.nanri.aiimage.config.StorageProperties;
@@ -61,6 +62,8 @@ public class DedupeRunService {
private static final String HEADER_SPLIT_MARKER = "idASIN国家状态价格变体数量";
private static final String HEADER_STOP_COLUMN = "缩略图地址8";
private static final List<String> EXPORT_COLUMN_PRIORITY = List.of("id", "ASIN", "国家", "价格", "品牌");
/** 去重源文件的列集由用户勾选,品牌列只能按表头认出来,其余列一律原文透传。 */
private static final String BRAND_COLUMN_HEADER = "品牌";
/** 同时处理的文件数上限,避免多文件并行时打满内存与 OSS 上传带宽 */
private static final int MAX_PARALLEL_FILES = 4;
/** 单用户同时运行中的去重任务数上限 */
@@ -856,7 +859,10 @@ public class DedupeRunService {
List<String> selectedColumns, Integer asinColumnIndex) {
List<String> selectedValues = new ArrayList<>(selectedColumns.size());
for (String selectedColumn : selectedColumns) {
selectedValues.add(normalizeCellText(cellText(rowMap, headerIndex.get(selectedColumn))));
String value = normalizeCellText(cellText(rowMap, headerIndex.get(selectedColumn)));
// 品牌列的值可能是用户从亚马逊详情页复制来的署名("Brand: XXX"):在这里剥一次,
// 下方出件写 cell 用的就是同一个字符串,比对与交付不会拿到两个版本
selectedValues.add(BRAND_COLUMN_HEADER.equals(selectedColumn) ? BrandLabel.strip(value) : value);
}
if (asinColumnIndex == null) {
asinColumnIndex = headerIndex.get("ASIN");
@@ -2,6 +2,7 @@ package com.nanri.aiimage.modules.invalidasin.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.nanri.aiimage.common.exception.BusinessException;
import com.nanri.aiimage.common.util.BrandLabel;
import com.nanri.aiimage.modules.invalidasin.mapper.InvalidAsinDataMapper;
import com.nanri.aiimage.modules.invalidasin.model.dto.InvalidAsinDataCreateRequest;
import com.nanri.aiimage.modules.invalidasin.model.dto.InvalidAsinDataUpdateRequest;
@@ -83,7 +84,11 @@ public class InvalidAsinDataService {
public InvalidAsinDataItemVo create(InvalidAsinDataCreateRequest request, Long operatorId) {
ShopManageGroupEntity group = requireGroup(request.getGroupId(), operatorId);
String dataValue = normalizeRequired(request.getDataValue(), "ASIN 不能为空");
String brand = normalizeRequired(request.getBrand(), "品牌不能为空").toLowerCase(Locale.ROOT);
// 品牌是这张表的匹配键(下游按它判"这个 ASIN 属于被屏蔽品牌"),键值一律先过 BrandLabel:
// 人工把详情页署名行整段粘进来会存成 "brand: nike",而采集侧现在给 "nike",
// 对不上就是屏蔽静默失效——比脏值出件更坏,因为它不报错。先洗再判空,纯标签值必须拒收。
String brand = normalizeRequired(BrandLabel.strip(request.getBrand()), "品牌不能为空")
.toLowerCase(Locale.ROOT);
ensureUnique(dataValue, null);
InvalidAsinDataEntity entity = new InvalidAsinDataEntity();
entity.setDataValue(dataValue);
@@ -101,7 +106,8 @@ public class InvalidAsinDataService {
// 自动导入的行分组由采集侧决定,这一页不替它重归:沿用改造前口径,与角色无关。
ShopManageGroupEntity writeGroup = isManualRecord(entity) ? requireGroup(request.getGroupId(), operatorId) : null;
String dataValue = normalizeRequired(request.getDataValue(), "ASIN 不能为空");
String brand = normalizeRequired(request.getBrand(), "品牌不能为空").toLowerCase(Locale.ROOT);
String brand = normalizeRequired(BrandLabel.strip(request.getBrand()), "品牌不能为空")
.toLowerCase(Locale.ROOT);
ensureUnique(dataValue, id);
entity.setDataValue(dataValue);
entity.setBrand(brand);
@@ -10,6 +10,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.nanri.aiimage.common.exception.BusinessException;
import com.nanri.aiimage.common.exception.TaskOwnerMismatchException;
import com.nanri.aiimage.common.util.BrandLabel;
import com.nanri.aiimage.config.InstanceMetadata;
import com.nanri.aiimage.modules.file.service.LocalFileStorageService;
import com.nanri.aiimage.modules.file.service.oss.OssStorageService;
@@ -1830,7 +1831,7 @@ public class PublishTaskService extends AbstractFileTaskPipeline<PublishRowDto>
entity.setSourceId(row.getSourceId());
entity.setAsin(row.getAsin());
entity.setCountry(row.getCountry());
entity.setBrand(PublishBrandLabel.strip(row.getBrand()));
entity.setBrand(BrandLabel.strip(row.getBrand()));
entity.setPriceValue(row.getPrice());
entity.setStatusValue(row.getStatus());
entity.setSyncStatus(row.getSyncStatus());
@@ -1,6 +1,7 @@
package com.nanri.aiimage.modules.publish.service;
import com.nanri.aiimage.common.exception.BusinessException;
import com.nanri.aiimage.common.util.BrandLabel;
import com.nanri.aiimage.common.util.ExcelStreamReader;
import com.nanri.aiimage.common.util.SxssfWorkbookWriter;
import com.nanri.aiimage.modules.publish.model.dto.PublishRowDto;
@@ -169,7 +170,7 @@ public class PublishWorkbookService {
row.setSourceId(values.get(0));
row.setAsin(values.get(1));
row.setCountry(values.get(2));
row.setBrand(PublishBrandLabel.strip(values.get(3)));
row.setBrand(BrandLabel.strip(values.get(3)));
row.setPrice(values.get(4));
return row;
}
@@ -194,7 +195,7 @@ public class PublishWorkbookService {
setText(row, 0, value.getSourceId());
setText(row, 1, value.getAsin());
setText(row, 2, publishCountry);
setText(row, 3, value.getBrand());
setText(row, 3, BrandLabel.strip(value.getBrand()));
setPrice(row, 4, value.getPrice());
setText(row, 5, value.getStatus());
setText(row, 6, value.getSyncStatus());
@@ -2,6 +2,7 @@ package com.nanri.aiimage.modules.shopdatacrawl.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.nanri.aiimage.common.util.BrandLabel;
import com.nanri.aiimage.modules.shopdatacrawl.mapper.ShopDataCrawlItemMapper;
import com.nanri.aiimage.modules.shopdatacrawl.model.dto.ShopDataCrawlCountryResultDto;
import com.nanri.aiimage.modules.shopdatacrawl.model.dto.ShopDataCrawlRowDto;
@@ -104,7 +105,9 @@ public class ShopDataCrawlItemStoreService {
entity.setBusinessDate(businessDate);
entity.setCountry(country);
entity.setAsin(item.getAsin().trim());
entity.setBrand(trimToNull(item.getBrand()));
// 明细表这一列是撞款扫描与台账出件唯一的品牌来源,而存量迁移的快照 JSON 不经 copyRow:
// 标签前缀必须在进表这一端剥掉,否则脏值每扫一次就复活一次
entity.setBrand(trimToNull(BrandLabel.strip(item.getBrand())));
entity.setPrice(trimToNull(item.getPrice()));
entity.setItemDate(trimToNull(item.getDate()));
entity.setUnitsSold(trimToNull(item.getUnitsSold()));
@@ -1,5 +1,6 @@
package com.nanri.aiimage.modules.shopdatacrawl.service.support;
import com.nanri.aiimage.common.util.BrandLabel;
import com.nanri.aiimage.modules.shopdatacrawl.model.dto.ShopDataCrawlRowDto;
/**
@@ -21,6 +22,15 @@ public final class ShopDataCrawlRowNormalizer {
return value == null ? "" : value.trim();
}
/**
* 品牌列的唯一取值口径:客户端从亚马逊详情页的署名行原样回传,值里带着 "Brand: " 这类标签前缀。
* 进模型、比相等、算去重键三处必须取同一个字符串 —— 只在写出那一端剥,会让清洗过的存量行与
* 未清洗的回传行算出两个键,跨分片合并时同一行重复出件。
*/
public static String brand(String value) {
return BrandLabel.strip(trim(value));
}
public static boolean blank(String value) {
return value == null || value.isBlank();
}
@@ -56,7 +66,7 @@ public final class ShopDataCrawlRowNormalizer {
ShopDataCrawlRowDto row = new ShopDataCrawlRowDto();
row.setDate(trim(source.getDate()));
row.setAsin(trim(source.getAsin()));
row.setBrand(trim(source.getBrand()));
row.setBrand(brand(source.getBrand()));
row.setCommodityImage(trim(source.getCommodityImage()));
row.setInventorySales(trim(source.getInventorySales()));
row.setSalesRank(trim(source.getSalesRank()));
@@ -77,7 +87,7 @@ public final class ShopDataCrawlRowNormalizer {
return left != null && right != null
&& java.util.Objects.equals(trim(left.getDate()), trim(right.getDate()))
&& java.util.Objects.equals(trim(left.getAsin()), trim(right.getAsin()))
&& java.util.Objects.equals(trim(left.getBrand()), trim(right.getBrand()))
&& java.util.Objects.equals(brand(left.getBrand()), brand(right.getBrand()))
&& java.util.Objects.equals(trim(left.getCommodityImage()), trim(right.getCommodityImage()))
&& java.util.Objects.equals(trim(left.getInventorySales()), trim(right.getInventorySales()))
&& java.util.Objects.equals(trim(left.getSalesRank()), trim(right.getSalesRank()))
@@ -92,7 +102,7 @@ public final class ShopDataCrawlRowNormalizer {
if (row == null) {
return null;
}
return trim(row.getDate()) + ROW_KEY_SEPARATOR + trim(row.getAsin()) + ROW_KEY_SEPARATOR + trim(row.getBrand())
return trim(row.getDate()) + ROW_KEY_SEPARATOR + trim(row.getAsin()) + ROW_KEY_SEPARATOR + brand(row.getBrand())
+ ROW_KEY_SEPARATOR + trim(row.getCommodityImage()) + ROW_KEY_SEPARATOR + trim(row.getInventorySales())
+ ROW_KEY_SEPARATOR + trim(row.getSalesRank()) + ROW_KEY_SEPARATOR + trim(row.getPageViews())
+ ROW_KEY_SEPARATOR + trim(row.getUnitsSold()) + ROW_KEY_SEPARATOR + trim(row.getPrice())
@@ -1,6 +1,7 @@
package com.nanri.aiimage.modules.shopdatacrawl.service.support;
import com.nanri.aiimage.common.exception.BusinessException;
import com.nanri.aiimage.common.util.BrandLabel;
import com.nanri.aiimage.modules.shopdatacrawl.model.dto.ShopDataCrawlCountryResultDto;
import com.nanri.aiimage.modules.shopdatacrawl.model.dto.ShopDataCrawlRowDto;
import com.nanri.aiimage.modules.shopdatacrawl.model.vo.ShopDataCrawlResultItemVo;
@@ -128,7 +129,10 @@ public final class ShopDataCrawlSheetBuilder {
/** 数据行 10 列值布局 + 样式应用(图片嵌入由调用方负责)。 */
public static void writeDataRowValues(Row row, ShopDataCrawlRowDto value, CellStyle[] styles) {
String[] values = {value.getDate(), value.getAsin(), "", value.getInventorySales(), value.getSalesRank(),
value.getPageViews(), value.getUnitsSold(), value.getPrice(), value.getRecommendedOffer(), value.getBrand()};
// 出件是用户的下一份上传物:改口径之前落库的累计文件快照与 row_payload 仍带 "Brand:" 前缀,
// 这一格不剥,下载再上传就把脏值送回链路里
value.getPageViews(), value.getUnitsSold(), value.getPrice(), value.getRecommendedOffer(),
BrandLabel.strip(value.getBrand())};
for (int column = 0; column < values.length; column++) {
Cell cell = row.createCell(column);
if (styles[column] != null) cell.setCellStyle(styles[column]);
@@ -1,5 +1,6 @@
package com.nanri.aiimage.modules.shopduplicatecheck.service;
import com.nanri.aiimage.common.util.BrandLabel;
import com.nanri.aiimage.common.util.UserMessages;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.nanri.aiimage.common.exception.BusinessException;
@@ -105,8 +106,10 @@ public class ShopDataDuplicateCheckImportService {
}
for (DuplicateItem item : base.items()) {
for (DuplicateOccurrence occ : item.occurrences()) {
// 基线行读自上一份落库 payload(改口径之前可能是脏值),这里不剥就直接把脏值重插回扫描表
rowsByShop.computeIfAbsent(occ.shopName(), k -> new ArrayList<>())
.add(new RawRow(occ.asin(), occ.date(), occ.price(), occ.brand(), occ.country()));
.add(new RawRow(occ.asin(), occ.date(), occ.price(),
BrandLabel.strip(occ.brand()), occ.country()));
}
}
List<ShopParsed> baseParsed = new ArrayList<>();
@@ -1,5 +1,6 @@
package com.nanri.aiimage.modules.shopduplicatecheck.service;
import com.nanri.aiimage.common.util.BrandLabel;
import com.nanri.aiimage.modules.shopduplicatecheck.mapper.ShopDuplicateCheckSourceMapper;
import com.nanri.aiimage.modules.shopduplicatecheck.model.payload.DuplicateItem;
import com.nanri.aiimage.modules.shopduplicatecheck.model.payload.DuplicateOccurrence;
@@ -433,8 +434,10 @@ public class ShopDataDuplicateCheckQueryService {
for (DuplicateItem item : matched) {
String shopCount = String.valueOf(item.shopCount());
for (DuplicateOccurrence occ : item.occurrences()) {
// 出件是用户的下一份上传物:库里的历史 payload 仍可能带标签前缀,最后一列(品牌)在此剥掉
flat.add(new Object[]{item.asin(), shopCount, occ.shopName(), occ.groupName(),
effectiveCountryCn(occ), safe(occ.date()), safe(occ.price()), safe(occ.brand())});
effectiveCountryCn(occ), safe(occ.date()), safe(occ.price()),
BrandLabel.strip(safe(occ.brand()))});
}
}
flat.sort(flatExportComparator());
@@ -1,5 +1,6 @@
package com.nanri.aiimage.modules.shopduplicatecheck.service;
import com.nanri.aiimage.common.util.BrandLabel;
import com.nanri.aiimage.common.util.UserMessages;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -325,7 +326,9 @@ public class ShopDataDuplicateCheckScanService implements DuplicateCheckRefreshP
row.asin().trim(),
nvl(row.itemDate()),
nvl(row.price()),
nvl(row.brand()),
// 明细表里的品牌是改口径之前写进去的,标签前缀在进聚合这一端剥,
// 落库 payload 与页面、出件拿到的才是同一个干净值
BrandLabel.strip(nvl(row.brand())),
country));
if (!country.isEmpty()) {
countries.add(country);
@@ -1,5 +1,6 @@
package com.nanri.aiimage.modules.shopduplicatecheck.service.support;
import com.nanri.aiimage.common.util.BrandLabel;
import com.nanri.aiimage.common.util.ExcelStreamReader;
import java.io.ByteArrayInputStream;
@@ -105,7 +106,8 @@ public final class DuplicateCheckWorkbookParser {
asin,
cell(rowMap.get(dateCol)),
cell(rowMap.get(priceCol)),
cell(rowMap.get(brandCol)),
// 上传文件的品牌列是亚马逊详情页复制来的署名("Brand: XXX"),标签前缀只能在这一处剥
BrandLabel.strip(cell(rowMap.get(brandCol))),
sheetCountry));
}
}
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.nanri.aiimage.common.exception.BusinessException;
import com.nanri.aiimage.common.util.BrandLabel;
import com.nanri.aiimage.common.util.GroupResultPropagator;
import com.nanri.aiimage.config.SimilarAsinProperties;
import com.nanri.aiimage.config.StorageProperties;
@@ -901,7 +902,8 @@ public class SimilarAsinResultWorkbookAssembler {
resultRow.getPrice(),
firstNonBlank(parsedRow.getPrice(), readValueByHeader(parsedRow, "价格", "price"))));
row.createCell(col++).setCellValue(readValueByHeader(parsedRow, "卖家名称", "卖家名", "卖家", "店铺名称", "店铺名", "seller name", "seller_name", "seller-name", "sellername", "store name", "shop name"));
row.createCell(col++).setCellValue(readValueByHeader(parsedRow, "品牌", "brand"));
// 与 SheetBuilder 同口径:结果文件的品牌列必须剥掉页面复制带上的标签前缀,否则二次上传把脏值带回链路
row.createCell(col++).setCellValue(BrandLabel.strip(readValueByHeader(parsedRow, "品牌", "brand")));
String isStock = resultRow == null ? "" : SimilarAsinResultTextSupport.userFacingLlmCellValue(resultRow, resultRow.getIsStock());
String similarity = resultRow == null ? "" : SimilarAsinResultTextSupport.userFacingLlmCellValue(resultRow, resultRow.getSimilarity());
String isConform = resultRow == null ? "" : SimilarAsinResultTextSupport.userFacingLlmCellValue(resultRow, resultRow.getIsConform());
@@ -1,5 +1,6 @@
package com.nanri.aiimage.modules.similarasin.service.support;
import com.nanri.aiimage.common.util.BrandLabel;
import com.nanri.aiimage.modules.similarasin.model.vo.SimilarAsinParsedRowVo;
import com.nanri.aiimage.modules.similarasin.util.SimilarAsinImageEmbedder;
import org.apache.poi.ss.usermodel.Cell;
@@ -84,7 +85,8 @@ public final class SimilarAsinSheetBuilder {
row.createCell(col++).setCellValue(readValueByHeader(
parsedRow, "卖家名称", "卖家名", "卖家", "店铺名称", "店铺名", "seller name", "seller_name",
"seller-name", "sellername", "store name", "shop name"));
row.createCell(col).setCellValue(readValueByHeader(parsedRow, "品牌", "brand"));
// 出件是用户的下一份上传物:品牌列带 "Brand:" 标签前缀不剥,下载再上传就把脏值送回链路(清洗出口唯 BrandLabel)
row.createCell(col).setCellValue(BrandLabel.strip(readValueByHeader(parsedRow, "品牌", "brand")));
row.setHeightInPoints(SimilarAsinImageEmbedder.IMAGE_ROW_HEIGHT_POINTS);
rowIndex++;
}