增加历史区间数据查询

This commit is contained in:
谷成伟 2024-10-21 09:47:27 +08:00
parent 92284f55a8
commit 4c055eec2a

View File

@ -75,6 +75,8 @@ data 中以字典的方式,返回查询的每个设备的属性的实时值。
### 历史区间数据查询 ### 历史区间数据查询
根据提供的开始时间及结束时间,查询指定设备在指定时间段内的历史数据。
POST 请求接口 POST 请求接口
> /api/data/history > /api/data/history
@ -84,16 +86,37 @@ POST 请求接口
```json ```json
{ {
"deviceId":"129476828342323", //开始时间
"attributes":["power","windSpeed","dailyUsageHours","monthlyUsageHours"] "startTime": "123452435324242",
//结束时间
"endTime": "123452435924242",
//查询设备列表
"devices": [
{
//设备ID
"deviceId":"129476828342323",
//要查询的属性列表
"attributes":["power","windSpeed"]
},
{
"deviceId":"129476828342324",
"attributes":["power","dailyUsageHours"]
}
],
"interval": "1h"
} }
``` ```
入参描述 入参描述
| 参数名 | 参数类型 | 可选 | 描述 | | 参数名 | 参数类型 | 可选 | 描述 |
| ------------ | -------- | ---- |------| | ------------ | -------- | ---- |------|
| deviceId | String | no | 设备ID | | startTime | String | no | 开始时间戳 |
| attributes | StringArray | no | 要查询实时数据的设备属性列表 | | endTime | String | no | 结束时间戳 |
| devices.deviceId | String | no | 设备ID |
| devices.attributes | StringArray | no | 要查询实时数据的设备属性列表 |
| interval | String | yes | 抽样间隔,1a(毫秒),1s(秒),1m(分),1h(小时),1d(天),1w(周)。 忽略或者值为空时,返回原始数据(不抽样) |
| endTime | String | no | 结束时间戳 |
返回报文 返回报文
@ -103,14 +126,22 @@ POST 请求接口
"msg": "操作成功", "msg": "操作成功",
"success": true, "success": true,
"data": { "data": {
"power": 56.2, //设备ID
"windSpeed": 45.3, "129476828342323":{
"dailyUsageHours": 20, //属性名
"monthlyUsageHours": 78, "power": {
.... //时间戳列表
"times": [123452435924242,123452435924342,123452435924442,123452435924542],
//值列表
"values": [123.23,35.21,34.56,67]
} ,
//属性名
"windSpeed": {
"times": [123452435924242,123452435924342,123452435924442,123452435924542],
"values": [123.23,35.21,34.56,67]
}
},
.......
} }
} }
``` ```
返参描述
data 中以字典的方式,返回查询的属性的实时值。