File was renamed from report/loop.go |
| | |
| | | var ctx context.Context |
| | | var cancel context.CancelFunc |
| | | |
| | | func StartReport() { |
| | | func Start() { |
| | | ctx, cancel = context.WithCancel(context.Background()) |
| | | go Loop(ctx) |
| | | go queryTasks(ctx) |
| | | } |
| | | |
| | | func RestartReport() { |
| | | cancel() |
| | | |
| | | StartReport() |
| | | Start() |
| | | } |
| | | |
| | | func Loop(c context.Context) { |
| | | func queryTasks(c context.Context) { |
| | | logger.Debug("启动数据上报任务") |
| | | for { |
| | | select { |
| | |
| | | return |
| | | default: |
| | | // 上报订单 |
| | | SendOrder() |
| | | if config.Options.OrderTopic != "" { |
| | | SendOrder() |
| | | } |
| | | |
| | | // 上报即时库存 |
| | | SendInventory() |
| | | if config.Options.InventoryTopic != "" { |
| | | SendInventory() |
| | | } |
| | | |
| | | // 测试查询请求 |
| | | //sql := []byte("select * from t_icitem where FItemID=3316") |
| | | //ok := nsqclient.Produce(config.Options.SqlQueryTopic, sql) |
| | | //logger.Debug("测试请求接口, %v", ok) |
| | | // 上报bom |
| | | if config.Options.BomTopic != "" { |
| | | SendBom(true) |
| | | } |
| | | |
| | | time.Sleep(time.Duration(config.Options.SyncInterval) * time.Second) |
| | | } |