feat(shipping-notice,receipt-report): 新增收料报表功能并优化发货通知流程
清理废弃的shipping xfa ocr automark相关代码和job配置 新增收料报表管理的前端页面、路由和侧边栏入口 新增后端收料报表配置接口、数据库模型和RPA脚本 优化发货通知流程的重试策略,将shipping相关job默认不自动重试 移除废弃的库存源确认相关逻辑,更新流程门禁规则 重构订单模板的值适配器模块,新增坐标OCR值适配器 清理前端shipping菜单和action的废弃选项 更新相关文档和测试用例,调整.gitignore忽略规则
This commit is contained in:
1 parent
260465b72d
commit
1b6483a4ea
466 files changed
+32115
-33796
No files matched your search
@@ -44,7 +44,6 @@ def test_unified_actions_deduplicates_gate_primary_action():
|
||||
{"code": "view_audit", "label": "查看审计", "kind": "view"},
|
||||
],
|
||||
},
|
||||
action_buttons=[],
|
||||
)
|
||||
|
||||
assert state["primary"]["code"] == "open_order_review"
|
||||
@@ -52,20 +51,47 @@ def test_unified_actions_deduplicates_gate_primary_action():
|
||||
|
||||
|
||||
def test_unified_action_shape_contains_gate_version_fields():
|
||||
"""统一动作 DTO 必须包含前端提交所需的版本与禁用字段。"""
|
||||
"""统一动作 DTO 必须包含前端提交所需的版本、分派与禁用字段。"""
|
||||
state = _unified_actions(
|
||||
process_gate={
|
||||
"lock_version": 7,
|
||||
"current_gate": {"evaluation_version": 3},
|
||||
"primary_action": {"code": "retry_inventory_matching", "label": "重新匹配"},
|
||||
"primary_action": {
|
||||
"code": "retry_inventory_matching",
|
||||
"label": "重新匹配",
|
||||
"dispatch": "mutation",
|
||||
},
|
||||
"action_presentation": [],
|
||||
},
|
||||
action_buttons=[],
|
||||
)
|
||||
assert state["primary"]["expected_gate_version"] == 3
|
||||
# 关键断言:前端必须按 Gate 声明的执行方式分派,不能按动作码硬编码。
|
||||
assert state["primary"]["dispatch"] == "mutation"
|
||||
assert "disabled_reason" in state["primary"]
|
||||
|
||||
|
||||
def test_unified_actions_preserve_backend_surface_without_action_code_fallback():
|
||||
"""UI State 只透传动作来源声明的位置,不再按下载动作码补默认工作面。"""
|
||||
state = _unified_actions(
|
||||
process_gate={
|
||||
"primary_action": {
|
||||
"code": "mark_manual_uploaded",
|
||||
"label": "登记人工上传",
|
||||
"target_surface": "upload_complete",
|
||||
},
|
||||
"action_presentation": [{
|
||||
"code": "download_excel",
|
||||
"label": "下载发货 Excel",
|
||||
"target_surface": "upload_complete",
|
||||
"target_anchor": "excel_artifact",
|
||||
}],
|
||||
},
|
||||
)
|
||||
assert state["primary"]["target_surface"] == "upload_complete"
|
||||
assert state["secondary"][0]["target_surface"] == "upload_complete"
|
||||
assert state["secondary"][0]["target_anchor"] == "excel_artifact"
|
||||
|
||||
|
||||
def test_build_task_ui_state_summary_has_required_keys(app) -> None:
|
||||
"""summary 必须包含 STP 可解释字段全集。"""
|
||||
with app.app_context():
|
||||
@@ -96,7 +122,7 @@ def test_task_ui_state_stage_context_is_opt_in(app) -> None:
|
||||
|
||||
|
||||
def test_build_task_ui_state_exposes_four_business_stages_and_unified_actions(app) -> None:
|
||||
"""业务 UI 只消费四阶段与后端统一 actions,不再要求前端解释旧七步。"""
|
||||
"""没有 Gate 的旧 checkpoint 仅表达状态,不能再直接产生可写 UI 动作。"""
|
||||
with app.app_context():
|
||||
task = ShippingNotice(
|
||||
task_no="SN-UI-STAGE-ACTIONS",
|
||||
@@ -108,9 +134,8 @@ def test_build_task_ui_state_exposes_four_business_stages_and_unified_actions(ap
|
||||
assert state["stage"]["code"] == "order_review"
|
||||
assert state["stage"]["index"] == 2
|
||||
assert state["stage"]["total"] == 4
|
||||
assert state["actions"]["primary"] is not None
|
||||
assert state["actions"]["primary"]["code"] == "confirm"
|
||||
assert all("code" in item and "kind" in item for item in state["actions"]["secondary"])
|
||||
assert state["actions"]["primary"] is None
|
||||
assert state["actions"]["secondary"] == []
|
||||
|
||||
|
||||
def test_build_task_ui_state_exposes_backend_owned_lifecycle_entries(app) -> None:
|
||||
@@ -274,7 +299,7 @@ def test_entry_surface_export_ready_is_task_workbench(app) -> None:
|
||||
]
|
||||
# 关键断言:没有可验证 Artifact 时,遗留 export_file_name 不得生成下载按钮。
|
||||
assert "download_excel" not in button_ids
|
||||
assert "mark_manual_uploaded" in button_ids
|
||||
assert "mark_manual_uploaded" not in button_ids
|
||||
|
||||
|
||||
def test_task_ui_state_only_exposes_download_for_resolved_artifact(app, monkeypatch) -> None:
|
||||
@@ -551,6 +576,52 @@ def test_workspace_inventory_download_requires_owned_active_file(app, client, tm
|
||||
assert forbidden.status_code == 404
|
||||
|
||||
|
||||
def test_workspace_line_inventory_download_requires_current_line_reference(app, client, tmp_path) -> None:
|
||||
"""行内下载只能读取当前匹配事实引用的库存文件,不能按文件号探测同任务其他来源。"""
|
||||
from app.models import ShippingInventoryFile, ShippingNoticeLineInventoryMatch
|
||||
|
||||
with app.app_context():
|
||||
owner = User(username='line-inventory-download-owner', email='line-inventory-download-owner@example.com')
|
||||
db.session.add(owner)
|
||||
db.session.flush()
|
||||
allowed_path = tmp_path / 'crane.xlsx'
|
||||
denied_path = tmp_path / 'dbs.xlsx'
|
||||
allowed_path.write_bytes(b'crane-content')
|
||||
denied_path.write_bytes(b'dbs-content')
|
||||
task = ShippingNotice(task_no='SN-LINE-INVENTORY-DOWNLOAD', user_id=owner.id, source_type='manual')
|
||||
allowed_file = ShippingInventoryFile(
|
||||
inventory_file_no='SIF-LINE-CRANE', storage_path=str(allowed_path),
|
||||
source_file_name='crane.xlsx', source_code='CRANE', snapshot_status='ready',
|
||||
)
|
||||
denied_file = ShippingInventoryFile(
|
||||
inventory_file_no='SIF-LINE-DBS', storage_path=str(denied_path),
|
||||
source_file_name='dbs.xlsx', source_code='DBS', snapshot_status='ready',
|
||||
)
|
||||
db.session.add_all([task, allowed_file, denied_file])
|
||||
db.session.flush()
|
||||
db.session.add(ShippingNoticeLineInventoryMatch(
|
||||
task_id=task.id, line_key='line-crane', line_index=0,
|
||||
inventory_snapshot_id=allowed_file.id, matched_file_no=allowed_file.inventory_file_no,
|
||||
inventory_source_code='CRANE', match_result='not_found', inventory_status='ready', is_current=True,
|
||||
))
|
||||
db.session.commit()
|
||||
headers = {'Authorization': f'Bearer {issue_local_access_token(owner)}'}
|
||||
|
||||
allowed = client.get(
|
||||
'/api/workspace/shipping-tasks/SN-LINE-INVENTORY-DOWNLOAD/inventory-files/SIF-LINE-CRANE',
|
||||
headers=headers,
|
||||
)
|
||||
assert allowed.status_code == 200
|
||||
assert allowed.data == b'crane-content'
|
||||
assert 'crane.xlsx' in str(allowed.headers.get('Content-Disposition') or '')
|
||||
|
||||
denied = client.get(
|
||||
'/api/workspace/shipping-tasks/SN-LINE-INVENTORY-DOWNLOAD/inventory-files/SIF-LINE-DBS',
|
||||
headers=headers,
|
||||
)
|
||||
assert denied.status_code == 404
|
||||
|
||||
|
||||
def test_stage_context_keeps_legacy_evidence_when_structured_row_is_partial(app) -> None:
|
||||
"""结构化事实字段为空时,历史/STP 证据仍应补齐通知准备行。"""
|
||||
with app.app_context():
|
||||
|
||||
Reference in new issue
Block a user