- 修复UpdateActStatusByTime中的BUG

This commit is contained in:
gazebo
2019-08-05 16:59:30 +08:00
parent 4b6ed5200f
commit 539cfb31fe
4 changed files with 22 additions and 14 deletions

View File

@@ -81,31 +81,30 @@ func IsImportantTaskRunning(taskName string) bool {
func Init() {
if globals.IsProductEnv() {
ScheduleTimerFunc(doDailyWork, dailyWorkTimeList)
ScheduleTimerFunc("doDailyWork", doDailyWork, dailyWorkTimeList)
ScheduleTimerFuncByInterval(func() {
RefreshRealMobile(jxcontext.AdminCtx, model.VendorIDEBAI, time.Now().Add(-24*time.Hour), utils.DefaultTimeValue, false, true)
}, 5*time.Second, 1*time.Hour)
ScheduleTimerFunc(func() {
ScheduleTimerFunc("auto enable remote store", func() {
cms.EnableHaveRestStores(jxcontext.AdminCtx, false, true)
cms.OpenRemoteStoreByJxStatus(jxcontext.AdminCtx, nil, nil, false, false, true)
}, openRemoteStoreTimeList)
ScheduleTimerFunc(func() {
ScheduleTimerFunc("SaveAndSendAlarmVendorSnapshot", func() {
cms.SaveAndSendAlarmVendorSnapshot(jxcontext.AdminCtx, nil, nil, false)
}, cms.WatchVendorStoreTimeList)
ScheduleTimerFunc(func() {
ScheduleTimerFunc("RefreshPageActs", func() {
act.RefreshPageActs(jxcontext.AdminCtx, []int{model.VendorIDEBAI}, time.Now().Add(-30*24*time.Hour), false)
}, refreshPageActTimeList)
ScheduleTimerFunc(func() {
ScheduleTimerFunc("UpdateActStatusByTime", func() {
dao.UpdateActStatusByTime(dao.GetDB(), time.Now().Add(-48*time.Hour))
}, updateActStatusTimeList)
InitEx()
}
ScheduleTimerFunc(func() {
ScheduleTimerFunc("AutoSaleStoreSku", func() {
cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil, false)
}, autoSaleStoreSkuTimeList)
}
@@ -170,14 +169,15 @@ func RefreshRealMobile(ctx *jxcontext.Context, vendorID int, fromTime, toTime ti
return hint, err
}
func ScheduleTimerFunc(handler func(), timeList []string) {
func ScheduleTimerFunc(name string, handler func(), timeList []string) {
now := time.Now()
nextTime := jxutils.GetNextTimeFromList(now, timeList)
duration := nextTime.Sub(now) + 1*time.Second
globals.SugarLogger.Debugf("ScheduleTimerFunc, duration:%v", duration)
globals.SugarLogger.Debugf("ScheduleTimerFunc, func:%s, duration:%v", name, duration)
utils.AfterFuncWithRecover(duration, func() {
globals.SugarLogger.Debugf("ScheduleTimerFunc func:%s", name)
handler()
ScheduleTimerFunc(handler, timeList)
ScheduleTimerFunc(name, handler, timeList)
})
}