export interface ProductionSensorGroupDetail {
  id: number;
  groupId: number;
  sensorId: number;
  orderNum: number;
  createdAt: string;
  updatedAt: string;
  isDeleted: number;
  deviceNo: string;
  deviceName: string;
  status: string;
}

export interface ProductionSensorGroup {
  id: number;
  groupName: string;
  userId: number;
  isDefault: number;
  refreshIntervalSec: number;
  isPaused: number;
  type: number;
  createdAt: string;
  updatedAt: string;
  isDeleted: number;
  sourceId: number;
  orderNum: number;
  details: ProductionSensorGroupDetail[];
  onlineRate: string;
  exceptionCount: number;
  outlineCount: number;
  failureCount: number;
}

export interface SensorDeviceViewItem {
  id: number;
  cameraGroupDetailId?: number;
  code: string;
  name: string;
  url?: string;
  imageUrl?: string;
  status: string;
}

export interface SensorGroupView extends Omit<ProductionSensorGroup, 'details'> {
  details: SensorDeviceViewItem[];
}

export interface AddSensorGroupReq {
  groupName: string;
}

export interface UpdateSensorGroupReq {
  groupId: number;
  groupName?: string;
  isDefault?: 0 | 1;
  refreshIntervalSec?: number;
  isPaused?: 0 | 1;
}

export interface QueryDeviceListReq {
  pageNumber: number;
  pageSize: number;
  queryParam: {
    deviceName?: string;
  };
}

export interface DeviceListItem {
  id: number;
  deviceNo: string;
  deviceName: string;
  deviceType: string;
  deviceModel: string;
  deptId: number;
  deptName: string;
  regionId: number;
  regionName: string;
  deptHead: number;
  deptHeadName: string;
  deviceHead: number;
  deviceHeadName: string;
  deviceStatus: string;
  location: string;
  imgUrl: string;
  filename: string;
  buyDate: string;
  createdAt: string;
  updatedAt: string;
  createdBy: number;
  updatedBy: number;
  isAlarm: number;
  isMonitor: number;
  isDashboardShow: number;
  isMaintain: number;
}

export interface QueryDeviceListRes {
  records: DeviceListItem[];
  pageNumber: number;
  pageSize: number;
  totalPage: number;
  totalRow: number;
}

export interface UpdateSensorInGroupReq {
  groupId: number;
  deviceList: { deviceNo: string; deviceName: string; status: string }[];
}

export interface BatchSaveSensor2GroupReq {
  groupId: number;
  deviceList: { deviceNo: string; deviceName: string; status: string }[];
}

export interface SaveSensor2GroupReq {
  groupId: number;
  deviceNo: string;
  orderNum: number;
  deviceName: string;
  status: string;
}

export interface DeleteSensorFromGroupReq {
  groupId: number;
  deviceNo: string;
}

export interface UpdateSensorGroupOrderItem {
  id: number;
  orderNum: number;
}

export interface UpdateSensorOrderItem {
  groupId: number;
  deviceNo: string;
  orderNum: number;
}

export interface QueryDevicePropertiesHistoryReq {
  deviceId: number;
  startTime: string;
  endTime: string;
  page: number;
  size: number;
}

export interface DevicePropertiesHistoryItem {
  deviceId: number;
  key: string;
  value: string | number;
  timestamp: number;
}

export interface QueryDevicePropertiesHistoryRes {
  total: number;
  list: DevicePropertiesHistoryItem[];
}
