import request from '@/utils/request'

export interface MachineStationQueueVO {
  warehouse: string
  stationCode: string
  queueSize: number
  configuredMaxCapacity: number | null
  effectiveMaxCapacity: number
  queuedChainCodes: string[]
}

export interface MachineStationQueueMaxUpdateDTO {
  warehouse: string
  stationCode: string
  maxCapacity: number
}

export function listStationQueues(warehouse: string) {
  return request.get<never, { code: number; data: MachineStationQueueVO[] }>(
    '/api/robot/external/admin/station-queue/list',
    { params: { warehouse } },
  )
}

/** 固定工作站编码（ASRS 工作站排除 A1、A2、A5，包含 WH01-3-2） */
export function listStationCodes(warehouse: string) {
  return request.get<never, { code: number; data: string[] }>(
    '/api/robot/external/admin/station-queue/station-codes',
    { params: { warehouse } },
  )
}

export function getStationQueueSnapshot(warehouse: string, stationCode: string) {
  return request.get<never, { code: number; data: MachineStationQueueVO }>(
    '/api/robot/external/admin/station-queue/snapshot',
    { params: { warehouse, stationCode } },
  )
}

export function updateStationQueueMax(payload: MachineStationQueueMaxUpdateDTO) {
  return request.post<never, { code: number; data: boolean }>(
    '/api/robot/external/admin/station-queue/max',
    payload,
  )
}
