enterprise/worker/worker.go

32 lines
623 B
Go

package worker
import (
"github.com/go-co-op/gocron"
"time"
)
func Init1() error {
for i := 0; i < 120; i++ {
day := time.Now().AddDate(0, 0, -1-i).Format("2006-01-02")
SyncCheckin(day)
}
return nil
}
func Init() error {
timezone, _ := time.LoadLocation("Asia/Shanghai")
cron := gocron.NewScheduler(timezone)
cron.Every(10).Minute().Do(func() {
go SyncCheckin(time.Now().Format("2006-01-02"))
})
cron.Every(1).Day().At("01:00").Do(func() {
go SyncStaffInfo()
})
cron.Every(1).Month(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).At("02:00").Do(func() {
go SyncStaffSalary("")
})
cron.StartAsync()
return nil
}