From 4012766341a607115e14640b13c590ace988af4f Mon Sep 17 00:00:00 2001 From: zhouwentao <1577701412@qq.com> Date: Thu, 3 Aug 2023 14:47:38 +0800 Subject: [PATCH] updates --- .../service/impl/OcrIdentifyServiceImpl.java | 58 +++++++++++-------- 1 file changed, 33 insertions(+), 25 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 64f2806..d5fee31 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 @@ -121,7 +121,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl checkSemanticModelMap = getCheckSemanticModelMap(ocrRuleCheckVo.getConfigRuleMap(), ocrRuleCheckVo.getFieldMap(), ocrIdentifyVo.getSourceJsonObjects()); //// - String text;//ocr 识别的文本, + String text=null;//ocr 识别的文本, Double probability = 0d; //用于数据结构化的对象 List ocrResultList = new ArrayList<>(); @@ -147,36 +147,43 @@ public class OcrIdentifyServiceImpl extends ServiceImpl"); - mapPutIfTrue(fieldRightMap, field, false); - ocrResultAdd(ocrResultList, field, inputText, text, probability, imgPath, value.getFieldName() + "参数未获取到结果", false); - } else if ("1".equals(ruleInfo) && StringUtils.isNotBlank(text)) { - //不必校验,有值就行,通过 - fieldRightMap.put(field, true); - ocrResultAdd(ocrResultList, field, inputText, text, probability, imgPath, "", true); - } else if ("0".equals(ruleInfo)) { - //必定验证参数,必须有值且匹配 - if (StringUtils.isBlank(inputText) || text.contains(inputText)) { + if (ocrArray.size()>0) { + ocrArrayFor: for (int i = 0; i < ocrArray.size(); i++) { + JSONObject ocrItem = ocrArray.get(i); + text = ocrItem.getString("text");//ocr 识别的文本 + probability = ocrItem.getDouble("probability");//置信度 + log.info("ocrItem:"); + log.info(ocrItem.toJSONString()); + + if (StringUtils.isBlank(text)) { + //ocr识别参数为空,不通过 + rMessage.append(value.getFieldName() + "参数未获取到结果
"); + mapPutIfTrue(fieldRightMap, field, false); + ocrResultAdd(ocrResultList, field, inputText, text, probability, imgPath, value.getFieldName() + "参数未获取到结果", false); + } else if ("1".equals(ruleInfo) && StringUtils.isNotBlank(text)) { + //不必校验,有值就行,通过 fieldRightMap.put(field, true); ocrResultAdd(ocrResultList, field, inputText, text, probability, imgPath, "", true); - } else { - rMessage.append(value.getFieldName() + "不匹配
"); - mapPutIfTrue(fieldRightMap, field, false); - ocrResultAdd(ocrResultList, field, inputText, text, probability, imgPath, value.getFieldName() + "不匹配", false); + } else if ("0".equals(ruleInfo)) { + //必定验证参数,必须有值且匹配 + if (StringUtils.isBlank(inputText) || text.contains(inputText)) { + fieldRightMap.put(field, true); + ocrResultAdd(ocrResultList, field, inputText, text, probability, imgPath, "", true); + } else { + rMessage.append(value.getFieldName() + "不匹配
"); + mapPutIfTrue(fieldRightMap, field, false); + ocrResultAdd(ocrResultList, field, inputText, text, probability, imgPath, value.getFieldName() + "不匹配", false); + } } } + }else{ + rMessage.append(value.getFieldName() + "参数未获取到结果
"); + mapPutIfTrue(fieldRightMap, field, false); + ocrResultAdd(ocrResultList, field, inputText, text, probability, imgPath, value.getFieldName() + "参数未获取到结果", false); } + } else { - rMessage.append(field + "_未查到ocr结果
"); + rMessage.append(value.getFieldName() + "_未查到ocr结果
"); ocrResultAdd(ocrResultList, field, inputText, null, 0d, imgPath, "ocr结果未获取", false); fieldRightMap.put(field, false); } @@ -539,6 +546,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl