import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import {
  ReportPeriodSummaryVO,
  ReportPeriodSummaryForm,
  ReportPeriodSummaryId,
  ReportPeriodSummaryIds,
  ReportPeriodSummaryQuery
} from '@/api/ems/base/reportPeriodSummary/types';

/**
 * 查询周期报汇总列表
 * @param query
 * @returns {*}
 */

export const listReportPeriodSummary = (query?: ReportPeriodSummaryQuery): AxiosPromise<ReportPeriodSummaryVO[]> => {
  return request({
    url: '/ems/base/reportPeriodSummary/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询动态聚合后的周期报表
 * @param query
 */
export const listAggregateReportPeriodSummary = (query?: ReportPeriodSummaryQuery): AxiosPromise<ReportPeriodSummaryVO[]> => {
  return request({
    url: '/ems/base/reportPeriodSummary/aggregateList',
    method: 'get',
    params: query
  });
};

/**
 * 查询周期报汇总详细
 * @param id
 */
export const getReportPeriodSummary = (id: ReportPeriodSummaryId): AxiosPromise<ReportPeriodSummaryVO> => {
  return request({
    url: '/ems/base/reportPeriodSummary/' + id,
    method: 'get'
  });
};

/**
 * 批量查询周期报汇总详细
 * @param ids
 */
export const getReportPeriodSummaryByIds = (ids: ReportPeriodSummaryIds): AxiosPromise<ReportPeriodSummaryVO[]> => {
  return request({
    url: '/ems/base/reportPeriodSummary/listByIds',
    method: 'post',
    data: ids
  });
};

/**
 * 统计周期报汇总数量
 * @param query
 */
export const countReportPeriodSummary = (query?: ReportPeriodSummaryQuery): AxiosPromise<number> => {
  return request({
    url: '/ems/base/reportPeriodSummary/count',
    method: 'get',
    params: query
  });
};

/**
 * 判断是否存在符合条件的周期报汇总
 * @param query
 */
export const existsReportPeriodSummary = (query?: ReportPeriodSummaryQuery): AxiosPromise<boolean> => {
  return request({
    url: '/ems/base/reportPeriodSummary/exists',
    method: 'get',
    params: query
  });
};

/**
 * 新增周期报汇总
 * @param data
 */
export const addReportPeriodSummary = (data: ReportPeriodSummaryForm) => {
  return request({
    url: '/ems/base/reportPeriodSummary',
    method: 'post',
    data: data
  });
};

/**
 * 修改周期报汇总
 * @param data
 */
export const updateReportPeriodSummary = (data: ReportPeriodSummaryForm) => {
  return request({
    url: '/ems/base/reportPeriodSummary',
    method: 'put',
    data: data
  });
};

/**
 * 删除周期报汇总
 * @param id
 */
export const delReportPeriodSummary = (id: ReportPeriodSummaryId | ReportPeriodSummaryIds) => {
  return request({
    url: '/ems/base/reportPeriodSummary/' + id,
    method: 'delete'
  });
};

/**
 * 导出动态聚合后的周期报表
 * @param query
 */
export const exportAggregateReportPeriodSummary = (query?: ReportPeriodSummaryQuery) => {
  return request({
    url: '/ems/base/reportPeriodSummary/aggregateExport',
    method: 'post',
    params: query
  });
};
