apim 历史数据接口说明

apim 提供查询各种历史数据的接口,现支持马赛克数据、栅格数据和统计计算结果数据的一些查询接口

列表条件查询说明

获取列表的接口提供 where_and, where_or, where_in 条件查询,参数类型统一为 json 字符串,格式如下:

  • where_and
    [[字段名, 操作符, 参数], [字段名, 操作符, 参数], …]

  • where_or
    [[字段名, 操作符, 参数], [字段名, 操作符, 参数], …]

  • where_in
    [[字段名, 逗号分隔字符串], [字段名, 逗号分隔字符串], …]

示例

{
    "action":"get_xxx_list",
    "where_and":"[[\"object_id\",\"=\",\"OBJ1\"], [\"rule_id\",\"=\",\"RULE1\"]]",
    "where_or":"[[\"object_id\",\"=\",\"OBJ1\"], [\"rule_id\",\"=\",\"RULE1\"]]",
    "where_in":"[[\"object_id\",\"OBJ1,OBJ2\"]]"
}

马赛克数据

获取最新一条马赛克

请求

{
    "action":"get_last_mosaic",
    "keys": ["Y02_1", "Y03_1"],
    "object_id": "OBJ1393762000004"
}

响应

{
    "resp": "get_last_mosaic",
    "code": 200,
    "msg": "成功",
    "result": {
        "data": [
            {
                "Y02_1": 79,
                "Y03_1": 203.2,
                "time": "2021-03-29 17:50:07"
            }
        ]
    }
}

按时间获取单条马赛克

获取到的数据是请求参数时间之后的第一条数据

请求

{
    "action":"get_mosaic_item",
    "keys": ["Y02_1", "Y03_1"],
    "time": "2021-03-29 17:50:07",
    "object_id": "OBJ1393762000004"
}

响应

{
    "resp": "get_mosaic_item",
    "code": 200,
    "msg": "成功",
    "result": {
        "data": [
            {
                "Y02_1": 79,
                "Y03_1": 203.2,
                "time": "2021-03-29 17:50:07"
            }
        ]
    }
}

获取最新N条马赛克

请求

{
    "action":"get_last_mosaic_list",
    "keys": ["Y02_1", "Y03_1"],
    "items": 2,
    "object_id": "OBJ1393762000004"
}

响应

{
    "resp": "get_last_mosaic_list",
    "code": 200,
    "msg": "成功",
    "result": {
        "data": [
            {
                "Y02_1": 79,
                "Y03_1": 203.2,
                "time": "2021-03-29 17:50:07"
            },
            {
                "Y02_1": 79,
                "Y03_1": 202.9,
                "time": "2021-03-29 17:49:36"
            },
            {
                "Y02_1": 79,
                "Y03_1": 203.6,
                "time": "2021-03-29 17:43:01"
            }
        ],
        "items": 2
    }
}

获取分页马赛克列表

请求

{
    "action":"get_mosaic_list",
    "keys": ["Y02_1", "Y03_1"],
    "object_id": "OBJ1393762000004",
    "start_time": "2021-03-29 17:30:00",
    "end_time": "2021-03-30 00:00:00"
}

响应

{
    "resp": "get_mosaic_list",
    "code": 200,
    "msg": "成功",
    "result": {
        "data": [
            {
                "Y02_1": 79,
                "Y03_1": 203.2,
                "time": "2021-03-29 17:50:07"
            },
            {
                "Y02_1": 79,
                "Y03_1": 202.9,
                "time": "2021-03-29 17:49:36"
            },
            {
                "Y02_1": 79,
                "Y03_1": 203.6,
                "time": "2021-03-29 17:43:01"
            },
            {
                "Y02_1": 82,
                "Y03_1": 203.8,
                "time": "2021-03-29 17:31:02"
            }
        ],
        "page_index": 1,
        "page_size": 20,
        "total_pages": 1,
        "total_records": 4
    }
}

获取马赛克数据曲线

请求

{
    "action":"get_mosaic_dataline",
    "keys": ["S01", "S02", "S03"],
    "object_id": "OBJ1644032200001",
    "start_time": "2021-08-10 17:30:00",
    "end_time": "2021-08-15 00:00:00",
    "items": 100 // 非必填,不填默认 500
}

响应

{
    "resp": "get_mosaic_dataline",
    "code": 200,
    "msg": "成功",
    "result": {
        "S01": {
            "data": [
                "43.7",
                "49.57",
                "41.08",
                ...
            ],
            "datetime": [
                "2021-08-10 17:00:00",
                "2021-08-10 18:00:00",
                "2021-08-10 19:00:00",
                ...
            ],
            "interval": [
                "3600s"
            ]
        },
        ...
    }
}

栅格数据

获取最新一条栅格

terminal_id 为终端 id,必填
topic 字段筛选栅格数据,不填则为所有 topic,下同

请求

{
    "action":"get_last_grid",
    "terminal_id": "A220161221008951",
    "topic": ["r", "disconnected"]
}

响应

{
    "resp": "get_last_grid",
    "code": 200,
    "msg": "成功",
    "result": {
        "data": [
            {
                "payload": {
                    "csq": 25
                },
                "time": "2021-03-30 16:42:29",
                "topic": "r"
            }
        ]
    }
}

按时间获取单条栅格

获取到的数据是请求参数时间之后的第一条数据

请求

{
    "action":"get_grid_item",
    "terminal_id": "A220161221008951",
    "topic": ["r", "disconnected"],
    "time": "2021-03-30 16:42:30"
}

响应

{
    "resp": "get_grid_item",
    "code": 200,
    "msg": "成功",
    "result": {
       "data": [
            {
                "payload": {
                    "csq": 25
                },
                "time": "2021-03-30 16:42:39",
                "topic": "r"
            }
        ]
    }
}

获取最新N条栅格

请求

{
    "action":"get_last_grid_list",
    "terminal_id": "A220161221008951",
    "topic": ["r", "disconnected"],
    "items": 2
}

响应

{
    "resp": "get_last_grid_list",
    "code": 200,
    "msg": "成功",
    "result": {
        "data": [
            {
                "payload": {
                    "csq": 23
                },
                "time": "2021-03-30 16:47:42",
                "topic": "r"
            },
            {
                "payload": {
                    "csq": 23
                },
                "time": "2021-03-30 16:47:32",
                "topic": "r"
            }
        ],
        "items": 2
    }
}

按分页栅格列表

请求

{
    "action":"get_grid_list",
    "terminal_id": "A220161221008951",
    "start_time": "2021-03-30 12:00:00",
    "end_time": "2021-03-30 18:00:00",
    "topic": ["r", "disconnected"],
    "page_index": 1,
    "page_size": 2
}

响应

{
    "resp": "get_grid_list",
    "code": 200,
    "msg": "成功",
    "result": {
        "data": [
            {
                "payload": {
                    "csq": 26
                },
                "time": "2021-03-30 17:59:59",
                "topic": "r"
            },
            {
                "payload": {
                    "L1_3_0": 267.6225,
                    "L1_3_14": 26.844,
                    "L1_3_16": 1630892.375,
                    "L1_3_2": 193,
                    "L1_3_20": 3788661,
                    "L1_3_4": 0,
                    "L1_3_6": 0.644,
                    "L1_3_8": 37.4
                },
                "time": "2021-03-30 17:59:48",
                "topic": "r"
            }
        ],
        "page_index": 1,
        "page_size": 2,
        "total_pages": 1068,
        "total_records": 2135
    }
}

统计计算数据

获取最新一条统计或者计算

请求

统计

{
    "action":"get_last_statistics",
    "script_uid": "STATISTICS1302924600002"
}

计算

{
    "action":"get_last_calculate",
    "script_uid": "STATISTICS1302924600002"
}

响应

{
    "resp": "get_last_statistics",
    "code": 200,
    "msg": "成功",
    "result": {
        "data": [
            {
                "id": 58,
                "script_uid": "STATISTICS1302924600002",
                "object_id": "OBJ1392682700001",
                "description": "this(2021-03-30 18:10:00,2021-03-30 18:11:00.205736257) real(2021-03-30 18:10:07.158470936,2021-03-30 18:10:44.267138313) next(2021-03-30 18:10:44.267138313,2021-03-30 18:12:00)",
                "data": "",
                "var_name": "RSTATISTICS1302924600002",
                "start_time": "2021-03-30T18:10:07+08:00",
                "end_time": "2021-03-30T18:10:44+08:00",
                "created": "2021-03-30T18:11:00+08:00",
                "is_available": 1
            }
        ]
    }
}

获取统计计算分页列表

请求

统计

{
    "action":"get_statistics_page",
    "script_uid": "STATISTICS1302924600002",
    "page_index": 1,
    "page_size": 2,
    "where_and": "[[\"object_id\", \"=\", \"OBJ1\"]]",  // 与筛选条件,json字符串 [[字段名, 大于小于等于, 值], ...]
    "where_or": "", // 或筛选条件,同上
    "where_in": "", // in 条件 [[]]
    "order_by": "[\"end_time\", \"asc\"]", // 按指定字段排序,json字符串 [字段名, asc 或 desc]
}

计算

{
    "action":"get_calculate_page",
    "script_uid": "STATISTICS1302924600002",
    "page_index": 1,
    "page_size": 2,
    "where_and": "",
    "where_or": "",
    "where_in": "",
    "order_by": "[\"end_time\", \"asc\"]", // 按指定字段排序,json字符串 [字段名, asc 或 desc]
}

响应

{
    "resp": "get_statistics_page",
    "code": 200,
    "msg": "成功",
    "result": {
        "page_index": 1,
        "page_size": 2,
        "total_pages": 941,
        "total_records": 1881,
        "data": [
            {
                "id": 1880,
                "script_uid": "STATISTICS1302924600002",
                "object_id": "OBJ1392682700001",
                "description": "this(2021-03-31 09:21:00,2021-03-31 09:22:00.205427629) real(2021-03-31 09:20:12.218593571,2021-03-31 09:21:58.301710943) next(2021-03-31 09:21:58.301710943,2021-03-31 09:23:00)",
                "data": "",
                "var_name": "RSTATISTICS1302924600002",
                "start_time": "2021-03-31T09:20:12+08:00",
                "end_time": "2021-03-31T09:21:58+08:00",
                "created": "2021-03-31T09:22:00+08:00",
                "is_available": 1
            },
            {
                "id": 1881,
                "script_uid": "STATISTICS1303439700001",
                "object_id": "OBJ1392682700001",
                "description": "this(2021-03-31 09:21:00,2021-03-31 09:22:00.504208789) real(2021-03-31 09:20:12.218593571,2021-03-31 09:21:58.301710943) next(2021-03-31 09:21:58.301710943,2021-03-31 09:23:00)",
                "data": "3.8497847e+06",
                "var_name": "RSTATISTICS1303439700001",
                "start_time": "2021-03-31T09:20:12+08:00",
                "end_time": "2021-03-31T09:21:58+08:00",
                "created": "2021-03-31T09:22:00+08:00",
                "is_available": 1
            }
        ]
    }
}

获取统计计算列表

时间范围说明:统计计算结果记录有三个时间,分别是周期开始时间(start_time)、周期结束时间(end_time)和记录生成时间(created),startend目前是对结果记录的周期结束时间(end_time)进行筛选。

请求

统计

{
    "action":"get_statistics_list",
    "script_uid": "STATISTICS1302924600002",
    "mapping_id": "",
    "object_id": "OBJ1392682700001",
    "start": "2021-03-29 00:00:00",
    "end": "2021-03-30 00:00:00",
    "order_by": "[\"end_time\", \"asc\"]", // 按指定字段排序,json字符串 [字段名, asc 或 desc]
    "items": 10000 // 不填默认返回 20 条数据
}

计算

{
    "action":"get_calculate_list",
    "script_uid": "STATISTICS1302924600002",
    "mapping_id": "",
    "object_id": "OBJ1392682700001",
    "start": "2021-03-29 00:00:00",
    "end": "2021-03-30 00:00:00",
    "order_by": "[\"end_time\", \"asc\"]", // 按指定字段排序,json字符串 [字段名, asc 或 desc]
    "items": 2  // 不填默认返回 20 条数据
}

响应

{
    "resp": "get_statistics_list",
    "code": 200,
    "msg": "成功",
    "result": {
        "data": [
            {
                "id": 1880,
                "script_uid": "STATISTICS1302924600002",
                "object_id": "OBJ1392682700001",
                "description": "this(2021-03-31 09:21:00,2021-03-31 09:22:00.205427629) real(2021-03-31 09:20:12.218593571,2021-03-31 09:21:58.301710943) next(2021-03-31 09:21:58.301710943,2021-03-31 09:23:00)",
                "data": "",
                "var_name": "RSTATISTICS1302924600002",
                "start_time": "2021-03-31T09:20:12+08:00",
                "end_time": "2021-03-31T09:21:58+08:00",
                "created": "2021-03-31T09:22:00+08:00",
                "is_available": 1
            },
            {
                "id": 1881,
                "script_uid": "STATISTICS1303439700001",
                "object_id": "OBJ1392682700001",
                "description": "this(2021-03-31 09:21:00,2021-03-31 09:22:00.504208789) real(2021-03-31 09:20:12.218593571,2021-03-31 09:21:58.301710943) next(2021-03-31 09:21:58.301710943,2021-03-31 09:23:00)",
                "data": "3.8497847e+06",
                "var_name": "RSTATISTICS1303439700001",
                "start_time": "2021-03-31T09:20:12+08:00",
                "end_time": "2021-03-31T09:21:58+08:00",
                "created": "2021-03-31T09:22:00+08:00",
                "is_available": 1
            }
        ]
    }
}
文档更新时间: 2024-04-12 17:57   作者:技术支持