From 29356da016392c6eaf46cacffb7aec50fdc630c0 Mon Sep 17 00:00:00 2001 From: 18209 Date: Thu, 25 Sep 2025 09:35:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A5=E5=BA=93es=E7=9A=84=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E6=94=B9=E6=88=902025-09-29T14:11:39.347+080?= =?UTF-8?q?0=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adaptors/安心云最新主题数据toE5.go | 7 ++++++- adaptors/知物云最新主题数据toES.go | 4 +++- configFiles/config_安心云测点数据_最新同步.yaml | 2 -- consumers/consumerAXYThemeToES.go | 5 ++++- models/esTheme.go | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/adaptors/安心云最新主题数据toE5.go b/adaptors/安心云最新主题数据toE5.go index 589bfb3..66b700a 100644 --- a/adaptors/安心云最新主题数据toE5.go +++ b/adaptors/安心云最新主题数据toE5.go @@ -43,11 +43,16 @@ func (the Adaptor_Anxinyun_LastTheme) Theme2Es(theme models.AXYSavoirTheme) *mod //} // Atime, err := time.Parse("2006-01-02T15:04:05.000+0800", theme.AcqTime) + AtimeStr := Atime.Format("2006-01-02T15:04:05.000+0800") + log.Printf("AtimeStr[%s]", AtimeStr) if err != nil { log.Printf("安心云 测点[%s] 数据时间 %s 解析错误", theme.Station.Name, theme.AcqTime) return nil } + //now := time.Now() + //formattedTime := now.Format("2006-01-02T15:04:05.000") + themeData := &models.EsTheme{ SensorName: theme.Station.Name, FactorName: theme.Station.Factor.Name, @@ -55,7 +60,7 @@ func (the Adaptor_Anxinyun_LastTheme) Theme2Es(theme models.AXYSavoirTheme) *mod Data: theme.Data, FactorProtoName: theme.Station.Factor.ProtoName, Factor: theme.Station.Factor.Id, - CollectTime: Atime, + CollectTime: AtimeStr, Sensor: theme.Station.Id, Structure: theme.Station.Structure.Id, IotaDevice: []string{}, diff --git a/adaptors/知物云最新主题数据toES.go b/adaptors/知物云最新主题数据toES.go index c6379d2..cc3fc77 100644 --- a/adaptors/知物云最新主题数据toES.go +++ b/adaptors/知物云最新主题数据toES.go @@ -43,6 +43,8 @@ func (the Adaptor_Savoir_LastTheme) Theme2Es(theme models.SavoirTheme) *models.E //} // Atime, err := time.Parse("2006-01-02T15:04:05.000+0800", theme.AcqTime) + AtimeStr := Atime.Format("2006-01-02T15:04:05.000+0800") + log.Printf("AtimeStr[%s]", AtimeStr) if err != nil { log.Printf("知物云 测点[%s] 数据时间 %s 解析错误", theme.Station.Name, theme.AcqTime) return nil @@ -55,7 +57,7 @@ func (the Adaptor_Savoir_LastTheme) Theme2Es(theme models.SavoirTheme) *models.E Data: theme.Data, FactorProtoName: theme.Station.Factor.ProtoName, Factor: theme.Station.Factor.Id, - CollectTime: Atime, + CollectTime: AtimeStr, Sensor: theme.Station.Id, Structure: theme.Station.Structure.Id, IotaDevice: []string{}, diff --git a/configFiles/config_安心云测点数据_最新同步.yaml b/configFiles/config_安心云测点数据_最新同步.yaml index 70de5e6..730ade0 100644 --- a/configFiles/config_安心云测点数据_最新同步.yaml +++ b/configFiles/config_安心云测点数据_最新同步.yaml @@ -11,8 +11,6 @@ ioConfig: es: address: - "http://10.8.30.150:30847" - # - "http://10.8.30.155:5601" - # - "http://10.8.30.160:30092" index: "anxincloud_last_theme" #es存测点最后一条数据的新索引 auth: userName: post diff --git a/consumers/consumerAXYThemeToES.go b/consumers/consumerAXYThemeToES.go index 10c19ae..aa3010c 100644 --- a/consumers/consumerAXYThemeToES.go +++ b/consumers/consumerAXYThemeToES.go @@ -80,6 +80,7 @@ func (the *consumerAXYThemeToES) outputInitial() error { func (the *consumerAXYThemeToES) sinkTask() { intervalSec := the.Info.IoConfig.Out.Es.Interval + log.Printf("读取配置文件intervalSec[%d]", intervalSec) ticker := time.NewTicker(time.Duration(intervalSec) * time.Second) defer ticker.Stop() for { @@ -108,7 +109,7 @@ func (the *consumerAXYThemeToES) toSink() { }) if len(themes) > 0 { index := the.Info.IoConfig.Out.Es.Index - log.Printf("写入es [%s] %d条", index, len(themes)) + log.Printf("写入es [%s] %d条,%s", index, len(themes), themes) the.OutEs.BulkWriteThemes2Es(index, themes) the.sinkMap.Clear() } @@ -146,7 +147,9 @@ func (the *consumerAXYThemeToES) onData(topic string, msg string) bool { the.dataCache <- needPush } else { s, _ := json.Marshal(needPush) + if needPush != nil { + log.Printf("onData 测点[%d] needPush= %s", needPush.Sensor, s) if needPush.Sensor == the.logTagId { log.Printf("onData 测点[%d] 异常needPush= %s", needPush.Sensor, s) } diff --git a/models/esTheme.go b/models/esTheme.go index ccaa4e8..cf7a993 100644 --- a/models/esTheme.go +++ b/models/esTheme.go @@ -9,7 +9,7 @@ type EsTheme struct { Data map[string]any `json:"data"` FactorProtoName string `json:"factor_proto_name"` Factor int `json:"factor"` - CollectTime time.Time `json:"collect_time"` + CollectTime string `json:"collect_time"` Sensor int `json:"sensor"` Structure int `json:"structure"` IotaDevice []string `json:"iota_device"`