|
|
@ -52,7 +52,21 @@ func (the Adaptor_AXY_LastRAW) raw2es(iotaData models.IotaData) *models.EsRaw { |
|
|
|
return EsRaws |
|
|
|
} |
|
|
|
|
|
|
|
var deviceInfoMap = map[string]models.DeviceInfo{} |
|
|
|
|
|
|
|
func (the Adaptor_AXY_LastRAW) GetDeviceInfo(deviceId string) models.DeviceInfo { |
|
|
|
if v, ok := deviceInfoMap[deviceId]; ok { |
|
|
|
durationMin := time.Now().Sub(v.RefreshTime).Minutes() |
|
|
|
if durationMin < 5 { |
|
|
|
return v |
|
|
|
} |
|
|
|
} |
|
|
|
v := the.GetDeviceInfoFromRedis(deviceId) |
|
|
|
deviceInfoMap[deviceId] = v |
|
|
|
return v |
|
|
|
} |
|
|
|
|
|
|
|
func (the Adaptor_AXY_LastRAW) GetDeviceInfoFromRedis(deviceId string) models.DeviceInfo { |
|
|
|
Key_Iota_device := "iota_device" |
|
|
|
key_Thing_struct := "thing_struct" |
|
|
|
key_Iota_meta := "iota_meta" |
|
|
@ -76,12 +90,14 @@ func (the Adaptor_AXY_LastRAW) GetDeviceInfo(deviceId string) models.DeviceInfo |
|
|
|
OrgId: thingStruct.OrgId, |
|
|
|
} |
|
|
|
return models.DeviceInfo{ |
|
|
|
Id: deviceId, |
|
|
|
Name: dev.Name, |
|
|
|
Structure: s, |
|
|
|
DeviceMeta: devMeta, |
|
|
|
Id: deviceId, |
|
|
|
Name: dev.Name, |
|
|
|
Structure: s, |
|
|
|
DeviceMeta: devMeta, |
|
|
|
RefreshTime: time.Now(), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func toEsRaw(deviceData *models.DeviceData) *models.EsRaw { |
|
|
|
dataOutMeta := deviceData.DeviceInfo.DeviceMeta.GetOutputProps() |
|
|
|
createNativeRaw := models.EsRaw{ |
|
|
|