|
|
|
@ -33,26 +33,28 @@ public class CallBackWlyUtils {
|
|
|
|
|
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);
|
|
|
|
|
int detailValidationCount=0;
|
|
|
|
|
String taskResultInfo = ocrIdentify.getTaskResultInfo();
|
|
|
|
|
if (StringUtils.isNotBlank(taskResultInfo)) {
|
|
|
|
|
//循环获取哪些字段通过了
|
|
|
|
|
List<JSONObject> taskResultInfoList = JSONArray.parseArray(taskResultInfo).toJavaList(JSONObject.class);
|
|
|
|
|
detail_detailCount=taskResultInfoList.size();
|
|
|
|
|
for (JSONObject jsonObject : taskResultInfoList) {
|
|
|
|
|
Boolean ruleValidation = (Boolean) jsonObject.getOrDefault("ruleValidation", false);
|
|
|
|
|
if (ruleValidation) {
|
|
|
|
|
//通过了,
|
|
|
|
|
detailValidationCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//组装回调参数
|
|
|
|
|
//成功率
|
|
|
|
|
double imageTagRetrievePercentage = 0.0d;
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|