feat(invoice check): 立账凭证检核优化部分代码

This commit is contained in:
sophie committed 2026-09-08 10:25:11 +08:00
1 parent 21d41acf50
commit d123d9cdf6
45 files changed
+498 -2508

No files matched your search

@@ -6,7 +6,7 @@ backend/app/services/schedule/scheduler_service.py
逻辑:api/schedule/tasks.py 与 import_service 调用 create_task/update_task/enable_task;
job_params 在本层经 normalize_job_params_for_contract 唯一归一化(含切换 platform_api_path
未传参时重置默认值);schedule worker 调用 run_task_now 并经 resolve_schedule_executor 分发 handler;
handler 抛错时 failed_count=1,排程记 failed。
handler 抛错时 failed_count=1、排程记 failed,并把 error= 打进 worker 日志。
"""
from __future__ import annotations
@@ -493,7 +493,8 @@ def run_task_now(task: ScheduleTask, *, trigger_type: str, triggered_by_user_id:
"""
立即执行一条排程并写入 ScheduleRun 终态。
核心逻辑:handler 未捕获异常记 failed_count=1,避免配置错误被标成 success。
核心逻辑:handler 未捕获异常记 failed_count=1,避免配置错误被标成 success;
该路径原先只写库不打日志,worker 汇总行看不到失败原因。
"""
recover_stale_awaiting_rpa_schedule_runs(task)
recover_stale_receipt_rpa_schedule_runs(task)
@@ -531,6 +532,14 @@ def run_task_now(task: ScheduleTask, *, trigger_type: str, triggered_by_user_id:
except Exception as exc:
total_count, success_count, failed_count, skipped_count, details, errors = 0, 0, 1, 0, [], [str(exc)]
step_logs = [{"step": "executor_error", "status": "failed", "detail": {"error": str(exc)}}]
if current_app:
current_app.logger.exception(
"[schedule-run] executor failed name=%s path=%s run_no=%s error=%s",
task.name,
task.platform_api_path,
run.run_no,
exc,
)
try:
db.session.refresh(run)
@@ -565,8 +574,9 @@ def run_task_now(task: ScheduleTask, *, trigger_type: str, triggered_by_user_id:
duration_ms = int((time.time() - start_ts) * 1000)
if current_app:
error_preview = "; ".join(str(item) for item in (errors or [])[:3])
current_app.logger.info(
"[schedule-run] name=%s path=%s run_no=%s total=%d success=%d failed=%d skipped=%d errors=%d",
"[schedule-run] name=%s path=%s run_no=%s total=%d success=%d failed=%d skipped=%d errors=%d error=%s",
task.name,
task.platform_api_path,
run.run_no,
@@ -574,7 +584,8 @@ def run_task_now(task: ScheduleTask, *, trigger_type: str, triggered_by_user_id:
success_count,
failed_count,
skipped_count,
len(errors),
len(errors or []),
error_preview or "-",
)
if total_count == 0 and not errors:
status = "success"