job.go 537 B

12345678910111213141516171819202122232425262728293031323334
  1. package routers
  2. import (
  3. // "github.com/robfig/cron"
  4. "time"
  5. "github.com/robfig/cron/v3"
  6. "kpt.xdmy/apiserver/service"
  7. "kpt.xdmy/pkg/log"
  8. )
  9. func SapJobInit(s *service.Service) {
  10. svc = s
  11. c := cron.New()
  12. // 02:00
  13. if _, e := c.AddFunc("00 00 02 * * *", jobMaterial); e != nil {
  14. log.Error("jobMaterial", e)
  15. }
  16. if _, e := c.AddFunc("00 00 02 * * *", jobTransfer); e != nil {
  17. log.Error("transfer", e)
  18. }
  19. c.Start()
  20. }
  21. func jobMaterial() {
  22. t := time.Now()
  23. var code string
  24. svc.SapMaterial(t, code)
  25. }
  26. func jobTransfer() {
  27. }