master
周文涛 2 years ago
parent b3b7fac351
commit 9e6fa254f7

@ -147,27 +147,28 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
ocrArray.addAll(jsonArray.toJavaList(JSONObject.class));
}
}
ocrArrayFor:
for (int i = 0; i < ocrArray.size(); i++) {
ocrArrayFor: for (int i = 0; i < ocrArray.size(); i++) {
JSONObject ocrItem = ocrArray.get(i);
text = ocrItem.getString("text");//ocr 识别的文本
probability = ocrItem.getDouble("probability");//置信度
if(inputText==null){
ocrResultAdd(ocrResultList, field, inputText, text, probability, imgPath, "", true);
fieldRightMap.put(field, true);
if (StringUtils.isBlank(text)) {
//ocr识别参数为空不通过
rMessage.append(value.getFieldName() + "参数未获取到结果<br>");
mapPutIfTrue(fieldRightMap, field, false);
ocrResultAdd(ocrResultList, field, inputText, text, probability, imgPath, value.getFieldName() + "参数未获取到结果", false);
} else if ("1".equals(ruleInfo) && StringUtils.isNotBlank(text)) {
// 1 不需要校验只需要有返回ocr识别值
//不必校验,有值就行,通过
fieldRightMap.put(field, true);
ocrResultAdd(ocrResultList, field, inputText, text, probability, imgPath, "", true);
} 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 {
if (StringUtils.isBlank(text) || !text.contains(inputText)) {
//识别结果为空,识别结果 匹配不上 校验文本
mapPutIfTrue(fieldRightMap, field, false);
rMessage.append(value.getFieldName() + "不匹配<br>");
mapPutIfTrue(fieldRightMap, field, false);
ocrResultAdd(ocrResultList, field, inputText, text, probability, imgPath, value.getFieldName() + "不匹配", false);
} else {
ocrResultAdd(ocrResultList, field, inputText, text, probability, imgPath, "", true);
fieldRightMap.put(field, true);
}
}
}
@ -194,9 +195,6 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
ocrApiCallStatisticsService.updateLogsEndTime(ocrApiCallStatisticsId, new Date());
}
public static String semanticResponse = "{\"execution_time\":69.1751720905304,\"img_path\":\"./static/ocrData/custom_2_44.jpg\",\"message\":\"成功\",\"semantic_result\":{\"医院名称\":[{\"area\":[[227,382],[441,388],[440,422],[226,416]],\"end\":7,\"ocrText\":\"开封市眼病医院\",\"probability\":0.9677108957485778,\"start\":0,\"text\":\"开封市眼病医院\"}],\"姓名\":[{\"area\":[[566,668],[691,668],[691,712],[566,712]],\"end\":3,\"ocrText\":\"闫利霞\",\"probability\":0.884488371938783,\"start\":0,\"text\":\"闫利霞\"}],\"时间\":[{\"area\":[[701,400],[874,400],[874,456],[701,456]],\"end\":5,\"ocrText\":\"10:40\",\"probability\":0.9626484940814066,\"start\":0,\"text\":\"10:40\"},{\"area\":[[502,422],[667,424],[667,452],[502,450]],\"end\":11,\"ocrText\":\"2023年05月17日\",\"probability\":0.815085233546764,\"start\":0,\"text\":\"2023年05月17日\"}],\"科室\":[]},\"task_id\":1}";
public static String semanticUrl = "http://111.202.228.113:7003/semantic";
@Override
@Async
public void postSemantic(OcrIdentify ocrIdentify, List<String> identifyUrlList) {
@ -403,6 +401,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
/**
*
*
* @param jsonObject
* @return
*/

Loading…
Cancel
Save