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 }