master
周文涛 2 years ago
parent 27ad210e89
commit 4012766341

@ -121,7 +121,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
Map<String, CheckSemanticModel> checkSemanticModelMap = getCheckSemanticModelMap(ocrRuleCheckVo.getConfigRuleMap(), ocrRuleCheckVo.getFieldMap(), ocrIdentifyVo.getSourceJsonObjects()); Map<String, CheckSemanticModel> checkSemanticModelMap = getCheckSemanticModelMap(ocrRuleCheckVo.getConfigRuleMap(), ocrRuleCheckVo.getFieldMap(), ocrIdentifyVo.getSourceJsonObjects());
//// ////
String text;//ocr 识别的文本, String text=null;//ocr 识别的文本,
Double probability = 0d; Double probability = 0d;
//用于数据结构化的对象 //用于数据结构化的对象
List<OcrResult> ocrResultList = new ArrayList<>(); List<OcrResult> ocrResultList = new ArrayList<>();
@ -147,36 +147,43 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
ocrArray.addAll(jsonArray.toJavaList(JSONObject.class)); ocrArray.addAll(jsonArray.toJavaList(JSONObject.class));
} }
} }
ocrArrayFor: for (int i = 0; i < ocrArray.size(); i++) { if (ocrArray.size()>0) {
JSONObject ocrItem = ocrArray.get(i); ocrArrayFor: for (int i = 0; i < ocrArray.size(); i++) {
text = ocrItem.getString("text");//ocr 识别的文本 JSONObject ocrItem = ocrArray.get(i);
probability = ocrItem.getDouble("probability");//置信度 text = ocrItem.getString("text");//ocr 识别的文本
log.info("ocrItem:"); probability = ocrItem.getDouble("probability");//置信度
log.info(ocrItem.toJSONString()); log.info("ocrItem:");
log.info(ocrItem.toJSONString());
if (StringUtils.isBlank(text)) {
//ocr识别参数为空不通过 if (StringUtils.isBlank(text)) {
rMessage.append(value.getFieldName() + "参数未获取到结果<br>"); //ocr识别参数为空不通过
mapPutIfTrue(fieldRightMap, field, false); rMessage.append(value.getFieldName() + "参数未获取到结果<br>");
ocrResultAdd(ocrResultList, field, inputText, text, probability, imgPath, value.getFieldName() + "参数未获取到结果", false); mapPutIfTrue(fieldRightMap, field, false);
} else if ("1".equals(ruleInfo) && StringUtils.isNotBlank(text)) { 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)) {
fieldRightMap.put(field, true); fieldRightMap.put(field, true);
ocrResultAdd(ocrResultList, field, inputText, text, probability, imgPath, "", true); ocrResultAdd(ocrResultList, field, inputText, text, probability, imgPath, "", true);
} else { } else if ("0".equals(ruleInfo)) {
rMessage.append(value.getFieldName() + "不匹配<br>"); //必定验证参数,必须有值且匹配
mapPutIfTrue(fieldRightMap, field, false); if (StringUtils.isBlank(inputText) || text.contains(inputText)) {
ocrResultAdd(ocrResultList, field, inputText, text, probability, imgPath, value.getFieldName() + "不匹配", false); fieldRightMap.put(field, true);
ocrResultAdd(ocrResultList, field, inputText, text, probability, imgPath, "", true);
} else {
rMessage.append(value.getFieldName() + "不匹配<br>");
mapPutIfTrue(fieldRightMap, field, false);
ocrResultAdd(ocrResultList, field, inputText, text, probability, imgPath, value.getFieldName() + "不匹配", false);
}
} }
} }
}else{
rMessage.append(value.getFieldName() + "参数未获取到结果<br>");
mapPutIfTrue(fieldRightMap, field, false);
ocrResultAdd(ocrResultList, field, inputText, text, probability, imgPath, value.getFieldName() + "参数未获取到结果", false);
} }
} else { } else {
rMessage.append(field + "_未查到ocr结果<br>"); rMessage.append(value.getFieldName() + "_未查到ocr结果<br>");
ocrResultAdd(ocrResultList, field, inputText, null, 0d, imgPath, "ocr结果未获取", false); ocrResultAdd(ocrResultList, field, inputText, null, 0d, imgPath, "ocr结果未获取", false);
fieldRightMap.put(field, false); fieldRightMap.put(field, false);
} }
@ -539,6 +546,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
requestBody.put("task_id", task_id); requestBody.put("task_id", task_id);
requestBody.put("img_path", image); requestBody.put("img_path", image);
JSONObject semanticResponseJson = RestUtil.post(OcrConstant.api_test_identify_url, requestBody); JSONObject semanticResponseJson = RestUtil.post(OcrConstant.api_test_identify_url, requestBody);
//semanticResponseJson = JSONObject.parseObject("{\"医院名称\":[{\"area\":[[361,93],[623,39],[630,73],[368,127]],\"end\":6,\"ocrText\":\"黑石社区医院\",\"probability\":0.9874083762059627,\"start\":0,\"text\":\"黑石社区医院\"}],\"姓名\":[],\"时间\":[],\"科室\":[]}");
semanticResponseJson.put("identifyId", masterTaskId); semanticResponseJson.put("identifyId", masterTaskId);
this.getSemanticInfo(semanticResponseJson); this.getSemanticInfo(semanticResponseJson);
//该子任务已执行,判断主任务是否残留 //该子任务已执行,判断主任务是否残留

Loading…
Cancel
Save