|
|
|
@ -18,6 +18,7 @@ import org.jeecg.modules.ocr.mapper.OcrIdentifyMapper;
|
|
|
|
|
import org.jeecg.modules.ocr.model.*;
|
|
|
|
|
import org.jeecg.modules.ocr.service.*;
|
|
|
|
|
import org.jeecg.modules.ocr.utils.ArrayOUtils;
|
|
|
|
|
import org.jeecg.modules.ocr.utils.StrCharUtil;
|
|
|
|
|
import org.jeecg.modules.ocr.vo.OcrIdentifyVo;
|
|
|
|
|
import org.jeecg.modules.ocr.vo.OcrRuleCheckVo;
|
|
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
|
@ -154,13 +155,14 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
|
|
|
|
|
ocrResultAdd(ocrResultList,value.getFieldName(), field, inputText, text, probability, imgPath, "", true);
|
|
|
|
|
} else if ("0".equals(ruleInfo)) {
|
|
|
|
|
//必定验证参数,必须有值且匹配
|
|
|
|
|
double v = StrCharUtil.similarityRatio(inputText, text);
|
|
|
|
|
if (StringUtils.isBlank(inputText) || text.contains(inputText) || inputText.contains(text)) {
|
|
|
|
|
fieldRightMap.put(field, true);
|
|
|
|
|
ocrResultAdd(ocrResultList,value.getFieldName(), field, inputText, text, probability, imgPath, "", true);
|
|
|
|
|
ocrResultAdd(ocrResultList,value.getFieldName(), field, inputText, text, probability, imgPath, "", true,v);
|
|
|
|
|
} else {
|
|
|
|
|
rMessage.append(value.getFieldName() + "不匹配<br>");
|
|
|
|
|
mapPutIfTrue(fieldRightMap, field, false);
|
|
|
|
|
ocrResultAdd(ocrResultList,value.getFieldName(), field, inputText, text, probability, imgPath, value.getFieldName() + "不匹配", false);
|
|
|
|
|
ocrResultAdd(ocrResultList,value.getFieldName(), field, inputText, text, probability, imgPath, value.getFieldName() + "不匹配", false,v);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -364,13 +366,14 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
|
|
|
|
|
ocrResultAdd(ocrResultList,value.getFieldName(), field, inputText, text, probability, imgPath, "", true);
|
|
|
|
|
} else if ("0".equals(ruleInfo)) {
|
|
|
|
|
//必定验证参数,必须有值且匹配
|
|
|
|
|
double v = StrCharUtil.similarityRatio(inputText, text);
|
|
|
|
|
if (StringUtils.isBlank(inputText) || text.contains(inputText) || inputText.contains(text)) {
|
|
|
|
|
fieldRightMap.put(field, true);
|
|
|
|
|
ocrResultAdd(ocrResultList,value.getFieldName(), field, inputText, text, probability, imgPath, "", true);
|
|
|
|
|
ocrResultAdd(ocrResultList,value.getFieldName(), field, inputText, text, probability, imgPath, "", true,v);
|
|
|
|
|
} else {
|
|
|
|
|
rMessage.append(value.getFieldName() + "_参数不匹配<br>");
|
|
|
|
|
mapPutIfTrue(fieldRightMap, field, false);
|
|
|
|
|
ocrResultAdd(ocrResultList,value.getFieldName(), field, inputText, text, probability, imgPath, value.getFieldName() + "_参数不匹配", false);
|
|
|
|
|
ocrResultAdd(ocrResultList,value.getFieldName(), field, inputText, text, probability, imgPath, value.getFieldName() + "_参数不匹配", false,v);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -477,6 +480,27 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
|
|
|
|
|
super.update(updateWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
int stringPercent = getStringPercent("张三", "张三脏");
|
|
|
|
|
System.out.println(stringPercent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static int getStringPercent(String text, String inputText) {
|
|
|
|
|
String[] inputTextSplit = inputText.split(".");
|
|
|
|
|
String[] textSplit = text.split(".");
|
|
|
|
|
int trueNum=0;
|
|
|
|
|
for (int i = 0; i < inputTextSplit.length; i++) {
|
|
|
|
|
if (textSplit.length>=i){
|
|
|
|
|
for (int p = 0; p < textSplit.length; p++) {
|
|
|
|
|
trueNum++;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void callbackWly(String ocrIdentifyId){
|
|
|
|
|
OcrIdentifyCallbackLog ocrIdentifyCallbackLog=new OcrIdentifyCallbackLog();
|
|
|
|
@ -576,25 +600,18 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 将数据 疯转成 OcrResult,追加到 ocrResultList
|
|
|
|
|
*
|
|
|
|
|
* @param ocrResultList
|
|
|
|
|
* @param field
|
|
|
|
|
* @param inputText
|
|
|
|
|
* @param ocrText
|
|
|
|
|
* @param ocrPrecisionRate
|
|
|
|
|
* @param imgPath
|
|
|
|
|
* @param failureReason
|
|
|
|
|
*/
|
|
|
|
|
public static void ocrResultAdd(List<OcrResult> ocrResultList,String fieldName, String field, String inputText, String ocrText, Double ocrPrecisionRate, String imgPath, String failureReason, Boolean ruleValidation) {
|
|
|
|
|
public static void ocrResultAdd(List<OcrResult> ocrResultList,String fieldName, String field, String inputText, String ocrText, Double ocrPrecisionRate, String imgPath, String failureReason, Boolean ruleValidation,Double d) {
|
|
|
|
|
OcrResult ocrResult = new OcrResult();
|
|
|
|
|
ocrResult.setTag(field);
|
|
|
|
|
ocrResult.setTagName(fieldName);
|
|
|
|
|
ocrResult.setOcrText(ocrText);
|
|
|
|
|
ocrResult.setInputText(inputText);
|
|
|
|
|
ocrResult.setOcrPrecisionRate(ocrPrecisionRate == null ? 0d : ocrPrecisionRate);
|
|
|
|
|
|
|
|
|
|
if (d==null) {
|
|
|
|
|
ocrResult.setTextRate(0d);
|
|
|
|
|
}else{
|
|
|
|
|
ocrResult.setTextRate(new BigDecimal(d).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
|
|
}
|
|
|
|
|
System.out.println("-----------------");
|
|
|
|
|
System.out.println(failureReason);
|
|
|
|
|
System.out.println("-----------------");
|
|
|
|
@ -613,6 +630,25 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
|
|
|
|
|
ocrResultList.add(ocrResult);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 将数据 疯转成 OcrResult,追加到 ocrResultList
|
|
|
|
|
*
|
|
|
|
|
* @param ocrResultList
|
|
|
|
|
* @param field
|
|
|
|
|
* @param inputText
|
|
|
|
|
* @param ocrText
|
|
|
|
|
* @param ocrPrecisionRate
|
|
|
|
|
* @param imgPath
|
|
|
|
|
* @param failureReason
|
|
|
|
|
*/
|
|
|
|
|
public static void ocrResultAdd(List<OcrResult> ocrResultList,String fieldName, String field, String inputText, String ocrText, Double ocrPrecisionRate, String imgPath, String failureReason, Boolean ruleValidation) {
|
|
|
|
|
if (ruleValidation) {
|
|
|
|
|
ocrResultAdd(ocrResultList,fieldName,field,inputText,ocrText,ocrPrecisionRate,imgPath,failureReason,ruleValidation,100d);
|
|
|
|
|
}else{
|
|
|
|
|
ocrResultAdd(ocrResultList,fieldName,field,inputText,ocrText,ocrPrecisionRate,imgPath,failureReason,ruleValidation,0d);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 组装 checkSemanticModelMap
|
|
|
|
|
*
|
|
|
|
|