import request from '@/utils/request'

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

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

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

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

// 删除设备
export function delDevice(deviceId) {
  return request({
    url: '/system/device/' + deviceId,
    method: 'delete'
  })
}

// 一键上线
export function oneClickOnline(deviceId) {
  return request({
    url: '/system/device/oneClickOnline/' + deviceId,
    method: 'post'
  })
}

// 一键下线
export function oneClickOffline(deviceId) {
  return request({
    url: '/system/device/oneClickOffline/' + deviceId,
    method: 'post'
  })
}


// 一键出仓
export function oneClickListing(deviceId) {
  return request({
    url: '/system/device/oneClickListing/' + deviceId,
    method: 'post'
  })
}

// 一键入仓
export function oneClickWarehousing(deviceId) {
  return request({
    url: '/system/device/oneClickWarehousing/' + deviceId,
    method: 'post'
  })
}

// 更新设备
export function refreshDevice(deviceId) {
  return request({
    url: '/system/device/refreshDevice/' + deviceId,
    method: 'post'
  })
}


// 查询所有车辆信息
export function allDevice() {
  return request({
    url: '/appVerify/allVehicleInfo',
    method: 'get'
  })
}






// 根据sn查询设备
export function getDeviceBySn(sn){
  return request({
    url: '/app/device/info?sn='+sn,
    method: 'get'
  })
}

// 绑定设备设施
export function bindDeviceFacility(data){
  return request({
    url: '/system/device/bindDeviceFacility/'+data.equipmentId+'/'+data.deviceId,
    method: 'post',
    // data: data
  })
}

// 设备开关
export function deviceSwitch(data){
  return request({
    url: '/system/device/'+data.deviceId+'/switch?open='+data.open,
    method: 'put',
    // data: data
  })
}
// 刷新设备
export function refreshIot(deviceId){
  return request({
    url: '/system/device/'+deviceId+'/refreshIot',
    method: 'get'
  })
}

// 重启设备
export function rebootDevice(deviceId){
  return request({
    url: '/system/device/'+deviceId+'/reboot',
    method: 'put'
  })
}
// 设备下线
export function offlineDevice(deviceId){
  return request({
    url: '/system/device/'+deviceId+'/offline',
    method: 'put'
  })
}


// 设备投放
export function placementDevice(data){
  return request({
    url: '/system/device/placement/',
    method: 'post',
    data: data
  })
}


// 设备绑定商户
export function bindMch(deviceId,mchId){
  return request({
    url: '/system/device/'+deviceId+'/bindMch?mchId='+mchId,
    method: 'put'
  })
}
