job.go 489 B

123456789101112131415161718192021222324252627282930
  1. package service
  2. import (
  3. "time"
  4. "github.com/robfig/cron/v3"
  5. log "github.com/sirupsen/logrus"
  6. )
  7. func SapJobInit() {
  8. c := cron.New()
  9. // 02:00
  10. // if _, e := c.AddFunc("00 00 02 * * *", jobMaterial); e != nil {
  11. // log.Error("jobMaterial", e)
  12. // }
  13. if _, e := c.AddFunc("30 0/1 6-23 * * ? ", jobTransfer); e != nil {
  14. log.Error("transfer", e)
  15. }
  16. c.Start()
  17. }
  18. func jobMaterial() {
  19. t := time.Now()
  20. var code string
  21. s.SapMaterial(t, code)
  22. }
  23. func jobTransfer() {
  24. autoTransfer()
  25. }