fix(shipping-notice,admin-schedule,frontend): 修复发货通知与后台排程的业务bug并优化各模块功能

1.  后端发货通知模块:
    清空重试任务旧状态避免残留,新增RPA进度回调接口
    优化库存匹配性能,修复人工确认校验逻辑与登录弹窗遮挡问题
    新增排程worker启动脚本,清理冗余环境配置与缓存查询开销
2.  前端后台排程模块:
    新增任务key归一化工具兼容历史格式,修复参数表单隐藏问题
    添加加载错误处理,更新多语言文案替换裸JSON占位符
This commit is contained in:
hugo committed 2026-08-26 22:05:25 +08:00
1 parent 1e5aedb9ed
commit 06c18b3c7c
81 files changed
+3301 -424

No files matched your search

@@ -610,6 +610,12 @@ def _build_stage_context(
}
# 冻结订单与库存匹配是不同事实:库存文件尚未准备好时,用户仍必须能核对
# 已冻结的预约号、料号和需求数量。禁止用“是否有匹配结果”决定订单行是否展示。
from app.services.shipping_notice.order_line_no_resolver import (
notice_line_field_id_map,
resolve_order_line_no_projection,
)
line_no_field_id_by_code = notice_line_field_id_map(task)
frozen_order_lines: list[dict[str, Any]] = []
preparation_lines: list[dict[str, Any]] = []
notice_lines = (
@@ -619,6 +625,11 @@ def _build_stage_context(
for line in notice_lines:
frozen_order_lines.append({
'line_key': getattr(line, 'line_key', None),
**resolve_order_line_no_projection(
field_values=dict(getattr(line, 'field_values_json', None) or {}),
field_id_by_code=line_no_field_id_by_code,
fallback_sequence=(int(line.position) + 1) if line.position is not None else None,
),
'reservation_id': getattr(line, 'reservation_id', None),
'part_number': getattr(line, 'part_number', None),
'required_qty': str(getattr(line, 'required_qty', None)) if getattr(line, 'required_qty', None) is not None else None,
@@ -660,6 +671,11 @@ def _build_stage_context(
shortage_qty = result.get('shortage_qty', source.get('shortage_qty', verification.get('shortage_qty')))
preparation_lines.append({
'line_key': getattr(line, 'line_key', None) or source.get('line_key'),
**resolve_order_line_no_projection(
field_values=dict(getattr(line, 'field_values_json', None) or {}) if line is not None else None,
field_id_by_code=line_no_field_id_by_code,
fallback_sequence=index + 1,
),
'reservation_id': result.get('reservation_id') or source.get('effective_reservation_id') or source.get('reservation_id') or getattr(line, 'reservation_id', None),
'part_number': result.get('part_number') or source.get('part_number') or getattr(line, 'part_number', None),
'required_qty': required_qty,
@@ -672,7 +688,7 @@ def _build_stage_context(
has_match_result = bool(current_match_rows or raw_rows or any(
row.get('matched_qty') is not None
or row.get('shortage_qty') is not None
or str(row.get('disposition') or '').lower() in {'ok', 'partial', 'shortage'}
or str(row.get('disposition') or '').lower() in {'ok', 'partial', 'shortage', 'released'}
for row in fact_rows if isinstance(row, dict)
))
gate = process_gate if isinstance(process_gate, dict) else {}
@@ -930,3 +946,31 @@ def _process_gate_user_summary_for_task(task: ShippingNotice) -> dict[str, Any]
)
def project_notice_available_actions(task: ShippingNotice) -> list[str]:
"""轻量投影单张 Notice 的已授权动作码,供货代上传面板按 business_no 展示单条菜单。
核心逻辑:与 ``build_task_ui_state`` 的 actions 同源(Gate 摘要 + 统一动作 + 已验证
Excel 下载授权),但**不**构建 stage_context / summary / steps / progress_nodes 等昂贵
重活。list_freight_notice_groups_for_task 会遍历同 PO 的多张 Notice,逐张调用完整
``build_task_ui_state`` 会造成 N 倍放大;此处只返回动作码,用于面板首屏即可。
Returns:
已启用动作码列表(primary + secondary + 已验证下载)。
"""
process_gate = _process_gate_user_summary_for_task(task)
actions = _unified_actions(process_gate=process_gate)
codes = [
str(item.get('code') or '').strip()
for item in [actions.get('primary'), *(actions.get('secondary') or [])]
if isinstance(item, dict) and item.get('enabled') is True and str(item.get('code') or '').strip()
]
# 与 build_task_ui_state 同款下载授权:Artifact 已验证后补入只读下载。
from app.services.shipping_notice.query_service import resolve_task_export_download
if resolve_task_export_download(task) is not None:
download_code = 'download_excel'
if download_code not in codes:
codes.append(download_code)
return codes