|
@@ -16,6 +16,7 @@ import (
|
|
|
"log-server/service/cache"
|
|
"log-server/service/cache"
|
|
|
"net/http"
|
|
"net/http"
|
|
|
"net/url"
|
|
"net/url"
|
|
|
|
|
+ "regexp"
|
|
|
"strconv"
|
|
"strconv"
|
|
|
"strings"
|
|
"strings"
|
|
|
"time"
|
|
"time"
|
|
@@ -160,23 +161,25 @@ func (s *ImageRecordService) ImageIdentify(record levelMonitor.ImageRecord, key
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- identify := 0
|
|
|
|
|
|
|
+ identify := 0.00
|
|
|
if data.WordsResultNum == 0 {
|
|
if data.WordsResultNum == 0 {
|
|
|
s.UpdateImageRecordStatus(record.Id, string(body), -1, 0, 0)
|
|
s.UpdateImageRecordStatus(record.Id, string(body), -1, 0, 0)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if len(data.WordsResult) > 1 {
|
|
|
|
|
- for _, words := range data.WordsResult {
|
|
|
|
|
- i, err := strconv.Atoi(words.Words)
|
|
|
|
|
- if err == nil {
|
|
|
|
|
- identify = i
|
|
|
|
|
- break
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ i, err := strconv.ParseFloat(data.WordsResult[0].Words, 64)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ // 定义价格提取的正则表达式模式
|
|
|
|
|
+ identifyPattern := `([0-9]+(?:\.[0-9]{1,2})?)`
|
|
|
|
|
+ // 编译正则表达式
|
|
|
|
|
+ re := regexp.MustCompile(identifyPattern)
|
|
|
|
|
+ // 使用正则表达式查找价格信息
|
|
|
|
|
+ level := re.FindAllString(data.WordsResult[0].Words, -1)
|
|
|
|
|
+ l, _ := strconv.ParseFloat(level[0], 64)
|
|
|
|
|
+ identify = l
|
|
|
} else {
|
|
} else {
|
|
|
- i, _ := strconv.Atoi(data.WordsResult[0].Words)
|
|
|
|
|
identify = i
|
|
identify = i
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
if identify == 0 {
|
|
if identify == 0 {
|
|
|
s.UpdateImageRecordStatus(record.Id, string(body), -1, 0, 0)
|
|
s.UpdateImageRecordStatus(record.Id, string(body), -1, 0, 0)
|
|
|
return
|
|
return
|
|
@@ -190,7 +193,7 @@ func (s *ImageRecordService) ImageIdentify(record levelMonitor.ImageRecord, key
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (s *ImageRecordService) UpdateImageRecordStatus(id int, result string, status int, useNum, identify int) {
|
|
|
|
|
|
|
+func (s *ImageRecordService) UpdateImageRecordStatus(id int, result string, status int, useNum int, identify float64) {
|
|
|
update := map[string]interface{}{
|
|
update := map[string]interface{}{
|
|
|
"result": result,
|
|
"result": result,
|
|
|
"status": status,
|
|
"status": status,
|
|
@@ -235,7 +238,7 @@ func Request(baiduToken, content string) (body []byte, err error) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 更新game_acount
|
|
// 更新game_acount
|
|
|
-func UpdateGameAccountIdentify(account string, gameId int, identify int) {
|
|
|
|
|
|
|
+func UpdateGameAccountIdentify(account string, gameId int, identify float64) {
|
|
|
global.GVA_DB.Table("game_account").Where("game_id", gameId).Where("account", account).Update("identify", identify)
|
|
global.GVA_DB.Table("game_account").Where("game_id", gameId).Where("account", account).Update("identify", identify)
|
|
|
}
|
|
}
|
|
|
|
|
|