import type { DeliveryTask } from '@/types/delivery'

function hoursAgo(h: number): string {
  return new Date(Date.now() - h * 3600_000).toISOString()
}

export async function mockDeliveries(): Promise<DeliveryTask[]> {
  await new Promise((r) => setTimeout(r, 60))
  return [
    {
      id: 'a7Kp3',
      taskId: 'WMS-20260720-001',
      missionId: 1,
      missionName: '搬运任务进程',
      missionTypeName: 'TransportMission',
      srcSiteId: 1,
      srcLabel: '1-取货台 A',
      dstSiteId: 8,
      dstLabel: '8-放货台 B',
      status: '执行中',
      statusCode: 'Fetching',
      carId: 1,
      carName: 'AGV-01',
      priority: 1,
      createTime: hoursAgo(0.5),
      startTime: hoursAgo(0.4),
      finishTime: null,
      stuckReason: null,
      overdue: false
    },
    {
      id: 'b2Xq9',
      taskId: null,
      missionId: 1,
      missionName: '搬运任务进程',
      missionTypeName: 'TransportMission',
      srcSiteId: 3,
      srcLabel: '3-缓存区',
      dstSiteId: 12,
      dstLabel: '12-工位 W2',
      status: '已下发',
      statusCode: 'Waiting',
      carId: null,
      carName: null,
      priority: 0,
      createTime: hoursAgo(0.8),
      startTime: null,
      finishTime: null,
      stuckReason: '无可用车辆',
      overdue: true
    },
    {
      id: 'c9Lm4',
      taskId: 'WMS-20260720-003',
      missionId: 1,
      missionName: '搬运任务进程',
      missionTypeName: 'TransportMission',
      srcSiteId: 4,
      srcLabel: '4-线边库',
      dstSiteId: 9,
      dstLabel: '9-包装台',
      status: '放货中',
      statusCode: 'Putting',
      carId: 3,
      carName: 'Kiva-03',
      priority: 2,
      createTime: hoursAgo(1.2),
      startTime: hoursAgo(1.0),
      finishTime: null,
      stuckReason: null,
      overdue: false
    },
    {
      id: 'd1Nb7',
      taskId: 'WMS-20260719-088',
      missionId: 1,
      missionName: '搬运任务进程',
      missionTypeName: 'TransportMission',
      srcSiteId: 2,
      srcLabel: '2-原料区',
      dstSiteId: 5,
      dstLabel: '5-成品区',
      status: '已完成',
      statusCode: 'Finished',
      carId: 2,
      carName: 'AGV-02',
      priority: 1,
      createTime: hoursAgo(6),
      startTime: hoursAgo(5.8),
      finishTime: hoursAgo(5.4),
      stuckReason: null,
      overdue: false
    },
    {
      id: 'e5Rt2',
      taskId: null,
      missionId: 1,
      missionName: '搬运任务进程',
      missionTypeName: 'TransportMission',
      srcSiteId: 6,
      srcLabel: '6-暂存',
      dstSiteId: 7,
      dstLabel: '7-发运',
      status: '已取消',
      statusCode: 'Canceled',
      carId: 4,
      carName: 'Kiva-04',
      priority: 0,
      createTime: hoursAgo(26),
      startTime: null,
      finishTime: hoursAgo(25.5),
      stuckReason: null,
      overdue: false
    },
    {
      id: 'f8Wy6',
      taskId: 'WMS-20260720-077',
      missionId: 1,
      missionName: '搬运任务进程',
      missionTypeName: 'TransportMission',
      srcSiteId: 10,
      srcLabel: '10-入库口',
      dstSiteId: 11,
      dstLabel: '11-立体库',
      status: '任务异常',
      statusCode: 'Error',
      carId: 5,
      carName: 'Kiva-05',
      priority: 3,
      createTime: hoursAgo(3),
      startTime: hoursAgo(2.8),
      finishTime: null,
      stuckReason: '放货点被占用',
      overdue: true
    }
  ]
}
