63 lines
1.6 KiB
Python
63 lines
1.6 KiB
Python
"""缺料审批 Schema
|
||
|
||
核心原则:
|
||
- 所有写操作仅在 pms_db 中进行
|
||
- 绝对禁止对 inventory_db 进行任何写操作
|
||
- 物料信息仅从 inventory_db 查询获取,不进行写操作
|
||
"""
|
||
from pydantic import BaseModel, Field
|
||
from datetime import datetime
|
||
from app.models.production import ApprovalStatus
|
||
|
||
|
||
class ApprovalCreate(BaseModel):
|
||
"""创建缺料审批申请"""
|
||
work_order_id: int = Field(..., description="工单ID")
|
||
missing_material_id: int = Field(..., description="缺失物料ID")
|
||
required_qty: int = Field(gt=0, description="需要补充的数量")
|
||
reason: str | None = Field(None, max_length=500, description="申请原因")
|
||
|
||
|
||
class ApprovalStatusUpdate(BaseModel):
|
||
"""审批状态更新"""
|
||
status: ApprovalStatus = Field(
|
||
...,
|
||
description="新状态(APPROVED 或 REJECTED)"
|
||
)
|
||
|
||
|
||
class ApprovalResponse(BaseModel):
|
||
"""基础缺料审批响应"""
|
||
id: int
|
||
work_order_id: int
|
||
missing_material_id: int
|
||
required_qty: int
|
||
reason: str | None
|
||
status: ApprovalStatus
|
||
created_at: datetime
|
||
|
||
class Config:
|
||
from_attributes = True
|
||
|
||
|
||
class ApprovalDetailResponse(BaseModel):
|
||
"""带详情的缺料审批响应
|
||
|
||
包含:
|
||
- 工单编号
|
||
- 物料名称
|
||
- 其他基本信息
|
||
"""
|
||
id: int
|
||
work_order_id: int
|
||
work_order_no: str = Field(..., description="工单编号")
|
||
missing_material_id: int
|
||
material_name: str = Field(..., description="物料名称")
|
||
required_qty: int
|
||
reason: str | None
|
||
status: ApprovalStatus
|
||
created_at: datetime
|
||
|
||
class Config:
|
||
from_attributes = True
|