// POP 샘플 데이터

import { Process, Equipment, WorkOrder, WorkStepTemplate } from "./types";

// 공정 목록
export const PROCESSES: Process[] = [
  { id: "P001", name: "절단", code: "CUT" },
  { id: "P002", name: "용접", code: "WELD" },
  { id: "P003", name: "도장", code: "PAINT" },
  { id: "P004", name: "조립", code: "ASSY" },
  { id: "P005", name: "검사", code: "QC" },
  { id: "P006", name: "포장", code: "PACK" },
  { id: "P007", name: "프레스", code: "PRESS" },
  { id: "P008", name: "연마", code: "POLISH" },
  { id: "P009", name: "열처리", code: "HEAT" },
  { id: "P010", name: "표면처리", code: "SURFACE" },
  { id: "P011", name: "드릴링", code: "DRILL" },
  { id: "P012", name: "밀링", code: "MILL" },
  { id: "P013", name: "선반", code: "LATHE" },
  { id: "P014", name: "연삭", code: "GRIND" },
  { id: "P015", name: "측정", code: "MEASURE" },
  { id: "P016", name: "세척", code: "CLEAN" },
  { id: "P017", name: "건조", code: "DRY" },
  { id: "P018", name: "코팅", code: "COAT" },
  { id: "P019", name: "라벨링", code: "LABEL" },
  { id: "P020", name: "출하검사", code: "FINAL_QC" },
];

// 설비 목록
export const EQUIPMENTS: Equipment[] = [
  {
    id: "E001",
    name: "CNC-01",
    processIds: ["P001"],
    processNames: ["절단"],
    status: "running",
  },
  {
    id: "E002",
    name: "CNC-02",
    processIds: ["P001"],
    processNames: ["절단"],
    status: "idle",
  },
  {
    id: "E003",
    name: "용접기-01",
    processIds: ["P002"],
    processNames: ["용접"],
    status: "running",
  },
  {
    id: "E004",
    name: "도장라인-A",
    processIds: ["P003"],
    processNames: ["도장"],
    status: "running",
  },
  {
    id: "E005",
    name: "조립라인-01",
    processIds: ["P004", "P006"],
    processNames: ["조립", "포장"],
    status: "running",
  },
  {
    id: "E006",
    name: "검사대-01",
    processIds: ["P005"],
    processNames: ["검사"],
    status: "idle",
  },
  {
    id: "E007",
    name: "작업대-A",
    processIds: ["P001", "P002", "P004"],
    processNames: ["절단", "용접", "조립"],
    status: "idle",
  },
  {
    id: "E008",
    name: "작업대-B",
    processIds: ["P003", "P005", "P006"],
    processNames: ["도장", "검사", "포장"],
    status: "idle",
  },
];

// 작업순서 템플릿
export const WORK_STEP_TEMPLATES: Record<string, WorkStepTemplate[]> = {
  P001: [
    // 절단 공정
    {
      id: 1,
      name: "설비 점검",
      type: "equipment-check",
      description: "설비 상태 및 안전 점검",
    },
    {
      id: 2,
      name: "원자재 확인",
      type: "material-check",
      description: "원자재 수량 및 품질 확인",
    },
    { id: 3, name: "설비 셋팅", type: "setup", description: "절단 조건 설정" },
    { id: 4, name: "가공 작업", type: "work", description: "절단 가공 진행" },
    {
      id: 5,
      name: "품질 검사",
      type: "inspection",
      description: "가공 결과 품질 검사",
    },
    { id: 6, name: "작업 기록", type: "record", description: "작업 실적 기록" },
  ],
  P002: [
    // 용접 공정
    {
      id: 1,
      name: "설비 점검",
      type: "equipment-check",
      description: "용접기 및 안전장비 점검",
    },
    {
      id: 2,
      name: "자재 준비",
      type: "material-check",
      description: "용접 자재 및 부품 확인",
    },
    {
      id: 3,
      name: "용접 조건 설정",
      type: "setup",
      description: "전류, 전압 등 설정",
    },
    { id: 4, name: "용접 작업", type: "work", description: "용접 진행" },
    {
      id: 5,
      name: "용접부 검사",
      type: "inspection",
      description: "용접 품질 검사",
    },
    { id: 6, name: "작업 기록", type: "record", description: "용접 실적 기록" },
  ],
  default: [
    {
      id: 1,
      name: "작업 준비",
      type: "preparation",
      description: "작업 전 준비사항 확인",
    },
    { id: 2, name: "작업 실행", type: "work", description: "작업 진행" },
    {
      id: 3,
      name: "품질 확인",
      type: "inspection",
      description: "작업 결과 확인",
    },
    { id: 4, name: "작업 기록", type: "record", description: "작업 내용 기록" },
  ],
};

// 작업지시 목록
export const WORK_ORDERS: WorkOrder[] = [
  {
    id: "WO-2025-001",
    itemCode: "PROD-001",
    itemName: "LCD 패널 A101",
    spec: "1920x1080",
    orderQuantity: 500,
    producedQuantity: 0,
    status: "waiting",
    process: "P001",
    processName: "절단",
    equipment: "E001",
    equipmentName: "CNC-01",
    startDate: "2025-01-06",
    dueDate: "2025-01-10",
    priority: "high",
    accepted: false,
    processFlow: [
      { id: "P001", name: "절단", status: "pending" },
      { id: "P007", name: "프레스", status: "pending" },
      { id: "P011", name: "드릴링", status: "pending" },
      { id: "P002", name: "용접", status: "pending" },
      { id: "P008", name: "연마", status: "pending" },
      { id: "P003", name: "도장", status: "pending" },
      { id: "P004", name: "조립", status: "pending" },
      { id: "P005", name: "검사", status: "pending" },
      { id: "P006", name: "포장", status: "pending" },
    ],
    currentProcessIndex: 0,
  },
  {
    id: "WO-2025-002",
    itemCode: "PROD-002",
    itemName: "LED 모듈 B202",
    spec: "500x500",
    orderQuantity: 300,
    producedQuantity: 150,
    status: "in-progress",
    process: "P002",
    processName: "용접",
    equipment: "E003",
    equipmentName: "용접기-01",
    startDate: "2025-01-05",
    dueDate: "2025-01-08",
    priority: "medium",
    accepted: true,
    processFlow: [
      { id: "P001", name: "절단", status: "completed" },
      { id: "P007", name: "프레스", status: "completed" },
      { id: "P011", name: "드릴링", status: "completed" },
      { id: "P002", name: "용접", status: "current" },
      { id: "P008", name: "연마", status: "pending" },
      { id: "P003", name: "도장", status: "pending" },
      { id: "P004", name: "조립", status: "pending" },
      { id: "P005", name: "검사", status: "pending" },
      { id: "P006", name: "포장", status: "pending" },
    ],
    currentProcessIndex: 3,
  },
  {
    id: "WO-2025-003",
    itemCode: "PROD-003",
    itemName: "OLED 디스플레이",
    spec: "2560x1440",
    orderQuantity: 200,
    producedQuantity: 50,
    status: "in-progress",
    process: "P004",
    processName: "조립",
    equipment: "E005",
    equipmentName: "조립라인-01",
    startDate: "2025-01-04",
    dueDate: "2025-01-09",
    priority: "high",
    accepted: true,
    processFlow: [
      { id: "P001", name: "절단", status: "completed" },
      { id: "P007", name: "프레스", status: "completed" },
      { id: "P002", name: "용접", status: "completed" },
      { id: "P003", name: "도장", status: "completed" },
      { id: "P004", name: "조립", status: "current" },
      { id: "P005", name: "검사", status: "pending" },
      { id: "P006", name: "포장", status: "pending" },
    ],
    currentProcessIndex: 4,
  },
  {
    id: "WO-2025-004",
    itemCode: "PROD-004",
    itemName: "스틸 프레임 C300",
    spec: "800x600",
    orderQuantity: 150,
    producedQuantity: 30,
    status: "in-progress",
    process: "P005",
    processName: "검사",
    equipment: "E006",
    equipmentName: "검사대-01",
    startDate: "2025-01-03",
    dueDate: "2025-01-10",
    priority: "medium",
    accepted: false,
    processFlow: [
      { id: "P001", name: "절단", status: "completed" },
      { id: "P002", name: "용접", status: "completed" },
      { id: "P008", name: "연마", status: "completed" },
      { id: "P003", name: "도장", status: "completed" },
      { id: "P004", name: "조립", status: "completed" },
      { id: "P005", name: "검사", status: "current" },
      { id: "P006", name: "포장", status: "pending" },
    ],
    currentProcessIndex: 5,
  },
  {
    id: "WO-2025-005",
    itemCode: "PROD-005",
    itemName: "알루미늄 케이스",
    spec: "300x400",
    orderQuantity: 400,
    producedQuantity: 400,
    status: "completed",
    process: "P006",
    processName: "포장",
    equipment: "E005",
    equipmentName: "조립라인-01",
    startDate: "2025-01-01",
    dueDate: "2025-01-05",
    completedDate: "2025-01-05",
    priority: "high",
    accepted: true,
    processFlow: [
      { id: "P001", name: "절단", status: "completed" },
      { id: "P007", name: "프레스", status: "completed" },
      { id: "P008", name: "연마", status: "completed" },
      { id: "P003", name: "도장", status: "completed" },
      { id: "P004", name: "조립", status: "completed" },
      { id: "P005", name: "검사", status: "completed" },
      { id: "P006", name: "포장", status: "completed" },
    ],
    currentProcessIndex: 6,
  },
  // 공정 리턴 작업지시
  {
    id: "WO-2025-006",
    itemCode: "PROD-006",
    itemName: "리턴품 샤프트 F100",
    spec: "50x300",
    orderQuantity: 80,
    producedQuantity: 30,
    status: "in-progress",
    process: "P008",
    processName: "연마",
    equipment: null,
    equipmentName: null,
    startDate: "2025-01-03",
    dueDate: "2025-01-08",
    priority: "high",
    accepted: false,
    isReturn: true,
    returnReason: "검사 불합격 - 표면 조도 미달",
    returnFromProcess: "P005",
    returnFromProcessName: "검사",
    processFlow: [
      { id: "P001", name: "절단", status: "completed" },
      { id: "P002", name: "용접", status: "completed" },
      { id: "P008", name: "연마", status: "pending", isReturnTarget: true },
      { id: "P014", name: "연삭", status: "pending" },
      { id: "P016", name: "세척", status: "pending" },
      { id: "P005", name: "검사", status: "pending" },
    ],
    currentProcessIndex: 2,
  },
  // 분할접수 작업지시
  {
    id: "WO-2025-007",
    itemCode: "PROD-007",
    itemName: "분할접수 테스트 품목",
    spec: "100x200",
    orderQuantity: 200,
    producedQuantity: 50,
    acceptedQuantity: 50,
    remainingQuantity: 150,
    status: "in-progress",
    process: "P002",
    processName: "용접",
    equipment: "E003",
    equipmentName: "용접기-01",
    startDate: "2025-01-04",
    dueDate: "2025-01-10",
    priority: "normal",
    accepted: true,
    isPartialAccept: true,
    processFlow: [
      { id: "P001", name: "절단", status: "completed" },
      { id: "P002", name: "용접", status: "current" },
      { id: "P003", name: "도장", status: "pending" },
      { id: "P004", name: "조립", status: "pending" },
      { id: "P005", name: "검사", status: "pending" },
      { id: "P006", name: "포장", status: "pending" },
    ],
    currentProcessIndex: 1,
  },
];

// 상태 텍스트 매핑
export const STATUS_TEXT: Record<string, string> = {
  waiting: "대기",
  "in-progress": "진행중",
  completed: "완료",
};

