import { ICreator, IFile, IQueryCommon, IRes, IUpdater } from '@/api/common'
import axios from '@/utils/request'

export interface IWarningInfo {
  id: number
  sid: string
  checkDataId: number
  scheckDataId: string
  /** 类型:0 告警, 1 预警   */
  type: number
  deviceName: string
  deviceType: number
  deviceTypeName: string
  deviceCode: string
  siteName: string
  longitude: number
  latitude: number
  collectionDate: string
  targetName: string
  checkValue: number
  targetUnit: string
  /** 告警处理状态 0 未读;1 已读;2 不告警 */
  handleState: number
  handleStateName: string
  handleUser: number
  handleUserName: string
  handleTime: string
  upperLimit: number
  upTolerance: number
  lowerLimit: number
  lowTolerance: number
  biginTime: string
  endTime: string
  warningName: string
  icon: string
  groupById: number
  groupByName: string
  partitionId: number
  partitionName: string
  iconFiles: IFile[]
}

export interface IDeviceType extends ICreator, IUpdater {
  id?: number
  dataUploadTime: number
  dictionaryId: number
  fileTypeID: number
  projectId: number
  deviceTypeName: string
  file: string
  projectName: string

  icon?: string
  iconFiles?: IFile[]
}

export const historyPage = (params: Partial<IWarningInfo & IQueryCommon>) =>
  axios.request<IRes<IWarningInfo[]>>({ url: `/survey/warninginfo/list`, method: 'get', params })

export const deviceTypePage = (params: Partial<IDeviceType & IQueryCommon>) =>
  axios.request<IRes<IDeviceType[]>>({ url: `/survey/devicetypep/page`, method: 'get', params })
