You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
39 lines
1.1 KiB
3 weeks ago
|
package adaptors
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"fmt"
|
||
|
"goInOut/consumers/SinoGnssMySQL"
|
||
|
)
|
||
|
|
||
|
// Adaptor_SINOMYSQL_AXYMQTT 数据 转换 江苏农村公路桥梁监测系统
|
||
|
type Adaptor_SINOMYSQL_AXYMQTT struct {
|
||
|
}
|
||
|
|
||
|
func (the Adaptor_SINOMYSQL_AXYMQTT) Transform(gnssDataList []SinoGnssMySQL.GnssData) []NeedPush {
|
||
|
var needPush []NeedPush
|
||
|
var allDxFiles map[string][]SinoGnssMySQL.DxFile
|
||
|
for _, gnssData := range gnssDataList {
|
||
|
OnceDxFiles := allDxFiles[gnssData.GroupName]
|
||
|
OnceDxFiles = append(OnceDxFiles, SinoGnssMySQL.DxFile{
|
||
|
Module: gnssData.StationName,
|
||
|
Timespan: gnssData.Time.UnixMilli(),
|
||
|
RawValue: []float64{gnssData.X, gnssData.Y, gnssData.H},
|
||
|
PhyValue: []float64{gnssData.X, gnssData.Y, gnssData.H},
|
||
|
ThemeValue: []float64{gnssData.X, gnssData.Y, gnssData.H},
|
||
|
})
|
||
|
allDxFiles[gnssData.GroupName] = OnceDxFiles
|
||
|
}
|
||
|
|
||
|
for groupName, groupFile := range allDxFiles {
|
||
|
bs, _ := json.Marshal(groupFile)
|
||
|
topic := fmt.Sprintf("SinoGnss/%s/", groupName)
|
||
|
needPush = append(needPush, NeedPush{
|
||
|
Topic: topic,
|
||
|
Payload: bs,
|
||
|
})
|
||
|
}
|
||
|
|
||
|
return needPush
|
||
|
}
|