From d9bc2c9e991b2fe925565dfd7d0ec667b64bb52f Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期四, 17 八月 2023 16:01:02 +0800
Subject: [PATCH] 完成bom上报

---
 report/task.go |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/report/task.go b/report/task.go
new file mode 100644
index 0000000..50c2727
--- /dev/null
+++ b/report/task.go
@@ -0,0 +1,57 @@
+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(false)
+			}
+
+			time.Sleep(time.Duration(config.Options.SyncInterval) * time.Second)
+		}
+	}
+}
+
+func HandleBomQuery(msg []byte) error {
+	SendBom(true)
+
+	return nil
+}

--
Gitblit v1.8.0