|
|
|
@ -243,9 +243,51 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
|
|
|
|
updateWrapper.eq(OcrIdentify::getId, id);
|
|
|
|
updateWrapper.eq(OcrIdentify::getId, id);
|
|
|
|
updateWrapper.set(OcrIdentify::getEndTime, new Date());
|
|
|
|
updateWrapper.set(OcrIdentify::getEndTime, new Date());
|
|
|
|
updateWrapper.set(OcrIdentify::getStatus, "1");
|
|
|
|
updateWrapper.set(OcrIdentify::getStatus, "1");
|
|
|
|
|
|
|
|
/*获取 明细 的成功或失败.*/
|
|
|
|
|
|
|
|
List<OcrIdentifyDetail> identifyDetailList = ocrIdentifyDetailService.listByIdentifyId(id);
|
|
|
|
|
|
|
|
if(true) {
|
|
|
|
|
|
|
|
if (identifyDetailList != null && identifyDetailList.size() > 0) {
|
|
|
|
|
|
|
|
Map<String, OcrResult> fieldRightMap = new LinkedHashMap<>();
|
|
|
|
|
|
|
|
String tag = null;
|
|
|
|
|
|
|
|
boolean ruleValidation = false;
|
|
|
|
|
|
|
|
/////明细中,如果有字段成功的,则会覆盖其他明细的匹配失败的情况,如果全都是失败的,会获取第一次失败的.
|
|
|
|
|
|
|
|
for (OcrIdentifyDetail ocrIdentifyDetail : identifyDetailList) {
|
|
|
|
|
|
|
|
String dataStructured = ocrIdentifyDetail.getDataStructured();
|
|
|
|
|
|
|
|
if (org.apache.commons.lang.StringUtils.isNotBlank(dataStructured)) {
|
|
|
|
|
|
|
|
JSONArray jsonArray = JSONObject.parseArray(dataStructured);
|
|
|
|
|
|
|
|
List<OcrResult> resultList = jsonArray.toJavaList(OcrResult.class);
|
|
|
|
|
|
|
|
for (OcrResult result : resultList) {
|
|
|
|
|
|
|
|
tag = result.getTag();
|
|
|
|
|
|
|
|
ruleValidation = result.getRuleValidation();
|
|
|
|
|
|
|
|
OcrResult lastResult = fieldRightMap.get(tag);
|
|
|
|
|
|
|
|
if (ruleValidation) {
|
|
|
|
|
|
|
|
fieldRightMap.put(tag, result);
|
|
|
|
|
|
|
|
} else if (lastResult == null && !lastResult.getRuleValidation()) {
|
|
|
|
|
|
|
|
fieldRightMap.put(tag, result);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//如果明细合并一起,都是成功,则主任务 匹配成功, 否则匹配失败
|
|
|
|
|
|
|
|
List<OcrResult> errorResults = fieldRightMap.values().stream().filter(f -> !f.getRuleValidation()).collect(Collectors.toList());
|
|
|
|
|
|
|
|
List<OcrResult> ocrResults = fieldRightMap.values().stream().collect(Collectors.toList());
|
|
|
|
|
|
|
|
String taskResultInfo = JSONArray.toJSONString(ocrResults);
|
|
|
|
|
|
|
|
updateWrapper.set(OcrIdentify::getTaskResultInfo,taskResultInfo);
|
|
|
|
|
|
|
|
if (errorResults.size() > 0) {
|
|
|
|
|
|
|
|
//匹配失败.
|
|
|
|
|
|
|
|
String errorMsg = errorResults.stream().map(e -> e.getFailureReason()).collect(Collectors.joining(";"));
|
|
|
|
|
|
|
|
updateWrapper.set(OcrIdentify::getErrorMsg, errorMsg);
|
|
|
|
|
|
|
|
updateWrapper.set(OcrIdentify::getTaskResult, 0);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
//匹配成功.
|
|
|
|
|
|
|
|
updateWrapper.set(OcrIdentify::getTaskResult, 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
super.update(updateWrapper);
|
|
|
|
super.update(updateWrapper);
|
|
|
|
|
|
|
|
|
|
|
|
this.callbackWly(id);
|
|
|
|
this.callbackWly(id);
|
|
|
|
System.out.println("已通过一条!");
|
|
|
|
/*System.out.println("已通过一条!");*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
|