diff --git a/adaptors/振动to江苏省农村公路桥梁监测.go b/adaptors/振动to江苏省农村公路桥梁监测.go index 63da16a..a5cb5dd 100644 --- a/adaptors/振动to江苏省农村公路桥梁监测.go +++ b/adaptors/振动to江苏省农村公路桥梁监测.go @@ -8,6 +8,8 @@ import ( "goInOut/models" "goInOut/utils" "log" + "strconv" + "strings" "time" ) @@ -23,6 +25,12 @@ func (the Adaptor_ZD_JSNCGLQL) Transform(inTopic, rawMsg string) []NeedPush { if err != nil { return nil } + lowerTopic := strings.ToLower(inTopic) + if strings.Contains(lowerTopic, "zdsl") || + strings.Contains(lowerTopic, "cableforce") { + return the.ZDSLtoJSNCGLQL(zd) + } + return the.ZDtoJSNCGLQL(zd) } @@ -68,6 +76,34 @@ func (the Adaptor_ZD_JSNCGLQL) ZDtoJSNCGLQL(zd models.ZD) (result []NeedPush) { return result } +func (the Adaptor_ZD_JSNCGLQL) ZDSLtoJSNCGLQL(zd models.ZD) (result []NeedPush) { + Atime := time.UnixMilli(zd.Ticks) + + sensorDataList := zd.ThemeValue + //获取对方系统 id + sensorCode := the.getSensorCode(strconv.Itoa(zd.SensorId)) + if sensorCode == "" { + log.Printf("振动索力 设备[%s] 无匹配的 江苏农村公路桥梁监测系统 测点id,请检查配置文件", zd.Module) + return + } + + topic := fmt.Sprintf("data/%s/%s", the.BridgeCode, sensorCode) + + var transBytes []byte + //1.添加时间段 + transBytes = append(transBytes, the.getTimeBytes(Atime)...) + + //数据值段 + bs := utils.Float32ToBytes(sensorDataList[0]) + transBytes = append(transBytes, bs...) + + result = append(result, NeedPush{ + Topic: topic, + Payload: transBytes, + }) + + return result +} func (the Adaptor_ZD_JSNCGLQL) getSensorCode(rawSensorName string) string { v, isValid := the.IdMap[rawSensorName] diff --git a/adaptors/统一采集to江苏省农村公路桥梁监测.go b/adaptors/统一采集to江苏省农村公路桥梁监测.go index a49745c..79dba45 100644 --- a/adaptors/统一采集to江苏省农村公路桥梁监测.go +++ b/adaptors/统一采集to江苏省农村公路桥梁监测.go @@ -55,7 +55,7 @@ func (the Adaptor_TYCJ_JSNCGLQL) TYCJtoJSNCGLQL(tycj models.TYCJ) (result []Need for _, sensorData := range sensorDataList { - //4.添加数据值段 + //添加数据值段 bs := utils.Float32ToBytes(sensorData) transBytes = append(transBytes, bs...) } diff --git a/configFiles/config_江苏农村公路桥梁.json b/configFiles/config_江苏农村公路桥梁.json index c5b360c..f52f500 100644 --- a/configFiles/config_江苏农村公路桥梁.json +++ b/configFiles/config_江苏农村公路桥梁.json @@ -11,6 +11,7 @@ "Topics": [ "upload/uds/+", "upload/ZD/+", + "upload/ZDSL/+", "upload/gdnd/+" ] } @@ -40,6 +41,9 @@ "m1c1": "LHTDQ-VIB-C08-001-01", "m1c2": "LHTDQ-VIB-L03-001-01" }, + "ZDSLensorMap": { + "333701": "LHTDQ-SL-C08-001-01" + }, "GDNDsensorMap": { "DY-DIS-ZG03-01": "LHTDQ-GDND-G03-003-01", "m3c2": "LHTDQ-GDND-G03-003-02" diff --git a/consumers/JSNCGLQL/config.go b/consumers/JSNCGLQL/config.go index 6849a12..7911724 100644 --- a/consumers/JSNCGLQL/config.go +++ b/consumers/JSNCGLQL/config.go @@ -24,6 +24,7 @@ type SensorConfig struct { TYCJsensorMap map[string]string `json:"TYCJsensorMap"` ZDsensorMap map[string]string `json:"ZDsensorMap"` GDNDsensorMap map[string]string `json:"GDNDsensorMap"` + ZDSLensorMap map[string]string `json:"ZDSLensorMap"` } type SensorInfo struct { diff --git a/consumers/consumerJSNCGLQL.go b/consumers/consumerJSNCGLQL.go index b880c33..c36b377 100644 --- a/consumers/consumerJSNCGLQL.go +++ b/consumers/consumerJSNCGLQL.go @@ -116,6 +116,9 @@ func (the *consumerJSNCGLQL) getAdaptor(flag string) (adaptor adaptors.IAdaptor4 case "upload/ZD": log.Printf("[振动软件]-上报,准备处理") adaptor = adaptors.Adaptor_ZD_JSNCGLQL{IdMap: the.Info.ZDsensorMap, BridgeCode: bridgeCode} + case "upload/ZDSL": + log.Printf("[振动索力软件]-上报,准备处理") + adaptor = adaptors.Adaptor_ZD_JSNCGLQL{IdMap: the.Info.ZDSLensorMap, BridgeCode: bridgeCode} case "upload/gdnd": log.Printf("[光电挠度]-上报,准备处理") adaptor = adaptors.Adaptor_GDND2LA_JSNCGLQL{IdMap: the.Info.GDNDsensorMap, BridgeCode: bridgeCode}