主要变更: 1. 移除废弃的发货通知字段抽取独立Workflow Agent相关代码 2. 重构Dify服务调用,新增inputs参数支持注入环境变量配置的工具API地址与密钥 3. 新增auto_progress工具API与checkpoint catalog接口,支持流程自动推进 4. 统一字段命名,将column_mapping_json改为map_json并兼容旧有调用 5. 重构库存匹配、解析结果的展示格式,改为标准化多语言Markdown表格 6. 新增ODM ID库存字段支持,优化库存解析与映射逻辑 7. 新增LibreOffice转换隔离Profile配置,避免多实例运行冲突 8. 新增完整环境变量配置、数据库迁移脚本与测试用例 9. 适配前端代码,更新字段命名与聊天跳转逻辑 10. 更新OpenAPI规范适配Dify工具调用,删除已归档的旧部署文档
75 lines
2.4 KiB
Python
75 lines
2.4 KiB
Python
"""Short canonical names for shipping notice API fields and state machine.
|
|
|
|
Naming layers (avoid drift):
|
|
- CP_* — API `checkpoint` / Dify `flow_ckpt` (see state_machine.CHECKPOINT_REGISTRY)
|
|
- RS_* — DB `review_status` where used
|
|
- PH_* — DB `pending_human_reason` (may equal CP_* when aligned)
|
|
- Button ids / registry — state_machine.py only
|
|
- DB state writes — state_machine.py `TaskTransition` / `apply_task_transition` (tools.py only)
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
# HTTP JSON request/response fields
|
|
MAP_JSON = "map_json"
|
|
SUGGEST_OK = "suggest_ok"
|
|
AUTO_MAP = "auto_map"
|
|
# Workspace / Hxops chat fallback only — Dify Agent 主路径应调 auto_progress,勿在画布 HTTP 传此字段
|
|
AUTO_CHAIN_FALLBACK = "auto_chain_fallback"
|
|
|
|
# Legacy request field names (read-only compat)
|
|
MAP_JSON_LEGACY = "column_mapping_json"
|
|
|
|
# Checkpoints (tool_response.checkpoint; canonical ids — register buttons in state_machine.py)
|
|
CP_ALIGN_REVIEW = "align_review"
|
|
CP_MAP_INFER = "map_infer"
|
|
CP_UPLOAD_REQ = "upload_req"
|
|
CP_MAP_OK = "map_ok"
|
|
CP_PARSE_OK = "parse_ok"
|
|
CP_PARSE_REVIEW = "parse_review"
|
|
CP_TASK_EXISTS = "task_exists"
|
|
CP_RSV_REQ = "rsv_req"
|
|
CP_UPLOAD_FAILED = "upload_failed"
|
|
CP_WAITING_UPLOAD = "waiting_upload"
|
|
CP_REJECTED = "rejected"
|
|
# Derived UI checkpoints (no separate pending_human_reason; from process_status)
|
|
CP_INVENTORY_PENDING = "inventory_pending"
|
|
CP_READY_MATCH = "ready_to_match"
|
|
CP_READY_EXPORT = "ready_to_export"
|
|
CP_EXPORT_READY = "export_ready"
|
|
CP_NOTICE_TEXT_EXTRACTION_FAILED = "notice_text_extraction_failed"
|
|
CP_EXPORT_GENERATED = "export_generated"
|
|
CP_UPLOADED = "uploaded"
|
|
CP_COMPLETED = "completed"
|
|
|
|
# review_status
|
|
RS_ALIGN_REVIEW = "align_review"
|
|
RS_PARSE_REVIEW = "parse_review"
|
|
RS_SHORTAGE_REVIEW = "shortage_review"
|
|
RS_RSV_REQ = "rsv_req"
|
|
RS_REJECTED = "rejected"
|
|
RS_CONFIRMED = "confirmed"
|
|
|
|
# pending_human_reason (internal; shortened)
|
|
PH_ALIGN_REVIEW = CP_ALIGN_REVIEW
|
|
PH_MAP_INFER = CP_MAP_INFER
|
|
PH_LOW_CONF = "low_confidence"
|
|
PH_RSV_REQ = CP_RSV_REQ
|
|
PH_SHORTAGE = "shortage"
|
|
PH_RPA_EXHAUSTED = "rpa_exhausted"
|
|
PH_RPA_PENDING = "rpa_pending"
|
|
PH_INV_UNAVAIL = "inv_unavail"
|
|
PH_UPLOAD_RPA_FAILED = "upload_rpa_failed"
|
|
PH_UPLOAD_RPA_PENDING = "upload_rpa_pending"
|
|
|
|
|
|
def payload_map_json(payload: dict[str, Any]) -> Any:
|
|
raw = payload.get(MAP_JSON)
|
|
if raw is None:
|
|
raw = payload.get(MAP_JSON_LEGACY)
|
|
if raw is None:
|
|
raw = payload.get("field_mapping")
|
|
return raw
|