浏览代码

设备异常逻辑更新

wangbin 2 年之前
父节点
当前提交
7fe48aaffd

+ 2 - 2
api/v1/log/loging.go

@@ -613,9 +613,9 @@ func (e *ApiLoging) GetDeviceInfoLog(c *gin.Context) {
 // @Success 200
 // @Router /loging/getDeviceIdErr [post]
 func (e *ApiLoging) GetDeviceIdErr(c *gin.Context) {
-	var paramsInfo request.GetDeviceInfoLogRequest
+	var paramsInfo request.GetDeviceIdErrRequest
 	_ = c.ShouldBindJSON(&paramsInfo)
-	list, total, err := ServiceStatisticsLog.GetDeviceIdErr(c, paramsInfo.DeviceLog, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc)
+	list, total, err := ServiceStatisticsLog.GetDeviceIdErr(c, paramsInfo.ScriptDeviceErr, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc)
 	if err != nil {
 		global.GVA_LOG.Error("获取失败!", zap.Error(err))
 		response.FailWithMessage("获取失败", c)

+ 2 - 0
model/log/device_log.go

@@ -76,6 +76,8 @@ type ScriptDeviceErr struct {
 	CreateTime      time.Time `json:"create_time"` // 创建时间
 	CreateDate      string    `json:"create_date"`
 	Status          uint      `json:"status"` // 1是同一账号不同设备id,2新增出现同一设备id
+	PcCode          string    `json:"pc_code"`
+	Operator        string    `json:"operator"`
 }
 
 func (ScriptDeviceErr) TableName() string {

+ 2 - 0
model/log/device_statistics.go

@@ -15,6 +15,8 @@ type DeviceStatistics struct {
 	NewDeviceIdRate      float64 `json:"new_device_id_rate"`
 	RetainedDeviceIdErr  int     `json:"retained_device_id_err"`
 	RetainedDeviceIdRate float64 `json:"retained_device_id_rate"`
+	DefinedErr           int     `json:"defined_err"`
+	UndefinedErr         int     `json:"undefined_err"`
 }
 
 func (DeviceStatistics) TableName() string {

+ 25 - 0
model/log/err_log.go

@@ -0,0 +1,25 @@
+package log
+
+import (
+	"log-server/global"
+	"time"
+)
+
+type DeviceErrLog struct {
+	Id         uint      `json:"id"`
+	Content    string    `json:"content"`
+	GameId     int       `json:"game_id"`
+	PcCode     string    `json:"pc_code"`
+	CreateDate time.Time `json:"create_date"`
+	CreateTime time.Time `json:"create_time"`
+	Err        string    `json:"err"`
+	Status     uint      `json:"status"`
+}
+
+func (DeviceErrLog) TableName() string {
+	return "device_err_log"
+}
+
+func (m *DeviceErrLog) Create() error {
+	return global.GVA_DB.Create(m).Error
+}

+ 7 - 0
model/log/request/log_statistics.go

@@ -123,3 +123,10 @@ type GetDeviceInfoLogRequest struct {
 	OrderKey string `json:"orderKey"` // 排序
 	Desc     bool   `json:"desc"`     // 排序方式:升序false(默认)|降序true
 }
+
+type GetDeviceIdErrRequest struct {
+	log.ScriptDeviceErr
+	PageInfo
+	OrderKey string `json:"orderKey"` // 排序
+	Desc     bool   `json:"desc"`     // 排序方式:升序false(默认)|降序true
+}

+ 1 - 0
model/log/request/loging.go

@@ -32,6 +32,7 @@ type AddLogRequest struct {
 	DeviceNumber       string `json:"device_number"`
 	DeviceIp           string `json:"device_ip"`
 	ScriptDeviceId     string `json:"script_device_id"`
+	Err                string `json:"err"` // 0或不传表示没有异常,其他表示异常,脚本端自定义
 }
 
 type ReportPointsData struct {

+ 4 - 7
service/fileManager/download_url.go

@@ -41,10 +41,7 @@ func (s *ServiceDownLoadUrl) UpdateGameVersion() {
 			return
 		}
 		dataJson, _ := simplejson.NewJson(result)
-		code, err := dataJson.Get("code").Int()
-		if err != nil {
-			return
-		}
+		code, _ := dataJson.Get("code").Int()
 		//global.GVA_LOG.Info(strconv.Itoa(code))
 		//msg, _ := dataJson.Get("msg").String()
 		//global.GVA_LOG.Info(msg)
@@ -81,7 +78,7 @@ func (s *ServiceDownLoadUrl) UpdateGameVersion() {
 				flagPackage = true
 				//global.GVA_LOG.Info("package有新版本")
 				if one.PackageUrl != "" {
-					keyWord += "在打包平台有新版本: " + one.PackageUrl + ";<font color=\"warning\">更新大概率为强制更新</font>;"
+					keyWord += "在打包平台有新版本,,游戏链接请找客服,<font color=\"warning\">更新大概率为强制更新</font>;"
 					//keyWord += "在打包平台有新版本: [点击下载](" + one.PackageUrl + ");"
 				}
 			}
@@ -94,10 +91,10 @@ func (s *ServiceDownLoadUrl) UpdateGameVersion() {
 					flagApp = true
 					//global.GVA_LOG.Info("app有新版本")
 					if one.AppUrl != "" {
-						keyWord += "在小绵羊APP有新版本: " + one.AppUrl + ";"
+						keyWord += "在小绵羊APP有新版本,游戏链接请找客服"
 						if one.AppFlag == 1 {
 							global.GVA_LOG.Info("游戏有强更")
-							keyWord += "<font color=\"warning\">更新可能为强制更新</font>;"
+							keyWord += ",<font color=\"warning\">更新可能为强制更新</font>;"
 						}
 					}
 					break

+ 13 - 13
service/log/log_ip.go

@@ -144,14 +144,14 @@ func (s *ServiceIpLog) GetAbnormalIpLogList(api log.AbnormalIpLogRequest, info r
 }
 
 //获取今日异常租机ip(ip播报使用)
-func (s *ServiceIpLog) GetTodayAbnormalIpLogList() (list map[string]string, err error){
+func (s *ServiceIpLog) GetTodayAbnormalIpLogList() (list map[string]string, err error) {
 	var total int64
 	var apiList []log.TodayAbnormalMachineIp
 	pcCodeList := make(map[string]string)
 	usePcCode := make(map[string]string)
 	date := time.Now().Format("2006-01-02")
 	//1个半小时前的时间
-	effectiveTime :=time.Now().Add(-time.Minute * 90).Format("2006-01-02 15:04:05")
+	effectiveTime := time.Now().Add(-time.Minute * 90).Format("2006-01-02 15:04:05")
 
 	db := global.GVA_DB.Table("abnormal_machine_ip as ami")
 	db = db.Select("ami.*, gt.task_name, gt.user")
@@ -175,7 +175,7 @@ func (s *ServiceIpLog) GetTodayAbnormalIpLogList() (list map[string]string, err
 
 	//遍历列表中的租机,查询数据库(租机编号,和本日时间),得到记录集合,通过ip作为map的key,判断是否需要播报
 	//遍历租机编号列表
-	for k,_ := range pcCodeList {
+	for k, _ := range pcCodeList {
 		var ipList []log.IpLogBroadcast
 		ipSet := make(map[string]int)
 		db1 := global.GVA_DB.Model(&log.IpLog{}).Select("ip_log.*, game_task.user")
@@ -197,7 +197,7 @@ func (s *ServiceIpLog) GetTodayAbnormalIpLogList() (list map[string]string, err
 			usePcCode[ipList[0].PcCode] = ipList[0].User
 		}
 	}
-	return usePcCode , err
+	return usePcCode, err
 }
 
 //根据gameId获取ip
@@ -361,7 +361,7 @@ func (s *ServiceIpLog) UpdateAbnormalMachineIp() (err error) {
 		return err
 	}
 	//将异常ip存储至abnormal_machine_ip数据库中
-	for i,_ := range abnormalIpList {
+	for i, _ := range abnormalIpList {
 		var entity log.AbnormalMachineIp
 		ip := abnormalIpList[i].Ip
 		gameId := abnormalIpList[i].GameId
@@ -370,11 +370,11 @@ func (s *ServiceIpLog) UpdateAbnormalMachineIp() (err error) {
 		count := abnormalIpList[i].Count
 
 		//根据count判断,如果count < 9, continue继续做下一条记录的处理
-		if count < 10 {
+		if count < 6 {
 			continue
 		}
 
-		if !errors.Is(global.GVA_DB.Model(&log.AbnormalMachineIp{}).Where("ip = ? and game_id = ? and pc_code = ? and create_date = ?",ip, gameId, pcCode, createDate).First(&entity).Error, gorm.ErrRecordNotFound) {
+		if !errors.Is(global.GVA_DB.Model(&log.AbnormalMachineIp{}).Where("ip = ? and game_id = ? and pc_code = ? and create_date = ?", ip, gameId, pcCode, createDate).First(&entity).Error, gorm.ErrRecordNotFound) {
 			//存在相同的ip、租机、gameid、创建日期记录,那么更新数量即可
 			err = global.GVA_DB.Model(&log.AbnormalMachineIp{}).Where("ip = ? and game_id = ? and pc_code = ? and create_date = ?", ip, gameId, pcCode, createDate).Update("count", count).Error
 			if err != nil {
@@ -400,7 +400,7 @@ func (s *ServiceIpLog) UpdateGameIpList() (err error) {
 	//筛选日期
 	db = db.Where("ip_log.create_date = ?", date)
 	//查找总ip上报次数
-	db = db.Joins("left join" + "(select count(*) as count, game_id, create_date from ip_log where create_date = ? group by game_id, create_date)" + " as late on late.game_id = ip_log.game_id and late.create_date = ip_log.create_date",  date)
+	db = db.Joins("left join"+"(select count(*) as count, game_id, create_date from ip_log where create_date = ? group by game_id, create_date)"+" as late on late.game_id = ip_log.game_id and late.create_date = ip_log.create_date", date)
 
 	db = db.Where("ip_log.status = 2")
 
@@ -425,14 +425,14 @@ func (s *ServiceIpLog) UpdateGameIpList() (err error) {
 		countDistinctIp := float64(apiList[i].CountDistinctIp)
 		successIp := float64(apiList[i].SuccessIp)
 		taskCount := float64(apiList[i].TaskCount)
-		apiList[i].IpRepetitionRate, _ =  strconv.ParseFloat(fmt.Sprintf("%.2f", (countDistinctIp/ successIp) *100), 64)
+		apiList[i].IpRepetitionRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (countDistinctIp/successIp)*100), 64)
 		if taskCount != 0 {
-			apiList[i].AverageIpRepetitionRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (countDistinctIp / taskCount) *100), 64)
+			apiList[i].AverageIpRepetitionRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (countDistinctIp/taskCount)*100), 64)
 		}
 		//查找数据库中是否有这条记录(game_id, create_date)
-		if !errors.Is(global.GVA_DB.Model(&log.GameIpResponse{}).Where("game_id = ? and create_date = ?",apiList[i].GameId, apiList[i].CreateDate).First(&entity).Error, gorm.ErrRecordNotFound) {
+		if !errors.Is(global.GVA_DB.Model(&log.GameIpResponse{}).Where("game_id = ? and create_date = ?", apiList[i].GameId, apiList[i].CreateDate).First(&entity).Error, gorm.ErrRecordNotFound) {
 			//如果有,更新
-			err = global.GVA_DB.Model(&log.GameIpResponse{}).Where("game_id = ? and create_date = ?",apiList[i].GameId, apiList[i].CreateDate).Save(&apiList[i]).Error
+			err = global.GVA_DB.Model(&log.GameIpResponse{}).Where("game_id = ? and create_date = ?", apiList[i].GameId, apiList[i].CreateDate).Save(&apiList[i]).Error
 			if err != nil {
 				return errors.New("更新ip列表失败")
 			}
@@ -445,4 +445,4 @@ func (s *ServiceIpLog) UpdateGameIpList() (err error) {
 		}
 	}
 	return err
-}
+}

+ 3 - 0
service/log/log_list.go

@@ -147,6 +147,9 @@ func (s *ServiceLogList) CreateLog(c context.Context, request request.AddLogRequ
 	if request.Coding == 4301001 || request.Coding == 4501001 {
 		return
 	}
+	if request.Err != "" {
+		return
+	}
 	if err != nil {
 		body, _ := json.Marshal(request)
 		current := time.Now().Format("2006-01-02")

+ 61 - 29
service/log/log_statistics.go

@@ -1365,33 +1365,34 @@ func (s *ServiceStatisticsLog) ComputerSevenStatistics(ctx context.Context, api
 
 // 定时统计设备信息
 func (s *ServiceStatisticsLog) DeviceStatistics() {
-	var devices []log.DeviceLog
 	date := time.Now().Format("2006-01-02")
-	db := global.GVA_DB.Model(&log.DeviceLog{})
-	db.Where("create_date = ?", date)
-	db.Where("is_err = ?", 1)
-	db.Group("game_id")
-	db.Select("game_id")
-	db.Find(&devices)
-	if len(devices) == 0 {
+	db := global.GVA_DB.Model(&task.GameTask{})
+	var apiList []task.GameTask
+	db = db.Where("is_del = ?", -1)
+	db = db.Where("status = ?", 1)
+	db.Order("id desc").Find(&apiList)
+	if len(apiList) == 0 {
 		return
 	}
 	retainedDeviceErr := s.DeviceIdStatistics(date, 1)
 	newDeviceErr := s.DeviceIdStatistics(date, 2)
+	undefinedErr := s.DeviceErrLogStatistics(date, 1)
+	DefinedErr := s.DeviceErrLogStatistics(date, 2)
 	completeData, _ := s.GameTargetComplete.CompleteTaskData(date)
 	ctx := context.Background()
-	for _, game := range devices {
+	for _, game := range apiList {
 		deviceLog := new(log.DeviceStatistics)
-		deviceLog.GameId = game.GameId
-		gameDeviceAccountErrKey := fmt.Sprintf(loging2.GameDeviceAccountErrKey, date, game.GameId)
-		gameDeviceErrKey := fmt.Sprintf(loging2.GameDeviceErrKey, date, game.GameId)
+		gameId := game.TaskId
+		deviceLog.GameId = gameId
+		gameDeviceAccountErrKey := fmt.Sprintf(loging2.GameDeviceAccountErrKey, date, gameId)
+		gameDeviceErrKey := fmt.Sprintf(loging2.GameDeviceErrKey, date, gameId)
 		deviceLog.AccountErrNum, _ = s.GetCacheNum(ctx, gameDeviceAccountErrKey)
 		deviceLog.DeviceErrNum, _ = s.GetCacheNum(ctx, gameDeviceErrKey)
-		n, _ := s.LogicalLog.NodeLogGetNum(ctx, date, game.GameId, "4300000", loging2.OkStatus, 0)
-		r, _ := s.LogicalLog.NodeLogGetNum(ctx, date, game.GameId, "4300000", loging2.OkStatus, 1)
+		n, _ := s.LogicalLog.NodeLogGetNum(ctx, date, gameId, "4300000", loging2.OkStatus, 0)
+		r, _ := s.LogicalLog.NodeLogGetNum(ctx, date, gameId, "4300000", loging2.OkStatus, 1)
 		deviceLog.SimulatorStartNum = n + r
-		deviceLog.NewComplete = completeData[game.GameId].NewComplete
-		deviceLog.RetainedComplete = completeData[game.GameId].RetainedComplete
+		deviceLog.NewComplete = completeData[gameId].NewComplete
+		deviceLog.RetainedComplete = completeData[gameId].RetainedComplete
 		if deviceLog.DeviceErrNum != 0 {
 			deviceLog.DeviceErrRate = utils.Decimal(float64(deviceLog.DeviceErrNum) / float64(deviceLog.RetainedComplete) * 100)
 		}
@@ -1399,28 +1400,35 @@ func (s *ServiceStatisticsLog) DeviceStatistics() {
 			deviceLog.AccountErrRate = utils.Decimal(float64(deviceLog.AccountErrNum) / float64(deviceLog.NewComplete) * 100)
 		}
 		deviceLog.CreateDate = date
-
-		if _, ok := retainedDeviceErr[game.GameId]; ok {
-			if retainedDeviceErr[game.GameId].Count != 0 {
-				deviceLog.RetainedDeviceIdErr = retainedDeviceErr[game.GameId].Count
+		if _, ok := retainedDeviceErr[gameId]; ok {
+			if retainedDeviceErr[gameId].Count != 0 {
+				deviceLog.RetainedDeviceIdErr = retainedDeviceErr[gameId].Count
 				deviceLog.RetainedDeviceIdRate = utils.Decimal(float64(deviceLog.RetainedDeviceIdErr) / float64(deviceLog.RetainedComplete) * 100)
 			}
-			delete(retainedDeviceErr, game.GameId)
 		}
 
-		if _, ok := newDeviceErr[game.GameId]; ok {
-			if newDeviceErr[game.GameId].Count != 0 {
-				deviceLog.NewDeviceIdErr = newDeviceErr[game.GameId].Count
+		if _, ok := newDeviceErr[gameId]; ok {
+			if newDeviceErr[gameId].Count != 0 {
+				deviceLog.NewDeviceIdErr = newDeviceErr[gameId].Count
 				deviceLog.NewDeviceIdRate = utils.Decimal(float64(deviceLog.NewDeviceIdErr) / float64(deviceLog.NewComplete) * 100)
 			}
-			delete(newDeviceErr, game.GameId)
+		}
+		if _, ok := undefinedErr[gameId]; ok {
+			if undefinedErr[gameId].Count != 0 {
+				deviceLog.UndefinedErr = undefinedErr[gameId].Count
+			}
+		}
+		if _, ok := DefinedErr[gameId]; ok {
+			if DefinedErr[gameId].Count != 0 {
+				deviceLog.DefinedErr = DefinedErr[gameId].Count
+			}
 		}
 
-		if !errors.Is(global.GVA_DB.Where("create_date = ?", date).Where("game_id = ?", game.GameId).First(&log.DeviceStatistics{}).Error, gorm.ErrRecordNotFound) {
-			global.GVA_DB.Where("create_date = ?", date).Where("game_id = ?", game.GameId).Omit("create_date,game_id").Updates(deviceLog)
+		if !errors.Is(global.GVA_DB.Where("create_date = ?", date).Where("game_id = ?", gameId).First(&log.DeviceStatistics{}).Error, gorm.ErrRecordNotFound) {
+			global.GVA_DB.Where("create_date = ?", date).Where("game_id = ?", gameId).Omit("create_date,game_id").Updates(&deviceLog)
 			continue
 		}
-		global.GVA_DB.Save(deviceLog)
+		global.GVA_DB.Create(&deviceLog)
 	}
 }
 
@@ -1447,6 +1455,24 @@ func (s *ServiceStatisticsLog) DeviceIdStatistics(date string, status int) map[i
 	return devicesErrMaps
 }
 
+func (s *ServiceStatisticsLog) DeviceErrLogStatistics(date string, status int) map[int]DeviceErr {
+	var devicesErr []DeviceErr
+	db := global.GVA_DB.Model(&log.DeviceErrLog{})
+	db.Where("create_date = ?", date)
+	db.Where("status = ?", status)
+	db.Group("game_id")
+	db.Select("game_id, count(*) count")
+	db.Find(&devicesErr)
+	if len(devicesErr) == 0 {
+		return nil
+	}
+	devicesErrMaps := make(map[int]DeviceErr, len(devicesErr))
+	for _, game := range devicesErr {
+		devicesErrMaps[game.GameId] = game
+	}
+	return devicesErrMaps
+}
+
 func (exa *ServiceStatisticsLog) DeviceErrRateExcel(statistics []*log.DeviceStatisticsReply, filePath string) error {
 	excel := excelize.NewFile()
 	excel.SetSheetRow("Sheet1", "A1", &[]string{"游戏ID", "负责人", "留存设备异常", "留存设备id异常", "留存完成目标", "留存异常率", "留存设备id异常率", "新增设备异常", "新增设备id异常", "新增完成目标", "新增异常率", "新增设备id异常率", "统计日期"})
@@ -1568,7 +1594,7 @@ func (s *ServiceStatisticsLog) GetDeviceInfo(ctx context.Context, api log.Device
 	return
 }
 
-func (s *ServiceStatisticsLog) GetDeviceIdErr(ctx context.Context, api log.DeviceLog, info request.PageInfo, order string, desc bool) (deviceLogs []*log.ScriptDeviceErr, total int64, err error) {
+func (s *ServiceStatisticsLog) GetDeviceIdErr(ctx context.Context, api log.ScriptDeviceErr, info request.PageInfo, order string, desc bool) (deviceLogs []*log.ScriptDeviceErr, total int64, err error) {
 	if api.CreateDate == "" {
 		api.CreateDate = time.Now().Format("2006-01-02")
 	}
@@ -1576,6 +1602,12 @@ func (s *ServiceStatisticsLog) GetDeviceIdErr(ctx context.Context, api log.Devic
 	if api.GameId != 0 {
 		db = db.Where("current_game_id = ?", api.GameId)
 	}
+	if api.Operator != "" {
+		db = db.Where("operator = ?", api.Operator)
+	}
+	if api.Status != 0 {
+		db = db.Where("status = ?", api.Status)
+	}
 	db = db.Where("create_date = ?", api.CreateDate)
 	err = db.Count(&total).Error
 	if err != nil {

+ 33 - 3
service/log/loging/logical_log.go

@@ -38,6 +38,7 @@ var (
 	PcReportingLog              = "%s:pc:Reporting:%s"
 	GameDeviceErrKey            = "%s:device:%d"
 	GameDeviceAccountErrKey     = "%s:deviceAccount:%d"
+	GameDeviceUuidKey           = "%s:GameDeviceUuid:%s"
 )
 
 type LogicalLog struct {
@@ -1004,7 +1005,7 @@ func (s *LogicalLog) AddAccount(request request.AddLogRequest) {
 	}
 }
 
-func (s *LogicalLog) AddScriptDeviceErr(gameId int, account, firstDeviceId, currentDeviceId string, firstAccount string, firstGameId int, status uint) {
+func (s *LogicalLog) AddScriptDeviceErr(gameId int, account, firstDeviceId, currentDeviceId string, firstAccount string, firstGameId int, status uint, pcCode string, operator string) {
 	scriptDeviceErr := new(log.ScriptDeviceErr)
 	scriptDeviceErr.GameId = firstGameId
 	scriptDeviceErr.Account = firstAccount
@@ -1014,6 +1015,8 @@ func (s *LogicalLog) AddScriptDeviceErr(gameId int, account, firstDeviceId, curr
 	scriptDeviceErr.CurrentDeviceId = currentDeviceId
 	scriptDeviceErr.CreateDate = time.Now().Format("2006-01-02")
 	scriptDeviceErr.Status = status
+	scriptDeviceErr.PcCode = pcCode
+	scriptDeviceErr.Operator = operator
 	err := global.GVA_DB.Omit("create_time").Create(&scriptDeviceErr).Error
 	if err != nil {
 		global.GVA_LOG.Error("create AddScriptDeviceErr fail", zap.Error(err))
@@ -1032,7 +1035,7 @@ func (s *LogicalLog) CheckDeviceId(request request.AddLogRequest) {
 		b, deviceLog := s.CheckDeviceIdErr(request.ScriptDeviceId, request.LogUuid, request.GameId)
 		// 有异常处理
 		if b {
-			s.AddScriptDeviceErr(request.GameId, request.Account, request.ScriptDeviceId, request.ScriptDeviceId, deviceLog.Account, deviceLog.GameId, 2)
+			s.AddScriptDeviceErr(request.GameId, request.Account, request.ScriptDeviceId, request.ScriptDeviceId, deviceLog.Account, deviceLog.GameId, 2, request.PcCode, request.Operator)
 			//ct := fmt.Sprintf("<font color=\"warning\">%s:%d, 相同设备id</font>", request.PcCode, request.GameId)
 			//s.SendDeviceMsg(ct, request.Operator)
 		}
@@ -1053,7 +1056,7 @@ func (s *LogicalLog) CheckDeviceId(request request.AddLogRequest) {
 		}
 	}
 	if gameAccount.ScriptDeviceId != request.ScriptDeviceId {
-		s.AddScriptDeviceErr(request.GameId, request.Account, gameAccount.ScriptDeviceId, request.ScriptDeviceId, gameAccount.Account, gameAccount.GameId, 1)
+		s.AddScriptDeviceErr(request.GameId, request.Account, gameAccount.ScriptDeviceId, request.ScriptDeviceId, gameAccount.Account, gameAccount.GameId, 1, request.PcCode, request.Operator)
 		//ct := fmt.Sprintf("<font color=\"warning\">%s:%d, 设备id出现不同</font>", request.PcCode, request.GameId)
 		//s.SendDeviceMsg(ct, request.Operator)
 		gameAccount.ScriptDeviceId = request.ScriptDeviceId
@@ -1115,3 +1118,30 @@ func (s *LogicalLog) CheckDeviceIdErr(scriptDeviceId string, uuid string, gameId
 	}
 	return true, deviceLog
 }
+
+func (s *LogicalLog) AddDeviceErrLog(request request.AddLogRequest, st uint) {
+	if request.Err == "" {
+		return
+	}
+	ctx := context.Background()
+	key := fmt.Sprintf(GameDeviceUuidKey, time.Now().Format("2006-01-02"), request.LogUuid)
+	status, _ := s.ExistsKey(ctx, key)
+	if status {
+		return
+	}
+	errLog := new(log.DeviceErrLog)
+	errLog.GameId = request.GameId
+	errLog.CreateDate = time.Now()
+	errLog.CreateTime = time.Now()
+	errLog.Err = request.Err
+	errLog.PcCode = request.PcCode
+	content, _ := json.Marshal(request)
+	errLog.Content = string(content)
+	errLog.Status = st
+	err := errLog.Create()
+	if err != nil {
+		global.GVA_LOG.Error("create AddAccount fail", zap.Error(err))
+		return
+	}
+	global.GVA_REDIS.Set(ctx, key, 1, time.Hour)
+}

+ 6 - 0
service/log/loging/simulator_start_log.go

@@ -15,7 +15,13 @@ func (s *SimulatorStartLog) SuccessLog(ctx context.Context, request request.AddL
 	s.logical.Request = request
 	s.logical.ScriptType = request.ScriptType
 	err = s.logical.DataAdd()
+	s.logical.AddDeviceErrLog(s.logical.Request, 2)
 	if err != nil {
+		if s.logical.Request.SimulatorIp == "" {
+			return
+		}
+		s.logical.Request.Err = s.logical.Request.SimulatorIp[:3]
+		s.logical.AddDeviceErrLog(s.logical.Request, 1)
 		return
 	}
 	code := strconv.Itoa(request.Coding)