|
|
|
|
@ -67,12 +67,12 @@ var auSimCmd = &cobra.Command{
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(exception.New("OCR请求失败:" + err.Error()))
|
|
|
|
|
}
|
|
|
|
|
info := extractInfoFromOCR(ocrText)
|
|
|
|
|
info := extractInfoFromOCR(ocrText, "")
|
|
|
|
|
//只要返回结果中存在空值的,就再调用另外的接口
|
|
|
|
|
if info.Name == "" || info.Phone == "" || info.School == "" || info.Amount == "" {
|
|
|
|
|
ocrTextBaidu := callOCRBaidu(base64Str, tokenBaidu)
|
|
|
|
|
logkit.Info("¥成功调用百度OCR")
|
|
|
|
|
infoBaidu := extractInfoFromOCR(ocrTextBaidu)
|
|
|
|
|
infoBaidu := extractInfoFromOCR(ocrTextBaidu, "")
|
|
|
|
|
//合并
|
|
|
|
|
if info.Name == "" {
|
|
|
|
|
info.Name = infoBaidu.Name
|
|
|
|
|
@ -87,25 +87,10 @@ var auSimCmd = &cobra.Command{
|
|
|
|
|
info.Amount = infoBaidu.Amount
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//号码里包含了这些敏感数字
|
|
|
|
|
//号码里包含了充值的这些敏感数字,就把号码从combined删除了重新再提取一次
|
|
|
|
|
if info.Phone != "" && (strings.Contains(info.Phone, "200") || strings.Contains(info.Phone, "100") || strings.Contains(info.Phone, "50")) {
|
|
|
|
|
if info.Name != "" {
|
|
|
|
|
combined := strings.Join(ocrText, "")
|
|
|
|
|
context := getContext(combined, info.Name, 30)
|
|
|
|
|
if strings.Contains(context, info.Phone) {
|
|
|
|
|
newName := "fail/" + file.Name() + ".phone.jpg"
|
|
|
|
|
newPath := filepath.Join(imageDir, newName)
|
|
|
|
|
os.Rename(fullPath, newPath)
|
|
|
|
|
logkit.Info("业务员:" + info.Name + " 学校:" + info.School + " 首充:" + info.Amount + " 号码:" + info.Phone + " 号码里包含充值敏感数字,可能会误识别!")
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
newName := "fail/" + file.Name() + ".phone.jpg"
|
|
|
|
|
newPath := filepath.Join(imageDir, newName)
|
|
|
|
|
os.Rename(fullPath, newPath)
|
|
|
|
|
logkit.Info("业务员:" + info.Name + " 学校:" + info.School + " 首充:" + info.Amount + " 号码:" + info.Phone + " 号码里包含充值敏感数字,可能会误识别!")
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
infoRedo := extractInfoFromOCR(ocrText, info.Phone)
|
|
|
|
|
info.Amount = infoRedo.Amount
|
|
|
|
|
}
|
|
|
|
|
if info.Phone != "" && containsBroadband(ocrText) {
|
|
|
|
|
newName := "broadband/" + file.Name()
|
|
|
|
|
@ -187,8 +172,11 @@ func callOCR(b64 string) []string {
|
|
|
|
|
return texts
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func extractInfoFromOCR(texts []string) ExtractedInfo {
|
|
|
|
|
func extractInfoFromOCR(texts []string, delPhone string) ExtractedInfo {
|
|
|
|
|
combined := strings.Join(texts, "")
|
|
|
|
|
if delPhone != "" {
|
|
|
|
|
combined = strings.Replace(combined, delPhone, "", -1)
|
|
|
|
|
}
|
|
|
|
|
info := ExtractedInfo{}
|
|
|
|
|
// 提取手机号
|
|
|
|
|
re := regexp.MustCompile(`(?:XH[^\x00-\xff]|H势|势|XH).*?(\d{11})`)
|
|
|
|
|
|