按陆运线路叶子收窄工单和看板,避免中港权限看到全部陆运;产品/航线排名只留智能体团队。空运核对卡不再列出空的非必填,报价合计标明约数。中港口语里的车型吨位和按运费比例不再算进金额。报价单上传人显示机器人名,进后台拉标题不再误报没有权限。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
linmianxun
2026-11-08 11:44:31 +08:00
co-authored by Cursor
parent 246ae4607c
commit b878a094b5
24 changed files with 1125 additions and 78 deletions
+51 -1
View File
@@ -1086,6 +1086,29 @@ _RE_FEE_LINE = re.compile(
rf"\s*(?P<ccy2>{_CCY_TOKEN}|元)?",
re.I,
)
# 中港陆运口语:「深圳--香港元朗运费10T:1700HKD/车」——车型吨位不是金额。
# 必须先于普通费用行,否则会抽成运费=10(WO202610300015)。
_RE_FEE_VEHICLE_PRICE = re.compile(
r"(?P<name>[\u4e00-\u9fffA-Za-z][\u4e00-\u9fffA-Za-z0-9/()()++\--]{0,24}费)"
r"\s*(?:改为|改成|调整为|调整成)?"
r"\s*[::=]?"
r"\s*(?P<label>\d+(?:\.\d+)?\s*(?:T|吨|HQ|GP|尺))"
r"\s*[::=]?\s*"
rf"(?:(?P<ccy1>{_CCY_TOKEN})\s*)?"
r"(?P<amount>\d+(?:\.\d+)?)"
rf"\s*(?P<ccy2>{_CCY_TOKEN}|元)?"
r"(?:\s*/\s*车)?",
re.I,
)
# 金额后紧跟车型单位:该数字是吨位/柜型,不是费用金额。
_RE_AMOUNT_IS_VEHICLE_UNIT = re.compile(r"^\s*(?:T|吨|HQ|GP|尺)\b", re.I)
# 「压夜按运费80%」「压日按运费100%」是比例,禁止落成 HKD 80/100 再加进合计。
_RE_FEE_OF_FREIGHT_PCT = re.compile(
r"(?P<name>[\u4e00-\u9fff]{1,8}按运费|[\u4e00-\u9fffA-Za-z][\u4e00-\u9fffA-Za-z0-9/()()++\--]{0,16}费)"
r"\s*[::=]?\s*"
r"(?P<amount>\d+(?:\.\d+)?)\s*%",
re.I,
)
# 多段报价「段1:」「第一段」只是段号,数字不能当费用金额。
_RE_SEGMENT_INDEX_LABEL = re.compile(
r"(?:段\s*\d+\s*[::]?|第\s*[一二三四五六七八九\d]+\s*段\s*[::]?)",
@@ -1366,6 +1389,8 @@ def _parse_fee_rows(text: str, baseline_currency: str = "") -> list[dict[str, st
只认带「费」的中文名或短英文费用码,避免把工单号当金额。
句里无币种时继承 baseline_currency(通常是当前 TMS/主账币种),禁止默认 USD。
认「费名, KG, 单价…」与「费名_板,单价…」里的计量单位,写入 unit,禁止出单再默认「票」。
「运费10T:1700HKD」先认车型价,禁止把吨位 10 当成运费金额。
「压夜按运费80%」金额带 %,禁止当绝对金额加进合计。
"""
project, body = _split_fee_project_prefix(text or "")
raw = _ascii_amount(body)
@@ -1395,6 +1420,23 @@ def _parse_fee_rows(text: str, baseline_currency: str = "") -> list[dict[str, st
row[key] = val
rows.append(row)
# 先认「运费10T:1700」——车型价;再认「按运费80%」比例;最后才普通金额行。
for hit in _RE_FEE_VEHICLE_PRICE.finditer(raw):
label = (hit.group("label") or "").strip().replace(" ", "")
_add(
(hit.group("name") or "").strip(),
_ascii_amount(hit.group("amount") or ""),
hit.group("ccy1") or hit.group("ccy2") or "",
unit="车",
vehicle=label,
unit_price=_ascii_amount(hit.group("amount") or ""),
)
for hit in _RE_FEE_OF_FREIGHT_PCT.finditer(raw):
name = (hit.group("name") or "").strip()
amt = _ascii_amount(hit.group("amount") or "")
if not name or not amt:
continue
_add(name, f"{amt}%", "")
priced_hits = 0
for hit in _RE_FEE_PRICED.finditer(raw):
priced_hits += 1
@@ -1427,9 +1469,17 @@ def _parse_fee_rows(text: str, baseline_currency: str = "") -> list[dict[str, st
quantity=quantity,
)
for hit in _RE_FEE_LINE.finditer(raw):
amount = _ascii_amount(hit.group("amount") or "")
after_amount = raw[hit.end("amount") :]
# 吨位/柜型数字不能当金额(运费10T:… 已被车型价规则吃掉;这里再挡漏网)。
if _RE_AMOUNT_IS_VEHICLE_UNIT.match(after_amount):
continue
# 「80%」保留百分号,合计时只加绝对金额。
if re.match(r"\s*%", after_amount or ""):
amount = f"{amount}%"
_add(
(hit.group("name") or "").strip(),
_ascii_amount(hit.group("amount") or ""),
amount,
hit.group("ccy1") or hit.group("ccy2") or "",
)
for hit in _RE_FEE_CHANGE.finditer(raw):