feat: 日志管理 + 质保书生产过程数据图表
- 新增 PlanLog 模型与 /logs API;计划新增/移动/投入生产/生产完成/删除均记录 (时间/计划号/卷号/操作/状态变化/位置/操作人/说明) - 新增「日志管理」页面 + 路由 + 导航 - 质保书:把生产完成持久化的实时数据(process_data)按单位分组生成多组柱状图 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,17 @@ from app.models.plan import ProductionPlan
|
||||
from app.models.production import ProductionRecord
|
||||
from app.models.downtime import DowntimeRecord
|
||||
from app.models.line_state import LineState
|
||||
from app.models.plan_log import PlanLog
|
||||
|
||||
|
||||
async def add_plan_log(db: AsyncSession, plan, action, operator="系统",
|
||||
from_status=None, to_status=None, position=None, detail=None):
|
||||
"""写入一条计划操作/状态变更日志。"""
|
||||
db.add(PlanLog(
|
||||
plan_id=plan.id, plan_no=plan.plan_no, coil_no=plan.cold_coil_no,
|
||||
action=action, from_status=from_status, to_status=to_status,
|
||||
position=position, operator=operator, detail=detail,
|
||||
))
|
||||
|
||||
# ── 入口位置 ──
|
||||
SADDLE_NAME = "上卷鞍座" # 唯一会触发生产联动的位置
|
||||
@@ -151,6 +162,8 @@ async def _produce(db: AsyncSession, plan: ProductionPlan):
|
||||
process_data=plan.run_data,
|
||||
)
|
||||
db.add(rec)
|
||||
await add_plan_log(db, plan, "生产完成", "系统", from_status="producing", to_status="produced",
|
||||
position="产线", detail=f"带头到达 {TARGET_LENGTH_M:.0f} m,自动产出实绩")
|
||||
logger.info(f"生产完成并产生实绩: {plan.cold_coil_no or plan.plan_no}")
|
||||
|
||||
|
||||
@@ -222,6 +235,8 @@ async def auto_commit_saddle(db: AsyncSession):
|
||||
if saddle is None:
|
||||
return
|
||||
await commit_plan(db, saddle)
|
||||
await add_plan_log(db, saddle, "投入生产", "系统", from_status="online", to_status="producing",
|
||||
position="上卷鞍座→产线", detail="产线空闲,自动投入生产")
|
||||
|
||||
|
||||
async def tick(db: AsyncSession):
|
||||
|
||||
Reference in New Issue
Block a user