worker
This commit is contained in:
parent
f12156cfed
commit
866b71f49e
|
@ -3,11 +3,12 @@ package main
|
|||
import (
|
||||
"enterprise/common/config"
|
||||
"enterprise/common/global"
|
||||
"enterprise/common/model"
|
||||
"enterprise/server"
|
||||
"enterprise/worker"
|
||||
)
|
||||
|
||||
func main() {
|
||||
func main22() {
|
||||
config.LoadServerConfig()
|
||||
global.InitGlobal()
|
||||
|
||||
|
@ -20,11 +21,11 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
func main22() {
|
||||
func main() {
|
||||
config.LoadServerConfig()
|
||||
global.InitGlobal()
|
||||
//cfg := config.GetConfig()
|
||||
|
||||
//new(worker.Checkin).SyncCheckinDay("2024-01-17")
|
||||
new(worker.Staff).SyncStaffInfo()
|
||||
new(worker.Approval).Sync("202401", model.ApprovalTypeRefund)
|
||||
}
|
||||
|
|
|
@ -41,6 +41,9 @@ func (s *Approval) Sync(month, tp string) {
|
|||
log.Errorf("approve GetDetail error :%s", err.Error())
|
||||
continue
|
||||
}
|
||||
if detail.SpStatus != 2 {
|
||||
continue
|
||||
}
|
||||
if tp == model.ApprovalTypeCheckin {
|
||||
s.saveCheckin(detail)
|
||||
} else if tp == model.ApprovalTypeRefund {
|
||||
|
@ -83,13 +86,10 @@ func (s *Approval) saveRefund(detail *qyweixin.ApproveDetail) {
|
|||
log.Errorf("db error :%s", err.Error())
|
||||
return
|
||||
}
|
||||
if old == nil {
|
||||
_, err = dbDao.Create(newData)
|
||||
} else {
|
||||
newData.Id = old.Id
|
||||
newData.CreateTime = old.CreateTime
|
||||
err = dbDao.Update(newData)
|
||||
if old != nil {
|
||||
return
|
||||
}
|
||||
_, err = dbDao.Create(newData)
|
||||
if err != nil {
|
||||
log.Errorf("db error :%s", err.Error())
|
||||
}
|
||||
|
@ -104,13 +104,10 @@ func (s *Approval) saveVacation(detail *qyweixin.ApproveDetail) {
|
|||
log.Errorf("db error :%s", err.Error())
|
||||
return
|
||||
}
|
||||
if old == nil {
|
||||
_, err = dbDao.Create(newData)
|
||||
} else {
|
||||
newData.Id = old.Id
|
||||
newData.CreateTime = old.CreateTime
|
||||
err = dbDao.Update(newData)
|
||||
if old != nil {
|
||||
return
|
||||
}
|
||||
_, err = dbDao.Create(newData)
|
||||
if err != nil {
|
||||
log.Errorf("db error :%s", err.Error())
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package worker
|
||||
|
||||
import (
|
||||
"enterprise/common/model"
|
||||
"github.com/go-co-op/gocron"
|
||||
"time"
|
||||
)
|
||||
|
@ -10,6 +11,7 @@ func Init() error {
|
|||
cron := gocron.NewScheduler(timezone)
|
||||
staff := new(Staff)
|
||||
checkIn := new(Checkin)
|
||||
approve := new(Approval)
|
||||
|
||||
// 每天同步企业人事信息
|
||||
cron.Every(1).Day().At("01:00").Do(func() {
|
||||
|
@ -21,12 +23,17 @@ func Init() error {
|
|||
go checkIn.SyncCheckinDay("")
|
||||
})
|
||||
|
||||
cron.Every(1).Month(1).At("05:20").Do(func() {
|
||||
go checkIn.SyncCheckinMonth("")
|
||||
//每月1号同步上月考勤、补卡审批、请假审批、报销审批
|
||||
cron.Every(1).Month(1).At("05:30").Do(func() {
|
||||
lastMonth := time.Now().AddDate(0, -1, 0).Format("200601")
|
||||
checkIn.SyncCheckinMonth("")
|
||||
approve.Sync(lastMonth, model.ApprovalTypeCheckin)
|
||||
approve.Sync(lastMonth, model.ApprovalTypeVacation)
|
||||
approve.Sync(lastMonth, model.ApprovalTypeRefund)
|
||||
})
|
||||
|
||||
// 1-10号计算工资信息
|
||||
cron.Every(1).Month(1).At("05:30").Do(func() {
|
||||
// 1号计算工资信息
|
||||
cron.Every(1).Month(1).At("06:00").Do(func() {
|
||||
go staff.SyncStaffSalary("")
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue