feat(shipping-notice): 通知准备履约字段就地编辑并修复缺口复核入口

- 编辑闸门翻转为状态制:Excel 生成前+无活动 Attempt 即可编辑,原因不强制(审计自动记录操作人与变更)
- 修复 Decimal 字段人工编辑无法持久化(单字段+整行替换两路径)
- 预约注册与核验比对改读有效订单值视图,消除编辑后重匹配 RESERVATION_MISMATCH 阻断
- 通知准备值列改读有效视图:保存即显新值,匹配结果列保持最近一轮事实
- 行编辑入口为更多操作列编辑按钮;编辑态替换为保存/取消;库存源行内改选随保存统一提交
- 展示态动作收纳进更多菜单(Teleport 浮层,防表格 overflow 裁剪)
- 修复缺口复核投影键错位(has_shortage 恒 False 致入口隐藏)并补齐行级结案入口
- 缺口放行改行内补录条(菜单放行或缺 N 项徽标展开,确认放行/取消收起),放行原因可选
- i18n 四语言;technical.md/funclist.md 语义文档同步
This commit is contained in:
hugo committed 2026-09-18 14:59:39 +08:00
1 parent 4d879dd8ea
commit eed1068ae3
29 files changed
+1981 -218

No files matched your search

@@ -11,7 +11,9 @@ services/shipping_notice/ui_state.py
Gate 摘要经 Notice.order_task_id→OT 查 Execution(禁止用 Notice.id);
五阶段 processing_stage 同样经 Notice→OT.stage(Notice 无 stage 列),
禁止仅靠 Gate 兜底把 order_freeze 误映射为订单复核;
stage_context.preparation 以 Snapshot 行 + 当前 Match 投影(Notice 经 order_task_id→OT),
stage_context.preparation 值列(预约号/料号/需求数量)有效值优先(快照 + 已接受修正,
经 effective_line_facts_for_notice),无有效值时回退快照列;匹配结果列仍以 Snapshot 行
+ 当前 Match 投影诚实反映最近一轮(Notice 经 order_task_id→OT),
行级拆 selected_source_code(CandidateSet 取数目标)与 source_code(Match 正式源);
短缺行复用放行模板字段;匹配成功无短缺下发 can_fulfill_complete_line;
下发 source_options 与 capabilities(阶段能力,供右卡点击 stageCapabilityBypass);
@@ -830,6 +832,7 @@ def _build_stage_context(
_shortage_release_required_fields,
)
from app.services.shipping_notice.upload_attempt_service import latest_export_artifact
from app.services.shipping_notice.effective_order_view import effective_line_facts_for_notice
facts = stp_facts if isinstance(stp_facts, dict) else {}
# [STEP 1] Snapshot/Match/Candidate 归属 OT;Notice 详情入口必须经 order_task_id 解析,
@@ -846,6 +849,19 @@ def _build_stage_context(
if snapshot is not None else []
)
match_by_snapshot_line_id = load_current_match_facts_by_task(getattr(order_task, 'id', None))
# [BE-有效视图] 值列消费有效订单值(快照 + 已接受修正):保存即显新值,
# 匹配结果列仍读当前匹配事实,诚实反映最近一轮匹配结论。
# 全循环只算一次,行内按 snapshot_line_id 取用;无冻结快照(如未绑定 OT 的 Notice)
# 保持空映射,行级回退快照列。有效视图解析失败(如历史/合成数据缺 Schema 版本)
# 与 ODM 投影同款降级:不阻断工作台渲染,值列退回快照列(此时有效值=快照值)。
effective_facts: dict[int, dict[str, Any]] = {}
if order_task is not None and getattr(order_task, 'order_snapshot_id', None):
try:
effective_facts = effective_line_facts_for_notice(order_task)
except Exception: # 遗留/合成快照缺 Schema 版本等:回退冻结列展示
from flask import current_app
current_app.logger.warning('effective order view resolution failed; falling back to frozen columns', exc_info=True)
effective_facts = {}
# [STEP] 与 Case 投影同源:库存 RPA 运行态只查一次 Attempt(请求内 memo),再传入各行纯函数。
inventory_rpa_running = inventory_rpa_is_running(order_task)
candidate_codes_by_line_no: dict[int, list[str]] = {}
@@ -869,17 +885,38 @@ def _build_stage_context(
for snapshot_line in snapshot_lines:
qty_text = str(snapshot_line.qty) if snapshot_line.qty is not None else None
line_no = int(snapshot_line.line_no) if snapshot_line.line_no is not None else None
# [BE-有效视图] 冻结订单行值列有效值优先(预约号/料号/需求数量):行内按
# snapshot_line_id 取有效事实,取不到(None)时回退冻结快照列;键名与前端
# 契约稳定不动(shipping.api.types.ts ShippingOrderFrozenLine)。
eff = effective_facts.get(int(snapshot_line.id)) or {}
frozen_order_lines.append({
'snapshot_line_id': int(snapshot_line.id),
'line_no': line_no,
'reservation_id': snapshot_line.reservation_id,
'part_number': snapshot_line.part_number,
'required_qty': qty_text,
'reservation_id': eff.get('reservation_id') if eff.get('reservation_id') is not None else snapshot_line.reservation_id,
'part_number': eff.get('part_number') if eff.get('part_number') is not None else snapshot_line.part_number,
'required_qty': str(eff['qty']) if eff.get('qty') is not None else qty_text,
})
fact = match_by_snapshot_line_id.get(int(snapshot_line.id))
required_qty = (fact or {}).get('required_qty')
# [BE-有效视图] 需求数量:有效事实 → 匹配事实 → 快照列(Decimal 需 str 化)。
required_qty = (
str(eff['qty'])
if eff.get('qty') is not None
else (fact or {}).get('required_qty')
)
if required_qty is None:
required_qty = qty_text
# [BE-有效视图] 预约号/料号:有效事实 → 匹配事实 → 快照列;保存修正后即使
# 匹配事实未刷新,prep 覆盖合并也立即显示新值。
reservation_id_value = (
eff.get('reservation_id')
if eff.get('reservation_id') is not None
else (fact or {}).get('reservation_id') or snapshot_line.reservation_id
)
part_number_value = (
eff.get('part_number')
if eff.get('part_number') is not None
else (fact or {}).get('part_number') or snapshot_line.part_number
)
inv_view = project_line_inventory_view(
has_formal_ot=has_formal_ot,
fact=fact,
@@ -934,8 +971,8 @@ def _build_stage_context(
field_id_by_code,
'customer_po_line_no',
),
'reservation_id': (fact or {}).get('reservation_id') or snapshot_line.reservation_id,
'part_number': (fact or {}).get('part_number') or snapshot_line.part_number,
'reservation_id': reservation_id_value,
'part_number': part_number_value,
'required_qty': required_qty,
'available_qty': inv_view.get('available_qty'),
'shortage_qty': inv_view.get('shortage_qty'),