import request from '@/utils/request'

const BASE = '/api/robot/external/admin/machine-generate'

export interface MachineBaseReq {
  warehouse: string
  container: string
  shelfDirection?: string
  sku?: string
  businessNo?: string
  priority?: number
}

export interface InboundReq extends MachineBaseReq {
  targetType?: string
  targetCode?: string
  stationCode?: string
}

export interface OutboundReq extends MachineBaseReq {
  targetType?: string
  targetCode?: string
  targetPoint?: string
}

export interface MoveReq extends MachineBaseReq {
  targetType?: string
  targetCode?: string
  targetLevel?: number
}

export interface ReleaseReq extends MachineBaseReq {
  taskChainCode: string
  targetType?: string
  targetCode?: string
}

export interface BindStationReq {
  warehouse: string
  container: string
  station: string
}

export interface ReleaseStationReq {
  warehouse: string
  container: string
  station: string
}

export interface CancelReq extends MachineBaseReq {
  reason?: string
}

export interface InboundExceptionReq {
  palletCode: string
  outboundStation: string
  elevatorId: number
  elevatorPoint: string
}

export interface ExpediteReq {
  businessNo: string
  priority: number
}

export function generateInbound(data: InboundReq) {
  return request.post<never, { code: number; data: string }>(`${BASE}/inbound`, data)
}

export function generateOutboundWait(data: OutboundReq[]) {
  return request.post<never, { code: number; data: Record<string, string> }>(`${BASE}/outboundWait`, data)
}

export function generateOutboundNoWait(data: OutboundReq[]) {
  return request.post<never, { code: number; data: Record<string, string> }>(`${BASE}/outboundNoWait`, data)
}

export function generateOutboundWaitNew(data: OutboundReq[]) {
  return request.post<never, { code: number; data: Record<string, string> }>(`${BASE}/outboundWaitNew`, data)
}

export function generateOutboundNoWaitNew(data: OutboundReq[]) {
  return request.post<never, { code: number; data: Record<string, string> }>(`${BASE}/outboundNoWaitNew`, data)
}

export function generateMove(data: MoveReq) {
  return request.post<never, { code: number; data: string }>(`${BASE}/move`, data)
}

export function generateMoveBatch(data: MoveReq[]) {
  return request.post<never, { code: number; data: Record<string, string> }>(`${BASE}/moveBatch`, data)
}

export function generateMoveBatchNew(data: MoveReq[]) {
  return request.post<never, { code: number; data: Record<string, string> }>(`${BASE}/moveBatchNew`, data)
}

export function generateRelease(data: ReleaseReq) {
  return request.post<never, { code: number; data: boolean }>(`${BASE}/release`, data)
}

export function generateBindStation(data: BindStationReq) {
  return request.post<never, { code: number; data: boolean }>(`${BASE}/bindStation`, data)
}

export function generateReleaseStation(data: ReleaseStationReq) {
  return request.post<never, { code: number; data: boolean }>(`${BASE}/releaseStation`, data)
}

export function generateCancel(data: CancelReq) {
  return request.post<never, { code: number; data: string[] }>(`${BASE}/cancel`, data)
}

export function generateInboundException(data: InboundExceptionReq) {
  return request.post<never, { code: number; data: boolean }>(`${BASE}/inboundException`, data)
}

export function generateExpedite(data: ExpediteReq) {
  return request.post<never, { code: number; data: boolean }>(`${BASE}/expedite`, data)
}
