package service import ( "fmt" "time" "github.com/robfig/cron" ) func SapJobInit() { // test() // c := cron.New() // 02:00 // if _, e := c.AddFunc("5 5 5 * * ", jobMaterial); e != nil { // log.Error("jobMaterial", e) // } // if _, e := c.AddFunc("1 * * * *", jobTransfer); e != nil { // // if _, e := c.AddFunc("@every 1m", jobTransfer); e != nil { // log.Error("transfer ", e) // } duetimecst, _ := time.ParseInLocation("15:04:05", "00:01:00", time.Local) duetimecst1, _ := time.ParseInLocation("15:04:05", "00:00:00", time.Local) spec := fmt.Sprintf("@every %v", duetimecst.Sub(duetimecst1)) c := cron.New() c.AddFunc(spec, func() { AutoSapOrderJob() AutoSrmOrderJob() // fmt.Println(time.Now()) }) c.Start() } func jobMaterial() { t := time.Now() var code string s.SapMaterial(t, code) } func jobTransfer() { autoTransfer() }