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
@@ -90,27 +90,35 @@ def _patch_unified_wecom(monkeypatch, *, enabled_events: bool):
|
||||
textcards: list[tuple[str, str]] = []
|
||||
media_uploads: list[str] = []
|
||||
file_sends: list[str] = []
|
||||
notify_mod = 'app.services.integrations.wecom.notify'
|
||||
|
||||
def _fake_send_textcard(_userid, _title, description, _jump_url):
|
||||
textcards.append((_title, description))
|
||||
return {'errcode': 0}
|
||||
|
||||
monkeypatch.setattr('app.services.wecom_notify.send_wecom_textcard_message', _fake_send_textcard)
|
||||
monkeypatch.setattr(f'{notify_mod}.send_wecom_textcard_message', _fake_send_textcard)
|
||||
if enabled_events:
|
||||
monkeypatch.setattr('app.services.wecom_notify._get_enabled_events', lambda: {'schedule_completed'})
|
||||
monkeypatch.setattr('app.services.wecom_notify.upload_wecom_temp_media', lambda _data, filename: media_uploads.append(filename) or f'media-{len(media_uploads)}')
|
||||
monkeypatch.setattr('app.services.wecom_notify.send_wecom_file_message', lambda _userid, media_id: file_sends.append(media_id) or {'errcode': 0})
|
||||
monkeypatch.setattr(f'{notify_mod}._get_enabled_events', lambda: {'schedule_completed'})
|
||||
monkeypatch.setattr(
|
||||
f'{notify_mod}.upload_wecom_temp_media',
|
||||
lambda _data, filename: media_uploads.append(filename) or f'media-{len(media_uploads)}',
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
f'{notify_mod}.send_wecom_file_message',
|
||||
lambda _userid, media_id: file_sends.append(media_id) or {'errcode': 0},
|
||||
)
|
||||
monkeypatch.setattr('app.services.file_assets.storage.file_asset_storage.get_bytes', lambda _key: b'receipt-data')
|
||||
return textcards, media_uploads, file_sends
|
||||
|
||||
|
||||
def test_receipt_run_notification_is_one_shot_at_finalize(app, monkeypatch):
|
||||
"""收料 run 终态后经通用排程出口一次性发 textcard+全部收料文件;重复归集不重发。"""
|
||||
def test_receipt_run_notification_is_one_shot_at_finalize(app, monkeypatch, tmp_path):
|
||||
"""收料 run 终态后经通用排程出口一次性发 textcard+收料 ZIP;重复归集不重发。"""
|
||||
from app import db
|
||||
from app.models import User
|
||||
from app.services.schedule.freight_receipt_rpa_finalize import finalize_receipt_schedule_run_if_complete
|
||||
|
||||
with app.app_context():
|
||||
app.config['FREIGHT_RPA_RECEIPT_ARCHIVE_DIR'] = str(tmp_path / 'receipt-archives')
|
||||
recipient = User(username='receipt-one-shot', email='one-shot@example.com', role='user', status='active', wecom_userid='one-shot-user')
|
||||
db.session.add(recipient); db.session.flush()
|
||||
task, run, _report_file = _make_receipt_run_fixture(db, 'SCH-RECEIPT-ONESHOT', 'RUN-RECEIPT-ONESHOT', 'receipt-oneshot-callback')
|
||||
@@ -124,13 +132,15 @@ def test_receipt_run_notification_is_one_shot_at_finalize(app, monkeypatch):
|
||||
|
||||
outcome = finalize_receipt_schedule_run_if_complete(run.id)
|
||||
|
||||
# [断言意图] 一次性出口:单条 textcard + 单文件消息,与库存排程同通道同门禁。
|
||||
# [断言意图] 一次性出口:单条 textcard + 单个收料 ZIP,与库存排程同通道同门禁。
|
||||
assert outcome == {'finalized': True, 'status': 'success'}
|
||||
assert len(textcards) == 1
|
||||
assert '收料报表文件 1 份:已随本通知发送' in textcards[0][1]
|
||||
assert media_uploads == ['receipt.xlsx']
|
||||
assert '原始收料包:已随本通知发送' in textcards[0][1]
|
||||
assert len(media_uploads) == 1
|
||||
assert media_uploads[0].startswith('收料RPA-') and media_uploads[0].endswith('-收料.zip')
|
||||
assert file_sends == ['media-1']
|
||||
assert run.wecom_notified is True
|
||||
assert run.response_summary_json.get('raw_receipt_zip_available') is True
|
||||
|
||||
# [断言意图] awaiting 标志清零后再次归集必须短路,绝不二次打扰接收人。
|
||||
outcome_again = finalize_receipt_schedule_run_if_complete(run.id)
|
||||
|
||||
Reference in new issue
Block a user