报价模板下线分类字段,匹配只靠业务类型与关键词;并补后台站点标题配置。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
职责:
|
||||
1) 扫描仓库「海陆空报价单模板」目录(忽略 ~$ 临时文件与嵌套重复)
|
||||
2) 按文件名判定 bizType / category / mode(auto|manual) / 关键词
|
||||
2) 按文件名判定 bizType / mode(auto|manual) / 关键词
|
||||
3) 用 openpyxl 做标签粗映射,写出 seed 清单 JSON(供人工核对)
|
||||
4) 若提供 --upload-url 与 token,则逐个 POST 到主账 /inquiry/quoteTemplate/upload
|
||||
|
||||
@@ -32,7 +32,7 @@ OUT_JSON = ROOT / "deploy" / "seed" / "quote_templates_seed_manifest_v1.json"
|
||||
|
||||
|
||||
def classify(name: str) -> dict[str, Any]:
|
||||
"""按文件名归类业务/分类/模式。"""
|
||||
"""按文件名归类业务/模式/关键词(分类字段已下线)。"""
|
||||
n = name
|
||||
mode = "auto"
|
||||
if any(k in n for k in ("人工报价", "双清", "保税仓", "仓储")):
|
||||
@@ -41,82 +41,69 @@ def classify(name: str) -> dict[str, Any]:
|
||||
if "海运" in n:
|
||||
return {
|
||||
"bizType": "海运",
|
||||
"category": "海运报价单模板",
|
||||
"keywords": ["海运", "整柜", "FCL"],
|
||||
"mode": mode,
|
||||
}
|
||||
if "空运到门" in n:
|
||||
return {
|
||||
"bizType": "空运",
|
||||
"category": "空运到门报价单模板",
|
||||
"keywords": ["空运", "到门"],
|
||||
"mode": mode,
|
||||
}
|
||||
if "空运" in n:
|
||||
return {
|
||||
"bizType": "空运",
|
||||
"category": "空运到港报价单模板",
|
||||
"keywords": ["空运", "到港"],
|
||||
"mode": mode,
|
||||
}
|
||||
if "中港" in n:
|
||||
return {
|
||||
"bizType": "陆运",
|
||||
"category": "中港",
|
||||
"keywords": ["中港", "陆运"],
|
||||
"mode": mode,
|
||||
}
|
||||
if "拼车" in n:
|
||||
return {
|
||||
"bizType": "陆运",
|
||||
"category": "国内拼车",
|
||||
"keywords": ["拼车", "零担"],
|
||||
"mode": mode,
|
||||
}
|
||||
if "国内" in n and "整车" in n:
|
||||
return {
|
||||
"bizType": "陆运",
|
||||
"category": "国内整车",
|
||||
"keywords": ["整车", "国内"],
|
||||
"mode": mode,
|
||||
}
|
||||
if "跨境整车" in n:
|
||||
return {
|
||||
"bizType": "陆运",
|
||||
"category": "跨境整车",
|
||||
"keywords": ["跨境", "整车"],
|
||||
"mode": mode,
|
||||
}
|
||||
if "跨境集拼" in n or "中越" in n or "集拼" in n:
|
||||
cat = "双清或中越" if ("中越" in n or "双清" in n) else "跨境集拼"
|
||||
return {
|
||||
"bizType": "陆运",
|
||||
"category": cat,
|
||||
"keywords": ["集拼", "跨境"] if "集拼" in n else ["中越"],
|
||||
"mode": mode,
|
||||
}
|
||||
if "凭祥" in n or "仓储" in n:
|
||||
return {
|
||||
"bizType": "陆运",
|
||||
"category": "凭祥保税仓&普仓仓储",
|
||||
"keywords": ["仓储", "凭祥"],
|
||||
"mode": "manual",
|
||||
}
|
||||
if "双清" in n:
|
||||
return {
|
||||
"bizType": "陆运",
|
||||
"category": "双清或中越",
|
||||
"keywords": ["双清"],
|
||||
"mode": "manual",
|
||||
}
|
||||
return {
|
||||
"bizType": "陆运",
|
||||
"category": "国内拼车",
|
||||
"keywords": [Path(name).stem[:20]],
|
||||
"mode": mode,
|
||||
}
|
||||
|
||||
|
||||
def unique_xlsx_files() -> list[Path]:
|
||||
files = [p for p in TEMPLATE_DIR.rglob("*.xlsx") if not p.name.startswith("~$")]
|
||||
by_name: dict[str, Path] = {}
|
||||
@@ -181,7 +168,6 @@ def build_manifest() -> list[dict[str, Any]]:
|
||||
"fileName": path.name,
|
||||
"relativePath": str(path.relative_to(ROOT)).replace("\\", "/"),
|
||||
"bizType": meta["bizType"],
|
||||
"category": meta["category"],
|
||||
"keywords": meta["keywords"],
|
||||
"mode": meta["mode"],
|
||||
"suggestedMappingPointCount": mapped.get("mappingPointCount", 0),
|
||||
@@ -201,7 +187,6 @@ def upload_one(base_url: str, token: str, item: dict[str, Any]) -> dict[str, Any
|
||||
fields = {
|
||||
"name": Path(item["fileName"]).stem,
|
||||
"bizType": item["bizType"],
|
||||
"category": item["category"],
|
||||
"keywordsJson": json.dumps(item["keywords"], ensure_ascii=False),
|
||||
"mode": item["mode"],
|
||||
"isDefault": "false",
|
||||
@@ -259,7 +244,7 @@ def main(argv: list[str]) -> int:
|
||||
print(f"wrote {OUT_JSON} count={len(items)}")
|
||||
for it in items:
|
||||
print(
|
||||
f" [{it['mode']}] {it['bizType']}/{it['category']} "
|
||||
f" [{it['mode']}] {it['bizType']} "
|
||||
f"map~{it['suggestedMappingPointCount']} {it['fileName']}"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user