feat(shipping-notice): 增加 RPA 库存回调处理逻辑,支持跳过无库存情况

This commit is contained in:
hugo committed 2026-07-10 17:21:11 +08:00
1 parent f21216f81e
commit c3f05ba96b
25 files changed
+1619 -81

No files matched your search

@@ -76,6 +76,26 @@ _WECOM_STATUS_LABEL = {
_WECOM_EVENT_TYPE = 'schedule_completed'
def _build_schedule_run_wecom_description(run: ScheduleRun) -> str:
"""
组装排程完成企微 textcard 正文。
核心逻辑:与管理端统计口径一致,展示 total/success/skipped/failed 四列计数。
"""
status_label = _WECOM_STATUS_LABEL.get(run.status, run.status)
skipped_count = int(run.skipped_count or 0)
description = (
f'执行单号: {run.run_no}\n'
f'状态: {status_label}\n'
f'总数: {run.total_count} 成功: {run.success_count} '
f'跳过: {skipped_count} 失败: {run.failed_count}'
)
summary = run.response_summary_json if isinstance(run.response_summary_json, dict) else {}
if summary.get('excel_failed') or summary.get('excel_export_status') == 'failed':
description += '\n备注: 库存源已成功,但排程 Excel 生成失败'
return description
def _notify_schedule_run_wecom(task: ScheduleTask, run: ScheduleRun) -> None:
from app.services.wecom_notify import (
upload_wecom_temp_media,
@@ -104,16 +124,8 @@ def _notify_schedule_run_wecom(task: ScheduleTask, run: ScheduleRun) -> None:
run.wecom_notify_error = 'no wecom_userid bound users in notify list'
return
status_label = _WECOM_STATUS_LABEL.get(run.status, run.status)
title = f'排程执行结果: {task.name}'
description = (
f'执行单号: {run.run_no}\n'
f'状态: {status_label}\n'
f'总数: {run.total_count} 成功: {run.success_count} 失败: {run.failed_count}'
)
summary = run.response_summary_json if isinstance(run.response_summary_json, dict) else {}
if summary.get('excel_failed') or summary.get('excel_export_status') == 'failed':
description += '\n备注: 库存源已成功,但排程 Excel 生成失败'
description = _build_schedule_run_wecom_description(run)
media_id = None
if run.excel_file_data and run.excel_file_name: