跳到主要内容

DataCollector API接口

可以基于该接口调用 智慧物流系统 中的数据采集模块,查询采集点位列表、设备列表以及采集点位的实时缓存值。

基础信息

Base URL: http://logimaster-api-base-url:port/api/data-collector

数据传输对象(DTO)

PagedResultDto

分页列表返回对象。

{
"totalCount": "number",
"items": "T[]"
}

PointGetListInput

采集点位列表查询参数。

{
"id": "string (Guid?)",
"name": "string",
"address": "string",
"filter": "string",
"deviceIds": "string[] (Guid[])",
"sorting": "string",
"skipCount": "number",
"maxResultCount": "number"
}

字段说明:

  • id: 按点位ID精确查询。
  • name: 按点位名称模糊查询。
  • address: 按点位地址模糊查询。
  • filter: 通用关键字,匹配点位名称、点位地址或设备名称。
  • deviceIds: 按设备ID集合过滤。
  • sorting: 排序字段,例如 name ascaddress desc
  • skipCount: 跳过的数据数量,常用于分页。
  • maxResultCount: 返回的数据数量,常用于分页。

PointDto

采集点位返回对象。

{
"id": "string (Guid)",
"name": "string",
"address": "string",
"dataType": "DataType枚举",
"readWriteType": "ReadWriteType枚举",
"length": "number (ushort)",
"description": "string",
"deviceId": "string (Guid)",
"deviceName": "string",
"pointResult": "CollectionPointResult?",
"creationTime": "DateTime",
"lastModificationTime": "DateTime?",
"creatorId": "Guid?",
"lastModifierId": "Guid?"
}

CollectionPointResult

采集点位读取结果。该对象来自点位缓存,用于表示最近一次读取状态和值。

{
"id": "string (Guid)",
"value": "any",
"valueString": "string",
"errorMessage": "string",
"isSuccess": "boolean",
"timeStamp": "DateTime"
}

DataType

采集点位数据类型枚举。

Bool
Int16
UInt16
Int32
UInt32
Float
Double
String

ReadWriteType

采集点位读写类型枚举。

ReadOnly
ReadWrite

DeviceDto

采集设备返回对象。点位列表会通过 deviceIddeviceName 关联到设备。

{
"id": "string (Guid)",
"name": "string",
"ipAddress": "string",
"port": "number",
"driverFullName": "string",
"enableBulkReading": "boolean",
"pollInterval": "number",
"active": "boolean",
"creationTime": "DateTime",
"lastModificationTime": "DateTime?",
"creatorId": "Guid?",
"lastModifierId": "Guid?"
}

API 端点

1. 获取采集点位列表

GET /points

获取采集点位分页列表。返回结果中每个点位会包含最近一次缓存读取结果 pointResult

参数

  • id (查询参数): 点位ID,类型为Guid,可选。
  • name (查询参数): 点位名称,支持模糊匹配,可选。
  • address (查询参数): 点位地址,支持模糊匹配,可选。
  • filter (查询参数): 通用关键字,匹配点位名称、点位地址或设备名称,可选。
  • deviceIds (查询参数): 设备ID集合,可重复传入,例如 deviceIds=id1&deviceIds=id2
  • sorting (查询参数): 排序表达式,可选。
  • skipCount (查询参数): 跳过数量,类型为number。
  • maxResultCount (查询参数): 返回数量,类型为number。

响应

  • 200 OK: 返回采集点位分页结果
    {
    "totalCount": 1,
    "items": [
    {
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "name": "入口光电",
    "address": "x=2;0",
    "dataType": 0,
    "readWriteType": 0,
    "length": 1,
    "description": "入库口光电检测",
    "deviceId": "223e4567-e89b-12d3-a456-426614174000",
    "deviceName": "USR-M050-01",
    "pointResult": {
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "value": true,
    "valueString": "True",
    "errorMessage": "",
    "isSuccess": true,
    "timeStamp": "2026-04-30T10:30:00"
    },
    "creationTime": "2026-04-30T09:00:00",
    "lastModificationTime": null,
    "creatorId": null,
    "lastModifierId": null
    }
    ]
    }

示例

GET /api/data-collector/points?filter=光电&skipCount=0&maxResultCount=20&sorting=name%20asc

按设备过滤:

GET /api/data-collector/points?deviceIds=223e4567-e89b-12d3-a456-426614174000&skipCount=0&maxResultCount=50

2. 获取采集设备列表

GET /devices

获取采集设备分页列表。该接口用于查询点位所属设备、驱动、IP、端口和启用状态。

参数

  • skipCount (查询参数): 跳过数量,类型为number。
  • maxResultCount (查询参数): 返回数量,类型为number。

响应

  • 200 OK: 返回采集设备分页结果
    {
    "totalCount": 1,
    "items": [
    {
    "id": "223e4567-e89b-12d3-a456-426614174000",
    "name": "USR-M050-01",
    "ipAddress": "192.168.1.100",
    "port": 502,
    "driverFullName": "Tgone.LogiMaster.DataCollection.ModbusTcp.ModbusTcpDriver",
    "enableBulkReading": true,
    "pollInterval": 1000,
    "active": true,
    "creationTime": "2026-04-30T09:00:00",
    "lastModificationTime": null,
    "creatorId": null,
    "lastModifierId": null
    }
    ]
    }

示例

GET /api/data-collector/devices?skipCount=0&maxResultCount=20

错误响应

所有API在出错时会返回标准错误格式:

{
"error": {
"code": "错误代码",
"message": "错误描述",
"details": "详细错误信息"
}
}

常见错误状态码:

  • 400 Bad Request: 请求参数错误。
  • 401 Unauthorized: 未登录或访问令牌无效。
  • 403 Forbidden: 当前用户没有访问权限。
  • 500 Internal Server Error: 服务器内部错误。