Files
track/backend/app/models/production_order.py
duxingchen e0c01a562f feat(models): Task/Product 模型扩充 + 4个Alembic迁移
Task 模型:
- 新增 received_at, completed_at, reject_reason, is_rework
- 新增 TaskRecord 模型 (remark + images JSON)
- 状态常量 PENDING/WIP/COMPLETED/REJECTED/ARCHIVED
- 全部时间字段改用北京时间 (get_beijing_time)

Product 模型:
- order_id → 可选; 新增 external_serial, current_location_id
- 新增 material_name/spec_model/category/material_type 快照字段
- 新增 overall_status (备货/生产/测试/维修/在库)

迁移:
- b2c3: HEX计数器Sequence + external_serial + order_id nullable
- c3d4: material快照4列
- d4e5: overall_status
- e5f6: task_records表
2026-08-05 14:00:23 +08:00

33 lines
1.1 KiB
Python

"""生产订单模型"""
import uuid
from datetime import datetime
from sqlalchemy import String, DateTime
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import Mapped, mapped_column
from app.models.base import Base
from app.core.time_utils import get_beijing_time
class ProductionOrder(Base):
__tablename__ = "production_orders"
id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True), primary_key=True, default=uuid.uuid4,
)
order_no: Mapped[str] = mapped_column(
String(64), unique=True, index=True, nullable=False, comment="订单编号",
)
customer_info: Mapped[str | None] = mapped_column(
String(500), nullable=True, comment="客户信息",
)
status: Mapped[str] = mapped_column(
String(50), nullable=False, default="pending", comment="订单状态",
)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), default=get_beijing_time, comment="创建时间",
)
def __repr__(self) -> str:
return f"<ProductionOrder {self.order_no}>"