import request from '@/utils/request';
import type {
  EfficiencyAnalysisVO,
  EnergyAbnormalAlertReportVO,
  EmsActionResponse,
  InstrumentConditionReportVO,
  MeterBalanceReportVO,
  RecordIotenvInstantReportQuery
} from '../types';

export interface MeterBalanceReportQuery extends RecordIotenvInstantReportQuery {
  rootMonitorId?: string;
  aggregationType?: 'LAST' | 'AVG' | 'SUM' | string;
  imbalanceThreshold?: number | string;
}

export interface EfficiencyAnalysisQuery extends RecordIotenvInstantReportQuery {
  metricCodes?: string[];
}

export interface EnergyAbnormalAlertReportQuery extends RecordIotenvInstantReportQuery {
  alarmStatus?: number;
  pushStatus?: string;
}

// 查询仪表工况分析
export function getInstrumentConditionReport(data: RecordIotenvInstantReportQuery): Promise<EmsActionResponse<InstrumentConditionReportVO>> {
  return request({
    url: '/ems/report/iotAdvanced/instrumentCondition',
    method: 'post',
    data
  });
}

// 查询计量平衡报表
export function getMeterBalanceReport(data: MeterBalanceReportQuery): Promise<EmsActionResponse<MeterBalanceReportVO>> {
  return request({
    url: '/ems/report/iotAdvanced/meterBalance',
    method: 'post',
    data
  });
}

// 查询综合运行能效分析
export function getEfficiencyAnalysisReport(data: EfficiencyAnalysisQuery): Promise<EmsActionResponse<EfficiencyAnalysisVO>> {
  return request({
    url: '/ems/report/iotAdvanced/efficiencyAnalysis',
    method: 'post',
    data
  });
}

// 查询用能异常报警报表
export function getEnergyAbnormalAlertReport(data: EnergyAbnormalAlertReportQuery): Promise<EmsActionResponse<EnergyAbnormalAlertReportVO>> {
  return request({
    url: '/ems/report/iotAdvanced/energyAbnormalAlert',
    method: 'post',
    data
  });
}
