/**
 * 작업 이력 관리 타입 정의
 */

export type WorkType = 'inbound' | 'outbound' | 'transfer' | 'maintenance';
export type WorkStatus = 'pending' | 'in_progress' | 'completed' | 'cancelled';

export interface WorkHistory {
  id: number;
  work_number: string;
  work_date: Date;
  work_type: WorkType;
  vehicle_number?: string;
  driver_name?: string;
  origin?: string;
  destination?: string;
  cargo_name?: string;
  cargo_weight?: number;
  cargo_unit?: string;
  distance?: number;
  distance_unit?: string;
  status: WorkStatus;
  scheduled_time?: Date;
  start_time?: Date;
  end_time?: Date;
  estimated_arrival?: Date;
  actual_arrival?: Date;
  is_on_time?: boolean;
  delay_reason?: string;
  notes?: string;
  created_by?: string;
  created_at: Date;
  updated_at: Date;
  deleted_at?: Date;
}

export interface CreateWorkHistoryDto {
  work_type: WorkType;
  vehicle_number?: string;
  driver_name?: string;
  origin?: string;
  destination?: string;
  cargo_name?: string;
  cargo_weight?: number;
  cargo_unit?: string;
  distance?: number;
  distance_unit?: string;
  status?: WorkStatus;
  scheduled_time?: Date;
  estimated_arrival?: Date;
  notes?: string;
  created_by?: string;
}

export interface UpdateWorkHistoryDto {
  work_type?: WorkType;
  vehicle_number?: string;
  driver_name?: string;
  origin?: string;
  destination?: string;
  cargo_name?: string;
  cargo_weight?: number;
  cargo_unit?: string;
  distance?: number;
  distance_unit?: string;
  status?: WorkStatus;
  scheduled_time?: Date;
  start_time?: Date;
  end_time?: Date;
  estimated_arrival?: Date;
  actual_arrival?: Date;
  delay_reason?: string;
  notes?: string;
}

export interface WorkHistoryFilters {
  work_type?: WorkType;
  status?: WorkStatus;
  vehicle_number?: string;
  driver_name?: string;
  start_date?: Date;
  end_date?: Date;
  search?: string;
}

export interface WorkHistoryStats {
  today_total: number;
  today_completed: number;
  total_weight: number;
  total_distance: number;
  on_time_rate: number;
  type_distribution: {
    inbound: number;
    outbound: number;
    transfer: number;
    maintenance: number;
  };
}

export interface MonthlyTrend {
  month: string;
  total: number;
  completed: number;
  weight: number;
  distance: number;
}

export interface TopRoute {
  origin: string;
  destination: string;
  count: number;
  total_weight: number;
}

