job.go 532 B

12345678910111213141516171819202122232425262728293031
  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("5 5 5 * * ", jobMaterial); e != nil {
  11. log.Error("jobMaterial", e)
  12. }
  13. if _, e := c.AddFunc("1 * * * *", jobTransfer); e != nil {
  14. // if _, e := c.AddFunc("@every 1m", jobTransfer); e != nil {
  15. log.Error("transfer ", e)
  16. }
  17. c.Start()
  18. }
  19. func jobMaterial() {
  20. t := time.Now()
  21. var code string
  22. s.SapMaterial(t, code)
  23. }
  24. func jobTransfer() {
  25. autoTransfer()
  26. }