落地多段联运私聊:齐了才建单拉群,附件只收格子值,核对改正不再整单重开。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
意图:普通文字询价(空运 / 海运闭环)。
|
||||
意图:普通文字询价(空运 / 海运 / 陆运 / 多段联运)。
|
||||
|
||||
本文件职责:入站文字 → 流程编排;回复只写入 outbox。
|
||||
禁止:在本文件抽字段语义(交给 extract);禁止直连 TMS;禁止回调线程外的额外阻塞。
|
||||
@@ -45,7 +45,7 @@ def _drop_other_mode_drafts(*, owner: str, sender_id: str) -> None:
|
||||
"""
|
||||
kind = (owner or "").upper()
|
||||
sid = (sender_id or "").strip()
|
||||
if not sid or kind not in {"SEA", "AIR", "LAND"}:
|
||||
if not sid or kind not in {"SEA", "AIR", "LAND", "MULTI"}:
|
||||
return
|
||||
land = get_land_text_flow()
|
||||
air = get_air_text_flow()
|
||||
@@ -112,6 +112,19 @@ def _pick_text_flow(*, sender_id: str, text: str, injected_mode: str = "", prefe
|
||||
from agent.policy.quote_adjust_ops import quoted_adjust_flow
|
||||
from agent.policy.handoff_human import is_handoff_frozen
|
||||
|
||||
from agent.policy.multi_segments import classify_multi_text
|
||||
from agent.policy.multi_text_flow import get_multi_text_flow
|
||||
|
||||
multi = get_multi_text_flow()
|
||||
# 多段核对上的「确定」优先于陆运旧核对,避免建出海运/陆运单段工单。
|
||||
if looks_like_confirm(text):
|
||||
multi_hit = multi.session_of(sender_id)
|
||||
if (
|
||||
multi_hit
|
||||
and (multi_hit.business_line or "").upper() == "MULTI"
|
||||
and (multi_hit.phase or "") == "wait_confirm"
|
||||
):
|
||||
return multi
|
||||
land = get_land_text_flow()
|
||||
if looks_like_confirm(text):
|
||||
restored = land.restore_confirm_session(sender_id)
|
||||
@@ -123,14 +136,42 @@ def _pick_text_flow(*, sender_id: str, text: str, injected_mode: str = "", prefe
|
||||
sea = get_sea_text_flow()
|
||||
air = get_air_text_flow()
|
||||
spoken = (injected_mode or detect_transport_mode(text) or "").upper()
|
||||
multi_kind = classify_multi_text(text) if not injected_mode else "single"
|
||||
if multi_kind in {"multi", "same_mode"}:
|
||||
_drop_other_mode_drafts(owner="MULTI", sender_id=sender_id)
|
||||
return multi
|
||||
# 本句点名运输方式:盖掉其它方式的旧补问,避免海运补字段走陆运样例图。
|
||||
# 多段正在补问时例外:销售会写「段2:运输方式:空运」,不能把多段草稿丢掉改走单段。
|
||||
# 已出号等拉群不算补问:再发陆运附件要走陆运,不能粘在旧工单的手动拉群提示上。
|
||||
if spoken in {"SEA", "AIR", "LAND"}:
|
||||
multi_draft = multi.session_of(sender_id)
|
||||
if (
|
||||
multi_draft
|
||||
and (multi_draft.business_line or "").upper() == "MULTI"
|
||||
and (multi_draft.phase or "") == "clarify"
|
||||
):
|
||||
return multi
|
||||
_drop_other_mode_drafts(owner=spoken, sender_id=sender_id)
|
||||
stale_handoff = (multi_draft.phase or "") in {
|
||||
"wait_collab",
|
||||
"wait_manual_group",
|
||||
"collab_group",
|
||||
} if multi_draft else False
|
||||
if _front_bookmark(multi_draft) or stale_handoff:
|
||||
multi.drop_current_bookmark(sender_id)
|
||||
if spoken == "SEA":
|
||||
return sea
|
||||
if spoken == "LAND":
|
||||
return land
|
||||
return air
|
||||
multi_sess = multi.session_of(sender_id)
|
||||
if (
|
||||
multi_sess
|
||||
and (multi_sess.business_line or "").upper() == "MULTI"
|
||||
and (multi_sess.phase or "") in {"clarify", "wait_confirm"}
|
||||
and not (looks_like_confirm(text) and (multi_sess.phase or "") != "wait_confirm")
|
||||
):
|
||||
return multi
|
||||
sea_sess = sea.session_of(sender_id)
|
||||
land_sess = land.session_of(sender_id)
|
||||
air_sess = air.session_of(sender_id)
|
||||
|
||||
Reference in New Issue
Block a user