wangbin 3 роки тому
батько
коміт
e1deb10fcd
4 змінених файлів з 43 додано та 36 видалено
  1. 1 1
      config.yaml
  2. 35 35
      initialize/timer.go
  3. 6 0
      model/log/computer.go
  4. 1 0
      service/log/computer.go

+ 1 - 1
config.yaml

@@ -118,7 +118,7 @@ qiniu:
   secret-key: ""
   use-cdn-domains: false
 redis:
-  db: 7
+  db: 8
   addr: 120.92.140.137:6379
   password: "rootredis!fu>6Wy2"
 system:

+ 35 - 35
initialize/timer.go

@@ -38,39 +38,39 @@ func Timer() {
 	if err != nil {
 		fmt.Println("add taskCode timer error:", err)
 	}
-	//// 定时同步电脑相关的统计数据
-	//_, err = global.GVA_Timer.AddTaskByFunc("CreateComputerStatisticsData", "40 0/9 7-23 * * * ", serviceStatisticsLog.CreateComputerStatisticsData)
-	//if err != nil {
-	//	fmt.Println("add CreateComputerStatisticsData timer error:", err)
-	//}
-	//// 同步游戏相关的统计数据
-	//_, err = global.GVA_Timer.AddTaskByFunc("TodayCreateStatisticsGameInfoLog", "2 0/8 6-23 * * * ", serviceStatisticsLog.TodayCreateStatisticsGameInfoLog)
-	//if err != nil {
-	//	fmt.Println("add TodayCreateStatisticsGameInfoLog timer error:", err)
-	//}
-	//// 同步任务统计数据
-	//_, err = global.GVA_Timer.AddTaskByFunc("TaskStatisticsDataCache", "2 0/3 6-23 * * * ", serviceStatisticsLog.TaskStatisticsDataCache)
-	//if err != nil {
-	//	fmt.Println("add TaskStatisticsDataCache timer error:", err)
-	//}
-	//// 重试失败数据
-	//_, err = global.GVA_Timer.AddTaskByFunc("createFailLog", "2 0/5 6-23 * * * ", ServiceLogList.CreateFailLog)
-	//if err != nil {
-	//	fmt.Println("everyDayResetStatisticsCache timer error:", err)
-	//}
-	//// 定时检查电脑上报
-	//_, err = global.GVA_Timer.AddTaskByFunc("RegularCheckPc", "2 0/57 8-23 * * * ", serviceStatisticsLog.RegularCheckPc)
-	//if err != nil {
-	//	fmt.Println("RegularCheckPc timer error:", err)
-	//}
-	//// 新建日志表
-	//_, err = global.GVA_Timer.AddTaskByFunc("RegularCreateLogingTable", "2 1 19 20,29 * * ", ServiceLogList.RegularCreateLogingTable)
-	//if err != nil {
-	//	fmt.Println("add RegularCreateLogingTable timer error:", err)
-	//}
-	//// 定时删缓存
-	//_, err = global.GVA_Timer.AddTaskByFunc("RegularDelCheckData", "2 33 11 * * *", serviceStatisticsLog.RegularDelCheckData)
-	//if err != nil {
-	//	fmt.Println("add RegularDelCheckData timer error:", err)
-	//}
+	// 定时同步电脑相关的统计数据
+	_, err = global.GVA_Timer.AddTaskByFunc("CreateComputerStatisticsData", "40 0/9 7-23 * * * ", serviceStatisticsLog.CreateComputerStatisticsData)
+	if err != nil {
+		fmt.Println("add CreateComputerStatisticsData timer error:", err)
+	}
+	// 同步游戏相关的统计数据
+	_, err = global.GVA_Timer.AddTaskByFunc("TodayCreateStatisticsGameInfoLog", "2 0/8 6-23 * * * ", serviceStatisticsLog.TodayCreateStatisticsGameInfoLog)
+	if err != nil {
+		fmt.Println("add TodayCreateStatisticsGameInfoLog timer error:", err)
+	}
+	// 同步任务统计数据
+	_, err = global.GVA_Timer.AddTaskByFunc("TaskStatisticsDataCache", "2 0/3 6-23 * * * ", serviceStatisticsLog.TaskStatisticsDataCache)
+	if err != nil {
+		fmt.Println("add TaskStatisticsDataCache timer error:", err)
+	}
+	// 重试失败数据
+	_, err = global.GVA_Timer.AddTaskByFunc("createFailLog", "2 0/5 6-23 * * * ", ServiceLogList.CreateFailLog)
+	if err != nil {
+		fmt.Println("everyDayResetStatisticsCache timer error:", err)
+	}
+	// 定时检查电脑上报
+	_, err = global.GVA_Timer.AddTaskByFunc("RegularCheckPc", "2 0/57 8-23 * * * ", serviceStatisticsLog.RegularCheckPc)
+	if err != nil {
+		fmt.Println("RegularCheckPc timer error:", err)
+	}
+	// 新建日志表
+	_, err = global.GVA_Timer.AddTaskByFunc("RegularCreateLogingTable", "2 1 19 20,29 * * ", ServiceLogList.RegularCreateLogingTable)
+	if err != nil {
+		fmt.Println("add RegularCreateLogingTable timer error:", err)
+	}
+	// 定时删缓存
+	_, err = global.GVA_Timer.AddTaskByFunc("RegularDelCheckData", "2 33 11 * * *", serviceStatisticsLog.RegularDelCheckData)
+	if err != nil {
+		fmt.Println("add RegularDelCheckData timer error:", err)
+	}
 }

+ 6 - 0
model/log/computer.go

@@ -68,3 +68,9 @@ func (c *Computer) DelAllOnlinePcCodeCache() (err error) {
 	err = global.GVA_REDIS.HDel(ctx, OnlinePcCode, keys...).Err()
 	return
 }
+
+func (c *Computer) ExistsPcCodeCache(pcCode string) bool {
+	ctx := context.Background()
+	b, _ := global.GVA_REDIS.HExists(ctx, OnlinePcCode, pcCode).Result()
+	return b
+}

+ 1 - 0
service/log/computer.go

@@ -221,6 +221,7 @@ func (a *ServiceComputer) UpdatePc(c log.Computer) (err error) {
 	if c.Status == -1 {
 		err = oldA.DelOnlinePcCodeCache(c.PcCode)
 	} else if c.Status == 1 {
+		err = oldA.DelOnlinePcCodeCache(oldA.PcCode)
 		err = oldA.UpdateOnlinePcCodeCache(c.PcCode, c.User)
 	}
 	return err