From 20b2f8eb5af35be28e2b1055a7e3f346c8bb322f Mon Sep 17 00:00:00 2001 From: 18209 Date: Fri, 24 Oct 2025 20:12:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9es=E6=B2=A1=E6=9C=89=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E5=81=9A=E4=BF=9D=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- consumers/consumerAXYThemeToES.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/consumers/consumerAXYThemeToES.go b/consumers/consumerAXYThemeToES.go index 06296ba..c84a306 100644 --- a/consumers/consumerAXYThemeToES.go +++ b/consumers/consumerAXYThemeToES.go @@ -157,8 +157,8 @@ func (the *consumerAXYThemeToES) onData(topic string, msg string) bool { log.Printf("安心云 newAtime数据时间 %s 解析错误: %v", newTimeStr, newErr) } - // 只有在两个时间解析成功时才进行比较 - if esErr == nil && newErr == nil && newAtime.After(esAtime) { + // 只有在两个时间解析成功时,且new时间在es时间之后,或者相等的情况下,才进行推送 + if esErr == nil && newErr == nil && (newAtime.After(esAtime) || newAtime.Equal(esAtime)) { judgeBool = true } @@ -191,8 +191,14 @@ func (the *consumerAXYThemeToES) judgeTime(rawMsg string) (string, string) { queryStr := the.getESTimeQueryStr(theme.Station.Structure.Id, theme.Station.Id) TimeTheme, err := the.OutEs.SearchThemeData("anxincloud_last_theme", queryStr) - log.Printf("判断 esTimeStr:%s,newTimeStr:%s", TimeTheme[0].CollectTime, theme.AcqTime) - return TimeTheme[0].CollectTime, theme.AcqTime + //如果es里面没有这个数据时间,呢就返回测点的时间 + if len(TimeTheme) > 0 { + log.Printf("判断 esTimeStr:%s,newTimeStr:%s", TimeTheme[0].CollectTime, theme.AcqTime) + return TimeTheme[0].CollectTime, theme.AcqTime + } else { + log.Printf("esTime 为空, 新时间:%s", theme.AcqTime) + return theme.AcqTime, theme.AcqTime + } } func (the *consumerAXYThemeToES) getESTimeQueryStr(structId, sensorId int) string {