feat: 补足数据

dev
Vincent 1 week ago
parent 9d3b2d6f1a
commit b425a1eed1

@ -71,8 +71,8 @@ public class TaskCompletionRequest {
@Data
public static class PictureRepeat {
@JSONField(name = "imgNo")
private Long imgNo;
@JSONField(name = "imgName")
private String imgName;
@JSONField(name = "imgUrl")
private String imgUrl;
@ -86,14 +86,35 @@ public class TaskCompletionRequest {
@Data
public static class HisPictureRepeat {
@JSONField(name = "hisTaskId")
private Long hisTaskId;
@JSONField(name = "hisTaskNo")
private Long hisTaskNo;
@JSONField(name = "hisRepeatImgNo")
private Long hisRepeatImgNo;
@JSONField(name = "hisRepeatSubmitTime")
private Long hisRepeatSubmitTime;
@JSONField(name = "hisRepeatImgName")
private String hisRepeatImgName;
@JSONField(name = "hisRepeatTaskId")
private Long hisRepeatTaskId;
@JSONField(name = "hisRepeatImgUrl")
private String hisRepeatImgUrl;
@JSONField(name = "hisRepeatSignAccountName")
private String hisRepeatSignAccountName;
@JSONField(name = "hisRepeatFillUserName")
private String hisRepeatFillUserName;
@JSONField(name = "hisRepeatTask")
private String hisRepeatTask;
}
@Data

@ -17,10 +17,7 @@ import org.jeecg.module.custom.ocr.dataDao.TaskMapper;
import org.jeecg.module.custom.ocr.dataobject.*;
import org.jeecg.module.custom.ocr.service.OcrPictureInfoService;
import org.jeecg.module.custom.ocr.service.OcrPictureService;
import org.jeecg.module.custom.ocr.utils.ApiHelper;
import org.jeecg.module.custom.ocr.utils.HashCompareUtil;
import org.jeecg.module.custom.ocr.utils.NameConverterUtil;
import org.jeecg.module.custom.ocr.utils.StringUtils;
import org.jeecg.module.custom.ocr.utils.*;
import org.jeecg.module.custom.ocr.utils.httputil.HttpClient;
import org.jeecg.module.custom.ocr.utils.httputil.HttpMethod;
import org.jeecg.module.custom.ocr.utils.httputil.HttpParamers;
@ -32,10 +29,7 @@ import org.springframework.util.CollectionUtils;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@ -157,6 +151,12 @@ public class DuplicateTaskRunner {
Set<Long> pictureIds = Sets.newHashSet();
List<Long> taskNoList = tasks.stream().map(Task::getTaskNo).distinct().collect(Collectors.toList());
Map<Long, Task> taskMap = tasks.stream()
.collect(Collectors.toMap(
Task::getTaskNo, // Key mapper - taskNo
task -> task, // Value mapper - the task itself
(existing, replacement) -> existing // Merge function - keep the existing one if duplicates
));
List<OcrPictureInfo> pictures = ocrPictureInfoMapper.selectByTaskNos(taskNoList);
if (!CollectionUtils.isEmpty(pictures)) {
pictures = pictures.stream().filter(item -> queryConfig.getValidateColumn().contains(item.getType())).collect(Collectors.toList());
@ -175,9 +175,19 @@ public class DuplicateTaskRunner {
double similarityValue = Double.parseDouble(similarityScore);
if (!pictureIds.contains(first.getId()) && similarityValue > queryConfig.getConfidenceLevel()) {
TaskCompletionRequest.HisPictureRepeat hisPictureRepeat = new TaskCompletionRequest.HisPictureRepeat();
Task task = taskMap.get(first.getTaskNo());
hisPictureRepeat.setHisTaskId(task.getTaskId());
hisPictureRepeat.setHisRepeatSubmitTime(task.getSubmitTime());
Map<String, String> stringStringMap = JsonUtil.jsonToMap(task.getDynamicFields());
hisPictureRepeat.setHisRepeatFillUserName(stringStringMap.get("fillUserName"));
hisPictureRepeat.setHisRepeatSignAccountName(stringStringMap.get("signAccountName"));
hisPictureRepeat.setHisRepeatTask(JSONObject.toJSONString(task));
hisPictureRepeat.setHisTaskNo(first.getTaskNo());
hisPictureRepeat.setHisRepeatImgUrl(first.getImageUrl());
hisPictureRepeat.setHisRepeatImgNo(first.getId());
hisPictureRepeat.setHisRepeatImgName(first.getImgName());
hisPictureRepeat.setHisRepeatTaskId(first.getTaskNo());
pictureIds.add(first.getId());
historyLists.add(hisPictureRepeat);
}
@ -230,7 +240,7 @@ public class DuplicateTaskRunner {
List<TaskCompletionRequest.PictureRepeat> pictureRepeatList = pictures.stream()
.map(p -> {
TaskCompletionRequest.PictureRepeat repeat = new TaskCompletionRequest.PictureRepeat();
repeat.setImgNo(p.getId());
repeat.setImgName(p.getImgName());
repeat.setImgUrl(p.getImageUrl());
repeat.setDynamicFields(new HashMap<>()); // 动态字段待补充
repeat.setHisPictureRepeatList(historyLists);

@ -0,0 +1,40 @@
package org.jeecg.module.custom.ocr.utils;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.core.type.TypeReference;
import java.util.Map;
import java.util.HashMap;
public class JsonUtil {
private static final ObjectMapper objectMapper = new ObjectMapper();
public static Map<String, String> jsonToMap(String jsonString) {
try {
// 先将JSON字符串转换为Map<String, Object>
Map<String, Object> originalMap = objectMapper.readValue(
jsonString,
new TypeReference<Map<String, Object>>() {}
);
// 转换为Map<String, String>
Map<String, String> resultMap = new HashMap<>();
for (Map.Entry<String, Object> entry : originalMap.entrySet()) {
Object value = entry.getValue();
// 处理不同类型的值
if (value == null) {
resultMap.put(entry.getKey(), null);
} else if (value instanceof String ||
value instanceof Number ||
value instanceof Boolean) {
resultMap.put(entry.getKey(), value.toString());
} else {
// 对于复杂对象Map、List等转换为JSON字符串
resultMap.put(entry.getKey(), objectMapper.writeValueAsString(value));
}
}
return resultMap;
} catch (Exception e) {
throw new RuntimeException("Failed to convert JSON to Map", e);
}
}
}
Loading…
Cancel
Save