|
@@ -15,6 +15,7 @@ import (
|
|
|
levelRequest "log-server/model/levelMonitor/request"
|
|
levelRequest "log-server/model/levelMonitor/request"
|
|
|
"log-server/model/log"
|
|
"log-server/model/log"
|
|
|
"log-server/service/cache"
|
|
"log-server/service/cache"
|
|
|
|
|
+ "log-server/utils"
|
|
|
"net/http"
|
|
"net/http"
|
|
|
"net/url"
|
|
"net/url"
|
|
|
"regexp"
|
|
"regexp"
|
|
@@ -34,7 +35,7 @@ func (s *ImageRecordService) CreateImageRecord(record levelMonitor.ImageRecord)
|
|
|
key := fmt.Sprintf(cache.UploadImageNum, date, record.TaskId)
|
|
key := fmt.Sprintf(cache.UploadImageNum, date, record.TaskId)
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
num, _ := s.cache.GetCacheNum(ctx, key)
|
|
num, _ := s.cache.GetCacheNum(ctx, key)
|
|
|
- if num > 50 {
|
|
|
|
|
|
|
+ if num > 100 {
|
|
|
return errors.New("数据上传已到上限")
|
|
return errors.New("数据上传已到上限")
|
|
|
}
|
|
}
|
|
|
var entity levelMonitor.ImageRecord
|
|
var entity levelMonitor.ImageRecord
|
|
@@ -50,6 +51,7 @@ func (s *ImageRecordService) CreateImageRecord(record levelMonitor.ImageRecord)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return err
|
|
return err
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
go s.ImageIdentify(record, key)
|
|
go s.ImageIdentify(record, key)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -57,12 +59,12 @@ func (s *ImageRecordService) CreateImageRecord(record levelMonitor.ImageRecord)
|
|
|
func (s *ImageRecordService) CreateLevel(request levelRequest.CreateLevelRequest) (err error) {
|
|
func (s *ImageRecordService) CreateLevel(request levelRequest.CreateLevelRequest) (err error) {
|
|
|
//获取今日日期
|
|
//获取今日日期
|
|
|
date := time.Now().Format("2006-01-02")
|
|
date := time.Now().Format("2006-01-02")
|
|
|
- key := fmt.Sprintf(cache.UploadImageNum, date, request.TaskId)
|
|
|
|
|
- ctx := context.Background()
|
|
|
|
|
- num, _ := s.cache.GetCacheNum(ctx, key)
|
|
|
|
|
- if num > 100 {
|
|
|
|
|
- return errors.New("数据上传已到上限")
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //key := fmt.Sprintf(cache.UploadImageNum, date, request.TaskId)
|
|
|
|
|
+ //ctx := context.Background()
|
|
|
|
|
+ //num, _ := s.cache.GetCacheNum(ctx, key)
|
|
|
|
|
+ //if num > 100 {
|
|
|
|
|
+ // return errors.New("数据上传已到上限")
|
|
|
|
|
+ //}
|
|
|
var entity levelMonitor.ImageRecord
|
|
var entity levelMonitor.ImageRecord
|
|
|
|
|
|
|
|
//查找数据库是否存在此账号此游戏今日等级上报记录
|
|
//查找数据库是否存在此账号此游戏今日等级上报记录
|
|
@@ -85,7 +87,24 @@ func (s *ImageRecordService) CreateLevel(request levelRequest.CreateLevelRequest
|
|
|
return err
|
|
return err
|
|
|
}
|
|
}
|
|
|
UpdateGameAccountIdentify(entity.Account, entity.TaskId, entity.Identify)
|
|
UpdateGameAccountIdentify(entity.Account, entity.TaskId, entity.Identify)
|
|
|
- s.cache.SetCacheNum(ctx, key)
|
|
|
|
|
|
|
+ // 等級》1上報中控
|
|
|
|
|
+ if request.Level > 1 {
|
|
|
|
|
+ s.UpdateControlAccountLevel(request.Account, request.TaskId, request.Level)
|
|
|
|
|
+ }
|
|
|
|
|
+ //s.cache.SetCacheNum(ctx, key)
|
|
|
|
|
+ return
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// http请求群控创建任务
|
|
|
|
|
+func (s *ImageRecordService) UpdateControlAccountLevel(account string, gameId, level int) {
|
|
|
|
|
+ urlControl := global.GVA_CONFIG.ExtranetDomain.Control + "/v1/account/account_level"
|
|
|
|
|
+ //game_id=2003&level=yyyyy
|
|
|
|
|
+ requestData := map[string]string{
|
|
|
|
|
+ "account": account,
|
|
|
|
|
+ "game_id": strconv.Itoa(gameId),
|
|
|
|
|
+ "level": strconv.Itoa(level),
|
|
|
|
|
+ }
|
|
|
|
|
+ _, _ = utils.HttpGet(urlControl, requestData)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -100,7 +119,7 @@ func (s *ImageRecordService) UploadOrNot(record levelMonitor.ImageRecord) (err e
|
|
|
return nil
|
|
return nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//删除三日前的图片记录
|
|
|
|
|
|
|
+//删除7日前的图片记录
|
|
|
func (s *ImageRecordService) DeleteExpireImageRecord() {
|
|
func (s *ImageRecordService) DeleteExpireImageRecord() {
|
|
|
markTime := time.Now().Add(-time.Hour * 48).Format("2006-01-02")
|
|
markTime := time.Now().Add(-time.Hour * 48).Format("2006-01-02")
|
|
|
err := global.GVA_DB.Where("create_date < ?", markTime).Delete(&levelMonitor.ImageRecord{}).Error
|
|
err := global.GVA_DB.Where("create_date < ?", markTime).Delete(&levelMonitor.ImageRecord{}).Error
|
|
@@ -234,11 +253,11 @@ func (s *ImageRecordService) ImageIdentify(record levelMonitor.ImageRecord, key
|
|
|
// 编译正则表达式
|
|
// 编译正则表达式
|
|
|
re := regexp.MustCompile(identifyPattern)
|
|
re := regexp.MustCompile(identifyPattern)
|
|
|
// 使用正则表达式查找价格信息
|
|
// 使用正则表达式查找价格信息
|
|
|
- level := re.FindAllString(data.WordsResult[0].Words, -1)
|
|
|
|
|
|
|
+ upLevel := strings.ReplaceAll(data.WordsResult[0].Words, ",", "")
|
|
|
|
|
+ level := re.FindAllString(upLevel, -1)
|
|
|
if len(level) == 0 {
|
|
if len(level) == 0 {
|
|
|
identify = 0
|
|
identify = 0
|
|
|
} else {
|
|
} else {
|
|
|
- level[0] = strings.ReplaceAll(level[0], ",", "")
|
|
|
|
|
l, _ := strconv.ParseFloat(level[0], 64)
|
|
l, _ := strconv.ParseFloat(level[0], 64)
|
|
|
identify = l
|
|
identify = l
|
|
|
}
|
|
}
|
|
@@ -254,7 +273,9 @@ func (s *ImageRecordService) ImageIdentify(record levelMonitor.ImageRecord, key
|
|
|
global.GVA_DB.Where("game_id", record.TaskId).Where("account", record.Account).First(&gameAccount)
|
|
global.GVA_DB.Where("game_id", record.TaskId).Where("account", record.Account).First(&gameAccount)
|
|
|
s.UpdateImageRecordStatus(record.Id, string(body), 1, gameAccount.UseNum, identify)
|
|
s.UpdateImageRecordStatus(record.Id, string(body), 1, gameAccount.UseNum, identify)
|
|
|
UpdateGameAccountIdentify(record.Account, record.TaskId, identify)
|
|
UpdateGameAccountIdentify(record.Account, record.TaskId, identify)
|
|
|
-
|
|
|
|
|
|
|
+ if identify > 1 && record.TaskId == 5001 {
|
|
|
|
|
+ s.UpdateControlAccountLevel(record.Account, record.TaskId, int(identify))
|
|
|
|
|
+ }
|
|
|
s.cache.SetCacheNum(ctx, key)
|
|
s.cache.SetCacheNum(ctx, key)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -406,7 +427,7 @@ func (s *ImageRecordService) CreateImageRecordStatistics(taskId int, imageRecord
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//获取7日统计数据
|
|
//获取7日统计数据
|
|
|
-func (s *ImageRecordService) GetWeekImageRecordStatistics(taskId int, createDate string) (dataList []levelMonitor.ImageRecordStatisticsResponse, err error){
|
|
|
|
|
|
|
+func (s *ImageRecordService) GetWeekImageRecordStatistics(taskId int, createDate string) (dataList []levelMonitor.ImageRecordStatisticsResponse, err error) {
|
|
|
db := global.GVA_DB.Model(&levelMonitor.ImageRecordStatistics{})
|
|
db := global.GVA_DB.Model(&levelMonitor.ImageRecordStatistics{})
|
|
|
db = db.Select("image_record_statistics.*, game_task.user, game_task.task_name")
|
|
db = db.Select("image_record_statistics.*, game_task.user, game_task.task_name")
|
|
|
db = db.Joins("left join game_task on image_record_statistics.task_id = game_task.task_id")
|
|
db = db.Joins("left join game_task on image_record_statistics.task_id = game_task.task_id")
|
|
@@ -524,4 +545,4 @@ func (s *ImageRecordService) ImageRecordStatisticsListExcel(infoList []levelMoni
|
|
|
}
|
|
}
|
|
|
err := excel.SaveAs(filePath)
|
|
err := excel.SaveAs(filePath)
|
|
|
return err
|
|
return err
|
|
|
-}
|
|
|
|
|
|
|
+}
|