Files
pickling-mes/backend/app/models/plan.py
wangyu 9cf422ef0d feat(plan): 计划详细面板 + 来料重量/外径/分卷重量 + 在线/生产中状态机 + 入口移动 + 上次模板回填
- backend: plan 增加 incoming_weight/incoming_od/split_weights(JSON) 字段及迁移
- backend: GET /plan/last-template 返回最近一条计划的工艺字段用于新增回填(多端共享)
- backend: PATCH /plan/{id}/start 设为 producing,强制单卷在产(其他 producing 回退 online)
- backend: 生成实绩时按卷号自动把对应计划状态置为 produced
- frontend: 新增计划默认状态 online;新增时调用 last-template 自动回填
- frontend: Plan 表格行点击展开 计划详细 面板(按截图布局)
- frontend: Plan 行操作增加「移动」(ready/online → producing)
- frontend: 物料跟踪页加 在线计划队列 + 入口移动按钮,显示当前生产中卷
- frontend: 计划弹窗新增 轧制模式/来料重量/来料外径/1-6#分卷重量
2026-06-21 23:42:22 +08:00

50 lines
2.3 KiB
Python

from sqlalchemy import Column, Integer, String, Float, DateTime, Text, func, JSON
from app.database import Base
# 计划状态:准备好/在线/生产中/产出
PLAN_STATUS = ("ready", "online", "producing", "produced")
class ProductionPlan(Base):
"""生产计划"""
__tablename__ = "production_plans"
id = Column(Integer, primary_key=True, index=True)
plan_no = Column(String(30), unique=True, nullable=False, index=True, comment="计划号")
plan_date = Column(DateTime, nullable=False, comment="计划时间")
status = Column(String(20), default="ready", comment="状态: ready/online/producing/produced")
# 新结构:卷号 / 钢种 / 厚宽 / 偏差 / 工艺
cold_coil_no = Column(String(30), index=True, comment="冷卷号")
hot_coil_no = Column(String(30), index=True, comment="热卷号")
steel_grade = Column(String(30), comment="钢种")
incoming_thickness = Column(Float, comment="来料厚度 mm")
product_thickness = Column(Float, comment="产品厚度 mm")
deviation_upper = Column(Float, comment="偏差上限 mm")
deviation_lower = Column(Float, comment="偏差下限 mm")
incoming_width = Column(Float, comment="来料宽度 mm")
product_width = Column(Float, comment="产品宽度 mm")
packaging_req = Column(String(30), comment="包装要求")
trim_req = Column(String(30), comment="切边要求")
rolling_mode = Column(String(30), comment="轧制模式")
coil_diameter = Column(Float, comment="卷径 mm")
split_count = Column(Integer, default=1, comment="分卷数")
next_process = Column(String(30), comment="下工序")
incoming_weight = Column(Float, comment="来料重量 t")
incoming_od = Column(Float, comment="来料外径 mm")
split_weights = Column(JSON, comment="分卷重量 [t,...]")
# 兼容历史字段
shift = Column(String(10), comment="班次")
plan_quantity = Column(Integer, default=0)
plan_weight = Column(Float, default=0)
actual_quantity = Column(Integer, default=0)
actual_weight = Column(Float, default=0)
spec_range = Column(String(50))
priority = Column(Integer, default=5)
remark = Column(Text)
created_by = Column(String(50))
created_at = Column(DateTime, server_default=func.now())
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())