import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RecordIOTInstantVO, RecordIOTInstantForm, RecordIOTInstantQuery } from '@/api/ems/record/types';

/**
 * 查询IOT即时数据列表
 */
export function listRecordIOTInstant(query: RecordIOTInstantQuery): AxiosPromise<RecordIOTInstantVO[]> {
  return request({
    url: '/ems/record/recordIOTInstant/list',
    method: 'get',
    params: query
  });
}

/**
 * 查询IOT即时数据详细
 */
export function getRecordIOTInstant(objId: string | number): AxiosPromise<RecordIOTInstantVO> {
  return request({
    url: '/ems/record/recordIOTInstant/' + objId,
    method: 'get'
  });
}

/**
 * 新增IOT即时数据
 */
export function addRecordIOTInstant(data: RecordIOTInstantForm): AxiosPromise<any> {
  return request({
    url: '/ems/record/recordIOTInstant',
    method: 'post',
    data: data
  });
}

/**
 * 修改IOT即时数据
 */
export function updateRecordIOTInstant(data: RecordIOTInstantForm): AxiosPromise<any> {
  return request({
    url: '/ems/record/recordIOTInstant',
    method: 'put',
    data: data
  });
}

/**
 * 删除IOT即时数据
 */
export function delRecordIOTInstant(objId: string | number | Array<string | number>): AxiosPromise<any> {
  return request({
    url: '/ems/record/recordIOTInstant/' + objId,
    method: 'delete'
  });
}

/**
 * 查询最新IOT数据
 */
export function getLatestIOTData(monitorId: string | number): AxiosPromise<RecordIOTInstantVO> {
  return request({
    url: '/ems/record/recordIOTInstant/latest/' + monitorId,
    method: 'get'
  });
}


// 查询电实时数据（曲线）
export function iotInstantList(query) {
  return request({
    url: '/ems/record/recordIOTInstant/iotInstantList',
    method: 'get',
    params: query
  })
}
