push_data.go
570 字节
package pushdata
import (
"time"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
)
func PushData() {
//每天16点运行
nowTime := time.Now()
y, m, d := nowTime.Date()
t1 := time.Date(y, m, d, 16, 0, 0, 0, time.Local) //今天的16点
interval := t1.Sub(nowTime)
if interval < 0 {
interval = (24 * time.Hour) + interval
}
timer := time.NewTimer(interval)
for {
<-timer.C
nowTime = time.Now()
err := SendDataStaffAssess(nowTime)
if err != nil {
log.Logger.Error("发送每日评估任务")
}
timer.Reset(24 * time.Hour)
}
}