fix: 对重复图片集合去重

dev
Vincent 1 week ago
parent b425a1eed1
commit 8cd5e83122

@ -224,6 +224,15 @@ public class DuplicateTaskRunner {
private boolean notifyTaskCompletion(String taskNo, Long tenantNo, Long accountNo, double maxSimilarity, List<OcrPictureInfo> pictures, List<TaskCompletionRequest.HisPictureRepeat> historyLists) {
try {
// 去重
List<TaskCompletionRequest.HisPictureRepeat> hisPictureRepeats = historyLists.stream()
.collect(Collectors.collectingAndThen(
Collectors.toMap(
TaskCompletionRequest.HisPictureRepeat::getHisTaskNo, // 按 hisTaskNo 作为 key
hisPictureRepeat -> hisPictureRepeat, // 保留整个对象
(existing, replacement) -> existing), // 保留第一个出现的元素
map -> new ArrayList<>(map.values())
));
// 构造任务完成数据
TaskCompletionRequest.TaskCompletionData data = new TaskCompletionRequest.TaskCompletionData();
data.setTenantNo(tenantNo);
@ -243,7 +252,7 @@ public class DuplicateTaskRunner {
repeat.setImgName(p.getImgName());
repeat.setImgUrl(p.getImageUrl());
repeat.setDynamicFields(new HashMap<>()); // 动态字段待补充
repeat.setHisPictureRepeatList(historyLists);
repeat.setHisPictureRepeatList(hisPictureRepeats);
return repeat;
})
.collect(Collectors.toList());

Loading…
Cancel
Save