export interface EnergyReportQuery {
  deviceType?: string | number;
  nodeIds?: string;
  timeType?: 'hour' | 'day' | 'month' | 'year' | 'shift' | 'latest';
  date?: string;
  beginDate?: string;
  endDate?: string;
  beginMonth?: string;
  endMonth?: string;
  startYear?: number;
  endYear?: number;
  latestCount?: number;
}

export interface EnergyReportColumnChild {
  prop: string;
  label: string;
}

export interface EnergyReportColumn {
  field: string;
  metricId?: string | number;
  collectionField?: string;
  aggregationRule?: string;
  label: string;
  children: EnergyReportColumnChild[];
}

export interface EnergyReportRow {
  id: string | number;
  name: string;
  deviceIds?: string[];
  [key: string]: string | number | string[] | null | undefined;
}

export interface EnergyReportResult {
  columns: EnergyReportColumn[];
  rows: EnergyReportRow[];
  buckets: Array<{ label: string; value: string | number }>;
  fields: string[];
  metrics?: Array<{
    key: string;
    id: string | number;
    label: string;
    collectionField: string;
    aggregationRule: string;
  }>;
  deviceType: string;
  deviceTypeLabel: string;
}

export interface TemperatureDeviceOption {
  label: string;
  value: string;
}

export interface TemperatureReportQuery {
  beginTime?: string;
  endTime?: string;
  deviceIds?: string;
  metricId?: string | number;
  interval?: number;
}

export interface TemperatureReportSeries {
  deviceId: string;
  name: string;
  type: 'line';
  smooth: boolean;
  connectNulls: boolean;
  data: Array<number | null>;
}

export interface TemperatureReportResult {
  xAxis: string[];
  series: TemperatureReportSeries[];
  devices: Array<{ deviceId: string; name: string }>;
  records?: Array<{
    deviceId: string;
    deviceName: string;
    deviceLocation: string;
    reportTime: string;
    metricName: string;
    metricUnit: string;
    value: number | null;
  }>;
  metric?: {
    id?: string | number;
    name: string;
    unit: string;
    aggregationRule: string;
  };
  beginTime: string;
  endTime: string;
}

export type ElectricityDeviceOption = TemperatureDeviceOption;
export type WaterDeviceOption = TemperatureDeviceOption;
export type ElectricityReportQuery = TemperatureReportQuery;
export type WaterReportQuery = TemperatureReportQuery;
export type ElectricityReportSeries = TemperatureReportSeries;
export type WaterReportSeries = TemperatureReportSeries;
export type ElectricityReportResult = TemperatureReportResult;
export type WaterReportResult = TemperatureReportResult;

export interface SeniorPowerQuery {
  beginTime?: string;
  endTime?: string;
  showGroup?: boolean;
  reportType?: string | number;
}

export interface SeniorPowerResult {
  beginTime: string;
  endTime: string;
  showGroup: boolean;
  reportType: string;
  valueName: string;
  unit: string;
  riverData: Array<[string, number, string]>;
  treemapData: any[];
  devices: Array<{ id: string | number; name: string; deviceId: string }>;
}

export interface SeniorFlowResult {
  beginTime: string;
  endTime: string;
  reportType: string;
  valueName: string;
  unit: string;
  sankeyData: {
    nodes: Array<{ name: string; value?: number }>;
    links: Array<{ source: string; target: string; value: number }>;
  };
  devices: Array<{ id: string | number; name: string; deviceId: string }>;
}

export interface CompareReportQuery {
  deviceType?: string | number;
  nodeIds?: string;
  compareTypes?: string;
  timeType?: 'hour' | 'day' | 'month' | 'year' | 'shift';
  date?: string;
  startYear?: number;
  endYear?: number;
}

export interface CompareReportResult {
  deviceType: string;
  valueName: string;
  unit: string;
  timeType: string;
  xAxis: string[];
  current: {
    periodLabel: string;
    values: Array<number | null>;
    total: number;
  };
  comparisons: Array<{
    type: 'yoy' | 'mom';
    label: string;
    periodLabel: string;
    values: Array<number | null>;
    total: number;
    percent: number;
  }>;
}

export interface TrendReportQuery {
  deviceType?: string | number;
  deviceIds?: string;
  interval?: number;
  beginTime?: string;
  endTime?: string;
  aggregateType?: 'max' | 'min' | 'avg' | 'sum' | 'subtract' | 'latest' | 'positive_diff' | 'negative_diff';
}

export interface TrendReportResult {
  deviceType: string;
  valueName: string;
  unit: string;
  interval: number;
  aggregateType: string;
  xAxis: string[];
  series: Array<{
    name: string;
    deviceId: string;
    type: 'line';
    smooth: boolean;
    connectNulls: boolean;
    data: Array<number | null>;
  }>;
}

export interface RealTimeCurveQuery {
  deviceIds?: string;
  metricIds?: string;
  beginTime?: string;
  endTime?: string;
}

export interface RealTimeCurveMetric {
  id: string;
  type: string;
  name: string;
  unit: string;
  field: string;
}

export interface RealTimeCurveDevice {
  deviceId: string;
  name: string;
  deviceType?: string;
}

export interface RealTimeCurvePoint {
  metricId: string;
  metricName: string;
  unit: string;
  deviceId: string;
  deviceName: string;
  reportTime: string;
  value: number;
}

export interface RealTimeCurveResult {
  beginTime: string;
  endTime: string;
  metrics: RealTimeCurveMetric[];
  devices: RealTimeCurveDevice[];
  points: RealTimeCurvePoint[];
}
