1

所有测量都带有创建测量时的时间戳(事件时间)。其中一些测量是人为的,这意味着它们不是由设备本身创建的,而是由在 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 
4

1 回答 1

1

请用:

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

代替

current_timestamp().toDate() as time 

在您的 cep 规则中。

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

于 2016-10-24T08:55:50.620 回答