Skip to content

项目 HTTP API

项目 HTTP API 基于当前 OpenAPI 定义生成,用于项目级资源访问、设备管理、设备数据查询、设备控制、告警和规则查询。

准备工作

在正式调用 API 前,请在 ZhiLian.Yun 控制台的项目应用中创建 API 类型应用,获取 appIdaccessKeysecretKey。除服务信息和获取访问令牌接口外,其他接口需要在请求头中携带项目 API 访问令牌。

http
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

TIP

这里的项目 API AccessToken/api/v1/access_token 获取,不是设备证书中的 AccessToken,两者不能混用。

API 请求代码示例

以获取 API AccessToken 为例,项目 API 通过 HTTP JSON 请求调用。

shell
curl -X POST "https://<endpoint>/api/v1/access_token" \
  -H "Content-Type: application/json" \
  -d '{
    "appId": "APP_ID",
    "accessKey": "ACCESS_KEY",
    "secretKey": "SECRET_KEY"
  }'

获取 API AccessToken

服务器获取 AccessToken

Request Syntax

http
POST /api/v1/access_token HTTP/1.1
Content-Type: application/json

Request Body

字段类型必填说明
appIdstring应用ID
accessKeystring访问KEY
secretKeystring访问密钥

Request Example

json
{
  "appId": "APP_ID",
  "accessKey": "ACCESS_KEY",
  "secretKey": "SECRET_KEY"
}

Response Data

字段类型说明
accessTokenstring访问令牌
expiresIninteger过期时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "accessToken": "ACCESS_TOKEN",
    "expiresIn": 315360000
  },
  "error": null,
  "traceId": "TRACE_ID"
}

接口总览

方法路径说明分组
POST/api/v1/access_token获取访问令牌获取 API AccessToken
POST/api/v1/device_type新增设备类型设备类型
DELETE/api/v1/device_type/:typeKey删除设备类型设备类型
GET/api/v1/device_type/:typeKey获取设备类型指定信息设备类型
GET/api/v1/device_type/:typeKey/extend_infos获取设备类型扩展信息列表设备类型
PUT/api/v1/device_type/:typeKey/info修改设备类型信息设备类型
GET/api/v1/device_types获取设备类型列表设备类型
GET/api/v1/device_groups_tree读取设备组树形列表设备组
POST/api/v1/device创建设备设备管理
DELETE/api/v1/device/:deviceCode删除设备设备管理
GET/api/v1/device/:deviceCode读取设备信息设备管理
PUT/api/v1/device/:deviceCode/info修改设备基本信息设备管理
GET/api/v1/devices读取设备列表设备管理
POST/api/v1/device/:deviceCode/extend_info修改设备扩展信息设备扩展信息
PUT/api/v1/device/:deviceCode/extend_info修改设备扩展信息设备扩展信息
GET/api/v1/device/:deviceCode/extend_infos读取设备扩展信息设备扩展信息
POST/api/v1/control/device/:deviceCode/attribute_acquisition采集设备属性设备数据
POST/api/v1/control/device/:deviceCode/attributes下发设备属性设备数据
GET/api/v1/device/:deviceCode/attribute/:key/aggregate获取设备历史属性聚合设备数据
GET/api/v1/device/:deviceCode/attribute/:key/series获取设备历史属性设备数据
GET/api/v1/device/:deviceCode/attributes获取设备最新属性设备数据
POST/api/v1/device/:deviceCode/attributes_remove删除设备历史属性设备数据
GET/api/v1/device/:deviceCode/device_config获取设备配置信息设备通信
PUT/api/v1/device/:deviceCode/device_config修改单个设备的配置设备通信
GET/api/v1/device_statistic/:deviceCode获取设备消息数设备通信
POST/api/v1/control/device/:deviceCode/command发送指令设备通信
GET/api/v1/alarm_rule/:id获取告警规则指定信息设备告警
GET/api/v1/alarm_rules获取告警规则列表设备告警
GET/api/v1/alarm_log/:id/info获取告警历史指定信息设备告警
PUT/api/v1/alarm_log/:id/maintain_info修改告警历史维护信息设备告警
GET/api/v1/alarm_logs读取所有告警消息设备告警
GET/api/v1/rules获取规则列表消息规则
GET/api/v1/rules/:id获取规则指定信息消息规则
GET/api/v1/device/:deviceCode/online_logs获取设备上下线日志列表设备上下线日志
GET/api/v1/info服务信息服务信息

设备类型

获取设备类型列表

Request Syntax

http
GET /api/v1/device_types HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Query Parameters

参数类型必填说明
pageinteger页码
pageSizeinteger每页大小
keywordstring关键字
idintegerID
namestring类型名称
createdAtarray<string>创建时间
typeKeystring类型KEY
connTypeinteger设备接入类型:1 直连设备,2 子设备,3 网关设备。
msgProtocolinteger设备接入协议:1 内部标准,2 Modbus RTU 透传,3 Modbus TCP 透传,99 其他。
productKeystring产品识别码
scanTypeKeystring扫描类型KEY,结合Sort使用
sortstring排序方式(type_key_asc:类型KEY升序,type_key_desc:类型KEY降序)
typeKeysarray<string>类型KEY列表

Response Data

字段类型说明
pageinteger
pageSizeinteger
totalinteger
itemsarray<internal.model.XjDeviceTypesListModel>数据列表
items[].idintegerID
items[].namestring类型名称
items[].descrstring类型描述
items[].iconstring类型图标
items[].connProtocolinteger设备通信方式:1 WiFi,2 以太网,3 4G,4 5G,5 NB-IoT,6 RS485,7 RS232,8 RS422,9 LoRa,10 Zigbee,11 BLE,99 其他。
items[].connTypeinteger设备接入类型:1 直连设备,2 子设备,3 网关设备。
items[].msgProtocolinteger设备接入协议:1 内部标准,2 Modbus RTU 透传,3 Modbus TCP 透传,99 其他。
items[].onlineDelayinteger在线超时时间(秒)
items[].activeDelayinteger活跃超时时间(秒)
items[].typeKeystring类型KEY
items[].productKeystring产品识别码
items[].createdAtstring创建时间
items[].deviceCountinteger设备数量

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "pageSize": 1,
    "total": 1,
    "items": [
      {
        "id": 1,
        "name": "名称",
        "descr": "描述",
        "icon": "string",
        "connProtocol": 1
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

读取设备类型信息

Request Syntax

http
GET /api/v1/device_type/:typeKey HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
typeKeystring类型KEY

Query Parameters

参数类型必填说明
idintegerID

Response Data

字段类型说明
idintegerID
namestring类型名称
descrstring类型描述
iconstring类型图标
connProtocolinteger设备通信方式:1 WiFi,2 以太网,3 4G,4 5G,5 NB-IoT,6 RS485,7 RS232,8 RS422,9 LoRa,10 Zigbee,11 BLE,99 其他。
connTypeinteger设备接入类型:1 直连设备,2 子设备,3 网关设备。
msgProtocolinteger设备接入协议:1 内部标准,2 Modbus RTU 透传,3 Modbus TCP 透传,99 其他。
onlineDelayinteger在线超时时间(秒)
activeDelayinteger活跃超时时间(秒)
masterModelstring主模型
pluginModelstring插件模型
typeKeystring类型KEY
openAutoCreateinteger是否允许设备自动创建:0 未开启,1 已开启。
openCreateListinteger是否启用设备白名单:0 未开启,1 已开启。
createListApistring设备白名单验证API
openProductKeyinteger是否启用产品识别码:0 未开启,1 已开启。
productKeystring产品识别码
openProductConfiginteger是否启用产品默认配置:0 未开启,1 已开启。
productConfigstring产品默认配置
updateVerinteger更新版本
tenantIdstring租户ID
createdDeptinteger创建部门
createdByinteger创建者
createdAtstring创建时间
updatedByinteger更新者
updatedAtstring更新时间
deviceCountinteger设备数量
panelConfigstring面板配置
userConfigstring用户配置

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": 1,
    "name": "名称",
    "descr": "描述",
    "icon": "string",
    "connProtocol": 1,
    "connType": 1,
    "msgProtocol": 1,
    "onlineDelay": 1,
    "activeDelay": 1,
    "masterModel": "string",
    "pluginModel": "string",
    "typeKey": "TYPE_KEY"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

读取设备类型扩展信息定义

Request Syntax

http
GET /api/v1/device_type/:typeKey/extend_infos HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
typeKeystring设备类型KEY

Response Data

字段类型说明
pageinteger
pageSizeinteger
totalinteger
itemsarray<internal.model.XjDevTypeExtendListModel>数据列表
items[].idintegerID
items[].typeKeystring设备类型KEY
items[].namestring名称
items[].descrstring描述
items[].infoTypestring扩展类型。内置值:location 地理坐标。
items[].infoConfigstring配置
items[].enabledinteger是否启用:0 未启用,1 已启用。
items[].createdAtstring创建时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "pageSize": 1,
    "total": 1,
    "items": [
      {
        "id": 1,
        "typeKey": "TYPE_KEY",
        "name": "名称",
        "descr": "描述",
        "infoType": "string"
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

创建设备类型

Request Syntax

http
POST /api/v1/device_type HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Request Body

字段类型必填说明
idintegerID
namestring类型名称
descrstring类型描述
iconstring类型图标
connProtocolinteger设备通信方式:1 WiFi,2 以太网,3 4G,4 5G,5 NB-IoT,6 RS485,7 RS232,8 RS422,9 LoRa,10 Zigbee,11 BLE,99 其他。
connTypeinteger设备接入类型:1 直连设备,2 子设备,3 网关设备。
msgProtocolinteger设备接入协议:1 内部标准,2 Modbus RTU 透传,3 Modbus TCP 透传,99 其他。
onlineDelayinteger在线超时时间(秒)
activeDelayinteger活跃超时时间(秒)
masterModelstring主模型
plugin_modelstring插件模型
openAutoCreateinteger是否允许设备自动创建:0 未开启,1 已开启。
openCreateListinteger是否启用设备白名单:0 未开启,1 已开启。
createListApistring设备白名单验证API
openProductKeyinteger是否启用产品识别码:0 未开启,1 已开启。
productKeystring产品识别码
openProductConfiginteger是否启用产品默认配置:0 未开启,1 已开启。
productConfigstring产品默认配置

Request Example

json
{
  "id": 1,
  "name": "名称",
  "descr": "描述",
  "icon": "string",
  "connProtocol": 1,
  "connType": 1,
  "msgProtocol": 1,
  "onlineDelay": 1,
  "activeDelay": 1,
  "masterModel": "string",
  "plugin_model": "string",
  "openAutoCreate": 1
}

Response Data

字段类型说明
idinteger设备类型ID
typeKeystring设备类型KEY

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": 1,
    "typeKey": "TYPE_KEY"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

修改设备类型信息

Request Syntax

http
PUT /api/v1/device_type/:typeKey/info HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
typeKeystring路径参数

Request Body

字段类型必填说明
idintegerID
namestring类型名称
descrstring类型描述
iconstring类型图标
connProtocolinteger设备通信方式:1 WiFi,2 以太网,3 4G,4 5G,5 NB-IoT,6 RS485,7 RS232,8 RS422,9 LoRa,10 Zigbee,11 BLE,99 其他。
connTypeinteger设备接入类型:1 直连设备,2 子设备,3 网关设备。
msgProtocolinteger设备接入协议:1 内部标准,2 Modbus RTU 透传,3 Modbus TCP 透传,99 其他。
onlineDelayinteger在线超时时间(秒)
activeDelayinteger活跃超时时间(秒)
masterModelstring主模型
plugin_modelstring插件模型
openAutoCreateinteger是否允许设备自动创建:0 未开启,1 已开启。
openCreateListinteger是否启用设备白名单:0 未开启,1 已开启。
createListApistring设备白名单验证API
openProductKeyinteger是否启用产品识别码:0 未开启,1 已开启。
productKeystring产品识别码
openProductConfiginteger是否启用产品默认配置:0 未开启,1 已开启。
productConfigstring产品默认配置

Request Example

json
{
  "id": 1,
  "name": "名称",
  "descr": "描述",
  "icon": "string",
  "connProtocol": 1,
  "connType": 1,
  "msgProtocol": 1,
  "onlineDelay": 1,
  "activeDelay": 1,
  "masterModel": "string",
  "plugin_model": "string",
  "openAutoCreate": 1
}

Response Data

字段类型说明
idinteger设备类型ID
typeKeystring设备类型KEY

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": 1,
    "typeKey": "TYPE_KEY"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

删除设备类型

Request Syntax

http
DELETE /api/v1/device_type/:typeKey HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
typeKeystring路径参数

Query Parameters

参数类型必填说明
idinterfaceID

Response Data

无响应业务字段。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {},
  "error": null,
  "traceId": "TRACE_ID"
}

设备组

读取设备组树形列表

Request Syntax

http
GET /api/v1/device_groups_tree HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Response Data

字段类型说明
itemsarray<internal.model.XjGroupsTreeModel>数据列表
items[].idintegerID
items[].namestring名称
items[].groupKeystring分组KEY
items[].descrstring描述
items[].parentKeystring父分组KEY
items[].createdAtstring创建时间
items[].deviceCountinteger设备数量
items[].childCountinteger子分组数量
items[].childrenarray<internal.model.XjGroupsTreeModel>子分组

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "items": [
      {
        "id": 1,
        "name": "名称",
        "groupKey": "string",
        "descr": "描述",
        "parentKey": "string"
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

设备管理

读取设备列表

Request Syntax

http
GET /api/v1/devices HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Query Parameters

参数类型必填说明
pageinteger页码
pageSizeinteger每页大小
keywordstring关键字
idinteger设备ID
namestring设备名称
deviceCodestring设备码
statusstring设备启用状态:0 启用,1 禁用。
typeKeystring设备类型
onlineStatusinteger设备在线状态:1 在线,2 离线。
activeStatusinteger设备列表活跃状态:1 活跃,2 5 分钟内活跃,3 1 小时内活跃,4 1 天内活跃,20 不活跃,21 不活跃超过 1 天,22 不活跃超过 3 天,23 不活跃超过 7 天,30 从未活跃。
debugStatusinteger设备调试状态:0 未开启,1 已开启。
createdAtarray<string>创建时间
alarmStatusinteger设备告警状态:1 未告警,2 告警中,3 普通告警,4 重要告警,5 紧急告警。
connTypeinteger设备接入类型:1 直连设备,2 子设备,3 网关设备。
groupNotInstring设备不在那个分组下(用于设备组筛选)
groupKeystring设备分组KEY
sortstring排序方式(last_active_desc:最后活跃,created_asc:最早创建时间,created_desc:最新创建时间,name_asc:名称升序,device_code_asc:设备码升序,device_code_desc:设备码降序)
isNoFatherDeviceboolean是否查询无父设备
scanDeviceCodestring扫描设备码,结合Sort使用
deviceCodesarray<string>设备码列表

Response Data

字段类型说明
pageinteger
pageSizeinteger
totalinteger
itemsarray<internal.model.XjDevicesListModel>数据列表
items[].idinteger设备ID
items[].namestring设备名称
items[].descrstring设备描述
items[].typeKeystring设备类型KEY
items[].deviceKeystring设备唯一标识(嵌入式端)
items[].deviceCodestring设备码
items[].statusstring设备启用状态:0 启用,1 禁用。
items[].onlineStatusinteger设备在线状态:1 在线,2 离线。
items[].activeStatusinteger设备列表活跃状态:1 活跃,2 5 分钟内活跃,3 1 小时内活跃,4 1 天内活跃,20 不活跃,21 不活跃超过 1 天,22 不活跃超过 3 天,23 不活跃超过 7 天,30 从未活跃。
items[].debugStatusinteger设备调试状态:0 未开启,1 已开启。
items[].debugEnableTimeinteger设备调试时间
items[].latnumber设备坐标纬度
items[].lngnumber设备坐标经度
items[].alarmStatusinteger设备告警状态:1 未告警,2 告警中,3 普通告警,4 重要告警,5 紧急告警。
items[].firstLoginAtinteger第一次登录时间戳(毫秒)
items[].lastLoginAtinteger最后登录时间戳(毫秒)
items[].lastActiveAtinteger最后活跃时间戳(毫秒)
items[].typeNamestring设备类型名称
items[].groupobject<string, string>设备分组
items[].otaModulestringOTA模块
items[].otaVersionstringOTA版本
items[].otaModule2stringOTA模块2
items[].otaVersion2stringOTA版本2
items[].otaModule3stringOTA模块3
items[].otaVersion3stringOTA版本3
items[].otaModule4stringOTA模块4
items[].otaVersion4stringOTA版本4
items[].connTypeinteger设备接入类型:1 直连设备,2 子设备,3 网关设备。
items[].msgProtocolinteger设备接入协议:1 内部标准,2 Modbus RTU 透传,3 Modbus TCP 透传,99 其他。
items[].onlineDelayinteger在线超时时间(秒)
items[].activeDelayinteger活跃超时时间(秒)
items[].updateVerinteger更新版本
items[].iccidstringICCID(冗余)
items[].signalQualityinteger信号强度:0-4,数值越大通常表示信号越好。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "pageSize": 1,
    "total": 1,
    "items": [
      {
        "id": 1,
        "name": "名称",
        "descr": "描述",
        "typeKey": "TYPE_KEY",
        "deviceKey": "string"
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

读取设备信息

Request Syntax

http
GET /api/v1/device/:deviceCode HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring设备码

Query Parameters

参数类型必填说明
idinteger设备ID

Response Data

字段类型说明
idinteger设备ID
namestring设备名称
descrstring设备描述
typeKeystring设备类型KEY
deviceKeystring设备唯一标识(嵌入式端)
deviceCodestring设备码
statusstring设备启用状态:0 启用,1 禁用。
onlineStatusinteger设备在线状态:1 在线,2 离线。
alarmStatusinteger设备告警状态:1 未告警,2 告警中,3 普通告警,4 重要告警,5 紧急告警。
debugStatusinteger设备调试状态:0 未开启,1 已开启。
debugEnableTimeinteger设备调试时间戳(毫秒)
gatewayDeviceCodestring网关设备码
subDeviceAddrstring子设备地址
gatewayAddTimestring网关添加时间
addressstring设备位置
latnumber设备坐标纬度
lngnumber设备坐标经度
regionCodestring行政区域代码
locationBuildingstring建筑
locationUnitstring单元
locationFloorstring楼层
locationRoomstring房号
deviceSecretstring设备密钥
firstLoginAtinteger第一次登录时间戳(毫秒)
lastLoginAtinteger最后登录时间戳(毫秒)
lastActiveAtinteger最后活跃时间戳(毫秒)
otaLockintegerOTA 升级锁定状态:0 未锁定,1 已锁定。
otaModulestringOTA模块
otaVersionstringOTA版本
otaModule2stringOTA模块2
otaVersion2stringOTA版本2
otaModule3stringOTA模块3
otaVersion3stringOTA版本3
otaModule4stringOTA模块4
otaVersion4stringOTA版本4
connTypeinteger设备接入类型:1 直连设备,2 子设备,3 网关设备。
msgProtocolinteger设备接入协议:1 内部标准,2 Modbus RTU 透传,3 Modbus TCP 透传,99 其他。
onlineDelayinteger在线超时时间(秒)
activeDelayinteger活跃超时时间(秒)
updateVerinteger更新版本
iccidstringICCID(冗余)
signalQualityinteger信号强度:0-4,数值越大通常表示信号越好。
tenantIdstring租户ID
createdDeptinteger创建部门
createdByinteger创建者
createdAtstring创建时间
updatedByinteger更新者
updatedAtstring更新时间
typeNamestring设备类型名称
masterModelstring物模型
connInfointernal.model.XjDeviceConnInfo设备连接信息
connInfo.deviceCodestring设备码
connInfo.loginTimeMsinteger最后登录时间(毫秒)
connInfo.lastTimeMsinteger最后在线时间(毫秒)
connInfo.onlineDelayinteger在线超时时间(秒)
connInfo.activeDelayinteger活跃超时时间(秒)
connInfo.svrTypeinteger数据服务类型
connInfo.svrCodestring数据服务编号
connInfo.connIdinteger连接ID
connInfo.connStatusinteger连接状态(0:离线 1:在线)
connInfo.gatewayCodestring网关设备码
connInfo.subAddrAllstring子设备地址全路径
connInfo.msgTypeTimeobject<string, integer>消息类型时间(毫秒)
connInfo.isOnlineboolean设备在线状态:1 在线,2 离线。
grouparray<internal.model.Group>设备分组
group[].routerstring
group[].keystring
group[].idinteger
parentDeviceIdinteger网关设备ID
parentDeviceNamestring网关设备名称

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": 1,
    "name": "名称",
    "descr": "描述",
    "typeKey": "TYPE_KEY",
    "deviceKey": "string",
    "deviceCode": "DEVICE_CODE",
    "status": "string",
    "onlineStatus": 1,
    "alarmStatus": 1,
    "debugStatus": 1,
    "debugEnableTime": 1626197189,
    "gatewayDeviceCode": "DEVICE_CODE"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

创建设备

Request Syntax

http
POST /api/v1/device HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Request Body

字段类型必填说明
idinteger设备ID
namestring设备名称
descrstring设备描述
typeKeystring设备类型KEY
deviceKeystring设备唯一标识(嵌入式端)
statusstring设备启用状态:0 启用,1 禁用。
debugStatusinteger设备调试状态:0 未开启,1 已开启。
debugEnableTimeinteger设备调试时间
addressstring设备位置
latnumber设备坐标纬度
lngnumber设备坐标经度
regionCodestring行政区域代码
locationBuildingstring建筑
locationUnitstring单元
locationFloorstring楼层
locationRoomstring房号

Request Example

json
{
  "id": 1,
  "name": "名称",
  "descr": "描述",
  "typeKey": "TYPE_KEY",
  "deviceKey": "string",
  "status": "string",
  "debugStatus": 1,
  "debugEnableTime": 1626197189,
  "address": "string",
  "lat": 1.23,
  "lng": 1.23,
  "regionCode": "string"
}

Response Data

字段类型说明
idinteger设备ID
deviceCodestring设备码

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": 1,
    "deviceCode": "DEVICE_CODE"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

修改设备基本信息

Request Syntax

http
PUT /api/v1/device/:deviceCode/info HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring路径参数

Request Body

字段类型必填说明
idinteger设备ID
namestring设备名称
descrstring设备描述
typeKeystring设备类型KEY
deviceKeystring设备唯一标识(嵌入式端)
statusstring设备启用状态:0 启用,1 禁用。
debugStatusinteger设备调试状态:0 未开启,1 已开启。
debugEnableTimeinteger设备调试时间
addressstring设备位置
latnumber设备坐标纬度
lngnumber设备坐标经度
regionCodestring行政区域代码
locationBuildingstring建筑
locationUnitstring单元
locationFloorstring楼层
locationRoomstring房号

Request Example

json
{
  "id": 1,
  "name": "名称",
  "descr": "描述",
  "typeKey": "TYPE_KEY",
  "deviceKey": "string",
  "status": "string",
  "debugStatus": 1,
  "debugEnableTime": 1626197189,
  "address": "string",
  "lat": 1.23,
  "lng": 1.23,
  "regionCode": "string"
}

Response Data

字段类型说明
idinteger设备ID
deviceCodestring设备码

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": 1,
    "deviceCode": "DEVICE_CODE"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

移除设备

Request Syntax

http
DELETE /api/v1/device/:deviceCode HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring设备码

Query Parameters

参数类型必填说明
idinterface设备ID

Response Data

无响应业务字段。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {},
  "error": null,
  "traceId": "TRACE_ID"
}

设备扩展信息

读取设备扩展信息

Request Syntax

http
GET /api/v1/device/:deviceCode/extend_infos HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring设备码

Query Parameters

参数类型必填说明
pageinteger页码
pageSizeinteger每页大小
keywordstring关键字

Response Data

字段类型说明
pageinteger
pageSizeinteger
totalinteger
itemsarray<internal.model.XjDeviceExtendsListModel>数据列表
items[].idintegerID
items[].deviceCodestring设备码
items[].namestring名称
items[].typeExtendIdinteger扩展类型。内置值:location 地理坐标。ID
items[].infoTypestring扩展类型。内置值:location 地理坐标。
items[].extendValuestring扩展数据值
items[].createdDeptinteger创建部门
items[].createdByinteger创建者
items[].createdBySummainternal.library.xgorm.hook.MemberSumma创建者摘要信息
items[].createdAtstring创建时间
items[].updatedByinteger更新者
items[].updatedBySummainternal.library.xgorm.hook.MemberSumma更新者摘要信息
items[].updatedAtstring更新时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "pageSize": 1,
    "total": 1,
    "items": [
      {
        "id": 1,
        "deviceCode": "DEVICE_CODE",
        "name": "名称",
        "typeExtendId": 1,
        "infoType": "string"
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

修改设备扩展信息(POST)

Request Syntax

http
POST /api/v1/device/:deviceCode/extend_info HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring路径参数

Request Body

字段类型必填说明
idintegerID
deviceCodestring设备码
namestring名称
typeExtendIdinteger扩展类型。内置值:location 地理坐标。ID
infoTypestring扩展类型。内置值:location 地理坐标。扩展类型。内置值:location 地理坐标。
extendValuestring扩展数据值
tenantIdstring租户ID
createdDeptinteger创建部门
createdByinteger创建者
createdAtstring创建时间
updatedByinteger更新者
updatedAtstring更新时间

Request Example

json
{
  "id": 1,
  "deviceCode": "DEVICE_CODE",
  "name": "名称",
  "typeExtendId": 1,
  "infoType": "string",
  "extendValue": "string",
  "tenantId": "string",
  "createdDept": 1,
  "createdBy": 1,
  "createdAt": "string",
  "updatedBy": 1,
  "updatedAt": "string"
}

Response Data

无响应业务字段。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {},
  "error": null,
  "traceId": "TRACE_ID"
}

修改设备扩展信息(PUT)

Request Syntax

http
PUT /api/v1/device/:deviceCode/extend_info HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring路径参数

Request Body

字段类型必填说明
idintegerID
deviceCodestring设备码
namestring名称
typeExtendIdinteger扩展类型。内置值:location 地理坐标。ID
infoTypestring扩展类型。内置值:location 地理坐标。扩展类型。内置值:location 地理坐标。
extendValuestring扩展数据值
tenantIdstring租户ID
createdDeptinteger创建部门
createdByinteger创建者
createdAtstring创建时间
updatedByinteger更新者
updatedAtstring更新时间

Request Example

json
{
  "id": 1,
  "deviceCode": "DEVICE_CODE",
  "name": "名称",
  "typeExtendId": 1,
  "infoType": "string",
  "extendValue": "string",
  "tenantId": "string",
  "createdDept": 1,
  "createdBy": 1,
  "createdAt": "string",
  "updatedBy": 1,
  "updatedAt": "string"
}

Response Data

无响应业务字段。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {},
  "error": null,
  "traceId": "TRACE_ID"
}

设备数据

读取设备当前属性值集合

Request Syntax

http
GET /api/v1/device/:deviceCode/attributes HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring设备码

Response Data

字段类型说明
deviceCodestring设备码
listarray<git.xiujie.cn.cloud.cloud-public.xjpubmodel.XjDeviceProperty>属性列表
list[].keystring属性标识
list[].namestring属性名称(可空)
list[].typestring属性值类型(可空)
list[].unitstring属性值单位(可空)
list[].vgithub.com.gogf.gf.v2.container.gvar.Var属性值
list[].tsstring时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "deviceCode": "DEVICE_CODE",
    "list": [
      {
        "key": "temperature",
        "name": "名称",
        "type": "string",
        "unit": "string",
        "v": {}
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

读取设备属性历史数据

Request Syntax

http
GET /api/v1/device/:deviceCode/attribute/:key/series HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring设备SN
keystring属性标识

Query Parameters

参数类型必填说明
startTimestring开始时间
endTimestring结束时间
isAscboolean是否升序
pageinteger页码
pageSizeinteger每页大小
keywordstring关键字

Response Data

字段类型说明
pageinteger
pageSizeinteger
totalinteger
dataarray<git.xiujie.cn.cloud.cloud-public.xjpubmodel.XjDeviceProperty>
data[].keystring属性标识
data[].namestring属性名称(可空)
data[].typestring属性值类型(可空)
data[].unitstring属性值单位(可空)
data[].vgithub.com.gogf.gf.v2.container.gvar.Var属性值
data[].tsstring时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "pageSize": 1,
    "total": 1,
    "data": [
      {
        "key": "temperature",
        "name": "名称",
        "type": "string",
        "unit": "string",
        "v": {}
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

读取设备属性聚合统计数据

Request Syntax

http
GET /api/v1/device/:deviceCode/attribute/:key/aggregate HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring设备SN
keystring属性标识

Query Parameters

参数类型必填说明
startTimestring开始时间
endTimestring结束时间
isAscboolean是否升序
aggregateWindowstring聚合窗口
aggregateFunctionstring聚合函数
pageinteger页码
pageSizeinteger每页大小
keywordstring关键字

Response Data

字段类型说明
pageinteger
pageSizeinteger
totalinteger
dataarray<git.xiujie.cn.cloud.cloud-public.xjpubmodel.XjDeviceProperty>
data[].keystring属性标识
data[].namestring属性名称(可空)
data[].typestring属性值类型(可空)
data[].unitstring属性值单位(可空)
data[].vgithub.com.gogf.gf.v2.container.gvar.Var属性值
data[].tsstring时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "pageSize": 1,
    "total": 1,
    "data": [
      {
        "key": "temperature",
        "name": "名称",
        "type": "string",
        "unit": "string",
        "v": {}
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

移除设备属性

Request Syntax

http
POST /api/v1/device/:deviceCode/attributes_remove HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring路径参数

Request Body

字段类型必填说明
deviceCodestring设备SN
keysarray<string>属性标识列表,必填
isRemoveboolean是否移除属性,true:移除最后属性和历史属性,false:保留最后属性
startTimestring开始时间,可空
endTimestring结束时间,可空

Request Example

json
{
  "deviceCode": "DEVICE_CODE",
  "keys": [
    "string"
  ],
  "isRemove": true,
  "startTime": "string",
  "endTime": "string"
}

Response Data

无响应业务字段。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {},
  "error": null,
  "traceId": "TRACE_ID"
}

采集设备属性

Request Syntax

http
POST /api/v1/control/device/:deviceCode/attribute_acquisition HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring路径参数

Request Body

字段类型必填说明
deviceCodestring设备SN,必填
keysarray<string>属性标识列表,可空
isAsyncboolean是否异步调用,同步:false,异步:true 同步调用等待设备响应
syncTimeoutinteger同步超时时间秒,默认10秒

Request Example

json
{
  "deviceCode": "DEVICE_CODE",
  "keys": [
    "string"
  ],
  "isAsync": true,
  "syncTimeout": 1626197189
}

Response Data

字段类型说明
deviceCodestring设备SN,必填
codeinteger返回码
messagestring返回消息
outputobject<string, interface>输出参数
outDatastring输出数据原始设备数据,可空
inDatastring输入数据原始设备数据,可空

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "deviceCode": "DEVICE_CODE",
    "code": 1,
    "message": "string",
    "output": {
      "key": {}
    },
    "outData": "string",
    "inData": "string"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

下发设备属性

Request Syntax

http
POST /api/v1/control/device/:deviceCode/attributes HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring路径参数

Request Body

字段类型必填说明
msgIdinteger消息ID,可空
deviceCodestring设备SN,必填
inputobject<string, interface>输入参数
isAsyncboolean是否异步调用,同步:false,异步:true 同步调用等待设备响应
syncTimeoutinteger同步超时时间秒,默认10秒

Request Example

json
{
  "msgId": 1,
  "deviceCode": "DEVICE_CODE",
  "input": {
    "key": {}
  },
  "isAsync": true,
  "syncTimeout": 1626197189
}

Response Data

字段类型说明
msgIdinteger消息ID,可空
deviceCodestring设备SN,必填
codeinteger返回码
messagestring返回消息
outDatastring输出数据原始设备数据,可空
inDatastring输入数据原始设备数据,可空

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "msgId": 1,
    "deviceCode": "DEVICE_CODE",
    "code": 1,
    "message": "string",
    "outData": "string",
    "inData": "string"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

设备通信

下发命令到设备

Request Syntax

http
POST /api/v1/control/device/:deviceCode/command HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring路径参数

Request Body

字段类型必填说明
msgIdinteger消息ID,可空
deviceCodestring设备SN,必填
keystring指令标识,必填
inputobject<string, interface>输入参数
isAsyncboolean是否异步调用,同步:false,异步:true 同步调用等待设备响应
syncTimeoutinteger同步超时时间秒,默认10秒

Request Example

json
{
  "msgId": 1,
  "deviceCode": "DEVICE_CODE",
  "key": "temperature",
  "input": {
    "key": {}
  },
  "isAsync": true,
  "syncTimeout": 1626197189
}

Response Data

字段类型说明
msgIdinteger消息ID,可空
deviceCodestring设备SN,必填
keystring指令标识,必填
codeinteger返回码
messagestring返回消息
outputobject<string, interface>输出参数
outDatastring输出数据原始设备数据,可空
inDatastring输入数据原始设备数据,可空

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "msgId": 1,
    "deviceCode": "DEVICE_CODE",
    "key": "temperature",
    "code": 1,
    "message": "string",
    "output": {
      "key": {}
    },
    "outData": "string",
    "inData": "string"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

读取设备配置信息

Request Syntax

http
GET /api/v1/device/:deviceCode/device_config HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring设备码

Response Data

字段类型说明
idintegerID
deviceCodestring设备码
confGroupKeystring配置分组Key
deviceConfIdinteger设备内配置ID
deviceConfVerinteger设备内配置版本
platDevConfVerinteger平台配置设备版本号(无分组)
platDevConfIdinteger平台配置版本ID(无分组)
platGroupConfVerinteger平台分组配置版本号(有分组)
platGroupConfIdinteger平台分组配置版本ID(有分组)
deviceConfAtstring设备端版本更新时间
tenantIdstring租户ID
createdDeptinteger创建部门
createdByinteger创建者
createdAtstring创建时间
updatedByinteger更新者
updatedAtstring更新时间
deviceConfigContentstring设备配置内容
groupConfigContentstring分组配置内容

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": 1,
    "deviceCode": "DEVICE_CODE",
    "confGroupKey": "string",
    "deviceConfId": 1,
    "deviceConfVer": 1,
    "platDevConfVer": 1,
    "platDevConfId": 1,
    "platGroupConfVer": 1,
    "platGroupConfId": 1,
    "deviceConfAt": "string",
    "tenantId": "string",
    "createdDept": 1
  },
  "error": null,
  "traceId": "TRACE_ID"
}

修改设备配置

Request Syntax

http
PUT /api/v1/device/:deviceCode/device_config HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring路径参数

Request Body

字段类型必填说明
deviceCodestring设备码
configContentstring配置内容(分组配置、设备配置)
fileUrlstring文件地址
filePathstring文件本地路径
fileMd5string文件md5

Request Example

json
{
  "deviceCode": "DEVICE_CODE",
  "configContent": "string",
  "fileUrl": "string",
  "filePath": "string",
  "fileMd5": "string"
}

Response Data

无响应业务字段。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {},
  "error": null,
  "traceId": "TRACE_ID"
}

读取设备消息统计

Request Syntax

http
GET /api/v1/device_statistic/:deviceCode HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring设备码

Query Parameters

参数类型必填说明
timestring统计时间范围,可选值:24h、3d、7d、15d、30d。不传会返回时间参数错误。

Response Data

字段类型说明
timesarray<string>
seriesarray<internal.model.MsgSeries>
series[].typeinteger
series[].namestring
series[].dataarray<integer>
totalarray<integer>

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "times": [
      "string"
    ],
    "series": [
      {
        "type": 1,
        "name": "名称",
        "data": [
          "integer"
        ]
      }
    ],
    "total": [
      1
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

设备告警

读取所有告警消息

Request Syntax

http
GET /api/v1/alarm_logs HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Query Parameters

参数类型必填说明
pageinteger页码
pageSizeinteger每页大小
keywordstring关键字
idinteger日志ID
alarmStatusinteger告警状态:0 正常,1 告警中,2 待定。
alarmLevelinteger告警级别:1 普通告警,2 重要告警,3 紧急告警。
createdAtarray<string>创建时间
deviceCodestring设备码
dsTypestring设备来源类型:device_type 设备类型,device 设备。
dsSourcestring来源标识
alarmRuleIdinteger告警规则ID
alarmRuleNamestring告警规则名称
scanIdinteger扫描ID,结合Sort使用
sortstring排序方式(id_asc:ID升序,id_desc:ID降序)

Response Data

字段类型说明
pageinteger
pageSizeinteger
totalinteger
itemsarray<internal.model.XjAlarmLogsListModel>数据列表
items[].idinteger日志ID
items[].alarmRuleIdinteger告警规则ID
items[].alarmRuleNamestring告警规则名称
items[].alarmRuleDescrstring告警规则描述
items[].deviceCodestring设备码
items[].deviceNamestring设备名称
items[].alarmLevelinteger告警级别:1 普通告警,2 重要告警,3 紧急告警。
items[].alarmStatusinteger告警状态:0 正常,1 告警中,2 待定。
items[].alarmInfostring告警信息
items[].triggerInfostring触发信息
items[].snapshotstring设备快照
items[].maintainInfostring维护信息
items[].maintainTsinteger维护更新时间戳秒
items[].maintainerstring维护信息更新用户
items[].recoverAlarmTypeinteger恢复告警类型
items[].recoverAlarmAtstring恢复告警时间
items[].recoverAlarmRuleIdinteger恢复告警规则ID
items[].recoverAlarmRuleNamestring恢复告警规则名称
items[].recoverTriggerInfostring恢复时触发信息
items[].recoverUserTypeinteger恢复告警用户类型
items[].recoverUserIdinteger恢复告警用户ID
items[].tenantIdstring租户ID
items[].createdDeptinteger创建部门
items[].createdByinteger创建者
items[].createdAtstring创建时间
items[].updatedByinteger更新者
items[].updatedAtstring更新时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "pageSize": 1,
    "total": 1,
    "items": [
      {
        "id": 1,
        "alarmRuleId": 1,
        "alarmRuleName": "名称",
        "alarmRuleDescr": "描述",
        "deviceCode": "DEVICE_CODE"
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

读取告警消息

Request Syntax

http
GET /api/v1/alarm_log/:id/info HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
idinteger日志ID

Response Data

字段类型说明
idinteger日志ID
alarmRuleIdinteger告警规则ID
alarmRuleNamestring告警规则名称
alarmRuleDescrstring告警规则描述
deviceCodestring设备码
deviceNamestring设备名称
alarmLevelinteger告警级别:1 普通告警,2 重要告警,3 紧急告警。
alarmStatusinteger告警状态:0 正常,1 告警中,2 待定。
alarmInfostring告警信息
triggerInfostring触发信息
snapshotstring设备快照
maintainInfostring维护信息
maintainTsinteger维护更新时间戳秒
maintainerstring维护信息更新用户
recoverAlarmTypeinteger恢复告警类型
recoverAlarmAtstring恢复告警时间
recoverAlarmRuleIdinteger恢复告警规则ID
recoverAlarmRuleNamestring恢复告警规则名称
recoverTriggerInfostring恢复时触发信息
recoverUserTypeinteger恢复告警用户类型
recoverUserIdinteger恢复告警用户ID
tenantIdstring租户ID
createdDeptinteger创建部门
createdByinteger创建者
createdAtstring创建时间
updatedByinteger更新者
updatedAtstring更新时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": 1,
    "alarmRuleId": 1,
    "alarmRuleName": "名称",
    "alarmRuleDescr": "描述",
    "deviceCode": "DEVICE_CODE",
    "deviceName": "名称",
    "alarmLevel": 1,
    "alarmStatus": 1,
    "alarmInfo": "string",
    "triggerInfo": "string",
    "snapshot": "string",
    "maintainInfo": "string"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

修改告警历史维护信息

Request Syntax

http
PUT /api/v1/alarm_log/:id/maintain_info HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
idstring路径参数

Request Body

字段类型必填说明
idinteger日志ID
alarmReasonstring告警原因
solutionstring解决方案
remarkstring其他备注
isRecoverboolean是否恢复告警

Request Example

json
{
  "id": 1,
  "alarmReason": "string",
  "solution": "string",
  "remark": "string",
  "isRecover": true
}

Response Data

无响应业务字段。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {},
  "error": null,
  "traceId": "TRACE_ID"
}

读取告警规则列表

Request Syntax

http
GET /api/v1/alarm_rules HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Query Parameters

参数类型必填说明
pageinteger页码
pageSizeinteger每页大小
keywordstring关键字
idinteger规则ID
debugStatusinteger规则调试状态:0 未开启,1 已开启。
dsTypestring设备来源类型:device_type 设备类型,device 设备。
dsSourcestring设备来源。dsType 为 device 时通常为设备码数组;dsType 为 device_type 时通常为设备类型标识数组。Id
triggerTypestring触发类型:attrs_changed 属性变化,inactive 设备不活跃,event_post 事件上报,online 设备在线,offline 设备离线。
createdAtarray<string>创建时间
scanIdinteger扫描ID,结合Sort使用
sortstring排序方式(id_asc:ID升序,id_desc:ID降序)

Response Data

字段类型说明
pageinteger
pageSizeinteger
totalinteger
itemsarray<internal.model.XjAlarmRulesListModel>数据列表
items[].idinteger规则ID
items[].namestring规则名称
items[].descrstring规则描述
items[].dsTypestring设备来源类型:device_type 设备类型,device 设备。
items[].dsSourcestring设备来源。dsType 为 device 时通常为设备码数组;dsType 为 device_type 时通常为设备类型标识数组。
items[].triggerTypestring触发类型:attrs_changed 属性变化,inactive 设备不活跃,event_post 事件上报,online 设备在线,offline 设备离线。
items[].pendingNuminteger重复次数
items[].pendingTimeinteger重复时间(秒)
items[].silentTimeinteger静默时间(秒)
items[].condsstring过滤条件
items[].devicesDisablestring禁用设备
items[].customTopicIdentifierstring自定义数据流标识符
items[].alarmLevelinteger告警级别:1 普通告警,2 重要告警,3 紧急告警。
items[].notificationConfigstring通知配置 JSON。可包含公众号、短信、电话、App 通知、每日通知次数上限、单设备每日通知次数上限等配置。
items[].enabledinteger是否启用:0 未启用,1 已启用。
items[].enableTimeSpansinteger是否启用有效时段:0 未启用,1 已启用。
items[].validTimeSpansstring有效时段配置 JSON。可包含有效时间段、是否允许解除告警、是否允许用户解除告警、是否允许用户禁用规则等配置。
items[].debugStatusinteger规则调试状态:0 未开启,1 已开启。
items[].debugEnableTimeinteger规则调试时间
items[].isAlarminteger是否处于告警中:0 否,1 是。
items[].isRecoverAlarminteger是否为恢复告警规则:0 否,1 是。
items[].recoverAlarmIdsstring恢复告警规则 ID 列表,JSON 数组格式,如 [1,2,3]。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "pageSize": 1,
    "total": 1,
    "items": [
      {
        "id": 1,
        "name": "名称",
        "descr": "描述",
        "dsType": "string",
        "dsSource": "string"
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

读取告警规则信息

Request Syntax

http
GET /api/v1/alarm_rule/:id HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
idinteger规则ID

Response Data

字段类型说明
idinteger规则ID
namestring规则名称
descrstring规则描述
dsTypestring设备来源类型:device_type 设备类型,device 设备。
dsSourcestring设备来源。dsType 为 device 时通常为设备码数组;dsType 为 device_type 时通常为设备类型标识数组。
triggerTypestring触发类型:attrs_changed 属性变化,inactive 设备不活跃,event_post 事件上报,online 设备在线,offline 设备离线。
pendingNuminteger重复次数
pendingTimeinteger重复时间(秒)
silentTimeinteger静默时间(秒)
condsstring过滤条件
devicesDisablestring禁用设备
customTopicIdentifierstring自定义数据流标识符
alarmLevelinteger告警级别:1 普通告警,2 重要告警,3 紧急告警。
notificationConfigstring通知配置 JSON。可包含公众号、短信、电话、App 通知、每日通知次数上限、单设备每日通知次数上限等配置。
enabledinteger是否启用:0 未启用,1 已启用。
enableTimeSpansinteger是否启用有效时段:0 未启用,1 已启用。
validTimeSpansstring有效时段配置 JSON。可包含有效时间段、是否允许解除告警、是否允许用户解除告警、是否允许用户禁用规则等配置。
debugStatusinteger规则调试状态:0 未开启,1 已开启。
debugEnableTimeinteger规则调试时间
isAlarminteger是否处于告警中:0 否,1 是。
isRecoverAlarminteger是否为恢复告警规则:0 否,1 是。
recoverAlarmIdsstring恢复告警规则 ID 列表,JSON 数组格式,如 [1,2,3]。
tenantIdstring租户ID
createdDeptinteger创建部门
createdByinteger创建者
createdAtstring创建时间
updatedByinteger更新者
updatedAtstring更新时间
dsSourceMapobject<string, string>设备信息

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": 1,
    "name": "名称",
    "descr": "描述",
    "dsType": "string",
    "dsSource": "string",
    "triggerType": "string",
    "pendingNum": 1,
    "pendingTime": 1626197189,
    "silentTime": 1626197189,
    "conds": "string",
    "devicesDisable": "string",
    "customTopicIdentifier": "string"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

消息规则

读取规则列表

Request Syntax

http
GET /api/v1/rules HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Query Parameters

参数类型必填说明
pageinteger页码
pageSizeinteger每页大小
keywordstring关键字
idinteger规则ID
dsTypestring设备来源类型:device_type 设备类型,device 设备。
ruleTypestring规则类型
actionTypearray<string>动作类型
actionTypeNamearray<string>动作类型名称
deviceCodestring设备码
enabledinteger是否启用:0 未启用,1 已启用。
debugStatusinteger规则调试状态:0 未开启,1 已开启。
createdAtarray<string>创建时间
scanIdinteger扫描ID,结合Sort使用
sortstring排序方式(id_asc:ID升序,id_desc:ID降序)

Response Data

字段类型说明
pageinteger
pageSizeinteger
totalinteger
itemsarray<internal.model.XjRulesListModel>数据列表
items[].idinteger规则ID
items[].namestring规则名称
items[].descrstring规则描述
items[].ruleTypestring规则类型
items[].actionTypearray<string>动作类型
items[].actionTypeNamearray<string>动作类型名称
items[].dsTypestring设备来源类型:device_type 设备类型,device 设备。
items[].customTopicIdentifierstring自定义数据流标识符
items[].enabledinteger是否启用:0 未启用,1 已启用。
items[].debugStatusinteger规则调试状态:0 未开启,1 已开启。
items[].debugEnableTimeinteger规则调试时间
items[].createdAtstring创建时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "pageSize": 1,
    "total": 1,
    "items": [
      {
        "id": 1,
        "name": "名称",
        "descr": "描述",
        "ruleType": "string",
        "actionType": [
          "string"
        ]
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

读取规则信息

Request Syntax

http
GET /api/v1/rules/:id HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
idinteger规则ID

Response Data

字段类型说明
idinteger规则ID
namestring规则名称
descrstring规则描述
ruleTypestring规则类型
dsTypestring设备来源类型:device_type 设备类型,device 设备。
dsSourcestring设备来源。dsType 为 device 时通常为设备码数组;dsType 为 device_type 时通常为设备类型标识数组。
msgCondsstring过滤条件
devicesDisablestring禁用设备
customTopicIdentifierstring自定义数据流标识符
eventKeystring事件标识
enabledinteger是否启用:0 未启用,1 已启用。
debugStatusinteger规则调试状态:0 未开启,1 已开启。
debugEnableTimeinteger规则调试时间
tenantIdstring租户ID
createdDeptinteger创建部门
createdByinteger创建者
createdAtstring创建时间
updatedByinteger更新者
updatedAtstring更新时间
dsSourceMapobject<string, string>设备信息
actionsarray<internal.model.XjRuleActionsListModelForRules>规则动作列表
actions[].idinteger动作ID
actions[].ruleIdinteger规则ID
actions[].typestring动作类型
actions[].namestring动作名称
actions[].optionsstring动作配置
actions[].orderNuminteger排序
actions[].createdAtstring创建时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": 1,
    "name": "名称",
    "descr": "描述",
    "ruleType": "string",
    "dsType": "string",
    "dsSource": "string",
    "msgConds": "string",
    "devicesDisable": "string",
    "customTopicIdentifier": "string",
    "eventKey": "string",
    "enabled": 1,
    "debugStatus": 1
  },
  "error": null,
  "traceId": "TRACE_ID"
}

设备上下线日志

读取设备上下线日志列表

Request Syntax

http
GET /api/v1/device/:deviceCode/online_logs HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring设备码

Query Parameters

参数类型必填说明
pageinteger页码
pageSizeinteger每页大小
keywordstring关键字
idintegerID
createdAtarray<string>创建时间

Response Data

字段类型说明
pageinteger
pageSizeinteger
totalinteger
itemsarray<internal.model.XjDeviceOnlineLogsListModel>数据列表
items[].idintegerID
items[].deviceCodestring设备码
items[].logTypeinteger日志类型:14 上线,15 下线。
items[].logReasonstring下线原因
items[].contentstring日志内容
items[].tenantIdstring租户ID
items[].createdAtstring创建时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "pageSize": 1,
    "total": 1,
    "items": [
      {
        "id": 1,
        "deviceCode": "DEVICE_CODE",
        "logType": 1,
        "logReason": "string",
        "content": "string"
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

服务信息

服务信息

Request Syntax

http
GET /api/v1/info HTTP/1.1
Content-Type: application/json

Response Data

字段类型说明
typestring
namestring
titlestring
descriptionstring
versionstring
buildstring
commitstring
dataobject<string, interface>

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "type": "string",
    "name": "名称",
    "title": "string",
    "description": "描述",
    "version": "string",
    "build": "string",
    "commit": "string",
    "data": {
      "key": {}
    }
  },
  "error": null,
  "traceId": "TRACE_ID"
}

全局定义

通用响应格式

枚举取值
设备通信方式 connProtocol1 WiFi,2 以太网,3 4G,4 5G,5 NB-IoT,6 RS485,7 RS232,8 RS422,9 LoRa,10 Zigbee,11 BLE,99 其他
设备接入类型 connType1 直连设备,2 子设备,3 网关设备
设备接入协议 msgProtocol1 内部标准,2 Modbus RTU 透传,3 Modbus TCP 透传,99 其他
设备在线状态 onlineStatus1 在线,2 离线
设备告警状态 alarmStatus1 未告警,2 告警中,3 普通告警,4 重要告警,5 紧急告警
设备活跃状态 activeStatus1 活跃,2 5 分钟内活跃,3 1 小时内活跃,4 1 天内活跃,20 不活跃,21 不活跃超过 1 天,22 不活跃超过 3 天,23 不活跃超过 7 天,30 从未活跃
告警级别 alarmLevel1 普通告警,2 重要告警,3 紧急告警
告警规则触发类型 triggerTypeattrs_changed 属性变化,inactive 设备不活跃,event_post 事件上报,online 设备在线,offline 设备离线
设备来源类型 dsTypedevice_type 设备类型,device 设备
数据模型属性类型 attrTypereport 设备上报,push 云端下发,share 设备云端共享,cloud 云端私有
数据模型数据类型 dataTypeinteger 整型,decimal 小数,string 字符串,bool 布尔型,enum 枚举型,array 数组型,object 对象型,map_point 地理坐标,map_circle 地理圆形围栏,map_polygon 地理多边形围栏,coords_point 平面坐标,coords_3d_point 三维坐标,daily_timer 每日定时器,daily_timer_range 每日定时区间
消息日志类型 logType1 属性上报,2 属性上报回复,3 事件上报,4 事件上报回复,5 属性设置,6 属性设置回复,7 功能调用,8 功能调用回复,9 连接事件,10 断开连接事件,11 心跳,12 设备获取平台属性,13 设备获取平台属性回复,14 上线,15 下线,16 属性采集,17 属性采集回复,18 批量上报,19 批量上报回复,20 自定义上报,21 自定义下发回复,22 获取期望值,23 获取期望值回复,24 清除期望值,25 清除期望值回复,26 文件上传,27 文件上传回复