1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
| package report
|
| import (
| "context"
| "kingdee-dbapi/logger"
| )
|
| var ctx context.Context
| var cancel context.CancelFunc
|
| func StartReport() {
| ctx, cancel = context.WithCancel(context.Background())
| go Loop(ctx)
| }
|
| func RestartReport() {
| cancel()
|
| StartReport()
| }
|
| func Loop(c context.Context) {
| logger.Debug("启动数据上报任务")
| for {
| select {
| case <-c.Done():
| logger.Debug("停止上报")
| return
| default:
| // 上报订单
| SendOrder()
|
| // 上报即时库存
| SendInventory()
|
| // 测试查询请求
| //sql := []byte("select * from t_icitem where FItemID=3316")
| //ok := nsqclient.Produce(config.Options.QueryTopic, sql)
| //logger.Debug("测试请求接口, %v", ok)
| //
| //time.Sleep(time.Duration(config.Options.SyncInterval) * time.Second)
| }
| }
| }
|
|