enterprise/worker/worker.go

32 lines
606 B
Go
Raw Normal View History

2023-08-04 11:13:41 +08:00
package worker
2023-08-04 18:27:37 +08:00
import (
"github.com/go-co-op/gocron"
"time"
)
2023-08-04 20:35:50 +08:00
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
}
2023-08-04 11:13:41 +08:00
func Init() error {
2023-08-04 18:27:37 +08:00
timezone, _ := time.LoadLocation("Asia/Shanghai")
cron := gocron.NewScheduler(timezone)
2023-08-31 10:28:46 +08:00
cron.Every(5).Minute().Do(func() {
2023-08-04 18:27:37 +08:00
go SyncCheckin(time.Now().Format("2006-01-02"))
})
2023-08-04 18:47:12 +08:00
2023-08-31 22:20:40 +08:00
cron.Every(1).Day().At("03:00").Do(func() {
go SyncStaffInfo()
})
2023-09-04 19:14:02 +08:00
cron.Every(1).Month(1, 2, 3, 4, 5).At("02:00").Do(func() {
go SyncStaffSalary("")
})
2023-08-04 18:47:12 +08:00
cron.StartAsync()
2023-08-04 11:13:41 +08:00
return nil
}