diff --git a/app/task/svc/svc_egg_energy_auto_update_user_access.go b/app/task/svc/svc_egg_energy_auto_update_user_access.go index 9dabbd0..71dd5dd 100644 --- a/app/task/svc/svc_egg_energy_auto_update_user_access.go +++ b/app/task/svc/svc_egg_energy_auto_update_user_access.go @@ -2,6 +2,7 @@ package svc import ( "applet/app/utils" + "applet/app/utils/cache" "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/es" es2 "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es" @@ -11,6 +12,7 @@ import ( ) const deleteLimit = 1000 +const EggEnergyAutoUpdateUserAccessLockKey = "egg_energy_auto_update_user_access_lock_key" // EggEnergyAutoUpdateUserAccess 自动更新用户访问次数记录 func EggEnergyAutoUpdateUserAccess(engine *xorm.Engine) { @@ -28,6 +30,13 @@ func EggEnergyAutoUpdateUserAccess(engine *xorm.Engine) { //TODO::只在凌晨两点 ~ 凌晨六点运行 return } + getString, _ := cache.GetString(EggEnergyAutoUpdateUserAccessLockKey) + if getString != "" { + fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", "上一次蛋蛋分统计未执行完") + return + } + cache.SetEx(EggEnergyAutoUpdateUserAccessLockKey, "running", 4*60*60) // 4 h + defer cache.Del(EggEnergyAutoUpdateUserAccessLockKey) // 获取当周信息 year, week := time.Now().ISOWeek() diff --git a/app/task/svc/svc_egg_energy_automatic_scoring.go b/app/task/svc/svc_egg_energy_automatic_scoring.go index c149aeb..d4a9f66 100644 --- a/app/task/svc/svc_egg_energy_automatic_scoring.go +++ b/app/task/svc/svc_egg_energy_automatic_scoring.go @@ -38,7 +38,6 @@ func EggEnergyAutomaticScoring(engine *xorm.Engine) { defer cache.Del(EggEnergyAutomaticScoringLockKey) now := time.Now() - fmt.Println(now.Hour()) weekday := now.Weekday() if !(weekday != time.Wednesday && now.Hour() >= 0 && now.Hour() < 4) { //TODO::只在周三凌晨零点 ~ 凌晨六点运行 (预计六点可以全部更新完,减少查询次数)