From f9f035c4c3f02f00939c59ea51b5cd25a70c26c0 Mon Sep 17 00:00:00 2001 From: lucas Date: Wed, 2 Apr 2025 16:09:01 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BF=AE=E6=94=B9=E6=B1=9F=E8=8B=8F?= =?UTF-8?q?=E5=86=9C=E6=9D=91=E5=85=AC=E8=B7=AF=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5=20=20=E6=94=AF=E6=8C=81=E5=B7=9E=E6=B4=AA?= =?UTF-8?q?=E6=B2=B3=E7=89=B9=E5=A4=A7=E6=A1=A5=E4=BB=A5=E5=8F=8A=E4=B8=89?= =?UTF-8?q?=E5=B9=B2=E6=B8=A0=E5=A4=A7=E6=A1=A5=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../振动to江苏省农村公路桥梁监测.go | 14 +++++++------- .../config_江苏农村公路桥梁.json | 8 ++++---- ...物云果子沟_中交华联_特征数据.yaml | 0 consumers/consumerJSNCGLQL.go | 2 +- models/ZD.go | 11 +++++++++++ 5 files changed, 23 insertions(+), 12 deletions(-) rename configFiles/{弃用备份 => }/config_江苏农村公路桥梁.json (87%) rename configFiles/{ => 弃用备份}/config_知物云果子沟_中交华联_特征数据.yaml (100%) diff --git a/adaptors/振动to江苏省农村公路桥梁监测.go b/adaptors/振动to江苏省农村公路桥梁监测.go index a5cb5dd..cf41c82 100644 --- a/adaptors/振动to江苏省农村公路桥梁监测.go +++ b/adaptors/振动to江苏省农村公路桥梁监测.go @@ -20,7 +20,7 @@ type Adaptor_ZD_JSNCGLQL struct { } func (the Adaptor_ZD_JSNCGLQL) Transform(inTopic, rawMsg string) []NeedPush { - zd := models.ZD{} + zd := models.ZDnew{} err := json.Unmarshal([]byte(rawMsg), &zd) if err != nil { return nil @@ -34,12 +34,12 @@ func (the Adaptor_ZD_JSNCGLQL) Transform(inTopic, rawMsg string) []NeedPush { return the.ZDtoJSNCGLQL(zd) } -func (the Adaptor_ZD_JSNCGLQL) ZDtoJSNCGLQL(zd models.ZD) (result []NeedPush) { +func (the Adaptor_ZD_JSNCGLQL) ZDtoJSNCGLQL(zd models.ZDnew) (result []NeedPush) { Atime := time.UnixMilli(zd.Ticks) sensorDataList := zd.AccValues //获取对方系统 id - sensorCode := the.getSensorCode(zd.Module) + sensorCode := the.getSensorCode(strconv.Itoa(zd.SensorId)) if sensorCode == "" { log.Printf("振动 设备[%s] 无匹配的 江苏农村公路桥梁监测系统 测点id,请检查配置文件", zd.Module) return @@ -47,7 +47,7 @@ func (the Adaptor_ZD_JSNCGLQL) ZDtoJSNCGLQL(zd models.ZD) (result []NeedPush) { topic := fmt.Sprintf("data/%s/%s", the.BridgeCode, sensorCode) //数据秒数 - seconds := len(zd.AccValues) / zd.Frequency + seconds := len(zd.AccValues) / int(zd.Frequency) for i := 0; i < seconds; i++ { var transBytes []byte @@ -55,8 +55,8 @@ func (the Adaptor_ZD_JSNCGLQL) ZDtoJSNCGLQL(zd models.ZD) (result []NeedPush) { //1.添加时间段 transBytes = append(transBytes, the.getTimeBytes(onceTime)...) - startIndex := (0 + i) * zd.Frequency - endIndex := (1 + i) * zd.Frequency + startIndex := (0 + i) * int(zd.Frequency) + endIndex := (1 + i) * int(zd.Frequency) if endIndex > len(sensorDataList) { endIndex = len(sensorDataList) } @@ -76,7 +76,7 @@ func (the Adaptor_ZD_JSNCGLQL) ZDtoJSNCGLQL(zd models.ZD) (result []NeedPush) { return result } -func (the Adaptor_ZD_JSNCGLQL) ZDSLtoJSNCGLQL(zd models.ZD) (result []NeedPush) { +func (the Adaptor_ZD_JSNCGLQL) ZDSLtoJSNCGLQL(zd models.ZDnew) (result []NeedPush) { Atime := time.UnixMilli(zd.Ticks) sensorDataList := zd.ThemeValue diff --git a/configFiles/弃用备份/config_江苏农村公路桥梁.json b/configFiles/config_江苏农村公路桥梁.json similarity index 87% rename from configFiles/弃用备份/config_江苏农村公路桥梁.json rename to configFiles/config_江苏农村公路桥梁.json index f52f500..1269c0b 100644 --- a/configFiles/弃用备份/config_江苏农村公路桥梁.json +++ b/configFiles/config_江苏农村公路桥梁.json @@ -5,12 +5,12 @@ "mqtt": { "host": "10.8.30.160", "port": 30883, - "userName": "goUpload", + "userName": "goInOut", "password": "", - "clientId": "goUpload_JSNCGLQL", + "clientId": "goInOut_JSNCGLQL", "Topics": [ "upload/uds/+", - "upload/ZD/+", + "upload/daas/+", "upload/ZDSL/+", "upload/gdnd/+" ] @@ -38,7 +38,7 @@ "m1c2": "LHTDQ-RSG-L04-001-03" }, "ZDsensorMap": { - "m1c1": "LHTDQ-VIB-C08-001-01", + "35968": "LHTDQ-VIB-C08-001-01", "m1c2": "LHTDQ-VIB-L03-001-01" }, "ZDSLensorMap": { diff --git a/configFiles/config_知物云果子沟_中交华联_特征数据.yaml b/configFiles/弃用备份/config_知物云果子沟_中交华联_特征数据.yaml similarity index 100% rename from configFiles/config_知物云果子沟_中交华联_特征数据.yaml rename to configFiles/弃用备份/config_知物云果子沟_中交华联_特征数据.yaml diff --git a/consumers/consumerJSNCGLQL.go b/consumers/consumerJSNCGLQL.go index 25c651c..e14b653 100644 --- a/consumers/consumerJSNCGLQL.go +++ b/consumers/consumerJSNCGLQL.go @@ -113,7 +113,7 @@ func (the *consumerJSNCGLQL) getAdaptor(flag string) (adaptor adaptors.IAdaptor4 case "upload/uds": log.Printf("[统一采集软件]-上报,准备处理") adaptor = adaptors.Adaptor_TYCJ_JSNCGLQL{IdMap: the.Info.TYCJsensorMap, BridgeCode: bridgeCode} - case "upload/ZD": + case "upload/ZD", "upload/daas": log.Printf("[振动软件]-上报,准备处理") adaptor = adaptors.Adaptor_ZD_JSNCGLQL{IdMap: the.Info.ZDsensorMap, BridgeCode: bridgeCode} case "upload/ZDSL": diff --git a/models/ZD.go b/models/ZD.go index 41728bb..3356322 100644 --- a/models/ZD.go +++ b/models/ZD.go @@ -10,3 +10,14 @@ type ZD struct { AccValues []float32 `json:"AccValues"` Ticks int64 `json:"Ticks"` //毫秒级 } + +type ZDnew struct { + SensorId int `json:"Sensorid"` + Module string `json:"Module"` + Channel int `json:"Channel"` + Frequency float32 `json:"Frequency,omitempty"` + ThemeValue []float32 `json:"ThemeValue"` + RawValues []float32 `json:"RawValues"` + AccValues []float32 `json:"AccValues"` + Ticks int64 `json:"Ticks"` //毫秒级 +}