master
周文涛 2 years ago
parent ee6b061f8e
commit 801c6f2dbc

@ -142,7 +142,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
ocrIdentifyDetail.setStatus(""); ocrIdentifyDetail.setStatus("");
ocrIdentifyDetail.setMessage(message); ocrIdentifyDetail.setMessage(message);
ocrIdentifyDetail.setExecutionTime(executionTime / 1000); ocrIdentifyDetail.setExecutionTime(executionTime / 1000);
ocrIdentifyDetail.setSemanticResult(semanticResult.toJSONString()); ocrIdentifyDetail.setSemanticResult(semanticResult.getJSONObject("semantic_result").toJSONString());
ocrIdentifyDetailService.save(ocrIdentifyDetail); ocrIdentifyDetailService.save(ocrIdentifyDetail);
} }
//=================== //===================
@ -165,13 +165,13 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
String inputText = value.getInputText();//校验文本 ocr识别的文本如果不包含该内容则算作失败 String inputText = value.getInputText();//校验文本 ocr识别的文本如果不包含该内容则算作失败
List<String> fieldNameList = Arrays.asList(fieldName.split(",")); List<String> fieldNameList = Arrays.asList(fieldName.split(","));
text = null; text = null;
boolean b = ArrayOUtils.containsStringList(fieldNameList, semanticResult.keySet().stream().collect(Collectors.toList())); boolean b = ArrayOUtils.containsStringList(fieldNameList, semanticResult.getJSONObject("semantic_result").keySet().stream().collect(Collectors.toList()));
//查看ocr识别返回的字段名称中是否有当前这个字段名称 //查看ocr识别返回的字段名称中是否有当前这个字段名称
if (b) { if (b) {
//TODO 注意ocr 识别返回的 字段是多个结果(数组),有一个值匹配上即为正确 //TODO 注意ocr 识别返回的 字段是多个结果(数组),有一个值匹配上即为正确
List<JSONObject> ocrArray = new ArrayList<>(); List<JSONObject> ocrArray = new ArrayList<>();
for (String s : fieldNameList) { for (String s : fieldNameList) {
JSONArray jsonArray = semanticResult.getJSONArray(s); JSONArray jsonArray = semanticResult.getJSONObject("semantic_result").getJSONArray(s);
if (jsonArray != null && jsonArray.size() > 0) { if (jsonArray != null && jsonArray.size() > 0) {
ocrArray.addAll(jsonArray.toJavaList(JSONObject.class)); ocrArray.addAll(jsonArray.toJavaList(JSONObject.class));
} }

Loading…
Cancel
Save