wangbin 2 gadi atpakaļ
vecāks
revīzija
327c3ded21

+ 2 - 1
.gitignore

@@ -43,4 +43,5 @@ _test
 log-server
 config.docker.yaml
 config.yaml
-/test
+/test
+/config.yaml

+ 72 - 0
api/v1/log/loging.go

@@ -553,3 +553,75 @@ func (e *ApiLoging) ComputerSevenRate(c *gin.Context) {
 		}, "获取成功", c)
 	}
 }
+
+// @Tags loging
+// @Summary 设备统计接口
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce  application/json
+// @Param data body request.GetDeviceStatisticsRequest true "设备统计接口"
+// @Success 200
+// @Router /loging/getDeviceStatistics [post]
+func (e *ApiLoging) GetDeviceStatistics(c *gin.Context) {
+	var paramsInfo request.GetDeviceStatisticsRequest
+	_ = c.ShouldBindJSON(&paramsInfo)
+	list, total, err := ServiceStatisticsLog.GetDeviceStatistics(c, paramsInfo.DeviceStatistics, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc)
+	if err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Error(err))
+		response.FailWithMessage("获取失败", c)
+	} else {
+		response.OkWithDetailed(response.PageResult{
+			List:     list,
+			Total:    total,
+			Page:     paramsInfo.Page,
+			PageSize: paramsInfo.PageSize,
+		}, "获取成功", c)
+	}
+}
+
+// @Tags loging
+// @Summary 设备统计接口
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce  application/json
+// @Param data body request.GetDeviceStatisticsRequest true "设备统计接口"
+// @Success 200
+// @Router /loging/getDeviceInfoLog [post]
+func (e *ApiLoging) GetDeviceInfoLog(c *gin.Context) {
+	var paramsInfo request.GetDeviceInfoLogRequest
+	_ = c.ShouldBindJSON(&paramsInfo)
+	list, total, err := ServiceStatisticsLog.GetDeviceInfo(c, paramsInfo.DeviceLog, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc)
+	if err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Error(err))
+		response.FailWithMessage("获取失败", c)
+	} else {
+		response.OkWithDetailed(response.PageResult{
+			List:     list,
+			Total:    total,
+			Page:     paramsInfo.Page,
+			PageSize: paramsInfo.PageSize,
+		}, "获取成功", c)
+	}
+}
+
+// @Tags loging
+// @Summary 设备异常数据接口
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce  application/json
+// @Param data body log2.DeviceLog true "设备异常数据接口"
+// @Success 200
+// @Router /loging/getErrDeviceLog [post]
+func (e *ApiLoging) GetErrDeviceLog(c *gin.Context) {
+	var paramsInfo log2.DeviceLog
+	_ = c.ShouldBindJSON(&paramsInfo)
+	list, err := ServiceStatisticsLog.GetDeviceContrastInfo(c, paramsInfo)
+	if err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Error(err))
+		response.FailWithMessage("获取失败", c)
+	} else {
+		response.OkWithDetailed(response.PageResult{
+			List: list,
+		}, "获取成功", c)
+	}
+}

+ 50 - 0
model/log/device_log.go

@@ -0,0 +1,50 @@
+package log
+
+type DeviceLog struct {
+	Id                 uint   `json:"id"`
+	SimulatorCode      string `json:"simulator_code"`
+	DeviceManufacturer string `json:"device_manufacturer"`
+	DeviceModel        string `json:"device_model"`
+	DeviceImei         string `json:"device_imei"`
+	DeviceSdk          string `json:"device_sdk"`
+	DeviceMac          string `json:"device_mac"`
+	DeviceNumber       string `json:"device_number"`
+	DeviceIp           string `json:"device_ip"`
+	DeviceId           string `json:"device_id"`
+	Account            string `json:"account"`
+	GameId             int    `json:"game_id"`
+	CreateDate         string `json:"create_date"`
+	CreateTime         string `json:"create_time"` // 创建时间
+	IsErr              int8   `json:"is_err"`
+	ErrStatus          uint8  `json:"err_status"`
+	DeviceHex          string `json:"device_hex"`
+	AccountHex         string `json:"account_hex"`
+	LogUuid            string `json:"log_uuid"` //日志UUID
+}
+
+func (DeviceLog) TableName() string {
+	return "device_log"
+}
+
+type AccountHex struct {
+	DeviceManufacturer string `json:"device_manufacturer"`
+	DeviceModel        string `json:"device_model"`
+	DeviceImei         string `json:"device_imei"`
+	DeviceSdk          string `json:"device_sdk"`
+	DeviceMac          string `json:"device_mac"`
+	DeviceNumber       string `json:"device_number"`
+	DeviceId           string `json:"device_id"`
+	GameId             int    `json:"game_id"`
+	Account            string `json:"account"`
+}
+
+type DeviceHex struct {
+	DeviceManufacturer string `json:"device_manufacturer"`
+	DeviceModel        string `json:"device_model"`
+	DeviceImei         string `json:"device_imei"`
+	DeviceSdk          string `json:"device_sdk"`
+	DeviceMac          string `json:"device_mac"`
+	DeviceNumber       string `json:"device_number"`
+	DeviceId           string `json:"device_id"`
+	GameId             int    `json:"game_id"`
+}

+ 18 - 0
model/log/device_statistics.go

@@ -0,0 +1,18 @@
+package log
+
+type DeviceStatistics struct {
+	Id                uint    `json:"id"`
+	GameId            int     `json:"game_id"`
+	DeviceErrNum      int     `json:"device_err_num"`
+	DeviceErrRate     float64 `json:"device_err_rate"`
+	AccountErrNum     int     `json:"account_err_num"`
+	AccountErrRate    float64 `json:"account_err_rate"`
+	SimulatorStartNum int     `json:"simulator_start_num"`
+	CreateDate        string  `json:"create_date"`
+	NewComplete       int     `json:"new_complete"`
+	RetainedComplete  int     `json:"retained_complete"`
+}
+
+func (DeviceStatistics) TableName() string {
+	return "device_statistics"
+}

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

@@ -99,3 +99,17 @@ type LogScanningRequest struct {
 	CreateDate string `json:"create_date"`
 	CreateTime string `json:"create_time"` // 创建时间
 }
+
+type GetDeviceStatisticsRequest struct {
+	log.DeviceStatistics
+	PageInfo
+	OrderKey string `json:"orderKey"` // 排序
+	Desc     bool   `json:"desc"`     // 排序方式:升序false(默认)|降序true
+}
+
+type GetDeviceInfoLogRequest struct {
+	log.DeviceLog
+	PageInfo
+	OrderKey string `json:"orderKey"` // 排序
+	Desc     bool   `json:"desc"`     // 排序方式:升序false(默认)|降序true
+}

+ 26 - 18
model/log/request/loging.go

@@ -5,24 +5,32 @@ import (
 )
 
 type AddLogRequest struct {
-	SimulatorIp      string `json:"simulator_ip"`
-	SimulatorMac     string `json:"simulator_mac"`
-	PcCode           string `json:"pc_code"`
-	PcIp             string `json:"pc_ip"`
-	PcMac            string `json:"pc_mac"`
-	DeviceId         string `json:"device_id"`
-	Account          string `json:"account"`
-	GameId           int    `json:"game_id"`
-	Coding           int    `json:"coding"`
-	ComputerType     int    `json:"computer_type"`
-	EnvCode          int    `json:"env_code"`
-	LogUuid          string `json:"log_uuid"`
-	Operator         string `json:"operator"`
-	AccountType      int    `json:"account_type"`
-	ReportPointsData string `json:"report_points_data"`
-	Remarks          string `json:"remarks"`
-	TaskType         int    `json:"task_type"`   // 新增1,活跃2
-	ScriptType       int    `json:"script_type"` // 中控1,脚本2
+	SimulatorIp        string `json:"simulator_ip"`
+	SimulatorMac       string `json:"simulator_mac"`
+	PcCode             string `json:"pc_code"`
+	PcIp               string `json:"pc_ip"`
+	PcMac              string `json:"pc_mac"`
+	DeviceId           string `json:"device_id"`
+	Account            string `json:"account"`
+	GameId             int    `json:"game_id"`
+	Coding             int    `json:"coding"`
+	ComputerType       int    `json:"computer_type"`
+	EnvCode            int    `json:"env_code"`
+	LogUuid            string `json:"log_uuid"`
+	Operator           string `json:"operator"`
+	AccountType        int    `json:"account_type"`
+	ReportPointsData   string `json:"report_points_data"`
+	Remarks            string `json:"remarks"`
+	TaskType           int    `json:"task_type"`   // 新增1,活跃2
+	ScriptType         int    `json:"script_type"` // 中控1,脚本2
+	SimulatorCode      string `json:"simulator_code"`
+	DeviceManufacturer string `json:"device_manufacturer"`
+	DeviceModel        string `json:"device_model"`
+	DeviceImei         string `json:"device_imei"`
+	DeviceSdk          string `json:"device_sdk"`
+	DeviceMac          string `json:"device_mac"`
+	DeviceNumber       string `json:"device_number"`
+	DeviceIp           string `json:"device_ip"`
 }
 
 type ReportPointsData struct {

+ 7 - 0
model/log/response/loging.go

@@ -91,3 +91,10 @@ type LogScanningReply struct {
 	CreateDate string `json:"create_date"`
 	CreateTime string `json:"create_time"` // 创建时间
 }
+
+type DeviceInfoReply struct {
+	DeviceErrNum  uint8  `json:"device_err_num"`
+	GameId        int    `json:"game_id"`
+	AccountErrNum uint8  `json:"account_err_num"`
+	CreateDate    string `json:"create_date"`
+}

+ 17 - 1
model/task/game_target_complete.go

@@ -1,6 +1,9 @@
 package task
 
-import "time"
+import (
+	"log-server/global"
+	"time"
+)
 
 type GameTargetComplete struct {
 	Id                   uint      `json:"id"`
@@ -25,3 +28,16 @@ type GameTargetComplete struct {
 func (GameTargetComplete) TableName() string {
 	return "game_target_complete"
 }
+
+// 获取任务完成数据
+func (s *GameTargetComplete) CompleteTaskData(date string) (mps map[int]GameTargetComplete, err error) {
+	db := global.GVA_DB.Table("game_target_complete")
+	db = db.Where("create_date = ?", date)
+	var apiList []GameTargetComplete
+	mps = map[int]GameTargetComplete{}
+	err = db.Order("id desc").Find(&apiList).Error
+	for _, api := range apiList {
+		mps[api.TaskId] = api
+	}
+	return
+}

+ 3 - 1
router/log/loging.go

@@ -28,6 +28,8 @@ func (e *LogingRouter) InitLogingRouter(Router *gin.RouterGroup) {
 		excelRouter.POST("getLogScanningList", logApi.GetLogScanningList)
 		excelRouter.POST("computerRateExport", logApi.ComputerRateExport)
 		excelRouter.POST("computerSevenRate", logApi.ComputerSevenRate)
-
+		excelRouter.POST("getDeviceStatistics", logApi.GetDeviceStatistics)
+		excelRouter.POST("getDeviceInfoLog", logApi.GetDeviceInfoLog)
+		excelRouter.POST("getErrDeviceLog", logApi.GetErrDeviceLog)
 	}
 }

+ 4 - 0
service/log/deviceInfo.go

@@ -0,0 +1,4 @@
+package log
+
+type DeviceInfo struct {
+}

+ 155 - 1
service/log/log_statistics.go

@@ -24,7 +24,8 @@ import (
 
 type ServiceStatisticsLog struct {
 	loging2.LogicalLog
-	Person typeManage.ResponsiblePerson
+	Person             typeManage.ResponsiblePerson
+	GameTargetComplete task.GameTargetComplete
 }
 
 var StatisticsCompletedKey = "%s:StatisticsCompleted"
@@ -1361,3 +1362,156 @@ func (s *ServiceStatisticsLog) ComputerSevenStatistics(ctx context.Context, api
 	}
 	return statisticsLogsComputer, total, err
 }
+
+// 定时统计设备信息
+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 {
+		return
+	}
+	completeData, _ := s.GameTargetComplete.CompleteTaskData(date)
+	ctx := context.Background()
+	for _, game := range devices {
+		deviceLog := new(log.DeviceStatistics)
+		deviceLog.GameId = game.GameId
+		gameDeviceAccountErrKey := fmt.Sprintf(loging2.GameDeviceAccountErrKey, date, game.GameId)
+		gameDeviceErrKey := fmt.Sprintf(loging2.GameDeviceErrKey, date, game.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)
+		deviceLog.SimulatorStartNum = n + r
+		deviceLog.NewComplete = completeData[game.GameId].NewComplete
+		deviceLog.RetainedComplete = completeData[game.GameId].RetainedComplete
+		if deviceLog.DeviceErrNum != 0 {
+			deviceLog.DeviceErrRate = utils.Decimal(float64(deviceLog.DeviceErrNum) / float64(deviceLog.RetainedComplete) * 100)
+		}
+		if deviceLog.AccountErrNum != 0 {
+			deviceLog.AccountErrRate = utils.Decimal(float64(deviceLog.AccountErrNum) / float64(deviceLog.NewComplete) * 100)
+		}
+		deviceLog.CreateDate = date
+		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)
+			continue
+		}
+		global.GVA_DB.Save(deviceLog)
+	}
+}
+
+func (s *ServiceStatisticsLog) GetDeviceStatistics(ctx context.Context, api log.DeviceStatistics, info request.PageInfo, order string, desc bool) (statistics []*log.DeviceStatistics, total int64, err error) {
+	if api.CreateDate == "" {
+		api.CreateDate = time.Now().Format("2006-01-02")
+	}
+	db := global.GVA_DB.Model(&log.DeviceStatistics{})
+	db = db.Where("create_date = ?", api.CreateDate)
+	if api.GameId != 0 {
+		db = db.Where("game_id = ?", api.GameId)
+	}
+	err = db.Count(&total).Error
+	if err != nil {
+		return nil, 0, err
+	}
+	limit := info.PageSize
+	offset := info.PageSize * (info.Page - 1)
+	db = db.Limit(limit).Offset(offset)
+	if order != "" {
+		var OrderStr string
+		orderMap := make(map[string]bool, 3)
+		orderMap["device_err_num"] = true
+		orderMap["game_id"] = true
+		orderMap["account_err_num"] = true
+		if orderMap[order] {
+			if desc {
+				OrderStr = order + " desc"
+			} else {
+				OrderStr = order
+			}
+		} else { // didn't matched any order key in `orderMap`
+			global.GVA_LOG.Error("获取失败!", zap.Error(err))
+			return statistics, total, err
+		}
+		err = db.Order(OrderStr).Find(&statistics).Error
+	} else {
+		err = db.Order("id").Find(&statistics).Error
+	}
+	for _, statistic := range statistics {
+		statistic.CreateDate = api.CreateDate
+	}
+	return
+}
+
+func (s *ServiceStatisticsLog) GetDeviceInfo(ctx context.Context, api log.DeviceLog, info request.PageInfo, order string, desc bool) (deviceLogs []*log.DeviceLog, total int64, err error) {
+	if api.CreateDate == "" {
+		api.CreateDate = time.Now().Format("2006-01-02")
+	}
+	db := global.GVA_DB.Model(&log.DeviceLog{})
+	if api.GameId != 0 {
+		db = db.Where("game_id = ?", api.GameId)
+	} else {
+		return
+	}
+	db = db.Where("create_date = ?", api.CreateDate)
+	if api.IsErr != 0 {
+		db = db.Where("is_err = ?", api.IsErr)
+	}
+	err = db.Count(&total).Error
+	if err != nil {
+		return nil, 0, err
+	}
+	limit := info.PageSize
+	offset := info.PageSize * (info.Page - 1)
+	db = db.Limit(limit).Offset(offset)
+	if order != "" {
+		var OrderStr string
+		// 设置有效排序key 防止sql注入
+		// 感谢 Tom4t0 提交漏洞信息
+		orderMap := make(map[string]bool, 3)
+		orderMap["game_id"] = true
+		if orderMap[order] {
+			if desc {
+				OrderStr = order + " desc"
+			} else {
+				OrderStr = order
+			}
+		} else { // didn't matched any order key in `orderMap`
+			global.GVA_LOG.Error("获取失败!", zap.Error(err))
+			return deviceLogs, total, err
+		}
+		err = db.Order(OrderStr).Find(&deviceLogs).Error
+	} else {
+		err = db.Order("id").Find(&deviceLogs).Error
+	}
+	for _, statistic := range deviceLogs {
+		statistic.CreateDate = api.CreateDate
+	}
+	return
+}
+
+func (s *ServiceStatisticsLog) GetDeviceContrastInfo(ctx context.Context, api log.DeviceLog) (deviceLogs []log.DeviceLog, err error) {
+	db := global.GVA_DB.Model(&log.DeviceLog{})
+	var device log.DeviceLog
+	err = db.Where("id = ?", api.Id).First(&device).Error
+	if err != nil {
+		return nil, err
+	}
+	if device.ErrStatus == 3 {
+		err = global.GVA_DB.Where("game_id = ?", device.GameId).Where("account = ?", device.Account).Where("id < ?", device.Id).Order("id desc").First(&deviceLogs).Error
+		if err != nil {
+			return nil, err
+		}
+	} else {
+		err = global.GVA_DB.Where("create_date = ?", device.CreateDate).Where("game_id = ?", device.GameId).Where("device_hex = ?", device.DeviceHex).Where("id < ?", device.Id).Order("id desc").Limit(10).Find(&deviceLogs).Error
+	}
+	deviceLogs = append(deviceLogs, device)
+	for _, statistic := range deviceLogs {
+		statistic.CreateDate = api.CreateDate
+	}
+	return
+}

+ 97 - 1
service/log/loging/logical_log.go

@@ -7,6 +7,7 @@ import (
 	"fmt"
 	"github.com/go-redis/redis/v8"
 	"go.uber.org/zap"
+	"gorm.io/gorm"
 	"log-server/global"
 	"log-server/model/log"
 	"log-server/model/log/request"
@@ -34,6 +35,8 @@ var (
 	GamePcFeeRateCacheKey       = "%s:gamePc:gameFeeRate:%d:%s"
 	OnLineComputerNum           = "%s:OnLineComputerNum:"
 	PcReportingLog              = "%s:pc:Reporting:%s"
+	GameDeviceErrKey            = "%s:device:%d"
+	GameDeviceAccountErrKey     = "%s:deviceAccount:%d"
 )
 
 type LogicalLog struct {
@@ -764,7 +767,7 @@ func (s *LogicalLog) GetPcReportingLog(ctx context.Context, pcCode string) (num
 		return
 	}
 	end := time.Now().UnixNano()/1e6 + 60*1000*2
-	start := end - (60*60*1000 + 60*1000)
+	start := end - (60*60*1000 + 60*1000*4)
 	op := redis.ZRangeBy{
 		Min: strconv.Itoa(int(start)),
 		Max: strconv.Itoa(int(end)),
@@ -886,3 +889,96 @@ func (s *LogicalLog) UpdateIpLogStatus(logUuid string, createDate string) {
 		global.GVA_LOG.Error("create LogScanningCode fail", zap.Error(err))
 	}
 }
+
+// 记录设备信息
+func (s *LogicalLog) AddDeviceLog(request request.AddLogRequest) {
+	if request.DeviceId == "" {
+		return
+	}
+	logSC := new(log.DeviceLog)
+	logSC.GameId = request.GameId
+	logSC.LogUuid = request.LogUuid
+	logSC.Account = request.Account
+	logSC.DeviceId = request.DeviceId
+	logSC.DeviceImei = request.DeviceImei
+	logSC.DeviceIp = request.DeviceIp
+	logSC.DeviceMac = request.DeviceMac
+	logSC.DeviceManufacturer = request.DeviceManufacturer
+	logSC.DeviceModel = request.DeviceModel
+	logSC.DeviceSdk = request.DeviceSdk
+	logSC.DeviceNumber = request.DeviceNumber
+	logSC.SimulatorCode = request.SimulatorCode
+	logSC.IsErr = -1
+	logSC.ErrStatus = 1
+	logSC.DeviceHex = s.DeviceHexLog(request)
+	logSC.AccountHex = s.AccountHexLog(request)
+	logSC.CreateDate = time.Now().Format("2006-01-02")
+	ctx := context.Background()
+	if request.TaskType == 1 {
+		var deviceLog = log.DeviceLog{}
+		if !errors.Is(global.GVA_DB.Where("account = ?", request.Account).Where("game_id = ?", request.GameId).Order("id desc").First(&deviceLog).Error, gorm.ErrRecordNotFound) {
+			if deviceLog.AccountHex != logSC.AccountHex {
+				logSC.IsErr = 1
+				logSC.ErrStatus = 3
+				gameDeviceErrKey := fmt.Sprintf(GameDeviceErrKey, logSC.CreateDate, request.GameId)
+				s.cache.SetCacheNum(ctx, gameDeviceErrKey)
+			}
+		}
+	} else {
+		var deviceLogs []log.DeviceLog
+		if !errors.Is(global.GVA_DB.Where("create_date = ?", logSC.CreateDate).Where("game_id = ?", request.GameId).Where("device_hex = ?", logSC.DeviceHex).Order("id desc").Limit(10).Find(&deviceLogs).Error, gorm.ErrRecordNotFound) {
+			mps := make(map[string]int, 10)
+			for _, dl := range deviceLogs {
+				mps[dl.Account] = 1
+			}
+			if len(mps) > 2 {
+				logSC.IsErr = 1
+				logSC.ErrStatus = 2
+				gameDeviceAccountErrKey := fmt.Sprintf(GameDeviceAccountErrKey, logSC.CreateDate, request.GameId)
+				s.cache.SetCacheNum(ctx, gameDeviceAccountErrKey)
+			}
+		}
+	}
+	logSC.CreateDate = time.Now().Format("2006-01-02")
+	err := global.GVA_DB.Omit("create_time").Create(&logSC).Error
+	if err != nil {
+		global.GVA_LOG.Error("create LogScanningCode fail", zap.Error(err))
+	}
+}
+
+func (s *LogicalLog) DeviceHexLog(request request.AddLogRequest) string {
+	logSC := new(log.DeviceHex)
+	logSC.GameId = request.GameId
+	logSC.DeviceId = request.DeviceId
+	logSC.DeviceImei = request.DeviceImei
+	logSC.DeviceMac = request.DeviceMac
+	logSC.DeviceManufacturer = request.DeviceManufacturer
+	logSC.DeviceModel = request.DeviceModel
+	logSC.DeviceSdk = request.DeviceSdk
+	logSC.DeviceNumber = request.DeviceNumber
+	dh, _ := json.Marshal(logSC)
+	return utils.ByteToHex(dh)
+}
+
+func (s *LogicalLog) AccountHexLog(request request.AddLogRequest) string {
+	logSC := new(log.AccountHex)
+	logSC.GameId = request.GameId
+	logSC.DeviceId = request.DeviceId
+	logSC.DeviceImei = request.DeviceImei
+	logSC.DeviceMac = request.DeviceMac
+	logSC.DeviceManufacturer = request.DeviceManufacturer
+	logSC.DeviceModel = request.DeviceModel
+	logSC.DeviceSdk = request.DeviceSdk
+	logSC.DeviceNumber = request.DeviceNumber
+	logSC.Account = request.Account
+	dh, _ := json.Marshal(logSC)
+	return utils.ByteToHex(dh)
+}
+
+// 修改设备信息状态
+func (s *LogicalLog) UpdateDeviceLogStatus(logUuid string, createDate string) {
+	err := global.GVA_DB.Table("ip_log").Where("create_date = ?", createDate).Where("log_uuid = ?", logUuid).Update("status", 2).Error
+	if err != nil {
+		global.GVA_LOG.Error("create LogScanningCode fail", zap.Error(err))
+	}
+}

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

@@ -26,6 +26,7 @@ func (s *SimulatorStartLog) SuccessLog(ctx context.Context, request request.AddL
 		_ = s.logical.SetUuidCodeCache(context.Background(), s.logical.CurrentDate(), s.logical.Request.LogUuid, s.logical.Request.Coding, s.logical.Request.GameId)
 	}
 	s.logical.AddIpLog(s.logical.Request)
+	s.logical.AddDeviceLog(s.logical.Request)
 	err = s.logical.PartTypeLogSetNum(ctx, s.logical.CurrentDate(), s.logical.Request.GameId, code, OkStatus, s.logical.Request.TaskType)
 	if err != nil {
 		return

+ 11 - 0
utils/common.go

@@ -0,0 +1,11 @@
+package utils
+
+import (
+	"fmt"
+	"strconv"
+)
+
+func Decimal(num float64) float64 {
+	num, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", num), 64)
+	return num
+}

+ 9 - 0
utils/hash.go

@@ -1,6 +1,8 @@
 package utils
 
 import (
+	"crypto/md5"
+	"encoding/hex"
 	"golang.org/x/crypto/bcrypt"
 )
 
@@ -15,3 +17,10 @@ func BcryptCheck(password, hash string) bool {
 	err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
 	return err == nil
 }
+
+func ByteToHex(bt []byte) string {
+	m := md5.New()
+	m.Write(bt)
+	res := hex.EncodeToString(m.Sum(nil))
+	return res
+}