/**
 * EMS 前端共享类型底座。
 * 这里优先对齐后端实体字段，避免 Vue3 迁移阶段把业务对象退化成宽松类型。
 * 未完全确认的字段保留索引签名，但页面代码应优先使用显式属性。
 */
export type EmsId = string | number;

/**
 * 删除接口通常同时兼容单条和批量主键，这里统一收口，避免每个文件重复声明。
 */
export type EmsIdParam = EmsId | EmsId[];

/**
 * 后端日期一般会以字符串序列化返回，少数页面在本地也会传 `Date`。
 */
export type EmsDateValue = string | Date;

/**
 * 后端 BigDecimal 可能序列化为字符串或数字，前端不强行压成单一类型。
 */
export type EmsDecimalValue = string | number;

export type EmsQueryValue = string | number | boolean | null | undefined | Date | EmsId | EmsId[];

export interface EmsActionResponse<T = never> {
  code?: number;
  msg?: string;
  data?: T;
  [key: string]: unknown;
}

export interface EmsDetailResponse<T = EmsEntity> extends EmsActionResponse<T> {}

export interface EmsListResponse<T = EmsEntity> extends EmsActionResponse<T[]> {
  rows?: T[];
  total?: number;
}

export interface EmsQuery extends Partial<PageQuery> {
  // 查询参数以标量/日期/主键为主，收紧到可序列化的值，避免页面层把任意对象塞进请求参数。
  params?: Record<string, EmsQueryValue>;
  beginTime?: EmsDateValue;
  endTime?: EmsDateValue;
  collectTime?: EmsDateValue;
  monitorId?: EmsId | EmsId[];
  monitorIds?: Array<EmsId> | string;
  collectDeviceId?: string;
  collectDeviceIds?: Array<string> | string;
  [key: string]: unknown;
}

/**
 * 报表类接口的通用查询字段。
 * 这类页面通常会额外携带时间粒度、能源类型、统计单元等参数，单独显式出来能减少页面层的宽松类型断言。
 */
export interface EmsReportQuery extends EmsQuery {
  energyType?: EmsId | string;
  dateType?: EmsId | string;
  workUnitCode?: string;
  workUnitName?: string;
  monitorCode?: string;
  monitorType?: EmsId | string;
  startTime?: EmsDateValue;
  endTime?: EmsDateValue;
  beginCollectTime?: EmsDateValue;
  endCollectTime?: EmsDateValue;
}

/**
 * 能耗预览报表的行数据不是标准分页表格结构，保留动态键是为了适配按时间段生成的列。
 */
export interface EnergyPreviewReportRow extends Record<string, unknown> {
  unitName?: string;
  state?: string | number;
  expendSum?: EmsDecimalValue;
  type?: string | number;
}

/**
 * 能耗预览页的查询参数与其他报表页不完全一致，单独收口避免在页面中散落魔法字段。
 */
export interface EnergyPreviewReportQuery extends EmsReportQuery {
  energyType?: EmsId | string;
  dateType?: EmsId | string;
  startTime?: EmsDateValue;
  endTime?: EmsDateValue;
}

/**
 * 物联/振动/温湿度报表共用的查询参数。
 * 页面会在基础查询外附带设备选择、采样间隔和主看指标等字段，这里统一显式定义，避免回退到宽松断言。
 */
export interface RecordIotenvInstantReportQuery extends EmsQuery {
  source?: string;
  compareScope?: string;
  monitorId?: EmsId | string;
  monitorIds?: Array<EmsId> | string;
  monitorName?: string;
  selectionLabel?: string;
  monitorType?: EmsId | string;
  monitorTypeList?: Array<EmsId> | string;
  monitorCodeList?: string;
  samplingInterval?: EmsId | string;
  vibrationParam?: string;
  highThreshold?: EmsDecimalValue;
  warningThreshold?: EmsDecimalValue;
  minContinuousSamples?: EmsId | string;
  rapidRiseThreshold?: EmsDecimalValue;
  stddevThreshold?: EmsDecimalValue;
  primaryMetricField?: string;
  samplingGranularity?: 'SECOND' | 'MINUTE' | 'HOUR' | string;
  beginRecordTime?: EmsDateValue;
  endRecordTime?: EmsDateValue;
}

/**
 * 振动看板专用查询参数。
 * 与后端 VibrationBoardQueryBo 一一对齐，避免页面继续复用过宽的通用报表查询类型。
 */
export interface VibrationBoardQuery extends EmsQuery {
  monitorId?: EmsId | string;
  monitorIds?: Array<EmsId> | string;
  samplingInterval?: number | string;
  vibrationParam?: string;
  highThreshold?: EmsDecimalValue;
  warningThreshold?: EmsDecimalValue;
  minContinuousSamples?: EmsId | string;
  rapidRiseThreshold?: EmsDecimalValue;
  stddevThreshold?: EmsDecimalValue;
  beginRecordTime?: EmsDateValue;
  endRecordTime?: EmsDateValue;
}

/**
 * 实时数据查询页只关心“最新一条”口径，所以把树节点范围、关键字和时效阈值单独收口。
 * 这样后续即使再加 OPC/管廊来源筛选，也不需要把页面参数继续塞回宽泛的 EmsQuery。
 */
export interface RecordIotenvLatestQuery extends EmsQuery {
  parentId?: EmsId | string;
  monitorName?: string;
  staleMinutes?: EmsId | string;
  staleOnly?: boolean;
}

/**
 * 物联瞬时数据页仍保留了历史拼写 `tempreture`，这里兼容旧字段，避免迁移时强制改动页面结构。
 */
export interface RecordIOTInstantQuery extends EmsQuery {
  monitorId?: EmsId | string;
  monitorIds?: Array<EmsId> | string;
  collectTime?: EmsDateValue;
  recordTime?: EmsDateValue;
  collectType?: EmsId | string;
  tempreture?: EmsDecimalValue;
  temperature?: EmsDecimalValue;
  humidity?: EmsDecimalValue;
  illuminance?: EmsDecimalValue;
  noise?: EmsDecimalValue;
  concentration?: EmsDecimalValue;
  glys?: EmsDecimalValue;
  zxyg?: EmsDecimalValue;
  activePower?: EmsDecimalValue;
  reactivePower?: EmsDecimalValue;
}

/**
 * 振动瞬时数据页的查询字段，显式定义后页面就不会再靠宽松索引签名“蒙混过关”。
 */
export interface RecordVibrationInstantQuery extends EmsQuery {
  monitorId?: EmsId | string;
  monitorIds?: Array<EmsId> | string;
  collectTime?: EmsDateValue;
  speed?: EmsDecimalValue;
  displacement?: EmsDecimalValue;
  acceleration?: EmsDecimalValue;
  temperature?: EmsDecimalValue;
  recodeTime?: EmsDateValue;
  remark?: string;
  samplingInterval?: EmsId | string;
}

/**
 * EMS 页面里大量查询条件都遵循“分页参数 + 业务筛选字段”的模式。
 * 抽成泛型后，页面层可以直接复用 VO 作为查询基底，减少局部重复声明。
 */
export type EmsCrudQuery<T extends EmsEntity = EmsEntity> = Partial<PageQuery> &
  Partial<T> & {
    params?: Record<string, EmsQueryValue>;
    [key: string]: unknown;
  };

/**
 * 表单对象通常就是 VO 的可编辑版本；页面层可在此基础上再补少量临时字段。
 */
export type EmsCrudForm<T extends EmsEntity = EmsEntity> = T;

export interface EmsEntity extends BaseEntity {
  id?: EmsId;
  objId?: EmsId;
  objid?: EmsId;
  code?: string;
  name?: string;
  label?: string;
  value?: EmsId;
  monitorId?: EmsId;
  monitorCode?: string;
  monitorName?: string;
  collectDeviceId?: string;
  collectDeviceName?: string;
  tenantId?: string;
  energyTypeId?: EmsId;
  energyTypeName?: string;
  energyId?: EmsId;
  energyName?: string;
  measureUnit?: string;
  model?: string;
  manufacturer?: string;
  ipAddress?: string;
  settingAddress?: string;
  protocolType?: string;
  protocolVersion?: string;
  port?: EmsId;
  slaveNo?: EmsId;
  serialPort?: string;
  baudRate?: EmsId;
  dataBits?: EmsId;
  stopBits?: EmsId;
  parity?: string;
  opcEndpointUrl?: string;
  opcSecurityPolicy?: string;
  opcSecurityMode?: string;
  username?: string;
  password?: string;
  heartbeatTime?: EmsDateValue;
  lastOnlineTime?: EmsDateValue;
  offlineTimeoutSec?: EmsId;
  onlineStatus?: string;
  collectTime?: EmsDateValue;
  recordTime?: EmsDateValue;
  beginTime?: EmsDateValue;
  endTime?: EmsDateValue;
  monthDate?: EmsDateValue;
  startDate?: EmsDateValue;
  endDate?: EmsDateValue;
  produceDate?: EmsDateValue;
  operationTime?: EmsDateValue;
  recoverTime?: EmsDateValue;
  createdAt?: EmsDateValue;
  createdTime?: EmsDateValue;
  updatedAt?: EmsDateValue;
  updatedTime?: EmsDateValue;
  createTime?: EmsDateValue;
  updateTime?: EmsDateValue;
  parentId?: EmsId;
  parentName?: string;
  orderNum?: number;
  ancestors?: string;
  pointType?: string;
  metricCode?: string;
  unitName?: string;
  collectChannel?: string;
  registerAddress?: string;
  registerType?: string;
  dataType?: string;
  byteOrder?: string;
  bitOffset?: EmsId;
  nodeId?: string;
  deviceSn?: string;
  deviceName?: string;
  locationCode?: string;
  locationName?: string;
  cabinetName?: string;
  circuitName?: string;
  phaseNo?: string;
  sensorType?: string;
  measurePrecision?: EmsDecimalValue;
  rangeMin?: EmsDecimalValue;
  rangeMax?: EmsDecimalValue;
  alarmEnable?: string;
  curveEnable?: string;
  displaySort?: EmsId;
  isFlag?: string | number | boolean;
  isAmmeter?: string | number | boolean;
  isEnable?: string | number | boolean;
  status?: string | number | boolean;
  alarmLevel?: string;
  thresholdValue?: EmsDecimalValue;
  actualValue?: EmsDecimalValue;
  alarmTitle?: string;
  alarmContent?: string;
  pushStatus?: string;
  pushCount?: EmsId;
  confirmUserId?: EmsId;
  confirmRemark?: string;
  alarmUpper?: EmsDecimalValue;
  alarmLower?: EmsDecimalValue;
  recoverUpper?: EmsDecimalValue;
  recoverLower?: EmsDecimalValue;
  hysteresis?: EmsDecimalValue;
  durationSec?: EmsId;
  notifyGroupId?: EmsId;
  remark?: string;
  remarks?: string;
  description?: string;
  children?: EmsEntity[];
  [key: string]: unknown;
}

export interface EmsForm extends EmsEntity {}

export interface EmsTreeNode extends EmsEntity {
  type?: string | number;
  disabled?: boolean;
  children?: EmsTreeNode[];
}

export interface EmsDynamicColumn extends Record<string, unknown> {
  prop?: string;
  label?: string;
  type?: string;
  checkName?: string;
}

export interface BaseCollectDeviceInfoVO extends EmsEntity {
  objId?: EmsId;
  collectDeviceId?: string;
  collectDeviceName?: string;
  energyTypeId?: EmsId;
  energyTypeName?: string;
  tenantId?: string;
  model?: string;
  manufacturer?: string;
  ipAddress?: string;
  produceDate?: EmsDateValue;
  settingAddress?: string;
  isFlag?: string | number;
  protocolType?: string;
  protocolVersion?: string;
  port?: EmsId;
  slaveNo?: EmsId;
  serialPort?: string;
  baudRate?: EmsId;
  dataBits?: EmsId;
  stopBits?: EmsId;
  parity?: string;
  opcEndpointUrl?: string;
  opcSecurityPolicy?: string;
  opcSecurityMode?: string;
  username?: string;
  password?: string;
  heartbeatTime?: EmsDateValue;
  lastOnlineTime?: EmsDateValue;
  offlineTimeoutSec?: EmsId;
  onlineStatus?: string;
}

export interface BaseEnergyTypeVO extends EmsEntity {
  objId?: EmsId;
  energyTypeId?: EmsId;
  energyName?: string;
  measureUnit?: string;
  price?: EmsDecimalValue;
}

export interface BaseEnergyPriceVO extends EmsEntity {
  objId?: EmsId;
  energyId?: EmsId;
  energyName?: string;
  measureUnit?: string;
  monthDate?: EmsDateValue;
  price?: EmsDecimalValue;
  unTaxPrice?: EmsDecimalValue;
  startDate?: EmsDateValue;
  endDate?: EmsDateValue;
}

export interface BaseMonitorInfoVO extends EmsEntity {
  objId?: EmsId;
  monitorCode?: string;
  monitorName?: string;
  monitorAddr?: string;
  monitorType?: EmsId;
  monitorStatus?: EmsId;
  collectDeviceId?: string;
  collectDeviceName?: string;
  grade?: EmsId;
  meterTypeId?: string;
  correctValue?: EmsDecimalValue;
  pt?: EmsDecimalValue;
  ct?: EmsDecimalValue;
  isAmmeter?: string;
  isKeyMonitor?: EmsId;
  isCircuit?: EmsId;
  publicShareType?: EmsId;
  monitorHierarchy?: EmsId;
  energyName?: string;
  parentName?: string;
  parentId?: EmsId;
  orderNum?: number;
  ancestors?: string;
  monitorTypeList?: Array<EmsId>;
  tenantId?: string;
  pointType?: string;
  metricCode?: string;
  unitName?: string;
  collectChannel?: string;
  registerAddress?: string;
  registerType?: string;
  dataType?: string;
  byteOrder?: string;
  bitOffset?: EmsId;
  nodeId?: string;
  deviceSn?: string;
  locationCode?: string;
  locationName?: string;
  cabinetName?: string;
  circuitName?: string;
  phaseNo?: string;
  sensorType?: string;
  measurePrecision?: EmsDecimalValue;
  rangeMin?: EmsDecimalValue;
  rangeMax?: EmsDecimalValue;
  alarmEnable?: string;
  curveEnable?: string;
  displaySort?: EmsId;
  children?: BaseMonitorInfoVO[];
}

export interface BaseMonitorThresholdVO extends EmsEntity {
  objId?: EmsId;
  monitorCode?: string;
  monitorName?: string;
  monitorType?: EmsId;
  iAMax?: EmsDecimalValue;
  iAMin?: EmsDecimalValue;
  iBMax?: EmsDecimalValue;
  iBMin?: EmsDecimalValue;
  iCMax?: EmsDecimalValue;
  iCMin?: EmsDecimalValue;
  vAMax?: EmsDecimalValue;
  vAMin?: EmsDecimalValue;
  vBMax?: EmsDecimalValue;
  vBMin?: EmsDecimalValue;
  vCMax?: EmsDecimalValue;
  vCMin?: EmsDecimalValue;
  hourConsumption?: EmsDecimalValue;
  dayConsumption?: EmsDecimalValue;
  lineLruoyisRate?: EmsDecimalValue;
  isFlag?: string;
}

export interface BaseMonitorWorkUnitVO extends EmsEntity {}

export interface BaseSharePriceVO extends EmsEntity {}

export interface BaseWorkUnitVO extends EmsEntity {
  objId?: EmsId;
  workUnitCode?: string;
  workUnitName?: string;
  workUnitAddress?: string;
  workUnitSort?: EmsId;
  productLineCode?: string;
  workUnitType?: EmsId;
  isFlag?: string;
  createdBy?: string;
  createdTime?: EmsDateValue;
  updatedBy?: string;
  updatedTime?: EmsDateValue;
  parentName?: string;
  parentId?: EmsId;
  orderNum?: number;
  ancestors?: string;
  children?: BaseWorkUnitVO[];
}

export interface EmsAlarmActionStepImageVO extends EmsEntity {
  objId?: EmsId;
  actionStepObjId?: EmsId;
  imageUrl?: string;
  imageSequence?: EmsId;
  description?: string;
}

export interface EmsAlarmActionStepVO extends EmsEntity {
  objId?: EmsId;
  ruleObjId?: EmsId;
  stepSequence?: EmsId;
  description?: string;
  remark?: string;
  stepImages?: EmsAlarmActionStepImageVO[];
}

export interface DailyFaultRecordVO extends EmsEntity {
  id?: EmsId;
  date?: string;
  location?: string;
  dailyDutySupervisor?: string;
  tendaDailyDutySupervisor?: string;
  faultSituation?: string;
  handlingMeasures?: string;
  faultType?: string;
  faultOccurrenceTime?: string;
  handlingCompletionTime?: string;
  handlingDuration?: EmsId;
  handlingDurationFormatted?: string;
  remarks?: string;
}

export interface FaultHandlingRecordVO extends EmsEntity {}

export interface LuggageSystemPlcBufferBatteryLifecycleVO extends EmsEntity {}

export interface LuggageSystemSecurityDoorBatteryLifecycleVO extends EmsEntity {}

export interface PowerEnergySparePartsRegistrationVO extends EmsEntity {
  objid?: EmsId;
  date?: string;
  sparePartsName?: string;
  sparePartModel?: string;
  wasteQuantity?: EmsId;
  storageLocation?: string;
  registrar?: string;
  warehouseConfirmation?: string;
  remarks?: string;
}

export interface PowerEnergySupervisionChecklistVO extends EmsEntity {}

export interface SparePartsInventoryVO extends EmsEntity {
  objid?: EmsId;
  warehouseDate?: string;
  purchaseMethod?: string;
  storageLocation?: string;
  itemName?: string;
  originalPartNumber?: string;
  model?: string;
  warehouseQuantity?: EmsId;
  remainingQuantity?: EmsId;
  threshold?: EmsId;
  remarks?: string;
  checkData?: Record<string, EmsId>;
}

export interface SparePartsInventoryExportVO extends SparePartsInventoryVO {}

export interface SparePartsInventoryCheckVO extends EmsEntity {
  id?: EmsId;
  inventoryObjid?: EmsId;
  checkName?: string;
  checkQuantity?: EmsId;
  checkDate?: string;
  createdAt?: EmsDateValue;
}

export interface SparePartsUsageRecordVO extends EmsEntity {
  id?: EmsId;
  date?: string;
  sparePartName?: string;
  sparePartModel?: string;
  quantityUsed?: EmsId;
  remainingQuantity?: EmsId;
  issuingWarehouse?: string;
  replacementLocation?: string;
  personReceived?: string;
  warehouseManagerConfirmation?: string;
  inventoryStatus?: string;
  departmentWarehouse?: string;
  remarks?: string;
}

export interface UpsBatteryLifecycleVO extends EmsEntity {}

export interface EmsRecordAlarmDataVO extends EmsEntity {
  objId?: EmsId;
  monitorId?: string;
  monitorName?: string;
  collectDeviceId?: string;
  collectDeviceName?: string;
  collectTime?: EmsDateValue;
  alarmType?: EmsId;
  alarmStatus?: EmsId;
  alarmData?: string;
  operationName?: string;
  operationTime?: EmsDateValue;
  beginOperationTime?: string;
  endOperationTime?: string;
  cause?: string;
  notifyUser?: string;
  deviceName?: string;
  tenantId?: string;
  metricCode?: string;
  alarmLevel?: string;
  thresholdValue?: EmsDecimalValue;
  actualValue?: EmsDecimalValue;
  alarmTitle?: string;
  alarmContent?: string;
  recoverTime?: EmsDateValue;
  pushStatus?: string;
  pushCount?: EmsId;
  confirmUserId?: EmsId;
  confirmRemark?: string;
}

export interface AlarmHandleResultVO extends EmsEntity {
  requestCount?: EmsId;
  updatedCount?: EmsId;
  alreadyHandledCount?: EmsId;
  missingCount?: EmsId;
  successIds?: EmsId[];
  alreadyHandledIds?: EmsId[];
  missingIds?: EmsId[];
}

export interface AlarmRealtimeSaveResultVO extends EmsEntity {
  requestCount?: EmsId;
  insertedCount?: EmsId;
  duplicateCount?: EmsId;
  failedCount?: EmsId;
  insertedAlarms?: EmsRecordAlarmDataVO[];
  duplicateKeys?: string[];
  failureMessages?: string[];
}

export interface AlarmOverviewSummaryVO extends EmsEntity {
  totalCount?: EmsId;
  unhandledCount?: EmsId;
  handledCount?: EmsId;
  pushPendingCount?: EmsId;
  pushProcessingCount?: EmsId;
  pushSuccessCount?: EmsId;
  pushFailCount?: EmsId;
}

export interface RealtimeAlarmBatchResultVO extends EmsEntity {
  totalCount?: EmsId;
  insertedCount?: EmsId;
  duplicateCount?: EmsId;
  failedCount?: EmsId;
  records?: EmsRecordAlarmDataVO[];
}

export interface RealtimeAlarmEventVO extends EmsEntity {
  eventType?: string;
  eventTime?: EmsDateValue;
  generatedAt?: EmsDateValue;
  source?: string;
  alarms?: EmsRecordAlarmDataVO[];
  payload?: RealtimeAlarmBatchResultVO;
}

export interface EmsRecordAlarmRuleVO extends EmsEntity {
  objId?: EmsId;
  ruleId?: string;
  ruleName?: string;
  monitorId?: string;
  monitorCode?: string;
  monitorName?: string;
  collectTime?: EmsDateValue;
  energyType?: EmsId;
  triggerRule?: EmsId;
  monitorField?: EmsId;
  timeRange?: EmsId;
  triggerValue?: EmsDecimalValue;
  notifyUser?: string;
  cause?: string;
  nickName?: string;
  tenantId?: string;
  metricCode?: string;
  alarmUpper?: EmsDecimalValue;
  alarmLower?: EmsDecimalValue;
  recoverUpper?: EmsDecimalValue;
  recoverLower?: EmsDecimalValue;
  hysteresis?: EmsDecimalValue;
  durationSec?: EmsId;
  alarmLevel?: string;
  notifyGroupId?: EmsId;
  isEnable?: string;
}

export interface AlarmNotifyGroupVO extends EmsEntity {
  id?: EmsId;
  groupName?: string;
  notifyChannel?: string;
  webhookUrl?: string;
  isEnable?: string;
  remark?: string;
  createTime?: EmsDateValue;
}

export interface AlarmNotifyGroupUserVO extends EmsEntity {
  id?: EmsId;
  groupId?: EmsId;
  groupName?: string;
  userId?: EmsId;
  userName?: string;
  nickName?: string;
  phone?: string;
  email?: string;
  isEnable?: string;
  createTime?: EmsDateValue;
}

export interface AlarmPushLogVO extends EmsEntity {
  id?: EmsId;
  alarmObjId?: EmsId;
  alarmTitle?: string;
  monitorCode?: string;
  monitorName?: string;
  channelType?: string;
  targetValue?: string;
  alarmLevel?: string;
  pushContent?: string;
  pushStatus?: string;
  responseMsg?: string;
  pushTime?: EmsDateValue;
}

export interface MonitorMetricThresholdVO extends EmsEntity {
  id?: EmsId;
  monitorCode?: string;
  monitorName?: string;
  metricCode?: string;
  warnUpper?: EmsDecimalValue;
  warnLower?: EmsDecimalValue;
  alarmUpper?: EmsDecimalValue;
  alarmLower?: EmsDecimalValue;
  hysteresis?: EmsDecimalValue;
  durationSec?: EmsId;
  alarmLevel?: string;
  notifyGroupId?: EmsId;
  notifyGroupName?: string;
  isEnable?: string;
  remark?: string;
  createTime?: EmsDateValue;
}

export interface DataExportTaskVO extends EmsEntity {
  id?: EmsId;
  exportType?: string;
  monitorCode?: string;
  monitorName?: string;
  metricCode?: string;
  timeStart?: EmsDateValue;
  timeEnd?: EmsDateValue;
  exportCondition?: string;
  fileFormat?: string;
  fileName?: string;
  fileUrl?: string;
  exportStatus?: string;
  remark?: string;
  createTime?: EmsDateValue;
}

export interface IntegrationEndpointVO extends EmsEntity {
  id?: EmsId;
  endpointName?: string;
  endpointType?: string;
  accessMode?: string;
  host?: string;
  port?: EmsId;
  configJson?: string;
  status?: string;
  createTime?: EmsDateValue;
}

export interface IntegrationPointMapVO extends EmsEntity {
  id?: EmsId;
  endpointId?: EmsId;
  endpointName?: string;
  monitorCode?: string;
  monitorName?: string;
  metricCode?: string;
  sourcePointCode?: string;
  targetPointCode?: string;
  transformScript?: string;
  dataFormat?: string;
  isEnable?: string;
  createTime?: EmsDateValue;
}

export interface ControlCommandLogVO extends EmsEntity {
  id?: EmsId;
  endpointId?: EmsId;
  endpointName?: string;
  monitorCode?: string;
  monitorName?: string;
  commandType?: string;
  commandContent?: string;
  executeStatus?: string;
  responseContent?: string;
  createTime?: EmsDateValue;
}

export interface ReportPeriodSummaryVO extends EmsEntity {
  id?: EmsId;
  monitorCode?: string;
  monitorName?: string;
  metricCode?: string;
  metricName?: string;
  periodType?: string;
  periodStart?: EmsDateValue;
  periodEnd?: EmsDateValue;
  beginValue?: EmsDecimalValue;
  endValue?: EmsDecimalValue;
  avgValue?: EmsDecimalValue;
  maxValue?: EmsDecimalValue;
  minValue?: EmsDecimalValue;
  consumeValue?: EmsDecimalValue;
  overLimitDuration?: EmsId;
  alarmCount?: EmsId;
  sampleCount?: EmsId;
}

export interface EmsRecordDnbInstantVO extends EmsEntity {
  objId?: EmsId;
  monitorCode?: string;
  monitorName?: string;
  collectTime?: EmsDateValue;
  vA?: EmsDecimalValue;
  vB?: EmsDecimalValue;
  vC?: EmsDecimalValue;
  iA?: EmsDecimalValue;
  iB?: EmsDecimalValue;
  iC?: EmsDecimalValue;
  recordTime?: EmsDateValue;
  glys?: EmsDecimalValue;
  zxyg?: EmsDecimalValue;
  activePower?: EmsDecimalValue;
  reactivePower?: EmsDecimalValue;
  collectType?: EmsId;
}

export interface EmsRecordSteamInstantVO extends EmsEntity {
  objId?: EmsId;
  monitorCode?: string;
  monitorName?: string;
  collectTime?: EmsDateValue;
  fluxFlow?: EmsDecimalValue;
  steamFlow?: EmsDecimalValue;
  heatInstantValue?: EmsDecimalValue;
  heatTotalValue?: EmsDecimalValue;
  temperature?: EmsDecimalValue;
  press?: EmsDecimalValue;
  density?: EmsDecimalValue;
  differencePress?: EmsDecimalValue;
  recordTime?: EmsDateValue;
}

export interface EmsRecordWaterInstantVO extends EmsEntity {
  objId?: EmsId;
  monitorCode?: string;
  monitorName?: string;
  collectTime?: EmsDateValue;
  fluxFlow?: EmsDecimalValue;
  waterFlow?: EmsDecimalValue;
  recordTime?: EmsDateValue;
  collectType?: EmsId;
}

export interface RecordIotenvInstantVO extends EmsEntity {
  objid?: EmsId;
  monitorId?: string;
  monitorCode?: string;
  monitorName?: string;
  /**
   * 历史页面里大量使用 `tempreture` 拼写，保留别名能避免 Vue3/TS 迁移把旧模板一起打断。
   */
  tempreture?: EmsDecimalValue;
  temperature?: EmsDecimalValue;
  humidity?: EmsDecimalValue;
  illuminance?: EmsDecimalValue;
  noise?: EmsDecimalValue;
  concentration?: EmsDecimalValue;
  vibrationSpeed?: EmsDecimalValue;
  vibrationDisplacement?: EmsDecimalValue;
  vibrationAcceleration?: EmsDecimalValue;
  vibrationTemp?: EmsDecimalValue;
  collectTime?: EmsDateValue;
  recodeTime?: EmsDateValue;
  monitorIds?: string[];
  monitorType?: EmsId;
  energyName?: string;
  samplingInterval?: EmsId;
  samplingGranularity?: 'SECOND' | 'MINUTE' | 'HOUR' | string;
  vibrationParam?: string;
}

export interface IotMetricOptionVO extends EmsEntity {
  metricCode?: string;
  metricName?: string;
  unit?: string;
}

export interface InstrumentConditionPointVO extends EmsEntity {
  time?: string;
  value?: EmsDecimalValue;
}

export interface InstrumentConditionSeriesVO extends EmsEntity {
  monitorId?: string;
  monitorName?: string;
  metricCode?: string;
  metricName?: string;
  unit?: string;
  points?: InstrumentConditionPointVO[];
}

export interface InstrumentConditionStatVO extends EmsEntity {
  metricCode?: string;
  metricName?: string;
  unit?: string;
  latest?: EmsDecimalValue;
  avg?: EmsDecimalValue;
  max?: EmsDecimalValue;
  min?: EmsDecimalValue;
  sampleCount?: EmsId;
}

export interface AdvancedReportBaseVO extends EmsEntity {
  hasData?: boolean;
  supported?: boolean;
  emptyReason?: string;
}

export interface InstrumentConditionReportVO extends AdvancedReportBaseVO {
  samplingGranularity?: string;
  samplingInterval?: EmsId;
  availableMetrics?: IotMetricOptionVO[];
  summaryCards?: InstrumentConditionStatVO[];
  seriesList?: InstrumentConditionSeriesVO[];
}

export interface MeterBalanceCircuitVO extends EmsEntity {
  monitorId?: string;
  monitorName?: string;
  monitorIds?: string[];
  upstreamValue?: EmsDecimalValue;
  downstreamTotal?: EmsDecimalValue;
  diffValue?: EmsDecimalValue;
  diffRate?: EmsDecimalValue;
  abnormal?: boolean;
}

export interface MeterBalanceReportVO extends AdvancedReportBaseVO {
  rootMonitorId?: string;
  rootMonitorName?: string;
  metricCode?: string;
  metricName?: string;
  unit?: string;
  aggregationType?: string;
  helpText?: string;
  upstreamValue?: EmsDecimalValue;
  downstreamTotal?: EmsDecimalValue;
  diffValue?: EmsDecimalValue;
  diffRate?: EmsDecimalValue;
  circuits?: MeterBalanceCircuitVO[];
}

export interface EfficiencyMetricScoreVO extends EmsEntity {
  metricCode?: string;
  metricName?: string;
  unit?: string;
  weight?: EmsDecimalValue;
  averageValue?: EmsDecimalValue;
  peakValue?: EmsDecimalValue;
  stabilityScore?: EmsDecimalValue;
  fluctuationScore?: EmsDecimalValue;
  thresholdScore?: EmsDecimalValue;
  score?: EmsDecimalValue;
}

export interface EfficiencyDeviceScoreVO extends EmsEntity {
  monitorId?: string;
  monitorName?: string;
  totalScore?: EmsDecimalValue;
  sampleCount?: EmsId;
  validMetricCount?: EmsId;
}

export interface EfficiencyAnalysisVO extends AdvancedReportBaseVO {
  templateName?: string;
  analysisConclusion?: string;
  overallScore?: EmsDecimalValue;
  metricScores?: EfficiencyMetricScoreVO[];
  deviceScores?: EfficiencyDeviceScoreVO[];
}

export interface AlertTrendPointVO extends EmsEntity {
  timeBucket?: string;
  alarmCount?: EmsId;
}

export interface AlertRankingVO extends EmsEntity {
  monitorId?: string;
  monitorName?: string;
  alarmCount?: EmsId;
  unhandledCount?: EmsId;
  pushFailCount?: EmsId;
}

export interface EnergyAbnormalAlertReportVO extends AdvancedReportBaseVO {
  summary?: AlarmOverviewSummaryVO;
  trend?: AlertTrendPointVO[];
  ranking?: AlertRankingVO[];
  records?: EmsRecordAlarmDataVO[];
}

export interface EmsReportPointDnbVO extends EmsEntity {
  objId?: EmsId;
  monitorCode?: string;
  monitorName?: string;
  instrumentValue?: EmsDecimalValue;
  expend?: EmsDecimalValue;
  recordTime?: EmsDateValue;
  beginTime?: EmsDateValue;
  endTime?: EmsDateValue;
  updateFlag?: string;
}

export interface EmsReportPointIOTVO extends EmsEntity {}

export interface EmsReportPointSteamVO extends EmsEntity {
  objId?: EmsId;
  monitorCode?: string;
  monitorName?: string;
  instrumentValue?: EmsDecimalValue;
  expend?: EmsDecimalValue;
  recordTime?: EmsDateValue;
  beginTime?: EmsDateValue;
  endTime?: EmsDateValue;
  updateFlag?: string;
}

export interface EmsReportPointWaterVO extends EmsEntity {
  objId?: EmsId;
  monitorCode?: string;
  monitorName?: string;
  instrumentValue?: EmsDecimalValue;
  expend?: EmsDecimalValue;
  recordTime?: EmsDateValue;
  beginTime?: EmsDateValue;
  endTime?: EmsDateValue;
  updateFlag?: string;
}

export interface EnergyStatisticalReportVO extends EmsEntity {
  workUnitCode?: string;
  workUnitName?: string;
  expend?: EmsDecimalValue;
  beginTime?: string;
  endTime?: string;
  instrumentValue?: EmsDecimalValue;
}

export interface PeaksValleysConsumptionReportVO extends EmsEntity {
  workUnitCode?: string;
  workUnitName?: string;
  pointTime?: string;
  priceType?: string;
  expend?: EmsDecimalValue;
  price?: EmsDecimalValue;
}

export interface EmsReportSummaryVO extends EmsEntity {
  monitorCode?: string;
  monitorName?: string;
  instrumentValue?: EmsDecimalValue;
  expend?: EmsDecimalValue;
  value?: EmsDecimalValue;
  unit?: string;
  recordTime?: EmsDateValue;
  beginTime?: EmsDateValue;
  endTime?: EmsDateValue;
}
