1. hapis接口说明

1.1. 文档说明

本文档为statistis_keeper组件API接口说明,适用于 statistics_keeper V5.1.1版本

1.2. 修订记录

日期 文档版本 增加/修订内容 修改人
2020-12-01 R1 添加添加,删除,编辑,启动,停止,列表,等接口 zhangrj
2020-12-04 R2 修改getList接口返回值的说明 zhangrj

1.3. 接口约定

规则 描述
服务器域名(IP) 以部署为准,如: https://xxx.mixiot.top
接口鉴权 令牌机制,详情请阅接口鉴权
字符编码 统一采用UTF-8编码
响应格式 统一采用JSON格式

1.4. 响应说明

1.4.1. 返回码

code 含义 备注
200 请求成功 Code不为200,则说明请求失败
500 请求错误

1.4.2. 格式

1.单条记录

{
    "code":200,
    "msg":"success",
    "info":"",
    "result":{}
}

2.多条记录

{
    "code":200,
    "msg":"success",
    "info":"",
    "result":{
        "page_index":1,
        "page_size":20,
        "total_pages":0,
        "total_records":0,
        "data":[]
    }
}

1.5. 获取统计结果列表

1.5.1. 请求地址

属性
URL /api/v1/statos/getList
Method get 或 post
Content-Type application/json或application/x-www-form-urlencoded

1.5.2. 请求参数

参数名称 是否必选 数据类型 数据约束 示例数据 描述
page_index int --- --- 查询页码(默认1)
page_size int --- --- 每页记录数(默认20)
where_and string --- --- AND查询条件
where_or string --- --- OR查询条件
type int 取值范围1-8 {"type":1} 1. 查询小时记录</br>2. 查询天记录</br>3. 查询月记录</br>4. 查询年记录</br>5. 查询当天记录</br>6. 查询当月记录</br>7. 查询当年记录</br>8. 查询累计记录</br> * 不填写默认值为1
joint string "AND","OR" {"joint":"AND"} 用于 where_and 和 where_or 查询条件之间的连接符
order_by string ["${key}", "${mode}"] ["time", "desc"] 1. ${key}排序key仅限于time字段</br>2. ${mode}排序模式仅限于"desc","asc",并且不区分大小写

1.5.3. 响应参数

参数名称 是否必选 数据类型 描述
code int 返回码
msg string 提示消息
info string 详细信息
result object 返回结果
+ page_index --- int 页索引
+ page_size --- int 页条数
+ total_pages --- int 总页数
+ total_records --- int 总条数
+ data --- array 返回数据列表
++ id --- string 编号(对于influxdb数据表的time字段)
++ created --- string 记录生成时间
++ object_id --- string 设备id
++ project_id --- string 项目id
++ data --- string 统计结果值
++ start --- string 统计时间段的起始时间
++ end --- string 统计时间段的结束时间
++ flag --- int 与请求参数flag含义一致

1.5.4. 请求示例

curl http://192.168.1.208:18000/statistics_keeper/api/v1/statos/getList?page_index=1&page_size=16

1.5.5. 返回示例

{
    "code": 200,
    "msg": "成功",
    "info": "",
    "result": {
        "page_index": 1,
        "page_size": 10,
        "total_pages": 1,
        "total_records": 10,
        "data": [
            {
                "created": "2020-11-30 17:00:30",
                "id": "2020-11-30 17:00:00",
                "object_id": 1010,
                "project_id": 1,
                "data": "[\"\",\"0.000000\"]",
                "end": "2020-11-30 17:00:00",
                "flag": 1,
                "start": "2020-11-30 16:00:00"
            },
            {
                "created": "2020-12-01 09:43:01",
                "id": "2020-11-30 08:00:00",
                "object_id": 1010,
                "project_id": 1,
                "created": "2020-12-01 09:43:01",
                "data": "[\"1616.930000\",\"360.000000\"]",
                "end": "2020-11-30 08:00:00",
                "flag": 1,
                "start": "2020-11-30 07:00:00"
            },
            {
                "created": "2020-12-01 09:43:01",
                "id": "2020-11-30 07:00:00",
                "object_id": 1010,
                "project_id": 1,
                "created": "2020-12-01 09:43:01",
                "data": "[\"1615.290000\",\"359.000000\"]",
                "end": "2020-11-30 07:00:00",
                "flag": 1,
                "start": "2020-11-30 06:00:00"
            },
            {
                "created": "2020-12-01 09:43:01",
                "id": "2020-11-30 06:00:00",
                "object_id": 1010,
                "project_id": 1,
                "created": "2020-12-01 09:43:01",
                "data": "[\"1613.700000\",\"359.000000\"]",
                "end": "2020-11-30 06:00:00",
                "flag": 1,
                "start": "2020-11-30 05:00:00"
            },
            {
                "created": "2020-12-01 09:43:01",
                "id": "2020-11-30 05:00:00",
                "object_id": 1010,
                "project_id": 1,
                "created": "2020-12-01 09:43:01",
                "data": "[\"1611.680000\",\"359.000000\"]",
                "end": "2020-11-30 05:00:00",
                "flag": 1,
                "start": "2020-11-30 04:00:00"
            },
            {
                "created": "2020-12-01 09:43:01",
                "id": "2020-11-30 04:00:00",
                "object_id": 1010,
                "project_id": 1,
                "created": "2020-12-01 09:43:01",
                "data": "[\"1609.440000\",\"355.000000\"]",
                "end": "2020-11-30 04:00:00",
                "flag": 1,
                "start": "2020-11-30 03:00:00"
            },
            {
                "created": "2020-12-01 09:43:00",
                "id": "2020-11-30 03:00:00",
                "object_id": 1010,
                "project_id": 1,
                "created": "2020-12-01 09:43:00",
                "data": "[\"1607.800000\",\"360.000000\"]",
                "end": "2020-11-30 03:00:00",
                "flag": 1,
                "start": "2020-11-30 02:00:00"
            },
            {
                "created": "2020-12-01 09:43:00",
                "id": "2020-11-30 02:00:00",
                "object_id": 1010,
                "project_id": 1,
                "created": "2020-12-01 09:43:00",
                "data": "[\"1605.880000\",\"358.000000\"]",
                "end": "2020-11-30 02:00:00",
                "flag": 1,
                "start": "2020-11-30 01:00:00"
            },
            {
                "created": "2020-12-01 09:43:00",
                "id": "2020-11-30 01:00:00",
                "object_id": 1010,
                "project_id": 1,
                "created": "2020-12-01 09:43:00",
                "data": "[\"1604.110000\",\"362.000000\"]",
                "end": "2020-11-30 01:00:00",
                "flag": 1,
                "start": "2020-11-30 00:00:00"
            },
            {
                "created": "2020-12-01 09:43:00",
                "id": "2020-11-30 00:00:00",
                "object_id": 1010,
                "project_id": 1,
                "created": "2020-12-01 09:43:00",
                "data": "[\"1602.010000\",\"360.000000\"]",
                "end": "2020-11-30 00:00:00",
                "flag": 1,
                "start": "2020-11-29 23:00:00"
            }
        ]
    }
}

1.6. 查询指定记录

1.6.1. 请求地址

属性
URL /api/v1/statos/getItem
Method get
Content-Type application/x-www-form-urlencoded

1.6.2. 请求参数

参数名称 是否必选 数据类型 数据约束 示例数据 描述
start string --- 2020-11-30 07:00:00 统计时间段的起始时间
end string --- 2020-11-30 08:00:00 统计时间段的结束时间
project_id string --- --- 项目id
object_id string --- --- 对象id

1.6.3. 响应参数

参数名称 是否必选 数据类型 描述
code int 返回码
msg string 提示消息
info string 详细信息
result object 返回结果
+ created --- string 记录生成时间
+ object_id --- string 对象id
+ project_id --- string 项目id
+ data --- string 统计结果值
+ start --- string 统计时间段的起始时间
+ end --- string 统计时间段的结束时间
+ flag --- int 与请求参数flag含义一致

1.6.4. 请求示例

curl -H "Content-Type: application/x-www-form-urlencoded" -X GET "http://192.168.1.208:18000/statistics_keeper/api/v1/statos/getItem?start=2020-11-30 07:00:00&end=2020-11-30 08:00:00&project_id=1&object_id=1010"

1.6.5. 返回示例

{
  "code": 200,
  "msg": "成功",
  "info": "",
  "result": {
    "created": "2020-12-01 10:28:06",
    "data": "[\"1616.930000\",\"360.000000\"]",
    "end": "2020-11-30 08:00:00",
    "flag": 1,
    "object_id": 1010,
    "project_id": 1,
    "start": "2020-11-30 07:00:00"
  }
}

1.7. 查询最新记录

1.7.1. 请求地址

属性
URL /api/v1/statos/getLastItem
Method get
Content-Type application/x-www-form-urlencoded

1.7.2. 请求参数

参数名称 是否必选 数据类型 数据约束 示例数据 描述
project_id string --- --- 项目id
object_id string --- --- 对象id
type int --- --- 与getList接口type含义一致

1.7.3. 响应参数

参数名称 是否必选 数据类型 描述
code int 返回码
msg string 提示消息
info string 详细信息
result object 返回结果
+ created --- string 记录生成时间
+ object_id --- string 对象id
+ project_id --- string 项目id
+ data --- string 统计结果值
+ start --- string 统计时间段的起始时间
+ end --- string 统计时间段的结束时间
+ flag --- int 与请求参数flag含义一致

1.7.4. 请求示例

curl -H "Content-Type: application/x-www-form-urlencoded" -X GET "http://192.168.1.208:18000/statistics_keeper/api/v1/statos/getLastItem?project_id=1&object_id=1010"

返回示例:

{
  "code": 200,
  "msg": "成功",
  "info": "",
  "result": {
    "created": "2020-11-30 17:00:30",
    "data": "[\"\",\"0.000000\"]",
    "end": "2020-11-30 17:00:00",
    "flag": 1,
    "object_id": 1010,
    "project_id": 1,
    "start": "2020-11-30 16:00:00"
  }
}
© Mixlinker all right reserved,powered by Gitbook文件修订时间: 2021-03-05 16:09:24

results matching ""

    No results matching ""