1. Retainer接口文档

1.1. 获取列表

body:

{
    "action":"get_retainer_list"
}

curl:

curl -X POST --data '{"action":"get_retainer_list"}' http://127.0.0.1:6061/retainer/api

response:

{
    "resp": "get_retainer_list",
    "code": 200,
    "msg": "成功",
    "result": {
        "page_index": 1,
        "page_size": 10,
        "total_pages": 1,
        "total_records": 2,
        "data": [
            {
                "id": 1017,
                "uid": "RETAINER1515245014412",
                "name": "adasdad",
                "description": "adad",
                "objectlist": ["OBJ1572697700024","OBJ1632060900003"],
                "is_active": 0,
                "script": [],
                "created": "2021-05-31T17:27:52+08:00",
                "last_modified": "2021-06-21T18:28:31+08:00",
                "last_modified_by": 0,
                "is_available": 1,
                "category": "OTHER"
            },
            {
                "id": 1014,
                "uid": "RETAINER1484592500004",
                "name": "test",
                "description": "",
                "objectlist": [],
                "is_active": 0,
                "script": [
                    [
                        "RV1",
                        "running_stop1",
                        "设备启停1",
                        "1711",
                        "1710"
                    ]
                ],
                "created": "2021-04-08T17:18:45+08:00",
                "last_modified": "2021-04-09T12:08:36+08:00",
                "last_modified_by": 0,
                "is_available": 1,
                "category": "OTHER"
            }
        ]
    }
}

1.2. 获取项目

{
    "action":"get_retainer_item",
    "uid":"RETAINER1323077500001"
}

curl:

curl -X POST --data '{"action":"get_retainer_item","uid":"RETAINER1323077500001"}' http://127.0.0.1:6061/retainer/api

response:

{
    "resp": "get_retainer_item",
    "code": 200,
    "msg": "成功",
    "result": {
        "id": 1008,
        "uid": "RETAINER1323077500001",
        "name": "test111",
        "description": "666666",
        "is_active": 1,
        "script": [
            [
                "a2b",
                "a2b_en",
                "a2b_cn",
                "1001",
                "1002"
            ],
            [
                "b2c",
                "b2c_en",
                "b2c_cn",
                "1002",
                "1003"
            ]
        ],
        "created": "2021-03-12T15:54:30+08:00",
        "last_modified": "2021-03-12T15:55:42+08:00",
        "last_modified_by": 0,
        "is_available": 1,
        "category": "OTHER"
    }
}

1.3. 创建项目

用于创建retainer项目。

body:

{
    "action":"create_retainer",
    "is_active":0,
    "description":"12164461",
    "name":"test",
    "script":[["a2b", "a2b_en", "a2b_cn", "1001", "1002"], ["b2c", "b2c_en", "b2c_cn", "1002", "1003"]],
    "object_list":["1001","1002"],
    "category":"FAULT"
}

curl:

curl -X POST --data '{"action":"create_retainer","is_active":0,"description":"12164461","name":"test","script":[["a2b","a2b_en","a2b_cn","1001","1002"],["b2c","b2c_en","b2c_cn","1002","1003"]],"object_list":["1001","1002"],"category":"FAULT"}' http://127.0.0.1:6061/retainer/api

response:

{
    "resp": "create_retainer",
    "code": 200,
    "msg": "成功",
    "result": {
        "uid": "RETAINER1622294400001"
    }
}

1.4. 更新项目

body:

{
    "action":"update_retainer",
    "uid":"RETAINER1622294400001",
    "description":"666666",
    "name":"test111",
    "script":[["a2b", "a2b_en", "a2b_cn", "1001", "1002"], ["b2c", "b2c_en", "b2c_cn", "1002", "1003"]],
    "object_list":["OBJ_TEST1001"],
    "category":"EVENT"
}

curl:

curl -X POST --data '{"action":"update_retainer","uid":"RETAINER1622294400001","description":"666666","name":"test111","script":[["a2b","a2b_en","a2b_cn","1001","1002"],["b2c","b2c_en","b2c_cn","1002","1003"]],"object_list":["OBJ_TEST1001"],"category":"EVENT"}' http://127.0.0.1:6061/retainer/api

response:

{
    "resp": "update_retainer",
    "code": 200,
    "msg": "成功"
}

1.5. 删除项目

body:

{
    "action":"delete_retainer",
    "uid":"RETAINER1622294400001"
}

curl:

curl -X POST --data '{"action":"delete_retainer","uid":"RETAINER1622294400001"}' http://127.0.0.1:6061/retainer/api

response:

{
    "resp": "delete_retainer",
    "code": 200,
    "msg": "成功"
}

1.6. 启动项目

body:

{
    "action":"start_retainer",
    "uid":"RETAINER1323077500001"
}

curl:

curl -X POST --data '{"action":"create_retainer","uid":"RETAINER1323077500001"}' http://127.0.0.1:6061/retainer/api

response:

{
    "resp": "start_retainer",
    "code": 200,
    "msg": "成功"
}

1.7. 停止项目

body:

{
    "action":"stop_retainer",
    "uid":"RETAINER1323077500001"
}

curl:

curl -X POST --data '{"action":"create_retainer","uid":"RETAINER1323077500001"}' http://127.0.0.1:6061/retainer/api

response:

{
    "resp": "stop_retainer",
    "code": 200,
    "msg": "成功"
}

1.8. 获取历程列表

body:

{
    "page_index": 1,
    "page_size": 20,
    "where_and": "[[\"object_id\",\"=\",\"OBJ1001\"],[\"retained\",\"=\",\"0\"],[\"category\",\"=\",\"FAULT\"]]",
    "action": "get_retainer_result_list",
    "organization_id":"ORGANIZATION1658222117234135"
}
retained 说明
1 开放状态
0 关闭状态
category 说明
EVENT 事件列表
ALERT 报警列表
FAULT 故障列表
OTHER 其他列表

response:

{
    "resp": "get_retainer_result_list",
    "code": 200,
    "msg": "成功",
    "result": {
        "page_index": 1,
        "page_size": 20,
        "total_pages": 1,
        "total_records": 0,
        "data": [
            {}
        ]
    }
}

1.9.event事件消息

1.9.1.历程开启事件

{
    "event": "retainer_open",
    "block": "retainer",
    "uniqueid": "REP4694582200022",
    "datetime": "2024-06-19 10:00:45",
    "uid": "RRS4694580700005",
    "object_id": "cdp_test",
    "object_name": "cdp_test(不删不更新)",
    "object_alias": "cdp_test",
    "template_id": "RETAINER3714009000001",
    "template_name": "RETAINER3714009000001",
     "template_alias": "RETAINER3714009000001",
    "code": "S03_cdp",
    "retained": "1",
    "label_en": "first(S03)",
    "label_local": "3缸缸温大于50",
    "opened_at": "2024-06-19 10:00:43",
    "value": {
        "S03": 60.3
    },
    "category": "ALERT"
}

1.9.2.1.测试websocket订阅

websocket地址:你的平台websocket地址
  如 `ws://xxx.mixiot.top/apiproxy/ws/api`,若有ssl加密则改为`wss://xxx.mixiot.top/apiproxy/ws/api`

测试如下:

你发送的信息 2025-12-19 18:15:19
    {"action": "ping","Authorization":"Bearer U0dONDQ0MDA0NjgwMDAwMSMxNDdmNjU3MS03ZDAxxxx"}
服务端回应 2025-12-19 18:15:19
    {"resp":"ping","code":200,"msg":"成功","result":{"pong":"pong"}}

你发送的信息 2025-12-19 18:15:30
    {"action": "sub_agent_event","event": {"event": "retainer_open", "block":"retainer"}}
服务端回应 2025-12-19 18:15:30
    {"resp":"sub_agent_event","actionid":"","code":200,"msg":"成功","result":{"uid":"a3e206b3-2ae3-406b-a502-5b90e1ead2ad"}}

服务端回应 2025-12-19 18:16:02
    {"event":"retainer_open","block":"retainer","uniqueid":"MIX529030225","datetime":"2025-12-19 18:16:03","uid":"RRS5290301","object_id":"OBJ49042358","object_name":"零部件1#","object_alias":"A240813_04","template_id":"RETAINER1059","template_name":"1059-HI系列","template_alias":"RETAINER19","code":"A09","retained":"1","label_en":"","label_local":"A09、燃烧器故障","opened_at":"2025-12-19 18:16:03","value":{"ALM01":256},"category":"FAULT","sub_uid":"a3e206b3-2ae3-406b-a502-5b90e1ead2ad"}

1.9.2.历程关闭事件

{
    "event": "retainer_close",
    "block": "retainer",
    "uniqueid": "REP4690810700876",
    "datetime": "2024-06-19 10:02:08",
    "uid": "RRS4690508200842",
    "object_id": "cdp_test",
    "object_name": "cdp_test(不删不更新)",
    "object_alias": "cdp_test",
    "template_id": "RETAINER3714009000001",
    "template_name": "RETAINER3714009000001",
     "template_alias": "RETAINER3714009000001",
    "code": "S06_cdp",
    "retained": "0",
    "label_en": "min(S06)",
    "label_local": "6缸缸温大于50",
    "opened_at": "2024-06-19 10:02:05",
    "value": {
        "S06": 48.74
    },
    "category": "ALERT",
    "elapsed": "3.012516372s",
    "elapsed_second": 3,
    "statis_expr": "min;S06",
    "statis_result": 50.33,
    "close_at": "2024-06-19 10:02:08"
}

1.9.3.历程持续事件

{
    "uid": "RRS4695704900759",
    "template_id": "RETAINER3714009000001",
    "category": "ALERT",
    "retainer_code": "S01_cdp",
    "uniqueid": "PUB4692639307048",
    "block": "retainer",
    "code": "2001",
    "datetime": "2024-06-19 10:03:26",
    "event": "retainer_event",
    "label_en": "",
    "label_local": "1缸缸温大于50",
    "object_id": "cdp_test",
    "object_name": "cdp_test(不删不更新)",
    "object_alias": "cdp_test",
    "terminal_id": "cdp_test",
    "value": {
        "S00": 628422.56,
        "S01": 53.79,
        "S01$1": 53.79
    }
}

1.9.4.历程实时结果事件

{
    "event": "retainer_realtime_result",
    "block": "retainer",
    "uniqueid": "REP4692810303627",
    "datetime": "2024-06-19 10:06:28",
    "uid": "RRS4692708803614",
    "object_id": "cdp_test",
    "object_name": "cdp_test(不删不更新)",
    "object_alias": "cdp_test",
    "template_id": "RETAINER3714009000001",
    "template_name": "RETAINER3714009000001",
     "template_alias": "RETAINER3714009000001",
    "code": "S03_cdp",
    "retained": "0",
    "label_en": "first(S03)",
    "label_local": "3缸缸温大于50",
    "opened_at": "2024-06-19 10:06:27",
    "value": {
        "S03": 49.21
    },
    "category": "ALERT",
    "elapsed": "1.003961439s",
    "elapsed_second": null,
    "statis_expr": "first;S03",
    "statis_result": null
}
文档更新时间: 2025-12-19 18:24   作者:技术支持