一部のフィールドで日付形式が異なるのはなぜだろうと思っていました。私のルールは次のように宣言されています。
@Name("measurement_occupation")
context ParkingSpotOccupation
insert into CreateMeasurement
select
e.source as source,
"ParkingSpotOccupation" as type,
min(e.time) as time,
{
"startDate", min(e.time),
"endDate", max(e.time),
"duration", dateDifferenceInSec(max(e.time), min(e.time))
} as fragments
from
SmartParkingEvent e
output
last when terminated;
API測定を使用した結果は次のとおりです。
{
"time": "2016-05-30T06:00:00.000+02:00",
"id": "33200",
"self": "https://management.post-iot.lu/measurement/measurements/33200",
"source": {
"id": "26932",
"self": "https://management.post-iot.lu/inventory/managedObjects/26932"
},
"type": "ParkingSpotOccupation",
"startDate": {
"time": 1464580800000,
"minutes": 0,
"seconds": 0,
"hours": 6,
"month": 4,
"timezoneOffset": -120,
"year": 116,
"day": 1,
"date": 30
},
"duration": 600,
"endDate": {
"time": 1464581400000,
"minutes": 10,
"seconds": 0,
"hours": 6,
"month": 4,
"timezoneOffset": -120,
"year": 116,
"day": 1,
"date": 30
}
}
time と startDate/endDate のレンダリングが異なるのはなぜですか? さらに奇妙なことに、イベント処理ルールの出力が表示されると、次のようにフォーマットされます。
{ "time": { "date": 30, "day": 1, "hours": 6, "minutes": 0, "month": 4, "seconds": 0, "time": 1464580800000, "timezoneOffset": -120, "year": 116 }, "source": "26932", "fragments": [ "startDate", { "date": 30, "day": 1, "hours": 6, "minutes": 0, "month": 4, "seconds": 0, "time": 1464580800000, "timezoneOffset": -120, "year": 116 }, "endDate", { "date": 30, "day": 1, "hours": 6, "minutes": 10, "month": 4, "seconds": 0, "time": 1464581400000, "timezoneOffset": -120, "year": 116 }, "duration", 600 ], "type": "ParkingSpotOccupation" }
したがって、すべての日付は同じように見えますが、API を使用して測定値にアクセスする場合はそうではありません。すべての日付を「2016-05-30T06:00:00.000+02:00」という形式で保存したいと思います。また、cast(min(e.time), Date) を使用しようとしましたが、エラーが発生しました ('Date' という名前でキャスト関数にリストされているクラスをロードできません)。toDate() 関数を試してみましたが、何も変わりませんでした。