From 6267ca2039e6538e4f687071e71e2ad2dda11d09 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期一, 13 十一月 2023 17:04:57 +0800 Subject: [PATCH] 系统启动时,保存systemDeviceId记录并上报 --- crontask/cron_task.go | 30 +++++++++++++++++++++++++++++- 1 files changed, 29 insertions(+), 1 deletions(-) diff --git a/crontask/cron_task.go b/crontask/cron_task.go index c38ef9d..fa684d2 100644 --- a/crontask/cron_task.go +++ b/crontask/cron_task.go @@ -84,7 +84,7 @@ s.Every(60).Seconds().Do(SyncProductionProgress) //鍚屾鐢熶骇鏁版嵁 s.Every(30).Seconds().Do(SyncTaskStatus) //鍚屾浠诲姟鐘舵�� s.Every(10).Seconds().Do(CheckNsqConn) //鏌ヨnsq杩炴帴 - + s.Every(30).Seconds().Do(ReportData) //涓婃姤鏁版嵁 } s.Every(20).Seconds().Do(QueryClusterStatus) //鏌ヨ闆嗙兢鑺傜偣鏁伴噺 @@ -127,6 +127,7 @@ err = caller.Send(msg) if err != nil { logx.Errorf("sync task status send msg error:%v", err.Error()) + continue } syncOkIds = append(syncOkIds, record.ID) } @@ -138,6 +139,33 @@ } } +func ReportData() { + records, err := model.NewReportsToCloudSearch(nil).SetOrder("id desc").SetPage(1, 100).FindNotTotal() + if err != nil { + logx.Errorf("ReportData get records err:%v", err) + } + okIds := make([]uint, 0, len(records)) + for _, record := range records { + msg := &common.MsgReportData{ + ReportType: record.ReportType, + Content: record.Content, + } + caller := nsq.NewCaller(fmt.Sprintf(constvar.NsqTopicApsClientReportData, conf.Conf.NsqConf.NodeId), "") + err = caller.Send(msg) + if err != nil { + logx.Errorf("sync task status send msg error:%v", err.Error()) + continue + } + okIds = append(okIds, record.ID) + } + if len(okIds) > 0 { + err = model.NewReportsToCloudSearch(nil).SetIDs(okIds).Delete() + if err != nil { + logx.Errorf("ReportData delete report ok records error:%v", err) + } + } +} + func RestartTask(isMaster bool) error { if s != nil { s.Stop() -- Gitblit v1.8.0