回传匹配度调整
chj_ocr
周文涛 2 years ago
parent 1c3ba1028a
commit ce00cf05c0

@ -18,6 +18,7 @@ import org.jeecg.modules.ocr.service.IOcrIdentifyDetailService;
import org.jeecg.modules.ocr.service.IOcrIdentifyService; import org.jeecg.modules.ocr.service.IOcrIdentifyService;
import org.jeecg.modules.ocr.service.IOcrRuleCheckService; import org.jeecg.modules.ocr.service.IOcrRuleCheckService;
import org.jeecg.modules.ocr.service.impl.TaskService; import org.jeecg.modules.ocr.service.impl.TaskService;
import org.jeecg.modules.ocr.utils.CallBackWlyUtils;
import org.jeecg.modules.ocr.utils.FileOUtils; import org.jeecg.modules.ocr.utils.FileOUtils;
import org.jeecg.modules.ocr.utils.ImageUtils; import org.jeecg.modules.ocr.utils.ImageUtils;
import org.jeecg.modules.ocr.dto.OcrIdentifyDTO; import org.jeecg.modules.ocr.dto.OcrIdentifyDTO;
@ -255,7 +256,11 @@ public class ApiController {
//ocrIdentifyService.getSemanticInfo(semanticResponseJson); //ocrIdentifyService.getSemanticInfo(semanticResponseJson);
/*OcrRuleCheckVo ocrRuleCheckVo = byId.getOcrRuleCheckVo(); /*OcrRuleCheckVo ocrRuleCheckVo = byId.getOcrRuleCheckVo();
Map<String, String> configRuleMap = ocrRuleCheckVo.getConfigRuleMap();*/ Map<String, String> configRuleMap = ocrRuleCheckVo.getConfigRuleMap();*/
OcrIdentifyDTO identifyDTO = ocrIdentifyService.findById("1703642249574752258");
List<OcrIdentifyDetail> identifyDetailList = ocrIdentifyDetailService.listByIdentifyId(identifyDTO.getId());
CallBackWlyUtils.callbackWly(identifyDTO,identifyDetailList);
return Result.OK(""); return Result.OK("");
} }
} }

@ -529,7 +529,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
configRuleMap.put("doctorName", value); configRuleMap.put("doctorName", value);
}else if("dmn".equals(s)) { }else if("dmn".equals(s)) {
configRuleMap.put("departmentName", value); configRuleMap.put("departmentName", value);
}else if("time".equals(s)) { }else if("tm".equals(s) || ("time".equals(s))) {
configRuleMap.put("time", value); configRuleMap.put("time", value);
} }
} }

@ -33,26 +33,28 @@ public class CallBackWlyUtils {
CallBackWlyResult result = new CallBackWlyResult(); CallBackWlyResult result = new CallBackWlyResult();
List<JSONObject> jsonObjects = new ArrayList<>(); List<JSONObject> jsonObjects = new ArrayList<>();
//成功率
BigDecimal textRateBigd = new BigDecimal(0);
//总明细数量 //总明细数量
int detail_detailCount = 0; int detail_detailCount = 0;
for (OcrIdentifyDetail identifyDetail : identifyDetails) { int detailValidationCount=0;
if (StringUtils.isNotBlank(identifyDetail.getDataStructured())) { String taskResultInfo = ocrIdentify.getTaskResultInfo();
List<JSONObject> jsonObjects1 = JSONArray.parseArray(identifyDetail.getDataStructured()).toJavaList(JSONObject.class); if (StringUtils.isNotBlank(taskResultInfo)) {
if (CollectionUtils.isNotEmpty(jsonObjects1)) { //循环获取哪些字段通过了
double textRate = jsonObjects.stream().mapToDouble(o->o.getDouble("textRate")).sum(); List<JSONObject> taskResultInfoList = JSONArray.parseArray(taskResultInfo).toJavaList(JSONObject.class);
textRateBigd = textRateBigd.add(new BigDecimal(textRate)); detail_detailCount=taskResultInfoList.size();
detail_detailCount += jsonObjects1.size(); for (JSONObject jsonObject : taskResultInfoList) {
jsonObjects.addAll(jsonObjects1); Boolean ruleValidation = (Boolean) jsonObject.getOrDefault("ruleValidation", false);
if (ruleValidation) {
//通过了,
detailValidationCount++;
} }
} }
} }
//组装回调参数 //组装回调参数
//成功率
double imageTagRetrievePercentage = 0.0d; double imageTagRetrievePercentage = 0.0d;
if (detail_detailCount > 0) { if (detail_detailCount > 0) {
BigDecimal divide = textRateBigd.divide(new BigDecimal(detail_detailCount), 2, RoundingMode.HALF_UP); BigDecimal divide = new BigDecimal(detailValidationCount).divide(new BigDecimal(detail_detailCount), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
imageTagRetrievePercentage = divide.doubleValue(); imageTagRetrievePercentage = divide.doubleValue();
} }
if (StringUtils.isNotBlank(ocrIdentify.getTaskResult()) && "1".equals(ocrIdentify.getTaskResult())) { if (StringUtils.isNotBlank(ocrIdentify.getTaskResult()) && "1".equals(ocrIdentify.getTaskResult())) {
@ -95,4 +97,52 @@ public class CallBackWlyUtils {
} }
} }
} }
public static boolean callbackWly2(OcrIdentify ocrIdentify, List<OcrIdentifyDetail> identifyDetails) {
String requestId = ocrIdentify.getRequestId();
//请求对象
CallBackWlyResult result = new CallBackWlyResult();
List<JSONObject> jsonObjects = new ArrayList<>();
//成功率
BigDecimal textRateBigd = new BigDecimal(0);
//总明细数量
int detail_detailCount = 0;
for (OcrIdentifyDetail identifyDetail : identifyDetails) {
if (StringUtils.isNotBlank(identifyDetail.getDataStructured())) {
List<JSONObject> jsonObjects1 = JSONArray.parseArray(identifyDetail.getDataStructured()).toJavaList(JSONObject.class);
if (CollectionUtils.isNotEmpty(jsonObjects1)) {
double textRate = jsonObjects.stream().mapToDouble(o->o.getDouble("textRate")).sum();
textRateBigd = textRateBigd.add(new BigDecimal(textRate));
detail_detailCount += jsonObjects1.size();
jsonObjects.addAll(jsonObjects1);
}
}
}
//组装回调参数
double imageTagRetrievePercentage = 0.0d;
if (detail_detailCount > 0) {
BigDecimal divide = textRateBigd.divide(new BigDecimal(detail_detailCount), 2, RoundingMode.HALF_UP);
imageTagRetrievePercentage = divide.doubleValue();
}
if (StringUtils.isNotBlank(ocrIdentify.getTaskResult()) && "1".equals(ocrIdentify.getTaskResult())) {
result.setRuleValidation(true);
}else{
result.setRuleValidation(false);
}
result.setImageTagRetrievePercentage(imageTagRetrievePercentage + "");
result.setRetrieveReviewCompliance(imageTagRetrievePercentage+"");
result.setFailureReason(ocrIdentify.getErrorMsg());
if (CollectionUtils.isEmpty(jsonObjects)) {
return false;
}
result.setOcrResult(jsonObjects);
log.info("请求无量云回调接口");
JSONObject semanticResponseJson = null;
return false;
}
} }

Loading…
Cancel
Save