@soszrg
2019-12-11T11:05:18.000000Z
字数 6441
阅读 362
anxin
http://121.40.214.215:8001
Authorization: token 1:d79be1d657d9a8b45f6f903620e84b06cbf225e0
登出接口(token)
POST /api/v1/scheduler/task/
# 每月1号的1点整对水表进行出账{"name": "每月出账","project_id":49,"crontab": {"month": "*","day": "1","hour":"1","minute":"0"},"device_type": 1,"enabled": true,"description": "定时出账"}
| 参数 | 类型 | 必须 | 说明 | 位置 |
|---|---|---|---|---|
| name | string | Y | 任务名 | body |
| project_id | int | Y | 项目id | body |
| crontab | json | Y | 定时规则(详细内容见下面说明) | body |
| device_type | int | Y | 设备类型:1 水表;2 电表 | body |
| enabled | bool | N | 任务是否开启:true 是; false 否 | body |
| description | string | N | 任务描述 | body |
「*」说明: 所有字段的值都支持设置为*,表示每xx,例如month=*,表示每月
| 字段 | 类型 | 说明 |
|---|---|---|
| month | string | 月 |
| day | string | 日 |
| hour | string | 时 |
| minute | string | 分 |
返回参数
{"meta": {"code": 0,"message": "create crontab ok."},"data": {"name": "每月出账","crontab": {"month": "*","day": "1","hour": "1","minute": "0"},"natrual_key": "02c8...","project_id": 49,"device_type": 1,"last_run_at": "2019-03-11T11:37:35","enabled": true,"update_time": "2019-03-11T11:37:35","create_time": "2019-03-11T11:37:35","description": "定时出账"}}
返回参数说明
| 参数 | 类型 | 说明 |
|---|---|---|
| natrual_key | string | 任务id |
| last_run_at | string | 上次运行时间 |
GET /api/v1/scheduler/tasks/
/api/v1/scheduler/tasks/?project_id=42&device_type=1&page_size=2&page=2{}
| 参数 | 类型 | 必须 | 说明 | 位置 |
|---|---|---|---|---|
| project_id | int | Y | 项目id | path |
| device_type | int | Y | 类型:0 全部;1 水表;2 电表 | path |
| page_size | int | N | 每页条目数 | path |
| page | int | N | 页码 | path |
{"meta": {"code": 0,"message": "task list info"},"data": {"count": 5,"page_size": 2,"next": true,"previous": true,"results": [{"name": "每月1号出账","crontab": {"month": "*","day": "1","hour": "1","minute": "0"},"natrual_key": "c5a...","project_id": 42,"device_type": 1,"enabled": true,"last_run_at": "2019-03-11T11:37:35","description": "定时出账","update_time": "2019-03-04T13:45:52","create_time": "2019-03-04T13:45:52"},{"name": "每月2号出账","crontab": {"month": "*","day": "2","hour": "1","minute": "0"},"natrual_key": "c5a...","project_id": 42,"device_type": 1,"enabled": true,"last_run_at": "2019-03-11T11:37:35","description": "定时出账","update_time": "2019-03-04T13:55:03","create_time": "2019-03-04T13:55:03"}]}}
返回参数说明
| 参数 | 类型 | 说明 |
|---|---|---|
| count | int | 总条目数 |
| next | bool | 是否有上一页 |
| previous | bool | 是否有上一页 |
GET /api/v1/scheduler/tasks/{natrual_key}/
/api/v1/scheduler/tasks/abcds.../{}
| 参数 | 类型 | 必须 | 说明 | 位置 |
|---|---|---|---|---|
| natrual_key | string | Y | 任务id | path |
{"meta": {"code": 0,"message": "task info"},"data": {"crontab": {"month": "*","day": "1","hour": "1","minute": "0"},"natrual_key": "c89d28c2453311e98d3af45c898eaab7","name": "dignshi","project_id": 49,"device_type": 1,"last_run_at": "2019-03-11T11:37:35","enabled": true,"description": "定时出账","update_time": "2019-03-13T10:00:32","create_time": "2019-03-13T10:00:32"}}
返回参数说明
| 参数 | 类型 | 说明 |
|---|---|---|
| -- | -- | -- |
PUT /api/v1/scheduler/tasks/{nature_key}/
# 每月1号的2点整对水表进行出账{"name": "每月出账","crontab": {"month": "*","day": "2","hour":"1","minute":"0"},"enabled": true,"description": "定时出账"}
| 参数 | 类型 | 必须 | 说明 | 位置 |
|---|---|---|---|---|
| nature_key | string | Y | 任务id | path |
| name | string | Y | 任务名 | body |
| crontab | json | Y | 定时规则(详细内容见下面说明) | body |
| enabled | bool | Y | 任务是否开启:true 是; false 否 | body |
| description | string | Y | 任务描述 | body |
「*」说明: 所有字段的值都支持设置为*,表示每xx,例如month=*,表示每月
| 字段 | 类型 | 说明 |
|---|---|---|
| month | string | 月 |
| day | string | 日 |
| hour | string | 时 |
| minute | string | 分 |
返回参数
{"meta": {"code": 0,"message": "task update ok."},"data": {"name": "每月出账","crontab": {"month": "*","day": "1","hour": "1","minute": "0"},"natrual_key": "02c8...","project_id": 49,"device_type": 1,"enabled": true,"last_run_at": "2019-03-11T11:37:35","update_time": "2019-03-11T11:37:35","create_time": "2019-03-11T11:37:35","description": "定时出账"}}
返回参数说明
| 参数 | 类型 | 说明 |
|---|---|---|
| -- | -- | -- |
DELETE /api/v1/scheduler/tasks/{nature_key}/
/api/v1/scheduler/tasks/avcxd.../{}
| 参数 | 类型 | 必须 | 说明 | 位置 |
|---|---|---|---|---|
| nature_key | string | Y | 任务id | path |
返回参数
{"meta": {"code": 0,"message": "delete ok."},"data": {}}
返回参数说明
| 参数 | 类型 | 说明 |
|---|---|---|
| -- | -- | -- |
PUT /api/v1/scheduler/tasks/{nature_key}/status/
/api/v1/scheduler/tasks/avcxd.../{"enabled": true}
| 参数 | 类型 | 必须 | 说明 | 位置 |
|---|---|---|---|---|
| nature_key | string | Y | 任务id | path |
| enabled | bool | Y | 状态 | body |
返回参数
{"meta": {"code": 0,"message": "update ok."},"data": {}}
返回参数说明
| 参数 | 类型 | 说明 |
|---|---|---|
| -- | -- | -- |
GET /api/v1/scheduler/history/
/api/v1/scheduler/history/?project_id=42&device_type=2&page_size=2&page=2&device_id=abc...{}
| 参数 | 类型 | 必须 | 说明 | 位置 |
|---|---|---|---|---|
| project_id | int | Y | 项目id | path |
| device_type | int | Y | 类型:0 全部;1 水表;2 电表 | path |
| device_id | int | N | 设备id | path |
| page_size | int | N | 每页条目数 | path |
| page | int | N | 页码 | path |
{"meta": {"message": "info list","code": 0},"data": {"count": 4,"page_size": 2,"next": null,"previous": true,"results": [{"id": "5c892dd2a90d784b33b9002c","device_id": "abc...","device_type": 2,"charge": "10.12","reading_data": "20.12","from_time": "2019-03-14T00:20:34","to_time": "2019-03-14T00:20:34","created_at": "2019-03-14T00:20:34"},{"id": "5c892dd1a90d784b33b9002b","device_id": "abc...","device_type": 2,"charge": "10.12","reading_data": "20.12","from_time": "2019-03-14T00:20:33","to_time": "2019-03-14T00:20:33","created_at": "2019-03-14T00:20:33"}]}}
返回参数说明
| 参数 | 类型 | 说明 |
|---|---|---|
| id | string | 出账id |
| device_id | string | 设备id或表号 |
| device_type | int | 设备类型 |
| charge | float | 收费额 |
| reading_data | float | 总读数(如:总电量或总水量) |
| from_time | string | 账单起始时间 |
| to_time | string | 账单截止时间 |
| created_at | string | 账单生成时间 |
GET /api/v1/scheduler/history/time/
/api/v1/scheduler/history/time/?project_id=28&device_id=avc..&device_type=0&start_date=2019-9-21&end_date=2019-11-21&wm_type=自来水表{}
| 参数 | 类型 | 必须 | 说明 | 位置 |
|---|---|---|---|---|
| project_id | int | Y | 项目id | path |
| device_type | int | Y | 类型:10 全部;0 电表;1 水表 | path |
| device_id | int | N | 设备id | path |
| wm_type | string | N | 水表类型:自来水表和纯净水表 | path |
| start_date | string | Y | 开始日期 | path |
| end_date | string | Y | 结束日期 | path |
{"meta": {"code": 0,"message": "success"},"data": [{"id": "5dbb0500152d9a01c13c2fee","house_address": ["安心e家","","","","空调房"],"residents": [{"name": "卢博腾","cellphone": "13336915622"},{"name": "程-庆科","cellphone": "15921574273"},{"name": "方浩伟","cellphone": "13336911233"},{"name": "刘-庆科","cellphone": "15715604269"},{"name": "高帅","cellphone": "13336919098"}],"device_id": "000090502121","device_type": 0,"charge": "63.79","previous_reading_data": "394.83","reading_data": "114.95","from_time": "2019-10-01T00:00:00","to_time": "2019-11-01T00:00:00","created_at": "2019-11-01T00:00:00"},{"id": "5d922680152d9a0e2381e711","house_address": ["安心e家","","","","空调房"],"residents": [{"name": "卢博腾","cellphone": "13336915622"},{"name": "程-庆科","cellphone": "15921574273"},{"name": "方浩伟","cellphone": "13336911233"},{"name": "刘-庆科","cellphone": "15715604269"},{"name": "高帅","cellphone": "13336919098"}],"device_id": "000090502121","device_type": 0,"charge": "236.40","previous_reading_data": "1501.58","reading_data": "394.83","from_time": "2019-09-01T00:00:00","to_time": "2019-10-01T00:00:00","created_at": "2019-10-01T00:00:00"}]}
返回参数说明
| 参数 | 类型 | 说明 |
|---|---|---|
| id | string | 出账id |
| device_id | string | 设备id或表号 |
| device_type | int | 设备类型 |
| charge | float | 收费额 |
| residents | array | 户主 |
| reading_data | float | 总读数(如:总电量或总水量) |
| from_time | string | 账单起始时间 |
| to_time | string | 账单截止时间 |
| created_at | string | 账单生成时间 |