123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- package service
- import (
- "fmt"
- "time"
- "github.com/robfig/cron"
- "kpt.xdmy/apiserver/model"
- )
- var s *Service
- func SapJobInit() {
- 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()
- AutoSapReturnOrderJob()
- AutoSrmReturnOrderJob()
- })
- c.Start()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- c1 := cron.New()
- c1.AddFunc("0 50 23 * * ?", func() {
- fmt.Println(time.Now())
- var t time.Time
- t = time.Now()
- var code string
- pastureList := make([]*model.Pasture, 0)
- err := s.d.DB.Table("pasture").Find(&pastureList)
- fmt.Println(err)
- for _, pasture := range pastureList {
- s.SapSupplier(t, pasture.CompanyCode, pasture.ID)
- s.SapAsset(t, code, pasture.CompanyCode)
- }
- s.SapMaterial(t, code)
- s.d.DB.Exec(`call createEqstatus()`)
- })
-
- duetimecst, _ = time.ParseInLocation("15:04:05", "01:00:00", time.Local)
- duetimecst1, _ = time.ParseInLocation("15:04:05", "00:00:00", time.Local)
- spec1 := fmt.Sprintf("@every %v", duetimecst.Sub(duetimecst1))
- c1.AddFunc(spec1, func() {
- s.d.DB.Exec(`call createRUcode()`)
- })
- duetimecst, _ = time.ParseInLocation("15:04:05", "00:05:00", time.Local)
- duetimecst1, _ = time.ParseInLocation("15:04:05", "00:00:00", time.Local)
- spec2 := fmt.Sprintf("@every %v", duetimecst.Sub(duetimecst1))
- c1.AddFunc(spec2, func() {
- s.d.DB.Exec(`call wxmsg()`)
- })
-
- timeLocalSub, _ := time.ParseInLocation("15:04:05", "00:05:00", time.Local)
- timeLocal, _ := time.ParseInLocation("15:04:05", "00:00:00", time.Local)
- c1.AddFunc(fmt.Sprintf("@every %v", timeLocalSub.Sub(timeLocal)), func() {
- AutoContractToASP()
- })
- c1.Start()
- }
- func jobMaterial() {
- t := time.Now()
- var code string
- s.SapMaterial(t, code)
- }
- func jobTransfer() {
- autoTransfer()
- }
|