import request from '@/utils/request'
import area from '@/views/basecfg/area/index.vue'

// 查询能源设备列表
export function listDevice(query) {
  return request({
    url: '/ems/device/list',
    method: 'get',
    params: query
  })
}

// 递归查询 区域/建筑/区块 下的设备(分页)
export function listDevRecursionByArea(query) {
  return request({
    url: '/ems/device/listRecursionByArea',
    method: 'get',
    params: query
  })
}

// 递归查询 区域/设施 下的设备(分页)
export function devTreeByFacs(areaCode, deviceCategory) {
  return request({
    url: '/ems/device/getTreeByFacs?areaCode=' + areaCode + '&deviceCategory=' + deviceCategory,
    method: 'get'
  })
}

// 查询能源设备详细
export function getDevice(id) {
  return request({
    url: '/ems/device/' + id,
    method: 'get'
  })
}

// 新增能源设备
export function addDevice(data) {
  return request({
    url: '/ems/device',
    method: 'post',
    data: data
  })
}

// 修改能源设备
export function updateDevice(data) {
  return request({
    url: '/ems/device',
    method: 'put',
    data: data
  })
}

// 删除能源设备
export function delDevice(id) {
  return request({
    url: '/ems/device/' + id,
    method: 'delete'
  })
}
// 查询设备
export function getByCondition(params) {
  return request({
    url: '/ems/device/getByCondition' ,
    method: 'get',
    params
  })
}
// 查询设备信息
export function getDeviceDetail(params) {
  return request({
    url: '/ems/device/getDetail' ,
    method: 'get',
    params
  })
}
//查询上游设备
export function getByFlowRel(params) {
  return request({
    url: '/ems/device/getByFlowRel' ,
    method: 'get',
    params
  })
}
// 查询设备属性信息
export function getObjAttr(params) {
  return request({
    url: '/ems/object/attr/getObjAttr' ,
    method: 'get',
    params
  })
}
// 查询设备最新1条指标
export function getNewIndex(params) {
  return request({
    url: '/ems/object/loadIndex/getNewIndex' ,
    method: 'get',
    params
  })
}
//查询设备下的设备部件
export function listByDevice(params) {
  return request({
    url: '/ems/device/component/listByDevice' ,
    method: 'get',
    params
  })
}
