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());
////
String text;//ocr 识别的文本,
String text=null;//ocr 识别的文本,
Double probability = 0d;
//用于数据结构化的对象
List<OcrResult> ocrResultList = new ArrayList<>();
@ -147,36 +147,43 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
ocrArray.addAll(jsonArray.toJavaList(JSONObject.class));
}
}
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() + "参数未获取到结果<br>");
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() + "参数未获取到结果<br>");
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() + "不匹配<br>");
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() + "不匹配<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 {
rMessage.append(field + "_未查到ocr结果<br>");
rMessage.append(value.getFieldName() + "_未查到ocr结果<br>");
ocrResultAdd(ocrResultList, field, inputText, null, 0d, imgPath, "ocr结果未获取", false);
fieldRightMap.put(field, false);
}
@ -539,6 +546,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
requestBody.put("task_id", task_id);
requestBody.put("img_path", image);
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);
this.getSemanticInfo(semanticResponseJson);
//该子任务已执行,判断主任务是否残留

Loading…
Cancel
Save