feat(shipping-notice): 支持发货通知解析延后至 Dify 画布,优化任务创建流程
This commit is contained in:
1 parent
d46d61bfa1
commit
70e8f700ff
38 files changed
+3215
-714
No files matched your search
@@ -127,11 +127,22 @@ def compute_batch_process_summary(tasks: list[ShippingTask]) -> dict[str, int]:
|
||||
completed = sum(1 for item in tasks if item.process_status in {"uploaded", "completed", "closed"})
|
||||
failed = sum(1 for item in tasks if item.process_status in {"rejected"} or item.upload_status == "failed")
|
||||
running = sum(1 for item in tasks if item.process_status not in {"uploaded", "completed", "closed", "rejected"})
|
||||
pending = sum(1 for item in tasks if item.process_status in {"created", "pending_review"} or not item.current_step)
|
||||
focus = next(
|
||||
(
|
||||
item for item in sort_batch_tasks(tasks)
|
||||
if item.process_status not in {"uploaded", "completed", "closed", "rejected"}
|
||||
),
|
||||
None,
|
||||
)
|
||||
return {
|
||||
"total": total,
|
||||
"completed": completed,
|
||||
"failed": failed,
|
||||
"running": running,
|
||||
"pending": pending,
|
||||
"current_index": int(focus.batch_index or 0) if focus else (total if total else 0),
|
||||
"current_task_no": focus.task_no if focus else None,
|
||||
}
|
||||
|
||||
|
||||
@@ -171,9 +182,12 @@ def resolve_task_from_payload(payload: dict[str, Any]) -> ShippingTask | None:
|
||||
|
||||
def _task_tool_payload(task: ShippingTask) -> dict[str, Any]:
|
||||
"""Tool data 基础字段(裁剪前)。"""
|
||||
return {
|
||||
from app.services.shipping_notice.notice_upload import max_notice_chars
|
||||
|
||||
payload: dict[str, Any] = {
|
||||
"task_no": task.task_no,
|
||||
"process_status": task.process_status,
|
||||
"current_step": task.current_step,
|
||||
"review_status": task.review_status,
|
||||
"match_status": task.match_status,
|
||||
"pending_human_reason": task.pending_human_reason,
|
||||
@@ -189,7 +203,17 @@ def _task_tool_payload(task: ShippingTask) -> dict[str, Any]:
|
||||
"freight_ref_no": task.freight_ref_no,
|
||||
"error_message": task.error_message,
|
||||
"conversation_id": task.conversation_id,
|
||||
"step_payload": task.step_payload_json or {},
|
||||
}
|
||||
raw_content = str(task.raw_content or "").strip()
|
||||
lines = task.lines_json or []
|
||||
# Dify 画布 LLM 字段抽取需要正文;已落库订单行后不再重复下发全文。
|
||||
if raw_content and (not lines or str(task.process_status or "").strip().lower() == "created"):
|
||||
limit = max_notice_chars()
|
||||
payload["raw_text"] = raw_content[:limit] if len(raw_content) > limit else raw_content
|
||||
if len(raw_content) > limit:
|
||||
payload["raw_text_truncated"] = True
|
||||
return payload
|
||||
|
||||
|
||||
def serialize_task(task: ShippingTask, projection: TaskProjection) -> dict[str, Any]:
|
||||
|
||||
Reference in new issue
Block a user