/**
 * 작업지시 관리 목업 데이터
 */

import type {
  WorkOrder,
  SalesOrder,
  WorkOrderStats,
  BendingDetail,
} from './types';

// 전개도 상세 목업 (절곡용)
const bendingDetailsSample: BendingDetail[] = [
  {
    id: 'bd-1',
    code: 'SD30',
    name: '엘바',
    material: 'E.G.I 1.6T',
    quantity: 4,
    developWidth: '500mm',
    length: '3000mm',
    weight: '0.9kg',
    note: '-',
    developDimension: '75',
  },
  {
    id: 'bd-2',
    code: 'SD31',
    name: '하장바',
    material: 'E.G.I 1.6T',
    quantity: 2,
    developWidth: '500mm',
    length: '3000mm',
    weight: '1.158kg',
    note: '-',
    developDimension: '67→126→165→178→193',
  },
  {
    id: 'bd-3',
    code: 'SD32',
    name: '짜부가스켓',
    material: 'E.G.I 0.8T',
    quantity: 4,
    developWidth: '500mm',
    length: '3000mm',
    weight: '0.576kg',
    note: '80*4,50*8',
    developDimension: '48',
  },
  {
    id: 'bd-4',
    code: 'SD33',
    name: '50평철',
    material: 'E.G.I 1.2T',
    quantity: 2,
    developWidth: '500mm',
    length: '3000mm',
    weight: '0.3kg',
    note: '-',
    developDimension: '50',
  },
  {
    id: 'bd-5',
    code: 'SD36',
    name: '밑면 점검구',
    material: 'E.G.I 1.6T',
    quantity: 2,
    developWidth: '500mm',
    length: '2438mm',
    weight: '0.98kg',
    note: '500*380',
    developDimension: '90→240→310',
  },
  {
    id: 'bd-6',
    code: 'SD37',
    name: '후면코너부',
    material: 'E.G.I 1.2T',
    quantity: 4,
    developWidth: '500mm',
    length: '1219mm',
    weight: '0.45kg',
    note: '-',
    developDimension: '35→85→120',
  },
];

// 작업지시 목업 데이터
export const mockWorkOrders: WorkOrder[] = [
  {
    id: 'wo-1',
    workOrderNo: 'KD-WO-251217-12',
    lotNo: 'KD-TS-251217-10',
    processType: 'screen',
    status: 'shipped',
    client: '두산건설(주)',
    projectName: '위브 청라 센트럴파크',
    dueDate: '2025-12-30',
    assignee: '최스크린',
    orderDate: '2025-12-17',
    shipmentDate: '2025-12-28',
    isAssigned: true,
    isStarted: true,
    priority: 5,
    currentStep: 5,
    items: [
      { id: 'item-1', no: 1, status: 'completed', productName: '스크린 셔터 (표준형)', floorCode: '1층/I-01', specification: '3500×2500', quantity: 1 },
      { id: 'item-2', no: 2, status: 'completed', productName: '스크린 셔터 (표준형)', floorCode: '1층/I-02', specification: '3500×2500', quantity: 1 },
    ],
  },
  {
    id: 'wo-2',
    workOrderNo: 'KD-WO-251217-11',
    lotNo: 'KD-TS-251217-09',
    processType: 'screen',
    status: 'in_progress',
    client: '대영건설(주)',
    projectName: '대시앙 동탄 레이크파크',
    dueDate: '2026-02-08',
    assignee: '김스크린',
    orderDate: '2025-12-17',
    shipmentDate: '2026-02-01',
    isAssigned: true,
    isStarted: true,
    priority: 5,
    currentStep: 3,
    items: [
      { id: 'item-3', no: 1, status: 'waiting', productName: '스크린 사타 (표준형)', floorCode: '1층/H-01', specification: '4000×3000', quantity: 1 },
      { id: 'item-4', no: 2, status: 'waiting', productName: '스크린 사타 (표준형)', floorCode: '2층/H-02', specification: '4000×3000', quantity: 1 },
    ],
    issues: [
      {
        id: 'issue-1',
        status: 'processing',
        type: '불량품발생',
        description: '앤드락 접착불량 - 전체 재작업 필요',
        createdAt: '2025-12-20',
      },
    ],
  },
  {
    id: 'wo-3',
    workOrderNo: 'KD-WO-251217-10',
    lotNo: 'KD-TS-251217-08',
    processType: 'screen',
    status: 'waiting',
    client: '포레나',
    projectName: '포레나 수지 더 퍼스트',
    dueDate: '2026-02-13',
    assignee: '-',
    orderDate: '2025-12-17',
    shipmentDate: '2026-02-05',
    isAssigned: false,
    isStarted: false,
    priority: 7,
    currentStep: 0,
    items: [
      { id: 'item-5', no: 1, status: 'waiting', productName: '스크린 셔터 (표준형)', floorCode: '1층/A-01', specification: '3000×2500', quantity: 1 },
    ],
  },
  {
    id: 'wo-4',
    workOrderNo: 'KD-WO-251217-09',
    lotNo: 'KD-TS-251217-07',
    processType: 'slat',
    status: 'in_progress',
    client: '호반건설(주)',
    projectName: '써밋 광교 리버파크',
    dueDate: '2026-01-30',
    assignee: '이슬랫',
    orderDate: '2025-12-17',
    shipmentDate: '2026-01-20',
    isAssigned: true,
    isStarted: true,
    priority: 5,
    currentStep: 1,
    items: [
      { id: 'item-6', no: 1, status: 'waiting', productName: '철재 슬랫 셔터', floorCode: '3층/F-05', specification: '3500×2500', quantity: 1 },
    ],
  },
  {
    id: 'wo-5',
    workOrderNo: 'KD-WO-251217-08',
    lotNo: 'KD-TS-251217-07',
    processType: 'screen',
    status: 'completed',
    client: '삼성물산(주)',
    projectName: '써밋 광교 리버파크',
    dueDate: '2026-01-18',
    assignee: '박스크린',
    orderDate: '2025-12-17',
    shipmentDate: '2026-01-10',
    isAssigned: true,
    isStarted: true,
    priority: 5,
    currentStep: 5,
    items: [
      { id: 'item-7', no: 1, status: 'completed', productName: '스크린 셔터 (표준형)', floorCode: '1층/A-01', specification: '3500×2500', quantity: 1 },
    ],
  },
  {
    id: 'wo-6',
    workOrderNo: 'KD-WO-FLD-251216-01',
    lotNo: 'KD-TS-251216-06',
    processType: 'bending',
    status: 'completed',
    client: '삼성물산(주)',
    projectName: '[E2E테스트] 절곡 전용 현장',
    dueDate: '2025-12-28',
    assignee: '최절곡',
    orderDate: '2025-12-16',
    shipmentDate: '2025-12-24',
    isAssigned: true,
    isStarted: true,
    priority: 3,
    currentStep: 4,
    items: [
      { id: 'item-8', no: 1, status: 'waiting', productName: '방화셔터 절곡 부품 SET (E2E)', floorCode: '테스트층/E2E-G-01', specification: '3000×4000', quantity: 1 },
    ],
    bendingDetails: bendingDetailsSample,
    issues: [
      {
        id: 'issue-2',
        status: 'processing',
        type: '불량품발생',
        description: '중간검사 불합격 - 절곡 각도 불량 1EA (90° 기준 ±2° 초과)',
        createdAt: '2025-12-22',
      },
    ],
  },
  {
    id: 'wo-7',
    workOrderNo: 'KD-WO-251217-07',
    lotNo: 'KD-TS-251217-07',
    processType: 'screen',
    status: 'completed',
    client: '삼성물산(주)',
    projectName: '써밋 광교 리버파크',
    dueDate: '2026-01-08',
    assignee: '김스크린',
    orderDate: '2025-12-17',
    shipmentDate: '2025-12-30',
    isAssigned: true,
    isStarted: true,
    priority: 5,
    currentStep: 5,
    items: [],
  },
  {
    id: 'wo-8',
    workOrderNo: 'KD-WO-251217-06',
    lotNo: 'KD-TS-251217-05',
    processType: 'screen',
    status: 'completed',
    client: '대산',
    projectName: '대산 송도 마린베이',
    dueDate: '2026-01-28',
    assignee: '최스크린',
    orderDate: '2025-12-17',
    shipmentDate: '2026-01-20',
    isAssigned: true,
    isStarted: true,
    priority: 5,
    currentStep: 5,
    items: [],
  },
  {
    id: 'wo-9',
    workOrderNo: 'KD-WO-251217-05',
    lotNo: 'KD-TS-251217-04',
    processType: 'slat',
    status: 'completed',
    client: '자이',
    projectName: '자이 위례 더 퍼스트',
    dueDate: '2026-01-28',
    assignee: '이슬랫',
    orderDate: '2025-12-17',
    shipmentDate: '2026-01-20',
    isAssigned: true,
    isStarted: true,
    priority: 5,
    currentStep: 5,
    items: [],
  },
  {
    id: 'wo-10',
    workOrderNo: 'KD-WO-251217-04',
    lotNo: 'KD-TS-251217-03',
    processType: 'screen',
    status: 'completed',
    client: '푸르지오',
    projectName: '푸르지오 일산 센트럴파크',
    dueDate: '2026-01-23',
    assignee: '박스크린',
    orderDate: '2025-12-17',
    shipmentDate: '2026-01-15',
    isAssigned: true,
    isStarted: true,
    priority: 5,
    currentStep: 5,
    items: [],
  },
  {
    id: 'wo-11',
    workOrderNo: 'KD-WO-251217-03',
    lotNo: 'KD-TS-251217-02',
    processType: 'bending',
    status: 'completed',
    client: '힐스테이트',
    projectName: '힐스테이트 판교 더 퍼스트',
    dueDate: '2026-01-18',
    assignee: '최절곡',
    orderDate: '2025-12-17',
    shipmentDate: '2026-01-10',
    isAssigned: true,
    isStarted: true,
    priority: 5,
    currentStep: 4,
    items: [],
  },
  {
    id: 'wo-12',
    workOrderNo: 'KD-WO-251217-02',
    lotNo: 'KD-TS-251217-82',
    processType: 'screen',
    status: 'completed',
    client: '힐스테이트',
    projectName: '힐스테이트 판교 더 머스트',
    dueDate: '2026-01-08',
    assignee: '김스크린',
    orderDate: '2025-12-17',
    shipmentDate: '2025-12-30',
    isAssigned: true,
    isStarted: true,
    priority: 5,
    currentStep: 5,
    items: [],
  },
  {
    id: 'wo-13',
    workOrderNo: 'KD-WO-251217-01',
    lotNo: 'KD-TS-251217-81',
    processType: 'screen',
    status: 'completed',
    client: '레미안',
    projectName: '레미안 강남 프레스티지',
    dueDate: '2026-01-13',
    assignee: '최스크린',
    orderDate: '2025-12-17',
    shipmentDate: '2026-01-05',
    isAssigned: true,
    isStarted: true,
    priority: 5,
    currentStep: 5,
    items: [],
  },
  {
    id: 'wo-14',
    workOrderNo: 'KD-WO-FLD-251215-01',
    lotNo: 'KD-TS-251215-01',
    processType: 'bending',
    status: 'completed',
    client: '삼성물산(주)',
    projectName: '송도 아파트 B동',
    dueDate: '2025-12-30',
    assignee: '최절곡',
    orderDate: '2025-12-15',
    shipmentDate: '2025-12-25',
    isAssigned: true,
    isStarted: true,
    priority: 5,
    currentStep: 4,
    items: [],
  },
  {
    id: 'wo-15',
    workOrderNo: 'KD-WO-FLD-251212-01',
    lotNo: 'KD-TS-251212-81',
    processType: 'bending',
    status: 'completed',
    client: '삼성물산(주)',
    projectName: '판교 롯데센터',
    dueDate: '2025-12-26',
    assignee: '최절곡',
    orderDate: '2025-12-13',
    shipmentDate: '2025-12-22',
    isAssigned: true,
    isStarted: true,
    priority: 5,
    currentStep: 4,
    items: [],
  },
  {
    id: 'wo-16',
    workOrderNo: 'KD-WO-FLD-251210-01',
    lotNo: 'KD-TS-251210-81',
    processType: 'screen',
    status: 'completed',
    client: '삼성물산(주)',
    projectName: '강남 타워 신축현장',
    dueDate: '2025-12-25',
    assignee: '김스크린',
    orderDate: '2025-12-10',
    shipmentDate: '2025-12-20',
    isAssigned: true,
    isStarted: true,
    priority: 5,
    currentStep: 5,
    items: [],
  },
  {
    id: 'wo-17',
    workOrderNo: 'KD-WO-FLD-251208-01',
    lotNo: 'KD-TS-251288-01',
    processType: 'screen',
    status: 'completed',
    client: '삼성물산(주)',
    projectName: '배곧더 타워',
    dueDate: '2025-12-22',
    assignee: '박스크린',
    orderDate: '2025-12-08',
    shipmentDate: '2025-12-18',
    isAssigned: true,
    isStarted: true,
    priority: 5,
    currentStep: 5,
    items: [],
  },
];

// 수주 목록 목업 데이터
export const mockSalesOrders: SalesOrder[] = [
  {
    id: 'so-1',
    orderNo: 'KD-TS-251201-01',
    status: '생산지시완료',
    client: '삼성물산(주)',
    projectName: '삼성물산 레미안 강남 1차',
    dueDate: '2025-12-20',
    itemCount: 2,
    splitCount: 1,
  },
  {
    id: 'so-2',
    orderNo: 'KD-TS-251205-01-A',
    status: '생산지시완료',
    client: '삼성물산(주)',
    projectName: '삼성물산 레미안 강남 1차',
    dueDate: '2025-12-28',
    itemCount: 1,
    splitCount: 1,
  },
  {
    id: 'so-3',
    orderNo: 'KD-TS-251206-01',
    status: '생산지시완료',
    client: '(주)서울인테리어',
    projectName: '강남 오피스타워 인테리어',
    dueDate: '2025-12-29',
    itemCount: 2,
    splitCount: 2,
  },
  {
    id: 'so-4',
    orderNo: 'KD-TS-251207-01',
    status: '생산지시완료',
    client: '삼성물산(주)',
    projectName: '삼성물산 레미안 강남 2차',
    dueDate: '2025-12-28',
    itemCount: 1,
    splitCount: 1,
  },
];

// 통계 계산
export function calculateStats(orders: WorkOrder[]): WorkOrderStats {
  return {
    total: orders.length,
    unassigned: orders.filter((o) => o.status === 'unassigned').length,
    pending: orders.filter((o) => o.status === 'pending').length,
    waiting: orders.filter((o) => o.status === 'waiting').length,
    inProgress: orders.filter((o) => o.status === 'in_progress').length,
    completed: orders.filter((o) => o.status === 'completed' || o.status === 'shipped').length,
  };
}

// 기본 통계
export const mockStats: WorkOrderStats = calculateStats(mockWorkOrders);