From c7551b3df828518f6fed57ff89c04b4cc63b718b Mon Sep 17 00:00:00 2001 From: zhouwentao <1577701412@qq.com> Date: Wed, 23 Aug 2023 09:06:27 +0800 Subject: [PATCH] updates --- .../ocr/controller/OcrSimulatorController.java | 12 +++++++++--- .../ocr/service/impl/OcrIdentifyServiceImpl.java | 7 ++++++- 2 files changed, 15 insertions(+), 4 deletions(-) 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 85a436b..52473b6 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 @@ -67,7 +67,14 @@ public class OcrSimulatorController{ //执行识别 JSONObject semanticRequestBody = new JSONObject(); semanticRequestBody.put("task_id", time+""); - semanticRequestBody.put("img_path", uploadFilePath + "/" + image); + OcrIdentifyDetail ocrIdentifyDetail=new OcrIdentifyDetail(); + if (image.contains("http:") || image.contains("https:")) { + semanticRequestBody.put("img_path",image); + ocrIdentifyDetail.setImageUrl(image);//图片地址 + }else{ + ocrIdentifyDetail.setImageUrl(uploadFilePath + "/" + image);//图片地址 + semanticRequestBody.put("img_path", uploadFilePath + "/" + image); + } JSONObject semanticResponseJson = RestUtil.post(OcrConstant.api_test2_identify_url, semanticRequestBody); //执行时间 调整小数点 Double nluTime = semanticResponseJson.getDouble("nlu_time"); @@ -75,12 +82,11 @@ public class OcrSimulatorController{ nluTime = nluTime != null && nluTime != 0 ? new BigDecimal(nluTime).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() : 0; ocrTime = ocrTime != null && ocrTime != 0 ? new BigDecimal(ocrTime).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() : 0; //入库 - OcrIdentifyDetail ocrIdentifyDetail=new OcrIdentifyDetail(); ocrIdentifyDetail.setIdentifyId(ocrIdentify.getId()); ocrIdentifyDetail.setOcrTime(ocrTime); ocrIdentifyDetail.setNluTime(nluTime); ocrIdentifyDetail.setImageName(image);//图片名称 - ocrIdentifyDetail.setImageUrl(uploadFilePath + "/" + image);//图片地址 + ocrIdentifyDetail.setSemanticResult(semanticResponseJson.toJSONString());//ocr识别结果 ocrIdentifyDetailList.add(ocrIdentifyDetail); //累计时间 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 5e8f741..ec248a6 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 @@ -1003,7 +1003,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpla.getTextRate().compareTo(b.getTextRate())).findFirst().get(); + //获取最大 + //ocrResultList.stream().sorted((a,b)->a.getTextRate()-b.getTextRate()).findAny().get(); + //.sorted(OcrResult::getTextRate).findFirst(); } }