菜单
HTTP数据接口 > API Reference > 数据累计信息接口
数据累计信息接口 最近更新时间:2022-08-29 16:14:14

# 接口描述

本接口为设备历史数据累计值接口,适用于设备雨量和流量累计值计算。
通过调用此接口可以获得设备一段时间内,从开始时间往后计算,最多31天的累计值。

# 接口调用

  •       GET /api/data/dataSumRange?placeId=<placeId>&st=<st>&et=<et> HTTP/1.1
    Host: dev.thuwater.com
    X-TH-TOKEN: 26b0e5bfcbc.214ce96c1f7c9f0a33549b81087579b38b6a8.e9ba17523a25d766
    
  •       /api/data/dataSumRange:
        get:
          tags:
            - 设备历史数据累计值
          summary: 设备历史数据累计值接口
          description: 设备历史数据累计值接口,查询区间有限制:从开始时间往后计算,最多31天。
          parameters:
            - name: X-TH-TOKEN
              in: header
              description: 通过登陆接口获取的token
              required: true
              schema:
                type: string
            - name: placeId
              in: query
              description: 安装点ID
              required: true
              schema:
                type: integer
            - name: st
              in: query
              description: 开始时间 格式 yyyy-MM-dd HH:mm:ss
              required: true
              schema:
                type: string
                format: dateTime
            - name: et
              in: query
              description: 结束时间 格式 yyyy-MM-dd HH:mm:ss
              required: true
              schema:
                type: string
                format: dateTime
            - name: type
              in: query
              description: 累计值计算维度,1-按天统计,2-按小时统计
              required: true
              schema:
                type: integer
  •       var request = require("request");
    
    var options = {
      method: 'GET',
      url: 'https://dev.thuwater.com/api/data/dataSumRange',
      "qs": {
        placeId: 1111,
        st: '2020-08-10 00:00:00',
        et: '2020-08-10 03:00:00',
        type: 1
      },
      headers: {
        'Host': 'dev.thuwater.com',
        'X-TH-TOKEN': '26b0e5bfcbc.214ce96c1f7c9f0a33549b81087579b38b6a8.e9ba17523a25d766'
      }
    };
    
    request(options, function (error, response, body) {
      if (error) throw new Error(error);
      console.log(body);
    });
  •       OkHttpClient client = new OkHttpClient();
    HttpUrl url = HttpUrl.parse("https://dev.thuwater.com/api/data/dataSumRange")
                         .newBuilder()
                         .addQueryParameter("placeId", 1111)
                         .addQueryParameter("st", "2020-08-10 00:00:00")
                         .addQueryParameter("et", "2020-08-10 03:00:00")
                         .addQueryParameter("type", 1)
                         .build();
    
    Request request = new Request.Builder()
      .url(url)
      .get()
      .addHeader("X-TH-TOKEN", "26b0e5bfcbc.214ce96c1f7c9f0a33549b81087579b38b6a8.e9ba17523a25d766")
      .build();
    
    Response response = client.newCall(request).execute();

# 调用参数

参数名称必填说明
X-TH-TOKEN通过登陆接口获取的token
placeId安装点ID
st开始时间 格式 yyyy-MM-dd HH:mm:ss
et结束时间 格式 yyyy-MM-dd HH:mm:ss
type累计值计算维度,1-按天统计,2-按小时统计

# 接口响应

  •       HTTP/1.1 200 OK
    Content-Type: application/json
    
    [
      {
        "dateTime" : "2020-08-10 00:00:00", // 数据时间
        "dataSum" : "xxxx" // 累计值
      },
      {
        "dateTime" : "2020-08-10 01:00:00", // 数据时间
        "dataSum" : "xxxx" // 累计值
      },
      {
        "dateTime" : "2020-08-10 02:00:00", // 数据时间
        "dataSum" : "xxxx" // 累计值
      }
    ]

# 响应参数

参数名称说明
httpcode200-正常,401-无权限,500-其他错误。
dateTime数据时间
dataSum累计值

查询区间有限制:从开始时间往后计算,最多31天。
当无数据的时候返回:[ ]