wangbin лет назад: 3
Родитель
Сommit
1ec971dd77

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

@@ -197,13 +197,13 @@ func (s *ApiLoging) ResetStatisticsLog(c *gin.Context) {
 // @Success 200 {object} response.Response{data=interface{}} "获取统计电脑"
 // @Success 200 {object} response.Response{data=interface{}} "获取统计电脑"
 // @Router /loging/getComputerStatistics [post]
 // @Router /loging/getComputerStatistics [post]
 func (s *ApiLoging) GetComputerStatistics(c *gin.Context) {
 func (s *ApiLoging) GetComputerStatistics(c *gin.Context) {
-	var paramsInfo request.GetStatisticsLogRequest
+	var paramsInfo request.GetStatisticsComputerRequest
 	_ = c.ShouldBindJSON(&paramsInfo)
 	_ = c.ShouldBindJSON(&paramsInfo)
 	/*if err := utils.Verify(paramsInfo.PageInfo, utils.PageInfoVerify); err != nil {
 	/*if err := utils.Verify(paramsInfo.PageInfo, utils.PageInfoVerify); err != nil {
 		response.FailWithMessage(err.Error(), c)
 		response.FailWithMessage(err.Error(), c)
 		return
 		return
 	}*/
 	}*/
-	list, total, err := ServiceStatisticsLog.ComputerStatistics(c, paramsInfo.StatisticsLog, paramsInfo.PageInfo)
+	list, total, err := ServiceStatisticsLog.ComputerStatistics(c, paramsInfo.LogComputer, paramsInfo.PageInfo)
 	if err != nil {
 	if err != nil {
 		global.GVA_LOG.Error("获取失败!", zap.Error(err))
 		global.GVA_LOG.Error("获取失败!", zap.Error(err))
 		response.FailWithMessage("获取失败", c)
 		response.FailWithMessage("获取失败", c)

+ 4 - 4
initialize/timer.go

@@ -38,10 +38,10 @@ func Timer() {
 		fmt.Println("add taskCode timer error:", err)
 		fmt.Println("add taskCode timer error:", err)
 	}
 	}
 
 
-	//_, err = global.GVA_Timer.AddTaskByFunc("CreateComputerStatisticsData","2 46 7-23 * * * ", serviceStatisticsLog.CreateComputerStatisticsData)
-	//if err != nil {
-	//	fmt.Println("add CreateComputerStatisticsData timer error:", err)
-	//}
+	_, err = global.GVA_Timer.AddTaskByFunc("CreateComputerStatisticsData", "2 8 7-23 * * * ", serviceStatisticsLog.CreateComputerStatisticsData)
+	if err != nil {
+		fmt.Println("add CreateComputerStatisticsData timer error:", err)
+	}
 	_, err = global.GVA_Timer.AddTaskByFunc("createFailLog", "2 0/5 6-23 * * * ", ServiceLogList.CreateFailLog)
 	_, err = global.GVA_Timer.AddTaskByFunc("createFailLog", "2 0/5 6-23 * * * ", ServiceLogList.CreateFailLog)
 	if err != nil {
 	if err != nil {
 		fmt.Println("everyDayResetStatisticsCache timer error:", err)
 		fmt.Println("everyDayResetStatisticsCache timer error:", err)

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

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

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

@@ -47,4 +47,6 @@ type ComputerStatisticsReply1 struct {
 	GameInfo   []*GameInfo `json:"game_info"`
 	GameInfo   []*GameInfo `json:"game_info"`
 	CreateDate string      `json:"create_date"`
 	CreateDate string      `json:"create_date"`
 	Operator   string      `json:"operator"`
 	Operator   string      `json:"operator"`
+	GameId     string      `json:"game_id"`
+	DataNumInfo
 }
 }

+ 1 - 3
service/log/log_list.go

@@ -47,9 +47,7 @@ func (s *ServiceLogList) GetCodeLogList(ctx context.Context, api log.Loging, inf
 	if api.LogUuid != "" {
 	if api.LogUuid != "" {
 		db = db.Where("log_uuid = ?", api.LogUuid)
 		db = db.Where("log_uuid = ?", api.LogUuid)
 	}
 	}
-	if api.LogUuid != "" {
-		db = db.Where("log_uuid = ?", api.LogUuid)
-	}
+
 	if code != 0 {
 	if code != 0 {
 		db = db.Where("type_coding = ?", code)
 		db = db.Where("type_coding = ?", code)
 	}
 	}

+ 19 - 8
service/log/log_statistics.go

@@ -574,13 +574,20 @@ func (s *ServiceStatisticsLog) CreateComputerStatisticsData() {
 	return
 	return
 }
 }
 
 
-func (s *ServiceStatisticsLog) ComputerStatistics(ctx context.Context, api log.StatisticsLog, info request.PageInfo) (interface{}, int64, error) {
+func (s *ServiceStatisticsLog) ComputerStatistics(ctx context.Context, api log.LogComputer, info request.PageInfo) (interface{}, int64, error) {
 	date := api.CreateDate
 	date := api.CreateDate
 	if date == "" {
 	if date == "" {
 		date = s.CurrentDate()
 		date = s.CurrentDate()
 	}
 	}
 	db := global.GVA_DB.Model(&log.LogComputer{})
 	db := global.GVA_DB.Model(&log.LogComputer{})
 	var total int64
 	var total int64
+	db = db.Where("create_date = ?", date)
+	if api.Operator != "" {
+		db = db.Where("operator = ?", api.Operator)
+	}
+	if api.PcCode != "" {
+		db = db.Where("pc_code = ?", api.PcCode)
+	}
 	err := db.Count(&total).Error
 	err := db.Count(&total).Error
 	if err != nil {
 	if err != nil {
 		return nil, 0, err
 		return nil, 0, err
@@ -588,7 +595,6 @@ func (s *ServiceStatisticsLog) ComputerStatistics(ctx context.Context, api log.S
 	limit := info.PageSize
 	limit := info.PageSize
 	offset := info.PageSize * (info.Page - 1)
 	offset := info.PageSize * (info.Page - 1)
 	var statisticsLogs []*log.LogComputer
 	var statisticsLogs []*log.LogComputer
-	db = db.Where("create_date = ?", date)
 	db = db.Limit(limit).Offset(offset)
 	db = db.Limit(limit).Offset(offset)
 	err = db.Order("id").Find(&statisticsLogs).Error
 	err = db.Order("id").Find(&statisticsLogs).Error
 	if err != nil {
 	if err != nil {
@@ -598,12 +604,17 @@ func (s *ServiceStatisticsLog) ComputerStatistics(ctx context.Context, api log.S
 	for _, statisticsLog := range statisticsLogs {
 	for _, statisticsLog := range statisticsLogs {
 		var gameInfo []*response.GameInfo
 		var gameInfo []*response.GameInfo
 		err = json.Unmarshal([]byte(statisticsLog.GameInfo), &gameInfo)
 		err = json.Unmarshal([]byte(statisticsLog.GameInfo), &gameInfo)
-		statisticsLogComputer := new(response.ComputerStatisticsReply1)
-		statisticsLogComputer.GameInfo = gameInfo
-		statisticsLogComputer.PcCode = statisticsLog.PcCode
-		statisticsLogComputer.Operator = statisticsLog.Operator
-		statisticsLogComputer.CreateDate = statisticsLog.CreateDate[:10]
-		statisticsLogsComputer = append(statisticsLogsComputer, statisticsLogComputer)
+		for i, _ := range gameInfo {
+			statisticsLogComputer := new(response.ComputerStatisticsReply1)
+			statisticsLogComputer.GameInfo = gameInfo
+			statisticsLogComputer.PcCode = statisticsLog.PcCode
+			statisticsLogComputer.Operator = statisticsLog.Operator
+			statisticsLogComputer.CreateDate = statisticsLog.CreateDate[:10]
+			statisticsLogComputer.GameId = gameInfo[i].GameId
+			statisticsLogComputer.PullAccountNum = gameInfo[i].PullAccountNum
+			statisticsLogComputer.TaskSuccessNum = gameInfo[i].TaskSuccessNum
+			statisticsLogsComputer = append(statisticsLogsComputer, statisticsLogComputer)
+		}
 	}
 	}
 	return statisticsLogsComputer, total, err
 	return statisticsLogsComputer, total, err
 }
 }