| | |
| | | package crontask |
| | | |
| | | import ( |
| | | "apsClient/conf" |
| | | "apsClient/constvar" |
| | | "apsClient/pkg/ecode" |
| | | "apsClient/pkg/logx" |
| | |
| | | ) |
| | | |
| | | func InitTask() error { |
| | | |
| | | finishNumberTimeInterval := conf.Conf.PLC.FinishNumberTimeInterval |
| | | totalNumberTimeInterval := conf.Conf.PLC.TotalNumberTimeInterval |
| | | if finishNumberTimeInterval == 0 { |
| | | finishNumberTimeInterval = 6 |
| | | } |
| | | if totalNumberTimeInterval == 0 { |
| | | totalNumberTimeInterval = 60 |
| | | } |
| | | s := gocron.NewScheduler(time.UTC) |
| | | _, err := s.Every(9).Seconds().StartImmediately().Do(func() { |
| | | _, err := s.Every(finishNumberTimeInterval).Seconds().StartImmediately().Do(func() { |
| | | plcConfig, code := service.NewDevicePlcService().GetDevicePlc() |
| | | if code != ecode.OK { |
| | | return |
| | |
| | | return err |
| | | } |
| | | |
| | | s.Every(60).Seconds().StartImmediately().Do(func() { |
| | | s.Every(totalNumberTimeInterval).Seconds().StartImmediately().Do(func() { |
| | | plcConfig, code := service.NewDevicePlcService().GetDevicePlc() |
| | | if code != ecode.OK { |
| | | return |