Get Asset DI Data Duration¶
获取指定设备的指定测点在一段时间内不同状态(DI)的时长统计。
操作权限¶
需授权的资源 |
所需操作权限 |
---|---|
资产 |
Read |
有关各资源及其对应的权限,参考 策略,角色,与权限>>
请求格式¶
POST https://{apigw-address}/tsdb-service/v2.1/di/duration
请求参数(URI)¶
名称 |
位置(Path/Query) |
必需/可选 |
数据类型 |
描述 |
---|---|---|---|---|
orgId |
Query |
必需 |
String |
资产所属的组织ID。如何获取orgId信息>> |
请求参数(Body)¶
名称 |
必需/可选 |
数据类型 |
描述 |
---|---|---|---|
modelId |
可选 |
String |
资产所属模型ID。如何获取modelId信息>> |
assetIds |
必需 |
String |
资产ID,支持查询多个资产,多个资产ID之间用英文逗号隔开。如何获取Asset ID信息>> |
pointIds |
必需 |
String |
资产测点,支持多测点查询,各个测点间用逗号隔开。如何获取pointId信息>> |
startTime |
必需 |
String |
采样数据开始时间,支持local时间和UTC时间。local时间的格式为 |
endTime |
必需 |
String |
采样数据结束时间,格式必须与开始时间保持一致。 |
status |
可选 |
String |
对包含多个状态时长统计的结果进行筛选,例如只需要状态0结果,可输入 0 。支持对多个状态进行筛选,多个状态之间用英文逗号隔开。 |
ifWithUnknown |
可选 |
Boolean |
某段时间内的状态无法确认,默认返回为“Unknown”状态,参数标识是否包含此状态。默认为true,即包含。 |
响应参数¶
名称 |
数据类型 |
描述 |
---|---|---|
data |
List<JSONObject> |
资产数据列表。单设备单点的返回数据按时间升序排列。详见 items |
items¶
示例¶
{
"scanEndTimestamp": 1569859800000,
"pointId": "yourPointId",
"assetId": "yourAssetId",
"durations": [
{
"duration": 60000,
"status": 0
},
{
"duration": 60000,
"status": 1
}
]
}
参数¶
名称 |
数据类型 |
描述 |
---|---|---|
scanEndTimestamp |
Long |
此参数标志时长统计所需要扫描的最后一条数据对应时间戳。一次时长统计扫描的数据不得超过640000条,当在用户期望的起止时间内扫描到的数据超过640000条时,停止扫描,此参数返回扫描到的最后一个点的时间戳,表示此时间戳后的数据未进行统计。 |
assetId |
String |
资产ID |
pointId |
String |
测点标识符。 |
durations |
List<JSONObject> |
各个状态的时长统计。 |
status |
Integer |
对应设备测点的值。 |
duration |
Integer |
上述设备测点的值在用户选择的开始时间到 |
错误码¶
有关错误码的描述,参见 通用错误码。
示例 1¶
请求示例¶
ifWithUnknown
为true:
url: https://{apigw-address}/tsdb-service/v2.1/di/duration?orgId=yourOrgId
method: POST
Content-Type: application/json
requestBody:
{
"assetIds": "yourAssetId1,yourAssetId2",
"pointIds": "yourPointIds",
"startTime": "2020-03-01 00:00:00",
"endTime": "2020-03-02 00:00:00",
"status": "0,1",
"ifWithUnknown": true,
"localTimeFormat": 1,
"itemFormat": 0
}
返回示例¶
{
"code": 0,
"msg": "OK",
"submsg": null,
"data": {
"items": [
{
"scanEndTimestamp": 1583082072000,
"pointId": "yourPointId",
"assetId": "yourAssetId1",
"durations": [
{
"duration": 60000,
"status": 0
},
{
"duration": 60000,
"status": 1
},
{
"duration": 180000,
"status": "Unknown"
}
]
},
{
"scanEndTimestamp": 1583082072000,
"pointId": "yourPointId",
"assetId": "yourAssetId2",
"durations": [
{
"duration": 60000,
"status": 0
},
{
"duration": 60000,
"status": 1
},
{
"duration": 180000,
"status": "Unknown"
}
]
}
]
}
}
示例 2¶
请求示例¶
ifWithUnknown
为false:
url: https://{apigw-address}/tsdb-service/v2.1/di/duration?orgId=yourOrgId
method: POST
Content-Type: application/json
requestBody:
{
"assetIds": "yourAssetId1,yourAssetId2",
"pointIds": "yourPointIds",
"startTime": "2020-03-01 00:00:00",
"endTime": "2020-03-02 00:00:00",
"status": "0,1",
"ifWithUnknown": false,
"localTimeFormat": 1,
"itemFormat": 0
}
返回示例¶
{
"code": 0,
"msg": "OK",
"submsg": null,
"data": {
"items": [
{
"scanEndTimestamp": 1583082072000,
"durations": [
{
"duration": 60000,
"status": 0
},
{
"duration": 60000,
"status": 1
}
],
"pointId": "yourPointId",
"assetId": "yourAssetId1"
},
{
"scanEndTimestamp": 1583082072000,
"durations": [
{
"duration": 60000,
"status": 0
},
{
"duration": 60000,
"status": 1
}
],
"pointId": "yourPointId",
"assetId": "yourAssetId2"
}
]
}
}
示例 3¶
请求示例¶
进行status
筛选:
备注
进行`status`筛选后,返回结果不会有Unknown的状态。
url: https://{apigw-address}/tsdb-service/v2.1/di/duration?orgId=yourOrgId
method: POST
Content-Type: application/json
requestBody:
{
"assetIds": "yourAssetId1,yourAssetId2",
"pointIds": "yourPointIds",
"startTime": "2020-03-01 00:00:00",
"endTime": "2020-03-02 00:00:00",
"status": "1",
"localTimeFormat": 1,
"itemFormat": 0
}
返回示例¶
{
"code": 0,
"msg": "OK",
"submsg": null,
"data": {
"items": [
{
"scanEndTimestamp": 1583082072000,
"durations": [
{
"duration": 60000,
"status": 1
}
],
"pointId": "yourPointId",
"assetId": "yourAssetId1"
},
{
"scanEndTimestamp": 1583082072000,
"durations": [
{
"duration": 60000,
"status": 1
}
],
"pointId": "yourPointId",
"assetId": "yourAssetId2"
}
]
}
}
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 GetAssetDIDataDuration {
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("modelId", "yourModelId");
request.setBodyParams("assetIds", "yourAssetId1,yourAssetId2");
request.setBodyParams("pointIds", "yourPointIds");
request.setBodyParams("startTime", "2020-03-01 00:00:00");
request.setBodyParams("endTime", "2020-03-02 01:01:12");
request.setBodyParams("status", "0,1");
request.setBodyParams("ifWithUnknown", false);
request.setBodyParams("localTimeFormat", 1);
request.setBodyParams("itemFormat", 0);
JSONObject response = poseidon
.url(API_Gateway_URL + "/tsdb-service/v2.1/di/duration")
.queryParam("orgId", "yourOrgId")
.getResponse(request, JSONObject.class);
System.out.println(response);
}
}