完善空运锁舱与海运报价单单选回填,并增强模板预览与协同字段盖写。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -78,6 +78,10 @@ _IATA_PAIR_BLOCK = frozenset(
|
||||
}
|
||||
)
|
||||
_NUMBER = re.compile(r"(\d+(?:\.\d+)?)")
|
||||
# 销售写尺寸当体积:1.1*1.2*3 / 1.1x1.2x3 / 1.1×1.2×3
|
||||
_DIM_PRODUCT = re.compile(
|
||||
r"(\d+(?:\.\d+)?)\s*[*xX×]\s*(\d+(?:\.\d+)?)(?:\s*[*xX×]\s*(\d+(?:\.\d+)?))?"
|
||||
)
|
||||
|
||||
|
||||
def _first_number(raw: str) -> str:
|
||||
@@ -85,6 +89,32 @@ def _first_number(raw: str) -> str:
|
||||
return hit.group(1) if hit else ""
|
||||
|
||||
|
||||
def volume_cbm_number(raw: str) -> str:
|
||||
"""
|
||||
体积出站用数字:尺寸式先相乘;否则取第一个数。
|
||||
|
||||
例:1.1*1.2*3 → 3.96;2CBM → 2。空串表示没有可用体积。
|
||||
"""
|
||||
text = (raw or "").strip()
|
||||
if not text:
|
||||
return ""
|
||||
dims = _DIM_PRODUCT.search(text)
|
||||
if dims:
|
||||
try:
|
||||
a = float(dims.group(1))
|
||||
b = float(dims.group(2))
|
||||
c = float(dims.group(3) or "1")
|
||||
product = a * b * c
|
||||
if product <= 0:
|
||||
return ""
|
||||
# 去掉多余尾零,保持可读小数
|
||||
text_num = f"{product:.10f}".rstrip("0").rstrip(".")
|
||||
return text_num or ""
|
||||
except ValueError:
|
||||
return ""
|
||||
return _first_number(text)
|
||||
|
||||
|
||||
def resolve_airport_code(raw: str) -> str:
|
||||
"""销售原文是地名或三字码时,给出 TMS originCode/destinationCode。"""
|
||||
text = (raw or "").strip()
|
||||
@@ -161,7 +191,7 @@ def assemble_air_query(facts: dict[str, Any] | None) -> dict[str, Any]:
|
||||
cargo = str(src.get("品名") or "").strip()
|
||||
pieces = _first_number(str(src.get("件数") or ""))
|
||||
weight = _first_number(str(src.get("毛重") or ""))
|
||||
volume = _first_number(str(src.get("体积") or ""))
|
||||
volume = volume_cbm_number(str(src.get("体积") or ""))
|
||||
pack_raw = str(src.get("包装方式") or src.get("包装类型") or "").strip()
|
||||
pack_code = resolve_package_type(pack_raw)
|
||||
quote_date = str(src.get("报价日期") or "").strip()
|
||||
|
||||
Reference in New Issue
Block a user