Get Asset Unformatted Data

获取指定设备的指定测点(支持多设备单侧点)在某段时间内的非标准原始数据。

操作权限

需授权的资源 所需操作权限
资产 Read

有关各资源及其对应的权限,参考 策略,角色,与权限>>

请求格式

POST https://{apigw-address}/tsdb-service/v2.1/unformatted

请求参数(URI)

名称 位置(Path/Query) 必需/可选 数据类型 描述
orgId Query 必需 String 资产所属的组织ID。如何获取orgId信息>>

请求参数(Body)

名称 必需/可选 数据类型 描述
assetIds 必需 String 资产ID,支持查询多个资产,多个资产ID之间用英文逗号隔开。如何获取Asset ID信息>>
pointIds 必需 String 资产度量,仅支持单测点查询。如何获取pointId信息>>
startTime 必需 String 采样数据开始时间,支持local时间和UTC时间。local时间的格式为 YYYY-MM-DD HH:MM:SS。当格式为local时间时,使用设备所在地的当地时间进行查询。UTC时间格式需要加入时区信息,例如:2019-06-01T00:00:00+08:00。当格式为UTC时间时,对所有资产按照统一的开始时间和结束时间进行查询。
endTime 必需 String 采样数据结束时间,格式必须与开始时间保持一致。
pageSize 可选 Integer 单次查询返回记录条数的上限,默认为1000。
localTimeAccuracy 可选 Boolean 指定查询结果是否包含毫秒级结果。true 表示需要毫秒格式,false 表示不需要毫秒格式。
localTimeFormat 可选 Integer 指定返回数据的local时间是否包含设备时区信息。0:不包含设备时区信息;1:包含设备时区信息;默认值为0。
itemFormat 可选 Integer 指定返回结果中测点数据的显示格式。可选值为0,1,2,默认值为0。对每种显示格式的详细介绍,参见 Item Format 示例>>
orderBy 可选 String 指定返回结果按照某字段排序,目前支持按照``timestamp``字段排序。timestamp asc``表示按字段升序排列;``timestamp desc``表示按字段倒序排列;默认为``timestamp asc

响应参数

名称 数据类型 描述
data List<JSONObject> 资产数据列表。单设备单点的返回数据按时间升序排列。详见 items

items

示例

{
  "localtime": "2021-10-18 00:00:00.000",
  "assetId": "yourAssetId",
  "yourPointId": "0.1",
  "timestamp": 1634486400000
}

参数

名称 数据类型 描述
assetId String 资产ID。
timestamp Long 数据时间戳,UNIX时间,精确到秒。
pointId Double 此参数是变量,在返回数据中显示为传入测点的标识符与查询到的测点数据。
localtime String 数据本地时间标记,精确到秒。返回结果是否包含设备时区信息,由 localTimeFormat 参数指定。

错误码

有关错误码的描述,参见 通用错误码

示例 1

请求示例

Local时间格式:

url: https://{apigw-address}/tsdb-service/v2.1/unformatted?orgId=yourOrgId

method: POST

Content-Type: application/json

requestBody:
{
  "assetIds": "YourAssetIds",
  "pointIds": "YourPointIds",
  "startTime": "2020-04-20 00:00:00",
  "endTime": "2020-04-21 00:00:00",
  "pageSize": 10,
  "localTimeAccuracy": true,
  "localTimeFormat": 1,
  "itemFormat": 0,
  "orderBy": "timestamp asc"
}

返回示例

{
  "code": 0,
  "msg": "OK",
  "submsg": null,
  "data": {
    "items": [
      {
        "assetId": "yourAssetId",
        "timestamp": 1587312000000,
        "yourPointId": 1.1236,
        "localtime": "2020-04-20T00:00:00.000+08:00"
      },
      {
        "assetId": "yourAssetId",
        "timestamp": 1587312003000,
        "yourPointId": 1.1236,
        "localtime": "2020-04-20T00:00:03.000+08:00"
      }
    ]
  }
}

示例 2

请求示例

UTC时间格式:

url: https://{apigw-address}/tsdb-service/v2.1/unformatted?orgId=yourOrgId

method: POST

Content-Type: application/json

requestBody:
{
  "assetIds": "yourAssetIds",
  "pointIds": "yourPointId",
  "startTime": "2020-04-20T00:00:00+08:00",
  "endTime": "2020-04-21T00:00:00+08:00",
  "pageSize": 10,
  "localTimeAccuracy": false,
  "localTimeFormat": 0,
  "itemFormat": 0,
  "orderBy": "timestamp asc"
}

返回示例

{
  "code": 0,
  "msg": "OK",
  "submsg": null,
  "data": {
    "items": [
      {
        "assetId": "yourAssetId",
        "timestamp": 1587312000000,
        "yourPointId": 1.1236,
        "localtime": "2020-04-20 00:00:00"
      },
      {
        "assetId": "yourAssetId",
        "timestamp": 1587312003000,
        "yourPointId": 1.1236,
        "localtime": "2020-04-20 00:00:03"
      }
    ]
  }
}

Java SDK调用示例

import com.alibaba.fastjson.JSONObject;
import com.envision.apim.poseidon.config.PConfig;
import com.envision.apim.poseidon.core.Poseidon;
import com.envision.apim.poseidon.request.PoseidonRequest;

public class GetAssetUnformattedData {
     private static final String API_GATEWAY_URL = "https://{apigw-address}";

     private static class Request extends PoseidonRequest {

          public void setBodyParams(String key, Object value) {
               bodyParams().put(key, value);
          }

          public void setMethod(String method) {
               this.method = method;
          }

          private String method;

          @Override
          public String baseUri() {
               return "";
          }

          @Override
          public String method() {
               return method;
          }
     }

     public static void main(String[] args) {
          //1.在EnOS管理门户的左边导航栏中点击应用注册。
          //2.点击需调用API的应用,查看基本信息中的AccessKey和SecretKey
          Poseidon poseidon = Poseidon.config(
                  PConfig.init()
                          .appKey("AccessKey of your APP")
                          .appSecret("SecretKey of your APP")
          ).method("POST").header("Content-Type", "application/json");
          Request request = new Request();
          request.setBodyParams("assetIds", "yourAssetIds");
          request.setBodyParams("pointIds", "yourPointIds");
          request.setBodyParams("startTime", "2021-09-01 00:00:00");
          request.setBodyParams("endTime", "2021-09-30 00:00:00");
          request.setBodyParams("pageSize", 10);
          request.setBodyParams("localTimeAccuracy", false);
          request.setBodyParams("localTimeFormat", 0);
          request.setBodyParams("itemFormat", 0);
          request.setBodyParams("orderBy", "timestamp asc");

          JSONObject response = poseidon
                  .url(API_GATEWAY_URL + "/tsdb-service/v2.1/unformatted")
                  .queryParam("orgId", "yourOrgId")
                  .getResponse(request, JSONObject.class);
          System.out.println(response);
     }
}