From 0c388e0183824b4ef503c8405148726d1c173c93 Mon Sep 17 00:00:00 2001 From: Vincent <19330835921@163.com> Date: Tue, 24 Jun 2025 00:47:25 +0800 Subject: [PATCH] fix: bug --- .../ocr/api/thread/DuplicateTaskRunner.java | 2 +- .../thread/tasks/PictureImgToLocalTask.java | 9 ++---- .../module/custom/ocr/dataDao/TaskMapper.java | 2 +- .../custom/ocr/utils/ImageClassUtil.java | 4 +-- .../src/main/resources/mapper/TaskMapper.xml | 29 +++++++++---------- 5 files changed, 20 insertions(+), 26 deletions(-) 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 270ab9f..2d3c486 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 @@ -104,7 +104,7 @@ public class DuplicateTaskRunner { boolean isCrossProject = "crossProject".equals(queryConfig.getValidateScope()) && !CollectionUtils.isEmpty(queryConfig.getCrossProjectLimit()); // 普通查重 - List tasks = taskMapper.selectByAccountNoAndQueryConfig(duplicateTask.getAccountNo(), duplicateTask.getQueryConfig()); + List tasks = taskMapper.selectByAccountNoAndQueryConfig(duplicateTask.getAccountNo(), duplicateTask.getQueryConfig(), queryConfig.getValidateColumn()); checkDuplicate(duplicateTask, tasks, queryConfig, isCrossProject); // 获取跨项目任务 diff --git a/jeecg-module-custom/src/main/java/org/jeecg/module/custom/ocr/api/thread/tasks/PictureImgToLocalTask.java b/jeecg-module-custom/src/main/java/org/jeecg/module/custom/ocr/api/thread/tasks/PictureImgToLocalTask.java index 0c9cbc3..62e998c 100644 --- a/jeecg-module-custom/src/main/java/org/jeecg/module/custom/ocr/api/thread/tasks/PictureImgToLocalTask.java +++ b/jeecg-module-custom/src/main/java/org/jeecg/module/custom/ocr/api/thread/tasks/PictureImgToLocalTask.java @@ -1,13 +1,7 @@ package org.jeecg.module.custom.ocr.api.thread.tasks; import cn.hutool.core.util.ObjectUtil; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import lombok.extern.slf4j.Slf4j; -import lombok.var; import org.jeecg.module.custom.ocr.api.entity.FormRecord; import org.jeecg.module.custom.ocr.api.entity.LivePhoto; import org.jeecg.module.custom.ocr.dataobject.Task; @@ -16,7 +10,6 @@ import org.jeecg.module.custom.ocr.service.TaskService; import org.jeecg.module.custom.ocr.utils.DownloadImgUtil; import org.jeecg.module.custom.ocr.utils.ImageUtils; import org.jeecg.module.custom.ocr.utils.SpringUtils; -import org.jeecg.module.custom.ocr.utils.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.util.CollectionUtils; @@ -90,6 +83,8 @@ public class PictureImgToLocalTask implements Runnable { } catch (IOException e) { throw new RuntimeException(e); } + + logger.info("task: {}", task); Map ocrPictureClassifyAndHash = ocrPictureService.getOcrPictureClassifyAndHash(task.getLocalImageUrl()); if (ocrPictureClassifyAndHash != null) { task.setImgHash(ocrPictureClassifyAndHash.get("hash")); diff --git a/jeecg-module-custom/src/main/java/org/jeecg/module/custom/ocr/dataDao/TaskMapper.java b/jeecg-module-custom/src/main/java/org/jeecg/module/custom/ocr/dataDao/TaskMapper.java index cdc5076..cafb3ab 100644 --- a/jeecg-module-custom/src/main/java/org/jeecg/module/custom/ocr/dataDao/TaskMapper.java +++ b/jeecg-module-custom/src/main/java/org/jeecg/module/custom/ocr/dataDao/TaskMapper.java @@ -14,7 +14,7 @@ public interface TaskMapper extends BaseMapper { void deleteByTaskNos(@Param("taskNos") List taskNos); - List selectByAccountNoAndQueryConfig(@Param("accountNo") Long accountNo, @Param("queryConfig") String queryConfig); + List selectByAccountNoAndQueryConfig(@Param("accountNo") Long accountNo, @Param("queryConfig") String queryConfig, @Param("validateColumns") List validateColumns); List selectByQueryConfig(@Param("queryConfig") QueryConfig queryConfig); } diff --git a/jeecg-module-custom/src/main/java/org/jeecg/module/custom/ocr/utils/ImageClassUtil.java b/jeecg-module-custom/src/main/java/org/jeecg/module/custom/ocr/utils/ImageClassUtil.java index 5d1c020..665b1e0 100644 --- a/jeecg-module-custom/src/main/java/org/jeecg/module/custom/ocr/utils/ImageClassUtil.java +++ b/jeecg-module-custom/src/main/java/org/jeecg/module/custom/ocr/utils/ImageClassUtil.java @@ -71,8 +71,8 @@ public class ImageClassUtil { jsonObjectVi.put("taskId", taskId); JSONArray jsonArrayVi = new JSONArray(); // TODO: 测试环境可能需要调整本地图片地址路径 -// jsonArrayVi.add(imgurl); - jsonArrayVi.add("/server/ocr/data/images/test01.png"); + jsonArrayVi.add(imgurl); +// jsonArrayVi.add("/server/ocr/data/images/test01.png"); logger.info("imgurl={}", imgurl); jsonObjectVi.put("imgUrls", jsonArrayVi); diff --git a/jeecg-module-custom/src/main/resources/mapper/TaskMapper.xml b/jeecg-module-custom/src/main/resources/mapper/TaskMapper.xml index 79fdc5b..0292aec 100644 --- a/jeecg-module-custom/src/main/resources/mapper/TaskMapper.xml +++ b/jeecg-module-custom/src/main/resources/mapper/TaskMapper.xml @@ -78,21 +78,20 @@ SELECT * FROM task t WHERE - UNIX_TIMESTAMP(STR_TO_DATE( - JSON_UNQUOTE(JSON_EXTRACT(t.dynamic_fields, CONCAT('$.', JSON_UNQUOTE(JSON_EXTRACT(#{queryConfig}, '$.validateTimeColumn'))))), - '%Y-%m-%d %H:%i:%s' - )) * 1000 BETWEEN - UNIX_TIMESTAMP(STR_TO_DATE(JSON_UNQUOTE(JSON_EXTRACT(#{queryConfig}, '$.startTime')), '%Y-%m-%d %H:%i:%s')) * 1000 - AND - UNIX_TIMESTAMP(STR_TO_DATE(JSON_UNQUOTE(JSON_EXTRACT(#{queryConfig}, '$.endTime')), '%Y-%m-%d %H:%i:%s')) * 1000 - AND EXISTS ( - SELECT 1 - FROM JSON_TABLE( - JSON_EXTRACT(#{queryConfig}, '$.validateColumn'), - '$[*]' COLUMNS (col VARCHAR(255) PATH '$') - ) AS jt - WHERE JSON_EXTRACT(t.dynamic_fields, CONCAT('$.', jt.col)) IS NOT NULL - AND JSON_LENGTH(JSON_EXTRACT(t.dynamic_fields, CONCAT('$.', jt.col))) > 0 + UNIX_TIMESTAMP(STR_TO_DATE( + JSON_UNQUOTE(JSON_EXTRACT(t.dynamic_fields, CONCAT('$.', JSON_UNQUOTE(JSON_EXTRACT(#{queryConfig}, '$.validateTimeColumn'))))), + '%Y-%m-%d %H:%i:%s' + )) * 1000 BETWEEN + UNIX_TIMESTAMP(STR_TO_DATE(JSON_UNQUOTE(JSON_EXTRACT(#{queryConfig}, '$.startTime')), '%Y-%m-%d %H:%i:%s')) * 1000 + AND + UNIX_TIMESTAMP(STR_TO_DATE(JSON_UNQUOTE(JSON_EXTRACT(#{queryConfig}, '$.endTime')), '%Y-%m-%d %H:%i:%s')) * 1000 + AND EXISTS ( + SELECT 1 + WHERE + + JSON_EXTRACT(t.dynamic_fields, CONCAT('$.', #{col})) IS NOT NULL + AND JSON_LENGTH(JSON_EXTRACT(t.dynamic_fields, CONCAT('$.', #{col}))) > 0 + )