feat(shipping-notice): 支持发货通知解析延后至 Dify 画布,优化任务创建流程

This commit is contained in:
hugo committed 2026-06-22 16:59:38 +08:00
1 parent d46d61bfa1
commit 70e8f700ff
38 files changed
+3215 -714

No files matched your search

@@ -64,6 +64,11 @@ def auto_mapping_allow_llm() -> bool:
return cfg_bool("SHIPPING_NOTICE_AUTO_MAPPING_ALLOW_LLM", False)
def defer_parse_to_dify_enabled() -> bool:
"""建单后是否延后 parse_notice,交由 Dify 画布完成 LLM 抽取与落库。"""
return cfg_bool("SHIPPING_NOTICE_DEFER_PARSE_TO_DIFY", True)
def auto_match_enabled() -> bool:
"""auto_progress 是否自动调用 match_inventory。"""
return cfg_bool("SHIPPING_NOTICE_AUTO_MATCH_ENABLED", True)
@@ -123,6 +128,49 @@ def prepend_tool_message(result: dict[str, Any], prefix: str) -> dict[str, Any]:
return {**result, "message": f"{note}\n\n{body}" if body else note}
def set_task_step_progress(
task: ShippingTask,
*,
step_key: str,
step_title: str,
status: str,
message: str,
progress_percent: int | None = None,
current: int | None = None,
total: int | None = None,
detail: str | None = None,
extra: dict[str, Any] | None = None,
) -> None:
"""写入任务当前步骤与步骤内细粒度进度,统一落到 current_step + step_payload_json。"""
payload = dict(task.step_payload_json or {})
progress: dict[str, Any] = {
"step_key": step_key,
"step_title": step_title,
"status": status,
"message": str(message or "").strip(),
}
if progress_percent is not None:
progress["progress_percent"] = max(0, min(int(progress_percent), 100))
if current is not None:
progress["current"] = int(current)
if total is not None:
progress["total"] = int(total)
if detail:
progress["detail"] = str(detail).strip()
if extra:
progress["extra"] = extra
payload["current_step_progress"] = progress
task.current_step = step_key
task.step_payload_json = payload
def clear_task_step_progress(task: ShippingTask) -> None:
"""清空任务步骤内进度,保留其他 step_payload_json 字段。"""
payload = dict(task.step_payload_json or {})
payload.pop("current_step_progress", None)
task.step_payload_json = payload or None