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
45
46
47
48
49
50
51
| package report
|
| import (
| "context"
| "time"
|
| "kingdee-dbapi/config"
| "kingdee-dbapi/logger"
| )
|
| var ctx context.Context
| var cancel context.CancelFunc
|
| func Start() {
| ctx, cancel = context.WithCancel(context.Background())
| go queryTasks(ctx)
| }
|
| func RestartReport() {
| cancel()
|
| Start()
| }
|
| func queryTasks(c context.Context) {
| logger.Debug("启动数据上报任务")
| for {
| select {
| case <-c.Done():
| logger.Debug("停止上报")
| return
| default:
| // 上报订单
| if config.Options.OrderTopic != "" {
| SendOrder()
| }
|
| // 上报即时库存
| if config.Options.InventoryTopic != "" {
| SendInventory()
| }
|
| // 上报bom
| if config.Options.BomTopic != "" {
| SendBom(true)
| }
|
| time.Sleep(time.Duration(config.Options.SyncInterval) * time.Second)
| }
| }
| }
|
|