import request from '@/utils/request';
import { baseURL } from '@/config';

//日运行报表
export function dailyReport(data) {
  return request({
    url:
      '/dataAnalysis/dailyReport?page=' +
      data.page +
      '&size=' +
      data.size +
      '&projectId=' +
      data.projectId +
      '&time=' +
      data.time,
    method: 'get',
    data,
  });
}

//周运行报表
export function weeklyReport(data) {
  return request({
    url:
      '/dataAnalysis/weeklyReport?page=' +
      data.page +
      '&size=' +
      data.size +
      '&projectId=' +
      data.projectId +
      '&start=' +
      data.start +
      '&end=' +
      data.end,
    method: 'get',
    data,
  });
}

//日运行报表
export function monthlyReport(data) {
  let param = '?page=' + data.page + '&size=' + data.size;
  if (data.projectId != '') {
    param += '&projectId=' + data.projectId;
  }
  if (data.month != '') {
    param += '&month=' + data.month;
  }
  if (data.deviceName != '') {
    param += '&deviceName=' + data.deviceName;
  }
  return request({
    url: '/waterElec/waterDay' + param,
    method: 'get',
    data,
  });
}
//水量日报导出
export function exportDevice(data) {
  let param = '?projectId=' + data.projectId + '&month=' + data.month;
  if (data.deviceName != '') {
    param += '&deviceName=' + data.deviceName;
  }
  return baseURL + '/waterElec/waterDayExport' + param;
}
//电量日报
export function elecDay(data) {
  let param = '?page=' + data.page + '&size=' + data.size;
  if (data.projectId != '') {
    param += '&projectId=' + data.projectId;
  }
  if (data.month != '') {
    param += '&month=' + data.month;
  }
  if (data.deviceName != '') {
    param += '&deviceName=' + data.deviceName;
  }
  return request({
    url: '/waterElec/elecDay' + param,
    method: 'get',
    data,
  });
}
//电量日报导出
export function elecDayExport(data) {
  let param = '?projectId=' + data.projectId + '&month=' + data.month;
  if (data.deviceName != '') {
    param += '&deviceName=' + data.deviceName;
  }
  return baseURL + '/waterElec/elecDayExport' + param;
}
//站点月运行报表
export function deviceMonth(data) {
  let param = '?page=' + data.page + '&size=' + data.size;
  if (data.month != '') {
    param += '&month=' + data.month;
  }
  if (data.projectId != '') {
    param += '&projectId=' + data.projectId;
  }
  if (data.projectName != '') {
    param += '&projectName=' + data.projectName;
  }
  return request({
    url: '/deviceReport/deviceMonth' + param,
    method: 'get',
    data,
  });
}
//站点月运行导出
export function deviceMonthExport(data) {
  let param = '?month=' + data.month;
  if (data.projectName != '') {
    param += '&projectName=' + data.projectName;
  }
  if (data.projectId != '') {
    param += '&projectId=' + data.projectId;
  }
  return baseURL + '/deviceReport/deviceMonth/export' + param;
}
//水量月报
export function waterMonth(data) {
  let param = '?page=' + data.page + '&size=' + data.size;
  if (data.projectId != '') {
    param += '&projectId=' + data.projectId;
  }
  if (data.year != '') {
    param += '&year=' + data.year;
  }
  if (data.deviceName != '') {
    param += '&deviceName=' + data.deviceName;
  }
  return request({
    url: '/waterElec/waterMonth' + param,
    method: 'get',
    data,
  });
}
//水量月报导出
export function waterMonthExport(data) {
  let param = '?projectId=' + data.projectId + '&year=' + data.year;
  if (data.deviceName != '') {
    param += '&deviceName=' + data.deviceName;
  }
  return baseURL + '/waterElec/waterMonthExport' + param;
}
//电量月报
export function elecMonth(data) {
  let param = '?page=' + data.page + '&size=' + data.size;
  if (data.projectId != '') {
    param += '&projectId=' + data.projectId;
  }
  if (data.year != '') {
    param += '&year=' + data.year;
  }
  if (data.deviceName != '') {
    param += '&deviceName=' + data.deviceName;
  }
  return request({
    url: '/waterElec/elecMonth' + param,
    method: 'get',
    data,
  });
}
//电量月报导出
export function elecMonthExport(data) {
  let param = '?projectId=' + data.projectId + '&year=' + data.year;
  if (data.deviceName != '') {
    param += '&deviceName=' + data.deviceName;
  }
  return baseURL + '/waterElec/elecMonthExport' + param;
}

//查询工厂数据
export function haianList(data) {
  let param = '?page=' + data.page + '&size=' + data.size;
  if (data.startTime) {
    param += '&startTime=' + data.startTime;
    param += '&endTime=' + data.endTime;
  }
  return request({
    url: '/haian/list' + param,
    method: 'get',
  });
}

export function saveHian(data) {
  return request({
    url: '/haian/update',
    method: 'post',
    data,
  });
}
export function addHian(data) {
  return request({
    url: '/haian/add',
    method: 'post',
    data,
  });
}
export function delHian(data) {
  return request({
    url: '/haian/remove/' + data,
    method: 'post',
  });
}
export function HianDevice() {
  return request({
    url: '/haian/devices',
    method: 'get',
  });
}
