enterprise/worker/worker.go

40 lines
844 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 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)
2024-01-07 17:17:33 +08:00
staff := new(Staff)
2024-01-07 18:53:21 +08:00
checkIn := new(Checkin)
2023-10-19 10:07:41 +08:00
2023-10-08 21:22:49 +08:00
// 每天同步企业人事信息
2023-09-05 10:49:24 +08:00
cron.Every(1).Day().At("01:00").Do(func() {
2024-01-07 17:17:33 +08:00
go staff.SyncStaffInfo()
})
//同步每日考勤数据
2024-01-17 22:30:38 +08:00
cron.Every(1).Day().At("05:00").Do(func() {
2024-01-07 17:17:33 +08:00
go checkIn.SyncCheckinDay("")
2023-08-31 22:20:40 +08:00
})
2023-10-08 21:22:49 +08:00
2024-01-10 12:16:48 +08:00
cron.Every(1).Month(1).At("05:20").Do(func() {
go checkIn.SyncCheckinMonth("")
})
2023-10-08 21:22:49 +08:00
// 1-10号计算工资信息
2024-01-10 12:11:27 +08:00
cron.Every(1).Month(1).At("05:30").Do(func() {
2024-01-07 17:17:33 +08:00
go staff.SyncStaffSalary("")
2023-09-04 19:14:02 +08:00
})
2023-10-08 21:22:49 +08:00
//10号晚上8点发送工资单
2024-01-07 17:17:33 +08:00
cron.Every(1).Month(10).At("20:00").Do(func() {
go staff.SendStaffSalaryBill(time.Now().AddDate(0, -1, 0).Format("200601"))
2023-10-08 21:22:49 +08:00
})
2023-08-04 18:47:12 +08:00
cron.StartAsync()
2023-08-04 11:13:41 +08:00
return nil
}