From 72004568e152140d85f0500b07f4d4dc3d415efb Mon Sep 17 00:00:00 2001 From: wangyu <823267011@qq.com> Date: Mon, 29 Jun 2026 14:44:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(entry):=20=E6=81=A2=E5=A4=8D=E5=85=A5?= =?UTF-8?q?=E5=8F=A3=E8=B7=9F=E8=B8=AA=E5=85=A8=E9=83=A8=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E5=B7=A5=E4=BD=8D=EF=BC=8C=E4=BF=AE=E5=A4=8D=E9=9E=8D=E5=BA=A7?= =?UTF-8?q?=E8=81=94=E5=8A=A8=E7=8A=B6=E6=80=81=E7=AB=9E=E4=BA=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 还原入口跟踪原有设备网格(2行):上卷小车/称重位/地辊/倒卷小车,仅上卷鞍座保留一个 - 移动可在所有入口设备间进行,仅「上卷鞍座」进入生产环节 - 修复 ensure_online 误将鞍座暂存计划回退导致卡死:移动到鞍座直接置生产中, ensure_online 排除 on_saddle 计划 Co-Authored-By: Claude Opus 4.8 --- backend/app/services/line_service.py | 32 +++++---- frontend/src/views/EntryTracking.vue | 99 ++++++++++++++-------------- 2 files changed, 66 insertions(+), 65 deletions(-) diff --git a/backend/app/services/line_service.py b/backend/app/services/line_service.py index b7aa844..b0ef04f 100644 --- a/backend/app/services/line_service.py +++ b/backend/app/services/line_service.py @@ -66,8 +66,10 @@ async def _saddle_plan(db: AsyncSession): async def ensure_online(db: AsyncSession): - """保证恰好一条 online(队首,最早录入的 ready)。""" - res = await db.execute(select(ProductionPlan).where(ProductionPlan.status == "online")) + """保证恰好一条 online(队首,最早录入的 ready)。鞍座上的计划不参与队列。""" + res = await db.execute( + select(ProductionPlan).where(ProductionPlan.status == "online", ProductionPlan.on_saddle != 1) + ) online = list(res.scalars()) if len(online) > 1: # 仅保留最早的一条为 online,其余回退 ready @@ -88,25 +90,27 @@ async def ensure_online(db: AsyncSession): async def move_to_saddle(db: AsyncSession, plan: ProductionPlan): - """把在线计划移动到上卷鞍座(staged,等待速度/投入生产)。""" + """把计划移动到上卷鞍座:上卷即获得速度 → 生产中。""" occupied = await _saddle_plan(db) if occupied and occupied.id != plan.id: raise ValueError("上卷鞍座已被占用,请等待当前钢卷生产完成") + now = datetime.now() plan.on_saddle = 1 plan.position = SADDLE_NAME - plan.saddle_at = datetime.now() - plan.run_started_at = None - plan.run_speed = 0 - plan.run_length_m = 0 - if plan.status not in ("producing", "produced"): - plan.status = "online" + plan.saddle_at = now + if plan.status != "produced": + plan.run_started_at = now + plan.run_speed = SIM_SPEED_M_MIN + plan.run_length_m = 0 + plan.status = "producing" await ensure_online(db) async def commit_plan(db: AsyncSession, plan: ProductionPlan): - """投入生产:鞍座计划有速度 → 生产中。""" + """投入生产(兜底):鞍座计划置为生产中。""" if plan.on_saddle != 1: await move_to_saddle(db, plan) + return if plan.run_started_at is None: plan.run_started_at = datetime.now() plan.run_speed = SIM_SPEED_M_MIN @@ -166,17 +170,11 @@ async def _produce(db: AsyncSession, plan: ProductionPlan): async def advance_saddle(db: AsyncSession): - """推进鞍座计划:staged 自动获得速度 → 生产中;累计长度到 2000m → 完成。""" + """推进鞍座计划:累计带头长度到 2000m → 生产完成。""" plan = await _saddle_plan(db) if not plan: return now = datetime.now() - # staged(在线且在鞍座)自动获得速度,模拟 PLC 速度信号 - if plan.status == "online" and plan.run_started_at is None: - plan.run_started_at = now - plan.run_speed = SIM_SPEED_M_MIN - plan.status = "producing" - await ensure_online(db) if plan.status == "producing" and plan.run_started_at: elapsed = (now - plan.run_started_at).total_seconds() plan.run_length_m = min(TARGET_LENGTH_M, (plan.run_speed or 0) / 60.0 * elapsed) diff --git a/frontend/src/views/EntryTracking.vue b/frontend/src/views/EntryTracking.vue index eaa1ae6..29b42e8 100644 --- a/frontend/src/views/EntryTracking.vue +++ b/frontend/src/views/EntryTracking.vue @@ -1,7 +1,7 @@