fix(外观专利): 整批失败文案带上游那句真因作样例(BK B95-02 判据收口)

上一条只做到「分类」:交付列写「服务侧解密链路故障」,但到底是 UTF-8 解不开、密钥不对
还是压缩坏了,只有上游那句 reason 知道——B95-02 的判据要求「能回读到是哪一步失败」。

- AppearancePatentBrandFailureText.describe:分类文案 + 一句样例(压单行、截 80 字、超出以 …
  收尾),没给原因时退回纯分类文案,不凭空补。
- aggregate 改用 describe(分类口径与保守判定一字未动)。
- 用例:e2e 改成「保前缀 + 带 Malformed UTF-8 样例」;新增样例单行/截断/空原因三格(共 21 支)。
This commit is contained in:
2026-11-11 20:14:44 +08:00
parent a17d8edc9e
commit ef78608a64
2 changed files with 44 additions and 2 deletions
@@ -32,6 +32,9 @@ final class AppearancePatentBrandFailureText {
static final String SERVICE_UNREACHABLE =
"商标查询失败:品牌检测服务不可达(连接未建立,非本行数据问题)";
/** 样例最多留几个字:够定位真因,又不把整段上游报错糊进交付列。 */
static final int SAMPLE_KEEP = 80;
private AppearancePatentBrandFailureText() {
}
@@ -56,7 +59,28 @@ final class AppearancePatentBrandFailureText {
}
reasons.add(normalize(check.reason()));
}
return anyChecked ? classify(reasons) : null;
return anyChecked ? describe(classify(reasons), reasons) : null;
}
/**
* 分类文案 + 一句失败样例。
*
* <p>BK B95-02 的判据是「解密失败那条要能回读到是哪一步失败」:分类只说到「解密链路」,
* 具体是 UTF-8 解不开、密钥不对还是压缩坏了,只有上游那句 reason 才知道。样例截断到
* {@link #SAMPLE_KEEP} 字并对齐单行——它是给人看的一句话,不是堆栈搬运。
*/
static String describe(String base, List<String> reasons) {
String sample = "";
if (reasons != null) {
for (String reason : reasons) {
String text = normalize(reason).replace('\n', ' ').replace('\r', ' ');
if (!text.isEmpty()) {
sample = text.length() > SAMPLE_KEEP ? text.substring(0, SAMPLE_KEEP) + "…" : text;
break;
}
}
}
return sample.isEmpty() ? base : base + ";样例=" + sample;
}
/** 批内 reason 全同形才分档;空 reason 或混形一律落回通用文案(不猜)。 */