task-4: 解析接口只返回固定数量预览行,完整行仅保存在后端任务载荷
parseAndCreateTask 响应 items/groups 改为 buildResponsePreviewRows/Groups 裁剪 到 PARSE_RESPONSE_PREVIEW_LIMIT(100) 行:大文件(5000行)响应体不再携带全量行, 前端/队列只依赖统计字段与 taskId,Python 通过 parsed-payload 接口拉全量。 groups 预览副本保留 itemCount 与行级字段,字段完整且顺序稳定。 8 个测试覆盖 150/5000/1/100/101 行、空文件、非法输入、存储失败恢复与临时文件清理。
This commit is contained in:
+26
-2
@@ -497,8 +497,8 @@ public class SimilarAsinTaskService {
|
||||
vo.setAiPrompt(normalize(request.getAiPrompt()));
|
||||
vo.setImgSwitch(Boolean.TRUE.equals(request.getImgSwitch()));
|
||||
vo.setCategorySwitch(Boolean.TRUE.equals(request.getCategorySwitch()));
|
||||
vo.setItems(new ArrayList<>(allRows));
|
||||
vo.setGroups(groups);
|
||||
vo.setItems(buildResponsePreviewRows(allRows));
|
||||
vo.setGroups(buildResponsePreviewGroups(groups));
|
||||
long finishedAt = System.nanoTime();
|
||||
log.info("[similar-asin] parse timing taskId={} files={} rows={} groups={} totalMs={} parseMs={} groupMs={} taskInsertMs={} payloadJsonMs={} payloadStoreMs={} persistMs={} responseMs={}",
|
||||
task.getId(),
|
||||
@@ -1468,6 +1468,30 @@ public class SimilarAsinTaskService {
|
||||
return groups;
|
||||
}
|
||||
|
||||
private List<SimilarAsinParsedGroupVo> buildResponsePreviewGroups(List<SimilarAsinParsedGroupVo> groups) {
|
||||
if (groups == null || groups.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
int limit = Math.min(PARSE_RESPONSE_PREVIEW_LIMIT, groups.size());
|
||||
List<SimilarAsinParsedGroupVo> preview = new ArrayList<>(limit);
|
||||
for (int i = 0; i < limit; i++) {
|
||||
SimilarAsinParsedGroupVo group = groups.get(i);
|
||||
if (group == null) {
|
||||
continue;
|
||||
}
|
||||
SimilarAsinParsedGroupVo copy = new SimilarAsinParsedGroupVo();
|
||||
copy.setSourceFileKey(group.getSourceFileKey());
|
||||
copy.setSourceFilename(group.getSourceFilename());
|
||||
copy.setGroupKey(group.getGroupKey());
|
||||
copy.setBaseId(group.getBaseId());
|
||||
copy.setDisplayId(group.getDisplayId());
|
||||
copy.setItemCount(group.getItemCount());
|
||||
copy.setItems(buildResponsePreviewRows(group.getItems()));
|
||||
preview.add(copy);
|
||||
}
|
||||
return preview;
|
||||
}
|
||||
|
||||
private List<SimilarAsinParsedRowVo> buildResponsePreviewRows(List<SimilarAsinParsedRowVo> rows) {
|
||||
if (rows == null || rows.isEmpty()) {
|
||||
return List.of();
|
||||
|
||||
Reference in New Issue
Block a user