fix(外观专利): 整批商标查询无一返回时表上改说「上游整体不可用」
2026-10-19 现网取证:品牌库代理套餐过期(供应商回 {"code":-1,"message":"套餐不存在"})
→ 16890 代理池恒为 0、一次代理都没挂上 → 全部直连打 WIPO branddb 被整片 Forbidden
→ 交付表 11 行全写「商标查询失败」。逐行失败可能是那个词本身查不了,整批全失败只可能
是上游挂了,两者在表上必须长得不一样;否则运维故障被伪装成数据问题,用户看不出该做什么。
新文案保留「商标查询失败」前缀,让三处既有语义逐字不变:
- isBrandQueryFailed() 继续成立
- buildConclusion 该支从返回常量改为返回 titleRisk(旧输入输出相同,新输入自动带原因)
- resolveResultStatus:新文案不含「侵权」二字,照旧判「失败」(已单独钉桩)
判据刻意保守:任一行拿到过侵权命中、或任一行查成功过即不升级;没发过查询的行
(LLM 已判「无」、标题为空)不参与判定,否则一批"无需查"的行会被误判成上游故障。
表上仍不会出现「欠费」二字——那个信息只存在于 16890 内部,Java 侧看不见。要把
message 一路带到表格,需先给 /root/BrandTesting 建版本控制再改它的响应契约。
AppearancePatentLlmClientTest 14 例 / SheetBuilder 15 例 / BrandBatch 3 例 /
BrandCheckClient* 12 例全绿;整个 test 源集 546 类编译通过,证明 applyResult
签名改动无漏改调用方。
This commit is contained in:
+87
@@ -79,6 +79,40 @@ class AppearancePatentLlmClientTest {
|
||||
assertThat(client.buildConclusion("商标查询失败", "侵权", "")).isEqualTo("侵权");
|
||||
}
|
||||
|
||||
/**
|
||||
* 整批待查词无一返回结果时,表上必须说清「上游整体不可用」而不是逐行的「商标查询失败」。
|
||||
* 2026-10-19 现网:品牌库的代理套餐过期(供应商回 套餐不存在)→ 16890 代理池恒为 0、
|
||||
* 一次代理都没挂上 → 全部直连打 WIPO branddb 被整片 Forbidden → 交付表 11 行全写
|
||||
* 「商标查询失败」,既看不出是运维故障,更看不出该去续什么。
|
||||
*/
|
||||
@Test
|
||||
void titleRiskNamesUpstreamOutageOnlyWhenWholeBatchFailed() {
|
||||
BrandCheckClient.BrandCheckBatchResult failed =
|
||||
new BrandCheckClient.BrandCheckBatchResult(List.of("nike"), List.of(), List.of("nike"));
|
||||
|
||||
assertThat(client.buildTitleRisk("nike air", failed, true))
|
||||
.isEqualTo(AppearancePatentLlmClient.BRAND_UPSTREAM_UNAVAILABLE);
|
||||
// 只有它自己查失败时维持原文案:不许把个例升级成整批口径
|
||||
assertThat(client.buildTitleRisk("nike air", failed, false)).isEqualTo("商标查询失败");
|
||||
}
|
||||
|
||||
/** 整批不可用不许盖掉真实命中——这一行只要拿到过侵权结论就先给结论。 */
|
||||
@Test
|
||||
void infringementStillWinsOverWholeBatchOutageMessage() {
|
||||
BrandCheckClient.BrandCheckBatchResult hit =
|
||||
new BrandCheckClient.BrandCheckBatchResult(List.of("阿凡达"), List.of("阿凡达"), List.of());
|
||||
|
||||
assertThat(client.buildTitleRisk("阿凡达 联名", hit, true)).isEqualTo("侵权");
|
||||
}
|
||||
|
||||
/** 长文案要一路传到结论列;旧输入逐字不变由上一个用例守住。 */
|
||||
@Test
|
||||
void conclusionCarriesUpstreamOutageReason() {
|
||||
assertThat(client.buildConclusion(
|
||||
AppearancePatentLlmClient.BRAND_UPSTREAM_UNAVAILABLE, "外观识别异常", ""))
|
||||
.isEqualTo(AppearancePatentLlmClient.BRAND_UPSTREAM_UNAVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void skipBrandCheckWhenLlmTitleIsNone() throws Exception {
|
||||
BrandCheckClient brandCheckClient = mock(BrandCheckClient.class);
|
||||
@@ -103,6 +137,59 @@ class AppearancePatentLlmClientTest {
|
||||
verify(brandCheckClient, never()).checkTitleText(anyString(), anyString());
|
||||
}
|
||||
|
||||
private static AppearancePatentLlmClient clientWith(BrandCheckClient brandCheckClient) {
|
||||
return new AppearancePatentLlmClient(new AppearancePatentProperties(), new ObjectMapper(),
|
||||
null, brandCheckClient, mock(UserSecretUsageService.class));
|
||||
}
|
||||
|
||||
private static AppearancePatentResultRowDto newRow(String id) {
|
||||
AppearancePatentResultRowDto row = new AppearancePatentResultRowDto();
|
||||
row.setId(id);
|
||||
return row;
|
||||
}
|
||||
|
||||
/** 整批无一返回结果 ⇒ 每一行都升级成「上游整体不可用」。 */
|
||||
@Test
|
||||
void wholeBatchQueryFailureEscalatesEveryRow() throws Exception {
|
||||
BrandCheckClient brandCheckClient = mock(BrandCheckClient.class);
|
||||
when(brandCheckClient.checkTitleTexts(anyList(), eq("Terms"))).thenReturn(List.of(
|
||||
new BrandCheckClient.BrandCheckBatchResult(List.of("nike"), List.of(), List.of("nike")),
|
||||
new BrandCheckClient.BrandCheckBatchResult(List.of("puma"), List.of(), List.of("puma"))));
|
||||
String dataText = """
|
||||
{"data":[{"row_id":"1","title":"nike","title_reason":"nike","appearance":"外观识别异常","result":""},
|
||||
{"row_id":"2","title":"puma","title_reason":"puma","appearance":"外观识别异常","result":""}]}
|
||||
""";
|
||||
|
||||
List<AppearancePatentResultRowDto> merged = clientWith(brandCheckClient)
|
||||
.mergeRowsFromDataText(List.of(newRow("1"), newRow("2")), dataText);
|
||||
|
||||
assertThat(merged).hasSize(2);
|
||||
assertThat(merged).allSatisfy(r -> assertThat(r.getTitleRisk())
|
||||
.isEqualTo(AppearancePatentLlmClient.BRAND_UPSTREAM_UNAVAILABLE));
|
||||
}
|
||||
|
||||
/**
|
||||
* 判据必须保守:只要有一行查成功过,就不是"整体不可用",失败那行仍按逐行文案写。
|
||||
* 否则一次零星抖动就会把整表刷成运维告警口径,反而把真正的个例盖掉。
|
||||
*/
|
||||
@Test
|
||||
void oneSuccessfulRowKeepsOthersOnPerRowFailureText() throws Exception {
|
||||
BrandCheckClient brandCheckClient = mock(BrandCheckClient.class);
|
||||
when(brandCheckClient.checkTitleTexts(anyList(), eq("Terms"))).thenReturn(List.of(
|
||||
new BrandCheckClient.BrandCheckBatchResult(List.of("nike"), List.of(), List.of("nike")),
|
||||
new BrandCheckClient.BrandCheckBatchResult(List.of("puma"), List.of(), List.of())));
|
||||
String dataText = """
|
||||
{"data":[{"row_id":"1","title":"nike","title_reason":"nike","appearance":"外观识别异常","result":""},
|
||||
{"row_id":"2","title":"puma","title_reason":"puma","appearance":"外观识别异常","result":""}]}
|
||||
""";
|
||||
|
||||
List<AppearancePatentResultRowDto> merged = clientWith(brandCheckClient)
|
||||
.mergeRowsFromDataText(List.of(newRow("1"), newRow("2")), dataText);
|
||||
|
||||
assertThat(merged.get(0).getTitleRisk()).isEqualTo("商标查询失败");
|
||||
assertThat(merged.get(1).getTitleRisk()).isEqualTo("无侵权");
|
||||
}
|
||||
|
||||
@Test
|
||||
void callBrandCheckOnlyWhenTitleAndAppearanceArePresent() throws Exception {
|
||||
BrandCheckClient brandCheckClient = mock(BrandCheckClient.class);
|
||||
|
||||
+3
@@ -327,6 +327,9 @@ class AppearancePatentSheetBuilderTest {
|
||||
assertEquals("成功", AppearancePatentSheetBuilder.resolveResultStatus("已侵权"));
|
||||
// 商标没成功 / 外观识别异常 / 技术失败 / 空白 → 失败
|
||||
assertEquals("失败", AppearancePatentSheetBuilder.resolveResultStatus("商标查询失败"));
|
||||
// 整批上游不可用那套长文案同样不能被判成成功:它不含「侵权」二字,也不带待复核标记
|
||||
assertEquals("失败", AppearancePatentSheetBuilder.resolveResultStatus(
|
||||
"商标查询失败:品牌库上游整体不可用(本批待查词无一返回结果,非本行数据问题)"));
|
||||
assertEquals("失败", AppearancePatentSheetBuilder.resolveResultStatus("外观识别异常"));
|
||||
assertEquals("失败", AppearancePatentSheetBuilder.resolveResultStatus("LLM http 503: overloaded"));
|
||||
assertEquals("失败", AppearancePatentSheetBuilder.resolveResultStatus(" "));
|
||||
|
||||
Reference in New Issue
Block a user