from pydantic import BaseModel
from typing import Optional
from datetime import datetime


class ProductionRecordCreate(BaseModel):
    coil_no: str
    plan_id: Optional[int] = None
    shift: Optional[str] = None
    shift_date: Optional[datetime] = None
    start_time: Optional[datetime] = None
    end_time: Optional[datetime] = None
    process_length: Optional[float] = None
    process_weight: Optional[float] = None
    avg_speed: Optional[float] = None
    max_speed: Optional[float] = None
    acid_consumption: Optional[float] = None
    inlet_thickness: Optional[float] = None
    outlet_thickness: Optional[float] = None
    inlet_width: Optional[float] = None
    quality_grade: Optional[str] = None
    operator: Optional[str] = None
    remark: Optional[str] = None


class ProductionRecordUpdate(BaseModel):
    shift: Optional[str] = None
    end_time: Optional[datetime] = None
    process_length: Optional[float] = None
    process_weight: Optional[float] = None
    avg_speed: Optional[float] = None
    acid_consumption: Optional[float] = None
    quality_grade: Optional[str] = None
    remark: Optional[str] = None


class ProductionRecordOut(BaseModel):
    id: int
    coil_no: str
    plan_id: Optional[int]
    shift: Optional[str]
    shift_date: Optional[datetime]
    start_time: Optional[datetime]
    end_time: Optional[datetime]
    process_length: Optional[float]
    process_weight: Optional[float]
    avg_speed: Optional[float]
    max_speed: Optional[float]
    acid_consumption: Optional[float]
    inlet_thickness: Optional[float]
    outlet_thickness: Optional[float]
    quality_grade: Optional[str]
    operator: Optional[str]
    created_at: datetime

    class Config:
        from_attributes = True
