diff --git a/jeecg-module-custom/src/main/java/org/jeecg/module/custom/ocr/api/thread/DuplicateTaskRunner.java b/jeecg-module-custom/src/main/java/org/jeecg/module/custom/ocr/api/thread/DuplicateTaskRunner.java index db0aa2c..40b1000 100644 --- a/jeecg-module-custom/src/main/java/org/jeecg/module/custom/ocr/api/thread/DuplicateTaskRunner.java +++ b/jeecg-module-custom/src/main/java/org/jeecg/module/custom/ocr/api/thread/DuplicateTaskRunner.java @@ -224,6 +224,15 @@ public class DuplicateTaskRunner { private boolean notifyTaskCompletion(String taskNo, Long tenantNo, Long accountNo, double maxSimilarity, List pictures, List historyLists) { try { + // 去重 + List 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());