feat(shipping-notice): 增强发货通知与审计功能,支持敏感数据控制与哈希链校验
- 更新发货通知工具 API,剥离不可信的操作人身份字段,确保审计安全 - 引入审计事件的哈希链校验机制,支持数据完整性验证 - 增强订单抽取与审计功能,支持敏感快照的访问控制 - 更新相关模型与服务,确保新功能的完整性与可追溯性 - 完善文档与代码注释,反映新的业务逻辑与审计要求
This commit is contained in:
1 parent
95cdfe66b0
commit
d0fe084999
225 files changed
+25923
-6653
No files matched your search
@@ -45,6 +45,7 @@ def test_build_task_ui_state_summary_has_required_keys(app) -> None:
|
||||
assert set(_REQUIRED_SUMMARY_KEYS).issubset(state["summary"].keys())
|
||||
assert state["checkpoint"] == CP_PARSE_REVIEW
|
||||
assert state["checkpoint_kind"] == "must_human"
|
||||
assert "stp_facts" not in state["summary"]
|
||||
|
||||
|
||||
def test_entry_surface_parse_review_is_review_workbench(app) -> None:
|
||||
@@ -62,7 +63,7 @@ def test_entry_surface_parse_review_is_review_workbench(app) -> None:
|
||||
|
||||
|
||||
def test_entry_surface_export_ready_is_task_workbench(app) -> None:
|
||||
"""Excel 待人工上传应进入任务处理工作台。"""
|
||||
"""Excel 待人工上传登记应进入任务处理工作台(下载 + 登记)。"""
|
||||
with app.app_context():
|
||||
task = ShippingTask(
|
||||
task_no="SN-UI-EXPORT",
|
||||
@@ -75,3 +76,98 @@ def test_entry_surface_export_ready_is_task_workbench(app) -> None:
|
||||
assert state["checkpoint"] == CP_EXPORT_READY
|
||||
assert state["checkpoint_kind"] == "wait_manual_upload"
|
||||
assert state["summary"]["entry_surface"] == "task_workbench"
|
||||
assert state["summary"].get("pause_reason_code") == "wait_manual_upload"
|
||||
assert "登记凭据" in str(state["summary"].get("pause_reason") or "")
|
||||
button_ids = [b.get("id") for b in (state.get("action_buttons") or [])]
|
||||
assert "download_excel" in button_ids
|
||||
assert "mark_manual_uploaded" in button_ids
|
||||
|
||||
|
||||
def test_stp_facts_candidates_frozen_projected(app) -> None:
|
||||
"""多候选冻结任务须投影 stp_facts.frozen_candidate_codes。"""
|
||||
with app.app_context():
|
||||
task = ShippingTask(
|
||||
task_no="SN-UI-STP-FROZEN",
|
||||
process_status="waiting_inventory",
|
||||
source_type="manual",
|
||||
inventory_source_status="candidates_frozen",
|
||||
inventory_source_method="stp_build_freeze",
|
||||
step_payload_json={
|
||||
"line_inventory_candidates": {
|
||||
"source_codes": ["DBS_DUB", "DBS_RTM"],
|
||||
"frozen_at": "build",
|
||||
},
|
||||
},
|
||||
)
|
||||
state = build_task_ui_state(task)
|
||||
facts = state["summary"]["stp_facts"]
|
||||
assert facts["inventory_source_status"] == "candidates_frozen"
|
||||
assert facts["frozen_candidate_codes"] == ["DBS_DUB", "DBS_RTM"]
|
||||
assert facts["multi_source_excel_block"] is False
|
||||
|
||||
|
||||
def test_stp_facts_projects_line_resolutions(app) -> None:
|
||||
"""stp_facts 须包含逐行 Reservation/料号/实际库存源/文件证据。"""
|
||||
with app.app_context():
|
||||
task = ShippingTask(
|
||||
task_no="SN-UI-STP-LINES",
|
||||
process_status="matched",
|
||||
source_type="manual",
|
||||
match_status="fulfillable",
|
||||
inventory_source_status="resolved",
|
||||
inventory_source_code="DBS_DUB",
|
||||
inventory_source_method="stp_line_match",
|
||||
step_payload_json={
|
||||
"line_inventory_resolutions": [
|
||||
{
|
||||
"line_index": 0,
|
||||
"disposition": "ok",
|
||||
"effective_reservation_id": "3000092917",
|
||||
"part_number": "PN-1",
|
||||
"resolved_inventory_source_code": "DBS_DUB",
|
||||
"inventory_file_no": "INV-1",
|
||||
"inventory_row_ref": {
|
||||
"reservation_id": "3000092917",
|
||||
"part_number": "PN-1",
|
||||
"source_code": "DBS_DUB",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
)
|
||||
state = build_task_ui_state(task)
|
||||
rows = state["summary"]["stp_facts"]["line_resolutions"]
|
||||
assert rows[0]["effective_reservation_id"] == "3000092917"
|
||||
assert rows[0]["part_number"] == "PN-1"
|
||||
assert rows[0]["resolved_inventory_source_code"] == "DBS_DUB"
|
||||
assert rows[0]["inventory_file_no"] == "INV-1"
|
||||
|
||||
|
||||
def test_stp_facts_multi_source_excel_block_legacy_payload(app) -> None:
|
||||
"""历史 multi_source_excel_block 载荷仍覆盖 pause_reason(兼容旧任务)。"""
|
||||
from app.services.shipping_notice.constants import RS_SHORTAGE_REVIEW
|
||||
|
||||
with app.app_context():
|
||||
task = ShippingTask(
|
||||
task_no="SN-UI-STP-MULTI",
|
||||
process_status="matched",
|
||||
review_status=RS_SHORTAGE_REVIEW,
|
||||
pending_human_reason="shortage",
|
||||
source_type="manual",
|
||||
match_status="fulfillable",
|
||||
inventory_source_status="candidates_frozen",
|
||||
inventory_source_method="stp_line_match",
|
||||
step_payload_json={
|
||||
"multi_source_excel_block": True,
|
||||
"resolved_ok_source_codes": ["DBS_DUB", "DBS_RTM"],
|
||||
"line_inventory_resolutions": [
|
||||
{"line_index": 0, "disposition": "ok", "resolved_inventory_source_code": "DBS_DUB"},
|
||||
{"line_index": 1, "disposition": "ok", "resolved_inventory_source_code": "DBS_RTM"},
|
||||
],
|
||||
},
|
||||
)
|
||||
state = build_task_ui_state(task)
|
||||
summary = state["summary"]
|
||||
assert summary["pause_reason_code"] == "multi_source_excel_block"
|
||||
assert summary["stp_facts"]["multi_source_excel_block"] is True
|
||||
assert summary["entry_surface"] == "task_workbench"
|
||||
Reference in new issue
Block a user