菜单
HTTP控制接口 > API Reference > 采样器控制接口
采样器控制接口 最近更新时间:2022-08-29 16:14:14

# 接口描述

本接口为采样器控制接口。
通过调用此接口可以对采样器进行采样控制,包括立即采样、预约采样和积分采样以及清除采样记录和清除状态标志

采样控制功能请谨慎使用

# 接口调用

# 立即采样接口

立即采样接口包括立即采样、清除采样记录和清除状态标志

  •       post /api/equips/{equipId}/samplerAction HTTP/1.1
    Host: dev.thuwater.com
    X-TH-TOKEN: 26b0e5bfcbc.214ce96c1f7c9f0a33549b81087579b38b6a8.e9ba17523a25d766
    Content-Type: application/x-www-form-urlencoded
    
    action=sampling
  •       var request = require("request");
    
    var options = {
      method: 'POST',
      url: 'https://dev.thuwater.com/api/equips/samplerAction',
    
      headers: {
        'Host': 'dev.thuwater.com',
        'X-TH-TOKEN': '26b0e5bfcbc.214ce96c1f7c9f0a33549b81087579b38b6a8.e9ba17523a25d766',
        'Content-Type': 'application/x-www-form-urlencoded'
      }
       form: {
         'action': 'sampling'
       }
    };
    
    request(options, function (error, response, body) {
      if (error) throw new Error(error);
      console.log(body);
    });
    
  •       OkHttpClient client = new OkHttpClient().newBuilder()
      .build();
    MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
    RequestBody body = RequestBody.create(mediaType, "action=sampling");
    Request request = new Request.Builder()
      .url("https://dev.thuwater.com/api/equips/samplerAction")
      .method("POST", body)
      .addHeader("X-TH-TOKEN", "26b0e5bfcbc.214ce96c1f7c9f0a33549b81087579b38b6a8.e9ba17523a25d766")
      .addHeader("Content-Type", "application/x-www-form-urlencoded")
      .build();
    
    Response response = client.newCall(request).execute();

# 调用参数

action命令类型:
1、sampling 设置立即采样;
2、clearrecord 清除采样记录;
3、clear 清除状态标志。

参数名称必填说明
X-TH-TOKEN通过登陆接口获取的token
equipId设备ID 放入请求路径
action命令类型 sampling-设置立即采样; clearrecord-清除采样记录;clear-清除状态标志

# 接口响应

  •       HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
        "result": true,
        "msg": ""
    }

# 响应参数

参数名称说明
httpcode200-正常,401-无权限,500-其他错误。
result返回处理结果
msg返回信息

# 预约采样接口

采样数据时间列表最多四组

# 预约采样

  •       Post /api/equips/{equipId}/addSamplerSchedule HTTP/1.1
    Host: dev.thuwater.com
    X-TH-TOKEN: eyJhbGciOiJIUzM4NCJ9
    Content-Type: application/json
    {
        "integralInfoList": [
            {
                "startTime": "2022-01-11 00:00:00"
            },
            {
                "startTime": "2022-01-12 00:00:00"
            },
            {
                "startTime": "2022-01-13 00:00:00"
            },
            {
                "startTime": "2022-01-14 00:00:00"
            }
        ]
    }
  •       var request = require('request');
    var options = {
      'method': 'Post',
      'url': 'https://dev.thuwater.com/api/equips/{equipId}/addSamplerSchedule',
      'headers': {
        'X-TH-TOKEN': 'eyJhbGciOiJIUzM4NCJ9',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        "integralInfoList": [
          {
            "startTime": "2022-01-11 00:00:00"
          },
          {
            "startTime": "2022-01-12 00:00:00"
          },
          {
            "startTime": "2022-01-13 00:00:00"
          },
          {
            "startTime": "2022-01-14 00:00:00"
          }
        ]
      })
    
    };
    request(options, function (error, response) {
      if (error) throw new Error(error);
      console.log(response.body);
    });
    
    
  •       OkHttpClient client = new OkHttpClient().newBuilder()
      .build();
    MediaType mediaType = MediaType.parse("application/json");
    RequestBody body = RequestBody.create(mediaType, "{"integralInfoList": [{ "startTime": "2022-01-11 17:00:00"},{ "startTime": "2022-01-12 00:00:00"},{ "startTime": "2022-01-13 00:00:00"},{ "startTime": "2022-01-14 00:00:00"}]}");
    Request request = new Request.Builder()
      .url("https://dev.thuwater.com/api/equips/{equipId}/addSamplerSchedule")
      .method("Post", body)
      .addHeader("X-TH-TOKEN", "eyJhbGciOiJIUzM4NCJ9")
      .addHeader("Content-Type", "application/json")
      .build();
    Response response = client.newCall(request).execute();

# 调用参数

参数名称类型必填说明
X-TH-TOKEN字符串通过登陆接口获取的token
equipId整形设备ID 放入请求路径
integralInfoListintegralInfo数组integralInfo任务详情list 最少1组最多4组
integralInfo类型必填说明
startTime字符串2022-01-11 00:00:00的格式时间

# 接口响应

  •       HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
        "result": true,
        "msg": ""
    }

# 响应参数

参数名称说明
httpcode200-正常,401-无权限,500-其他错误。
result返回处理结果
msg返回信息

# 积分采样接口

# 积分采样

采样数据时间列表最多四组,积分采样时间不可重叠

  •       Post /api/equips/{equipId}/addSamplerIntegral HTTP/1.1
    Host: dev.thuwater.com
    X-TH-TOKEN: eyJhbGciOiJIUzM4NCJ9
    Content-Type: application/json
    
    {
        "integralInfoList": [
            {
                "startTime": "2022-01-11 00:00:00",
                "period": 60,
                "perSum": 100,
                "samplerCount": 5
            },
            {
                "startTime": "2022-01-12 00:00:00",
                "period": 60,
                "perSum": 100,
                "samplerCount": 5
            },
            {
                "startTime": "2022-01-13 00:00:00",
                "period": 60,
                "perSum": 100,
                "samplerCount": 5
            },
            {
                "startTime": "2022-01-14 00:00:00",
                "period": 60,
                "perSum": 100,
                "samplerCount": 5
            }
        ]
    }
  •       var request = require('request');
    var options = {
      'method': 'Post',
      'url': 'https://dev.thuwater.com/api/equips/{equipId}/addSamplerIntegral',
      'headers': {
        'X-TH-TOKEN': 'eyJhbGciOiJIUzM4NCJ9',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        "integralInfoList": [
          {
            "startTime": "2022-01-11 00:00:00",
            "period": 60,
            "perSum": 100,
            "samplerCount": 5
          },
          {
            "startTime": "2022-01-12 00:00:00",
            "period": 60,
            "perSum": 100,
            "samplerCount": 5
          },
          {
            "startTime": "2022-01-13 00:00:00",
            "period": 60,
            "perSum": 100,
            "samplerCount": 5
          },
          {
            "startTime": "2022-01-14 00:00:00",
            "period": 60,
            "perSum": 100,
            "samplerCount": 5
          }
        ]
      })
    
    };
    request(options, function (error, response) {
      if (error) throw new Error(error);
      console.log(response.body);
    });
    
    
  •       OkHttpClient client = new OkHttpClient().newBuilder()
      .build();
    MediaType mediaType = MediaType.parse("application/json");
    RequestBody body = RequestBody.create(mediaType, "{"integralInfoList": [{ "startTime": "2022-01-11 00:00:00",  "period": 60,  "perSum": 100,  "samplerCount": 5},{ "startTime": "2022-01-12 00:00:00",  "period": 60,  "perSum": 100,  "samplerCount": 5},{ "startTime": "2022-01-13 00:00:00",  "period": 60,  "perSum": 100,  "samplerCount": 5},{ "startTime": "2022-01-14 00:00:00",  "period": 60,  "perSum": 100,  "samplerCount": 5}]}");
    Request request = new Request.Builder()
      .url("https://dev.thuwater.com/api/equips/{equipId}/addSamplerIntegral")
      .method("Post", body)
      .addHeader("X-TH-TOKEN", "eyJhbGciOiJIUzM4NCJ9")
      .addHeader("Content-Type", "application/json")
      .build();
    Response response = client.newCall(request).execute();

# 调用参数

参数名称类型必填说明
X-TH-TOKEN字符串通过登陆接口获取的token
equipId整形设备ID 放入请求路径
integralInfoListintegralInfo数组integralInfo任务详情list 最少1组最多4组
integralInfo类型必填说明
startTime字符串2022-01-11 00:00:00的格式时间
period整形间隔 60-255 采样间隔,必须大于等于60分钟 积分采样参数
perSum整形每次采样量 0-255 积分采样参数
samplerCount整形采样次数 每次采样数量(ml) * 采样次数,必须小于等于500 积分采样参数

# 接口响应

  •       HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
        "result": true,
        "msg": ""
    }

# 响应参数

参数名称说明
httpcode200-正常,401-无权限,500-其他错误。
result返回处理结果
msg返回信息