From ad1c4ff9255e1a19567a7df11231bc7173c21a81 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期二, 21 十一月 2023 18:28:36 +0800 Subject: [PATCH] fix --- crontask/cron_task.go | 31 +++++++++++++++++++++++++++++-- 1 files changed, 29 insertions(+), 2 deletions(-) diff --git a/crontask/cron_task.go b/crontask/cron_task.go index c38ef9d..7ae210c 100644 --- a/crontask/cron_task.go +++ b/crontask/cron_task.go @@ -72,7 +72,6 @@ totalNumber := cast.ToInt64(value) if totalNumber != 0 { service.PlcCacheSet(addressItem.Channel, constvar.PlcCacheKeyTotalNumber, totalNumber) - _ = service.NewProgressService().UpdateProgress(addressItem.Channel, cast.ToInt64(totalNumber)) } logx.Infof("plc read total number: %v", totalNumber) } @@ -84,7 +83,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 +126,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 +138,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