From 678d3c47c1e0515f4ec29cbe2754d7cc6ef9a030 Mon Sep 17 00:00:00 2001 From: zhouwentao <1577701412@qq.com> Date: Fri, 15 Sep 2023 14:55:16 +0800 Subject: [PATCH] updates --- .../jeecg/modules/ocr/init/HandleTransInit.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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 4256d30..b34403d 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 @@ -149,24 +149,31 @@ public class HandleTransInit implements ApplicationRunner { requestBody.put("img_path", image); //更新主任务,正在识别中. conda activate ai ocrIdentifyService.updateMasterTaskStartTime(task_id.split("_")[0]); - boolean flag=false; + int check=0; JSONObject semanticResponseJson =null; - while (!flag){ + while (check==0){ try { semanticResponseJson = RestUtil.post(OcrConstant.api_test2_identify_url, requestBody); //semanticResponseJson = JSONObject.parseObject("{\"img_path\":\"https://h5.mcnetmart.com/tmp/images/dc_demo1.png\",\"ocr_time\":3.4992809295654297,\"task_id\":\"1697133769514909698_1\",\"message\":\"成功\",\"semantic_result\":{\"ocr_res\":[[[[136.0,98.0],[276.0,70.0],[281.0,93.0],[141.0,121.0]],[\"深圳康瑞医院\",0.9387677311897278]],[[[139.0,120.0],[284.0,92.0],[288.0,109.0],[142.0,136.0]],[\"Shenzhen Kangrui hospual\",0.9168243408203125]],[[[171.0,284.0],[260.0,268.0],[264.0,292.0],[175.0,308.0]],[\"赵思杰\",0.9619879126548767]],[[[191.0,311.0],[247.0,301.0],[251.0,323.0],[195.0,333.0]],[\"妇产科\",0.9429848790168762]],[[[189.0,346.0],[259.0,332.0],[263.0,350.0],[193.0,364.0]],[\"主治医师\",0.8993821144104004]],[[[198.0,375.0],[263.0,364.0],[267.0,381.0],[201.0,393.0]],[\"202015\",0.9382884502410889]]],\"其他\":[{\"area\":[[139.0,120.0],[284.0,92.0],[288.0,109.0],[142.0,136.0]],\"end\":24,\"ocrText\":\"Shenzhen Kangrui hospual\",\"probability\":0.9846151031007864,\"start\":0,\"text\":\"Shenzhen Kangrui hospual\"},{\"area\":[[189.0,346.0],[259.0,332.0],[263.0,350.0],[193.0,364.0]],\"end\":4,\"ocrText\":\"主治医师\",\"probability\":0.9848503723946322,\"start\":0,\"text\":\"主治医师\"},{\"area\":[[198.0,375.0],[263.0,364.0],[267.0,381.0],[201.0,393.0]],\"end\":6,\"ocrText\":\"202015\",\"probability\":0.9731923600763821,\"start\":0,\"text\":\"202015\"}],\"医院名称\":[{\"area\":[[136.0,98.0],[276.0,70.0],[281.0,93.0],[141.0,121.0]],\"end\":6,\"ocrText\":\"深圳康瑞医院\",\"probability\":0.9856892892579268,\"start\":0,\"text\":\"深圳康瑞医院\"}],\"姓名\":[{\"area\":[[171.0,284.0],[260.0,268.0],[264.0,292.0],[175.0,308.0]],\"end\":3,\"ocrText\":\"赵思杰\",\"probability\":0.9996551423001598,\"start\":0,\"text\":\"赵思杰\"}],\"时间\":[],\"科室\":[{\"area\":[[191.0,311.0],[247.0,301.0],[251.0,323.0],[195.0,333.0]],\"end\":3,\"ocrText\":\"妇产科\",\"probability\":0.9983404968615517,\"start\":0,\"text\":\"妇产科\"}]},\"nlu_time\":16.85913324356079,\"identifyId\":\"1697133769514909698\"}"); if (semanticResponseJson!=null) { - flag=true; + check=1; } }catch (org.springframework.web.client.ResourceAccessException e){ log.error(e.getMessage()); log.error("正在重试..."); + }catch (org.springframework.web.client.HttpServerErrorException e){ + if (e.getMessage().contains("\\u56fe\\u7247\\u8def\\u5f84\\u9519\\u8bef")) { + //图片不存在,跳过 + check=2; + } } } semanticResponseJson.put("identifyId", masterTaskId); log.info("ocr识别返回数据:"); log.info(semanticResponseJson.toJSONString()); - ocrIdentifyService.getSemanticInfo(semanticResponseJson); + if (check==1) { + ocrIdentifyService.getSemanticInfo(semanticResponseJson); + } //该子任务已执行,判断主任务是否残留 String masterTask = (String) redisUtil.get("identify_" + masterTaskId); if (StringUtils.isNotBlank(masterTask)) {