feat: 外观专利改直连 LLM(DeepSeek/Gemini)、无效ASIN菜单更名 BRAND_DB、紫鸟店铺索引场景化
- AppearancePatent:Coze 工作流切换为 llm-host 直连模型(title/appearance 双模型、行并发、重试),配置键迁移并保留旧环境变量兜底 - InvalidAsinDataMapper 补充按值+品牌唯一键查询 - ZiniaoShopIndexService 新增店铺分类/索引场景 - V98:无效ASIN菜单 rename 补充 BRAND_DB;docs 架构优化规划 - 配套单测更新
This commit is contained in:
+470
-804
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -35,7 +35,7 @@ import java.nio.charset.StandardCharsets;
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/appearance-patent")
|
||||
@Tag(name = "外观专利检测", description = "外观专利检测任务接口。前端上传 Excel 后由 Java 解析并创建任务;Python 回传商品数据;Java 负责攒批调用 Coze、补齐子行、生成最终 xlsx 并上传 OSS。")
|
||||
@Tag(name = "外观专利检测", description = "外观专利检测任务接口。前端上传 Excel 后由 Java 解析并创建任务;Python 回传商品数据;Java 负责攒批调用 LLM 检测、补齐子行、生成最终 xlsx 并上传 OSS。")
|
||||
public class AppearancePatentController {
|
||||
|
||||
private final AppearancePatentTaskService service;
|
||||
@@ -110,7 +110,7 @@ public class AppearancePatentController {
|
||||
}
|
||||
|
||||
@PostMapping("/tasks/{taskId}/result")
|
||||
@Operation(summary = "提交 Python 回传结果", description = "Python 回传商品数据接口。items 可以是一条或多条;Java 先原样保存回传数据,再内部攒够 10 条调用 Coze。done=true 表示 Python 已完成全部回传,Java 会强制处理剩余不足 10 条的数据并生成最终 xlsx。")
|
||||
@Operation(summary = "提交 Python 回传结果", description = "Python 回传商品数据接口。items 可以是一条或多条;Java 先原样保存回传数据,再内部攒够 10 条调用 LLM 检测。done=true 表示 Python 已完成全部回传,Java 会强制处理剩余不足 10 条的数据并生成最终 xlsx。")
|
||||
public ApiResponse<Void> result(
|
||||
@Parameter(description = "外观专利检测任务 ID。任务必须处于 RUNNING 状态。", required = true, example = "3938")
|
||||
@PathVariable Long taskId,
|
||||
|
||||
+3
-3
@@ -24,17 +24,17 @@ public class AppearancePatentParseRequest {
|
||||
|
||||
@JsonProperty("ai_prompt")
|
||||
@JsonAlias({"aiPrompt", "prompt"})
|
||||
@Schema(description = "AI 提示词。非必填;为空时前端会使用默认提示词。后端会保存该提示词,并在调用 Coze workflow 时作为 prompt 参数传入。", example = "请排查这些亚马逊商品在英国及欧洲地区是否存在知识产权侵权风险。")
|
||||
@Schema(description = "AI 提示词。非必填;为空时前端会使用默认提示词。后端会保存该提示词,并在调用 LLM 时作为附加要求传入。", example = "请排查这些亚马逊商品在英国及欧洲地区是否存在知识产权侵权风险。")
|
||||
private String aiPrompt;
|
||||
|
||||
@JsonProperty("api_key")
|
||||
@JsonAlias({"apiKey"})
|
||||
@Schema(description = "传递给 Coze workflow parameters.api_key 的任务级密钥。")
|
||||
@Schema(description = "调用 LLM API 的任务级密钥。")
|
||||
@NotBlank(message = "密钥不能为空")
|
||||
private String apiKey;
|
||||
|
||||
@JsonProperty("patent_token")
|
||||
@JsonAlias({"patentToken"})
|
||||
@Schema(description = "传递给 Coze workflow parameters.patent_token 的专利汇令牌。非必填。")
|
||||
@Schema(description = "专利汇令牌。非必填。")
|
||||
private String patentToken;
|
||||
}
|
||||
|
||||
+2
-2
@@ -14,10 +14,10 @@ public class AppearancePatentParsedPayloadDto {
|
||||
@Schema(description = "AI 提示词")
|
||||
private String aiPrompt;
|
||||
|
||||
@Schema(description = "传递给 Coze workflow parameters.api_key 的任务级密钥")
|
||||
@Schema(description = "调用 LLM API 的任务级密钥")
|
||||
private String apiKey;
|
||||
|
||||
@Schema(description = "传递给 Coze workflow parameters.patent_token 的专利汇令牌")
|
||||
@Schema(description = "专利汇令牌")
|
||||
private String patentToken;
|
||||
|
||||
@Schema(description = "本次解析的源文件列表")
|
||||
|
||||
+7
-7
@@ -29,7 +29,7 @@ public class AppearancePatentResultRowDto {
|
||||
@Schema(description = "站点或国家。来自 Excel 的国家列,例如英国、德国、法国。", example = "英国")
|
||||
private String country;
|
||||
|
||||
@Schema(description = "商品 SKU。Java 调用 Coze 时会放入 items[].sku。", example = "SKU-001")
|
||||
@Schema(description = "商品 SKU。Java 调用 LLM 时会作为标题识别输入。", example = "SKU-001")
|
||||
@JsonAlias({"SKU", "sellerSku", "seller_sku", "merchantSku", "merchant_sku", "商品SKU", "商品 sku", "库存SKU"})
|
||||
private String sku;
|
||||
|
||||
@@ -41,7 +41,7 @@ public class AppearancePatentResultRowDto {
|
||||
@JsonAlias({"Price", "价格"})
|
||||
private String price;
|
||||
|
||||
@Schema(description = "商品主图或待检测图片 URL。Java 调用 Coze 时会放入 url_list。", example = "https://webstatic.aiproxy.vip/output/20260425/103322/demo.jpg")
|
||||
@Schema(description = "商品主图或待检测图片 URL。Java 调用 LLM 时会作为外观检测图片输入。", example = "https://webstatic.aiproxy.vip/output/20260425/103322/demo.jpg")
|
||||
@JsonAlias({
|
||||
"imageUrl", "image_url", "imgUrl", "img_url", "pictureUrl", "picture_url",
|
||||
"mainImage", "main_image", "mainImageUrl", "main_image_url",
|
||||
@@ -51,24 +51,24 @@ public class AppearancePatentResultRowDto {
|
||||
})
|
||||
private String url;
|
||||
|
||||
@Schema(description = "商品标题。Java 调用 Coze 时会放入 title_list;为空时会回退使用 ASIN。", example = "Women Floral Dress Summer Casual")
|
||||
@Schema(description = "商品标题。Java 调用 LLM 时会作为标题识别输入;为空时会回退使用 ASIN。", example = "Women Floral Dress Summer Casual")
|
||||
@JsonAlias({"productTitle", "product_title", "itemTitle", "item_title", "商品标题", "商品名称", "标题"})
|
||||
private String title;
|
||||
|
||||
@Schema(description = "单行错误信息。通常用于记录 Python 单行处理异常;Coze 失败时后端会尽量保留原始行,不强行写入风险结果。", example = "图片地址为空")
|
||||
@Schema(description = "单行错误信息。通常用于记录 Python 单行处理异常;LLM 检测失败时后端会尽量保留原始行,不强行写入风险结果。", example = "图片地址为空")
|
||||
private String error;
|
||||
|
||||
@Schema(description = "单行完成标记。当前主要使用请求体顶层 done 控制任务收尾,该字段仅作兼容。", example = "true")
|
||||
private Boolean done;
|
||||
|
||||
@JsonAlias({"row_status", "rowStatus", "Status"})
|
||||
@Schema(description = "Coze 行处理状态", example = "success", accessMode = Schema.AccessMode.READ_ONLY)
|
||||
@Schema(description = "行处理状态", example = "success", accessMode = Schema.AccessMode.READ_ONLY)
|
||||
private String status;
|
||||
|
||||
@Schema(description = "Java 调用 Coze 后生成的标题维度检测结果,对应最终 xlsx 的“标题维度(商标)”列。Python 回传请求中不要传该字段;即使传入,后端也会以 Java/Coze 处理结果为准。", example = "标题未发现明显商标侵权风险。", accessMode = Schema.AccessMode.READ_ONLY)
|
||||
@Schema(description = "Java 调用 LLM 后生成的标题维度检测结果,对应最终 xlsx 的“标题维度(商标)”列。Python 回传请求中不要传该字段;即使传入,后端也会以 Java/LLM 处理结果为准。", example = "标题未发现明显商标侵权风险。", accessMode = Schema.AccessMode.READ_ONLY)
|
||||
private String titleRisk;
|
||||
|
||||
@Schema(description = "Java 调用 Coze 后生成的外观维度检测结果,对应最终 xlsx 的“外观维度(外观设计专利)”列。Python 回传请求中不要传该字段。", example = "未发现明显外观设计专利侵权风险。", accessMode = Schema.AccessMode.READ_ONLY)
|
||||
@Schema(description = "Java 调用 LLM 后生成的外观维度检测结果,对应最终 xlsx 的“外观维度(外观设计专利)”列。Python 回传请求中不要传该字段。", example = "未发现明显外观设计专利侵权风险。", accessMode = Schema.AccessMode.READ_ONLY)
|
||||
private String appearanceRisk;
|
||||
|
||||
@JsonAlias({"patent ", "patent"})
|
||||
|
||||
+40
@@ -126,11 +126,51 @@ public class AppearancePatentTaskCacheService {
|
||||
try {
|
||||
stringRedisTemplate.delete(pendingRowsKey(taskId));
|
||||
stringRedisTemplate.delete(heartbeatKey(taskId));
|
||||
stringRedisTemplate.delete(processedRowsKey(taskId));
|
||||
} catch (Exception ex) {
|
||||
log.warn("[appearance-patent-cache] delete degraded taskId={} msg={}", taskId, ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 行级检测去重:Redis SETNX,防止 submitResult 与 stale 恢复双入口并发处理同一批。
|
||||
* 返回 true 表示首次标记(应执行检测),false 表示已处理过(跳过)。
|
||||
*/
|
||||
public boolean markRowProcessed(Long taskId, String rowKey) {
|
||||
if (taskId == null || taskId <= 0 || rowKey == null || rowKey.isBlank()) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
Boolean first = stringRedisTemplate.opsForValue().setIfAbsent(
|
||||
processedRowKey(taskId, rowKey), "1", Duration.ofHours(TTL_HOURS));
|
||||
return Boolean.TRUE.equals(first);
|
||||
} catch (Exception ex) {
|
||||
log.warn("[appearance-patent-cache] mark row processed degraded taskId={} rowKey={} msg={}", taskId, rowKey, ex.getMessage());
|
||||
// Redis 降级时放行,由持久化层的 hasResolvedCozeFields 判据兜底去重。
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isRowProcessed(Long taskId, String rowKey) {
|
||||
if (taskId == null || taskId <= 0 || rowKey == null || rowKey.isBlank()) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return Boolean.TRUE.equals(stringRedisTemplate.hasKey(processedRowKey(taskId, rowKey)));
|
||||
} catch (Exception ex) {
|
||||
log.warn("[appearance-patent-cache] check row processed degraded taskId={} rowKey={} msg={}", taskId, rowKey, ex.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private String processedRowsKey(Long taskId) {
|
||||
return "appearance-patent:task:processed-rows:" + taskId;
|
||||
}
|
||||
|
||||
private String processedRowKey(Long taskId, String rowKey) {
|
||||
return processedRowsKey(taskId) + ":" + rowKey;
|
||||
}
|
||||
|
||||
private String pendingRowsKey(Long taskId) {
|
||||
return "appearance-patent:task:pending-rows:" + taskId;
|
||||
}
|
||||
|
||||
+167
-1459
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user