| | |
| | | import ( |
| | | "apsClient/conf" |
| | | "apsClient/constvar" |
| | | "apsClient/nsq" |
| | | "apsClient/pkg/ecode" |
| | | "apsClient/pkg/logx" |
| | | "apsClient/service" |
| | | "fmt" |
| | | "github.com/go-co-op/gocron" |
| | | "github.com/spf13/cast" |
| | | "time" |
| | |
| | | return err |
| | | } |
| | | |
| | | s.Every(totalNumberTimeInterval).Seconds().StartImmediately().Do(func() { |
| | | s.Every(totalNumberTimeInterval).Seconds().Do(func() { |
| | | plcConfig, code := service.NewDevicePlcService().GetDevicePlc() |
| | | if code != ecode.OK { |
| | | return |
| | |
| | | logx.Infof("plc read total number:%v, err:%v", totalNumber, err) |
| | | }) |
| | | |
| | | s.Every(60).Seconds().StartImmediately().Do(SyncProductionProgress) //同步生产数据 |
| | | s.StartAsync() |
| | | return nil |
| | | } |
| | | |
| | | func SyncProductionProgress() { |
| | | progress, err := service.NewProgressService().GetCurrentProgress() |
| | | if err != nil { |
| | | return |
| | | } |
| | | if progress == nil { |
| | | return |
| | | } |
| | | |
| | | caller := nsq.NewCaller(fmt.Sprintf(constvar.NsqTopicSyncTaskProgress, conf.Conf.NsqConf.NodeId), "") |
| | | err = caller.Send(progress) |
| | | if err != nil { |
| | | logx.Errorf("SyncProductionProgress error:%v", err.Error()) |
| | | } |
| | | } |