控制统计配置API
控制统计配置的字段请查看字段说明
# 列表查询
接口说明
根据查询条件查询控制统计配置列表。
接口版本
v1接口地址
/api-v1/operate-reduces
请求方法
GET
请求参数
参数类型 | 参数名称 | 数据类型 | 是否必须 | 参数描述 | 默认 | 示例 |
---|---|---|---|---|---|---|
query | label | string | false | 模糊查询字段 | name | |
query | search | string | false | 模糊查询值 | 测试 | |
query | time | string | false | 时间范围查询字段,必须是设备字段中的时间或时间戳字段名,例如createdAt,updatedAt | createdAt | |
query | range | string[] or string | false | 时间范围,开始时间到结束时间,可以是string[]或者以逗号分割的开始时间到结束时间或时间戳 | 2019-10-22T00:00:00.000Z,2022-01-22T00:00:00.000Z | |
query | page | number | false | 分页第几页 | 1 | |
query | limit | number | false | 单页几条数据 | 10 | |
query | sort | string | false | 根据哪个字段排序 | _id | -createdAt |
query | select | string | false | 只查询部分字段,字段名之间用过空格分隔,去掉某个字段的查询字段名前面加- | ||
query | autopopulate | boolean | false | 自动关联数据,部分字段自动关联关系表查询,设置这个值可开关自动联表查询 | true | false |
query | populate | string | false | 指定关联表查询,查询多个关联表用逗号分隔 | checks,operates |
请求参数举例
注意
GET请求所有参数类型都会变成string拼接在url上面,文档为了表述清晰,将示例结构以json格式编写
{
"page":"1",
"limit":"2",
"sort":"-createdAt",
"autopopulate":"false"
}
// Make sure to add code blocks to your code group
返回参数
参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|
code | number | True | 返回代码 |
data | json | True | 返回数据 |
-total | number | False | 控制统计配置总条数 |
-rows | array | False | 当前返回的控制统计配置对象列表 |
返回参数举例
{
"code": 0,
"data": {
"total": 1,
"rows": [{
"operates": ["5de787c8cb4761001b3363e1"],
"isResolve": false,
"boardConfigStr": "{}",
"cloudRunState": false,
"status": true,
"_id": "5e79d0117bc86700bfa8e927",
"name": "name",
"control": "5dc3e6a55b5edb001c2c14e4",
"cycle": "1m",
"map": "_this.count = 1\n _this.value= _this.value*60\n _this.total = _this.value\n _this.open = _this.value\n _this.openTime = _this.recordTime\n _this.close = _this.value\n _this.closeTime = _this.recordTime\n _this.high = _this.value\n _this.highTime = _this.recordTime\n _this.low = _this.value\n _this.lowTime = _this.recordTime\n return _this\n ",
"reduce": "array.forEach(function(item,index){\n if(index===0)return\n value.total += item.total\n value.count += item.count\n if(item.openTime < value.openTime){\n value.openTime = item.openTime\n value.open = item.open\n }\n if(item.closeTime > value.closeTime){\n value.closeTime = item.closeTime\n value.close = item.close\n }\n if(item.high > value.high){\n value.highTime = item.highTime\n value.high = item.high\n }\n if(item.low < value.low){\n value.lowTime = item.lowTime\n value.low = item.low\n }\n })\n return value",
"finalize": "value.name='name'\nvalue.dValue=Number((value.close-value.open).toFixed(2))\nreturn value",
"creator": "5dc3e4795b5edb001c2c1314",
"createdAt": "2020-03-24T09:17:05.917Z",
"updatedAt": "2020-05-11T09:14:03.086Z",
"__v": 0
}]
}
}
# 新建
接口说明
新建一个控制统计配置。
接口版本
v1接口地址
/api-v1/operate-reduces/
请求方法
POST
请求参数
参数类型 | 参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|---|
body | - | Object | True | 控制统计配置对象字段说明 |
请求参数举例
{
"operates": ["5de787c8cb4761001b3363e1"],
"isResolve": false,
"boardConfigStr": "{}",
"cloudRunState": false,
"status": true,
"name": "name",
"control": "5dc3e6a55b5edb001c2c14e4",
"cycle": "1m",
"map": "_this.count = 1\n _this.value= _this.value*60\n _this.total = _this.value\n _this.open = _this.value\n _this.openTime = _this.recordTime\n _this.close = _this.value\n _this.closeTime = _this.recordTime\n _this.high = _this.value\n _this.highTime = _this.recordTime\n _this.low = _this.value\n _this.lowTime = _this.recordTime\n return _this\n ",
"reduce": "array.forEach(function(item,index){\n if(index===0)return\n value.total += item.total\n value.count += item.count\n if(item.openTime < value.openTime){\n value.openTime = item.openTime\n value.open = item.open\n }\n if(item.closeTime > value.closeTime){\n value.closeTime = item.closeTime\n value.close = item.close\n }\n if(item.high > value.high){\n value.highTime = item.highTime\n value.high = item.high\n }\n if(item.low < value.low){\n value.lowTime = item.lowTime\n value.low = item.low\n }\n })\n return value",
"finalize": "value.name='name'\nvalue.dValue=Number((value.close-value.open).toFixed(2))\nreturn value"
}
// Make sure to add code blocks to your code group
返回参数
参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|
code | number | True | 返回代码 |
data | json | True | 返回创建的对象 |
返回参数举例
{
"code": 0,
"data":{
"operates": ["5de787c8cb4761001b3363e1"],
"isResolve": false,
"boardConfigStr": "{}",
"cloudRunState": false,
"status": true,
"name": "name",
"control": "5dc3e6a55b5edb001c2c14e4",
"cycle": "1m",
"map": "_this.count = 1\n _this.value= _this.value*60\n _this.total = _this.value\n _this.open = _this.value\n _this.openTime = _this.recordTime\n _this.close = _this.value\n _this.closeTime = _this.recordTime\n _this.high = _this.value\n _this.highTime = _this.recordTime\n _this.low = _this.value\n _this.lowTime = _this.recordTime\n return _this\n ",
"reduce": "array.forEach(function(item,index){\n if(index===0)return\n value.total += item.total\n value.count += item.count\n if(item.openTime < value.openTime){\n value.openTime = item.openTime\n value.open = item.open\n }\n if(item.closeTime > value.closeTime){\n value.closeTime = item.closeTime\n value.close = item.close\n }\n if(item.high > value.high){\n value.highTime = item.highTime\n value.high = item.high\n }\n if(item.low < value.low){\n value.lowTime = item.lowTime\n value.low = item.low\n }\n })\n return value",
"finalize": "value.name='name'\nvalue.dValue=Number((value.close-value.open).toFixed(2))\nreturn value"
}
}
# 编辑
接口说明
修改控制统计配置。
接口版本
v1接口地址
/api-v1/operate-reduces/:id
请求方法
PUT
请求参数
参数类型 | 参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|---|
params | id | string | True | 修改的控制统计配置ID |
body | - | Object | True | 控制统计配置对象字段说明 |
请求参数举例
{
"name":"updatename"
}
// Make sure to add code blocks to your code group
返回参数
参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|
code | number | True | 返回代码 |
data | json | True | 返回创建的对象 |
返回参数举例
{
"code": 0,
"data": {
"operates": ["5de787c8cb4761001b3363e1"],
"isResolve": false,
"boardConfigStr": "{}",
"cloudRunState": false,
"status": true,
"name": "updatename",
"control": "5dc3e6a55b5edb001c2c14e4",
"cycle": "1m",
"map": "_this.count = 1\n _this.value= _this.value*60\n _this.total = _this.value\n _this.open = _this.value\n _this.openTime = _this.recordTime\n _this.close = _this.value\n _this.closeTime = _this.recordTime\n _this.high = _this.value\n _this.highTime = _this.recordTime\n _this.low = _this.value\n _this.lowTime = _this.recordTime\n return _this\n ",
"reduce": "array.forEach(function(item,index){\n if(index===0)return\n value.total += item.total\n value.count += item.count\n if(item.openTime < value.openTime){\n value.openTime = item.openTime\n value.open = item.open\n }\n if(item.closeTime > value.closeTime){\n value.closeTime = item.closeTime\n value.close = item.close\n }\n if(item.high > value.high){\n value.highTime = item.highTime\n value.high = item.high\n }\n if(item.low < value.low){\n value.lowTime = item.lowTime\n value.low = item.low\n }\n })\n return value",
"finalize": "value.name='name'\nvalue.dValue=Number((value.close-value.open).toFixed(2))\nreturn value"
}
}
# 删除
接口说明
删除一个控制统计配置。
接口版本
v1接口地址
/api-v1/operate-reduces/:id
请求方法
DELETE
请求参数
参数类型 | 参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|---|
params | id | string | True | 删除的控制统计配置ID |
请求参数举例
只需发送删除记录的ID
返回参数
参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|
code | number | True | 返回代码 |
data | string | false | 返回数据 |
返回参数举例
{
"code": 0,
"data": {
"operates": [],
"isResolve": false,
"boardConfigStr": "{}",
"cloudRunState": false,
"status": true,
"_id": "62b2d9a737f6906ed8cb293f",
"name": "name",
"creator": "5dc3e4795b5edb001c2c1314",
"createdAt": "2022-06-22T08:58:15.797Z",
"updatedAt": "2022-06-22T08:58:15.797Z",
"__v": 0
}
}
# 统计
接口说明
执行一个统计。
接口版本
v1接口地址
/api-v1/operate-reduces/:id/map-reduce
请求方法
POST
请求参数
参数类型 | 参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|---|
params | id | string | True | 删除的控制统计配置ID |
post请求体参数
参数类型 | 参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|---|
body | id | Number | fasle | 1为云执行,本地执行不填 |
请求参数举例
发送控制统计配置的ID
如果需要云执行 post请求体传参数 {state:1}
返回参数
参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|
code | number | True | 返回代码 |
message | string | false | 返回说明信息 |
返回参数举例
{
"code": 0,
"message": "统计中,根据数据量将需要几秒到几分钟时间"
}
上次更新: 2022/06/28, 15:55:53