feat(in-transit-transfer): 自动调拨联动收料就绪并分层来源错误
- 调度整合:退役 in_transit_receipt_file_job,收料归档收敛 shipping_receipt_rpa_archive,排程注册表统一 - 自动调拨 Job:调拨前确保各来源当日收料文件就绪(缺失自动触发收料 RPA),严格等量匹配后生成 ERP 调拨单 - worker 手动唤醒:排程工作台支持手动唤醒与 runs 透视,heartbeat 协议同步 - 收料缺失幸存 T2:parse_failed 状态落库(迁移 q4c5) - 来源错误分层与 stale 时钟换源:改挂 inventory_checked_at 库存查得时刻,展示阈值与执行门禁解耦(迁移 t5a6) - 新增 wecom_sender 企微通知:每非空 Run 汇总一条,通知失败不影响 ERP 结果 - 同步排程工作台/调拨卡片前端、chat/admin 文案四语言、RPA 脚本与测试全家
This commit is contained in:
1 parent
993e581135
commit
abf3d48927
144 files changed
+10161
-2132
No files matched your search
@@ -0,0 +1,106 @@
|
||||
"""
|
||||
backend/tests/test_receipt_excel_empty.py
|
||||
|
||||
用途:收料 Excel「有表头无明细」判空回归;钉死标题行不得当表头。
|
||||
依赖:openpyxl、scripts/freight_rpa/receipt/receipt_excel_empty。
|
||||
逻辑:构造 DSV 标题+表头无数据簿;复制生产 drop 样例断言 empty。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import shutil
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from openpyxl import Workbook
|
||||
|
||||
_REPO_ROOT = Path(__file__).resolve().parents[2]
|
||||
_RECEIPT_DIR = _REPO_ROOT / 'scripts' / 'freight_rpa' / 'receipt'
|
||||
if str(_RECEIPT_DIR) not in sys.path:
|
||||
sys.path.insert(0, str(_RECEIPT_DIR))
|
||||
|
||||
from receipt_excel_empty import ( # noqa: E402
|
||||
NoReceiptDataError,
|
||||
enforce_receipt_excel_not_empty,
|
||||
receipt_excel_has_detail_rows,
|
||||
)
|
||||
|
||||
_DROP_SAMPLE = (
|
||||
_REPO_ROOT
|
||||
/ 'backend'
|
||||
/ 'data'
|
||||
/ 'freight_rpa'
|
||||
/ 'receipt'
|
||||
/ 'drop'
|
||||
/ 'receipt_RUN202609290016193A2E_DSV360_AWSBI_BYAWSPRD01_NA_20260929002248.xlsx'
|
||||
)
|
||||
|
||||
|
||||
def _write_dsv_title_header_only(path: Path) -> None:
|
||||
"""写入与生产一致的标题行 + 表头行、无明细。"""
|
||||
workbook = Workbook()
|
||||
sheet = workbook.active
|
||||
assert sheet is not None
|
||||
sheet.title = 'LognetAWSReceiptDetail3lv'
|
||||
sheet.append(['AWS Receipt Detail', '1 | + | | | + | + | CBIS-0000000100 | | | '])
|
||||
sheet.append([
|
||||
'Supplier',
|
||||
'External\nASN #',
|
||||
'WMS\nReceipt #',
|
||||
'Mode of\nTransport',
|
||||
'Carrier\nCode',
|
||||
'Waybill #',
|
||||
'Type',
|
||||
'ASN Status',
|
||||
'Date\nExpected',
|
||||
'Date\nReceived',
|
||||
'External\nLine #',
|
||||
'Supplier ID',
|
||||
'Carton ID',
|
||||
'Pallet ID',
|
||||
'AWS Sku',
|
||||
])
|
||||
workbook.save(path)
|
||||
|
||||
|
||||
def test_title_row_must_not_count_as_detail(tmp_path: Path):
|
||||
"""
|
||||
标题含 receipt 时旧逻辑会把真表头当成明细 → 误 success。
|
||||
|
||||
[断言意图] 仅标题+表头必须判定为无明细(False),enforce 抛 no_receipt_data。
|
||||
"""
|
||||
path = tmp_path / 'header_only.xlsx'
|
||||
_write_dsv_title_header_only(path)
|
||||
assert receipt_excel_has_detail_rows(path) is False
|
||||
with pytest.raises(NoReceiptDataError, match='no_receipt_data'):
|
||||
enforce_receipt_excel_not_empty(path)
|
||||
|
||||
|
||||
def test_header_plus_data_row_is_not_empty(tmp_path: Path):
|
||||
"""有表头且下一行有业务单元格时不得 empty。"""
|
||||
path = tmp_path / 'with_data.xlsx'
|
||||
_write_dsv_title_header_only(path)
|
||||
from openpyxl import load_workbook
|
||||
|
||||
workbook = load_workbook(path)
|
||||
sheet = workbook.active
|
||||
assert sheet is not None
|
||||
sheet.append(['Well Trust', 'HOX1', '0001', 'O', 'KN', 'WB1', 'Inbound', 'Closed', '01/01/2026', '', '0010', 'CBIS', '', '', 'SKU-1'])
|
||||
workbook.save(path)
|
||||
assert receipt_excel_has_detail_rows(path) is True
|
||||
enforce_receipt_excel_not_empty(path)
|
||||
|
||||
|
||||
@pytest.mark.skipif(not _DROP_SAMPLE.is_file(), reason='production drop sample not present')
|
||||
def test_production_header_only_sample_is_empty(tmp_path: Path):
|
||||
"""
|
||||
生产样例 receipt_RUN202609290016193A2E_*_BYAWSPRD01_* 仅表头却曾 success。
|
||||
|
||||
[断言意图] 复制该文件后必须判 empty / no_receipt_data。
|
||||
"""
|
||||
target = tmp_path / _DROP_SAMPLE.name
|
||||
shutil.copy2(_DROP_SAMPLE, target)
|
||||
assert receipt_excel_has_detail_rows(target) is False
|
||||
with pytest.raises(NoReceiptDataError, match='no_receipt_data'):
|
||||
enforce_receipt_excel_not_empty(target)
|
||||
Reference in new issue
Block a user