CEP生成的测量/事件不是UTC时间,而是Local

时间:2016-10-24 08:55:51

标签: iot complex-event-processing esper cumulocity

所有测量都带有测量创建时间戳(事件时间)。其中一些测量是人为的,这意味着它们不是由设备本身创建的,而是由在CoT内部运行的CEP规则创建的。

The "normal" measurements have the time format coded as UTC 
[{ 
"id": "12704547", 
"data": { 
"data": { 
"time": "2016-07-25T15:24:11.000Z", 
"id": "1152930", 
"self": "http://testTenant.c8y.com/measurement/measurements/1152930", 
"source": { 
"id": "222812", 
"self": "http://testTenant.c8y.com/inventory/managedObjects/222812" 
}, 
"type": "tsystems_cumulocity_energymeter_digital_ping", 
"Energieverbrauch": { 
"Ping": { 
"unit": "Wh", 
"value": 1 
} 
} 
}, 
"realtimeAction": "CREATE" 
}, 
"channel": "/measurements/222812" 
}, { 
"successful": true, 
"channel": "/meta/connect" 
}] 

但"人造"测量(由CEP规则创建)使用具有本地时间的时间戳

[{ 
"id": "12704578", 
"data": { 
"data": { 
"time": "2016-07-25T17:24:00.952+02:00", 
"id": "1152931", 
"self": "http://testTenant.c8y.com/measurement/measurements/1152931", 
"source": { 
"id": "222812", 
"self": "http://testTenant.c8y.com/inventory/managedObjects/222812" 
}, 
"type": "tsystems_cumulocity_energymeter_power_consumption", 
"Leistung": { 
"Aggregation_1min": { 
"unit": "W", 
"value": 900 
} 
} 
}, 
"realtimeAction": "CREATE" 
}, 
"channel": "/measurements/222812" 
}] 

来自一个设备的测量值应始终使用相同的时区(首选UTC)进行编码,因为不同的时区可能会在使用该数据的客户端中产生问题。

我创造了'时间'在CEP中

current_timestamp().toDate() as time 

1 个答案:

答案 0 :(得分:1)

请使用:

com.cumulocity.model.util.DateTimeUtils.newUTC(current_timestamp().toDate()) as dateTime,

而不是

current_timestamp().toDate() as time 

在你的cep规则中。

最好的问候,
的Arkadiusz
QuarkIoE支持团队