From ce00cf05c0f8d0be74796e0b8a0d23c19f47e2bd Mon Sep 17 00:00:00 2001 From: zhouwentao <1577701412@qq.com> Date: Mon, 18 Sep 2023 20:45:50 +0800 Subject: [PATCH 01/36] =?UTF-8?q?updates=20=E5=9B=9E=E4=BC=A0=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E5=BA=A6=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/api/controller/ApiController.java | 5 ++ .../service/impl/OcrIdentifyServiceImpl.java | 2 +- .../modules/ocr/utils/CallBackWlyUtils.java | 72 ++++++++++++++++--- 3 files changed, 67 insertions(+), 12 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java index a551e02..613aece 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java @@ -18,6 +18,7 @@ import org.jeecg.modules.ocr.service.IOcrIdentifyDetailService; import org.jeecg.modules.ocr.service.IOcrIdentifyService; import org.jeecg.modules.ocr.service.IOcrRuleCheckService; import org.jeecg.modules.ocr.service.impl.TaskService; +import org.jeecg.modules.ocr.utils.CallBackWlyUtils; import org.jeecg.modules.ocr.utils.FileOUtils; import org.jeecg.modules.ocr.utils.ImageUtils; import org.jeecg.modules.ocr.dto.OcrIdentifyDTO; @@ -255,7 +256,11 @@ public class ApiController { //ocrIdentifyService.getSemanticInfo(semanticResponseJson); /*OcrRuleCheckVo ocrRuleCheckVo = byId.getOcrRuleCheckVo(); Map configRuleMap = ocrRuleCheckVo.getConfigRuleMap();*/ + OcrIdentifyDTO identifyDTO = ocrIdentifyService.findById("1703642249574752258"); + List identifyDetailList = ocrIdentifyDetailService.listByIdentifyId(identifyDTO.getId()); + CallBackWlyUtils.callbackWly(identifyDTO,identifyDetailList); return Result.OK(""); } + } \ No newline at end of file diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java index ecd4f76..2baec19 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java @@ -529,7 +529,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl jsonObjects = new ArrayList<>(); - //成功率 - BigDecimal textRateBigd = new BigDecimal(0); //总明细数量 int detail_detailCount = 0; - for (OcrIdentifyDetail identifyDetail : identifyDetails) { - if (StringUtils.isNotBlank(identifyDetail.getDataStructured())) { - List jsonObjects1 = JSONArray.parseArray(identifyDetail.getDataStructured()).toJavaList(JSONObject.class); - if (CollectionUtils.isNotEmpty(jsonObjects1)) { - double textRate = jsonObjects.stream().mapToDouble(o->o.getDouble("textRate")).sum(); - textRateBigd = textRateBigd.add(new BigDecimal(textRate)); - detail_detailCount += jsonObjects1.size(); - jsonObjects.addAll(jsonObjects1); + int detailValidationCount=0; + String taskResultInfo = ocrIdentify.getTaskResultInfo(); + if (StringUtils.isNotBlank(taskResultInfo)) { + //循环获取哪些字段通过了 + List taskResultInfoList = JSONArray.parseArray(taskResultInfo).toJavaList(JSONObject.class); + detail_detailCount=taskResultInfoList.size(); + for (JSONObject jsonObject : taskResultInfoList) { + Boolean ruleValidation = (Boolean) jsonObject.getOrDefault("ruleValidation", false); + if (ruleValidation) { + //通过了, + detailValidationCount++; } } } //组装回调参数 + //成功率 double imageTagRetrievePercentage = 0.0d; if (detail_detailCount > 0) { - BigDecimal divide = textRateBigd.divide(new BigDecimal(detail_detailCount), 2, RoundingMode.HALF_UP); + BigDecimal divide = new BigDecimal(detailValidationCount).divide(new BigDecimal(detail_detailCount), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)); imageTagRetrievePercentage = divide.doubleValue(); } if (StringUtils.isNotBlank(ocrIdentify.getTaskResult()) && "1".equals(ocrIdentify.getTaskResult())) { @@ -95,4 +97,52 @@ public class CallBackWlyUtils { } } } + + public static boolean callbackWly2(OcrIdentify ocrIdentify, List identifyDetails) { + String requestId = ocrIdentify.getRequestId(); + //请求对象 + CallBackWlyResult result = new CallBackWlyResult(); + + List jsonObjects = new ArrayList<>(); + //成功率 + BigDecimal textRateBigd = new BigDecimal(0); + //总明细数量 + int detail_detailCount = 0; + for (OcrIdentifyDetail identifyDetail : identifyDetails) { + if (StringUtils.isNotBlank(identifyDetail.getDataStructured())) { + List jsonObjects1 = JSONArray.parseArray(identifyDetail.getDataStructured()).toJavaList(JSONObject.class); + if (CollectionUtils.isNotEmpty(jsonObjects1)) { + double textRate = jsonObjects.stream().mapToDouble(o->o.getDouble("textRate")).sum(); + textRateBigd = textRateBigd.add(new BigDecimal(textRate)); + detail_detailCount += jsonObjects1.size(); + jsonObjects.addAll(jsonObjects1); + } + } + } + + //组装回调参数 + double imageTagRetrievePercentage = 0.0d; + if (detail_detailCount > 0) { + BigDecimal divide = textRateBigd.divide(new BigDecimal(detail_detailCount), 2, RoundingMode.HALF_UP); + imageTagRetrievePercentage = divide.doubleValue(); + } + if (StringUtils.isNotBlank(ocrIdentify.getTaskResult()) && "1".equals(ocrIdentify.getTaskResult())) { + result.setRuleValidation(true); + }else{ + result.setRuleValidation(false); + } + result.setImageTagRetrievePercentage(imageTagRetrievePercentage + ""); + result.setRetrieveReviewCompliance(imageTagRetrievePercentage+""); + result.setFailureReason(ocrIdentify.getErrorMsg()); + if (CollectionUtils.isEmpty(jsonObjects)) { + return false; + } + result.setOcrResult(jsonObjects); + + log.info("请求无量云回调接口"); + JSONObject semanticResponseJson = null; + return false; + } + + } From 4a0b5f2393571ccc140afa13afd3547666ce4e7b Mon Sep 17 00:00:00 2001 From: zhouwentao <1577701412@qq.com> Date: Mon, 18 Sep 2023 21:01:21 +0800 Subject: [PATCH 02/36] =?UTF-8?q?updates=20=E5=9B=9E=E4=BC=A0=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E5=BA=A6=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/modules/ocr/init/HandleCallbacklnit.java | 2 +- .../org/jeecg/modules/ocr/utils/CallBackWlyUtils.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleCallbacklnit.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleCallbacklnit.java index de36fe1..6b3ef7d 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleCallbacklnit.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleCallbacklnit.java @@ -62,7 +62,7 @@ public class HandleCallbacklnit implements ApplicationRunner { autoPushNoticeMaxNum = Integer.valueOf(callbackApiConfig.getValue()); } } - + log.info(pushTimeInterval+"秒请求一次回调"); while (true){ try { Thread.sleep(pushTimeInterval*1000); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java index 71df850..97a79d0 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java @@ -32,14 +32,14 @@ public class CallBackWlyUtils { //请求对象 CallBackWlyResult result = new CallBackWlyResult(); - List jsonObjects = new ArrayList<>(); + List taskResultInfoList=null; //总明细数量 int detail_detailCount = 0; int detailValidationCount=0; String taskResultInfo = ocrIdentify.getTaskResultInfo(); if (StringUtils.isNotBlank(taskResultInfo)) { //循环获取哪些字段通过了 - List taskResultInfoList = JSONArray.parseArray(taskResultInfo).toJavaList(JSONObject.class); + taskResultInfoList = JSONArray.parseArray(taskResultInfo).toJavaList(JSONObject.class); detail_detailCount=taskResultInfoList.size(); for (JSONObject jsonObject : taskResultInfoList) { Boolean ruleValidation = (Boolean) jsonObject.getOrDefault("ruleValidation", false); @@ -65,10 +65,10 @@ public class CallBackWlyUtils { result.setImageTagRetrievePercentage(imageTagRetrievePercentage + ""); result.setRetrieveReviewCompliance(imageTagRetrievePercentage+""); result.setFailureReason(ocrIdentify.getErrorMsg()); - if (CollectionUtils.isEmpty(jsonObjects)) { + if (CollectionUtils.isEmpty(taskResultInfoList)) { return false; } - result.setOcrResult(jsonObjects); + result.setOcrResult(taskResultInfoList); log.info("请求无量云回调接口"); JSONObject semanticResponseJson = null; From d519ba7f2d6a04556a36f8cb03918548e04e5c7c Mon Sep 17 00:00:00 2001 From: zhouwentao <1577701412@qq.com> Date: Mon, 18 Sep 2023 21:04:26 +0800 Subject: [PATCH 03/36] =?UTF-8?q?updates=20=E5=9B=9E=E4=BC=A0=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E5=BA=A6=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/ocr/utils/CallBackWlyUtils.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java index 97a79d0..680877b 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java @@ -32,14 +32,14 @@ public class CallBackWlyUtils { //请求对象 CallBackWlyResult result = new CallBackWlyResult(); - List taskResultInfoList=null; + List jsonObjects=new ArrayList<>(); //总明细数量 int detail_detailCount = 0; int detailValidationCount=0; String taskResultInfo = ocrIdentify.getTaskResultInfo(); if (StringUtils.isNotBlank(taskResultInfo)) { //循环获取哪些字段通过了 - taskResultInfoList = JSONArray.parseArray(taskResultInfo).toJavaList(JSONObject.class); + List taskResultInfoList = JSONArray.parseArray(taskResultInfo).toJavaList(JSONObject.class); detail_detailCount=taskResultInfoList.size(); for (JSONObject jsonObject : taskResultInfoList) { Boolean ruleValidation = (Boolean) jsonObject.getOrDefault("ruleValidation", false); @@ -50,6 +50,16 @@ public class CallBackWlyUtils { } } + for (OcrIdentifyDetail identifyDetail : identifyDetails) { + if (StringUtils.isNotBlank(identifyDetail.getDataStructured())) { + List jsonObjects1 = JSONArray.parseArray(identifyDetail.getDataStructured()).toJavaList(JSONObject.class); + if (CollectionUtils.isNotEmpty(jsonObjects1)) { + jsonObjects.addAll(jsonObjects1); + } + } + } + + //组装回调参数 //成功率 double imageTagRetrievePercentage = 0.0d; @@ -65,10 +75,10 @@ public class CallBackWlyUtils { result.setImageTagRetrievePercentage(imageTagRetrievePercentage + ""); result.setRetrieveReviewCompliance(imageTagRetrievePercentage+""); result.setFailureReason(ocrIdentify.getErrorMsg()); - if (CollectionUtils.isEmpty(taskResultInfoList)) { + if (CollectionUtils.isEmpty(jsonObjects)) { return false; } - result.setOcrResult(taskResultInfoList); + result.setOcrResult(jsonObjects); log.info("请求无量云回调接口"); JSONObject semanticResponseJson = null; From 258b40332ab15f52cf1db8f3b40d93018ef6b8e1 Mon Sep 17 00:00:00 2001 From: DELL Date: Tue, 19 Sep 2023 17:54:10 +0800 Subject: [PATCH 04/36] =?UTF-8?q?=E8=A7=84=E5=88=99=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/OcrIdentifyServiceImpl.java | 123 +++++++++++++++++- 1 file changed, 118 insertions(+), 5 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java index 2baec19..e8a921c 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java @@ -248,8 +248,8 @@ public class OcrIdentifyServiceImpl extends ServiceImpl sourceJson = new ArrayList<>(); if (StringUtils.isNotBlank(doctorName)) { sourceJson.add(JSONObject.parseObject(String.format("{\"tag\":\"doctorName\", \"inputText\":\"%s\"}", doctorName))); @@ -712,6 +717,21 @@ public class OcrIdentifyServiceImpl extends ServiceImpl Date: Tue, 19 Sep 2023 19:28:09 +0800 Subject: [PATCH 05/36] updates --- .../modules/api/controller/ApiController.java | 2 +- .../service/impl/OcrIdentifyServiceImpl.java | 20 ------------------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java index 613aece..d22bb6b 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java @@ -256,7 +256,7 @@ public class ApiController { //ocrIdentifyService.getSemanticInfo(semanticResponseJson); /*OcrRuleCheckVo ocrRuleCheckVo = byId.getOcrRuleCheckVo(); Map configRuleMap = ocrRuleCheckVo.getConfigRuleMap();*/ - OcrIdentifyDTO identifyDTO = ocrIdentifyService.findById("1703642249574752258"); + OcrIdentifyDTO identifyDTO = ocrIdentifyService.findById("1702560400245035009"); List identifyDetailList = ocrIdentifyDetailService.listByIdentifyId(identifyDTO.getId()); CallBackWlyUtils.callbackWly(identifyDTO,identifyDetailList); return Result.OK(""); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java index e8a921c..99a4fd1 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java @@ -699,11 +699,6 @@ public class OcrIdentifyServiceImpl extends ServiceImpl sourceJson = new ArrayList<>(); if (StringUtils.isNotBlank(doctorName)) { sourceJson.add(JSONObject.parseObject(String.format("{\"tag\":\"doctorName\", \"inputText\":\"%s\"}", doctorName))); @@ -717,21 +712,6 @@ public class OcrIdentifyServiceImpl extends ServiceImpl Date: Tue, 19 Sep 2023 19:47:53 +0800 Subject: [PATCH 06/36] =?UTF-8?q?=E8=A7=84=E5=88=99=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/ocr/service/impl/OcrIdentifyServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java index 99a4fd1..b0dcf9d 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java @@ -520,7 +520,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl getCheckSemanticModelMap(Map configRuleMap, Map fieldMap, List sourceJsonObjects) { - if (configRuleMap!=null) { + if (configRuleMap!=null && CollectionUtils.isNotEmpty(configRuleMap.keySet())) { for (String s : configRuleMap.keySet()) { String value = configRuleMap.get(s); if ("hn".equals(s)) { @@ -893,8 +893,8 @@ public class OcrIdentifyServiceImpl extends ServiceImpl Date: Tue, 19 Sep 2023 19:55:19 +0800 Subject: [PATCH 07/36] updates --- .../ocr/service/impl/OcrIdentifyServiceImpl.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java index b0dcf9d..ad7e136 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java @@ -516,13 +516,14 @@ public class OcrIdentifyServiceImpl extends ServiceImpl getCheckSemanticModelMap(Map configRuleMap, Map fieldMap, List sourceJsonObjects) { - if (configRuleMap!=null && CollectionUtils.isNotEmpty(configRuleMap.keySet())) { - for (String s : configRuleMap.keySet()) { - String value = configRuleMap.get(s); + public Map getCheckSemanticModelMap(Map oldConfigRuleMap, Map fieldMap, List sourceJsonObjects) { + Map configRuleMap=new LinkedHashMap<>(); + if (oldConfigRuleMap!=null && CollectionUtils.isNotEmpty(oldConfigRuleMap.keySet())) { + for (String s : oldConfigRuleMap.keySet()) { + String value = oldConfigRuleMap.get(s); if ("hn".equals(s)) { configRuleMap.put("hospitalName",value); }else if("dn".equals(s)) { @@ -531,6 +532,8 @@ public class OcrIdentifyServiceImpl extends ServiceImpl Date: Tue, 19 Sep 2023 20:02:12 +0800 Subject: [PATCH 08/36] updates --- .../ocr/service/impl/OcrIdentifyServiceImpl.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java index ad7e136..183ac50 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java @@ -516,14 +516,14 @@ public class OcrIdentifyServiceImpl extends ServiceImpl getCheckSemanticModelMap(Map oldConfigRuleMap, Map fieldMap, List sourceJsonObjects) { - Map configRuleMap=new LinkedHashMap<>(); - if (oldConfigRuleMap!=null && CollectionUtils.isNotEmpty(oldConfigRuleMap.keySet())) { - for (String s : oldConfigRuleMap.keySet()) { - String value = oldConfigRuleMap.get(s); + public Map getCheckSemanticModelMap(Map configRuleMap, Map fieldMap, List sourceJsonObjects) { + if (configRuleMap!=null && CollectionUtils.isNotEmpty(configRuleMap.keySet())) { + Set keySet = configRuleMap.keySet(); + for (String s : keySet) { + String value = configRuleMap.get(s); if ("hn".equals(s)) { configRuleMap.put("hospitalName",value); }else if("dn".equals(s)) { From 132976ba135ae52f262fdc18ecd4f7135c16fb10 Mon Sep 17 00:00:00 2001 From: zhouwentao <1577701412@qq.com> Date: Tue, 19 Sep 2023 20:30:56 +0800 Subject: [PATCH 09/36] updates --- .../modules/ocr/service/impl/OcrIdentifyServiceImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java index 183ac50..d2140bd 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java @@ -521,7 +521,9 @@ public class OcrIdentifyServiceImpl extends ServiceImpl getCheckSemanticModelMap(Map configRuleMap, Map fieldMap, List sourceJsonObjects) { if (configRuleMap!=null && CollectionUtils.isNotEmpty(configRuleMap.keySet())) { - Set keySet = configRuleMap.keySet(); + //将 configRuleMap的 key 创建一个Set + Set keySet = new HashSet<>(configRuleMap.keySet()); + //循环keySet,判断字段是否是缩写,如果是缩写就把缩写的全称put一下 for (String s : keySet) { String value = configRuleMap.get(s); if ("hn".equals(s)) { From b88eafe8abe81393563cb646e18bc0822209ef54 Mon Sep 17 00:00:00 2001 From: zhouwentao <1577701412@qq.com> Date: Wed, 20 Sep 2023 18:39:25 +0800 Subject: [PATCH 10/36] =?UTF-8?q?updates=20=E6=89=A7=E8=A1=8C=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=9A=84=E6=B5=81=E7=A8=8B=E9=80=BB=E8=BE=91=20?= =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/api/controller/ApiController.java | 2 +- .../ocr/controller/OcrIdentifyController.java | 2 +- .../modules/ocr/init/HandleTaskInit.java | 146 ++++++++++++++++++ .../modules/ocr/init/HandleTransInit.java | 3 +- .../ocr/service/IOcrIdentifyService.java | 6 + .../service/impl/OcrIdentifyServiceImpl.java | 20 ++- .../modules/ocr/service/impl/TaskService.java | 2 +- 7 files changed, 169 insertions(+), 12 deletions(-) create mode 100644 jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java index d22bb6b..6d03744 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java @@ -133,7 +133,7 @@ public class ApiController { } Thread.sleep(1000L); //3.请求python ocr识别,异步执行 - taskService.postSemantic(ocrIdentify,fileList); + //taskService.postSemantic(ocrIdentify,fileList); //ocrIdentifyService.postSemantic(ocrIdentify, fileList); return Result.OK("请求成功"); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyController.java index e46698d..70e8439 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyController.java @@ -182,7 +182,7 @@ public class OcrIdentifyController extends JeecgController list= ocrIdentifyService.getSemanticTaskList(); + if (CollectionUtils.isEmpty(list)) { + continue; + } + + //获取相对路径 + List ocr_relative_path = sysDictService.queryDictItemsByCode("ocr_relative_path"); + String relativePath = null; + if (ocr_relative_path != null && ocr_relative_path.size() > 0) { + for (DictModel dictModel : ocr_relative_path) { + if (dictModel.getValue().equals("0")) { + relativePath = dictModel.getText(); + } + } + } + //获取识别的图片 + List fileList=null; + + //临时变量 + List fileUrlList; + String image;//图片 + //执行获取到的任务 + identifyFor: for (OcrIdentify ocrIdentify : list) { + image=null; + fileList=new ArrayList<>(); + //识别的图片路径 + String imageUrl = ocrIdentify.getIdentifyUrl(); + //判断是不是网络图片 + Boolean onlineFile = FileOUtils.isOnlineFile(ocrIdentify.getIdentifyUrl()); + + //最终要请求ocr识别的图片对象 + JSONObject requestBody = new JSONObject(); + if (onlineFile) { + //如果是网络图片,则将图片下载 + image = FileOUtils.downLoadFromUrl(imageUrl, FileOUtils.getFileName(imageUrl), OcrConstant.FILE_DOWNLOAD_URL_PREFIX); + fileList.add(image); + }else{ + //路径下识别到的图片集合 + fileUrlList = FileOUtils.fileLists(relativePath, ocrIdentify.getIdentifyUrl()); + AssertUtils.notNull(fileUrlList, "图片地址不存在"); + for (String fileUrl : fileUrlList) { + //判断附件是否是 图片格式 + if (fileUrl.lastIndexOf(".png") != -1 || fileUrl.lastIndexOf(".jpg") != -1 || fileUrl.lastIndexOf(".jpeg") != -1) { + fileList.add(fileUrl); + } + } + } + + //最终要识别哪些图片 + int i=0; + for (String img : fileList) { + i++; + requestBody.put("task_id", ocrIdentify.getId()+"_"+i); + requestBody.put("img_path", image); + log.info("----------------------请求参数"); + log.info(requestBody.toJSONString()); + try { + log.info("----------------------请求参数"); + log.info(requestBody.toJSONString()); + JSONObject semanticResponseJson = RestUtil.post(OcrConstant.api_test2_identify_url, requestBody); + semanticResponseJson.put("identifyId", ocrIdentify.getId()); + log.info("ocr识别返回数据:"); + log.info(semanticResponseJson.toJSONString()); + ocrIdentifyService.getSemanticInfo(semanticResponseJson); + }catch (Exception e){ + log.error("识别图片失败:"); + SysLog sysLog=new SysLog(); + sysLog.setLogType(2); + sysLog.setLogContent(img+"_识别图片失败:"+e.getMessage()); + sysLog.setOperateType(2); + sysLogService.save(sysLog); + log.error(e.getMessage()); + log.error("正在重试..."); + continue identifyFor; + } + + } + //更改任务状态 + ocrIdentifyService.updateOcrIdentifyStatus(ocrIdentify.getId(), "1"); + } + } + } + } +} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTransInit.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTransInit.java index 47d0b01..df4be2c 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTransInit.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTransInit.java @@ -48,8 +48,9 @@ public class HandleTransInit implements ApplicationRunner { @Override @Async + @Deprecated public void run(ApplicationArguments args) throws UnknownHostException { - if (enableHandleTask) { + if (false) { try { Thread.sleep(5000L); } catch (InterruptedException e) { diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyService.java index 770adba..8d2bbcf 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyService.java @@ -62,4 +62,10 @@ public interface IOcrIdentifyService extends IService { * @param simulateChecksVO */ JSONObject simulateChecks(SimulateChecksVO simulateChecksVO); + + /** + * 获取待执行任务 + * @return + */ + List getSemanticTaskList(); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java index d2140bd..d2c6dfe 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java @@ -10,6 +10,7 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.jeecg.common.api.vo.Result; import org.jeecg.common.constant.OcrConstant; +import org.jeecg.common.util.AssertUtils; import org.jeecg.common.util.RedisUtil; import org.jeecg.common.util.RestUtil; import org.jeecg.modules.ocr.dto.OcrIdentifyDTO; @@ -87,13 +88,8 @@ public class OcrIdentifyServiceImpl extends ServiceImpl updateWrapper = new LambdaUpdateWrapper<>(); updateWrapper.eq(OcrIdentify::getId, id); List identifyDetailList = ocrIdentifyDetailService.listByIdentifyId(id); @@ -1026,6 +1021,15 @@ public class OcrIdentifyServiceImpl extends ServiceImpl getSemanticTaskList() { + LambdaQueryWrapper queryWrapper=new LambdaQueryWrapper<>(); + queryWrapper.in(OcrIdentify::getStatus,0,2); + queryWrapper.orderByDesc(OcrIdentify::getPriority);//优先 加急 1>0 不加急 + queryWrapper.ne(OcrIdentify::getTaskSource,"模拟实验");//不获取模拟实验室的数据 + return this.list(queryWrapper); + } + // 自定义的脱敏方法,对字段进行半脱敏 private String desensitizeText(String text) { StringBuilder sb = new StringBuilder(text); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/TaskService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/TaskService.java index 90931a4..899350a 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/TaskService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/TaskService.java @@ -100,7 +100,7 @@ public class TaskService { } //获取全部任务 - public List getTaskList() { + public List getTaskList(String ss) { String task_0 = (String) redisUtil.get("task_identify_0"); String task_1 = (String) redisUtil.get("task_identify_1"); /*String task_2 = (String) redisUtil.get("task_2"); From 76cfd00bfd159a5d4942d7dbac5c5339226be371 Mon Sep 17 00:00:00 2001 From: zhouwentao <1577701412@qq.com> Date: Wed, 20 Sep 2023 18:40:38 +0800 Subject: [PATCH 11/36] =?UTF-8?q?updates=20=E6=89=A7=E8=A1=8C=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=9A=84=E6=B5=81=E7=A8=8B=E9=80=BB=E8=BE=91=20?= =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/jeecg/modules/ocr/service/impl/TaskService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/TaskService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/TaskService.java index 899350a..90931a4 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/TaskService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/TaskService.java @@ -100,7 +100,7 @@ public class TaskService { } //获取全部任务 - public List getTaskList(String ss) { + public List getTaskList() { String task_0 = (String) redisUtil.get("task_identify_0"); String task_1 = (String) redisUtil.get("task_identify_1"); /*String task_2 = (String) redisUtil.get("task_2"); From 9286533797abc6720b1d7c05f82748b313b030e4 Mon Sep 17 00:00:00 2001 From: zhouwentao <1577701412@qq.com> Date: Wed, 20 Sep 2023 18:44:38 +0800 Subject: [PATCH 12/36] =?UTF-8?q?updates=20=E6=89=A7=E8=A1=8C=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=9A=84=E6=B5=81=E7=A8=8B=E9=80=BB=E8=BE=91=20?= =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java index 9860e70..98add75 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java @@ -113,7 +113,7 @@ public class HandleTaskInit implements ApplicationRunner { for (String img : fileList) { i++; requestBody.put("task_id", ocrIdentify.getId()+"_"+i); - requestBody.put("img_path", image); + requestBody.put("img_path", img); log.info("----------------------请求参数"); log.info(requestBody.toJSONString()); try { From 09fe33ce1e33a086a5c08fd4f6c8266de2f09a92 Mon Sep 17 00:00:00 2001 From: zhouwentao <1577701412@qq.com> Date: Wed, 20 Sep 2023 18:50:08 +0800 Subject: [PATCH 13/36] =?UTF-8?q?updates=20=E6=89=A7=E8=A1=8C=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=9A=84=E6=B5=81=E7=A8=8B=E9=80=BB=E8=BE=91=20?= =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/jeecg/modules/ocr/init/HandleTaskInit.java | 6 ++++++ .../modules/ocr/service/IOcrIdentifyDetailService.java | 2 ++ .../ocr/service/impl/OcrIdentifyDetailServiceImpl.java | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java index 98add75..7f3a3d4 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java @@ -9,6 +9,7 @@ import org.jeecg.common.util.AssertUtils; import org.jeecg.common.util.RestUtil; import org.jeecg.modules.ocr.dto.OcrIdentifyDTO; import org.jeecg.modules.ocr.entity.OcrIdentify; +import org.jeecg.modules.ocr.service.IOcrIdentifyDetailService; import org.jeecg.modules.ocr.service.IOcrIdentifyService; import org.jeecg.modules.ocr.service.impl.TaskService; import org.jeecg.modules.ocr.utils.FileOUtils; @@ -36,6 +37,8 @@ public class HandleTaskInit implements ApplicationRunner { @Resource IOcrIdentifyService ocrIdentifyService; @Resource + IOcrIdentifyDetailService ocrIdentifyDetailService; + @Resource TaskService taskService; @Resource private ISysDictService sysDictService; @@ -90,6 +93,9 @@ public class HandleTaskInit implements ApplicationRunner { //判断是不是网络图片 Boolean onlineFile = FileOUtils.isOnlineFile(ocrIdentify.getIdentifyUrl()); + //把过去执行过的明细给删掉 + ocrIdentifyDetailService.deleteByOcrIdentifyId(ocrIdentify.getId()); + //最终要请求ocr识别的图片对象 JSONObject requestBody = new JSONObject(); if (onlineFile) { diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyDetailService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyDetailService.java index 09eb3fa..956fda9 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyDetailService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyDetailService.java @@ -18,4 +18,6 @@ public interface IOcrIdentifyDetailService extends IService { * @return */ List listByIdentifyId(String identifyId); + + boolean deleteByOcrIdentifyId(String id); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyDetailServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyDetailServiceImpl.java index 51e7e7a..5ae3439 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyDetailServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyDetailServiceImpl.java @@ -23,4 +23,11 @@ public class OcrIdentifyDetailServiceImpl extends ServiceImpl list = super.list(new LambdaQueryWrapper().eq(OcrIdentifyDetail::getIdentifyId, identifyId)); return list; } + + @Override + public boolean deleteByOcrIdentifyId(String identifyId) { + LambdaQueryWrapper queryWrapper=new LambdaQueryWrapper<>(); + queryWrapper.eq(OcrIdentifyDetail::getIdentifyId,identifyId); + return this.remove(queryWrapper); + } } From 96573a1c92c8ab67d9cd9692f88a4ca03b5dcf20 Mon Sep 17 00:00:00 2001 From: zhouwentao <1577701412@qq.com> Date: Wed, 20 Sep 2023 18:58:29 +0800 Subject: [PATCH 14/36] =?UTF-8?q?updates=20=E4=BC=98=E5=8C=96=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E4=BB=BB=E5=8A=A1=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/jeecg/modules/ocr/init/HandleTaskInit.java | 3 +++ .../jeecg/modules/ocr/service/IOcrIdentifyService.java | 6 ++++++ .../modules/ocr/service/impl/OcrIdentifyServiceImpl.java | 9 +++++++++ 3 files changed, 18 insertions(+) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java index 7f3a3d4..1c2459b 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java @@ -96,6 +96,9 @@ public class HandleTaskInit implements ApplicationRunner { //把过去执行过的明细给删掉 ocrIdentifyDetailService.deleteByOcrIdentifyId(ocrIdentify.getId()); + //更新开始时间 + ocrIdentifyService.updateMasterTaskStartTime(ocrIdentify.getId()); + //最终要请求ocr识别的图片对象 JSONObject requestBody = new JSONObject(); if (onlineFile) { diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyService.java index 8d2bbcf..e24e383 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyService.java @@ -49,6 +49,12 @@ public interface IOcrIdentifyService extends IService { */ Result pushTask(JSONObject jsonObject); + /** + * 更新任务的开始识别时间 + */ + void updateOcrIdentifyStartTime(String id); + + @Deprecated void updateMasterTaskStartTime(String id); /** diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java index d2c6dfe..1f132e3 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java @@ -656,6 +656,15 @@ public class OcrIdentifyServiceImpl extends ServiceImpl updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.set(OcrIdentify::getStartTime, new Date()); + updateWrapper.set(OcrIdentify::getEndTime,null); + updateWrapper.eq(OcrIdentify::getId, id); + super.update(updateWrapper); + } + @Override public void updateMasterTaskStartTime(String id) { LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); From eb50805c864a4b0dc669fcd02c3bc5ea8dc00af1 Mon Sep 17 00:00:00 2001 From: DELL Date: Wed, 20 Sep 2023 21:28:29 +0800 Subject: [PATCH 15/36] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=96=B9=E6=B3=95?= =?UTF-8?q?=EF=BC=9A=E8=AE=A1=E7=AE=97=E6=9C=80=E8=BF=91=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4=E5=B7=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/api/controller/ApiController.java | 3 +++ .../ocr/controller/OcrIdentifyController.java | 2 ++ .../ocr/service/IOcrIdentifyService.java | 7 +++++++ .../service/impl/OcrIdentifyServiceImpl.java | 21 ++++++++++++++++--- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java index 6d03744..208e7ab 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java @@ -3,6 +3,7 @@ package org.jeecg.modules.api.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.ApiOperation; @@ -34,6 +35,7 @@ import javax.annotation.Resource; import java.awt.*; import java.io.File; import java.util.ArrayList; +import java.util.Date; import java.util.List; /** @@ -71,6 +73,7 @@ public class ApiController { } //1.获取请求参数 String taskName = requestBody.getString("taskName"); + AssertUtils.notTrue(ocrIdentifyService.calculateTimeDifference(taskName)<=10,"[任务名称]-"+taskName+" 短时间内已存在,不可再次请求"); String requestId = requestBody.getString("requestId");//请求唯一标识 String scenes = requestBody.getString("scenes");//场景类型:door=门头照片,cases=病例,bill=票据 String ruleId = requestBody.getString("ruleId");//规则标识 diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyController.java index 70e8439..c14aeaf 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyController.java @@ -153,6 +153,7 @@ public class OcrIdentifyController extends JeecgController { * @return */ List getSemanticTaskList(); + + + /** + * 新增方法:计算最近任务创建时间差 + * @return + */ + long calculateTimeDifference(String taskName); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java index 1f132e3..289ac1d 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java @@ -3,6 +3,7 @@ package org.jeecg.modules.ocr.service.impl; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.extern.slf4j.Slf4j; @@ -62,6 +63,8 @@ public class OcrIdentifyServiceImpl extends ServiceImpl updateWrapper = new LambdaUpdateWrapper(); @@ -426,7 +428,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl identifyDetailList = ocrIdentifyDetailService.listByIdentifyId(ocrIdentifyId); ocrIdentifyCallbackLog.setStartTime(date); boolean b = CallBackWlyUtils.callbackWly(ocrIdentify, identifyDetailList); - ocrIdentifyCallbackLog.setStatus(b?1:0); + ocrIdentifyCallbackLog.setStatus(b?1:0);//0-失败,1-成功 ocrIdentifyCallbackLog.setEndTime(new Date()); ocrIdentifyCallbackLogService.save(ocrIdentifyCallbackLog); if (b) { @@ -903,7 +905,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("taskName", taskName).orderByDesc("createTime").last("LIMIT 1"); + OcrIdentify lastIdentify = ocrIdentifyService.getOne(queryWrapper); + if (lastIdentify != null) { + Date lastCreateTime = lastIdentify.getCreateTime(); + Date currentTime = new Date(); + return (currentTime.getTime() - lastCreateTime.getTime()) / 1000; + } + return 11; // 如果没有找到数据,返回默认值 + } + } From d092e9c4186618e3f38054ce310271f7594d7bf8 Mon Sep 17 00:00:00 2001 From: DELL Date: Wed, 20 Sep 2023 21:53:32 +0800 Subject: [PATCH 16/36] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=96=B9=E6=B3=95?= =?UTF-8?q?=EF=BC=9A=E8=AE=A1=E7=AE=97=E6=9C=80=E8=BF=91=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4=E5=B7=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/ocr/service/impl/OcrIdentifyServiceImpl.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java index 289ac1d..736b417 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java @@ -63,8 +63,6 @@ public class OcrIdentifyServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); queryWrapper.eq("taskName", taskName).orderByDesc("createTime").last("LIMIT 1"); - OcrIdentify lastIdentify = ocrIdentifyService.getOne(queryWrapper); + OcrIdentify lastIdentify = this.getOne(queryWrapper); if (lastIdentify != null) { Date lastCreateTime = lastIdentify.getCreateTime(); Date currentTime = new Date(); From 41e3ab829d9dde044c34ba3e52bb8ce2cab45a18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E5=90=91=E6=96=8C?= <574110378@qq.com> Date: Thu, 21 Sep 2023 15:55:58 +0800 Subject: [PATCH 17/36] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeecg-system-start/src/main/resources/application-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jeecg-module-system/jeecg-system-start/src/main/resources/application-test.yml b/jeecg-module-system/jeecg-system-start/src/main/resources/application-test.yml index 57b3751..9fea26c 100644 --- a/jeecg-module-system/jeecg-system-start/src/main/resources/application-test.yml +++ b/jeecg-module-system/jeecg-system-start/src/main/resources/application-test.yml @@ -131,7 +131,7 @@ spring: connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 datasource: master: - url: jdbc:mysql://47.103.213.109:3306/ocr?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai + url: jdbc:mysql://127.0.0.1:3306/ocr?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai username: root password: Wang5322570.. driver-class-name: com.mysql.cj.jdbc.Driver From d07f666e6411fdbc2d18aad366fbdf203cef7f2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E5=90=91=E6=96=8C?= <574110378@qq.com> Date: Thu, 21 Sep 2023 16:12:28 +0800 Subject: [PATCH 18/36] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/ocr/service/impl/OcrIdentifyServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java index 736b417..2062e4b 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java @@ -1223,8 +1223,8 @@ public class OcrIdentifyServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("taskName", taskName).orderByDesc("createTime").last("LIMIT 1"); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(OcrIdentify::getTaskName, taskName).orderByDesc(OcrIdentify::getCreateTime).last("LIMIT 1"); OcrIdentify lastIdentify = this.getOne(queryWrapper); if (lastIdentify != null) { Date lastCreateTime = lastIdentify.getCreateTime(); From e2893a2fd751c304fa9122a42a0c650cbd027787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E5=90=91=E6=96=8C?= <574110378@qq.com> Date: Thu, 21 Sep 2023 16:43:17 +0800 Subject: [PATCH 19/36] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ocr/controller/OcrIdentifyDetailController.java | 10 ++++++---- .../ocr/service/impl/OcrIdentifyServiceImpl.java | 9 ++++++--- .../modules/system/controller/CommonController.java | 4 +++- .../src/main/resources/application-dev.yml | 3 ++- .../src/main/resources/application-prod.yml | 3 ++- .../src/main/resources/application-test.yml | 7 ++++--- 6 files changed, 23 insertions(+), 13 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyDetailController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyDetailController.java index 813774f..dbce764 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyDetailController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyDetailController.java @@ -41,6 +41,8 @@ public class OcrIdentifyDetailController extends JeecgController ocrResultDTOList, String fieldName, String field, String inputText, String ocrText, Double ocrPrecisionRate, String imgPath, String failureReason, Boolean ruleValidation, Double d, String ruleValidationValue) { + public void ocrResultAdd(List ocrResultDTOList, String fieldName, String field, String inputText, String ocrText, Double ocrPrecisionRate, String imgPath, String failureReason, Boolean ruleValidation, Double d, String ruleValidationValue) { OcrResultDTO ocrResultDTO = new OcrResultDTO(); ocrResultDTO.setTag(field); ocrResultDTO.setTagName(fieldName); @@ -471,7 +474,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl ocrResultDTOList, String fieldName, String field, String inputText, String ocrText, Double ocrPrecisionRate, String imgPath, String failureReason, Boolean ruleValidation, String ruleValidationValue) { + public void ocrResultAdd(List ocrResultDTOList, String fieldName, String field, String inputText, String ocrText, Double ocrPrecisionRate, String imgPath, String failureReason, Boolean ruleValidation, String ruleValidationValue) { if (ruleValidation) { ocrResultAdd(ocrResultDTOList, fieldName, field, inputText, ocrText, ocrPrecisionRate, imgPath, failureReason, ruleValidation, 100d,ruleValidationValue); } else { diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java index e60373a..1352920 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java @@ -51,6 +51,8 @@ public class CommonController { */ @Value(value="${jeecg.uploadType}") private String uploadType; + @Value("${system.project.fileReviewUrlPrefix") + private String fileReviewUrlPrefix; /** * @Author 政辉 @@ -120,7 +122,7 @@ public class CommonController { if(oConvertUtils.isNotEmpty(savePath)){ /*result.setMessage(savePath); result.setSuccess(true);*/ - return Result.OK(savePath, OcrConstant.FILE_REVIEW_URL_PREFIX+uploadpath+"/"+savePath); + return Result.OK(savePath, fileReviewUrlPrefix+uploadpath+"/"+savePath); }else { result.setMessage("上传失败!"); result.setSuccess(false); diff --git a/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml b/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml index b7af88c..fc82474 100644 --- a/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml +++ b/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml @@ -299,4 +299,5 @@ third-app: system: project: env: customer_test - enableHandleTask: false \ No newline at end of file + enableHandleTask: false + fileReviewUrlPrefix: http://47.103.213.109:8072/files \ No newline at end of file diff --git a/jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml b/jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml index 0f6f5fe..50a8d0e 100644 --- a/jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml +++ b/jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml @@ -303,4 +303,5 @@ third-app: agent-id: ?? system: project: - env: customer_prod \ No newline at end of file + env: customer_prod + fileReviewUrlPrefix: http://47.103.213.109:8072/files \ No newline at end of file diff --git a/jeecg-module-system/jeecg-system-start/src/main/resources/application-test.yml b/jeecg-module-system/jeecg-system-start/src/main/resources/application-test.yml index 9fea26c..adbf4df 100644 --- a/jeecg-module-system/jeecg-system-start/src/main/resources/application-test.yml +++ b/jeecg-module-system/jeecg-system-start/src/main/resources/application-test.yml @@ -148,8 +148,8 @@ spring: #redis 配置 redis: database: 3 - #host: 127.0.0.1 - host: 47.103.213.109 + host: 127.0.0.1 +# host: 47.103.213.109 port: 6379 password: '' #mybatis plus 设置 @@ -300,4 +300,5 @@ third-app: system: project: env: customer_test - enableHandleTask: true \ No newline at end of file + enableHandleTask: true + fileReviewUrlPrefix: http://172.16.0.132:8072/files \ No newline at end of file From fcdf01600b2cd3b08348c835636c9c649216da2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E5=90=91=E6=96=8C?= <574110378@qq.com> Date: Thu, 21 Sep 2023 17:00:21 +0800 Subject: [PATCH 20/36] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/ocr/controller/OcrIdentifyDetailController.java | 2 +- .../jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java | 2 +- .../org/jeecg/modules/system/controller/CommonController.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyDetailController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyDetailController.java index dbce764..551fd08 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyDetailController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyDetailController.java @@ -41,7 +41,7 @@ public class OcrIdentifyDetailController extends JeecgController Date: Thu, 21 Sep 2023 17:11:03 +0800 Subject: [PATCH 21/36] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeecg-system-start/src/main/resources/application-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jeecg-module-system/jeecg-system-start/src/main/resources/application-test.yml b/jeecg-module-system/jeecg-system-start/src/main/resources/application-test.yml index adbf4df..4840223 100644 --- a/jeecg-module-system/jeecg-system-start/src/main/resources/application-test.yml +++ b/jeecg-module-system/jeecg-system-start/src/main/resources/application-test.yml @@ -301,4 +301,4 @@ system: project: env: customer_test enableHandleTask: true - fileReviewUrlPrefix: http://172.16.0.132:8072/files \ No newline at end of file + fileReviewUrlPrefix: http://172.16.0.132:8071/files \ No newline at end of file From 6cfced5860b69513c5a84318b0514d4eb0e2c7e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E5=90=91=E6=96=8C?= <574110378@qq.com> Date: Fri, 22 Sep 2023 15:50:37 +0800 Subject: [PATCH 22/36] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/api/controller/ApiController.java | 6 +- .../ocr/controller/OcrIdentifyController.java | 6 +- .../controller/OcrSimulatorController.java | 17 +- .../modules/ocr/dto/OcrRuleCheckDTO.java | 2 +- .../modules/ocr/init/HandleCallbacklnit.java | 4 + .../ocr/service/IOcrIdentifyService.java | 2 + .../ocr/service/IOcrRuleCheckService.java | 1 + .../service/impl/OcrIdentifyServiceImpl.java | 400 ++++++++++++++++++ .../service/impl/OcrRuleCheckServiceImpl.java | 197 ++++++++- .../modules/ocr/utils/CallBackWlyUtils.java | 2 + .../modules/system/util/RandImageUtil.java | 6 + 11 files changed, 618 insertions(+), 25 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java index 208e7ab..fb26250 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java @@ -65,9 +65,9 @@ public class ApiController { @Transactional @ResponseBody public Result pushSemantic(@RequestBody JSONObject requestBody) throws InterruptedException { - if (!"test".equals(profiles)) { - return Result.error("当前环境不支持该功能,请访问测试环境"); - } +// if (!"test".equals(profiles)) { +// return Result.error("当前环境不支持该功能,请访问测试环境"); +// } if (requestBody == null) { return Result.error("请输入请求参数"); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyController.java index c14aeaf..1ca4b29 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyController.java @@ -149,9 +149,9 @@ public class OcrIdentifyController extends JeecgController add(@RequestBody OcrIdentify ocrIdentify) { - if (!"test".equals(profiles)) { - return Result.error("当前环境不支持该功能,请访问测试环境"); - } +// if (!"test".equals(profiles)) { +// return Result.error("当前环境不支持该功能,请访问测试环境"); +// } AssertUtils.notEmpty(ocrIdentify.getTaskName(), "[任务名称]-不可为空"); AssertUtils.notTrue(ocrIdentifyService.calculateTimeDifference(ocrIdentify.getTaskName())<=10,"[任务名称]-"+ocrIdentify.getTaskName()+" 短时间内已存在,不可再次请求"); AssertUtils.notEmpty(ocrIdentify.getIdentifyUrl(), "[识别路径]不可为空"); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrSimulatorController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrSimulatorController.java index 895b0b9..727a0f4 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrSimulatorController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrSimulatorController.java @@ -51,9 +51,9 @@ public class OcrSimulatorController{ @ApiOperation(value = "场景识别") @PostMapping(value = "/identify") public Result identify(@RequestBody JSONObject requestBody) { - if (!"test".equals(profiles)) { - return Result.error("当前环境不支持该功能,请访问测试环境"); - } +// if (!"test".equals(profiles)) { +// return Result.error("当前环境不支持该功能,请访问测试环境"); +// } JSONObject responseBody = new JSONObject(); JSONArray images = requestBody.getJSONArray("images"); AssertUtils.hasSize(images,"请先上传图片"); @@ -115,5 +115,14 @@ public class OcrSimulatorController{ AssertUtils.hasSize(identifyDetailIdList,"请先上传图片"); return Result.OK(ocrIdentifyService.simulateChecks(simulateChecksVO)); } - + @ApiOperation(value = "模拟检查G") + @PostMapping(value = "/simulateChecksV01") + public Result simulateChecksV01(@RequestBody SimulateChecksVO simulateChecksVO) { + //规则检查配置id + String ruleCheckId = simulateChecksVO.getRuleCheckId(); + List identifyDetailIdList = simulateChecksVO.getIdentifyDetailIdList(); + AssertUtils.notEmpty(ruleCheckId, "请选择[规则扫描器]"); + AssertUtils.hasSize(identifyDetailIdList,"请先上传图片"); + return Result.OK(ocrIdentifyService.simulateChecksV01(simulateChecksVO)); + } } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/dto/OcrRuleCheckDTO.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/dto/OcrRuleCheckDTO.java index d030bd5..66ee45b 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/dto/OcrRuleCheckDTO.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/dto/OcrRuleCheckDTO.java @@ -22,7 +22,7 @@ public class OcrRuleCheckDTO extends OcrRuleCheck { @ApiModelProperty(value = "元数据配置名称") @Excel(name = "元数据配置名称", width = 15) private String metadataConfigName; - + private String configRuleAdapter; private Map configRuleMap=new LinkedHashMap<>(); private Map fieldMap=new LinkedHashMap<>(); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleCallbacklnit.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleCallbacklnit.java index 6b3ef7d..c4cba36 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleCallbacklnit.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleCallbacklnit.java @@ -70,9 +70,13 @@ public class HandleCallbacklnit implements ApplicationRunner { e.printStackTrace(); } List ocrIdentifyList = ocrIdentifyService.findNeNoticeList(autoPushNoticeMaxNum); + log.info("待回调任务:{}",ocrIdentifyList.size()); + log.info("待回调任务:{}",ocrIdentifyList); for (OcrIdentify ocrIdentify : ocrIdentifyList) { try { + log.info("回调:{}",ocrIdentify); ocrIdentifyService.callbackWly(ocrIdentify.getId()); + log.info("回调结束:{}",ocrIdentify); Thread.sleep(pushTimeInterval*1000); } catch (InterruptedException e) { log.error(e.getMessage()); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyService.java index 9c5abab..3f4a948 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyService.java @@ -81,4 +81,6 @@ public interface IOcrIdentifyService extends IService { * @return */ long calculateTimeDifference(String taskName); + + JSONObject simulateChecksV01(SimulateChecksVO simulateChecksVO); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrRuleCheckService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrRuleCheckService.java index 28a82c2..e340c86 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrRuleCheckService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrRuleCheckService.java @@ -78,4 +78,5 @@ public interface IOcrRuleCheckService extends IService { boolean copy(OcrRuleCheck ocrRuleCheck); + OcrRuleCheckDTO findByIdV01(String ruleCheckId); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java index 5c999bd..db68725 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java @@ -428,7 +428,9 @@ public class OcrIdentifyServiceImpl extends ServiceImpl identifyDetailList = ocrIdentifyDetailService.listByIdentifyId(ocrIdentifyId); ocrIdentifyCallbackLog.setStartTime(date); + log.info("执行CallBackWlyUtils.callbackWly({}, {})",ocrIdentify,identifyDetailList); boolean b = CallBackWlyUtils.callbackWly(ocrIdentify, identifyDetailList); + log.info("执行CallBackWlyUtils.callbackWly 结束",ocrIdentify,identifyDetailList); ocrIdentifyCallbackLog.setStatus(b?1:0);//0-失败,1-成功 ocrIdentifyCallbackLog.setEndTime(new Date()); ocrIdentifyCallbackLogService.save(ocrIdentifyCallbackLog); @@ -510,6 +512,38 @@ public class OcrIdentifyServiceImpl extends ServiceImpl ocrResultDTOList, String fieldName, String field, String inputText, String ocrText, Double ocrPrecisionRate, String imgPath, String failureReason, Boolean ruleValidation, Double d) { + OcrResultDTO ocrResultDTO = new OcrResultDTO(); + ocrResultDTO.setTag(field); + ocrResultDTO.setTagName(fieldName); + ocrResultDTO.setOcrText(ocrText); + ocrResultDTO.setInputText(inputText); + ocrResultDTO.setOcrPrecisionRate(ocrPrecisionRate == null ? 0d : ocrPrecisionRate); + if (d == null) { + ocrResultDTO.setTextRate(0d); + } else { + ocrResultDTO.setTextRate(new BigDecimal(d).setScale(2, RoundingMode.HALF_UP).doubleValue()); + } + /*System.out.println("-----------------"); + System.out.println(failureReason); + System.out.println("-----------------");*/ + if (StringUtils.isNotBlank(imgPath)) { + SourceImage sourceImage = new SourceImage(); + sourceImage.setPath(imgPath); + int i = imgPath.lastIndexOf("/"); + sourceImage.setFileName(imgPath.substring(i + 1, imgPath.length())); + sourceImage.setPreviewUrl(OcrConstant.FILE_REVIEW_URL_PREFIX+imgPath); + ocrResultDTO.setSourceImage(sourceImage); + } + ocrResultDTO.setFailureReason(failureReason); + if (ocrResultDTOList == null) { + ocrResultDTOList = new ArrayList<>(); + } + ocrResultDTOList.add(ocrResultDTO); + } /** * 组装 checkSemanticModelMap @@ -1042,6 +1076,372 @@ public class OcrIdentifyServiceImpl extends ServiceImpl identifyDetailList = ocrIdentifyDetailService.listByIds(simulateChecksVO.getIdentifyDetailIdList()); + System.out.println("1111111111111111111111111111111"); + //遍历任务,做匹配 + int i1=1; + //用于数据结构化的对象 + List ocrResultDTOList = new ArrayList<>(); + Date startDataCheckTime = new Date(); + Map fieldRightMap = new LinkedHashMap<>();//存放 字段判断正确map + for (OcrIdentifyDetail ocrIdentifyDetail : identifyDetailList) { + i1++; + String semanticResultJson = ocrIdentifyDetail.getSemanticResult(); + String imgPath = ocrIdentifyDetail.getImageUrl(); + if (StringUtils.isBlank(semanticResultJson)) {continue;} + String doctorName = simulateChecksVO.getDoctorName(); + String hospitalName = simulateChecksVO.getHospitalName(); + String departmentName = simulateChecksVO.getDepartmentName(); + String time = simulateChecksVO.getTime(); + List sourceJson = new ArrayList<>(); + if (StringUtils.isNotBlank(doctorName)) { + sourceJson.add(JSONObject.parseObject(String.format("{\"tag\":\"doctorName\", \"inputText\":\"%s\"}", doctorName))); + } + if (StringUtils.isNotBlank(hospitalName)) { + sourceJson.add(JSONObject.parseObject(String.format("{\"tag\":\"hospitalName\", \"inputText\":\"%s\"}", hospitalName))); + } + if (StringUtils.isNotBlank(departmentName)) { + sourceJson.add(JSONObject.parseObject(String.format("{\"tag\":\"departmentName\", \"inputText\":\"%s\"}", departmentName))); + } + if (StringUtils.isNotBlank(time)) { + sourceJson.add(JSONObject.parseObject(String.format("{\"tag\":\"time\", \"inputText\":\"%s\"}", time))); + } + JSONObject semanticResult = JSONObject.parseObject(ocrIdentifyDetail.getSemanticResult()); + + //判断是不是网络图片 + Boolean onlineFile = FileOUtils.isOnlineFile(imgPath); + if (onlineFile) { + //如果是网络图片,则将图片下载 + imgPath = FileOUtils.downLoadFromUrl(imgPath, FileOUtils.getFileName(imgPath), OcrConstant.FILE_DOWNLOAD_URL_PREFIX); + } + + File file = new File(imgPath); + //当原图片存在时. + if (file.exists()) { + int i = imgPath.lastIndexOf("/"); + //压缩图片 + /*if (true) { + String fileUrl = "/data/ocrImage/thumbnail" + imgPath.substring(0, i); + //判断新目录是否存在,不存在则新建 + FileOUtils.folderCreate(fileUrl); + String outputImagePath = fileUrl + imgPath.substring(i + 1, imgPath.length()); + File thumbnailFile = new File(outputImagePath); + //如果上次生成过缩率图,就不生成了 + if (!thumbnailFile.exists()) { + ImageUtils.compressImage(file.getAbsolutePath(), outputImagePath, 0.3f, 0.3f); + } + ocrIdentifyDetail.setThumbnailImageUrl(outputImagePath); + }*/ + //============================绘制虚线 + JSONObject semanticResult2 = semanticResult.getJSONObject("semantic_result"); + String fileUrl = "/data/ocrImage/drawDashed" + imgPath.substring(0, i); + //判断新目录是否存在,不存在则新建 + FileOUtils.folderCreate(fileUrl); + String outputImagePath = fileUrl + imgPath.substring(i + 1, imgPath.length()); + if (semanticResult2!=null) { + List> resultToPoints = ImageUtils.semanticResultToPoints(semanticResult2); + boolean hasPoints=true; + if (CollectionUtils.isNotEmpty(resultToPoints)) { + for (List resultToPoint : resultToPoints) { + if (CollectionUtils.isEmpty(resultToPoint)) { + hasPoints=false; + } + } + if (hasPoints){ + ImageUtils.drawDashedRectangleOnImages(file.getAbsolutePath(), resultToPoints, outputImagePath,"green"); + imgPath = outputImagePath; + } + } + } + //============================ + } + + OcrRuleCheckDTO ocrRuleCheckVo = ocrRuleCheckService.findByIdV01(simulateChecksVO.getRuleCheckId()); +// Map checkSemanticModelMap = getCheckSemanticModelMapV0(ocrRuleCheckVo.getConfigRule(), ocrRuleCheckVo.getFieldMap(), sourceJson); + String text = null;//ocr 识别的文本 + Double probability = 0d; + StringBuilder rMessage = new StringBuilder(); + //========================== + for (String key : ocrRuleCheckVo.getFieldMap().keySet()) { + CheckSemanticModel checkSemanticModel=new CheckSemanticModel(); + for(JSONObject jsonObject:sourceJson){ + Object tag = jsonObject.get("tag"); + if(tag.equals(key)){ + checkSemanticModel.setField(key); + checkSemanticModel.setFieldName(ocrRuleCheckVo.getFieldMap().get(key)); + checkSemanticModel.setInputText(jsonObject.getString("inputText")); + } + } + String field = key;//字段 name. + String fieldName = checkSemanticModel.getFieldName();//校验的字段名称 +// String ruleInfo = value.getRuleInfo();//是否绝对判断 0-绝对判断,1-不绝对判断 + String inputText = checkSemanticModel.getInputText();//校验文本 ,ocr识别的文本如果不包含该内容,则算作失败 + if (StringUtils.isBlank(fieldName)) { + continue; + } + List fieldNameList = Arrays.asList(fieldName.split(",")); + text = null; + //boolean b = ArrayOUtils.containsStringList(fieldNameList, new ArrayList<>(semanticResult.getJSONObject("semantic_result").keySet())); + //查看ocr识别返回的字段名称中是否有当前这个字段名称 + //TODO 注意,ocr 识别返回的 字段是多个结果(数组),有一个值匹配上即为正确 + List ocrArray = new ArrayList<>(); + for (String s : fieldNameList) { + JSONArray jsonArray = new JSONArray(); + if (Arrays.asList("医生名称","姓名","医生").contains(s)) { + for (String s1 : Arrays.asList("医生名称", "姓名", "医生")) { + JSONArray semantic_result = semanticResult.getJSONObject("semantic_result").getJSONArray(s1); + if (CollectionUtils.isNotEmpty(semantic_result)) { + jsonArray.addAll(semantic_result); + break; + } + } + }else if (Arrays.asList("科室名称","科室").contains(s)) { + for (String s1 : Arrays.asList("科室名称","科室")) { + JSONArray semantic_result = semanticResult.getJSONObject("semantic_result").getJSONArray(s1); + if (CollectionUtils.isNotEmpty(semantic_result)) { + jsonArray.addAll(semantic_result); + break; + } + } + }else if (Arrays.asList("医院名称","医院").contains(s)) { + for (String s1 : Arrays.asList("医院名称", "医院")) { + JSONArray semantic_result = semanticResult.getJSONObject("semantic_result").getJSONArray(s1); + if (CollectionUtils.isNotEmpty(semantic_result)) { + jsonArray.addAll(semantic_result); + break; + } + } + }else if (Arrays.asList("日期", "时间").contains(s)) { + for (String s1 : Arrays.asList("日期", "时间")) { + JSONArray semantic_result = semanticResult.getJSONObject("semantic_result").getJSONArray(s1); + if (CollectionUtils.isNotEmpty(semantic_result)) { + jsonArray.addAll(semantic_result); + break; + } + } + }else if (Arrays.asList("患者姓名","患者").contains(s)) { + for (String s1 : Arrays.asList("患者姓名","患者")) { + JSONArray semantic_result = semanticResult.getJSONObject("semantic_result").getJSONArray(s1); + if (CollectionUtils.isNotEmpty(semantic_result)) { + jsonArray.addAll(semantic_result); + break; + } + } + }else if (Arrays.asList("病历号").contains(s)) { + for (String s1 : Arrays.asList("病历号")) { + JSONArray semantic_result = semanticResult.getJSONObject("semantic_result").getJSONArray(s1); + if (CollectionUtils.isNotEmpty(semantic_result)) { + jsonArray.addAll(semantic_result); + break; + } + } + }else if (Arrays.asList("入院日期").contains(s)) { + for (String s1 : Arrays.asList("入院日期")) { + JSONArray semantic_result = semanticResult.getJSONObject("semantic_result").getJSONArray(s1); + if (CollectionUtils.isNotEmpty(semantic_result)) { + jsonArray.addAll(semantic_result); + break; + } + } + }else if (Arrays.asList("出生日期").contains(s)) { + for (String s1 : Arrays.asList("出生日期")) { + JSONArray semantic_result = semanticResult.getJSONObject("semantic_result").getJSONArray(s1); + if (CollectionUtils.isNotEmpty(semantic_result)) { + jsonArray.addAll(semantic_result); + break; + } + } + }else if (Arrays.asList("年龄").contains(s)) { + for (String s1 : Arrays.asList("年龄")) { + JSONArray semantic_result = semanticResult.getJSONObject("semantic_result").getJSONArray(s1); + if (CollectionUtils.isNotEmpty(semantic_result)) { + jsonArray.addAll(semantic_result); + break; + } + } + }else{ + jsonArray = semanticResult.getJSONObject("semantic_result").getJSONArray(s); + } + + if (jsonArray != null && jsonArray.size() > 0) { + ocrArray.addAll(jsonArray.toJavaList(JSONObject.class)); + } + } + if (ocrArray.size() > 0) { + for (JSONObject ocrItem : ocrArray) { + text = ocrItem.getString("text");//ocr 识别的文本 + probability = ocrItem.getDouble("probability");//置信度 + double v = StrCharUtil.similarityRatio(inputText, text); + this.ocrResultAddV01(ocrResultDTOList, checkSemanticModel.getFieldName(), field, inputText, text, probability, imgPath, checkSemanticModel.getFieldName() + "参数未获取到结果", false,v); + } + } + + } + } + Date overDataCheckTime = new Date(); + + JSONObject responseBody=new JSONObject(); + + //OCR和NlU执行时间总和(秒) + double ocrAndNluTimeSum = identifyDetailList.stream().mapToDouble(i -> (i.getOcrTime() == null ? 0 : i.getOcrTime()) + (i.getNluTime() == null ? 0 : i.getNluTime())).sum(); + //执行时间(毫秒) + double dataStructuredTime = new BigDecimal(overDataCheckTime.getTime() - startDataCheckTime.getTime()).setScale(2, RoundingMode.HALF_UP).doubleValue(); + double executionTime = new BigDecimal(ocrAndNluTimeSum+(dataStructuredTime/1000)).setScale(2, RoundingMode.HALF_UP).doubleValue(); + responseBody.put("dataStructuredTime",dataStructuredTime); + responseBody.put("allExecutionTime",executionTime); + + //=========排序 + if (CollectionUtils.isNotEmpty(ocrResultDTOList)) { + ocrResultDTOList.sort((h1, h2) -> h1.getTag().compareTo(h2.getTag())); + } + //============ + if (CollectionUtils.isEmpty(ocrResultDTOList)) { + //没有匹配结果 + responseBody.put("taskResult",1); + }else{ + long count = fieldRightMap.values().stream().filter(o->!o).count(); + //long count = ocrResultDTOList.stream().filter(o -> !o.getRuleValidation()).count(); + responseBody.put("taskResult",count>0?0:1);//匹配成功或失败 + Set haveRateTagList = ocrResultDTOList.stream().filter(o -> o.getTextRate() > 0).map(OcrResultDTO::getTag).collect(Collectors.toSet()); + List newResultDTOList=new ArrayList<>(); + //过滤掉0的值 + + for (OcrResultDTO o : ocrResultDTOList) { + if (haveRateTagList.contains(o.getTag())) { + if (o.getTextRate()>0) { + newResultDTOList.add(o); + } + }else{ + newResultDTOList.add(o); + } + //脱敏处理 + String tagName = o.getTagName(); + String ocrText = o.getOcrText(); + StringBuilder sb = new StringBuilder(); + if ("患者姓名".equals(tagName)) { + // 保留第一个字,其余用 "*" 替代 + int length = Math.max(0, ocrText.length() - 1); + for (int i = 0; i < length; i++) { + sb.append("*"); + } + String desensitizedText = ocrText.substring(0, 1) + sb.toString(); + o.setOcrText(desensitizedText); + } + if ("联系方式".equals(tagName) || "身份证号".equals(tagName)){ + String desensitizedText = desensitizeText(ocrText); // 自定义的脱敏方法 + // 更新脱敏后的值 + o.setOcrText(desensitizedText); + } + if ("家庭住址".equals(tagName) || "工作地址".equals(tagName) || "病情陈述人".equals(tagName) + || "户籍地".equals(tagName)){ + + sb.append(ocrText.charAt(0)); + for (int i = 1; i < ocrText.length() - 1; i++) { + sb.append("*"); + } + sb.append(ocrText.charAt(ocrText.length() - 1)); + String desensitizedText= sb.toString(); + o.setOcrText(desensitizedText); + } + } + ocrResultDTOList = newResultDTOList; + } + //获取最小 + double min = 0d; + //获取最大 + double max = 0d; + if (CollectionUtils.isNotEmpty(ocrResultDTOList)) { + min = ocrResultDTOList.stream().mapToDouble(OcrResultDTO::getTextRate).min().getAsDouble(); + max = ocrResultDTOList.stream().mapToDouble(OcrResultDTO::getTextRate).max().getAsDouble(); + } + responseBody.put("min",min); + responseBody.put("max",max); + responseBody.put("detailList", ocrResultDTOList); + return responseBody; + } + + private Map getCheckSemanticModelMapV0(String configRule, Map fieldMap, List sourceJson) { + if (configRule!=null) { + String[] split = configRule.split("&"); + //将 configRuleMap的 key 创建一个Set +// Set keySet = new HashSet<>(configRuleMap.keySet()); +// //循环keySet,判断字段是否是缩写,如果是缩写就把缩写的全称put一下 +// for (String s : keySet) { +// String value = configRuleMap.get(s); +// if ("hn".equals(s)) { +// configRuleMap.put("hospitalName",value); +// }else if("dn".equals(s)) { +// configRuleMap.put("doctorName", value); +// }else if("dmn".equals(s)) { +// configRuleMap.put("departmentName", value); +// }else if("tm".equals(s) || ("time".equals(s))) { +// configRuleMap.put("time", value); +// }else{ +// configRuleMap.put(s,value); +// } +// } + } + + Map checkSemanticModelMap = new LinkedHashMap<>(); + //校验正确的值 + Map inputMap = new LinkedHashMap<>(); + if (sourceJson != null && sourceJson.size() > 0) { + String tag, inputText; + for (JSONObject sourceJsonObject : sourceJson) { + tag = sourceJsonObject.getString("tag"); + if (StringUtils.isBlank(tag)) { + continue; + } + inputText = sourceJsonObject.getString("inputText"); + inputMap.put(tag, inputText); + } + } + + CheckSemanticModel copyEntity = null; + String fieldName = null, inputText; + + + //判断 规则检查配置 是不是 isrule=1 + if (configRule.contains("isrule==1")) { + //isrule=1 + for (String field : inputMap.keySet()) { + fieldName = fieldMap.get(field); + copyEntity = new CheckSemanticModel(); + inputText = inputMap.get(field); + copyEntity.setField(field); + copyEntity.setInputText(inputText); + copyEntity.setRuleInfo("1"); + copyEntity.setFieldName(fieldName); + checkSemanticModelMap.put(field, copyEntity); + } + } else { + if (fieldMap != null) { + for (String field : fieldMap.keySet()) { + copyEntity = new CheckSemanticModel(); + copyEntity.setField(field); + //1/0 +// if (configRuleMap != null && configRuleMap.containsKey(field)) { +// configRule = configRuleMap.get(field); +// copyEntity.setRuleInfo(configRule); +// //端字段含义 +// fieldName = fieldMap.get(field); +// //检查数据 +// inputText = inputMap.get(field); +// +// copyEntity.setFieldName(fieldName); +// +// copyEntity.setInputText(inputText); +// +// checkSemanticModelMap.put(field, copyEntity); +// } + } + } + } + return checkSemanticModelMap; + } + // 自定义的脱敏方法,对字段进行半脱敏 private String desensitizeText(String text) { StringBuilder sb = new StringBuilder(text); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrRuleCheckServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrRuleCheckServiceImpl.java index 98cd3e7..b7825db 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrRuleCheckServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrRuleCheckServiceImpl.java @@ -1,5 +1,6 @@ package org.jeecg.modules.ocr.service.impl; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -18,13 +19,16 @@ import org.jeecg.modules.ocr.mapper.OcrRuleCheckMapper; import org.jeecg.modules.ocr.service.IOcrRuleCheckDetailService; import org.jeecg.modules.ocr.service.IOcrRuleCheckService; import org.jeecg.modules.ocr.vo.SaveOcrRuleCheckVO; +import org.jetbrains.annotations.NotNull; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; +import javax.script.ScriptException; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; /** @@ -96,6 +100,88 @@ public class OcrRuleCheckServiceImpl extends ServiceImpl list=new ArrayList<>(); + for(int i=0;i keySet = new HashSet<>(configRuleMap.keySet()); +// //循环keySet,判断字段是否是缩写,如果是缩写就把缩写的全称put一下 +// for (String s : keySet) { +// String value = configRuleMap.get(s); +// if ("hn".equals(s)) { +// configRuleMap.put("hospitalName",value); +// }else if("dn".equals(s)) { +// configRuleMap.put("doctorName", value); +// }else if("dmn".equals(s)) { +// configRuleMap.put("departmentName", value); +// }else if("tm".equals(s) || ("time".equals(s))) { +// configRuleMap.put("time", value); +// }else{ +// configRuleMap.put(s,value); +// } +// } + } + //hn=40&&(dmn=0||dn=0) + } + if (StringUtils.isNotBlank(ocrRuleCheckVo.getMetadataConfigId())) { + String metadataConfigId = ocrRuleCheckVo.getMetadataConfigId(); + List ocrMetadataConfigDetails = ocrMetadataConfigDetailMapper.selectList(new LambdaQueryWrapper().eq(OcrMetadataConfigDetail::getMetadataConfigId, metadataConfigId)); + Map fieldMap=new LinkedHashMap<>(); + for (OcrMetadataConfigDetail ocrMetadataConfigDetail : ocrMetadataConfigDetails) { + fieldMap.put(ocrMetadataConfigDetail.getFieldName(),ocrMetadataConfigDetail.getGetField()); + } + ocrRuleCheckVo.setFieldMap(fieldMap); + } + return ocrRuleCheckVo; + } @Override public OcrRuleCheck updateModel(SaveOcrRuleCheckVO saveOcrRuleCheckVO) { @@ -148,6 +234,99 @@ public class OcrRuleCheckServiceImpl extends ServiceImpl=","") + .replaceAll(">","") + .replaceAll("<","") + .replaceAll("=",""); + } + public static boolean compare(char cur, char peek) {// 如果是peek优先级高于cur,返回true,默认都是peek优先级要低 + int[] operatPriority = new int[] { 0, 3, 2, 1, -1, 1, 0, 2 }; + boolean result = false; + System.out.println(peek+cur); + if (operatPriority[(peek) - 40] >= operatPriority[(cur) - 40]) { + result = true; + } + return result; + } + public static void main(String[] args) throws ScriptException { + String str="((hn=40)&((dmn=0&tm=2)|dn=0))"; + StringBuffer sb=new StringBuffer(); + System.out.println(str); + configRuleAdapter(new StringBuffer(str),"&",sb); + System.out.println(sb); + } + static boolean isMatch(String s){ + //定义左右括号的对应关系 + Map bracket = new HashMap<>(); + bracket.put(')','('); + bracket.put(']','['); + bracket.put('}','{'); + Stack stack = new Stack(); + for(int i = 0; i < s.length(); i++){ + Character temp = s.charAt(i);//先转换成字符 + //是否为左括号 + if(bracket.containsValue(temp)){ + stack.push(temp); + //是否为右括号 + }else if(bracket.containsKey(temp)){ + if(stack.isEmpty()){ + return false; + } + //若左右括号匹配 + if(stack.peek() == bracket.get(temp)){ + stack.pop(); + } + else{ + return false; + } + } + } + return stack.isEmpty()? true: false; + } + public static String replaceFunctionStr(String text){ + return text.replaceAll("hn","H").replaceAll("dmn","D").replaceAll("dn","N").replaceAll("&","K").replaceAll("\\|","L"); + } + public static String zkh="(",ykh=")",hz="||",bq="&",dy="=",th="!"; + + public static int strNumber(String zf,String str){ + int oldCount=str.length(); + int newCount=str.replace(zf,"").length(); + return oldCount-newCount/zf.length(); + } + public static boolean isOperator(char c){ + return c == '(' || c == ')'; + } + public static boolean isExpression(String op){ + return op.contains("&")||op.contains("|"); + } + public static boolean isFlagOp(String op){ + return op.contains(">")||op.contains("<")||op.contains("!="); + } + public static boolean isExpressOp(String op){ + return op.equals("H")||op.equals("D")||op.equals("N")||op.equals("O"); + } + public static boolean isOtherOp(String op){ + return op.equals(","); + } + public static boolean isNumber(String op){ + return op.matches("\\d+(\\.\\d+)?"); + } + public static boolean isString(String op){ + return op.matches("[\\u4e00-\\u9fa50-9a-zA-Z-]{1,}$"); + } + public static int priority(String op){ + if(op.equals("*")||op.equals("/")||isFlagOp(op)||isExpressOp(op)){ + return 1; + }else if(op.equals("+")||op.equals("-")){ + return 0; + } + return -1; + } + @Override public OcrRuleCheckDTO findById(String id) { @@ -200,14 +379,4 @@ public class OcrRuleCheckServiceImpl extends ServiceImpl identifyDetails) { String requestId = ocrIdentify.getRequestId(); + log.info("数据准备:{}",ocrIdentify); //请求对象 CallBackWlyResult result = new CallBackWlyResult(); @@ -76,6 +77,7 @@ public class CallBackWlyUtils { result.setRetrieveReviewCompliance(imageTagRetrievePercentage+""); result.setFailureReason(ocrIdentify.getErrorMsg()); if (CollectionUtils.isEmpty(jsonObjects)) { + log.info("结果为空不给无量云推送:{}",jsonObjects); return false; } result.setOcrResult(jsonObjects); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/util/RandImageUtil.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/util/RandImageUtil.java index 3311d68..c96fc5e 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/util/RandImageUtil.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/util/RandImageUtil.java @@ -84,10 +84,13 @@ public class RandImageUtil { } private static BufferedImage getImageBuffer(String resultCode){ + System.out.println("验证码:"+resultCode); // 在内存中创建图象 final BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB); + System.out.println("image:"+image); // 获取图形上下文 final Graphics2D graphics = (Graphics2D) image.getGraphics(); + System.out.println("image11111111111 :"+graphics); // 设定背景颜色 // ---1 graphics.setColor(Color.WHITE); @@ -119,6 +122,9 @@ public class RandImageUtil { // 设置字体样式 // graphics.setFont(new Font("Arial Black", Font.ITALIC, 18)); graphics.setFont(new Font("Times New Roman", Font.BOLD, 24)); + System.out.println("resultCode:"+resultCode); + System.out.println("resultCode i:"+i); + System.out.println("resultCode:"+String.valueOf(resultCode.charAt(i))); // 设置字符,字符间距,上边距 graphics.drawString(String.valueOf(resultCode.charAt(i)), (23 * i) + 8, 26); } From 5eedb16ec0f262c3ec0536677bfd3b9444a1fe2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E5=90=91=E6=96=8C?= <574110378@qq.com> Date: Fri, 22 Sep 2023 16:05:38 +0800 Subject: [PATCH 23/36] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/jeecg/modules/ocr/init/HandleCallbacklnit.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleCallbacklnit.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleCallbacklnit.java index c4cba36..3c15037 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleCallbacklnit.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleCallbacklnit.java @@ -51,6 +51,7 @@ public class HandleCallbacklnit implements ApplicationRunner { @Override @Async public void run(ApplicationArguments args) throws UnknownHostException { + log.info("---------------------回调任务开启{}---------------------",enableHandleTask); if (enableHandleTask) { List callbackApiConfigs = sysDictService.queryDictItemsByCode("callback_api_config"); Integer autoPushNoticeMaxNum=10;//自动请求最大次数. From af81d8b1be4c736bf2a97e55fd7c0d29449d6e08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E5=90=91=E6=96=8C?= <574110378@qq.com> Date: Fri, 22 Sep 2023 16:25:52 +0800 Subject: [PATCH 24/36] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java index 1c2459b..0605b4c 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java @@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.Async; import javax.annotation.Resource; import java.util.ArrayList; @@ -48,6 +49,7 @@ public class HandleTaskInit implements ApplicationRunner { private boolean enableHandleTask; @Override + @Async public void run(ApplicationArguments args) throws Exception { if(enableHandleTask){ try { From c325db2c58dd8f3dea485fba21c711a7e3f44679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E5=90=91=E6=96=8C?= <574110378@qq.com> Date: Fri, 22 Sep 2023 16:31:01 +0800 Subject: [PATCH 25/36] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/jeecg/modules/ocr/init/HandleCallbacklnit.java | 6 ++---- .../modules/ocr/service/impl/OcrIdentifyServiceImpl.java | 2 -- .../java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleCallbacklnit.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleCallbacklnit.java index 3c15037..4403567 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleCallbacklnit.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleCallbacklnit.java @@ -71,13 +71,11 @@ public class HandleCallbacklnit implements ApplicationRunner { e.printStackTrace(); } List ocrIdentifyList = ocrIdentifyService.findNeNoticeList(autoPushNoticeMaxNum); - log.info("待回调任务:{}",ocrIdentifyList.size()); - log.info("待回调任务:{}",ocrIdentifyList); for (OcrIdentify ocrIdentify : ocrIdentifyList) { try { - log.info("回调:{}",ocrIdentify); + log.info("回调:{}",ocrIdentify.getIdentifyUrl()); ocrIdentifyService.callbackWly(ocrIdentify.getId()); - log.info("回调结束:{}",ocrIdentify); + log.info("回调结束:{}",ocrIdentify.getIdentifyUrl()); Thread.sleep(pushTimeInterval*1000); } catch (InterruptedException e) { log.error(e.getMessage()); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java index db68725..38c03eb 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java @@ -428,9 +428,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl identifyDetailList = ocrIdentifyDetailService.listByIdentifyId(ocrIdentifyId); ocrIdentifyCallbackLog.setStartTime(date); - log.info("执行CallBackWlyUtils.callbackWly({}, {})",ocrIdentify,identifyDetailList); boolean b = CallBackWlyUtils.callbackWly(ocrIdentify, identifyDetailList); - log.info("执行CallBackWlyUtils.callbackWly 结束",ocrIdentify,identifyDetailList); ocrIdentifyCallbackLog.setStatus(b?1:0);//0-失败,1-成功 ocrIdentifyCallbackLog.setEndTime(new Date()); ocrIdentifyCallbackLogService.save(ocrIdentifyCallbackLog); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java index 64668d5..5072313 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java @@ -29,7 +29,7 @@ public class CallBackWlyUtils { public static boolean callbackWly(OcrIdentify ocrIdentify, List identifyDetails) { String requestId = ocrIdentify.getRequestId(); - log.info("数据准备:{}",ocrIdentify); + log.info("数据准备:{}",requestId); //请求对象 CallBackWlyResult result = new CallBackWlyResult(); From d75970a3e2e6e6c0b4a8590cf39b2134e6c11ece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E5=90=91=E6=96=8C?= <574110378@qq.com> Date: Fri, 22 Sep 2023 17:12:28 +0800 Subject: [PATCH 26/36] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-prod.yml | 53 +++++++++---------- .../src/main/resources/application.yml | 2 +- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml b/jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml index 50a8d0e..9a86f11 100644 --- a/jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml +++ b/jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml @@ -1,5 +1,5 @@ server: - port: 8080 + port: 8020 tomcat: max-swallow-size: -1 error: @@ -7,7 +7,7 @@ server: include-stacktrace: ALWAYS include-message: ALWAYS servlet: - context-path: /jeecg-boot + context-path: /ocr compression: enabled: true min-response-size: 1024 @@ -26,7 +26,7 @@ spring: max-request-size: 10MB mail: host: smtp.163.com - username: ?? + username: jeecgos@163.com password: ?? properties: mail: @@ -111,14 +111,14 @@ spring: # 初始化大小,最小,最大 initial-size: 5 min-idle: 5 - maxActive: 1000 + maxActive: 20 # 配置获取连接等待超时的时间 maxWait: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 timeBetweenEvictionRunsMillis: 60000 # 配置一个连接在池中最小生存的时间,单位是毫秒 minEvictableIdleTimeMillis: 300000 - validationQuery: SELECT 1 FROM DUAL + validationQuery: SELECT 1 testWhileIdle: true testOnBorrow: false testOnReturn: false @@ -131,10 +131,14 @@ spring: connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 datasource: master: - url: jdbc:mysql://127.0.0.1:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai + url: jdbc:mysql://127.0.0.1:3306/ocr?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai username: root - password: root + password: stqpvqk/.6:H driver-class-name: com.mysql.cj.jdbc.Driver + # url: jdbc:mysql://127.0.0.1:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai + # username: root + # password: root + # driver-class-name: com.mysql.cj.jdbc.Driver # 多数据源配置 #multi-datasource1: #url: jdbc:mysql://localhost:3306/jeecg-boot2?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai @@ -143,8 +147,9 @@ spring: #driver-class-name: com.mysql.cj.jdbc.Driver #redis 配置 redis: - database: 0 + database: 3 host: 127.0.0.1 + # host: 47.103.213.109 port: 6379 password: '' #mybatis plus 设置 @@ -173,31 +178,30 @@ jeecg: signatureSecret: dd05f1c54d63749eda95f9fa6d49v442a # 签名拦截接口 signUrls: /sys/dict/getDictItems/*,/sys/dict/loadDict/*,/sys/dict/loadDictOrderByValue/*,/sys/dict/loadDictItem/*,/sys/dict/loadTreeData,/sys/api/queryTableDictItemsByCode,/sys/api/queryFilterTableDictInfo,/sys/api/queryTableDictByKeys,/sys/api/translateDictFromTable,/sys/api/translateDictFromTableByKeys - #local\minio\alioss - uploadType: alioss + #local、minio、alioss + uploadType: local # 前端访问地址 domainUrl: pc: http://localhost:3100 app: http://localhost:8051 path: #文件上传根目录 设置 - upload: /data/ocr/upload + upload: /data/ocr/upFiles #webapp文件路径 - webapp: /opt/jeecg-boot/webapp + webapp: /opt/webapp shiro: - excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/api/getUserInfo + excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/** #阿里云oss存储和大鱼短信秘钥配置 oss: accessKey: ?? secretKey: ?? endpoint: oss-cn-beijing.aliyuncs.com bucketName: jeecgdev - staticDomain: https://static.jeecg.com - # ElasticSearch 设置 + # ElasticSearch 6设置 elasticsearch: cluster-name: jeecg-ES cluster-nodes: 127.0.0.1:9200 - check-enabled: true + check-enabled: false # 在线预览文件服务器地址配置 file-view-domain: http://fileview.jeecg.com # minio文件上传 @@ -208,17 +212,9 @@ jeecg: bucketName: otatest #大屏报表参数设置 jmreport: - mode: prod + mode: dev #数据字典是否进行saas数据隔离,自己看自己的字典 saas: false - #是否开启租户模式 Support By v1.5.5+ - openTenant: false - #安全模式(敏感接口校验、saas模式下不允许使用平台数据源) - #safeMode: true - #是否需要校验token - is_verify_token: true - #必须校验方法 - verify_methods: remove,delete,save,add,update #xxl-job配置 xxljob: enabled: false @@ -250,7 +246,7 @@ knife4j: #开启生产环境屏蔽 production: false basic: - enable: true + enable: false username: jeecg password: jeecg1314 #第三方登录 @@ -303,5 +299,6 @@ third-app: agent-id: ?? system: project: - env: customer_prod - fileReviewUrlPrefix: http://47.103.213.109:8072/files \ No newline at end of file + env: customer_test + enableHandleTask: true + fileReviewUrlPrefix: http://localhost:8071/files \ No newline at end of file diff --git a/jeecg-module-system/jeecg-system-start/src/main/resources/application.yml b/jeecg-module-system/jeecg-system-start/src/main/resources/application.yml index 678c3e7..691f1e0 100644 --- a/jeecg-module-system/jeecg-system-start/src/main/resources/application.yml +++ b/jeecg-module-system/jeecg-system-start/src/main/resources/application.yml @@ -3,4 +3,4 @@ spring: name: jeecg-system profiles: # active: '@profile.name@' - active: dev \ No newline at end of file + active: prod \ No newline at end of file From 10ecb1179cd30bd4f22ad9e5dbc8cac706abf1ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E5=90=91=E6=96=8C?= <574110378@qq.com> Date: Fri, 22 Sep 2023 18:19:16 +0800 Subject: [PATCH 27/36] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/ocr/service/impl/OcrIdentifyServiceImpl.java | 4 ++-- .../jeecg-system-start/src/main/resources/application.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java index 38c03eb..bf33cb6 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java @@ -365,7 +365,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl resultList = jsonArray.toJavaList(OcrResultDTO.class); for (OcrResultDTO result : resultList) { @@ -376,7 +376,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl Date: Fri, 22 Sep 2023 18:19:32 +0800 Subject: [PATCH 28/36] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeecg-system-start/src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jeecg-module-system/jeecg-system-start/src/main/resources/application.yml b/jeecg-module-system/jeecg-system-start/src/main/resources/application.yml index 678c3e7..691f1e0 100644 --- a/jeecg-module-system/jeecg-system-start/src/main/resources/application.yml +++ b/jeecg-module-system/jeecg-system-start/src/main/resources/application.yml @@ -3,4 +3,4 @@ spring: name: jeecg-system profiles: # active: '@profile.name@' - active: dev \ No newline at end of file + active: prod \ No newline at end of file From b903c453d79a8feb75cfca11bf243665589db3ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E5=90=91=E6=96=8C?= <574110378@qq.com> Date: Tue, 26 Sep 2023 14:36:42 +0800 Subject: [PATCH 29/36] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeecg/common/aspect/AutoLogAspect.java | 22 +++++++++++-------- .../modules/api/controller/ApiController.java | 4 ++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/aspect/AutoLogAspect.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/aspect/AutoLogAspect.java index 7738835..3be5439 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/aspect/AutoLogAspect.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/aspect/AutoLogAspect.java @@ -15,6 +15,7 @@ import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.enums.ModuleType; import org.jeecg.common.constant.enums.OperateTypeEnum; +import org.jeecg.common.exception.JeecgBootException; import org.jeecg.modules.base.service.BaseCommonService; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.util.IpUtils; @@ -52,17 +53,18 @@ public class AutoLogAspect { } @Around("logPointCut()") - public Object around(ProceedingJoinPoint point) throws Throwable { + public void around(ProceedingJoinPoint point) throws Throwable { long beginTime = System.currentTimeMillis(); //执行方法 - Object result = point.proceed(); - //执行时长(毫秒) - long time = System.currentTimeMillis() - beginTime; - - //保存日志 - saveSysLog(point, time, result); - - return result; + try{ + Object result = point.proceed(); + long time = System.currentTimeMillis() - beginTime; + saveSysLog(point, time, result); + }catch (Exception e){ + long time = System.currentTimeMillis() - beginTime; + saveSysLog(point, time, e.getMessage()); + throw new JeecgBootException(e.getMessage()); + } } private void saveSysLog(ProceedingJoinPoint joinPoint, long time, Object obj) { @@ -95,6 +97,8 @@ public class AutoLogAspect { //获取request HttpServletRequest request = SpringContextUtils.getHttpServletRequest(); + dto.setRequestUrl(request.getRequestURL().toString()); + dto.setRequestType(request.getMethod()); //请求的参数 dto.setRequestParam(getReqestParams(request,joinPoint)); //设置IP地址 diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java index fb26250..115941d 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java @@ -10,6 +10,9 @@ import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.jeecg.common.api.vo.Result; +import org.jeecg.common.aspect.annotation.AutoLog; +import org.jeecg.common.constant.CommonConstant; +import org.jeecg.common.constant.enums.ModuleType; import org.jeecg.common.system.vo.DictModel; import org.jeecg.common.util.*; import org.jeecg.modules.ocr.entity.OcrIdentify; @@ -64,6 +67,7 @@ public class ApiController { @RequestMapping("/identify") @Transactional @ResponseBody + @AutoLog(value = "api接口-通用识别",logType = CommonConstant.OPERATE_TYPE_1) public Result pushSemantic(@RequestBody JSONObject requestBody) throws InterruptedException { // if (!"test".equals(profiles)) { // return Result.error("当前环境不支持该功能,请访问测试环境"); From e021526a26f3733bfacb3fd7f9c2bedcb3a97443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E5=90=91=E6=96=8C?= <574110378@qq.com> Date: Wed, 27 Sep 2023 10:43:42 +0800 Subject: [PATCH 30/36] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/modules/api/controller/ApiController.java | 6 ++++-- .../modules/ocr/service/impl/OcrIdentifyServiceImpl.java | 5 +++-- .../java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java | 6 ++++-- .../src/main/resources/application-prod.yml | 3 ++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java index 115941d..ddb2451 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java @@ -63,11 +63,13 @@ public class ApiController { private TaskService taskService; @Value("${spring.profiles.active}") private String profiles; + @Value("${system.project.wlyCallback}") + private String wlyCallback; @ApiOperation(value = "通用识别") @RequestMapping("/identify") @Transactional @ResponseBody - @AutoLog(value = "api接口-通用识别",logType = CommonConstant.OPERATE_TYPE_1) + @AutoLog(value = "api接口-通用识别",logType = CommonConstant.LOG_TYPE_2,operateType=CommonConstant.OPERATE_TYPE_1) public Result pushSemantic(@RequestBody JSONObject requestBody) throws InterruptedException { // if (!"test".equals(profiles)) { // return Result.error("当前环境不支持该功能,请访问测试环境"); @@ -265,7 +267,7 @@ public class ApiController { Map configRuleMap = ocrRuleCheckVo.getConfigRuleMap();*/ OcrIdentifyDTO identifyDTO = ocrIdentifyService.findById("1702560400245035009"); List identifyDetailList = ocrIdentifyDetailService.listByIdentifyId(identifyDTO.getId()); - CallBackWlyUtils.callbackWly(identifyDTO,identifyDetailList); + CallBackWlyUtils.callbackWly(wlyCallback,identifyDTO,identifyDetailList); return Result.OK(""); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java index bf33cb6..c17560f 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java @@ -66,7 +66,8 @@ public class OcrIdentifyServiceImpl extends ServiceImpl identifyDetailList = ocrIdentifyDetailService.listByIdentifyId(ocrIdentifyId); ocrIdentifyCallbackLog.setStartTime(date); - boolean b = CallBackWlyUtils.callbackWly(ocrIdentify, identifyDetailList); + boolean b = CallBackWlyUtils.callbackWly(wlyCallback,ocrIdentify, identifyDetailList); ocrIdentifyCallbackLog.setStatus(b?1:0);//0-失败,1-成功 ocrIdentifyCallbackLog.setEndTime(new Date()); ocrIdentifyCallbackLogService.save(ocrIdentifyCallbackLog); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java index 5072313..5cdef29 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java @@ -27,7 +27,9 @@ import java.util.List; @Slf4j public class CallBackWlyUtils { - public static boolean callbackWly(OcrIdentify ocrIdentify, List identifyDetails) { + + + public static boolean callbackWly(String url,OcrIdentify ocrIdentify, List identifyDetails) { String requestId = ocrIdentify.getRequestId(); log.info("数据准备:{}",requestId); //请求对象 @@ -91,7 +93,7 @@ public class CallBackWlyUtils { System.out.println("============================================="); System.out.println(JSONObject.toJSONString(callBackWlyRequestBody)); System.out.println("============================================="); - semanticResponseJson = RestUtil.post("https://192.168.1.100:8894/api/task/image/ocr/callback", JSONObject.parseObject(JSONObject.toJSONString(callBackWlyRequestBody, SerializerFeature.WriteNullStringAsEmpty))); + semanticResponseJson = RestUtil.post(url, JSONObject.parseObject(JSONObject.toJSONString(callBackWlyRequestBody, SerializerFeature.WriteNullStringAsEmpty))); } catch (org.springframework.web.client.ResourceAccessException e) { log.error("请求无量云回调接口失败-拒绝连接 (Connection refused)"); log.error(e.getMessage()); diff --git a/jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml b/jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml index 9a86f11..10b730c 100644 --- a/jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml +++ b/jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml @@ -301,4 +301,5 @@ system: project: env: customer_test enableHandleTask: true - fileReviewUrlPrefix: http://localhost:8071/files \ No newline at end of file + fileReviewUrlPrefix: http://localhost:8071/files + wlyCallback: https://hyycsozs.prevailcloud.com/api/task/image/ocr/callback \ No newline at end of file From 291cadcbec4b610574db3f072c40593c195b6ed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E5=90=91=E6=96=8C?= <574110378@qq.com> Date: Wed, 27 Sep 2023 19:07:57 +0800 Subject: [PATCH 31/36] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/ocr/utils/CallBackWlyUtils.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java index 5cdef29..f18fc04 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java @@ -39,15 +39,23 @@ public class CallBackWlyUtils { //总明细数量 int detail_detailCount = 0; int detailValidationCount=0; + BigDecimal imageTagRetrievePercentage = new BigDecimal("0");//成功率 String taskResultInfo = ocrIdentify.getTaskResultInfo(); if (StringUtils.isNotBlank(taskResultInfo)) { //循环获取哪些字段通过了 List taskResultInfoList = JSONArray.parseArray(taskResultInfo).toJavaList(JSONObject.class); - detail_detailCount=taskResultInfoList.size(); +// detail_detailCount=taskResultInfoList.size(); +// for (JSONObject jsonObject : taskResultInfoList) { +// Boolean ruleValidation = (Boolean) jsonObject.getOrDefault("ruleValidation", false); +// if (ruleValidation) { +// //通过了, +// detailValidationCount++; +// } +// } for (JSONObject jsonObject : taskResultInfoList) { - Boolean ruleValidation = (Boolean) jsonObject.getOrDefault("ruleValidation", false); - if (ruleValidation) { - //通过了, + Double ruleValidation = jsonObject.getDouble("textRate"); + if (ruleValidation!=null) { + imageTagRetrievePercentage=imageTagRetrievePercentage.add(new BigDecimal(ruleValidation)); detailValidationCount++; } } @@ -64,12 +72,7 @@ public class CallBackWlyUtils { //组装回调参数 - //成功率 - double imageTagRetrievePercentage = 0.0d; - if (detail_detailCount > 0) { - BigDecimal divide = new BigDecimal(detailValidationCount).divide(new BigDecimal(detail_detailCount), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)); - imageTagRetrievePercentage = divide.doubleValue(); - } + imageTagRetrievePercentage = imageTagRetrievePercentage.divide(new BigDecimal(detailValidationCount), 2, RoundingMode.HALF_UP); if (StringUtils.isNotBlank(ocrIdentify.getTaskResult()) && "1".equals(ocrIdentify.getTaskResult())) { result.setRuleValidation(true); }else{ From fc39d130aa8e0556575ea908f2c4b06369045650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E5=90=91=E6=96=8C?= <574110378@qq.com> Date: Thu, 28 Sep 2023 14:46:28 +0800 Subject: [PATCH 32/36] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/api/controller/ApiController.java | 2 +- .../ocr/controller/OcrIdentifyController.java | 2 +- .../ocr/service/IOcrIdentifyService.java | 4 +++- .../service/impl/OcrIdentifyServiceImpl.java | 17 ++++++++++++++--- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java index ddb2451..36b3f06 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java @@ -79,7 +79,6 @@ public class ApiController { } //1.获取请求参数 String taskName = requestBody.getString("taskName"); - AssertUtils.notTrue(ocrIdentifyService.calculateTimeDifference(taskName)<=10,"[任务名称]-"+taskName+" 短时间内已存在,不可再次请求"); String requestId = requestBody.getString("requestId");//请求唯一标识 String scenes = requestBody.getString("scenes");//场景类型:door=门头照片,cases=病例,bill=票据 String ruleId = requestBody.getString("ruleId");//规则标识 @@ -90,6 +89,7 @@ public class ApiController { //============================================================= //2.参数判断 AssertUtils.notNull(requestId, "[requestId]-不可为空"); + AssertUtils.notTrue(ocrIdentifyService.calculateTimeDifferenceByRequestId(requestId)<=10,"[任务名称]-"+taskName+" 短时间内已存在,不可再次请求"); AssertUtils.notTrue(!"door".equals(scenes), String.format("暂不支持该场景类型[%s]", scenes)); AssertUtils.notNull(ruleId, "[ruleId]-不可为空"); OcrRuleCheckDTO ruleCheck = ocrRuleCheckService.findById(ruleId); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyController.java index 1ca4b29..aaa9b2d 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyController.java @@ -153,7 +153,7 @@ public class OcrIdentifyController extends JeecgController { * 新增方法:计算最近任务创建时间差 * @return */ - long calculateTimeDifference(String taskName); + long calculateTimeDifferenceByRequestId(String requestId); JSONObject simulateChecksV01(SimulateChecksVO simulateChecksVO); + + long calculateTimeDifferenceByTaskName(String taskName); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java index c17560f..49e29c9 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java @@ -1624,9 +1624,21 @@ public class OcrIdentifyServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(OcrIdentify::getTaskName, taskName).orderByDesc(OcrIdentify::getCreateTime).last("LIMIT 1"); + queryWrapper.eq(OcrIdentify::getRequestId, requestId).orderByDesc(OcrIdentify::getCreateTime).last("LIMIT 1"); + OcrIdentify lastIdentify = this.getOne(queryWrapper); + if (lastIdentify != null) { + Date lastCreateTime = lastIdentify.getCreateTime(); + Date currentTime = new Date(); + return (currentTime.getTime() - lastCreateTime.getTime()) / 1000; + } + return 11; // 如果没有找到数据,返回默认值 + } + @Override + public long calculateTimeDifferenceByTaskName(String taskName) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(OcrIdentify::getTaskName,taskName).orderByDesc(OcrIdentify::getCreateTime).last("LIMIT 1"); OcrIdentify lastIdentify = this.getOne(queryWrapper); if (lastIdentify != null) { Date lastCreateTime = lastIdentify.getCreateTime(); @@ -1635,5 +1647,4 @@ public class OcrIdentifyServiceImpl extends ServiceImpl Date: Sat, 7 Oct 2023 11:07:45 +0800 Subject: [PATCH 33/36] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/jeecg/modules/api/controller/ApiController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java index 36b3f06..b897df3 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java @@ -89,7 +89,7 @@ public class ApiController { //============================================================= //2.参数判断 AssertUtils.notNull(requestId, "[requestId]-不可为空"); - AssertUtils.notTrue(ocrIdentifyService.calculateTimeDifferenceByRequestId(requestId)<=10,"[任务名称]-"+taskName+" 短时间内已存在,不可再次请求"); + AssertUtils.notTrue(ocrIdentifyService.calculateTimeDifferenceByRequestId(requestId)<=10,"[requestId]-"+taskName+" 短时间内已存在,不可再次请求"); AssertUtils.notTrue(!"door".equals(scenes), String.format("暂不支持该场景类型[%s]", scenes)); AssertUtils.notNull(ruleId, "[ruleId]-不可为空"); OcrRuleCheckDTO ruleCheck = ocrRuleCheckService.findById(ruleId); From c65202d585e10055f7af0d99d324991091439c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E5=90=91=E6=96=8C?= <574110378@qq.com> Date: Sat, 7 Oct 2023 23:08:55 +0800 Subject: [PATCH 34/36] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/jeecg/modules/api/controller/ApiController.java | 2 +- .../jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java index b897df3..1e68f7c 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java @@ -140,7 +140,7 @@ public class ApiController { ocrIdentify.setSourceJson(requestBody.getJSONArray("sourceJson").toJSONString());//校验数据源 ocrIdentifyService.save(ocrIdentify); } - Thread.sleep(1000L); +// Thread.sleep(1000L); //3.请求python ocr识别,异步执行 //taskService.postSemantic(ocrIdentify,fileList); //ocrIdentifyService.postSemantic(ocrIdentify, fileList); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java index 49e29c9..0bea5ee 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java @@ -355,6 +355,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl updateWrapper = new LambdaUpdateWrapper<>(); updateWrapper.eq(OcrIdentify::getId, id); From 1ed303f7c65b8d14edaf02cf09241831e6b02b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E5=90=91=E6=96=8C?= <574110378@qq.com> Date: Fri, 13 Oct 2023 17:05:35 +0800 Subject: [PATCH 35/36] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/jeecg/modules/api/controller/ApiController.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java index 1e68f7c..6131293 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java @@ -74,6 +74,7 @@ public class ApiController { // if (!"test".equals(profiles)) { // return Result.error("当前环境不支持该功能,请访问测试环境"); // } + log.info("api接口-通用识别请求开始,{}",requestBody); if (requestBody == null) { return Result.error("请输入请求参数"); } @@ -140,7 +141,8 @@ public class ApiController { ocrIdentify.setSourceJson(requestBody.getJSONArray("sourceJson").toJSONString());//校验数据源 ocrIdentifyService.save(ocrIdentify); } -// Thread.sleep(1000L); + log.info("api接口-通用识别请求结束,{}",requestBody); + Thread.sleep(1000L); //3.请求python ocr识别,异步执行 //taskService.postSemantic(ocrIdentify,fileList); //ocrIdentifyService.postSemantic(ocrIdentify, fileList); From 21a022ca7d89f1ec4153b2cc5aaf19df03cd0987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E5=90=91=E6=96=8C?= <574110378@qq.com> Date: Mon, 27 Nov 2023 09:37:44 +0800 Subject: [PATCH 36/36] =?UTF-8?q?=E5=9B=BE=E7=89=87=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java | 4 ++++ .../src/main/resources/application-dev.yml | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java index 0605b4c..7bc9588 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTaskInit.java @@ -88,6 +88,10 @@ public class HandleTaskInit implements ApplicationRunner { String image;//图片 //执行获取到的任务 identifyFor: for (OcrIdentify ocrIdentify : list) { + //过滤不需要的任务批次 + if(ocrIdentify.getRequestId().contains("c1b1f298e7ab4ba59103081e55f9cd01")){ + continue; + } image=null; fileList=new ArrayList<>(); //识别的图片路径 diff --git a/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml b/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml index fc82474..3d1354c 100644 --- a/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml +++ b/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml @@ -299,5 +299,6 @@ third-app: system: project: env: customer_test - enableHandleTask: false - fileReviewUrlPrefix: http://47.103.213.109:8072/files \ No newline at end of file + enableHandleTask: true + fileReviewUrlPrefix: http://47.103.213.109:8072/files + wlyCallback: https://hyycsozs.prevailcloud.com/api/task/image/ocr/callback \ No newline at end of file