员工岗位可重新启用;调价认空运航线;会话存档跳号补拉;陆运报价按车型列回填
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -181,11 +181,33 @@ def _split_routes(raw: str) -> list[str]:
|
||||
return out
|
||||
|
||||
|
||||
def _air_od_codes(facts: dict[str, str] | None) -> tuple[str, str]:
|
||||
"""从工单 facts 取空运起运/目的三字码(兼容港/地/投影字段)。"""
|
||||
src = dict(facts or {})
|
||||
origin = resolve_airport_code(
|
||||
str(
|
||||
src.get("起运港")
|
||||
or src.get("起运地")
|
||||
or src.get("originCode")
|
||||
or src.get("origin_code")
|
||||
or ""
|
||||
)
|
||||
)
|
||||
dest = resolve_airport_code(
|
||||
str(
|
||||
src.get("目的港")
|
||||
or src.get("目的地")
|
||||
or src.get("destinationCode")
|
||||
or src.get("destination_code")
|
||||
or ""
|
||||
)
|
||||
)
|
||||
return origin, dest
|
||||
|
||||
|
||||
def air_route_keys(facts: dict[str, str] | None) -> set[str]:
|
||||
"""本单可对上的空运线路名:三字码对 + 目的港。"""
|
||||
src = dict(facts or {})
|
||||
origin = resolve_airport_code(str(src.get("起运港") or src.get("originCode") or ""))
|
||||
dest = resolve_airport_code(str(src.get("目的港") or src.get("destinationCode") or ""))
|
||||
origin, dest = _air_od_codes(facts)
|
||||
keys: set[str] = set()
|
||||
if dest:
|
||||
keys.add(dest)
|
||||
@@ -194,6 +216,32 @@ def air_route_keys(facts: dict[str, str] | None) -> set[str]:
|
||||
return keys
|
||||
|
||||
|
||||
def air_staff_route_matches(*, routes: str, facts: dict[str, str] | None) -> bool:
|
||||
"""
|
||||
空运群 @ 航线:按员工「负责线路」是否对上本单。
|
||||
|
||||
与成交负责人推送同口径(全线 / 外采 / 三字码对),但不要求 isLeader。
|
||||
仅有目的港、无起运时:后台常配 CGO-KUL,允许 token 以 -目的 结尾命中。
|
||||
"""
|
||||
tokens = _split_routes(routes)
|
||||
if not tokens:
|
||||
return False
|
||||
if _has_all_line(tokens, line="AIR"):
|
||||
return True
|
||||
if any("外采-空运" in t or t == "外采-空运" for t in tokens) and _is_waicai(facts):
|
||||
return True
|
||||
origin, dest = _air_od_codes(facts)
|
||||
keys = air_route_keys(facts)
|
||||
if any(t in keys for t in tokens):
|
||||
return True
|
||||
# 只有目的港:KUL 应对上 CGO-KUL / SZX-KUL 等配线
|
||||
if dest and not origin:
|
||||
suffix = f"-{dest}"
|
||||
if any(t == dest or t.endswith(suffix) for t in tokens):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def _is_waicai(facts: dict[str, str] | None) -> bool:
|
||||
src = dict(facts or {})
|
||||
for key in ("外采", "是否外采", "采购方式"):
|
||||
@@ -251,12 +299,7 @@ def leader_matches(
|
||||
if line == "AIR":
|
||||
if code != "air":
|
||||
return False
|
||||
if _has_all_line(tokens, line="AIR"):
|
||||
return True
|
||||
if "外采-空运" in tokens and _is_waicai(facts):
|
||||
return True
|
||||
keys = air_route_keys(facts)
|
||||
return any(t in keys for t in tokens)
|
||||
return air_staff_route_matches(routes=routes, facts=facts)
|
||||
return False
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user