|
|
@ -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] |
|
|
|