zlwu 3 ヶ月 前
親
コミット
5cf67f60d1
39 ファイル変更、2207 行追加、1616 行削除
  1. 1 1
      backend/app.pid
  2. 240 43
      backend/app/crud/crm/contract.py
  3. 5 1
      backend/app/crud/crm/contract_product.py
  4. 2 12
      backend/graphify-out/.graphify_labels.json
  5. 8 0
      backend/graphify-out/2026-08-04/.graphify_labels.json
  6. 219 179
      backend/graphify-out/2026-08-04/GRAPH_REPORT.md
  7. 144 134
      backend/graphify-out/2026-08-04/graph.json
  8. 156 210
      backend/graphify-out/GRAPH_REPORT.md
  9. 0 0
      backend/graphify-out/cache/ast/v0.9.4/0d35214081d8a80769bdc081741b21f0f3d3af272d2ca6122744a5cbbc002ae1.json
  10. 0 0
      backend/graphify-out/cache/ast/v0.9.4/34c9d96b8b5da5dacd84a86a557455f5e81ed38c96452f6be763f241163c160c.json
  11. 0 0
      backend/graphify-out/cache/ast/v0.9.4/369ddae942265f4492be1901fd0bec978288096dd18525fcc9f10d8eec470332.json
  12. 0 0
      backend/graphify-out/cache/ast/v0.9.4/38bfbe51fdb8f5bc43c48fc0767e742edfc963761252f32e6868c4341e61af84.json
  13. 0 0
      backend/graphify-out/cache/ast/v0.9.4/3f46aa8277a5a3ac9a73aebbf39a72ef64852d05e40af224633d2a50d0e82953.json
  14. 0 0
      backend/graphify-out/cache/ast/v0.9.4/69bc7d7ead223c34143e56ed7eb1381b48e07fef4b74b4dd83365e8cca1edab8.json
  15. 0 0
      backend/graphify-out/cache/ast/v0.9.4/9a59bc109ddc024a07b33b7392a05d483860e2214950a5e3552dee57e207be2f.json
  16. 0 0
      backend/graphify-out/cache/ast/v0.9.4/c74f02d4dc391a4a35e4810c57fdd5f8f1b5ef7d3c2a6d1a9c152adce0e05fce.json
  17. 0 0
      backend/graphify-out/cache/ast/v0.9.4/d97668b63b513d8b42809522f685db6266d93099e61fa808684126f63c7c127f.json
  18. 0 0
      backend/graphify-out/cache/ast/v0.9.4/ff831959d54053ab544d9c377133a120cd4caa8aac6650da16a36150444d78e6.json
  19. 0 0
      backend/graphify-out/cache/stat-index.json
  20. 1 1
      backend/graphify-out/graph.html
  21. 112 112
      backend/graphify-out/graph.json
  22. 169 0
      backend/tests/test_crm_contract_name_from_parties.py
  23. 38 1
      backend/tests/test_crm_contract_no_align.py
  24. 76 0
      docs/sql/migrations/2026-08-04-split-framework-contract-type.sql
  25. 32 0
      docs/superpowers/specs/2026-08-04-crm-contract-name-from-parties-design.md
  26. 0 0
      graphify-out/cache/stat-index.json
  27. 23 18
      graphify-out/manifest.json
  28. 8 16
      web-admin/graphify-out/.graphify_labels.json
  29. 9 6
      web-admin/graphify-out/2026-08-04/.graphify_labels.json
  30. 240 219
      web-admin/graphify-out/2026-08-04/GRAPH_REPORT.md
  31. 122 112
      web-admin/graphify-out/2026-08-04/graph.json
  32. 230 222
      web-admin/graphify-out/GRAPH_REPORT.md
  33. 112 112
      web-admin/graphify-out/graph.json
  34. 0 1
      web-admin/src/assets/styles/core/app.scss
  35. 6 5
      web-admin/src/views/crm/contract/components/ContractDetailDialog.vue
  36. 174 96
      web-admin/src/views/crm/contract/components/ContractFormDialog.vue
  37. 12 0
      web-admin/src/views/crm/contract/contractType.ts
  38. 5 4
      web-admin/src/views/crm/contract/detail.vue
  39. 63 111
      web-admin/src/views/crm/contract/form.vue

+ 1 - 1
backend/app.pid

@@ -1 +1 @@
-87236
+58367

+ 240 - 43
backend/app/crud/crm/contract.py

@@ -576,6 +576,52 @@ def _get_supplier_short_name(db: Session, supplier_id: str, tenant_no: str) -> s
     return "山峡"
 
 
+def _build_contract_name_from_parties(
+    db: Session,
+    *,
+    tenant_no: str,
+    contract_no: str,
+    party_a: str = "",
+    party_b: str = "",
+    supplier_id: str = "",
+    customer_id: str = "",
+    customer_name: str = "",
+    customer_short_name: str = "",
+    user_contract_name: str = "",
+) -> str:
+    """根据供需方面板与主数据生成/校正合同名称。"""
+    supplier = get_supplier_info(db, supplier_id, tenant_no=tenant_no) if supplier_id else None
+    supplier_name = (getattr(supplier, "supplier_name", None) or "").strip() if supplier else ""
+    supplier_short_name = _get_supplier_short_name(db, supplier_id or "", tenant_no)
+
+    cust_name = (customer_name or "").strip()
+    cust_short = (customer_short_name or "").strip()
+    invoice_name = ""
+    if customer_id:
+        # 始终从客户主数据取简称,避免前端未带 shortName 时落成全称
+        customer = get_customer(db, customer_id)
+        if customer:
+            cust_name = cust_name or (customer.customer_name or "").strip()
+            db_short = (customer.short_name or "").strip()
+            if db_short:
+                cust_short = db_short
+        inv = _get_default_invoice_info(db, tenant_no=tenant_no, customer_id=customer_id)
+        if inv:
+            invoice_name = (inv.get("companyName") or "").strip()
+
+    return generate_contract_name(
+        contract_no or "",
+        party_a=party_a or "",
+        party_b=party_b or "",
+        supplier_name=supplier_name,
+        supplier_short_name=supplier_short_name,
+        customer_name=cust_name,
+        customer_short_name=cust_short,
+        customer_invoice_name=invoice_name,
+        user_contract_name=user_contract_name or "",
+    )
+
+
 def generate_contract_no(
     db: Session,
     tenant_no: str,
@@ -583,7 +629,10 @@ def generate_contract_no(
     supplier_id: str = None,
     sign_date: date = None,
 ) -> str:
-    """Java: generateContractNo — {供方编码}/X-JT{yyyyMMdd}{3位序号}"""
+    """Java: generateContractNo — {供方编码}/X-JT{yyyyMMdd}{3位序号}
+
+    流水与撞号检测须含软删:uk_contract_tenant_no 对 (contract_no, tenant_no) 全局唯一。
+    """
     supplier_code = "SX"
     if supplier_id:
         supplier = get_supplier_info(db, supplier_id, tenant_no=tenant_no)
@@ -594,11 +643,11 @@ def generate_contract_no(
     date_str = date_to_use.strftime("%Y%m%d")
     prefix = f"{supplier_code}/X-JT{date_str}"
 
+    # 含软删:已软删编号仍占唯一索引,不能复用
     last = (
         db.query(CrmContract)
         .filter(
             CrmContract.tenant_no == tenant_no,
-            CrmContract.del_flag == 0,
             CrmContract.contract_no.like(f"{prefix}%"),
         )
         .order_by(CrmContract.contract_no.desc())
@@ -612,14 +661,9 @@ def generate_contract_no(
         except ValueError:
             sequence = 1
 
-    for retry in range(10):
+    for retry in range(50):
         candidate = f"{prefix}{sequence + retry:03d}"
-        exists = (
-            db.query(CrmContract.id)
-            .filter(CrmContract.contract_no == candidate, CrmContract.del_flag == 0)
-            .first()
-        )
-        if not exists:
+        if not contract_no_exists(db, tenant_no, candidate):
             return candidate
 
     raise ValueError("生成合同编号失败,请稍后重试")
@@ -690,37 +734,183 @@ def align_contract_no_to_sign_date(
     raise ValueError("生成合同编号失败,请稍后重试")
 
 
+def resolve_party_short_name(
+    party_name: str,
+    *,
+    supplier_name: str = "",
+    supplier_short_name: str = "",
+    customer_name: str = "",
+    customer_short_name: str = "",
+    customer_invoice_name: str = "",
+) -> str:
+    """按面板单位全称精确匹配交易主体/客户主数据,取 shortName;对不上则用全称。"""
+    party = (party_name or "").strip()
+    if not party:
+        return ""
+
+    s_name = (supplier_name or "").strip()
+    s_short = (supplier_short_name or "").strip()
+    if s_name and party == s_name:
+        return s_short or s_name
+    if s_short and party == s_short:
+        return s_short
+
+    c_name = (customer_name or "").strip()
+    c_short = (customer_short_name or "").strip()
+    c_inv = (customer_invoice_name or "").strip()
+    if c_name and party == c_name:
+        return c_short or c_name
+    if c_short and party == c_short:
+        return c_short
+    if c_inv and party == c_inv:
+        return c_short or c_inv
+
+    return party
+
+
+def _strip_contract_name_no_suffix(name: str) -> str:
+    return re.sub(r"([^)]+)$", "", (name or "").strip()).strip()
+
+
+def _auto_contract_name_body(
+    party_a: str = "",
+    party_b: str = "",
+    *,
+    supplier_name: str = "",
+    supplier_short_name: str = "",
+    customer_name: str = "",
+    customer_short_name: str = "",
+    customer_invoice_name: str = "",
+) -> str:
+    a = resolve_party_short_name(
+        party_a,
+        supplier_name=supplier_name,
+        supplier_short_name=supplier_short_name,
+        customer_name=customer_name,
+        customer_short_name=customer_short_name,
+        customer_invoice_name=customer_invoice_name,
+    )
+    b = resolve_party_short_name(
+        party_b,
+        supplier_name=supplier_name,
+        supplier_short_name=supplier_short_name,
+        customer_name=customer_name,
+        customer_short_name=customer_short_name,
+        customer_invoice_name=customer_invoice_name,
+    )
+    return "-".join(x for x in (a, b) if x)
+
+
+def _user_contract_name_uses_party_full_name(
+    cleaned_user_name: str,
+    party_a: str = "",
+    party_b: str = "",
+    *,
+    supplier_name: str = "",
+    customer_name: str = "",
+    customer_invoice_name: str = "",
+) -> bool:
+    """前端预览误用单位全称时,名称片段会等于面板/客户/开票全称。"""
+    parts = [p.strip() for p in (cleaned_user_name or "").split("-") if p.strip()]
+    if not parts:
+        return False
+    full_names = {
+        (party_a or "").strip(),
+        (party_b or "").strip(),
+        (supplier_name or "").strip(),
+        (customer_name or "").strip(),
+        (customer_invoice_name or "").strip(),
+    }
+    full_names.discard("")
+    return any(part in full_names for part in parts)
+
+
 def generate_contract_name(
     contract_no: str,
-    contract_type: str,
-    supplier_short_name: str,
-    customer_short_name: str,
+    party_a: str = "",
+    party_b: str = "",
+    *,
+    supplier_name: str = "",
+    supplier_short_name: str = "",
+    customer_name: str = "",
+    customer_short_name: str = "",
+    customer_invoice_name: str = "",
     user_contract_name: str = "",
+    contract_type: str = "",  # 保留兼容旧调用,命名不再按类型反序
 ) -> str:
-    """Java: generateContractName"""
-    if not (user_contract_name or "").strip():
-        if contract_type in ("sale", "framework"):
-            return f"{supplier_short_name}-{customer_short_name}({contract_no})"
-        if contract_type == "purchase":
-            return f"{customer_short_name}-{supplier_short_name}({contract_no})"
-        return f"合同({contract_no})"
-
-    cleaned = re.sub(r"([^)]+)$", "", user_contract_name.strip())
-    if f"({contract_no})" not in cleaned:
+    """按面板供方(partyA)-需方(partyB)生成:{供方简称}-{需方简称}({合同编号})。
+
+    - 名称为空:按主数据简称自动生成
+    - 名称含单位全称(前端误预览):仍按简称重算
+    - 续签 / 真正手填自定义名:保留主体,仅校正末尾括号内合同编号
+    """
+    auto_body = _auto_contract_name_body(
+        party_a,
+        party_b,
+        supplier_name=supplier_name,
+        supplier_short_name=supplier_short_name,
+        customer_name=customer_name,
+        customer_short_name=customer_short_name,
+        customer_invoice_name=customer_invoice_name,
+    )
+
+    def _with_no(body: str) -> str:
+        if not body:
+            return f"合同({contract_no})" if contract_no else "合同"
+        return f"{body}({contract_no})" if contract_no else body
+
+    user_raw = (user_contract_name or "").strip()
+    if not user_raw:
+        return _with_no(auto_body)
+
+    # 续签名称:保留整段(含原编号括号),仅必要时追加当前编号
+    if "-续签" in user_raw:
+        cleaned = _strip_contract_name_no_suffix(user_raw)
+        # 若原文已以当前编号结尾则保持;否则在整段后续签名后挂编号
+        if contract_no and user_raw.endswith(f"({contract_no})"):
+            return user_raw
+        if contract_no and f"({contract_no})" not in cleaned:
+            # 续签名通常为「原名-续签N」,原名里已有旧编号括号,不能 strip 掉
+            return f"{user_raw}({contract_no})" if not user_raw.endswith(f"({contract_no})") else user_raw
+        return user_raw
+
+    cleaned = _strip_contract_name_no_suffix(user_raw)
+    if (
+        cleaned == auto_body
+        or _user_contract_name_uses_party_full_name(
+            cleaned,
+            party_a,
+            party_b,
+            supplier_name=supplier_name,
+            customer_name=customer_name,
+            customer_invoice_name=customer_invoice_name,
+        )
+    ):
+        return _with_no(auto_body)
+
+    if contract_no and f"({contract_no})" not in cleaned:
         return f"{cleaned}({contract_no})"
     return cleaned
 
 
+# 框架类合同类型(含历史 framework,兼容未刷完数据)
+FRAMEWORK_CONTRACT_TYPES = frozenset({"framework", "framework_sale", "framework_purchase"})
+
+
+def is_framework_contract_type(contract_type: Optional[str]) -> bool:
+    return (contract_type or "").strip() in FRAMEWORK_CONTRACT_TYPES
+
+
 def _validate_contract_type_and_products(data: dict) -> None:
     contract_type = (_get_field(data, "contract_type", "contractType") or "").strip()
-    if contract_type in ("sale", "purchase", "framework"):
+    if contract_type in ("sale", "purchase") or is_framework_contract_type(contract_type):
         products = _get_field(data, "products", "productList") or []
         if not products:
             raise ValueError("销售合同、采购合同或框架合同必须至少添加一个产品")
 
 
 def _normalize_framework_contract_data(data: dict) -> None:
-    if (_get_field(data, "contract_type", "contractType") or "").strip() != "framework":
+    if not is_framework_contract_type(_get_field(data, "contract_type", "contractType")):
         return
     data["amount"] = 0
     data["amountWithTax"] = 0
@@ -979,7 +1169,6 @@ def create_contract(
         raise ValueError("客户ID不能为空")
 
     supplier_id = (_get_field(data, "supplier_id", "supplierId") or "").strip() or None
-    supplier_short_name = _get_supplier_short_name(db, supplier_id or "", tenant_no)
 
     assert_products_allowed_for_supplier(
         db,
@@ -999,18 +1188,13 @@ def create_contract(
         if contract_no_exists(db, tenant_no, contract_no):
             raise ValueError(f"合同编号已存在:{contract_no}")
 
-    customer = get_customer(db, customer_id)
-    customer_short_name = (customer.short_name or "") if customer else ""
     user_contract_name = (_get_field(data, "contract_name", "contractName") or "").strip()
-    contract_name = generate_contract_name(
-        contract_no, contract_type, supplier_short_name, customer_short_name, user_contract_name
-    )
 
     now = datetime.now()
     entity = CrmContract(
         id=generate_uuid(),
         contract_no=contract_no,
-        contract_name=contract_name,
+        contract_name="",
         customer_id=customer_id,
         status="draft",
         contract_type=contract_type,
@@ -1032,7 +1216,17 @@ def create_contract(
         entity, data, db=db, tenant_no=tenant_no, user_id=user_id, is_create=True
     )
     entity.contract_no = contract_no
-    entity.contract_name = contract_name
+    entity.contract_name = _build_contract_name_from_parties(
+        db,
+        tenant_no=tenant_no,
+        contract_no=contract_no,
+        party_a=entity.party_a or "",
+        party_b=entity.party_b or "",
+        supplier_id=entity.supplier_id or supplier_id or "",
+        customer_id=entity.customer_id or customer_id,
+        customer_name=entity.customer_name or "",
+        user_contract_name=user_contract_name,
+    )
 
     _resolve_contract_product_ids(db, tenant_no=tenant_no, products=product_rows, user_id=user_id)
     db.add(entity)
@@ -1126,16 +1320,17 @@ def update_contract(
                 raise ValueError(f"合同编号已存在:{submitted_no}")
             old.contract_no = submitted_no
 
-    supplier_short_name = _get_supplier_short_name(db, old.supplier_id or "", tenant_no)
-    customer = get_customer(db, old.customer_id) if old.customer_id else None
-    customer_short_name = (customer.short_name or "") if customer else (old.customer_name or "")
     user_name = (_get_field(data, "contract_name", "contractName") or old.contract_name or "").strip()
-    old.contract_name = generate_contract_name(
-        old.contract_no or "",
-        contract_type,
-        supplier_short_name,
-        customer_short_name,
-        user_name,
+    old.contract_name = _build_contract_name_from_parties(
+        db,
+        tenant_no=tenant_no,
+        contract_no=old.contract_no or "",
+        party_a=old.party_a or "",
+        party_b=old.party_b or "",
+        supplier_id=old.supplier_id or "",
+        customer_id=old.customer_id or "",
+        customer_name=old.customer_name or "",
+        user_contract_name=user_name,
     )
 
     old.update_by = user_id
@@ -1194,7 +1389,7 @@ def validate_framework_contract_for_submit_approval(
     entity = contract or get_contract_row(db, contract_id, tenant_no=tenant_no)
     if not entity:
         raise ValueError("合同不存在")
-    if (entity.contract_type or "").strip() != "framework":
+    if not is_framework_contract_type(entity.contract_type):
         return
 
     products = list_contract_products(db, contract_id, tenant_no=tenant_no)
@@ -1615,7 +1810,9 @@ def statistics_by_type(db: Session, tenant_no: str, *, user_info=None) -> List[D
         ("sale", "销售合同"),
         ("service", "服务合同"),
         ("purchase", "采购合同"),
-        ("framework", "框架合同"),
+        ("framework_sale", "框架销售合同"),
+        ("framework_purchase", "框架采购合同"),
+        ("framework", "框架合同"),  # 历史兼容
         ("supplement", "补充协议"),
         ("lease", "租赁合同"),
         ("other", "其他"),

+ 5 - 1
backend/app/crud/crm/contract_product.py

@@ -287,7 +287,11 @@ def batch_insert_contract_products(
             user_id=user_id,
             dept_id=dept_id,
         )
-        if contract_type == "framework":
+        if (contract_type or "").strip() in (
+            "framework",
+            "framework_sale",
+            "framework_purchase",
+        ):
             tiers = _get_field(row, "priceTiers", "price_tiers") or []
             if tiers:
                 save_price_tiers_for_product(

+ 2 - 12
backend/graphify-out/.graphify_labels.json

@@ -138,31 +138,23 @@
   "136": "Community 136",
   "137": "statistics.py",
   "138": "Community 138",
-  "139": "Community 139",
   "140": "Community 140",
-  "141": "clue_statistics.py",
   "142": "Community 142",
   "143": "SysEthnic",
-  "144": "SysApiRequestLog",
   "145": "minio_url.py",
   "146": "__init__.py",
   "147": "Community 147",
   "148": "storage.py",
   "149": "Community 149",
-  "150": "ContractListQuery",
   "151": "Community 151",
-  "152": "MinIOStorage",
   "153": "Community 153",
   "154": "PlCarrier",
   "155": "Community 155",
-  "156": "get_client_ip",
   "157": "Community 157",
   "158": "Community 158",
   "159": "minio_url.py",
   "160": "register_local_callback",
   "161": "backfill_crm_contract_attachment_urls.py",
-  "162": "crm_models.py",
-  "163": "login_crypto.py",
   "164": "ethnic.py",
   "165": "Community 165",
   "166": "code:block1 (/iflytek/shanxia2.0/backend)",
@@ -170,19 +162,17 @@
   "168": "vehicle_urea.py",
   "169": "product.py",
   "170": "test_quote_approver_setting.py",
-  "171": "BaseStorage",
-  "172": "LocalStorage",
   "173": "resolve_create_time_bounds",
   "174": "datetime_parse.py",
   "175": "vehicle_maintenance.py",
   "176": "_forbid_legacy_invoice_fields",
   "177": "vehicle_maintenance.py",
-  "178": ".to_tenant_user_dict",
+  "178": "product_allowed",
   "179": "_ensure_subpack_slip_no",
   "180": "menu.py",
-  "181": "get_db_current_user_optional",
   "185": "vehicle_urea.py",
   "186": "transport_address.py",
+  "187": "allocate_next_biz_no",
   "189": "create",
   "190": "menu.py",
   "192": "pool_rule.py",

+ 8 - 0
backend/graphify-out/2026-08-04/.graphify_labels.json

@@ -177,12 +177,20 @@
   "175": "vehicle_maintenance.py",
   "176": "_forbid_legacy_invoice_fields",
   "177": "vehicle_maintenance.py",
+  "178": "product_allowed",
   "179": "_ensure_subpack_slip_no",
   "180": "menu.py",
+  "181": "storage.py",
+  "182": "QiniuStorage",
+  "183": "assert_products_allowed_for_supplier",
+  "184": "pl_transport_site_service.py",
   "185": "vehicle_urea.py",
   "186": "transport_address.py",
+  "187": "allocate_next_biz_no",
+  "188": "oss.py",
   "189": "create",
   "190": "menu.py",
+  "191": "CrmProductBrand",
   "192": "pool_rule.py",
   "197": "_coerce_resource_snapshot",
   "198": "user.py",

+ 219 - 179
backend/graphify-out/2026-08-04/GRAPH_REPORT.md

@@ -1,16 +1,16 @@
 # Graph Report - backend  (2026-08-04)
 
 ## Corpus Check
-- 306 files · ~207,829 words
+- 307 files · ~208,617 words
 - Verdict: corpus is large enough that graph structure adds value.
 
 ## Summary
-- 4579 nodes · 15550 edges · 531 communities (515 shown, 16 thin omitted)
+- 4609 nodes · 15615 edges · 539 communities (523 shown, 16 thin omitted)
 - Extraction: 97% EXTRACTED · 3% INFERRED · 0% AMBIGUOUS · INFERRED: 410 edges (avg confidence: 0.53)
 - Token cost: 0 input · 0 output
 
 ## Graph Freshness
-- Built from commit: `012a2ad6`
+- Built from commit: `5fe53c54`
 - Run `git rev-parse HEAD` and compare to check if the graph is stale.
 - Run `graphify update .` after code changes (no API cost).
 
@@ -148,8 +148,16 @@
 - [[_COMMUNITY_LocalStorage|LocalStorage]]
 - [[_COMMUNITY_resolve_create_time_bounds|resolve_create_time_bounds]]
 - [[_COMMUNITY_datetime_parse.py|datetime_parse.py]]
+- [[_COMMUNITY_product_allowed|product_allowed]]
 - [[_COMMUNITY__ensure_subpack_slip_no|_ensure_subpack_slip_no]]
 - [[_COMMUNITY_menu.py|menu.py]]
+- [[_COMMUNITY_storage.py|storage.py]]
+- [[_COMMUNITY_QiniuStorage|QiniuStorage]]
+- [[_COMMUNITY_assert_products_allowed_for_supplier|assert_products_allowed_for_supplier]]
+- [[_COMMUNITY_pl_transport_site_service.py|pl_transport_site_service.py]]
+- [[_COMMUNITY_allocate_next_biz_no|allocate_next_biz_no]]
+- [[_COMMUNITY_oss.py|oss.py]]
+- [[_COMMUNITY_CrmProductBrand|CrmProductBrand]]
 - [[_COMMUNITY_crm_quote_pdf.py|crm_quote_pdf.py]]
 - [[_COMMUNITY_shanxia2.0 后端骨架(FastAPI)|shanxia2.0 后端骨架(FastAPI)]]
 - [[_COMMUNITY_api_crypto_middleware.py|api_crypto_middleware.py]]
@@ -171,11 +179,11 @@
 - [[_COMMUNITY_PlanResourceSnapshotMixin|PlanResourceSnapshotMixin]]
 
 ## God Nodes (most connected - your core abstractions)
-1. `BaseModel` - 442 edges
-2. `get_tenant_no()` - 349 edges
+1. `BaseModel` - 443 edges
+2. `get_tenant_no()` - 350 edges
 3. `DbUserContext` - 254 edges
-4. `success_response()` - 253 edges
-5. `error_response()` - 235 edges
+4. `success_response()` - 254 edges
+5. `error_response()` - 236 edges
 6. `generate_uuid()` - 195 edges
 7. `BxUserContext` - 183 edges
 8. `crm_user_info()` - 137 edges
@@ -197,79 +205,79 @@
 ## Import Cycles
 - None detected.
 
-## Communities (531 total, 16 thin omitted)
+## Communities (539 total, 16 thin omitted)
 
 ### Community 0 - "Community 0"
-Cohesion: 0.11
-Nodes (41): approve_settlement_legacy(), cancel_settlement(), create_settlement(), delete_settlement(), disburse_settlement(), _generate_settlement_no(), get_settlement(), get_settlement_approval_flow() (+33 more)
+Cohesion: 0.16
+Nodes (32): check_document_expiry(), document_reminder_stats(), get_inventory_ledger(), get_summary(), list_document_reminders(), list_transactions(), list_warnings(), date (+24 more)
 
 ### Community 1 - "Community 1"
 Cohesion: 0.08
-Nodes (28): ContractApprovalActionBody, ContractApprovalPassBody, ContractApprovalRejectBody, ContractApprovalTransferBody, ContractBatchAssignBody, ContractBatchSubmitBody, ContractChangeCreateBody, ContractChangeSubmitBody (+20 more)
+Nodes (36): CRM 合同 API 路由 — GET/PUT/DELETE/POST 对齐原 Java CRM, ContractApproverSettingSaveBody, ContractApprovalActionBody, ContractApprovalPassBody, ContractApprovalRejectBody, ContractApprovalTransferBody, ContractBatchAssignBody, ContractBatchSubmitBody (+28 more)
 
 ### Community 2 - "Community 2"
 Cohesion: 0.15
 Nodes (11): BxAdvanceApply, BxAdvanceApproval, AdvanceService, Any, Session, 同一节点多次审批时,取 approval_time 最新的一条作为当前节点状态。, 返回全部审批动作,按时间正序排列,用于展示完整审批历史。, Any (+3 more)
 
 ### Community 3 - "Community 3"
-Cohesion: 0.08
-Nodes (98): attachment_download_url(), attachment_preview_url(), AttachmentDownloadUrlBody, create_dept(), create_dict_data(), create_dict_type(), create_menu(), create_post() (+90 more)
+Cohesion: 0.09
+Nodes (88): attachment_download_url(), attachment_preview_url(), AttachmentDownloadUrlBody, create_dept(), create_dict_data(), create_dict_type(), create_menu(), create_post() (+80 more)
 
 ### Community 4 - "Community 4"
-Cohesion: 0.12
-Nodes (61): _apply_list_filters(), assign_opportunities(), batch_update_expect_date(), batch_update_stage(), change_stage(), create_opportunity(), _decimal_value(), _enrich_user_names() (+53 more)
+Cohesion: 0.09
+Nodes (76): _apply_list_filters(), assign_opportunities(), batch_update_expect_date(), batch_update_stage(), change_stage(), create_opportunity(), _decimal_value(), _enrich_user_names() (+68 more)
 
 ### Community 5 - "Community 5"
 Cohesion: 0.20
 Nodes (24): count_source_rows(), derive_source_url(), fetch_portal_admin_id(), fetch_source_rows(), legacy_id_to_str(), load_runtime_settings(), load_settings_env(), load_user_mapping() (+16 more)
 
 ### Community 6 - "Community 6"
-Cohesion: 0.19
-Nodes (31): assign_customer(), batch_claim_customers(), check_duplicate_customer(), claim_customer(), create_customer(), deal_customer(), _enrich_user_names(), _ensure_customer_in_scope() (+23 more)
+Cohesion: 0.18
+Nodes (32): assign_customer(), batch_claim_customers(), check_duplicate_customer(), claim_customer(), create_customer(), deal_customer(), _enrich_user_names(), _ensure_customer_in_scope() (+24 more)
 
 ### Community 7 - "Community 7"
 Cohesion: 0.12
 Nodes (36): get_password_hash(), Namespace, build_merged_users(), bx_role_labels(), check_minio(), check_mysql(), check_redis(), _clip() (+28 more)
 
 ### Community 8 - "Community 8"
-Cohesion: 0.11
-Nodes (47): _build_quote_filters(), calculate_quote_amount(), create_new_version(), create_quote(), _decimal_value(), _enrich_contact_fields(), _enrich_supplier_name(), _fill_contract_linked_count() (+39 more)
+Cohesion: 0.10
+Nodes (48): _build_quote_filters(), calculate_quote_amount(), create_new_version(), create_quote(), _decimal_value(), _enrich_contact_fields(), _enrich_supplier_name(), _fill_contract_linked_count() (+40 more)
 
 ### Community 11 - "Community 11"
-Cohesion: 0.10
-Nodes (55): cancel_apply(), create_apply(), create_disburse(), delete_applies(), delete_disburses(), get_apply(), get_disburse(), list_applies() (+47 more)
+Cohesion: 0.15
+Nodes (40): PlVehicleUreaApply, PlVehicleUreaDisburse, 车辆尿素申请 pl_vehicle_urea_apply, 车辆尿素发放登记 pl_vehicle_urea_disburse, Decimal, VehicleUreaApplyCreate, VehicleUreaApplyRead, VehicleUreaApplyUpdate (+32 more)
 
 ### Community 12 - "Community 12"
-Cohesion: 0.03
-Nodes (97): category_add(), category_delete(), category_tree(), category_update(), contact_add(), contact_delete(), contact_update(), customer_create() (+89 more)
+Cohesion: 0.05
+Nodes (70): contact_add(), customer_create(), customer_update(), customer_name_exists(), BaseModel, AttachmentUploadResponse, ChangePasswordRequest, Config (+62 more)
 
 ### Community 13 - "Community 13"
-Cohesion: 0.15
-Nodes (32): create_instance(), create_process_def(), create_task(), get_all_tasks_for_business(), get_instance(), get_latest_version(), get_nodes_by_version(), get_pending_tasks_by_node() (+24 more)
+Cohesion: 0.16
+Nodes (31): create_instance(), create_process_def(), create_task(), get_all_tasks_for_business(), get_instance(), get_latest_version(), get_nodes_by_version(), get_pending_tasks_by_node() (+23 more)
 
 ### Community 14 - "Community 14"
-Cohesion: 0.16
-Nodes (31): bx_health(), 报销(bx)API 路由聚合 — REST 风格,协议对齐 bx 原系统。, P0 健康检查:验证 bx 路由已挂载且响应协议为 code=0。, approve_reimburse(), approved_by_me(), _build_details_data(), create_reimburse(), delete_reimburse() (+23 more)
+Cohesion: 0.12
+Nodes (20): get_menu_list(), 运营端菜单接口(与 web-admin 前端静态路由 sqxp.ts 对齐,14 个一级菜单), menu_badge_stats(), Session, Session, recognize_cert(), RecognizeCertBody, RecognizeCertResult (+12 more)
 
 ### Community 15 - "Community 15"
 Cohesion: 0.11
 Nodes (13): BxReimburseApply, BxReimburseApproval, BxReimburseDetail, 报销单勾选的发票附件(同一发票可勾选多个附件,各占一条)。, ReimburseInvoiceBriefOut, ReimburseInvoiceLinkIn, Any, Session (+5 more)
 
 ### Community 16 - "Community 16"
-Cohesion: 0.18
-Nodes (36): PlVehicleRechargeApply, PlVehicleRechargeRecord, 车辆ETC/加油充值申请 pl_vehicle_recharge_apply, 车辆ETC/加油充值发放登记 pl_vehicle_recharge_record, 发放登记页:申请单 + 关联发放信息(左连接), VehicleRechargeApplyRead, VehicleRechargeDisburseBoardItem, VehicleRechargeRecordRead (+28 more)
+Cohesion: 0.14
+Nodes (41): PlVehicleRechargeApply, PlVehicleRechargeRecord, 车辆ETC/加油充值申请 pl_vehicle_recharge_apply, 车辆ETC/加油充值发放登记 pl_vehicle_recharge_record, Decimal, 发放登记页:申请单 + 关联发放信息(左连接), VehicleRechargeApplyCreate, VehicleRechargeApplyRead (+33 more)
 
 ### Community 18 - "Community 18"
 Cohesion: 0.15
 Nodes (30): advance_pending_approval_stats(), advance_status_counts(), approve_advance(), approved_by_me(), create_advance(), delete_advance(), _fill_offset_amounts(), get_advance() (+22 more)
 
 ### Community 19 - "Community 19"
-Cohesion: 0.11
-Nodes (36): _avatar_url_field(), _build_user_info_payload(), _jwt_user_payload(), logout(), 公共接口(Web 登录、刷新 Token、登出;用户模型对齐 docs/sql/shanxia2.0.sql 基线), 登出:吊销 Redis 会话(若已配置 REDIS_HOST)。, 与 web-admin 静态路由 meta.roles(admin/super_admin)对齐的单元素数组。, 与 web-admin `userInfo` 字段约定一致。 (+28 more)
+Cohesion: 0.12
+Nodes (34): _avatar_url_field(), _build_user_info_payload(), _jwt_user_payload(), logout(), 公共接口(Web 登录、刷新 Token、登出;用户模型对齐 docs/sql/shanxia2.0.sql 基线), 登出:吊销 Redis 会话(若已配置 REDIS_HOST)。, 与 web-admin 静态路由 meta.roles(admin/super_admin)对齐的单元素数组。, 与 web-admin `userInfo` 字段约定一致。 (+26 more)
 
 ### Community 21 - "Community 21"
-Cohesion: 0.06
-Nodes (74): _alias_row_to_dict(), _assert_brand_deletable(), barcode_exists(), _brand_row_to_dict(), _build_category_tree(), category_code_exists(), _category_row_to_dict(), _collect_category_with_ancestors() (+66 more)
+Cohesion: 0.10
+Nodes (54): _alias_row_to_dict(), _assert_brand_deletable(), barcode_exists(), _brand_row_to_dict(), _build_category_tree(), category_code_exists(), _category_row_to_dict(), _collect_category_with_ancestors() (+46 more)
 
 ### Community 22 - "Community 22"
 Cohesion: 0.08
@@ -280,28 +288,28 @@ Cohesion: 0.11
 Nodes (8): convert_heic_to_jpeg(), OSSStorage, process_image_content(), QiniuStorage, 文件存储工具模块  支持多种存储方式: 1. 本地存储 (local) - 默认 2. 七牛云存储 (qiniu) - 推荐生产环境使用 3. 阿里云OSS (, 将 HEIC/HEIF 格式转换为 JPEG 格式, 处理图片内容,如果是 HEIC 格式则转换为 JPEG, BytesIO
 
 ### Community 24 - "Community 24"
-Cohesion: 0.09
-Nodes (34): SoftDeleteModel, BizAttachment, 用户-职位关联 sys_user_post, 民族码表 sys_ethnic(国标 GB/T 3304,全局), 用户-角色关联 sys_user_role(V0.3), SysEthnic, SysUserPost, SysUserRole (+26 more)
+Cohesion: 0.10
+Nodes (19): category_add(), category_delete(), category_tree(), category_update(), product_add(), product_delete(), product_detail(), 删除产品(支持单条 body.id 和批量 body.ids) (+11 more)
 
 ### Community 25 - "Community 25"
-Cohesion: 0.16
-Nodes (22): PlTransportProductFeedback, 运输单按产品回传 pl_transport_product_feedback, _dict_field(), format_brand_qty_summary(), load_transport_driver_product_feedbacks(), persist_io_item_brand_qtys(), persist_transport_product_feedback(), Any (+14 more)
+Cohesion: 0.14
+Nodes (24): PlTransportProductBrandQty, PlTransportProductFeedback, 运输单按产品回传 pl_transport_product_feedback, 运输单产品回传品牌数量 pl_transport_product_brand_qty, _dict_field(), format_brand_qty_summary(), load_transport_driver_product_feedbacks(), persist_io_item_brand_qtys() (+16 more)
 
 ### Community 26 - "Community 26"
-Cohesion: 0.07
-Nodes (36): 地磅 API 路由聚合 — REST 风格,协议对齐原 simple-dibang-xiaoshou。, list_public_vehicle_plates(), Session, 地磅公共只读:免登车牌 options(现场填写页), 免登:按出入库/计划解析 tenant_no,返回 pl_vehicle 车牌(self + carrier)。, _resolve_tenant_no(), API 路由包 — 山峡化工生产一体化门户, get_menu_list() (+28 more)
+Cohesion: 0.16
+Nodes (31): bx_health(), 报销(bx)API 路由聚合 — REST 风格,协议对齐 bx 原系统。, P0 健康检查:验证 bx 路由已挂载且响应协议为 code=0。, approve_reimburse(), approved_by_me(), _build_details_data(), create_reimburse(), delete_reimburse() (+23 more)
 
 ### Community 27 - "Community 27"
 Cohesion: 0.13
-Nodes (41): _apply_plan_product_update(), _apply_plan_update(), AutoGenerateMonthlyResult, _base_query(), create_plan(), _generate_plan_no(), get_plan(), _get_plan_by_id_only() (+33 more)
+Nodes (42): _apply_plan_product_update(), _apply_plan_update(), AutoGenerateMonthlyResult, _base_query(), create_plan(), _generate_plan_no(), get_plan(), _get_plan_by_id_only() (+34 more)
 
 ### Community 28 - "Community 28"
-Cohesion: 0.05
-Nodes (101): check_document_expiry(), document_reminder_stats(), get_inventory_ledger(), get_summary(), list_document_reminders(), list_transactions(), list_warnings(), date (+93 more)
+Cohesion: 0.06
+Nodes (94): approve_settlement_legacy(), cancel_settlement(), create_settlement(), delete_settlement(), disburse_settlement(), _generate_settlement_no(), get_settlement(), get_settlement_approval_flow() (+86 more)
 
 ### Community 29 - "Community 29"
-Cohesion: 0.20
-Nodes (20): _build_public_page(), _build_site_product_read(), _format_file_size(), get_public_site(), _get_site_link_by_token(), _parse_feedback_images(), Session, UploadFile (+12 more)
+Cohesion: 0.12
+Nodes (31): _build_public_page(), _build_site_product_read(), _format_file_size(), get_public_site(), _get_site_link_by_token(), _parse_feedback_images(), Session, UploadFile (+23 more)
 
 ### Community 30 - "Community 30"
 Cohesion: 0.16
@@ -312,32 +320,32 @@ Cohesion: 0.20
 Nodes (15): bind_biz(), delete_attachment(), download_file(), list_by_biz(), _parse_id_list(), preview_attachment(), Session, UploadFile (+7 more)
 
 ### Community 34 - "Community 34"
-Cohesion: 0.06
-Nodes (50): _claims_from_auth(), _format_body_bytes(), _persist_log(), Any, Request, 统一记录 API 请求/响应出入参的中间件, _redact_obj(), _schedule_persist_log() (+42 more)
+Cohesion: 0.15
+Nodes (31): approve_task(), _assert_wf_instance_in_scope(), _business_type_label(), create_process_def(), _enrich_task_list(), get_business_all_tasks(), _get_business_form_fields(), get_designer_data() (+23 more)
 
 ### Community 35 - "Community 35"
 Cohesion: 0.18
 Nodes (36): clear_portal_workflow(), _dec(), derive_source_url(), fetch_portal_admin_id(), fetch_source_rows(), legacy_id_to_str(), load_bx_user_mapping(), load_runtime_settings() (+28 more)
 
 ### Community 36 - "Community 36"
-Cohesion: 0.18
-Nodes (25): approve_task(), _assert_wf_instance_in_scope(), _business_type_label(), create_process_def(), delete_process_def(), _enrich_task_list(), get_business_all_tasks(), _get_business_form_fields() (+17 more)
+Cohesion: 0.14
+Nodes (15): 流程实例 wf_process_instance, WfProcessInstance, _dispatch_local(), Any, 工作流回调服务 —— 流程状态变更时通知业务系统, 注册本地回调函数。当 callback_url 以 path 开头时直接调用 fn。, 尝试本地直调。返回 True 表示已处理,False 表示无匹配的本地回调。, 流程实例状态变更后,向业务系统发送回调通知。      优先级:     1. 如果 callback_url 是内部路径(以 / 开头),优先尝试本地直调 (+7 more)
 
 ### Community 37 - "Community 37"
-Cohesion: 0.17
-Nodes (26): delete_plan(), delete_carrier(), delete_driver(), delete_personnel(), delete_vehicle(), unbind_vehicle_driver(), delete_plan(), _actor_ids() (+18 more)
+Cohesion: 0.19
+Nodes (23): delete_plan(), delete_carrier(), unbind_vehicle_driver(), delete_plan(), _actor_ids(), _actor_names(), assert_row_deletable_by_creator(), assert_rows_deletable_by_creator() (+15 more)
 
 ### Community 38 - "Community 38"
-Cohesion: 0.14
-Nodes (25): load_brand_qtys_by_plan_product_ids(), persist_plan_product_brand_qtys(), Any, Decimal, Session, 按计划产品明细 ID 批量加载归档品牌数量(brandId/brandName/qty)。, 软删旧品牌量行后按归档结果插入;无品牌约定则只软删不插入。, validate_brand_qty_rows() (+17 more)
+Cohesion: 0.21
+Nodes (15): load_brand_qtys_by_plan_product_ids(), persist_plan_product_brand_qtys(), Any, Decimal, Session, 按计划产品明细 ID 批量加载归档品牌数量(brandId/brandName/qty)。, 软删旧品牌量行后按归档结果插入;无品牌约定则只软删不插入。, validate_brand_qty_rows() (+7 more)
 
 ### Community 39 - "Community 39"
 Cohesion: 0.22
 Nodes (28): assign_clues(), check_convert(), check_duplicate_clue(), convert_clue(), create_clue(), _enrich_user_names(), _ensure_clue_in_scope(), get_clue() (+20 more)
 
 ### Community 42 - "Community 42"
-Cohesion: 0.19
-Nodes (32): _dec(), derive_source_url(), fetch_portal_admin_id(), fetch_source_rows(), legacy_id_to_str(), load_oss_id_to_url(), load_runtime_settings(), load_settings_env() (+24 more)
+Cohesion: 0.20
+Nodes (31): _dec(), derive_source_url(), fetch_portal_admin_id(), fetch_source_rows(), legacy_id_to_str(), load_oss_id_to_url(), load_runtime_settings(), load_settings_env() (+23 more)
 
 ### Community 43 - "Community 43"
 Cohesion: 0.10
@@ -348,28 +356,28 @@ Cohesion: 0.11
 Nodes (18): ApiCryptoMiddleware, ApiRequestLogMiddleware, _db_pool_keepalive_loop(), _error_json(), lifespan(), Exception, Request, 数据库异常:返回 JSON 并保留 CORS 头,避免浏览器只报跨域错误 (+10 more)
 
 ### Community 45 - "Community 45"
-Cohesion: 0.09
-Nodes (69): _build_driver_url(), get_plan_arrange_info(), 获取计划已安排运输后的司机链接与地磅出入库关联(供查看弹窗复制简述/二维码)。, _apply_plan_logistics_from_payload(), _apply_transport_arrange_fields(), arrange_transport(), _assert_vehicle_carrier_eligible(), _build_arrange_result() (+61 more)
+Cohesion: 0.10
+Nodes (58): _apply_plan_logistics_from_payload(), _apply_transport_arrange_fields(), arrange_transport(), _assert_vehicle_carrier_eligible(), _build_arrange_result(), _build_driver_url(), create_transport(), _ensure_driver_access_token() (+50 more)
 
 ### Community 46 - "Community 46"
-Cohesion: 0.14
-Nodes (30): _apply_contract_entity_fields(), _build_contract_filters(), _build_customer_address(), _calc_amount_with_tax(), contract_no_exists(), _contract_period_key(), create_contract(), _decimal_value() (+22 more)
+Cohesion: 0.19
+Nodes (16): align_contract_no_to_sign_date(), date, 标准编号替换日期段,保留序号;非标准返回 None。, 将标准合同编号日期段对齐签订日;撞号则序号顺延(含软删查重)。      非标准编号原样返回。无签订日则原样返回。, replace_contract_no_date(), _mock_last_contract(), 软删占用的编号仍占唯一索引,生成时须跳过(对齐 uk_contract_tenant_no)。, 取最大流水号须含软删,避免复用已软删的最大编号。 (+8 more)
 
 ### Community 48 - "Community 48"
-Cohesion: 0.15
-Nodes (31): _apply_inventory_product_update(), _apply_inventory_update(), _base_query(), create_inventory(), create_link_for_plan(), delete_inventory(), _generate_batch_no(), _get_inventory() (+23 more)
+Cohesion: 0.17
+Nodes (26): 地磅 API 路由聚合 — REST 风格,协议对齐原 simple-dibang-xiaoshou。, _apply_inventory_product_update(), _apply_inventory_update(), _base_query(), create_inventory(), create_link_for_plan(), delete_inventory(), _generate_batch_no() (+18 more)
 
 ### Community 49 - "Community 49"
-Cohesion: 0.21
-Nodes (17): apply_crm_create_by_scope(), _apply_list_filters(), create_supplier_info(), list_all_supplier_info(), list_supplier_info(), Any, Session, CRM 供方信息 CRUD — 对照 CrmSupplierInfoServiceImpl.java (+9 more)
+Cohesion: 0.22
+Nodes (17): _apply_list_filters(), create_supplier_info(), get_supplier_info(), list_all_supplier_info(), list_supplier_info(), Any, Session, CRM 供方信息 CRUD — 对照 CrmSupplierInfoServiceImpl.java (+9 more)
 
 ### Community 50 - "Community 50"
-Cohesion: 0.17
-Nodes (8): 发送订单状态通知                  Args:             openid: 用户openid             order_n, 发送支付成功通知                  Args:             openid: 用户openid             order_n, 发送配送通知                  Args:             openid: 配送员openid             task_no:, 发送配送时效预警                  Args:             openid: 配送员openid             task_n, 发送退款结果通知                  Args:             openid: 用户openid             order_n, 发送催单通知给配送员                  Args:             deliver_openid: 配送员openid, 发送模板消息                  Args:             openid: 用户openid             template_, WechatMessageService
+Cohesion: 0.15
+Nodes (9): 微信消息通知服务  支持微信小程序模板消息推送  使用方式:     from app.core.wechat_message import WechatMes, 发送订单状态通知                  Args:             openid: 用户openid             order_n, 发送支付成功通知                  Args:             openid: 用户openid             order_n, 发送配送通知                  Args:             openid: 配送员openid             task_no:, 发送配送时效预警                  Args:             openid: 配送员openid             task_n, 发送退款结果通知                  Args:             openid: 用户openid             order_n, 发送催单通知给配送员                  Args:             deliver_openid: 配送员openid, 发送模板消息                  Args:             openid: 用户openid             template_ (+1 more)
 
 ### Community 51 - "Community 51"
-Cohesion: 0.14
-Nodes (37): PlPlanProduct, 计划产品明细表 pl_plan_product, PlanArchiveProductItem, PlanProductCreate, PlanTransportCreateBlock, all_hazard_products_cert_complete(), apply_archive_product_quantities(), _apply_payload_to_transport_row() (+29 more)
+Cohesion: 0.10
+Nodes (62): create_plan_full(), _generate_notify_message(), list_plans(), 列表展示用:优先 CRM 标准名(详情仍返回库内 product_name,以便编辑反推别名)。, 创建运输计划(完整表单:合同产品 + 可选预选车辆,不自动安排运输), _resolve_list_product_name(), update_plan(), PlPlan (+54 more)
 
 ### Community 52 - "Community 52"
 Cohesion: 0.18
@@ -380,28 +388,28 @@ Cohesion: 0.09
 Nodes (41): 报销模块认证适配:门户 JWT 用户 → bx 业务上下文。, BxReimburseInvoice, BxReimburseOffset, BxWorkflowNode, 报销(bx)模块数据模型 — 对齐 docs/sql/20260606_bx_tables.sql, filter_current_cycle_approvals(), 审批轮次过滤 — 驳回后重新提交时,进度接口仅展示当前轮次。, 审批进度仅展示当前轮次;完整历史由 get_approval_history 返回。 (+33 more)
 
 ### Community 54 - "Community 54"
-Cohesion: 0.19
-Nodes (28): _get_by_plan(), get_inbound(), get_inbound_by_plan(), _get_order(), get_outbound(), get_outbound_by_plan(), inbound_site_url(), list_inbound() (+20 more)
+Cohesion: 0.18
+Nodes (29): _get_by_plan(), get_inbound(), get_inbound_by_plan(), _get_order(), get_outbound(), get_outbound_by_plan(), inbound_site_url(), list_inbound() (+21 more)
 
 ### Community 58 - "Community 58"
 Cohesion: 0.15
-Nodes (33): CRM 合同子模块路由 — 变更/模板/审批独立页, register_contract_sub_routes(), _change_row_to_dict(), create_contract_change(), create_contract_template(), _enrich_change_rows(), execute_change(), export_contract_changes() (+25 more)
+Nodes (35): CRM 合同子模块路由 — 变更/模板/审批独立页, register_contract_sub_routes(), _change_row_to_dict(), create_contract_change(), create_contract_template(), _enrich_change_rows(), execute_change(), export_contract_changes() (+27 more)
 
 ### Community 59 - "Community 59"
 Cohesion: 0.20
 Nodes (28): _dec(), derive_source_url(), fetch_portal_admin_id(), fetch_source_rows(), legacy_id_to_str(), load_oss_id_to_url(), load_runtime_settings(), load_settings_env() (+20 more)
 
 ### Community 60 - "Community 60"
-Cohesion: 0.15
-Nodes (24): cancel_apply(), create_apply(), create_record(), delete_applies(), delete_records(), get_apply(), get_record(), list_applies() (+16 more)
+Cohesion: 0.07
+Nodes (51): operlog_detail(), operlog_list(), Session, 操作日志分页列表(基于 API 请求日志适配 RuoYi OperLog 结构), _user_info(), _claims_from_auth(), _format_body_bytes(), _persist_log() (+43 more)
 
 ### Community 61 - "Community 61"
-Cohesion: 0.14
-Nodes (36): DbInboundOutbound, PlTransportDbLink, 运输-地磅出入库关联 pl_transport_db_link, parse_date_str(), _apply_plan_quantity_delta(), _create_db_inventory(), _create_db_plan(), DibangInventoryLinkResult (+28 more)
+Cohesion: 0.15
+Nodes (30): DbPurchasePlan, apply_product_snapshot_to_plan(), ProductSnapshot, Session, 地磅模块 — CRM 产品解析与快照写入。, 校验 CRM 产品并返回名称/规格快照。新建单据 product_id 必填。, resolve_crm_product(), _apply_plan_quantity_delta() (+22 more)
 
 ### Community 62 - "Community 62"
-Cohesion: 0.21
-Nodes (22): clear_target_products(), count_target_rows(), _dec(), derive_source_url(), fetch_portal_admin_id(), fetch_source_rows(), legacy_id_to_str(), load_runtime_settings() (+14 more)
+Cohesion: 0.20
+Nodes (19): cancel_apply(), create_apply(), create_disburse(), delete_applies(), delete_disburses(), get_apply(), get_disburse(), list_applies() (+11 more)
 
 ### Community 63 - "Community 63"
 Cohesion: 0.20
@@ -409,11 +417,11 @@ Nodes (13): create_expense_item(), delete_expense_item(), get_expense_item(), ge
 
 ### Community 64 - "Community 64"
 Cohesion: 0.04
-Nodes (168): clue_detail(), clue_export(), clue_follow_detail(), clue_follow_statistics(), clue_import(), clue_import_template(), clue_list(), clue_mine() (+160 more)
+Nodes (184): clue_assign(), clue_check_convert(), clue_check_duplicate(), clue_convert(), clue_create(), clue_delete(), clue_detail(), clue_export() (+176 more)
 
 ### Community 65 - "Community 65"
-Cohesion: 0.10
-Nodes (58): cancel_apply(), create_apply(), create_process(), delete_applies(), delete_processes(), get_apply(), get_process(), list_applies() (+50 more)
+Cohesion: 0.19
+Nodes (34): PlVehicleMaintenanceApply, PlVehicleMaintenanceProcess, 车辆维保申请 pl_vehicle_maintenance_apply, 车辆维保处理登记 pl_vehicle_maintenance_process, VehicleMaintenanceApplyRead, VehicleMaintenanceProcessBoardItem, apply_to_read(), _assert_vehicle_exists() (+26 more)
 
 ### Community 66 - "Community 66"
 Cohesion: 0.15
@@ -421,15 +429,15 @@ Nodes (24): create_workflow(), delete_workflow(), get_workflow(), get_workflow_b
 
 ### Community 67 - "Community 67"
 Cohesion: 0.17
-Nodes (17): CertRead, SnapshotCertRead, SnapshotPersonnelRow, build_personnel_summary(), load_vehicle_personnel_rows(), load_vehicle_personnel_summaries(), Session, 运输计划 - 人员 upsert 与车辆-人员关联保存 (+9 more)
+Nodes (21): _build_public_page(), _format_file_size(), _format_plan_date(), get_public_transport(), _get_transport_by_token(), _parse_feedback_images(), Session, UploadFile (+13 more)
 
 ### Community 68 - "Community 68"
-Cohesion: 0.21
-Nodes (23): create_vehicle(), get_vehicle(), paste_recognize_commit(), update_vehicle(), _vehicle_to_detail(), _vehicle_to_read(), PlVehicle, VehicleDetailRead (+15 more)
+Cohesion: 0.13
+Nodes (38): bind_vehicle_driver(), create_vehicle(), get_vehicle(), paste_recognize_commit(), update_vehicle(), _vehicle_to_detail(), _vehicle_to_read(), generate_uuid() (+30 more)
 
 ### Community 69 - "Community 69"
-Cohesion: 0.15
-Nodes (27): _append_user_scope_conditions(), apply_data_scope(), assert_row_in_data_scope(), _collect_scope_ids(), _get_child_dept_ids(), get_user_dept_id(), Session, 数据权限过滤(V0.3:基于角色 data_scope 的查询级行级过滤)  data_scope 值:   1 = 全部数据   2 = 本部门数据   3 (+19 more)
+Cohesion: 0.13
+Nodes (29): _append_user_scope_conditions(), apply_data_scope(), assert_row_in_data_scope(), _collect_scope_ids(), _get_child_dept_ids(), get_user_dept_id(), Session, 数据权限过滤(V0.3:基于角色 data_scope 的查询级行级过滤)  data_scope 值:   1 = 全部数据   2 = 本部门数据   3 (+21 more)
 
 ### Community 70 - "Community 70"
 Cohesion: 0.39
@@ -437,43 +445,43 @@ Nodes (10): create_post(), get_post(), list_posts(), post_code_exists(), Any, Se
 
 ### Community 71 - "Community 71"
 Cohesion: 0.10
-Nodes (35): CRM 报价单 API 路由 — 挂接到 crm.router, 接口菜单权限守卫。super_admin 直接放行。, require_menu_code(), total_pages(), QuoteApproverSettingSaveBody, QuoteAcceptBody, QuoteApprovalApproveBody, QuoteApprovalListBody (+27 more)
+Nodes (33): CRM 报价单 API 路由 — 挂接到 crm.router, total_pages(), QuoteApproverSettingSaveBody, QuoteAcceptBody, QuoteApprovalApproveBody, QuoteApprovalListBody, QuoteApprovalRefreshNamesBody, QuoteApprovalWithdrawBody (+25 more)
 
 ### Community 72 - "Community 72"
-Cohesion: 0.19
-Nodes (28): apply_biz_backfill(), BackfillRule, BizRef, build_biz_index(), count_target_rows(), derive_source_url(), fetch_portal_admin_id(), fetch_source_rows() (+20 more)
+Cohesion: 0.17
+Nodes (30): apply_biz_backfill(), BackfillRule, BizRef, build_biz_index(), count_target_rows(), derive_source_url(), fetch_portal_admin_id(), fetch_source_rows() (+22 more)
 
 ### Community 73 - "Community 73"
 Cohesion: 0.20
 Nodes (25): derive_source_url(), fetch_portal_admin_id(), fetch_source_rows(), legacy_id_to_str(), load_oss_id_to_url(), load_runtime_settings(), load_settings_env(), load_user_mapping() (+17 more)
 
 ### Community 74 - "Community 74"
-Cohesion: 0.10
-Nodes (27): generate_uuid(), get_current_time(), parse_datetime(), datetime, allocate_next_biz_no(), _format_biz_no(), _prefix_for(), datetime (+19 more)
+Cohesion: 0.12
+Nodes (29): get_pool_record(), list_pool_records(), Any, Session, _row_to_dict(), total_pages(), create_pool_rule(), delete_pool_rules() (+21 more)
 
 ### Community 77 - "Community 77"
 Cohesion: 0.11
 Nodes (12): get_wechat_pay_client(), get_wechat_pay_v2(), Any, 微信支付工具模块  支持微信支付 V3 API 文档参考: https://pay.weixin.qq.com/docs/v3/apis/index.html, 统一下单接口 (V3)          Args:             out_trade_no: 商户订单号             total_amo, 申请退款          Args:             out_trade_no: 商户订单号             total_amount: 订单, 小程序调起支付的二次签名参数(与公众号 JSAPI 规则一致), 统一下单 (V2 API)          Args:             out_trade_no: 商户订单号             total_f (+4 more)
 
 ### Community 78 - "Community 78"
-Cohesion: 0.08
-Nodes (25): clue_assign(), clue_convert(), clue_create(), clue_delete(), clue_follow_create(), clue_follow_delete(), clue_follow_list(), clue_follow_update() (+17 more)
+Cohesion: 0.12
+Nodes (15): pool_rule_add(), pool_rule_delete(), pool_rule_detail(), pool_rule_execute(), pool_rule_list(), pool_rule_update(), pool_rule_update_status(), PoolRuleAddBody (+7 more)
 
 ### Community 81 - "Community 81"
-Cohesion: 0.24
-Nodes (20): register_quote_routes(), accept_quote(), _ensure_quote_in_scope(), generate_pdf(), generate_share(), get_quote(), get_quote_detail(), _get_quote_in_scope() (+12 more)
+Cohesion: 0.17
+Nodes (24): cancel_apply(), create_apply(), create_process(), delete_applies(), delete_processes(), get_apply(), get_process(), list_applies() (+16 more)
 
 ### Community 83 - "Community 83"
-Cohesion: 0.15
-Nodes (30): _advance_contract_after_approval(), approve_contract(), approve_contract_by_contract_id(), approve_pass(), approve_reject(), approve_transfer(), _build_approval_list_filters(), can_user_approve() (+22 more)
+Cohesion: 0.17
+Nodes (28): _advance_contract_after_approval(), approve_contract(), approve_contract_by_contract_id(), approve_pass(), approve_reject(), approve_transfer(), _build_approval_list_filters(), can_user_approve() (+20 more)
 
 ### Community 84 - "Community 84"
 Cohesion: 0.23
 Nodes (23): build_id_maps(), clip_text(), count_rows(), export_mapping(), fetch_rows(), legacy_id_to_str(), main(), map_id() (+15 more)
 
 ### Community 86 - "Community 86"
-Cohesion: 0.19
-Nodes (26): _apply_weighing_product_update(), _apply_weighing_update(), _base_query(), create_weighing(), delete_weighing(), _get_weighing(), get_weighing_related(), list_weighing() (+18 more)
+Cohesion: 0.17
+Nodes (28): _apply_weighing_product_update(), _apply_weighing_update(), _base_query(), create_weighing(), delete_weighing(), _get_weighing(), get_weighing_related(), list_weighing() (+20 more)
 
 ### Community 87 - "Community 87"
 Cohesion: 0.20
@@ -481,23 +489,23 @@ Nodes (19): approve_quote(), can_user_approve(), create_approval_records(), dele
 
 ### Community 88 - "Any"
 Cohesion: 0.18
-Nodes (31): _dec(), derive_source_url(), fetch_portal_admin_id(), fetch_source_rows(), legacy_id_to_str(), legacy_parent_id(), load_oss_id_to_url(), load_runtime_settings() (+23 more)
+Nodes (30): _dec(), derive_source_url(), fetch_portal_admin_id(), fetch_source_rows(), legacy_id_to_str(), legacy_parent_id(), load_oss_id_to_url(), load_runtime_settings() (+22 more)
 
 ### Community 89 - "pl_ocr_service.py"
 Cohesion: 0.19
 Nodes (22): PlOcrUsageMonth, 阿里云 OCR 月度调用计数 pl_ocr_usage_month(按自然月全局统计), assert_quota_available(), _build_ocr_client(), compress_image_bytes(), current_usage_month(), _first_attachment_url(), get_or_create_usage_row() (+14 more)
 
 ### Community 91 - "pl_vehicle_recharge_service.py"
-Cohesion: 0.09
-Nodes (61): CRM 合同 API 路由 — GET/PUT/DELETE/POST 对齐原 Java CRM, register_contract_routes(), batch_assign_owner(), batch_submit_contract_approval(), contract_row_to_dict(), create_from_opportunity(), create_from_quote(), download_contract_pdf() (+53 more)
+Cohesion: 0.07
+Nodes (88): register_contract_routes(), _apply_contract_entity_fields(), delete_pending_approvals(), Java: withdraw — 软删除 pending 审批, batch_assign_owner(), batch_submit_contract_approval(), _build_contract_filters(), _build_contract_name_from_parties() (+80 more)
 
 ### Community 92 - "Community 92"
 Cohesion: 0.16
 Nodes (25): 验证密码(哈希非 bcrypt 或损坏时返回 False,避免抛错), verify_password(), change_password(), create_user(), get_user(), get_user_with_relations(), _hash_password(), list_post_ids_for_user() (+17 more)
 
 ### Community 93 - "_invoice_info_by_customer_impl"
-Cohesion: 0.36
-Nodes (15): create_opportunity_follow(), _ensure_parent_opportunity(), get_opportunity_follow(), list_follows_by_opportunity(), list_opportunity_follows(), _parse_optional_datetime(), Any, datetime (+7 more)
+Cohesion: 0.19
+Nodes (19): cancel_apply(), create_apply(), create_record(), delete_applies(), delete_records(), get_apply(), get_record(), list_applies() (+11 more)
 
 ### Community 94 - "response.py"
 Cohesion: 0.22
@@ -508,8 +516,8 @@ Cohesion: 0.35
 Nodes (11): create_tenant(), get_tenant(), list_tenants(), Any, Session, _row_to_dict(), soft_delete_tenant(), tenant_no_exists() (+3 more)
 
 ### Community 97 - "_ensure_subpack_slip_no"
-Cohesion: 0.10
-Nodes (44): approve_carrier(), create_carrier(), create_driver(), get_carrier(), get_driver(), list_carriers(), list_drivers(), _personnel_to_driver_read() (+36 more)
+Cohesion: 0.21
+Nodes (22): clear_target_products(), count_target_rows(), _dec(), derive_source_url(), fetch_portal_admin_id(), fetch_source_rows(), legacy_id_to_str(), load_runtime_settings() (+14 more)
 
 ### Community 100 - "price_letter_detail"
 Cohesion: 0.27
@@ -528,28 +536,28 @@ Cohesion: 0.29
 Nodes (15): create_price_letter(), get_price_letter(), list_price_letters(), _parse_date(), Any, date, Session, _row_to_dict() (+7 more)
 
 ### Community 105 - "list_customers"
-Cohesion: 0.21
-Nodes (23): bind_vehicle_driver(), create_personnel(), get_personnel(), list_personnel(), list_vehicles(), _personnel_to_detail(), _personnel_to_read(), Session (+15 more)
+Cohesion: 0.13
+Nodes (27): list_personnel(), list_vehicles(), PlCert, PlDocumentReminder, 证件到期提醒表 pl_document_reminder, CertRead, SnapshotCertRead, SnapshotPersonnelRow (+19 more)
 
 ### Community 106 - "Community 106"
-Cohesion: 0.42
-Nodes (11): _enrich_follow_dict(), get_follow(), list_follows(), list_follows_by_customer(), Any, Session, _row_to_dict(), soft_delete_follow() (+3 more)
+Cohesion: 0.24
+Nodes (20): register_quote_routes(), accept_quote(), _ensure_quote_in_scope(), generate_pdf(), generate_share(), get_quote(), get_quote_detail(), _get_quote_in_scope() (+12 more)
 
 ### Community 107 - "apply_pl_scope"
-Cohesion: 0.23
-Nodes (19): create_contact(), get_contact(), list_contacts_by_customer(), _parse_optional_date(), Any, date, Session, _row_to_dict() (+11 more)
+Cohesion: 0.30
+Nodes (12): PlCarrier, assert_carrier_eligible_for_transport(), carrier_agreement_expired(), carrier_audit_approved(), carrier_eligible_for_transport(), carrier_qualification_complete(), date, 资质附件均为选填,保留函数签名供兼容调用。 (+4 more)
 
 ### Community 109 - "Community 109"
 Cohesion: 0.35
 Nodes (11): create_dict_type(), dict_type_code_exists(), get_dict_type(), list_dict_types(), Any, Session, 字典类型 CRUD(sys_dict_type), _row_to_dict() (+3 more)
 
 ### Community 110 - "Base"
-Cohesion: 0.23
-Nodes (13): get_user_menu_codes(), Session, 读取用户授权的菜单权限标识集合(与前端 meta.menuCode / perms 对齐)。, _expand_with_ancestor_menu_ids(), _granted_menu_ids_for_user(), iter_user_menu_perm_codes(), Session, Web 管理端登录:基于 V0.3 sys_user / sys_user_role / sys_role 的角色与菜单权限解析 (+5 more)
+Cohesion: 0.16
+Nodes (19): get_web_auth_menu_codes(), 获取当前用户菜单权限标识(sys_menu.perms,经角色继承)。, get_user_menu_codes(), Session, 读取用户授权的菜单权限标识集合(与前端 meta.menuCode / perms 对齐)。, _expand_with_ancestor_menu_ids(), _granted_menu_ids_for_user(), iter_user_menu_perm_codes() (+11 more)
 
 ### Community 111 - "Community 111"
-Cohesion: 0.28
-Nodes (14): _assert_editable(), _build_public_page(), _format_file_size(), _get_inventory_by_token(), get_public_inventory(), _parse_feedback_images(), Session, UploadFile (+6 more)
+Cohesion: 0.21
+Nodes (17): _assert_editable(), _build_public_page(), _format_file_size(), _get_inventory_by_token(), get_public_inventory(), _parse_feedback_images(), Session, UploadFile (+9 more)
 
 ### Community 112 - "storage.py"
 Cohesion: 0.12
@@ -560,56 +568,56 @@ Cohesion: 0.26
 Nodes (12): list_share_logs(), _parse_user_agent(), Any, Session, CRM 报价单分享访问日志 CRUD — 对照 CrmQuoteShareLogServiceImpl.java, Java: statisticsVisits, 简易 User-Agent 解析(替代 Hutool UserAgentUtil), Java: queryLogsByQuoteId (+4 more)
 
 ### Community 114 - "db_models.py"
-Cohesion: 0.24
-Nodes (12): DbSequence, 地磅(db)模块数据模型 — 对齐 docs/sql/db_tables.sql, _allocate_inbound_outbound_id(), _ensure_sequence_row(), max_numeric_inbound_outbound_id(), next_inbound_outbound_id(), Session, 出入库单 id 生成 — 租户内纯数字自增,并发安全。 (+4 more)
+Cohesion: 0.16
+Nodes (17): list_public_vehicle_plates(), Session, 地磅公共只读:免登车牌 options(现场填写页), 免登:按出入库/计划解析 tenant_no,返回 pl_vehicle 车牌(self + carrier)。, _resolve_tenant_no(), DbSequence, 地磅(db)模块数据模型 — 对齐 docs/sql/db_tables.sql, _allocate_inbound_outbound_id() (+9 more)
 
 ### Community 115 - "site.py"
 Cohesion: 0.28
 Nodes (17): _address_to_read(), _build_address_query(), create_transport_address(), delete_transport_address(), _get_address(), get_transport_address(), list_all_transport_addresses(), list_transport_addresses() (+9 more)
 
 ### Community 116 - "Community 116"
-Cohesion: 0.19
-Nodes (25): calculate_subtotal(), _decimal_value(), delete_products_by_quote_id(), _ensure_quote_parent_scope(), _get_field(), get_quote_product(), insert_quote_product(), list_quote_products() (+17 more)
+Cohesion: 0.22
+Nodes (23): calculate_subtotal(), _decimal_value(), _ensure_quote_parent_scope(), _get_field(), get_quote_product(), insert_quote_product(), list_quote_products(), normalize_line_brand() (+15 more)
 
 ### Community 118 - "Community 118"
 Cohesion: 0.22
-Nodes (22): batch_insert_contract_products(), calculate_subtotal(), _decimal_value(), delete_price_tiers_by_contract_id(), delete_products_by_contract_id(), _get_field(), insert_contract_product(), _letter_oss_ids_to_json() (+14 more)
+Nodes (21): batch_insert_contract_products(), calculate_subtotal(), _decimal_value(), delete_price_tiers_by_contract_id(), delete_products_by_contract_id(), _get_field(), insert_contract_product(), _letter_oss_ids_to_json() (+13 more)
 
 ### Community 119 - "Community 119"
 Cohesion: 0.16
-Nodes (29): CertRow, VehiclePersonnelRow, _cert_row_complete(), collect_required_cert_errors(), _find_cert_for_required(), get_required_personnel_cert_names(), match_required_cert_name(), _missing_field_labels() (+21 more)
+Nodes (28): CertRow, _cert_row_complete(), collect_required_cert_errors(), _find_cert_for_required(), get_required_personnel_cert_names(), match_required_cert_name(), _missing_field_labels(), Session (+20 more)
 
 ### Community 122 - "Community 122"
-Cohesion: 0.38
-Nodes (13): ensure_crm_customer_linked_row_in_scope(), 客户子表(开票信息等):先校验关联客户 owner scope,否则校验 create_by。, _clear_default_for_customer(), create_invoice_info(), get_invoice_info(), list_invoice_info_by_customer(), Any, Session (+5 more)
+Cohesion: 0.29
+Nodes (16): ensure_crm_customer_linked_row_in_scope(), ensure_crm_owner_row_in_scope(), Session, CRM 数据权限辅助(负责人 owner_user_id + 标准 create_by/create_dept_id)。, 客户子表(开票信息等):先校验关联客户 owner scope,否则校验 create_by。, _clear_default_for_customer(), create_invoice_info(), get_invoice_info() (+8 more)
 
 ### Community 125 - "Community 125"
-Cohesion: 0.06
-Nodes (66): _generate_notify_message(), _build_page(), _get_by_token(), _make_handlers(), _models(), Session, 运输计划 · 入库/出库单现场免登录公共 API, 附件上传 bizType 与 MinIO 目录映射(对齐原 CRM oss 上传语义) (+58 more)
+Cohesion: 0.08
+Nodes (45): _build_page(), _get_by_token(), _make_handlers(), _models(), Session, 运输计划 · 入库/出库单现场免登录公共 API, DbInboundOutbound, PlInboundOrder (+37 more)
 
 ### Community 126 - "customer_pool.py"
-Cohesion: 0.45
-Nodes (11): _customer_base_query(), get_follow_statistics(), get_industry_statistics(), get_level_statistics(), get_overview_statistics(), get_owner_statistics(), get_source_statistics(), get_trend_statistics() (+3 more)
+Cohesion: 0.19
+Nodes (19): invoice_info_by_customer(), _invoice_info_by_customer_impl(), invoice_info_delete(), invoice_info_list(), 按客户ID查询开票信息(与 by-customer 等价), _customer_base_query(), get_follow_statistics(), get_industry_statistics() (+11 more)
 
 ### Community 127 - "Community 127"
-Cohesion: 0.26
-Nodes (18): _cargo_stats(), get_dashboard_stats(), get_inbound_by_cargo(), get_inbound_by_partner_cargo(), get_outbound_by_cargo(), get_outbound_by_partner_cargo(), _partner_cargo_stats(), Session (+10 more)
+Cohesion: 0.38
+Nodes (14): _cargo_stats(), get_dashboard_stats(), get_inbound_by_cargo(), get_inbound_by_partner_cargo(), get_outbound_by_cargo(), get_outbound_by_partner_cargo(), _partner_cargo_stats(), Session (+6 more)
 
 ### Community 128 - "plan.py"
 Cohesion: 0.39
 Nodes (10): create_site(), get_site(), list_sites(), Any, Session, _row_to_dict(), site_code_exists(), soft_delete_site() (+2 more)
 
 ### Community 129 - "BaseStorage"
-Cohesion: 0.29
-Nodes (14): create_clue_follow(), delete_clue_follow(), get_clue_follow(), get_follow_statistics(), list_clue_follows(), Any, Session, 更新线索跟进记录,必要时同步线索 next_time (+6 more)
+Cohesion: 0.18
+Nodes (17): generate_contract_name(), 按面板单位全称精确匹配交易主体/客户主数据,取 shortName;对不上则用全称。, 按面板供方(partyA)-需方(partyB)生成:{供方简称}-{需方简称}({合同编号})。, resolve_party_short_name(), 合同名称按供需方面板(partyA/partyB)解析简称。, 避免「山峡」子串误匹配客户全称中的山峡二字到交易主体。, 调换后供方=辉隆、需方=山峡 → 辉隆-山峡(编号),不因类型反序。, test_generate_empty_default_party_order() (+9 more)
 
 ### Community 130 - "datetime_parse.py"
-Cohesion: 0.15
-Nodes (18): ProcessDefCreateBody, ProcessDefUpdateBody, PublishVersionBody, StartInstanceBody, 流程实例 wf_process_instance, WfNode, WfProcessInstance, WfTask (+10 more)
+Cohesion: 0.24
+Nodes (7): camel_to_snake(), CRUDBase, get_model_attr(), HistoryCRUD, Any, Session, ModelType
 
 ### Community 131 - "LocalStorage"
-Cohesion: 0.50
-Nodes (4): ApiRequestLogCRUD, Session, SysApiRequestLog, SysApiRequestLogHis
+Cohesion: 0.29
+Nodes (16): create_contact(), get_contact(), list_contacts_by_customer(), _parse_optional_date(), Any, date, Session, _row_to_dict() (+8 more)
 
 ### Community 132 - "crm_supplier_hazard.py"
 Cohesion: 0.29
@@ -620,12 +628,12 @@ Cohesion: 0.25
 Nodes (18): batch_generate_sample_codes(), batch_issue_sample_codes(), batch_revoke_sample_codes(), create_sample_code(), get_sample_code(), list_sample_codes(), _parse_issued_time(), Any (+10 more)
 
 ### Community 135 - "post.py"
-Cohesion: 0.24
-Nodes (12): get_last_month_range(), month_range(), date, Session, 地磅计划按月自动生成 — 迁移自 simple-dibang-xiaoshou/auto-create-plan/auto_create_monthly_pla, 按月自动生成采购计划。      - 默认仅在每月 1 日执行(force=True 时跳过该限制,供手动触发验收)     - 遍历所有租户,按上月计划模板生, run_auto_generate_monthly_plans(), default_execution_status() (+4 more)
+Cohesion: 0.16
+Nodes (15): get_current_time(), parse_datetime(), datetime, get_last_month_range(), month_range(), date, Session, 地磅计划按月自动生成 — 迁移自 simple-dibang-xiaoshou/auto-create-plan/auto_create_monthly_pla (+7 more)
 
 ### Community 136 - "Community 136"
-Cohesion: 0.15
-Nodes (22): create_role(), get_role(), get_role_data_scope(), get_role_menu_ids(), list_roles(), Any, Session, 角色 CRUD(sys_role / sys_role_menu / sys_role_data_scope_detail) (+14 more)
+Cohesion: 0.19
+Nodes (18): create_role(), get_role(), get_role_data_scope(), get_role_menu_ids(), list_roles(), Any, Session, 角色 CRUD(sys_role / sys_role_menu / sys_role_data_scope_detail) (+10 more)
 
 ### Community 137 - "statistics.py"
 Cohesion: 0.09
@@ -636,78 +644,78 @@ Cohesion: 0.33
 Nodes (19): check_python(), create_venv(), ensure_dirs(), ensure_valid_venv(), ensure_venv_and_runtime(), install_dependencies(), is_running(), log_error() (+11 more)
 
 ### Community 139 - "Community 139"
-Cohesion: 0.23
-Nodes (13): align_contract_no_to_sign_date(), generate_contract_no(), date, Java: generateContractNo — {供方编码}/X-JT{yyyyMMdd}{3位序号}, 标准编号替换日期段,保留序号;非标准返回 None。, 将标准合同编号日期段对齐签订日;撞号则序号顺延(含软删查重)。      非标准编号原样返回。无签订日则原样返回。, replace_contract_no_date(), test_align_bumps_seq_when_occupied() (+5 more)
+Cohesion: 0.29
+Nodes (11): normalize_attachment_csv(), normalize_attachment_csv(), extract_minio_object_key(), join_relative_urls(), MinIO 附件 URL 规范化(数据迁移共用)。  背景 ---- CRM / 地磅 / 报销与 shanxia2.0 共用同一 MinIO(bucket 默, 业务表 OSS ID 串 → 相对 URL 串(用于客户证照、跟进附件等)。, 去掉预签名 query(``?X-Amz-...``)。, 将绝对/相对 URL 规范为 MinIO object key(不含 bucket)。 (+3 more)
 
 ### Community 141 - "clue_statistics.py"
-Cohesion: 0.31
-Nodes (15): ensure_crm_create_by_row_in_scope(), create_pool_rule(), delete_pool_rules(), execute_pool_rules(), _execute_single_rule(), get_pool_rule(), list_pool_rules(), Any (+7 more)
+Cohesion: 0.28
+Nodes (15): create_clue_follow(), delete_clue_follow(), get_clue_follow(), get_follow_statistics(), list_clue_follows(), Any, Session, 更新线索跟进记录,必要时同步线索 next_time (+7 more)
 
 ### Community 143 - "SysEthnic"
 Cohesion: 0.33
 Nodes (11): create_leave(), get_leave(), list_leaves(), Any, Session, _row_to_dict(), soft_delete_leave(), update_leave() (+3 more)
 
 ### Community 144 - "SysApiRequestLog"
-Cohesion: 0.15
-Nodes (14): invoice_info_add(), invoice_info_by_customer(), _invoice_info_by_customer_impl(), invoice_info_delete(), invoice_info_list(), invoice_info_set_default(), invoice_info_update(), 按客户ID查询开票信息(与 by-customer 等价) (+6 more)
+Cohesion: 0.27
+Nodes (11): customer_dealed(), customer_export(), customer_key(), customer_list(), customer_long_time_no_follow(), customer_mine(), customer_to_follow(), customer_week_new() (+3 more)
 
 ### Community 145 - "minio_url.py"
-Cohesion: 0.21
-Nodes (14): change_current_user_password(), get_current_user_profile(), get_web_auth_menu_codes(), public_quote_share(), Request, Session, 获取当前用户信息(与 sys_user 字段对应)。, 获取当前用户菜单权限标识(sys_menu.perms,经角色继承)。 (+6 more)
+Cohesion: 0.17
+Nodes (11): pool_customer_assign(), pool_customer_claim(), pool_customer_list(), pool_record_detail(), pool_record_list(), PoolAssignBody, PoolClaimBody, PoolCustomerListBody (+3 more)
 
 ### Community 146 - "__init__.py"
-Cohesion: 0.49
-Nodes (10): clue_statistics_level(), _apply_create_range(), _base_query(), get_clue_level_statistics(), get_clue_overview_statistics(), get_clue_owner_statistics(), get_clue_source_statistics(), get_clue_trend_statistics() (+2 more)
+Cohesion: 0.58
+Nodes (9): _apply_create_range(), _base_query(), get_clue_level_statistics(), get_clue_overview_statistics(), get_clue_owner_statistics(), get_clue_source_statistics(), get_clue_trend_statistics(), Any (+1 more)
 
 ### Community 147 - "Community 147"
 Cohesion: 0.37
 Nodes (17): check_env(), check_python(), create_venv(), init_env(), install_dependencies(), log_error(), log_info(), log_success() (+9 more)
 
 ### Community 150 - "ContractListQuery"
-Cohesion: 0.27
-Nodes (11): customer_dealed(), customer_export(), customer_key(), customer_list(), customer_long_time_no_follow(), customer_mine(), customer_to_follow(), customer_week_new() (+3 more)
+Cohesion: 0.17
+Nodes (11): price_letter_add(), price_letter_detail(), price_letter_list(), price_letter_update(), price_letter_void(), PriceLetterCreateBody, PriceLetterDetailBody, PriceLetterListBody (+3 more)
 
 ### Community 152 - "MinIOStorage"
 Cohesion: 0.24
 Nodes (5): MinIOStorage, Any, 从 MINIO_BASE_URL 解析公网 endpoint;未配置或与内网相同时复用 self.client。, MinIO 预签名下载 URL,携带原始文件名。, MinIO 预签名内联预览 URL(PDF 等 iframe 场景)。
 
 ### Community 154 - "PlCarrier"
-Cohesion: 0.30
-Nodes (12): PlCarrier, assert_carrier_eligible_for_transport(), carrier_agreement_expired(), carrier_audit_approved(), carrier_eligible_for_transport(), carrier_qualification_complete(), date, 资质附件均为选填,保留函数签名供兼容调用。 (+4 more)
+Cohesion: 0.09
+Nodes (52): approve_carrier(), create_carrier(), create_driver(), create_personnel(), delete_driver(), delete_personnel(), delete_vehicle(), get_carrier() (+44 more)
 
 ### Community 156 - "get_client_ip"
 Cohesion: 0.27
 Nodes (11): create_dict_data(), get_dict_data(), list_dict_data(), list_dict_data_options(), Any, Session, 字典数据 CRUD(sys_dict_data), 字典下拉选项:租户主数据,忽略数据范围(user_info 保留兼容调用方,不参与过滤)。 (+3 more)
 
 ### Community 159 - "minio_url.py"
-Cohesion: 0.24
-Nodes (11): extract_minio_object_key(), join_relative_urls(), normalize_oss_storage_url(), MinIO 附件 URL 规范化(数据迁移共用)。  背景 ---- CRM / 地磅 / 报销与 shanxia2.0 共用同一 MinIO(bucket 默, 业务表 OSS ID 串 → 相对 URL 串(用于客户证照、跟进附件等)。, 去掉预签名 query(``?X-Amz-...``)。, 将绝对/相对 URL 规范为 MinIO object key(不含 bucket)。, 迁移 CRM ``sys_oss`` 行:``url`` + ``file_name`` → 门户相对路径。 (+3 more)
+Cohesion: 0.49
+Nodes (10): apply_pl_scope(), Session, build_menu_badge_counts(), count_document_reminder_expired_pending(), count_freight_approval_pending(), count_freight_disburse_pending(), _count_pending_applies(), count_plan_archive_pending() (+2 more)
 
 ### Community 160 - "register_local_callback"
-Cohesion: 0.12
-Nodes (23): create_leave(), delete_leave(), get_leave(), _leave_local_callback(), leave_workflow_callback(), list_leaves(), Session, submit_leave() (+15 more)
+Cohesion: 0.13
+Nodes (21): API 路由包 — 山峡化工生产一体化门户, create_leave(), delete_leave(), get_leave(), _leave_local_callback(), leave_workflow_callback(), list_leaves(), Session (+13 more)
 
 ### Community 161 - "backfill_crm_contract_attachment_urls.py"
 Cohesion: 0.33
 Nodes (10): load_oss_map(), load_runtime_settings(), load_settings_env(), main(), Any, Engine, 返回 (新值, 是否发生了 id→url 替换)。, resolve_token() (+2 more)
 
 ### Community 162 - "crm_models.py"
-Cohesion: 0.36
-Nodes (9): create_oss(), get_oss_by_id(), get_oss_by_url(), Session, 按主键 id 查询附件(兼容旧 CRM 雪花 oss_id 迁入后的记录), 将 fileUrl 或旧 CRM 数字 ossId 解析为 MinIO 相对路径。      门户新上传把相对路径写入业务字段;迁入合同附件仍存数字 ossId, resolve_storage_path(), CRM 模块数据模型(产品分类、产品主表、统一附件表、客户管理、公海池、线索管理) (+1 more)
+Cohesion: 0.17
+Nodes (15): change_current_user_password(), get_current_user_profile(), public_quote_share(), Request, Session, 获取当前用户信息(与 sys_user 字段对应)。, 公开分享查看报价单 — Java: GET /share/{shareCode}(无 JWT), get_current_user() (+7 more)
 
 ### Community 163 - "login_crypto.py"
-Cohesion: 0.18
-Nodes (11): Config, decrypt_login_payload(), ensure_initialized(), extract_login_credentials(), get_public_pem(), Any, 登录凭据 RSA 解密(与前端 JSEncrypt PKCS#1 v1.5 兼容)。, Base64 密文 -> JSON 对象(须含 username、password、ts 毫秒时间戳)。 (+3 more)
+Cohesion: 0.31
+Nodes (9): decrypt_login_payload(), ensure_initialized(), extract_login_credentials(), get_public_pem(), Any, 登录凭据 RSA 解密(与前端 JSEncrypt PKCS#1 v1.5 兼容)。, Base64 密文 -> JSON 对象(须含 username、password、ts 毫秒时间戳)。, 从请求体解析用户名、密码。     返回 (username, password, error_message);error_message 非空时表示失败。 (+1 more)
 
 ### Community 164 - "ethnic.py"
-Cohesion: 0.47
-Nodes (5): list_ethnics(), Any, Session, 民族码表 CRUD(全局 sys_ethnic), _row_to_dict()
+Cohesion: 0.08
+Nodes (34): ApiRequestLogCRUD, Session, list_ethnics(), Any, Session, 民族码表 CRUD(全局 sys_ethnic), _row_to_dict(), SoftDeleteModel (+26 more)
 
 ### Community 170 - "test_quote_approver_setting.py"
-Cohesion: 0.20
-Nodes (21): _assert_users_exist(), get_setting(), Any, Session, _row_to_dict(), save_setting(), _assert_users_exist(), get_setting() (+13 more)
+Cohesion: 0.18
+Nodes (22): _assert_users_exist(), get_setting(), Any, Session, _row_to_dict(), save_setting(), _assert_users_exist(), get_setting() (+14 more)
 
-### Community 171 - "BaseStorage"
+### Community 172 - "LocalStorage"
 Cohesion: 0.22
 Nodes (3): BaseStorage, 带下载文件名的访问 URL;默认实现为普通访问地址。, 浏览器内联预览 URL;默认实现为普通访问地址。
 
@@ -716,17 +724,49 @@ Cohesion: 0.67
 Nodes (3): parse_optional_plan_datetime(), datetime, 运输计划相关日期时间解析:前端 date-picker 仅传 YYYY-MM-DD。
 
 ### Community 174 - "datetime_parse.py"
-Cohesion: 0.12
-Nodes (27): _build_public_page(), _format_file_size(), _format_plan_date(), get_public_transport(), _get_transport_by_token(), _parse_feedback_images(), Session, UploadFile (+19 more)
+Cohesion: 0.20
+Nodes (14): _build_driver_url(), get_plan_arrange_info(), 获取计划已安排运输后的司机链接与地磅出入库关联(供查看弹窗复制简述/二维码)。, apply_dibang_prefill_to_order(), build_io_order_site_url(), create_io_order_for_transport(), _dibang_qty_by_plan_product(), get_active_io_order_for_plan() (+6 more)
+
+### Community 178 - "product_allowed"
+Cohesion: 0.24
+Nodes (13): get_product(), soft_delete_product(), assert_products_allowed_for_supplier(), enrich_products_with_hazard_flags(), get_supplier_hazard_flags(), product_allowed(), Any, Session (+5 more)
 
 ### Community 179 - "_ensure_subpack_slip_no"
-Cohesion: 0.06
-Nodes (84): archive_plan(), cancel_plan(), cancel_plan_wait_notice(), count_plans_by_contract(), create_from_contract(), create_plan(), create_plan_full(), _determine_plan_type() (+76 more)
+Cohesion: 0.08
+Nodes (63): archive_plan(), cancel_plan(), cancel_plan_wait_notice(), count_plans_by_contract(), create_from_contract(), create_plan(), _determine_plan_type(), _ensure_subpack_slip_no() (+55 more)
 
 ### Community 180 - "menu.py"
 Cohesion: 0.36
 Nodes (13): _build_tree(), _cascade_soft_delete(), create_menu(), get_menu(), list_menus(), list_menus_tree(), menu_name_exists(), Any (+5 more)
 
+### Community 181 - "storage.py"
+Cohesion: 0.31
+Nodes (13): PlInventory, PlInventoryTransaction, 库存流水表 pl_inventory_transaction, apply_archive_inventory_for_plan(), apply_brand_stock_change(), get_or_create_inventory(), Decimal, Session (+5 more)
+
+### Community 182 - "QiniuStorage"
+Cohesion: 0.40
+Nodes (12): create_follow(), _enrich_follow_dict(), get_follow(), list_follows(), list_follows_by_customer(), Any, Session, _row_to_dict() (+4 more)
+
+### Community 183 - "assert_products_allowed_for_supplier"
+Cohesion: 0.40
+Nodes (12): apply_site_feedback(), 更新明细实际数量,并按需校验/持久化现场品牌数量。, update_io_order_items_qty_and_brand(), OrderItem, _header(), _item(), test_apply_site_feedback_does_not_reset_first_submitted_at(), test_apply_site_feedback_keeps_in_progress_when_requested() (+4 more)
+
+### Community 184 - "pl_transport_site_service.py"
+Cohesion: 0.29
+Nodes (9): _plan_type_to_business_type(), _normalize_plan_date(), date, Session, 运输计划 · 工厂现场链接(与地磅出入库单解耦), 入库/出库安排运输:按产品生成现场链接(不写 db_inbound_outbound)。, revoke_site_links_for_transport(), sync_site_links_for_transport() (+1 more)
+
+### Community 187 - "allocate_next_biz_no"
+Cohesion: 0.33
+Nodes (8): allocate_next_biz_no(), _format_biz_no(), _prefix_for(), datetime, Session, 业务协议号自动生成:XBCC / JZCC + YYYYMMDD + 6 位序号, 原子分配下一个业务协议号。     须在 create 事务内调用;使用 MySQL LAST_INSERT_ID 保证并发安全。, BizNoKind
+
+### Community 188 - "oss.py"
+Cohesion: 0.47
+Nodes (8): create_oss(), get_oss_by_id(), get_oss_by_url(), Session, 按主键 id 查询附件(兼容旧 CRM 雪花 oss_id 迁入后的记录), 将 fileUrl 或旧 CRM 数字 ossId 解析为 MinIO 相对路径。      门户新上传把相对路径写入业务字段;迁入合同附件仍存数字 ossId, resolve_storage_path(), SysOss
+
+### Community 191 - "CrmProductBrand"
+Cohesion: 0.46
+Nodes (7): CrmProductBrand, apply_updates(), collect_candidates(), main(), parse_name(), Path, write_csv()
+
 ### Community 206 - "crm_quote_pdf.py"
 Cohesion: 0.36
 Nodes (10): build_quote_html(), _default_value(), _format_date(), _format_discount(), _format_money(), generate_quote_pdf(), _get_pdf_styles(), Any (+2 more)
@@ -736,8 +776,8 @@ Cohesion: 0.18
 Nodes (10): 1. 创建虚拟环境, 2. 安装依赖, 3. 配置环境变量, 4. 启动服务, API 路由分组, shanxia2.0 后端骨架(FastAPI), 开发规范, 快速开始 (+2 more)
 
 ### Community 220 - "api_crypto_middleware.py"
-Cohesion: 0.15
-Nodes (21): _claims_from_auth(), _coerce_post_method_override_to_get(), _get_redis_client(), _is_crypto_api(), _json_error_response(), _mark_nonce_once(), _nonce_key(), Redis (+13 more)
+Cohesion: 0.13
+Nodes (22): _claims_from_auth(), _coerce_post_method_override_to_get(), _get_redis_client(), _is_crypto_api(), _json_error_response(), _mark_nonce_once(), _nonce_key(), Redis (+14 more)
 
 ### Community 237 - "order_status_compat.py"
 Cohesion: 0.36
@@ -759,17 +799,17 @@ Nodes (6): eq_unicode(), like_unicode(), MySQL 字符串比较/模糊匹配时
 ## Suggested Questions
 _Questions this graph is uniquely positioned to answer:_
 
-- **Why does `generate_uuid()` connect `Community 74` to `plan.py`, `BaseStorage`, `Community 2`, `Community 4`, `Community 6`, `Community 134`, `Community 8`, `Community 136`, `post.py`, `Community 11`, `Community 7`, `clue_statistics.py`, `Community 13`, `SysEthnic`, `Community 15`, `Community 16`, `Community 19`, `Community 21`, `Community 25`, `Community 27`, `Community 28`, `get_client_ip`, `crm_models.py`, `Community 38`, `Community 39`, `test_quote_approver_setting.py`, `Community 43`, `Community 45`, `Community 46`, `Community 49`, `_ensure_subpack_slip_no`, `menu.py`, `Community 53`, `Community 51`, `Community 58`, `Community 61`, `Community 65`, `Community 66`, `Community 67`, `Community 68`, `Community 70`, `Community 83`, `Community 86`, `Community 87`, `pl_ocr_service.py`, `pl_vehicle_recharge_service.py`, `Community 92`, `_invoice_info_by_customer_impl`, `Community 95`, `_ensure_subpack_slip_no`, `dept.py`, `apply_crm_create_by_scope`, `list_customers`, `Community 106`, `apply_pl_scope`, `Community 109`, `quote_share_log.py`, `db_models.py`, `site.py`, `Community 116`, `Community 118`, `Community 122`, `Community 125`?**
-  _High betweenness centrality (0.117) - this node is a cross-community bridge._
-- **Why does `Settings` connect `price_letter_detail` to `backfill_crm_contract_attachment_urls.py`, `login_crypto.py`, `crm_supplier_hazard.py`, `Community 35`, `Community 5`, `Community 7`, `Community 72`, `Community 73`, `Community 42`, `Community 52`, `Community 30`, `Any`, `Community 59`, `Community 62`?**
+- **Why does `generate_uuid()` connect `Community 68` to `Community 0`, `plan.py`, `Community 2`, `LocalStorage`, `Community 4`, `Community 6`, `post.py`, `Community 8`, `Community 136`, `Community 134`, `Community 11`, `Community 7`, `clue_statistics.py`, `Community 13`, `SysEthnic`, `Community 15`, `Community 16`, `Community 19`, `Community 21`, `Community 25`, `PlCarrier`, `Community 27`, `get_client_ip`, `Community 28`, `Community 38`, `Community 39`, `test_quote_approver_setting.py`, `Community 43`, `Community 45`, `datetime_parse.py`, `Community 49`, `_ensure_subpack_slip_no`, `Community 51`, `menu.py`, `QiniuStorage`, `Community 53`, `storage.py`, `pl_transport_site_service.py`, `Community 58`, `allocate_next_biz_no`, `oss.py`, `Community 61`, `CrmProductBrand`, `Community 65`, `Community 66`, `Community 70`, `Community 74`, `Community 83`, `Community 86`, `Community 87`, `pl_ocr_service.py`, `pl_vehicle_recharge_service.py`, `Community 92`, `Community 95`, `dept.py`, `apply_crm_create_by_scope`, `list_customers`, `Community 109`, `quote_share_log.py`, `db_models.py`, `site.py`, `Community 116`, `Community 118`, `Community 122`, `Community 125`?**
+  _High betweenness centrality (0.114) - this node is a cross-community bridge._
+- **Why does `Settings` connect `price_letter_detail` to `backfill_crm_contract_attachment_urls.py`, `_ensure_subpack_slip_no`, `Community 35`, `crm_supplier_hazard.py`, `Community 5`, `Community 7`, `Community 72`, `Community 73`, `Community 42`, `Community 52`, `Any`, `Community 59`, `api_crypto_middleware.py`, `Community 30`?**
   _High betweenness centrality (0.110) - this node is a cross-community bridge._
-- **Why does `BaseModel` connect `Community 12` to `Community 0`, `Community 1`, `datetime_parse.py`, `Community 3`, `statistics.py`, `Community 11`, `Community 14`, `Community 15`, `SysApiRequestLog`, `Community 16`, `Community 18`, `ContractListQuery`, `Community 24`, `Community 26`, `Community 27`, `Community 28`, `register_local_callback`, `Community 33`, `Community 36`, `Community 43`, `Community 45`, `datetime_parse.py`, `Community 48`, `_ensure_subpack_slip_no`, `Community 51`, `Community 54`, `Community 58`, `Community 60`, `Community 63`, `Community 64`, `Community 65`, `Community 66`, `Community 67`, `Community 68`, `Community 71`, `Community 78`, `Community 86`, `pl_vehicle_recharge_service.py`, `_ensure_subpack_slip_no`, `Community 111`, `storage.py`, `site.py`, `Community 119`, `Community 127`?**
-  _High betweenness centrality (0.094) - this node is a cross-community bridge._
+- **Why does `BaseModel` connect `Community 12` to `Community 0`, `Community 1`, `Community 3`, `statistics.py`, `Community 11`, `Community 14`, `Community 15`, `SysApiRequestLog`, `minio_url.py`, `Community 18`, `Community 16`, `ContractListQuery`, `Community 24`, `Community 26`, `Community 27`, `PlCarrier`, `Community 28`, `Community 29`, `register_local_callback`, `Community 33`, `Community 34`, `ethnic.py`, `Community 43`, `Community 45`, `Community 48`, `_ensure_subpack_slip_no`, `Community 51`, `Community 54`, `Community 58`, `Community 60`, `Community 62`, `Community 63`, `Community 64`, `Community 65`, `Community 66`, `Community 67`, `Community 68`, `Community 71`, `Community 78`, `Community 81`, `Community 86`, `_invoice_info_by_customer_impl`, `list_customers`, `Community 111`, `storage.py`, `site.py`, `Community 119`, `customer_pool.py`, `Community 127`?**
+  _High betweenness centrality (0.107) - this node is a cross-community bridge._
 - **Are the 8 inferred relationships involving `DbUserContext` (e.g. with `InventoryRelatedData` and `AutoGenerateMonthlyResult`) actually correct?**
   _`DbUserContext` has 8 INFERRED edges - model-reasoned connections that need verification._
 - **What connects `API 路由包 — 山峡化工生产一体化门户`, `返回运营端角色下拉选项(label=库中角色名,value=Web 角色码)。`, `返回用户下拉选项(label=昵称,value=用户ID,附带 nickName/userNo)。      供申请人/审批人等选择场景使用,返回本租户全部有效` to the rest of the system?**
-  _504 weakly-connected nodes found - possible documentation gaps or missing edges._
-- **Should `Community 0` be split into smaller, more focused modules?**
-  _Cohesion score 0.10821256038647344 - nodes in this community are weakly interconnected._
+  _514 weakly-connected nodes found - possible documentation gaps or missing edges._
 - **Should `Community 1` be split into smaller, more focused modules?**
-  _Cohesion score 0.07881773399014778 - nodes in this community are weakly interconnected._
+  _Cohesion score 0.08367071524966262 - nodes in this community are weakly interconnected._
+- **Should `Community 2` be split into smaller, more focused modules?**
+  _Cohesion score 0.14979757085020243 - nodes in this community are weakly interconnected._

ファイルの差分が大きいため隠しています
+ 144 - 134
backend/graphify-out/2026-08-04/graph.json


+ 156 - 210
backend/graphify-out/GRAPH_REPORT.md

@@ -1,16 +1,16 @@
 # Graph Report - backend  (2026-08-04)
 
 ## Corpus Check
-- 306 files · ~208,041 words
+- 307 files · ~208,854 words
 - Verdict: corpus is large enough that graph structure adds value.
 
 ## Summary
-- 4585 nodes · 15567 edges · 533 communities (517 shown, 16 thin omitted)
+- 4616 nodes · 15627 edges · 523 communities (506 shown, 17 thin omitted)
 - Extraction: 97% EXTRACTED · 3% INFERRED · 0% AMBIGUOUS · INFERRED: 410 edges (avg confidence: 0.53)
 - Token cost: 0 input · 0 output
 
 ## Graph Freshness
-- Built from commit: `012a2ad6`
+- Built from commit: `5fe53c54`
 - Run `git rev-parse HEAD` and compare to check if the graph is stale.
 - Run `graphify update .` after code changes (no API cost).
 
@@ -124,34 +124,24 @@
 - [[_COMMUNITY_Community 136|Community 136]]
 - [[_COMMUNITY_statistics.py|statistics.py]]
 - [[_COMMUNITY_Community 138|Community 138]]
-- [[_COMMUNITY_Community 139|Community 139]]
-- [[_COMMUNITY_clue_statistics.py|clue_statistics.py]]
 - [[_COMMUNITY_SysEthnic|SysEthnic]]
-- [[_COMMUNITY_SysApiRequestLog|SysApiRequestLog]]
 - [[_COMMUNITY_minio_url.py|minio_url.py]]
 - [[_COMMUNITY___init__.py|__init__.py]]
 - [[_COMMUNITY_Community 147|Community 147]]
-- [[_COMMUNITY_ContractListQuery|ContractListQuery]]
 - [[_COMMUNITY_Community 151|Community 151]]
-- [[_COMMUNITY_MinIOStorage|MinIOStorage]]
 - [[_COMMUNITY_PlCarrier|PlCarrier]]
-- [[_COMMUNITY_get_client_ip|get_client_ip]]
 - [[_COMMUNITY_minio_url.py|minio_url.py]]
 - [[_COMMUNITY_register_local_callback|register_local_callback]]
 - [[_COMMUNITY_backfill_crm_contract_attachment_urls.py|backfill_crm_contract_attachment_urls.py]]
-- [[_COMMUNITY_crm_models.py|crm_models.py]]
-- [[_COMMUNITY_login_crypto.py|login_crypto.py]]
 - [[_COMMUNITY_ethnic.py|ethnic.py]]
 - [[_COMMUNITY_codeblock1 (iflytekshanxia2.0backend)|code:block1 (/iflytek/shanxia2.0/backend)]]
 - [[_COMMUNITY_test_quote_approver_setting.py|test_quote_approver_setting.py]]
-- [[_COMMUNITY_BaseStorage|BaseStorage]]
-- [[_COMMUNITY_LocalStorage|LocalStorage]]
 - [[_COMMUNITY_resolve_create_time_bounds|resolve_create_time_bounds]]
 - [[_COMMUNITY_datetime_parse.py|datetime_parse.py]]
-- [[_COMMUNITY_.to_tenant_user_dict|.to_tenant_user_dict]]
+- [[_COMMUNITY_product_allowed|product_allowed]]
 - [[_COMMUNITY__ensure_subpack_slip_no|_ensure_subpack_slip_no]]
 - [[_COMMUNITY_menu.py|menu.py]]
-- [[_COMMUNITY_get_db_current_user_optional|get_db_current_user_optional]]
+- [[_COMMUNITY_allocate_next_biz_no|allocate_next_biz_no]]
 - [[_COMMUNITY_crm_quote_pdf.py|crm_quote_pdf.py]]
 - [[_COMMUNITY_shanxia2.0 后端骨架(FastAPI)|shanxia2.0 后端骨架(FastAPI)]]
 - [[_COMMUNITY_api_crypto_middleware.py|api_crypto_middleware.py]]
@@ -185,8 +175,6 @@
 10. `ApiResponse` - 79 edges
 
 ## Surprising Connections (you probably didn't know these)
-- `BackfillRule` --uses--> `Settings`  [INFERRED]
-  scripts/migrate_crm_sys_oss.py → app/core/config.py
 - `MigrationStats` --uses--> `Settings`  [INFERRED]
   scripts/migrate_bx_data.py → app/core/config.py
 - `StepStats` --uses--> `Settings`  [INFERRED]
@@ -195,19 +183,21 @@
   scripts/migrate_crm_clue.py → app/core/config.py
 - `StepStats` --uses--> `Settings`  [INFERRED]
   scripts/migrate_crm_clue.py → app/core/config.py
+- `MigrationStats` --uses--> `Settings`  [INFERRED]
+  scripts/migrate_crm_contract.py → app/core/config.py
 
 ## Import Cycles
 - None detected.
 
-## Communities (533 total, 16 thin omitted)
+## Communities (523 total, 17 thin omitted)
 
 ### Community 0 - "Community 0"
 Cohesion: 0.16
 Nodes (32): check_document_expiry(), document_reminder_stats(), get_inventory_ledger(), get_summary(), list_document_reminders(), list_transactions(), list_warnings(), date (+24 more)
 
 ### Community 1 - "Community 1"
-Cohesion: 0.08
-Nodes (38): CRM 合同 API 路由 — GET/PUT/DELETE/POST 对齐原 Java CRM, 接口菜单权限守卫。super_admin 直接放行。, require_menu_code(), ContractApproverSettingSaveBody, ContractApprovalActionBody, ContractApprovalPassBody, ContractApprovalRejectBody, ContractApprovalTransferBody (+30 more)
+Cohesion: 0.10
+Nodes (32): CRM 合同 API 路由 — GET/PUT/DELETE/POST 对齐原 Java CRM, 接口菜单权限守卫。super_admin 直接放行。, require_menu_code(), ContractApproverSettingSaveBody, ContractApprovalActionBody, ContractBatchAssignBody, ContractBatchSubmitBody, ContractChangeCreateBody (+24 more)
 
 ### Community 2 - "Community 2"
 Cohesion: 0.14
@@ -215,27 +205,27 @@ Nodes (15): BxAdvanceApply, BxAdvanceApproval, AdvanceService, Any, Session, 同
 
 ### Community 3 - "Community 3"
 Cohesion: 0.08
-Nodes (92): attachment_download_url(), attachment_preview_url(), AttachmentDownloadUrlBody, create_dept(), create_dict_data(), create_dict_type(), create_menu(), create_post() (+84 more)
+Nodes (99): attachment_download_url(), attachment_preview_url(), AttachmentDownloadUrlBody, create_dept(), create_dict_data(), create_dict_type(), create_menu(), create_post() (+91 more)
 
 ### Community 4 - "Community 4"
-Cohesion: 0.09
-Nodes (76): _apply_list_filters(), assign_opportunities(), batch_update_expect_date(), batch_update_stage(), change_stage(), create_opportunity(), _decimal_value(), _enrich_user_names() (+68 more)
+Cohesion: 0.12
+Nodes (61): _apply_list_filters(), assign_opportunities(), batch_update_expect_date(), batch_update_stage(), change_stage(), create_opportunity(), _decimal_value(), _enrich_user_names() (+53 more)
 
 ### Community 5 - "Community 5"
-Cohesion: 0.19
-Nodes (26): Settings, BaseSettings, count_source_rows(), derive_source_url(), fetch_portal_admin_id(), fetch_source_rows(), legacy_id_to_str(), load_runtime_settings() (+18 more)
+Cohesion: 0.20
+Nodes (24): count_source_rows(), derive_source_url(), fetch_portal_admin_id(), fetch_source_rows(), legacy_id_to_str(), load_runtime_settings(), load_settings_env(), load_user_mapping() (+16 more)
 
 ### Community 6 - "Community 6"
 Cohesion: 0.13
-Nodes (44): assign_customer(), batch_claim_customers(), check_duplicate_customer(), claim_customer(), create_customer(), deal_customer(), _enrich_user_names(), _ensure_customer_in_scope() (+36 more)
+Nodes (42): assign_customer(), batch_claim_customers(), claim_customer(), create_customer(), deal_customer(), _enrich_user_names(), _ensure_customer_in_scope(), create_follow() (+34 more)
 
 ### Community 7 - "Community 7"
 Cohesion: 0.12
 Nodes (36): get_password_hash(), Namespace, build_merged_users(), bx_role_labels(), check_minio(), check_mysql(), check_redis(), _clip() (+28 more)
 
 ### Community 8 - "Community 8"
-Cohesion: 0.10
-Nodes (66): register_quote_routes(), accept_quote(), _build_quote_filters(), calculate_quote_amount(), create_new_version(), create_quote(), _decimal_value(), _enrich_contact_fields() (+58 more)
+Cohesion: 0.12
+Nodes (50): register_quote_routes(), accept_quote(), _build_quote_filters(), calculate_quote_amount(), create_new_version(), create_quote(), _decimal_value(), _enrich_contact_fields() (+42 more)
 
 ### Community 11 - "Community 11"
 Cohesion: 0.10
@@ -243,31 +233,31 @@ Nodes (55): cancel_apply(), create_apply(), create_disburse(), delete_applies(),
 
 ### Community 12 - "Community 12"
 Cohesion: 0.05
-Nodes (73): contact_add(), contact_delete(), contact_update(), customer_create(), customer_delete(), customer_update(), customer_name_exists(), BaseModel (+65 more)
+Nodes (69): contact_add(), contact_delete(), contact_update(), customer_create(), customer_delete(), customer_update(), customer_name_exists(), BaseModel (+61 more)
 
 ### Community 13 - "Community 13"
 Cohesion: 0.15
 Nodes (32): create_instance(), create_process_def(), create_task(), get_all_tasks_for_business(), get_instance(), get_latest_version(), get_nodes_by_version(), get_pending_tasks_by_node() (+24 more)
 
 ### Community 14 - "Community 14"
-Cohesion: 0.17
-Nodes (20): operlog_detail(), operlog_list(), Session, 操作日志分页列表(基于 API 请求日志适配 RuoYi OperLog 结构), _user_info(), business_type_from_path(), title_from_path(), _apply_oper_log_scope() (+12 more)
+Cohesion: 0.10
+Nodes (25): list_public_vehicle_plates(), Session, 地磅公共只读:免登车牌 options(现场填写页), 免登:按出入库/计划解析 tenant_no,返回 pl_vehicle 车牌(self + carrier)。, _resolve_tenant_no(), get_menu_list(), 运营端菜单接口(与 web-admin 前端静态路由 sqxp.ts 对齐,14 个一级菜单), menu_badge_stats() (+17 more)
 
 ### Community 15 - "Community 15"
-Cohesion: 0.09
-Nodes (43): approve_reimburse(), approved_by_me(), _build_details_data(), create_reimburse(), delete_reimburse(), get_approval_history(), get_approvals(), get_generated_title() (+35 more)
+Cohesion: 0.10
+Nodes (39): approve_reimburse(), approved_by_me(), _build_details_data(), create_reimburse(), delete_reimburse(), get_approval_history(), get_approvals(), get_generated_title() (+31 more)
 
 ### Community 16 - "Community 16"
-Cohesion: 0.09
-Nodes (60): cancel_apply(), create_apply(), create_record(), delete_applies(), delete_records(), get_apply(), get_record(), list_applies() (+52 more)
+Cohesion: 0.10
+Nodes (62): cancel_apply(), create_apply(), create_record(), delete_applies(), delete_records(), get_apply(), get_record(), list_applies() (+54 more)
 
 ### Community 18 - "Community 18"
-Cohesion: 0.11
-Nodes (41): advance_pending_approval_stats(), advance_status_counts(), approve_advance(), approved_by_me(), create_advance(), delete_advance(), _fill_offset_amounts(), get_advance() (+33 more)
+Cohesion: 0.10
+Nodes (56): advance_pending_approval_stats(), advance_status_counts(), approve_advance(), approved_by_me(), create_advance(), delete_advance(), _fill_offset_amounts(), get_advance() (+48 more)
 
 ### Community 19 - "Community 19"
 Cohesion: 0.09
-Nodes (50): _avatar_url_field(), _build_user_info_payload(), change_current_user_password(), get_current_user_profile(), get_web_auth_menu_codes(), _jwt_user_payload(), logout(), public_quote_share() (+42 more)
+Nodes (46): _avatar_url_field(), _build_user_info_payload(), change_current_user_password(), get_current_user_profile(), _jwt_user_payload(), logout(), public_quote_share(), Request (+38 more)
 
 ### Community 21 - "Community 21"
 Cohesion: 0.09
@@ -278,64 +268,64 @@ Cohesion: 0.08
 Nodes (28): parse_admin_request_json(), Any, Request, 运营 Web(/web/admin)JSON 请求体解析。  与 ApiCryptoMiddleware 配合:中间件未改写 body 时,在路由内解密 `{, 读取 JSON body;dict 时走 resolve_request_payload(明文 / 密文 / data 包装)。      Returns:, ApiCryptoError, _b64url_decode(), _b64url_encode() (+20 more)
 
 ### Community 23 - "Community 23"
-Cohesion: 0.11
-Nodes (8): convert_heic_to_jpeg(), OSSStorage, process_image_content(), QiniuStorage, 文件存储工具模块  支持多种存储方式: 1. 本地存储 (local) - 默认 2. 七牛云存储 (qiniu) - 推荐生产环境使用 3. 阿里云OSS (, 将 HEIC/HEIF 格式转换为 JPEG 格式, 处理图片内容,如果是 HEIC 格式则转换为 JPEG, BytesIO
+Cohesion: 0.05
+Nodes (31): BaseStorage, convert_heic_to_jpeg(), get_storage(), LocalStorage, MinIOStorage, OSSStorage, process_image_content(), Any (+23 more)
 
 ### Community 24 - "Community 24"
-Cohesion: 0.09
-Nodes (21): category_add(), category_delete(), category_tree(), category_update(), product_add(), product_delete(), product_options(), product_update() (+13 more)
+Cohesion: 0.08
+Nodes (25): category_add(), category_delete(), category_tree(), category_update(), product_add(), product_delete(), product_detail(), product_options() (+17 more)
 
 ### Community 25 - "Community 25"
-Cohesion: 0.14
-Nodes (24): PlTransportProductBrandQty, PlTransportProductFeedback, 运输单按产品回传 pl_transport_product_feedback, 运输单产品回传品牌数量 pl_transport_product_brand_qty, _dict_field(), format_brand_qty_summary(), load_transport_driver_product_feedbacks(), persist_io_item_brand_qtys() (+16 more)
+Cohesion: 0.05
+Nodes (72): BizAttachment, PlDriver, PlInboundOrderItemBrandQty, PlInventory, PlInventoryTransaction, PlInventoryWarning, PlOutboundOrderItemBrandQty, PlPlanChange (+64 more)
 
 ### Community 26 - "Community 26"
-Cohesion: 0.12
-Nodes (19): list_public_vehicle_plates(), Session, 地磅公共只读:免登车牌 options(现场填写页), 免登:按出入库/计划解析 tenant_no,返回 pl_vehicle 车牌(self + carrier)。, _resolve_tenant_no(), API 路由包 — 山峡化工生产一体化门户, get_menu_list(), 运营端菜单接口(与 web-admin 前端静态路由 sqxp.ts 对齐,14 个一级菜单) (+11 more)
+Cohesion: 0.14
+Nodes (24): list_vehicles(), PlVehiclePersonnel, 车辆-人员关联表 pl_vehicle_personnel, CertRead, VehicleListResponse, VehiclePersonnelRow, SnapshotCertRead, SnapshotPersonnelRow (+16 more)
 
 ### Community 27 - "Community 27"
-Cohesion: 0.12
-Nodes (34): _apply_plan_product_update(), _apply_plan_update(), AutoGenerateMonthlyResult, _base_query(), create_plan(), _generate_plan_no(), get_plan(), _get_plan_by_id_only() (+26 more)
+Cohesion: 0.17
+Nodes (32): _apply_plan_product_update(), _apply_plan_update(), AutoGenerateMonthlyResult, _base_query(), create_plan(), delete_plan(), _generate_plan_no(), get_plan() (+24 more)
 
 ### Community 28 - "Community 28"
 Cohesion: 0.06
 Nodes (92): approve_settlement_legacy(), cancel_settlement(), create_settlement(), delete_settlement(), disburse_settlement(), _generate_settlement_no(), get_settlement(), get_settlement_approval_flow() (+84 more)
 
 ### Community 29 - "Community 29"
-Cohesion: 0.15
-Nodes (26): _build_public_page(), _build_site_product_read(), _format_file_size(), get_public_site(), _get_site_link_by_token(), _parse_feedback_images(), Session, UploadFile (+18 more)
+Cohesion: 0.17
+Nodes (22): _build_public_page(), _build_site_product_read(), _format_file_size(), get_public_site(), _get_site_link_by_token(), _parse_feedback_images(), Session, UploadFile (+14 more)
 
 ### Community 30 - "Community 30"
 Cohesion: 0.16
 Nodes (26): clear_target_categories(), compute_level(), count_target_rows(), derive_source_url(), fetch_portal_admin_id(), fetch_source_rows(), legacy_id_to_str(), load_runtime_settings() (+18 more)
 
 ### Community 33 - "Community 33"
-Cohesion: 0.20
-Nodes (15): bind_biz(), delete_attachment(), download_file(), list_by_biz(), _parse_id_list(), preview_attachment(), Session, UploadFile (+7 more)
+Cohesion: 0.18
+Nodes (17): bind_biz(), delete_attachment(), download_file(), list_by_biz(), _parse_id_list(), preview_attachment(), Session, UploadFile (+9 more)
 
 ### Community 34 - "Community 34"
-Cohesion: 0.24
-Nodes (7): camel_to_snake(), CRUDBase, get_model_attr(), HistoryCRUD, Any, Session, ModelType
+Cohesion: 0.18
+Nodes (25): approve_task(), _assert_wf_instance_in_scope(), _business_type_label(), create_process_def(), delete_process_def(), _enrich_task_list(), get_business_all_tasks(), _get_business_form_fields() (+17 more)
 
 ### Community 35 - "Community 35"
 Cohesion: 0.18
 Nodes (36): clear_portal_workflow(), _dec(), derive_source_url(), fetch_portal_admin_id(), fetch_source_rows(), legacy_id_to_str(), load_bx_user_mapping(), load_runtime_settings() (+28 more)
 
 ### Community 36 - "Community 36"
-Cohesion: 0.16
-Nodes (31): approve_task(), _assert_wf_instance_in_scope(), _business_type_label(), create_process_def(), delete_process_def(), _enrich_task_list(), get_business_all_tasks(), _get_business_form_fields() (+23 more)
+Cohesion: 0.13
+Nodes (21): ProcessDefCreateBody, ProcessDefUpdateBody, PublishVersionBody, StartInstanceBody, 流程实例 wf_process_instance, WfNode, WfProcessInstance, WfTask (+13 more)
 
 ### Community 37 - "Community 37"
-Cohesion: 0.20
-Nodes (22): delete_plan(), delete_carrier(), unbind_vehicle_driver(), _actor_ids(), _actor_names(), assert_row_deletable_by_creator(), assert_rows_deletable_by_creator(), can_delete_by_creator() (+14 more)
+Cohesion: 0.13
+Nodes (29): _actor_ids(), _actor_names(), assert_row_deletable_by_creator(), assert_rows_deletable_by_creator(), can_delete_by_creator(), is_super_admin(), normalize_user_info(), Any (+21 more)
 
 ### Community 38 - "Community 38"
-Cohesion: 0.13
-Nodes (27): PlInventoryTransaction, 库存流水表 pl_inventory_transaction, load_brand_qtys_by_plan_product_ids(), persist_plan_product_brand_qtys(), Any, Decimal, Session, 按计划产品明细 ID 批量加载归档品牌数量(brandId/brandName/qty)。 (+19 more)
+Cohesion: 0.16
+Nodes (19): ApiRequestLogMiddleware, _claims_from_auth(), _format_body_bytes(), _persist_log(), Any, Request, 统一记录 API 请求/响应出入参的中间件, _redact_obj() (+11 more)
 
 ### Community 39 - "Community 39"
-Cohesion: 0.22
-Nodes (28): assign_clues(), check_convert(), check_duplicate_clue(), convert_clue(), create_clue(), _enrich_user_names(), _ensure_clue_in_scope(), get_clue() (+20 more)
+Cohesion: 0.13
+Nodes (44): assign_clues(), check_convert(), check_duplicate_clue(), convert_clue(), create_clue(), _enrich_user_names(), _ensure_clue_in_scope(), create_clue_follow() (+36 more)
 
 ### Community 42 - "Community 42"
 Cohesion: 0.19
@@ -343,67 +333,63 @@ Nodes (32): _dec(), derive_source_url(), fetch_portal_admin_id(), fetch_source_r
 
 ### Community 43 - "Community 43"
 Cohesion: 0.10
-Nodes (32): create_invoice(), delete_invoice(), get_mine_wallet_summary(), list_invoice_ledgers(), list_invoice_wallets(), list_invoices(), Request, Session (+24 more)
+Nodes (31): create_invoice(), delete_invoice(), get_mine_wallet_summary(), list_invoice_ledgers(), list_invoice_wallets(), list_invoices(), Request, Session (+23 more)
 
 ### Community 44 - "Community 44"
-Cohesion: 0.12
-Nodes (15): _db_pool_keepalive_loop(), _error_json(), lifespan(), Exception, Request, 数据库异常:返回 JSON 并保留 CORS 头,避免浏览器只报跨域错误, 未捕获异常:统一 JSON 500,确保跨域场景下仍有 Access-Control-Allow-Origin, 定期 ping MySQL,避免远程库/NAT 回收空闲 TCP 后首请求长时间卡住。 (+7 more)
+Cohesion: 0.08
+Nodes (25): Config, decrypt_login_payload(), ensure_initialized(), extract_login_credentials(), get_public_pem(), Any, 登录凭据 RSA 解密(与前端 JSEncrypt PKCS#1 v1.5 兼容)。, Base64 密文 -> JSON 对象(须含 username、password、ts 毫秒时间戳)。 (+17 more)
 
 ### Community 45 - "Community 45"
-Cohesion: 0.07
-Nodes (84): _build_driver_url(), get_plan_arrange_info(), 获取计划已安排运输后的司机链接与地磅出入库关联(供查看弹窗复制简述/二维码)。, _build_public_page(), _format_file_size(), _format_plan_date(), get_public_transport(), _get_transport_by_token() (+76 more)
+Cohesion: 0.12
+Nodes (42): _apply_plan_logistics_from_payload(), _apply_transport_arrange_fields(), arrange_transport(), _assert_vehicle_carrier_eligible(), _build_arrange_result(), _build_driver_url(), create_transport(), _ensure_driver_access_token() (+34 more)
 
 ### Community 46 - "Community 46"
-Cohesion: 0.11
-Nodes (48): _apply_contract_entity_fields(), _build_contract_filters(), _build_customer_address(), _calc_amount_with_tax(), contract_no_exists(), _contract_period_key(), create_contract(), create_from_opportunity() (+40 more)
+Cohesion: 0.18
+Nodes (18): align_contract_no_to_sign_date(), generate_contract_no(), date, Java: generateContractNo — {供方编码}/X-JT{yyyyMMdd}{3位序号}      流水与撞号检测须含软删:uk_contr, 标准编号替换日期段,保留序号;非标准返回 None。, 将标准合同编号日期段对齐签订日;撞号则序号顺延(含软删查重)。      非标准编号原样返回。无签订日则原样返回。, replace_contract_no_date(), _mock_last_contract() (+10 more)
 
 ### Community 48 - "Community 48"
-Cohesion: 0.21
-Nodes (26): _apply_inventory_product_update(), _apply_inventory_update(), _base_query(), create_inventory(), create_link_for_plan(), delete_inventory(), _generate_batch_no(), _get_inventory() (+18 more)
+Cohesion: 0.16
+Nodes (32): _apply_inventory_product_update(), _apply_inventory_update(), _base_query(), create_inventory(), create_link_for_plan(), delete_inventory(), _generate_batch_no(), _get_inventory() (+24 more)
 
 ### Community 49 - "Community 49"
-Cohesion: 0.22
-Nodes (17): _apply_list_filters(), create_supplier_info(), get_supplier_info(), list_all_supplier_info(), list_supplier_info(), Any, Session, CRM 供方信息 CRUD — 对照 CrmSupplierInfoServiceImpl.java (+9 more)
+Cohesion: 0.13
+Nodes (31): apply_crm_create_by_scope(), ensure_crm_create_by_row_in_scope(), create_pool_rule(), delete_pool_rules(), execute_pool_rules(), get_pool_rule(), list_pool_rules(), Any (+23 more)
 
 ### Community 50 - "Community 50"
 Cohesion: 0.15
 Nodes (9): 微信消息通知服务  支持微信小程序模板消息推送  使用方式:     from app.core.wechat_message import WechatMes, 发送订单状态通知                  Args:             openid: 用户openid             order_n, 发送支付成功通知                  Args:             openid: 用户openid             order_n, 发送配送通知                  Args:             openid: 配送员openid             task_no:, 发送配送时效预警                  Args:             openid: 配送员openid             task_n, 发送退款结果通知                  Args:             openid: 用户openid             order_n, 发送催单通知给配送员                  Args:             deliver_openid: 配送员openid, 发送模板消息                  Args:             openid: 用户openid             template_ (+1 more)
 
 ### Community 51 - "Community 51"
-Cohesion: 0.11
-Nodes (62): create_from_contract(), create_plan(), create_plan_full(), _generate_plan_no(), 生成计划编号 POYYYYMMDD###(当日 3 位序号,每日重置), 创建运输计划(完整表单:合同产品 + 可选预选车辆,不自动安排运输), update_plan(), PlPlan (+54 more)
+Cohesion: 0.14
+Nodes (44): PlPlanProduct, 计划产品明细表 pl_plan_product, PlanArchiveFreightBlock, PlanProductCreate, PlanTransportCreateBlock, all_hazard_products_cert_complete(), apply_archive_freight(), _apply_payload_to_transport_row() (+36 more)
 
 ### Community 52 - "Community 52"
 Cohesion: 0.18
 Nodes (29): _dec(), derive_source_url(), fetch_portal_admin_id(), fetch_source_rows(), legacy_id_to_str(), load_oss_id_to_url(), load_runtime_settings(), load_settings_env() (+21 more)
 
 ### Community 53 - "Community 53"
-Cohesion: 0.12
-Nodes (29): 报销模块认证适配:门户 JWT 用户 → bx 业务上下文。, filter_current_cycle_approvals(), 审批轮次过滤 — 驳回后重新提交时,进度接口仅展示当前轮次。, 审批进度仅展示当前轮次;完整历史由 get_approval_history 返回。, 报销模块 Service 基类 — 租户隔离 + UUID + 软删除。, apply_bx_scope(), assert_bx_attachment_biz_in_scope(), assert_bx_biz_in_scope() (+21 more)
+Cohesion: 0.14
+Nodes (21): 报销模块认证适配:门户 JWT 用户 → bx 业务上下文。, BxReimburseInvoice, BxReimburseOffset, BxWorkflowNode, 报销(bx)模块数据模型 — 对齐 docs/sql/20260606_bx_tables.sql, filter_current_cycle_approvals(), 审批轮次过滤 — 驳回后重新提交时,进度接口仅展示当前轮次。, 审批进度仅展示当前轮次;完整历史由 get_approval_history 返回。 (+13 more)
 
 ### Community 54 - "Community 54"
 Cohesion: 0.19
 Nodes (28): _get_by_plan(), get_inbound(), get_inbound_by_plan(), _get_order(), get_outbound(), get_outbound_by_plan(), inbound_site_url(), list_inbound() (+20 more)
 
 ### Community 58 - "Community 58"
-Cohesion: 0.15
-Nodes (34): CRM 合同子模块路由 — 变更/模板/审批独立页, register_contract_sub_routes(), _change_row_to_dict(), create_contract_change(), create_contract_template(), _enrich_change_rows(), execute_change(), export_contract_changes() (+26 more)
+Cohesion: 0.13
+Nodes (37): CRM 合同子模块路由 — 变更/模板/审批独立页, register_contract_sub_routes(), _change_row_to_dict(), create_contract_change(), create_contract_template(), execute_change(), export_contract_changes(), export_contract_templates() (+29 more)
 
 ### Community 59 - "Community 59"
 Cohesion: 0.20
 Nodes (28): _dec(), derive_source_url(), fetch_portal_admin_id(), fetch_source_rows(), legacy_id_to_str(), load_oss_id_to_url(), load_runtime_settings(), load_settings_env() (+20 more)
 
 ### Community 60 - "Community 60"
-Cohesion: 0.18
-Nodes (17): get_oper_log_meta(), OperLogMeta, 请求级操作日志元数据(ContextVar), 供异步落库线程使用,避免 ContextVar 跨线程丢失。, set_oper_log_meta(), snapshot_oper_log_meta(), _format_summary(), oper_log() (+9 more)
+Cohesion: 0.17
+Nodes (20): operlog_detail(), operlog_list(), Session, 操作日志分页列表(基于 API 请求日志适配 RuoYi OperLog 结构), _user_info(), business_type_from_path(), title_from_path(), _apply_oper_log_scope() (+12 more)
 
 ### Community 61 - "Community 61"
-Cohesion: 0.13
-Nodes (34): parse_date_str(), _create_db_inventory(), _create_db_plan(), DibangInventoryLinkResult, find_monthly_db_plan(), _generate_batch_no(), _inventory_has_weighing_slip(), _month_range() (+26 more)
-
-### Community 62 - "Community 62"
-Cohesion: 0.21
-Nodes (22): clear_target_products(), count_target_rows(), _dec(), derive_source_url(), fetch_portal_admin_id(), fetch_source_rows(), legacy_id_to_str(), load_runtime_settings() (+14 more)
+Cohesion: 0.11
+Nodes (45): _generate_notify_message(), PlPlan, PlTransportDbLink, 运输-地磅出入库关联 pl_transport_db_link, _apply_plan_quantity_delta(), _create_db_inventory(), _create_db_plan(), DibangInventoryLinkResult (+37 more)
 
 ### Community 63 - "Community 63"
 Cohesion: 0.20
@@ -411,47 +397,47 @@ Nodes (13): create_expense_item(), delete_expense_item(), get_expense_item(), ge
 
 ### Community 64 - "Community 64"
 Cohesion: 0.04
-Nodes (197): clue_assign(), clue_check_convert(), clue_check_duplicate(), clue_convert(), clue_create(), clue_delete(), clue_detail(), clue_export() (+189 more)
+Nodes (178): clue_assign(), clue_convert(), clue_create(), clue_delete(), clue_detail(), clue_export(), clue_follow_create(), clue_follow_delete() (+170 more)
 
 ### Community 65 - "Community 65"
 Cohesion: 0.10
 Nodes (58): cancel_apply(), create_apply(), create_process(), delete_applies(), delete_processes(), get_apply(), get_process(), list_applies() (+50 more)
 
 ### Community 66 - "Community 66"
-Cohesion: 0.13
-Nodes (23): create_workflow(), delete_workflow(), get_workflow(), get_workflow_by_biz_type(), list_workflows(), Session, save_workflow_nodes(), update_workflow() (+15 more)
+Cohesion: 0.18
+Nodes (18): create_workflow(), delete_workflow(), get_workflow(), get_workflow_by_biz_type(), list_workflows(), Session, save_workflow_nodes(), update_workflow() (+10 more)
 
 ### Community 67 - "Community 67"
-Cohesion: 0.19
-Nodes (14): parse_resource_snapshot(), Any, 运输计划 - 安排运输时车辆/人员/证件资源快照 Schema, 从 ORM 文本列或 dict 解析快照。, SnapshotCertRead, SnapshotPersonnelRow, TransportResourceSnapshot, build_personnel_summary() (+6 more)
+Cohesion: 0.09
+Nodes (48): _build_public_page(), _format_file_size(), _format_plan_date(), get_public_transport(), _get_transport_by_token(), _parse_feedback_images(), Session, UploadFile (+40 more)
 
 ### Community 68 - "Community 68"
 Cohesion: 0.19
-Nodes (24): paste_recognize_commit(), generate_uuid(), PlVehiclePersonnel, 车辆-人员关联表 pl_vehicle_personnel, VehiclePersonnelRow, ConflictAction, PasteCommitBody, PasteCommitResult (+16 more)
+Nodes (25): bind_vehicle_driver(), create_vehicle(), get_vehicle(), paste_recognize_commit(), update_vehicle(), _vehicle_to_detail(), _vehicle_to_read(), PlVehicle (+17 more)
 
 ### Community 69 - "Community 69"
-Cohesion: 0.13
-Nodes (29): _append_user_scope_conditions(), apply_data_scope(), assert_row_in_data_scope(), _collect_scope_ids(), _get_child_dept_ids(), get_user_dept_id(), Session, 数据权限过滤(V0.3:基于角色 data_scope 的查询级行级过滤)  data_scope 值:   1 = 全部数据   2 = 本部门数据   3 (+21 more)
+Cohesion: 0.14
+Nodes (28): _append_user_scope_conditions(), apply_data_scope(), assert_row_in_data_scope(), _collect_scope_ids(), _get_child_dept_ids(), get_user_dept_id(), Session, 数据权限过滤(V0.3:基于角色 data_scope 的查询级行级过滤)  data_scope 值:   1 = 全部数据   2 = 本部门数据   3 (+20 more)
 
 ### Community 70 - "Community 70"
 Cohesion: 0.39
 Nodes (10): create_post(), get_post(), list_posts(), post_code_exists(), Any, Session, _row_to_dict(), soft_delete_post() (+2 more)
 
 ### Community 71 - "Community 71"
-Cohesion: 0.10
-Nodes (33): CRM 报价单 API 路由 — 挂接到 crm.router, total_pages(), QuoteApproverSettingSaveBody, QuoteAcceptBody, QuoteApprovalApproveBody, QuoteApprovalListBody, QuoteApprovalRefreshNamesBody, QuoteApprovalWithdrawBody (+25 more)
+Cohesion: 0.11
+Nodes (32): CRM 报价单 API 路由 — 挂接到 crm.router, QuoteApproverSettingSaveBody, QuoteAcceptBody, QuoteApprovalApproveBody, QuoteApprovalListBody, QuoteApprovalRefreshNamesBody, QuoteApprovalWithdrawBody, QuoteCreateBody (+24 more)
 
 ### Community 72 - "Community 72"
-Cohesion: 0.19
-Nodes (28): apply_biz_backfill(), BackfillRule, BizRef, build_biz_index(), count_target_rows(), derive_source_url(), fetch_portal_admin_id(), fetch_source_rows() (+20 more)
+Cohesion: 0.18
+Nodes (30): Settings, BaseSettings, apply_biz_backfill(), BackfillRule, BizRef, build_biz_index(), count_target_rows(), derive_source_url() (+22 more)
 
 ### Community 73 - "Community 73"
 Cohesion: 0.20
 Nodes (25): derive_source_url(), fetch_portal_admin_id(), fetch_source_rows(), legacy_id_to_str(), load_oss_id_to_url(), load_runtime_settings(), load_settings_env(), load_user_mapping() (+17 more)
 
 ### Community 74 - "Community 74"
-Cohesion: 0.14
-Nodes (18): get_pool_record(), list_pool_records(), Any, Session, _row_to_dict(), total_pages(), CrmCustomerPool, CRM 模块数据模型(产品分类、产品主表、统一附件表、客户管理、公海池、线索管理) (+10 more)
+Cohesion: 0.18
+Nodes (17): get_pool_record(), list_pool_records(), Any, Session, _row_to_dict(), total_pages(), _execute_single_rule(), CrmCustomerPool (+9 more)
 
 ### Community 77 - "Community 77"
 Cohesion: 0.11
@@ -462,8 +448,8 @@ Cohesion: 0.12
 Nodes (15): pool_rule_add(), pool_rule_delete(), pool_rule_detail(), pool_rule_execute(), pool_rule_list(), pool_rule_update(), pool_rule_update_status(), PoolRuleAddBody (+7 more)
 
 ### Community 81 - "Community 81"
-Cohesion: 0.28
-Nodes (11): assert_products_allowed_for_supplier(), enrich_products_with_hazard_flags(), get_supplier_hazard_flags(), product_allowed(), Any, Session, 批量回填明细行 isToxic/isExplosive(来自产品主数据,供前端切换主体剔除)。, test_dual_requires_both() (+3 more)
+Cohesion: 0.18
+Nodes (17): get_oper_log_meta(), OperLogMeta, 请求级操作日志元数据(ContextVar), 供异步落库线程使用,避免 ContextVar 跨线程丢失。, set_oper_log_meta(), snapshot_oper_log_meta(), _format_summary(), oper_log() (+9 more)
 
 ### Community 83 - "Community 83"
 Cohesion: 0.15
@@ -474,8 +460,8 @@ Cohesion: 0.23
 Nodes (23): build_id_maps(), clip_text(), count_rows(), export_mapping(), fetch_rows(), legacy_id_to_str(), main(), map_id() (+15 more)
 
 ### Community 86 - "Community 86"
-Cohesion: 0.13
-Nodes (44): get_plan_related(), _apply_weighing_product_update(), _apply_weighing_update(), _base_query(), create_weighing(), delete_weighing(), _get_weighing(), get_weighing_related() (+36 more)
+Cohesion: 0.12
+Nodes (39): _apply_weighing_product_update(), _apply_weighing_update(), _base_query(), create_weighing(), delete_weighing(), _get_weighing(), get_weighing_related(), list_weighing() (+31 more)
 
 ### Community 87 - "Community 87"
 Cohesion: 0.20
@@ -490,36 +476,36 @@ Cohesion: 0.19
 Nodes (22): PlOcrUsageMonth, 阿里云 OCR 月度调用计数 pl_ocr_usage_month(按自然月全局统计), assert_quota_available(), _build_ocr_client(), compress_image_bytes(), current_usage_month(), _first_attachment_url(), get_or_create_usage_row() (+14 more)
 
 ### Community 91 - "pl_vehicle_recharge_service.py"
-Cohesion: 0.12
-Nodes (37): register_contract_routes(), batch_assign_owner(), batch_submit_contract_approval(), contract_row_to_dict(), download_contract_pdf(), _ensure_contract_in_scope(), export_contracts(), finish_contract() (+29 more)
+Cohesion: 0.07
+Nodes (87): register_contract_routes(), _apply_contract_entity_fields(), batch_assign_owner(), batch_submit_contract_approval(), _build_contract_filters(), _build_contract_name_from_parties(), _build_customer_address(), _calc_amount_with_tax() (+79 more)
 
 ### Community 92 - "Community 92"
-Cohesion: 0.15
-Nodes (27): 验证密码(哈希非 bcrypt 或损坏时返回 False,避免抛错), verify_password(), change_password(), create_user(), get_user(), get_user_with_relations(), _hash_password(), list_post_ids_for_user() (+19 more)
+Cohesion: 0.09
+Nodes (36): 验证密码(哈希非 bcrypt 或损坏时返回 False,避免抛错), verify_password(), camel_to_snake(), CRUDBase, get_model_attr(), HistoryCRUD, Any, Session (+28 more)
 
 ### Community 93 - "_invoice_info_by_customer_impl"
-Cohesion: 0.17
-Nodes (11): price_letter_add(), price_letter_detail(), price_letter_list(), price_letter_update(), price_letter_void(), PriceLetterCreateBody, PriceLetterDetailBody, PriceLetterListBody (+3 more)
+Cohesion: 0.24
+Nodes (16): allocate_reimburse_title_seq(), format_reimburse_title(), generate_apply_code(), generate_title(), is_auto_reimburse_title(), parse_reimburse_date(), preview_reimburse_title_seq(), date (+8 more)
 
 ### Community 94 - "response.py"
-Cohesion: 0.22
-Nodes (15): get_storage(), download_file_bytes(), file_stream(), get_access_url(), get_download_url(), get_preview_url(), normalize_storage_path(), 报销附件存储适配 — 复用门户 app.core.storage,对外保持 bx 协议。 (+7 more)
+Cohesion: 0.36
+Nodes (15): create_opportunity_follow(), _ensure_parent_opportunity(), get_opportunity_follow(), list_follows_by_opportunity(), list_opportunity_follows(), _parse_optional_datetime(), Any, datetime (+7 more)
 
 ### Community 95 - "Community 95"
 Cohesion: 0.35
 Nodes (11): create_tenant(), get_tenant(), list_tenants(), Any, Session, _row_to_dict(), soft_delete_tenant(), tenant_no_exists() (+3 more)
 
 ### Community 97 - "_ensure_subpack_slip_no"
-Cohesion: 0.09
-Nodes (56): bind_vehicle_driver(), create_driver(), create_personnel(), create_vehicle(), delete_driver(), delete_personnel(), delete_vehicle(), get_driver() (+48 more)
+Cohesion: 0.21
+Nodes (22): clear_target_products(), count_target_rows(), _dec(), derive_source_url(), fetch_portal_admin_id(), fetch_source_rows(), legacy_id_to_str(), load_runtime_settings() (+14 more)
 
 ### Community 100 - "price_letter_detail"
 Cohesion: 0.31
 Nodes (13): apply_renumber(), build_mapping(), fetch_products(), format_new_product_no(), load_settings_env(), main(), product_id_sort_key(), Engine (+5 more)
 
 ### Community 101 - ".to_tenant_user_dict"
-Cohesion: 0.19
-Nodes (15): CRM 模块 Excel 导出列定义(字段与字典类型对齐 Java *Vo @ExcelDictFormat)。, _build_workbook(), DictLabelResolver, export_rows_to_xlsx_response(), ExportColumn, load_dict_label_maps(), Any, Session (+7 more)
+Cohesion: 0.23
+Nodes (12): CRM 模块 Excel 导出列定义(字段与字典类型对齐 Java *Vo @ExcelDictFormat)。, _build_workbook(), DictLabelResolver, export_rows_to_xlsx_response(), ExportColumn, Any, Excel 导出工具:集中处理字典 code → label(对齐 Java ExcelDictConvert / ExcelDictPreloadConver, CRM 列表导出统一入口:表头 + 行数据 + 字典 label 转换 + 文件流响应。 (+4 more)
 
 ### Community 102 - "dept.py"
 Cohesion: 0.33
@@ -530,32 +516,32 @@ Cohesion: 0.29
 Nodes (15): create_price_letter(), get_price_letter(), list_price_letters(), _parse_date(), Any, date, Session, _row_to_dict() (+7 more)
 
 ### Community 105 - "list_customers"
-Cohesion: 0.31
-Nodes (12): PlCert, list_owner_certs(), list_owner_certs_batch(), nearest_expire_date(), _normalize_cert_row(), date, Session, 扫描 pl_cert 生成到期提醒,返回新建条数。 (+4 more)
+Cohesion: 0.21
+Nodes (16): PlCert, PlDocumentReminder, 证件到期提醒表 pl_document_reminder, list_owner_certs(), list_owner_certs_batch(), nearest_expire_date(), _normalize_cert_row(), date (+8 more)
 
 ### Community 106 - "Community 106"
-Cohesion: 0.36
-Nodes (11): PlTransportDbLink, 运输-地磅出入库关联 pl_transport_db_link, 再次勾选地磅安排前:软删本运输单此前生成的、仍可作废的出入库单及关联。      - 不删除地磅月计划(可能被其他业务复用)     - 若出入库单已完成的/已, _resolve_link_contributed_qty(), revoke_regeneratable_dibang_for_transport(), _subtract_plan_contribution(), test_resolve_link_contributed_qty_falls_back_to_inventory(), test_resolve_link_contributed_qty_prefers_link_field() (+3 more)
+Cohesion: 0.20
+Nodes (15): _fill_contract_linked_count(), list_quotes(), _parse_optional_datetime(), _period_key(), Any, datetime, query_versions(), quote_row_to_dict() (+7 more)
 
 ### Community 107 - "apply_pl_scope"
-Cohesion: 0.23
-Nodes (19): create_contact(), get_contact(), list_contacts_by_customer(), _parse_optional_date(), Any, date, Session, _row_to_dict() (+11 more)
+Cohesion: 0.30
+Nodes (12): PlCarrier, assert_carrier_eligible_for_transport(), carrier_agreement_expired(), carrier_audit_approved(), carrier_eligible_for_transport(), carrier_qualification_complete(), date, 资质附件均为选填,保留函数签名供兼容调用。 (+4 more)
 
 ### Community 109 - "Community 109"
 Cohesion: 0.35
 Nodes (11): create_dict_type(), dict_type_code_exists(), get_dict_type(), list_dict_types(), Any, Session, 字典类型 CRUD(sys_dict_type), _row_to_dict() (+3 more)
 
 ### Community 110 - "Base"
-Cohesion: 0.19
-Nodes (15): get_user_menu_codes(), Session, 读取用户授权的菜单权限标识集合(与前端 meta.menuCode / perms 对齐)。, _expand_with_ancestor_menu_ids(), _granted_menu_ids_for_user(), iter_user_menu_perm_codes(), _map_role_name_to_web(), Session (+7 more)
+Cohesion: 0.18
+Nodes (17): get_web_auth_menu_codes(), 获取当前用户菜单权限标识(sys_menu.perms,经角色继承)。, get_user_menu_codes(), Session, 读取用户授权的菜单权限标识集合(与前端 meta.menuCode / perms 对齐)。, _expand_with_ancestor_menu_ids(), _granted_menu_ids_for_user(), iter_user_menu_perm_codes() (+9 more)
 
 ### Community 111 - "Community 111"
 Cohesion: 0.28
 Nodes (14): _assert_editable(), _build_public_page(), _format_file_size(), _get_inventory_by_token(), get_public_inventory(), _parse_feedback_images(), Session, UploadFile (+6 more)
 
 ### Community 112 - "storage.py"
-Cohesion: 0.12
-Nodes (16): 供方全量列表(下拉)— Java: CrmSupplierInfoController.listAll, 供方详情 — Java: CrmSupplierInfoController.getInfo, 新增供方 — Java: CrmSupplierInfoController.add, 修改供方 — Java: CrmSupplierInfoController.edit, 删除供方 — Java: CrmSupplierInfoController.remove, supplier_info_add(), supplier_info_delete(), supplier_info_detail() (+8 more)
+Cohesion: 0.09
+Nodes (21): 分页查询供方列表 — Java: CrmSupplierInfoController.list, 供方全量列表(下拉)— Java: CrmSupplierInfoController.listAll, 供方详情 — Java: CrmSupplierInfoController.getInfo, 新增供方 — Java: CrmSupplierInfoController.add, 修改供方 — Java: CrmSupplierInfoController.edit, 删除供方 — Java: CrmSupplierInfoController.remove, 导出供方列表 — Java: CrmSupplierInfoController.export, supplier_info_add() (+13 more)
 
 ### Community 113 - "quote_share_log.py"
 Cohesion: 0.26
@@ -566,12 +552,12 @@ Cohesion: 0.24
 Nodes (12): DbSequence, 地磅(db)模块数据模型 — 对齐 docs/sql/db_tables.sql, _allocate_inbound_outbound_id(), _ensure_sequence_row(), max_numeric_inbound_outbound_id(), next_inbound_outbound_id(), Session, 出入库单 id 生成 — 租户内纯数字自增,并发安全。 (+4 more)
 
 ### Community 115 - "site.py"
-Cohesion: 0.28
-Nodes (17): _address_to_read(), _build_address_query(), create_transport_address(), delete_transport_address(), _get_address(), get_transport_address(), list_all_transport_addresses(), list_transport_addresses() (+9 more)
+Cohesion: 0.26
+Nodes (18): _address_to_read(), _build_address_query(), create_transport_address(), delete_transport_address(), _get_address(), get_transport_address(), list_all_transport_addresses(), list_transport_addresses() (+10 more)
 
 ### Community 116 - "Community 116"
 Cohesion: 0.19
-Nodes (25): calculate_subtotal(), _decimal_value(), delete_products_by_quote_id(), _ensure_quote_parent_scope(), _get_field(), get_quote_product(), insert_quote_product(), list_quote_products() (+17 more)
+Nodes (26): batch_insert_quote_products(), calculate_subtotal(), _decimal_value(), delete_products_by_quote_id(), _ensure_quote_parent_scope(), _get_field(), get_quote_product(), insert_quote_product() (+18 more)
 
 ### Community 118 - "Community 118"
 Cohesion: 0.22
@@ -582,12 +568,12 @@ Cohesion: 0.16
 Nodes (28): CertRow, _cert_row_complete(), collect_required_cert_errors(), _find_cert_for_required(), get_required_personnel_cert_names(), match_required_cert_name(), _missing_field_labels(), Session (+20 more)
 
 ### Community 122 - "Community 122"
-Cohesion: 0.38
-Nodes (13): ensure_crm_customer_linked_row_in_scope(), 客户子表(开票信息等):先校验关联客户 owner scope,否则校验 create_by。, _clear_default_for_customer(), create_invoice_info(), get_invoice_info(), list_invoice_info_by_customer(), Any, Session (+5 more)
+Cohesion: 0.16
+Nodes (33): create_contact(), get_contact(), list_contacts_by_customer(), _parse_optional_date(), Any, date, Session, _row_to_dict() (+25 more)
 
 ### Community 125 - "Community 125"
-Cohesion: 0.06
-Nodes (63): _build_page(), _get_by_token(), _models(), Session, 运输计划 · 入库/出库单现场免登录公共 API, SoftDeleteModel, CrmProductBrand, BizAttachment (+55 more)
+Cohesion: 0.08
+Nodes (53): _build_page(), _get_by_token(), _models(), Session, 运输计划 · 入库/出库单现场免登录公共 API, PlInboundOrder, PlInboundOrderItem, PlOutboundOrder (+45 more)
 
 ### Community 126 - "customer_pool.py"
 Cohesion: 0.45
@@ -602,16 +588,12 @@ Cohesion: 0.39
 Nodes (10): create_site(), get_site(), list_sites(), Any, Session, _row_to_dict(), site_code_exists(), soft_delete_site() (+2 more)
 
 ### Community 129 - "BaseStorage"
-Cohesion: 0.49
-Nodes (10): apply_pl_scope(), Session, build_menu_badge_counts(), count_document_reminder_expired_pending(), count_freight_approval_pending(), count_freight_disburse_pending(), _count_pending_applies(), count_plan_archive_pending() (+2 more)
+Cohesion: 0.12
+Nodes (24): _auto_contract_name_body(), generate_contract_name(), 按面板单位全称精确匹配交易主体/客户主数据,取 shortName;对不上则用全称。, 前端预览误用单位全称时,名称片段会等于面板/客户/开票全称。, 按面板供方(partyA)-需方(partyB)生成:{供方简称}-{需方简称}({合同编号})。      - 名称为空:按主数据简称自动生成     - 名, resolve_party_short_name(), _strip_contract_name_no_suffix(), _user_contract_name_uses_party_full_name() (+16 more)
 
 ### Community 130 - "datetime_parse.py"
-Cohesion: 0.15
-Nodes (14): 流程实例 wf_process_instance, 用户-角色关联 sys_user_role(V0.3), SysUserRole, WfProcessInstance, _dispatch_local(), Any, 工作流回调服务 —— 流程状态变更时通知业务系统, 尝试本地直调。返回 True 表示已处理,False 表示无匹配的本地回调。 (+6 more)
-
-### Community 131 - "LocalStorage"
-Cohesion: 0.14
-Nodes (21): ApiCryptoMiddleware, ApiRequestLogMiddleware, _claims_from_auth(), _format_body_bytes(), _persist_log(), Any, Request, 统一记录 API 请求/响应出入参的中间件 (+13 more)
+Cohesion: 0.40
+Nodes (3): Any, 供 get_tenant_no 等门户工具使用。, 与门户 JWT / apply_data_scope 所需的 user_info 字段对齐。
 
 ### Community 132 - "crm_supplier_hazard.py"
 Cohesion: 0.14
@@ -630,77 +612,45 @@ Cohesion: 0.19
 Nodes (18): create_role(), get_role(), get_role_data_scope(), get_role_menu_ids(), list_roles(), Any, Session, 角色 CRUD(sys_role / sys_role_menu / sys_role_data_scope_detail) (+10 more)
 
 ### Community 137 - "statistics.py"
-Cohesion: 0.10
-Nodes (31): advance_issue_stats(), batch_offset(), export_advance_issues(), issue_advance(), list_advance_issues(), list_advance_offset_records(), list_pending_payments(), list_processed_payments() (+23 more)
+Cohesion: 0.09
+Nodes (18): _date_to_str(), _dt_to_str(), PagedQuery, PagedResponse, date, datetime, bx 原系统 API 响应包装(code=0 / msg / data.rows),与门户 success_response 分离。, _coerce_id() (+10 more)
 
 ### Community 138 - "Community 138"
 Cohesion: 0.33
 Nodes (19): check_python(), create_venv(), ensure_dirs(), ensure_valid_venv(), ensure_venv_and_runtime(), install_dependencies(), is_running(), log_error() (+11 more)
 
-### Community 139 - "Community 139"
-Cohesion: 0.31
-Nodes (10): align_contract_no_to_sign_date(), 标准编号替换日期段,保留序号;非标准返回 None。, 将标准合同编号日期段对齐签订日;撞号则序号顺延(含软删查重)。      非标准编号原样返回。无签订日则原样返回。, replace_contract_no_date(), test_align_bumps_seq_when_occupied(), test_align_exclude_id_skips_self(), test_align_returns_original_when_nonstandard(), test_replace_keeps_seq_and_swaps_date() (+2 more)
-
-### Community 141 - "clue_statistics.py"
-Cohesion: 0.15
-Nodes (30): create_clue_follow(), delete_clue_follow(), get_clue_follow(), get_follow_statistics(), list_clue_follows(), Any, Session, 更新线索跟进记录,必要时同步线索 next_time (+22 more)
-
 ### Community 143 - "SysEthnic"
 Cohesion: 0.33
 Nodes (11): create_leave(), get_leave(), list_leaves(), Any, Session, _row_to_dict(), soft_delete_leave(), update_leave() (+3 more)
 
-### Community 144 - "SysApiRequestLog"
-Cohesion: 0.15
-Nodes (14): invoice_info_add(), invoice_info_by_customer(), _invoice_info_by_customer_impl(), invoice_info_delete(), invoice_info_list(), invoice_info_set_default(), invoice_info_update(), 按客户ID查询开票信息(与 by-customer 等价) (+6 more)
-
 ### Community 145 - "minio_url.py"
-Cohesion: 0.51
-Nodes (10): apply_site_feedback(), OrderItem, _header(), _item(), test_apply_site_feedback_does_not_reset_first_submitted_at(), test_apply_site_feedback_keeps_in_progress_when_requested(), test_apply_site_feedback_rejects_already_voided(), test_apply_site_feedback_rejects_invalid_status() (+2 more)
+Cohesion: 0.08
+Nodes (22): pool_customer_assign(), pool_customer_claim(), pool_customer_list(), pool_record_detail(), pool_record_list(), price_letter_add(), price_letter_detail(), price_letter_list() (+14 more)
 
 ### Community 146 - "__init__.py"
-Cohesion: 0.49
-Nodes (10): clue_statistics_level(), _apply_create_range(), _base_query(), get_clue_level_statistics(), get_clue_overview_statistics(), get_clue_owner_statistics(), get_clue_source_statistics(), get_clue_trend_statistics() (+2 more)
+Cohesion: 0.29
+Nodes (15): clue_statistics_level(), clue_statistics_overview(), clue_statistics_owner(), clue_statistics_source(), clue_statistics_trend(), _apply_create_range(), _base_query(), get_clue_level_statistics() (+7 more)
 
 ### Community 147 - "Community 147"
 Cohesion: 0.37
 Nodes (17): check_env(), check_python(), create_venv(), init_env(), install_dependencies(), log_error(), log_info(), log_success() (+9 more)
 
-### Community 150 - "ContractListQuery"
-Cohesion: 0.33
-Nodes (8): allocate_next_biz_no(), _format_biz_no(), _prefix_for(), datetime, Session, 业务协议号自动生成:XBCC / JZCC + YYYYMMDD + 6 位序号, 原子分配下一个业务协议号。     须在 create 事务内调用;使用 MySQL LAST_INSERT_ID 保证并发安全。, BizNoKind
-
-### Community 152 - "MinIOStorage"
-Cohesion: 0.24
-Nodes (5): MinIOStorage, Any, 从 MINIO_BASE_URL 解析公网 endpoint;未配置或与内网相同时复用 self.client。, MinIO 预签名下载 URL,携带原始文件名。, MinIO 预签名内联预览 URL(PDF 等 iframe 场景)。
-
 ### Community 154 - "PlCarrier"
-Cohesion: 0.15
-Nodes (24): approve_carrier(), create_carrier(), get_carrier(), update_carrier(), PlCarrier, carrier_to_read(), CarrierBase, CarrierCreate (+16 more)
-
-### Community 156 - "get_client_ip"
-Cohesion: 0.27
-Nodes (11): create_dict_data(), get_dict_data(), list_dict_data(), list_dict_data_options(), Any, Session, 字典数据 CRUD(sys_dict_data), 字典下拉选项:租户主数据,忽略数据范围(user_info 保留兼容调用方,不参与过滤)。 (+3 more)
+Cohesion: 0.09
+Nodes (54): approve_carrier(), create_carrier(), create_driver(), create_personnel(), delete_carrier(), delete_driver(), delete_personnel(), delete_vehicle() (+46 more)
 
 ### Community 159 - "minio_url.py"
-Cohesion: 0.52
-Nodes (6): apply_updates(), collect_candidates(), main(), parse_name(), Path, write_csv()
+Cohesion: 0.49
+Nodes (10): apply_pl_scope(), Session, build_menu_badge_counts(), count_document_reminder_expired_pending(), count_freight_approval_pending(), count_freight_disburse_pending(), _count_pending_applies(), count_plan_archive_pending() (+2 more)
 
 ### Community 160 - "register_local_callback"
-Cohesion: 0.15
-Nodes (19): create_leave(), delete_leave(), get_leave(), _leave_local_callback(), leave_workflow_callback(), list_leaves(), Session, submit_leave() (+11 more)
+Cohesion: 0.13
+Nodes (21): API 路由包 — 山峡化工生产一体化门户, create_leave(), delete_leave(), get_leave(), _leave_local_callback(), leave_workflow_callback(), list_leaves(), Session (+13 more)
 
 ### Community 161 - "backfill_crm_contract_attachment_urls.py"
 Cohesion: 0.33
 Nodes (10): load_oss_map(), load_runtime_settings(), load_settings_env(), main(), Any, Engine, 返回 (新值, 是否发生了 id→url 替换)。, resolve_token() (+2 more)
 
-### Community 162 - "crm_models.py"
-Cohesion: 0.24
-Nodes (11): get_current_time(), parse_datetime(), datetime, create_oss(), get_oss_by_id(), get_oss_by_url(), Session, 按主键 id 查询附件(兼容旧 CRM 雪花 oss_id 迁入后的记录) (+3 more)
-
-### Community 163 - "login_crypto.py"
-Cohesion: 0.31
-Nodes (9): decrypt_login_payload(), ensure_initialized(), extract_login_credentials(), get_public_pem(), Any, 登录凭据 RSA 解密(与前端 JSEncrypt PKCS#1 v1.5 兼容)。, Base64 密文 -> JSON 对象(须含 username、password、ts 毫秒时间戳)。, 从请求体解析用户名、密码。     返回 (username, password, error_message);error_message 非空时表示失败。 (+1 more)
-
 ### Community 164 - "ethnic.py"
 Cohesion: 0.21
 Nodes (11): list_ethnics(), Any, Session, 民族码表 CRUD(全局 sys_ethnic), _row_to_dict(), 数据模型(与 docs/sql/shanxia2.0.sql 全库导出基线对齐的核心系统表), Web 管理端约定角色(由 sys_role.role_name 映射而来,非数据库枚举), 民族码表 sys_ethnic(国标 GB/T 3304,全局) (+3 more)
@@ -709,33 +659,29 @@ Nodes (11): list_ethnics(), Any, Session, 民族码表 CRUD(全局 sys_ethnic
 Cohesion: 0.20
 Nodes (21): _assert_users_exist(), get_setting(), Any, Session, _row_to_dict(), save_setting(), _assert_users_exist(), get_setting() (+13 more)
 
-### Community 171 - "BaseStorage"
-Cohesion: 0.22
-Nodes (3): BaseStorage, 带下载文件名的访问 URL;默认实现为普通访问地址。, 浏览器内联预览 URL;默认实现为普通访问地址。
-
 ### Community 173 - "resolve_create_time_bounds"
 Cohesion: 0.67
 Nodes (3): parse_optional_plan_datetime(), datetime, 运输计划相关日期时间解析:前端 date-picker 仅传 YYYY-MM-DD。
 
 ### Community 174 - "datetime_parse.py"
-Cohesion: 0.60
-Nodes (4): date, _resolve_create_date(), test_resolve_create_date_defaults_today(), test_resolve_create_date_uses_explicit()
+Cohesion: 0.33
+Nodes (8): _build_driver_url(), get_plan_arrange_info(), 获取计划已安排运输后的司机链接与地磅出入库关联(供查看弹窗复制简述/二维码)。, TransportSiteLinkRead, build_transport_site_link_read(), build_transport_site_link_read_from_row(), _parse_feedback_images(), Session
 
-### Community 178 - ".to_tenant_user_dict"
-Cohesion: 0.40
-Nodes (3): Any, 供 get_tenant_no 等门户工具使用。, 与门户 JWT / apply_data_scope 所需的 user_info 字段对齐。
+### Community 178 - "product_allowed"
+Cohesion: 0.28
+Nodes (11): assert_products_allowed_for_supplier(), enrich_products_with_hazard_flags(), get_supplier_hazard_flags(), product_allowed(), Any, Session, 批量回填明细行 isToxic/isExplosive(来自产品主数据,供前端切换主体剔除)。, test_dual_requires_both() (+3 more)
 
 ### Community 179 - "_ensure_subpack_slip_no"
 Cohesion: 0.07
-Nodes (66): Session, recognize_cert(), RecognizeCertBody, RecognizeCertResult, archive_plan(), cancel_plan(), cancel_plan_wait_notice(), count_plans_by_contract() (+58 more)
+Nodes (78): archive_plan(), cancel_plan(), cancel_plan_wait_notice(), count_plans_by_contract(), create_from_contract(), create_plan(), create_plan_full(), delete_plan() (+70 more)
 
 ### Community 180 - "menu.py"
 Cohesion: 0.36
 Nodes (13): _build_tree(), _cascade_soft_delete(), create_menu(), get_menu(), list_menus(), list_menus_tree(), menu_name_exists(), Any (+5 more)
 
-### Community 181 - "get_db_current_user_optional"
-Cohesion: 0.67
-Nodes (3): get_db_current_user_optional(), Session, 有 Bearer 且为 admin/super_admin 时返回上下文,否则 None(供三方 H5 无登录调用)。
+### Community 187 - "allocate_next_biz_no"
+Cohesion: 0.11
+Nodes (27): generate_uuid(), get_current_time(), parse_datetime(), datetime, allocate_next_biz_no(), _format_biz_no(), _prefix_for(), datetime (+19 more)
 
 ### Community 206 - "crm_quote_pdf.py"
 Cohesion: 0.36
@@ -746,8 +692,8 @@ Cohesion: 0.18
 Nodes (10): 1. 创建虚拟环境, 2. 安装依赖, 3. 配置环境变量, 4. 启动服务, API 路由分组, shanxia2.0 后端骨架(FastAPI), 开发规范, 快速开始 (+2 more)
 
 ### Community 220 - "api_crypto_middleware.py"
-Cohesion: 0.13
-Nodes (22): _claims_from_auth(), _coerce_post_method_override_to_get(), _get_redis_client(), _is_crypto_api(), _json_error_response(), _mark_nonce_once(), _nonce_key(), Redis (+14 more)
+Cohesion: 0.14
+Nodes (23): ApiCryptoMiddleware, _claims_from_auth(), _coerce_post_method_override_to_get(), _get_redis_client(), _is_crypto_api(), _json_error_response(), _mark_nonce_once(), _nonce_key() (+15 more)
 
 ### Community 237 - "order_status_compat.py"
 Cohesion: 0.36
@@ -764,22 +710,22 @@ Nodes (6): eq_unicode(), like_unicode(), MySQL 字符串比较/模糊匹配时
 ## Knowledge Gaps
 - **30 isolated node(s):** `Config`, `Config`, `Config`, `Config`, `Config` (+25 more)
   These have ≤1 connection - possible missing edges or undocumented components.
-- **16 thin communities (<3 nodes) omitted from report** — run `graphify query` to explore isolated nodes.
+- **17 thin communities (<3 nodes) omitted from report** — run `graphify query` to explore isolated nodes.
 
 ## Suggested Questions
 _Questions this graph is uniquely positioned to answer:_
 
-- **Why does `BaseModel` connect `Community 12` to `Community 0`, `Community 1`, `Community 3`, `statistics.py`, `Community 11`, `Community 14`, `Community 15`, `SysApiRequestLog`, `Community 16`, `Community 18`, `Community 24`, `PlCarrier`, `Community 27`, `Community 28`, `Community 26`, `register_local_callback`, `Community 33`, `Community 36`, `Community 43`, `Community 45`, `Community 48`, `_ensure_subpack_slip_no`, `Community 51`, `Community 54`, `Community 58`, `Community 63`, `Community 64`, `Community 65`, `Community 66`, `Community 67`, `Community 68`, `Community 71`, `Community 78`, `Community 86`, `_invoice_info_by_customer_impl`, `_ensure_subpack_slip_no`, `Community 111`, `storage.py`, `site.py`, `Community 119`, `Community 125`, `Community 127`?**
-  _High betweenness centrality (0.120) - this node is a cross-community bridge._
-- **Why does `generate_uuid()` connect `Community 68` to `Community 0`, `plan.py`, `Community 2`, `Community 4`, `Community 6`, `Community 134`, `Community 8`, `Community 136`, `post.py`, `Community 11`, `Community 7`, `clue_statistics.py`, `Community 13`, `SysEthnic`, `Community 15`, `Community 16`, `Community 19`, `Community 21`, `ContractListQuery`, `Community 25`, `PlCarrier`, `Community 27`, `get_client_ip`, `Community 28`, `minio_url.py`, `crm_models.py`, `Community 38`, `Community 39`, `test_quote_approver_setting.py`, `Community 43`, `Community 45`, `Community 46`, `Community 49`, `_ensure_subpack_slip_no`, `Community 51`, `menu.py`, `Community 53`, `Community 58`, `Community 61`, `Community 65`, `Community 66`, `Community 70`, `Community 74`, `Community 83`, `Community 86`, `Community 87`, `pl_ocr_service.py`, `Community 92`, `Community 95`, `_ensure_subpack_slip_no`, `dept.py`, `apply_crm_create_by_scope`, `list_customers`, `apply_pl_scope`, `Community 109`, `quote_share_log.py`, `db_models.py`, `site.py`, `Community 116`, `Community 118`, `Community 122`, `Community 125`?**
-  _High betweenness centrality (0.116) - this node is a cross-community bridge._
-- **Why does `Settings` connect `Community 5` to `backfill_crm_contract_attachment_urls.py`, `Community 35`, `crm_supplier_hazard.py`, `price_letter_detail`, `Community 7`, `Community 72`, `Community 73`, `Community 42`, `Community 52`, `Community 30`, `Any`, `Community 59`, `api_crypto_middleware.py`, `Community 62`?**
-  _High betweenness centrality (0.111) - this node is a cross-community bridge._
+- **Why does `Settings` connect `Community 72` to `backfill_crm_contract_attachment_urls.py`, `_ensure_subpack_slip_no`, `Community 35`, `crm_supplier_hazard.py`, `Community 5`, `price_letter_detail`, `Community 7`, `Community 73`, `Community 42`, `Community 44`, `Community 52`, `Any`, `Community 59`, `Community 30`?**
+  _High betweenness centrality (0.109) - this node is a cross-community bridge._
+- **Why does `BaseModel` connect `Community 12` to `Community 0`, `Community 1`, `Community 3`, `LocalStorage`, `statistics.py`, `Community 11`, `Community 14`, `Community 15`, `Community 16`, `minio_url.py`, `Community 18`, `__init__.py`, `Community 24`, `Community 25`, `PlCarrier`, `Community 27`, `Community 26`, `Community 28`, `register_local_callback`, `Community 33`, `Community 34`, `Community 36`, `Community 43`, `Community 45`, `datetime_parse.py`, `Community 48`, `_ensure_subpack_slip_no`, `Community 51`, `Community 54`, `Community 58`, `Community 60`, `Community 63`, `Community 64`, `Community 65`, `Community 66`, `Community 67`, `Community 68`, `Community 71`, `Community 78`, `Community 86`, `Community 111`, `storage.py`, `site.py`, `Community 119`, `Community 127`?**
+  _High betweenness centrality (0.103) - this node is a cross-community bridge._
+- **Why does `generate_uuid()` connect `allocate_next_biz_no` to `Community 0`, `plan.py`, `Community 2`, `Community 4`, `Community 6`, `Community 134`, `Community 8`, `Community 136`, `post.py`, `Community 11`, `Community 7`, `Community 13`, `SysEthnic`, `Community 15`, `Community 16`, `Community 19`, `Community 21`, `Community 25`, `PlCarrier`, `Community 27`, `Community 28`, `Community 26`, `Community 37`, `Community 39`, `test_quote_approver_setting.py`, `Community 43`, `Community 45`, `Community 49`, `_ensure_subpack_slip_no`, `menu.py`, `Community 53`, `Community 51`, `Community 58`, `Community 61`, `Community 65`, `Community 66`, `Community 68`, `Community 70`, `Community 74`, `Community 83`, `Community 86`, `Community 87`, `pl_ocr_service.py`, `pl_vehicle_recharge_service.py`, `Community 92`, `response.py`, `Community 95`, `dept.py`, `apply_crm_create_by_scope`, `list_customers`, `Community 109`, `quote_share_log.py`, `db_models.py`, `site.py`, `Community 116`, `Community 118`, `Community 122`, `Community 125`?**
+  _High betweenness centrality (0.092) - this node is a cross-community bridge._
 - **Are the 8 inferred relationships involving `DbUserContext` (e.g. with `InventoryRelatedData` and `AutoGenerateMonthlyResult`) actually correct?**
   _`DbUserContext` has 8 INFERRED edges - model-reasoned connections that need verification._
 - **What connects `API 路由包 — 山峡化工生产一体化门户`, `返回运营端角色下拉选项(label=库中角色名,value=Web 角色码)。`, `返回用户下拉选项(label=昵称,value=用户ID,附带 nickName/userNo)。      供申请人/审批人等选择场景使用,返回本租户全部有效` to the rest of the system?**
-  _507 weakly-connected nodes found - possible documentation gaps or missing edges._
+  _516 weakly-connected nodes found - possible documentation gaps or missing edges._
 - **Should `Community 1` be split into smaller, more focused modules?**
-  _Cohesion score 0.07804878048780488 - nodes in this community are weakly interconnected._
+  _Cohesion score 0.0957983193277311 - nodes in this community are weakly interconnected._
 - **Should `Community 2` be split into smaller, more focused modules?**
   _Cohesion score 0.14304993252361672 - nodes in this community are weakly interconnected._

ファイルの差分が大きいため隠しています
+ 0 - 0
backend/graphify-out/cache/ast/v0.9.4/0d35214081d8a80769bdc081741b21f0f3d3af272d2ca6122744a5cbbc002ae1.json


ファイルの差分が大きいため隠しています
+ 0 - 0
backend/graphify-out/cache/ast/v0.9.4/34c9d96b8b5da5dacd84a86a557455f5e81ed38c96452f6be763f241163c160c.json


ファイルの差分が大きいため隠しています
+ 0 - 0
backend/graphify-out/cache/ast/v0.9.4/369ddae942265f4492be1901fd0bec978288096dd18525fcc9f10d8eec470332.json


ファイルの差分が大きいため隠しています
+ 0 - 0
backend/graphify-out/cache/ast/v0.9.4/38bfbe51fdb8f5bc43c48fc0767e742edfc963761252f32e6868c4341e61af84.json


ファイルの差分が大きいため隠しています
+ 0 - 0
backend/graphify-out/cache/ast/v0.9.4/3f46aa8277a5a3ac9a73aebbf39a72ef64852d05e40af224633d2a50d0e82953.json


ファイルの差分が大きいため隠しています
+ 0 - 0
backend/graphify-out/cache/ast/v0.9.4/69bc7d7ead223c34143e56ed7eb1381b48e07fef4b74b4dd83365e8cca1edab8.json


ファイルの差分が大きいため隠しています
+ 0 - 0
backend/graphify-out/cache/ast/v0.9.4/9a59bc109ddc024a07b33b7392a05d483860e2214950a5e3552dee57e207be2f.json


ファイルの差分が大きいため隠しています
+ 0 - 0
backend/graphify-out/cache/ast/v0.9.4/c74f02d4dc391a4a35e4810c57fdd5f8f1b5ef7d3c2a6d1a9c152adce0e05fce.json


ファイルの差分が大きいため隠しています
+ 0 - 0
backend/graphify-out/cache/ast/v0.9.4/d97668b63b513d8b42809522f685db6266d93099e61fa808684126f63c7c127f.json


ファイルの差分が大きいため隠しています
+ 0 - 0
backend/graphify-out/cache/ast/v0.9.4/ff831959d54053ab544d9c377133a120cd4caa8aac6650da16a36150444d78e6.json


ファイルの差分が大きいため隠しています
+ 0 - 0
backend/graphify-out/cache/stat-index.json


ファイルの差分が大きいため隠しています
+ 1 - 1
backend/graphify-out/graph.html


ファイルの差分が大きいため隠しています
+ 112 - 112
backend/graphify-out/graph.json


+ 169 - 0
backend/tests/test_crm_contract_name_from_parties.py

@@ -0,0 +1,169 @@
+"""合同名称按供需方面板(partyA/partyB)解析简称。"""
+
+from app.crud.crm.contract import generate_contract_name, resolve_party_short_name
+
+
+def test_resolve_matches_supplier_exact_name():
+    assert (
+        resolve_party_short_name(
+            "安庆市山峡化工有限公司",
+            supplier_name="安庆市山峡化工有限公司",
+            supplier_short_name="山峡",
+            customer_name="安徽辉隆农资集团股份有限公司",
+            customer_short_name="辉隆",
+        )
+        == "山峡"
+    )
+
+
+def test_resolve_matches_customer_exact_name():
+    assert (
+        resolve_party_short_name(
+            "安徽辉隆农资集团股份有限公司",
+            supplier_name="安庆市山峡化工有限公司",
+            supplier_short_name="山峡",
+            customer_name="安徽辉隆农资集团股份有限公司",
+            customer_short_name="辉隆",
+        )
+        == "辉隆"
+    )
+
+
+def test_resolve_matches_customer_invoice_name():
+    assert (
+        resolve_party_short_name(
+            "辉隆开票公司",
+            supplier_name="安庆市山峡化工有限公司",
+            supplier_short_name="山峡",
+            customer_name="安徽辉隆农资集团股份有限公司",
+            customer_short_name="辉隆",
+            customer_invoice_name="辉隆开票公司",
+        )
+        == "辉隆"
+    )
+
+
+def test_resolve_fallback_to_party_full_name():
+    assert (
+        resolve_party_short_name(
+            "第三方单位",
+            supplier_name="安庆市山峡化工有限公司",
+            supplier_short_name="山峡",
+            customer_name="安徽辉隆农资集团股份有限公司",
+            customer_short_name="辉隆",
+        )
+        == "第三方单位"
+    )
+
+
+def test_resolve_does_not_fuzzy_match_short_inside_longer_name():
+    """避免「山峡」子串误匹配客户全称中的山峡二字到交易主体。"""
+    assert (
+        resolve_party_short_name(
+            "安庆市山峡化工有限公司",
+            supplier_name="其他主体",
+            supplier_short_name="山峡",
+            customer_name="安庆市山峡化工有限公司",
+            customer_short_name="山峡客户",
+        )
+        == "山峡客户"
+    )
+
+
+def test_generate_empty_uses_party_order_after_swap():
+    """调换后供方=辉隆、需方=山峡 → 辉隆-山峡(编号),不因类型反序。"""
+    name = generate_contract_name(
+        "SX/X-JT20260804001",
+        party_a="安徽辉隆农资集团股份有限公司",
+        party_b="安庆市山峡化工有限公司",
+        supplier_name="安庆市山峡化工有限公司",
+        supplier_short_name="山峡",
+        customer_name="安徽辉隆农资集团股份有限公司",
+        customer_short_name="辉隆",
+        user_contract_name="",
+    )
+    assert name == "辉隆-山峡(SX/X-JT20260804001)"
+
+
+def test_generate_empty_default_party_order():
+    name = generate_contract_name(
+        "SX/X-JT20260804001",
+        party_a="安庆市山峡化工有限公司",
+        party_b="安徽辉隆农资集团股份有限公司",
+        supplier_name="安庆市山峡化工有限公司",
+        supplier_short_name="山峡",
+        customer_name="安徽辉隆农资集团股份有限公司",
+        customer_short_name="辉隆",
+        user_contract_name="",
+    )
+    assert name == "山峡-辉隆(SX/X-JT20260804001)"
+
+
+def test_generate_purchase_does_not_reverse_party_order():
+    name = generate_contract_name(
+        "SX/X-JT20260804001",
+        party_a="安徽辉隆农资集团股份有限公司",
+        party_b="安庆市山峡化工有限公司",
+        supplier_name="安庆市山峡化工有限公司",
+        supplier_short_name="山峡",
+        customer_name="安徽辉隆农资集团股份有限公司",
+        customer_short_name="辉隆",
+        user_contract_name="",
+        contract_type="purchase",
+    )
+    assert name == "辉隆-山峡(SX/X-JT20260804001)"
+
+
+def test_generate_user_name_keeps_body_and_syncs_no():
+    name = generate_contract_name(
+        "SX/X-JT20260804002",
+        party_a="安徽辉隆农资集团股份有限公司",
+        party_b="安庆市山峡化工有限公司",
+        supplier_name="安庆市山峡化工有限公司",
+        supplier_short_name="山峡",
+        customer_name="安徽辉隆农资集团股份有限公司",
+        customer_short_name="辉隆",
+        user_contract_name="自定义合同名(SX/X-JT20260804001)",
+    )
+    assert name == "自定义合同名(SX/X-JT20260804002)"
+
+
+def test_generate_full_party_name_in_user_input_is_replaced_by_short():
+    """前端误传全称时,后端按主数据简称重算(华尔泰生产案例)。"""
+    name = generate_contract_name(
+        "YD/X-JT20260731003",
+        party_a="安徽华尔泰股份有限公司",
+        party_b="安徽云栋化工有限公司",
+        supplier_name="安徽云栋化工有限公司",
+        supplier_short_name="云栋",
+        customer_name="安徽华尔泰股份有限公司",
+        customer_short_name="华尔泰",
+        user_contract_name="安徽华尔泰股份有限公司-云栋(YD/X-JT20260731003)",
+    )
+    assert name == "华尔泰-云栋(YD/X-JT20260731003)"
+
+
+def test_generate_renewal_name_is_preserved():
+    name = generate_contract_name(
+        "YD/X-JT20260804001",
+        party_a="安徽华尔泰股份有限公司",
+        party_b="安徽云栋化工有限公司",
+        supplier_name="安徽云栋化工有限公司",
+        supplier_short_name="云栋",
+        customer_name="安徽华尔泰股份有限公司",
+        customer_short_name="华尔泰",
+        user_contract_name="华尔泰-云栋(YD/X-JT20260731003)-续签1",
+    )
+    assert name == "华尔泰-云栋(YD/X-JT20260731003)-续签1(YD/X-JT20260804001)"
+
+
+def test_generate_fallback_when_parties_blank():
+    name = generate_contract_name(
+        "SX/X-JT20260804001",
+        party_a="",
+        party_b="",
+        supplier_short_name="山峡",
+        customer_short_name="辉隆",
+        user_contract_name="",
+    )
+    assert name == "合同(SX/X-JT20260804001)"

+ 38 - 1
backend/tests/test_crm_contract_no_align.py

@@ -1,7 +1,11 @@
 from datetime import date
 from unittest.mock import MagicMock, patch
 
-from app.crud.crm.contract import align_contract_no_to_sign_date, replace_contract_no_date
+from app.crud.crm.contract import (
+    align_contract_no_to_sign_date,
+    generate_contract_no,
+    replace_contract_no_date,
+)
 
 
 def test_replace_keeps_seq_and_swaps_date():
@@ -61,3 +65,36 @@ def test_align_exclude_id_skips_self():
             exclude_id="self-id",
         )
         assert out == "SX/X-JT20250810001"
+
+
+def _mock_last_contract(contract_no: str):
+    db = MagicMock()
+    last = MagicMock()
+    last.contract_no = contract_no
+    q = MagicMock()
+    q.filter.return_value = q
+    q.order_by.return_value = q
+    q.first.return_value = last
+    db.query.return_value = q
+    return db
+
+
+def test_generate_bumps_past_soft_deleted_occupied_no():
+    """软删占用的编号仍占唯一索引,生成时须跳过(对齐 uk_contract_tenant_no)。"""
+    db = _mock_last_contract("SX/X-JT20260804005")
+
+    def _exists(db_, tenant, no, exclude_id=None):
+        return no == "SX/X-JT20260804006"
+
+    with patch("app.crud.crm.contract.contract_no_exists", side_effect=_exists):
+        out = generate_contract_no(db, "shanxia2.0", sign_date=date(2026, 8, 4))
+        assert out == "SX/X-JT20260804007"
+
+
+def test_generate_starts_after_soft_deleted_max():
+    """取最大流水号须含软删,避免复用已软删的最大编号。"""
+    db = _mock_last_contract("SX/X-JT20260804006")
+
+    with patch("app.crud.crm.contract.contract_no_exists", return_value=False):
+        out = generate_contract_no(db, "shanxia2.0", sign_date=date(2026, 8, 4))
+        assert out == "SX/X-JT20260804007"

+ 76 - 0
docs/sql/migrations/2026-08-04-split-framework-contract-type.sql

@@ -0,0 +1,76 @@
+-- 合同类型:框架合同 → 框架销售合同 / 框架采购合同
+-- 幂等可重复执行
+
+-- 1) 停用旧「框架合同」
+UPDATE sys_dict_data
+SET del_flag = 1,
+    update_time = NOW()
+WHERE dict_type = 'crm_contract_type'
+  AND dict_value = 'framework'
+  AND tenant_no = 'shanxia2.0'
+  AND del_flag = 0;
+
+-- 2) 新增/恢复两类
+INSERT INTO sys_dict_data (
+  id, dict_label, dict_value, tag_type, dict_type, tenant_no, order_num, remark,
+  create_by, create_dept_id, create_time, update_by, update_time, del_flag
+) VALUES (
+  'SXDC0000020260804FS01', '框架销售合同', 'framework_sale', '', 'crm_contract_type', 'shanxia2.0', 3,
+  '原框架合同拆分:供方为本公司时',
+  '1', '', NOW(), NULL, NOW(), 0
+)
+ON DUPLICATE KEY UPDATE
+  dict_label = VALUES(dict_label),
+  order_num = 3,
+  remark = VALUES(remark),
+  del_flag = 0,
+  update_time = NOW();
+
+INSERT INTO sys_dict_data (
+  id, dict_label, dict_value, tag_type, dict_type, tenant_no, order_num, remark,
+  create_by, create_dept_id, create_time, update_by, update_time, del_flag
+) VALUES (
+  'SXDC0000020260804FP01', '框架采购合同', 'framework_purchase', '', 'crm_contract_type', 'shanxia2.0', 4,
+  '原框架合同拆分:供方非本公司时',
+  '1', '', NOW(), NULL, NOW(), 0
+)
+ON DUPLICATE KEY UPDATE
+  dict_label = VALUES(dict_label),
+  order_num = 4,
+  remark = VALUES(remark),
+  del_flag = 0,
+  update_time = NOW();
+
+-- 3) 固定后续排序(避免重复执行时 order_num 漂移)
+UPDATE sys_dict_data SET order_num = 1, update_time = NOW()
+WHERE dict_type = 'crm_contract_type' AND tenant_no = 'shanxia2.0' AND dict_value = 'sale' AND del_flag = 0;
+UPDATE sys_dict_data SET order_num = 2, update_time = NOW()
+WHERE dict_type = 'crm_contract_type' AND tenant_no = 'shanxia2.0' AND dict_value = 'purchase' AND del_flag = 0;
+UPDATE sys_dict_data SET order_num = 5, update_time = NOW()
+WHERE dict_type = 'crm_contract_type' AND tenant_no = 'shanxia2.0' AND dict_value = 'service';
+UPDATE sys_dict_data SET order_num = 6, update_time = NOW()
+WHERE dict_type = 'crm_contract_type' AND tenant_no = 'shanxia2.0' AND dict_value = 'lease';
+UPDATE sys_dict_data SET order_num = 7, update_time = NOW()
+WHERE dict_type = 'crm_contract_type' AND tenant_no = 'shanxia2.0' AND dict_value = 'other';
+UPDATE sys_dict_data SET order_num = 8, update_time = NOW()
+WHERE dict_type = 'crm_contract_type' AND tenant_no = 'shanxia2.0' AND dict_value = 'supplement';
+
+-- 4) 业务数据:供方为本公司 → 框架销售
+-- 含用户口述「安庆市山峡有限公司」及库内全称「安庆市山峡化工有限公司」
+UPDATE crm_contract
+SET contract_type = 'framework_sale',
+    update_time = NOW()
+WHERE tenant_no = 'shanxia2.0'
+  AND contract_type = 'framework'
+  AND TRIM(IFNULL(party_a, '')) IN (
+    '安庆市山峡有限公司',
+    '安庆市山峡化工有限公司',
+    '安徽云栋化工有限公司'
+  );
+
+-- 5) 其余原框架合同 → 框架采购
+UPDATE crm_contract
+SET contract_type = 'framework_purchase',
+    update_time = NOW()
+WHERE tenant_no = 'shanxia2.0'
+  AND contract_type = 'framework';

+ 32 - 0
docs/superpowers/specs/2026-08-04-crm-contract-name-from-parties-design.md

@@ -0,0 +1,32 @@
+# 合同名称按供需方面板生成
+
+## 目标
+
+合同名称始终为:`{供方简称}-{需方简称}({合同编号})`。
+
+「供方 / 需方」指面板 `partyA` / `partyB`,与是否调换、合同类型无关;采购合同不再单独反序。
+
+## 简称解析
+
+对每一侧单位全称,按精确匹配:
+
+1. 交易主体名称或简称 → 交易主体 `shortName`(无则全称)
+2. 客户名称、简称或开票公司名 → 客户 `shortName`(无则全称)
+3. 否则用面板全称
+
+后端保存时**始终以客户主数据 `short_name` 为准**;若提交的名称片段含单位全称(前端误预览),按简称重算。
+
+## 行为
+
+| 场景 | 行为 |
+|------|------|
+| 名称为空 | 后端按 `party_a`/`party_b` 自动生成 |
+| 名称含面板/客户/开票全称 | 按简称重算(防误用全称) |
+| 真正手填自定义名 | 保留主体,仅校正末尾括号内合同编号 |
+| 前端选客户/交易主体/调换供需方 | 按面板重建名称(可预览);选客户时拉取客户详情取简称 |
+| 续签 | 不改(仍为原名-续签N) |
+
+## 改动
+
+- `backend/app/crud/crm/contract.py`:`resolve_party_short_name` + `generate_contract_name`;create/update 在 apply 字段后生成;提交名含全称时重算简称
+- `ContractFormDialog.vue`(及遗留 `form.vue`):`rebuildContractName` 按面板解析;选客户时 `fetchCustomerDetail` 取 `shortName`

ファイルの差分が大きいため隠しています
+ 0 - 0
graphify-out/cache/stat-index.json


+ 23 - 18
graphify-out/manifest.json

@@ -1070,8 +1070,8 @@
     "semantic_hash": ""
   },
   "src/api/pl/index.ts": {
-    "mtime": 1785637875.0674777,
-    "ast_hash": "c2f8fec9acb4519de443caffa9651ebb",
+    "mtime": 1785808699.8540757,
+    "ast_hash": "9006d02ba1167a5ec553edf0f8291d4a",
     "semantic_hash": ""
   },
   "src/api/pl/public-io-order.ts": {
@@ -1315,8 +1315,8 @@
     "semantic_hash": ""
   },
   "src/components/business/pl-paste-recognize-dialog/index.vue": {
-    "mtime": 1785656610.2477045,
-    "ast_hash": "c2642bb0a71196a4a81111e645160ec7",
+    "mtime": 1785808688.3845584,
+    "ast_hash": "c02675f401a112033d0b9eed7ddcd260",
     "semantic_hash": ""
   },
   "src/components/business/pl-personnel-cert-badges/index.vue": {
@@ -3165,13 +3165,13 @@
     "semantic_hash": ""
   },
   "src/views/crm/contract/components/ContractDetailDialog.vue": {
-    "mtime": 1785727036.4136395,
-    "ast_hash": "b7c0c770cc47aa026296a1a03ce1ad03",
+    "mtime": 1785826532.0972168,
+    "ast_hash": "d01b340ef5e06d2d8371439e410d8fee",
     "semantic_hash": ""
   },
   "src/views/crm/contract/components/ContractFormDialog.vue": {
-    "mtime": 1785728997.1862123,
-    "ast_hash": "18c1bd7bad8fcfab013feb6b0b295478",
+    "mtime": 1785828156.2686965,
+    "ast_hash": "9de6f145ca9ed609fd4d64e52c16843f",
     "semantic_hash": ""
   },
   "src/views/crm/contract/components/ExecuteDialog.vue": {
@@ -3199,14 +3199,19 @@
     "ast_hash": "becea01b30f150e2593681ec61999147",
     "semantic_hash": ""
   },
+  "src/views/crm/contract/contractType.ts": {
+    "mtime": 1785826243.6920145,
+    "ast_hash": "b0eab96786149e6a88652caa16fdc38c",
+    "semantic_hash": ""
+  },
   "src/views/crm/contract/detail.vue": {
-    "mtime": 1785726994.2510676,
-    "ast_hash": "5645349fce2be6a52ff232a7b0b9e76e",
+    "mtime": 1785826534.2113764,
+    "ast_hash": "0d543a840781ed35138747ccb0cab5a9",
     "semantic_hash": ""
   },
   "src/views/crm/contract/form.vue": {
-    "mtime": 1785728999.854405,
-    "ast_hash": "f6aa486d1f678e73340360224e7854e1",
+    "mtime": 1785828197.6271558,
+    "ast_hash": "183076189e200e758e08ab7579137780",
     "semantic_hash": ""
   },
   "src/views/crm/contract/index.vue": {
@@ -3705,8 +3710,8 @@
     "semantic_hash": ""
   },
   "src/views/pl/vehicle/index.vue": {
-    "mtime": 1785689659.111005,
-    "ast_hash": "94669850fd3f99b6a46caa6b28ed0a0b",
+    "mtime": 1785808583.335664,
+    "ast_hash": "3bf2ed912aef74dc1e4da60b67f48fc9",
     "semantic_hash": ""
   },
   "src/views/public/db/inventory/index.vue": {
@@ -3755,8 +3760,8 @@
     "semantic_hash": ""
   },
   "src/views/system/menu/index.vue": {
-    "mtime": 1785689659.121256,
-    "ast_hash": "4d2754b4f5fa30dc4f93cc4201f8e053",
+    "mtime": 1785809169.4375062,
+    "ast_hash": "67438855097fbc2c74a5e0b768877804",
     "semantic_hash": ""
   },
   "src/views/system/operlog/index.vue": {
@@ -3790,8 +3795,8 @@
     "semantic_hash": ""
   },
   "src/views/system/user/index.vue": {
-    "mtime": 1785689659.127322,
-    "ast_hash": "ae8debfa4ae20000d7c1005a03939c1a",
+    "mtime": 1785809086.7390087,
+    "ast_hash": "eae35857d64dc408e7f0ecd15d3f5562",
     "semantic_hash": ""
   },
   "src/views/system/user/modules/user-dialog.vue": {

+ 8 - 16
web-admin/graphify-out/.graphify_labels.json

@@ -88,33 +88,30 @@
   "86": "Community 86",
   "87": "canDeleteByCreator",
   "88": "index.vue",
-  "89": "error.ts",
+  "89": "handleDisburse",
   "90": "Community 90",
   "91": "Community 91",
   "92": "Community 92",
   "93": "loadUserOptions",
-  "94": "loadUserOptions",
+  "94": "error-handle.ts",
   "95": "Community 95",
   "96": "Community 96",
-  "97": "crypto.ts",
-  "98": "pl-batch-print.ts",
+  "97": "canDeleteByCreator",
+  "98": "loadUserOptions",
   "99": "StorageKeyManager",
-  "100": "Ha",
-  "101": "highlight.ts",
-  "102": "error-handle.ts",
+  "100": "v2.4.2.1 - 2025-06-16",
+  "101": "price-letter.ts",
+  "102": "handleSearch",
   "103": "SettingDrawer.vue",
-  "104": "index.vue",
-  "105": "emit",
+  "104": "loadUserOptions",
   "106": "Community 106",
   "107": "Community 107",
   "108": "Community 108",
   "109": "Community 109",
   "110": "Community 110",
-  "111": "DbRelatedViewDialog.vue",
   "112": "Community 112",
   "113": "Community 113",
   "114": "index.vue",
-  "115": "tabs.ts",
   "116": "Community 116",
   "117": "Community 117",
   "118": "zh_CN.js",
@@ -179,7 +176,6 @@
   "239": "Community 239",
   "242": "Community 242",
   "243": "Community 243",
-  "244": "index.vue",
   "246": "price-letter-template.ts",
   "247": "Community 247",
   "248": "Community 248",
@@ -283,15 +279,12 @@
   "443": "index.vue",
   "444": "index.vue",
   "445": "Community 445",
-  "448": "theme.min.js",
   "453": "ViewKvTableCell.vue",
   "454": "zh_CN.js",
-  "457": "pl-batch-print.ts",
   "458": "Community 458",
   "459": "Community 459",
   "460": "Community 460",
   "462": "Community 462",
-  "463": "index.vue",
   "465": "index.vue",
   "470": "Ta",
   "471": "Community 471",
@@ -300,7 +293,6 @@
   "474": "Community 474",
   "475": "Community 475",
   "476": "Community 476",
-  "483": "crm-product-display.ts",
   "487": "Community 487",
   "488": "Community 488",
   "496": "Community 496",

+ 9 - 6
web-admin/graphify-out/2026-08-04/.graphify_labels.json

@@ -88,13 +88,19 @@
   "86": "Community 86",
   "87": "canDeleteByCreator",
   "88": "index.vue",
+  "89": "handleDisburse",
   "90": "Community 90",
   "91": "Community 91",
   "92": "Community 92",
   "93": "loadUserOptions",
-  "94": "loadUserOptions",
+  "94": "error-handle.ts",
   "95": "Community 95",
   "96": "Community 96",
+  "97": "canDeleteByCreator",
+  "98": "loadUserOptions",
+  "99": "StorageKeyManager",
+  "100": "v2.4.2.1 - 2025-06-16",
+  "103": "SettingDrawer.vue",
   "106": "Community 106",
   "107": "Community 107",
   "108": "Community 108",
@@ -102,8 +108,10 @@
   "110": "Community 110",
   "112": "Community 112",
   "113": "Community 113",
+  "114": "index.vue",
   "116": "Community 116",
   "117": "Community 117",
+  "118": "zh_CN.js",
   "119": "Community 119",
   "120": "Community 120",
   "125": "Community 125",
@@ -136,7 +144,6 @@
   "180": "Community 180",
   "181": "Community 181",
   "182": "Community 182",
-  "186": "Community 186",
   "187": "Community 187",
   "188": "Community 188",
   "189": "Community 189",
@@ -166,7 +173,6 @@
   "239": "Community 239",
   "242": "Community 242",
   "243": "Community 243",
-  "244": "index.vue",
   "246": "price-letter-template.ts",
   "247": "Community 247",
   "248": "Community 248",
@@ -273,12 +279,10 @@
   "448": "theme.min.js",
   "453": "ViewKvTableCell.vue",
   "454": "zh_CN.js",
-  "457": "pl-batch-print.ts",
   "458": "Community 458",
   "459": "Community 459",
   "460": "Community 460",
   "462": "Community 462",
-  "463": "index.vue",
   "465": "index.vue",
   "470": "Ta",
   "471": "Community 471",
@@ -287,7 +291,6 @@
   "474": "Community 474",
   "475": "Community 475",
   "476": "Community 476",
-  "483": "crm-product-display.ts",
   "487": "Community 487",
   "488": "Community 488",
   "496": "Community 496",

ファイルの差分が大きいため隠しています
+ 240 - 219
web-admin/graphify-out/2026-08-04/GRAPH_REPORT.md


ファイルの差分が大きいため隠しています
+ 122 - 112
web-admin/graphify-out/2026-08-04/graph.json


ファイルの差分が大きいため隠しています
+ 230 - 222
web-admin/graphify-out/GRAPH_REPORT.md


ファイルの差分が大きいため隠しています
+ 112 - 112
web-admin/graphify-out/graph.json


+ 0 - 1
web-admin/src/assets/styles/core/app.scss

@@ -419,7 +419,6 @@ body {
   flex-wrap: wrap;
   gap: 8px;
   padding: 10px 16px;
-  border-bottom: 1px solid var(--mint-border);
 
   h2,
   h3 {

+ 6 - 5
web-admin/src/views/crm/contract/components/ContractDetailDialog.vue

@@ -218,7 +218,7 @@
                   align="right"
                 >
                   <template #default="scope">
-                    <span v-if="detailContract.contractType === 'framework'" class="text-muted">随行就市</span>
+                    <span v-if="isFrameworkContractType(detailContract.contractType)" class="text-muted">随行就市</span>
                     <span v-else class="money-display">¥{{ parseFloat(scope.row.price || 0).toFixed(2) }}</span>
                   </template>
                 </el-table-column>
@@ -230,7 +230,7 @@
                   align="right"
                 >
                   <template #default="scope">
-                    <span v-if="detailContract.contractType === 'framework'" class="text-muted">随行就市</span>
+                    <span v-if="isFrameworkContractType(detailContract.contractType)" class="text-muted">随行就市</span>
                     <span v-else class="money-display">¥{{ parseFloat(scope.row.subtotal || 0).toFixed(2) }}</span>
                   </template>
                 </el-table-column>
@@ -242,7 +242,7 @@
                   align="right"
                 >
                   <template #default="scope">
-                    <span v-if="detailContract.contractType === 'framework'" class="text-muted">随行就市</span>
+                    <span v-if="isFrameworkContractType(detailContract.contractType)" class="text-muted">随行就市</span>
                     <span v-else class="money-display">¥{{ parseFloat(scope.row.taxAmount || 0).toFixed(2) }}</span>
                   </template>
                 </el-table-column>
@@ -265,7 +265,7 @@
                 </div>
               </div>
 
-              <template v-if="detailContract.contractType === 'framework' && !hideProductPrice">
+              <template v-if="isFrameworkContractType(detailContract.contractType) && !hideProductPrice">
                 <el-divider content-position="left">框架合同调价明细</el-divider>
                 <p class="text-muted" style="font-size: 13px; margin-bottom: 12px">按生效区间记录含税单价及调价函;后续结算可据此核对。</p>
                 <div
@@ -850,6 +850,7 @@
 <script setup lang="ts">
 import { ref, reactive, computed, onMounted, defineAsyncComponent, nextTick } from 'vue';
 import { useRouter } from 'vue-router';
+import { isFrameworkContractType } from '../contractType'
 import {
   CircleCheck,
   CircleClose,
@@ -1771,7 +1772,7 @@ const replacePlaceholders = (htmlContent: string, contractData: ContractVO | und
     const typeLabel = dictStore.getLabel('crm_contract_type', contractData.contractType);
     return typeLabel || '销售合同';
   };
-  const isFrameworkContract = getContractTypeName() === '框架合同';
+  const isFrameworkContract = isFrameworkContractType(contractData.contractType);
 
   // 计算产品相关数据
   const productTotal = parseFloat(String(contractData.amount || 0));

+ 174 - 96
web-admin/src/views/crm/contract/components/ContractFormDialog.vue

@@ -11,8 +11,20 @@
     :close-on-click-modal="false"
     @opened="handleOpened"
   >
-    <div class="contract-form-body">
-      <el-form ref="formRef" :model="form" :rules="rules" label-position="right" label-width="120px" class="crm-dialog-form">
+    <div
+      class="contract-form-body"
+      v-loading="formLoading"
+      element-loading-text="正在加载合同数据..."
+    >
+      <el-form
+        ref="formRef"
+        :model="form"
+        :rules="rules"
+        label-position="right"
+        label-width="120px"
+        class="crm-dialog-form"
+        :disabled="formLoading"
+      >
         <!-- 合同基础信息(一行 4 列) -->
         <div class="contract-basic-info">
           <el-form-item label="合同编号" prop="contractNo">
@@ -420,7 +432,7 @@
           </div>
 
           <!-- 框架合同调价区间 -->
-          <template v-if="form.contractType === 'framework'">
+          <template v-if="isFrameworkContractType(form.contractType)">
             <el-divider content-position="left">框架合同调价区间</el-divider>
             <p class="text-muted mb-3" style="font-size: 13px">
               按产品维护生效日期区间与含税单价(可选);若填写区间则须完整(日期、单价、调价函)。合同总金额不与此联动,仍为 0。
@@ -511,11 +523,18 @@
         <el-button
           class="btn-ghost"
           :loading="saveDraftLoading"
+          :disabled="formLoading"
           @click="handleSaveDraft"
         >
           <el-icon><FolderChecked /></el-icon>保存草稿
         </el-button>
-        <el-button class="btn-main" type="primary" :loading="submitLoading" @click="handleSubmit">
+        <el-button
+          class="btn-main"
+          type="primary"
+          :loading="submitLoading"
+          :disabled="formLoading"
+          @click="handleSubmit"
+        >
           <el-icon><Promotion /></el-icon>提交审批
         </el-button>
       </div>
@@ -556,7 +575,7 @@
 </template>
 
 <script setup lang="ts">
-import { ref, reactive, computed, nextTick } from 'vue'
+import { ref, reactive, computed, nextTick, watch } from 'vue'
 import type { FormInstance, UploadRequestOptions } from 'element-plus'
 import { ElMessage } from 'element-plus'
 import {
@@ -567,6 +586,7 @@ import {
   type ContractProductForm,
   type ContractProductPriceTierForm
 } from '@/api/crm/contract/index'
+import { isFrameworkContractType } from '../contractType'
 import { useDictStore } from '@/store/modules/dict'
 import { useUserStore } from '@/store/modules/user'
 import { $modal } from '@/utils/modal'
@@ -607,7 +627,7 @@ import {
 import { fetchProductDetail } from '@/api/crm/product'
 import ApprovalDialog from './ApprovalDialog.vue'
 import { omitEmptyExceptPartyFields } from '../partyFields'
-import { getContactByCustomerId } from '@/api/crm/customer'
+import { getContactByCustomerId, fetchCustomerDetail } from '@/api/crm/customer'
 import type { CustomerVO, ContactVO } from '@/api/crm/customer/types'
 import { getDefaultInvoiceInfoByCustomerId } from '@/api/crm/invoiceInfo'
 import { listAllSupplierInfo, type SupplierInfoVO } from '@/api/crm/supplierInfo'
@@ -744,8 +764,9 @@ const originalTemplateContent = ref<string>('')
 // 供方信息列表
 const supplierList = ref<SupplierInfoVO[]>([])
 
-// 客户简称(用于按合同类型重建合同名称)
+// 客户简称 / 开票公司名(用于按供需方面板匹配简称)
 const customerShortName = ref('')
+const customerInvoiceName = ref('')
 
 // 表单校验规则
 const rules = ref({
@@ -773,12 +794,25 @@ const rules = ref({
 // 附件列表
 const attachmentList = ref<ContractAttachmentItem[]>([])
 
-const isFrameworkContract = computed(() => form.value.contractType === 'framework')
+const isFrameworkContract = computed(() => isFrameworkContractType(form.value.contractType))
 
 // 加载状态
+const formLoading = ref(false)
 const saveDraftLoading = ref(false)
 const submitLoading = ref(false)
 
+/** 编辑打开时立即进入加载态,避免空白表单可被误改 */
+watch(
+  () => props.visible,
+  (visible) => {
+    if (visible && props.editId) {
+      formLoading.value = true
+    } else if (!visible) {
+      formLoading.value = false
+    }
+  }
+)
+
 // 组件引用
 const formRef = ref<FormInstance>()
 const approvalDialogRef = ref()
@@ -820,21 +854,35 @@ interface QuoteVO {
 /** 对话框打开后的初始化 */
 const handleOpened = async () => {
   resetPartyExpand()
-  await Promise.all([loadSupplierList(), loadUserList()])
+  const isEdit = !!props.editId
+  if (isEdit) {
+    formLoading.value = true
+  }
+  try {
+    await Promise.all([loadSupplierList(), loadUserList()])
 
-  if (props.editId) {
-    await loadContractDetail(props.editId)
-  } else {
-    resetForm()
-    form.value.signDate = new Date().toISOString().split('T')[0]
-    handleSignDateChange(form.value.signDate)
-
-    // 设置默认供方主体为"SX"
-    const defaultSupplier = supplierList.value.find((supplier) => supplier.supplierCode === 'SX')
-    if (defaultSupplier) {
-      form.value.supplierId = defaultSupplier.id
-      await handleSupplierChange(defaultSupplier.id)
+    if (props.editId) {
+      await loadContractDetail(props.editId)
+    } else {
+      resetForm()
+      form.value.signDate = new Date().toISOString().split('T')[0]
+      handleSignDateChange(form.value.signDate)
+
+      // 设置默认供方主体为"SX"
+      const defaultSupplier = supplierList.value.find((supplier) => supplier.supplierCode === 'SX')
+      if (defaultSupplier) {
+        form.value.supplierId = defaultSupplier.id
+        await handleSupplierChange(defaultSupplier.id)
+      }
     }
+  } catch (error: any) {
+    console.error('合同表单初始化失败:', error)
+    $modal.msgError(error?.message || '加载合同数据失败')
+    if (isEdit) {
+      dialogVisible.value = false
+    }
+  } finally {
+    formLoading.value = false
   }
 }
 
@@ -891,6 +939,7 @@ const resetForm = () => {
   resetPartyExpand()
   originalTemplateContent.value = ''
   customerShortName.value = ''
+  customerInvoiceName.value = ''
   contractDateRange.value = [] as any
   attachmentList.value = []
   selectedProducts.value = []
@@ -972,7 +1021,7 @@ const loadContractDetail = async (id: number | string) => {
 
     await enrichContractProductBrandMeta(form.value.products)
 
-    if (contractData.contractType === 'framework') {
+    if (isFrameworkContractType(contractData.contractType)) {
       form.value.products.forEach((product: any) => {
         product.price = 0
         product.subtotal = 0
@@ -995,7 +1044,25 @@ const loadContractDetail = async (id: number | string) => {
     await handleAttachmentData()
   }
 
-  customerShortName.value = inferCustomerShortNameFromContractName()
+  customerShortName.value = ''
+  customerInvoiceName.value = ''
+  if (form.value.customerId) {
+    try {
+      const [invoiceRes, customerRes] = await Promise.all([
+        getDefaultInvoiceInfoByCustomerId(form.value.customerId),
+        fetchCustomerDetail({ id: String(form.value.customerId) })
+      ])
+      customerInvoiceName.value = invoiceRes?.data?.companyName || ''
+      customerShortName.value = customerRes?.data?.shortName || ''
+      if (!form.value.customerName && customerRes?.data?.customerName) {
+        form.value.customerName = customerRes.data.customerName
+      }
+    } catch {
+      customerInvoiceName.value = ''
+    }
+  }
+  syncPartiesSwappedFlagFromPanels()
+  rebuildContractName()
 }
 
 /** 选择客户 */
@@ -1023,9 +1090,19 @@ const handleCustomerConfirm = async (customer: CustomerVO) => {
     form.value.quoteNo = ''
 
     try {
-      const invoiceRes = await getDefaultInvoiceInfoByCustomerId(customer.id)
+      const [invoiceRes, customerRes] = await Promise.all([
+        getDefaultInvoiceInfoByCustomerId(customer.id),
+        fetchCustomerDetail({ id: String(customer.id) })
+      ])
       const invoiceData = invoiceRes?.data
+      // 简称以客户主数据为准(列表/选择器可能缺字段)
+      customerShortName.value =
+        (customerRes?.data?.shortName || customer.shortName || '').trim()
+      if (customerRes?.data?.customerName) {
+        form.value.customerName = customerRes.data.customerName
+      }
 
+      customerInvoiceName.value = invoiceData?.companyName || ''
       if (invoiceData && invoiceData.companyName) {
         if (isPartiesSwapped.value) {
           form.value.partyA = invoiceData.companyName || ''
@@ -1065,6 +1142,7 @@ const handleCustomerConfirm = async (customer: CustomerVO) => {
       }
     } catch (error) {
       console.error('获取客户开票信息失败:', error)
+      customerInvoiceName.value = ''
       if (isPartiesSwapped.value) {
         form.value.partyA = customer.customerName
         form.value.partyAAddress = fullAddress
@@ -1116,7 +1194,9 @@ const handleCustomerConfirm = async (customer: CustomerVO) => {
       console.error('获取客户联系人失败:', error)
     }
 
-    customerShortName.value = customer.shortName || ''
+    if (!customerShortName.value) {
+      customerShortName.value = (customer.shortName || '').trim()
+    }
     rebuildContractName()
   }
 }
@@ -1198,7 +1278,7 @@ const handleQuoteConfirm = (quote: QuoteVO) => {
       $modal
         .confirm('是否要从报价单中带入产品明细?')
         .then(async () => {
-          const isFw = form.value.contractType === 'framework'
+          const isFw = isFrameworkContractType(form.value.contractType)
           form.value.products = quote.productList!.map((item: any) => ({
             productId: item.productId,
             productName: item.productName,
@@ -1363,82 +1443,79 @@ const syncContractNoDateFromSignDate = (signDateVal: string | null) => {
 
   const nextNo = `${m[1]}/X-JT${dateStr}${m[3]}`
   form.value.contractNo = nextNo
-
-  if (form.value.contractName) {
-    const replaced = form.value.contractName.replace(/[((][^))]*[))]$/, `(${nextNo})`)
-    if (replaced !== form.value.contractName) {
-      form.value.contractName = replaced
-    } else {
-      rebuildContractName()
-    }
-  }
+  rebuildContractName()
 }
 
-const COMMON_SUPPLIER_SHORT_NAMES = ['山峡', 'SX']
-
-const extractContractNameParts = (contractName: string) => {
-  const contractNoMatch = contractName.match(/[((](.+?)[))]$/)
-  const contractNoInName = contractNoMatch ? contractNoMatch[1] : ''
-  const nameBody = contractNoMatch ? contractName.substring(0, contractNoMatch.index).trim() : contractName.trim()
-  return { contractNoInName, nameBody }
-}
+/** 面板单位全称 → 匹配交易主体/客户主数据取简称;对不上用全称 */
+const resolvePartyShortName = (partyName?: string): string => {
+  const party = (partyName || '').trim()
+  if (!party) return ''
 
-const getSupplierShortName = (): string => {
   const supplier = form.value.supplierId ? supplierList.value.find((s) => s.id === form.value.supplierId) : undefined
-  return supplier?.shortName || supplier?.supplierName || '山峡'
-}
-
-const isSupplierShortNamePart = (part: string, supplierShort: string) => {
-  return part === supplierShort || COMMON_SUPPLIER_SHORT_NAMES.some((name) => part.includes(name))
-}
-
-/** 从现有合同名称推断客户简称(统一格式:供方简称-需方简称) */
-const inferCustomerShortNameFromContractName = (): string => {
-  if (customerShortName.value) return customerShortName.value
-  if (!form.value.contractName) return ''
+  const supplierName = (supplier?.supplierName || '').trim()
+  const supplierShort = (supplier?.shortName || supplierName || '').trim()
+  if (supplierName && party === supplierName) return supplierShort || party
+  if (supplierShort && party === supplierShort) return supplierShort
 
-  const { nameBody } = extractContractNameParts(form.value.contractName)
-  const parts = nameBody
-    .split('-')
-    .map((p) => p.trim())
-    .filter(Boolean)
-  if (parts.length === 0) return ''
+  const customerName = (form.value.customerName || '').trim()
+  const customerShort = (customerShortName.value || '').trim()
+  const invoiceName = (customerInvoiceName.value || '').trim()
+  if (customerName && party === customerName) return customerShort || customerName
+  if (customerShort && party === customerShort) return customerShort
+  if (invoiceName && party === invoiceName) return customerShort || invoiceName
 
-  const supplierShort = getSupplierShortName()
-  if (parts.length === 1) {
-    return isSupplierShortNamePart(parts[0], supplierShort) ? '' : parts[0]
-  }
-
-  // 统一格式:供方(交易主体)-需方(客户);供方在前则取第二段为客户简称
-  if (isSupplierShortNamePart(parts[0], supplierShort)) return parts[1]
-  if (isSupplierShortNamePart(parts[1], supplierShort)) return parts[0]
-  return parts[1]
+  return party
 }
 
-/** 重建合同名称:统一为 {供方简称}-{需方简称}({合同编号}),不因采购反序 */
+/** 重建合同名称:始终 {供方简称}-{需方简称}({合同编号}),随面板调换 */
 const rebuildContractName = () => {
-  if (!form.value.contractName) return
+  const partyAShort = resolvePartyShortName(form.value.partyA)
+  const partyBShort = resolvePartyShortName(form.value.partyB)
+  const nameBody = [partyAShort, partyBShort].filter(Boolean).join('-')
+  if (!nameBody) return
 
-  const customerShort = inferCustomerShortNameFromContractName()
-  const supplierShort = getSupplierShortName()
-  if (!customerShort && !supplierShort) return
+  const contractNo = (form.value.contractNo || '').trim()
+  form.value.contractName = contractNo ? `${nameBody}(${contractNo})` : nameBody
+}
 
-  const { contractNoInName } = extractContractNameParts(form.value.contractName)
-  const contractNo = form.value.contractNo || contractNoInName
-  const nameBody = [supplierShort, customerShort].filter(Boolean).join('-')
+/** 根据面板与交易主体/客户推断是否已调换(编辑回显用) */
+const syncPartiesSwappedFlagFromPanels = () => {
+  const partyA = (form.value.partyA || '').trim()
+  const partyB = (form.value.partyB || '').trim()
+  if (!partyA && !partyB) {
+    isPartiesSwapped.value = false
+    return
+  }
 
-  if (!nameBody) return
+  const supplier = form.value.supplierId
+    ? supplierList.value.find((s) => s.id === form.value.supplierId)
+    : undefined
+  const supplierName = (supplier?.supplierName || '').trim()
 
-  form.value.contractName = contractNo ? `${nameBody}(${contractNo})` : nameBody
-  if (customerShort) {
-    customerShortName.value = customerShort
+  if (supplierName) {
+    if (partyB === supplierName && partyA !== supplierName) {
+      isPartiesSwapped.value = true
+      return
+    }
+    if (partyA === supplierName) {
+      isPartiesSwapped.value = false
+      return
+    }
+  }
+
+  const customerName = (form.value.customerName || '').trim()
+  const invoiceName = (customerInvoiceName.value || '').trim()
+  if ((customerName && partyA === customerName) || (invoiceName && partyA === invoiceName)) {
+    isPartiesSwapped.value = true
+    return
+  }
+  if ((customerName && partyB === customerName) || (invoiceName && partyB === invoiceName)) {
+    isPartiesSwapped.value = false
   }
 }
 
-/** 供需方调换 */
+/** 供需方调换:仅交换面板字段,勿再调 handleSupplierChange(会按交易主体覆盖一侧,导致两边都变成交易主体) */
 const handleSwapParties = async () => {
-  const currentSupplierId = form.value.supplierId
-
   const temp = {
     partyA: form.value.partyA,
     partyAAddress: form.value.partyAAddress,
@@ -1471,17 +1548,14 @@ const handleSwapParties = async () => {
   form.value.partyBAccount = temp.partyAAccount
 
   isPartiesSwapped.value = !isPartiesSwapped.value
-
-  if (currentSupplierId) {
-    await handleSupplierChange(currentSupplierId)
-  }
+  rebuildContractName()
 
   $modal.msgSuccess('供需方信息已调换')
 }
 
 /** 合同类型变化处理 */
 const handleContractTypeChange = (value: string) => {
-  if (value === 'framework') {
+  if (isFrameworkContractType(value)) {
     form.value.amount = 0
     form.value.products?.forEach((p) => {
       p.price = 0
@@ -1573,7 +1647,7 @@ const handleAddProduct = () => {
 
 /** 产品选择确认 */
 const handleProductSelected = (products: any[]) => {
-  const isFw = form.value.contractType === 'framework'
+  const isFw = isFrameworkContractType(form.value.contractType)
   products.forEach((product) => {
     const brandMeta = initLineBrandMetaFromProduct(product)
     form.value.products.push({
@@ -1718,7 +1792,7 @@ const handlePackageSpecChange = (product: ExtendedContractProductForm, value: st
 
 /** 计算产品金额 */
 const calculateProductAmount = (product: ExtendedContractProductForm) => {
-  if (form.value.contractType === 'framework') {
+  if (isFrameworkContractType(form.value.contractType)) {
     product.price = 0
     product.subtotal = 0
     product.taxAmount = 0
@@ -1742,7 +1816,7 @@ const calculateProductAmount = (product: ExtendedContractProductForm) => {
 
 /** 计算合计金额 */
 const calculateTotalAmount = () => {
-  if (form.value.contractType === 'framework') {
+  if (isFrameworkContractType(form.value.contractType)) {
     form.value.amount = 0
     return
   }
@@ -1822,7 +1896,7 @@ const buildProductsPayload = () => {
     if (product.id) {
       base.id = product.id
     }
-    if (form.value.contractType === 'framework') {
+    if (isFrameworkContractType(form.value.contractType)) {
       base.price = 0
       base.subtotal = 0
       base.taxAmount = 0
@@ -1931,6 +2005,7 @@ const handleSaveDraft = async () => {
     return
   }
 
+  rebuildContractName()
   saveDraftLoading.value = true
   try {
     const attachmentJson = serializeContractAttachments(attachmentList.value)
@@ -2012,7 +2087,7 @@ const handleSubmit = async () => {
     }
   }
 
-  const requiresProducts = form.value.contractType === 'sale' || form.value.contractType === 'purchase' || form.value.contractType === 'framework'
+  const requiresProducts = form.value.contractType === 'sale' || form.value.contractType === 'purchase' || isFrameworkContractType(form.value.contractType)
 
   const validateProductRowCommon = (product: any, rowNum: number): boolean => {
     if (!product.productName || String(product.productName).trim() === '') {
@@ -2044,7 +2119,7 @@ const handleSubmit = async () => {
       const product = form.value.products[i]
       const rowNum = i + 1
       if (!validateProductRowCommon(product, rowNum)) return
-      const isFw = form.value.contractType === 'framework'
+      const isFw = isFrameworkContractType(form.value.contractType)
       if (!isFw) {
         if (!product.price || Number(product.price) <= 0) {
           $modal.msgWarning(`第${rowNum}行产品的含税单价不能为空且必须大于0`)
@@ -2098,6 +2173,7 @@ const handleSubmit = async () => {
 
   submitLoading.value = true
   try {
+    rebuildContractName()
     const attachmentJson = serializeContractAttachments(attachmentList.value)
     const data: any = { ...form.value }
 
@@ -2215,6 +2291,8 @@ const loadSupplierList = async () => {
 }
 
 .contract-form-body {
+  position: relative;
+  min-height: 280px;
   padding: 0 4px;
 }
 

+ 12 - 0
web-admin/src/views/crm/contract/contractType.ts

@@ -0,0 +1,12 @@
+/** 框架类合同类型(含历史 framework,兼容未刷完的数据) */
+export const FRAMEWORK_CONTRACT_TYPES = [
+  'framework',
+  'framework_sale',
+  'framework_purchase'
+] as const
+
+export type FrameworkContractType = (typeof FRAMEWORK_CONTRACT_TYPES)[number]
+
+export function isFrameworkContractType(type?: string | null): boolean {
+  return FRAMEWORK_CONTRACT_TYPES.includes((type || '').trim() as FrameworkContractType)
+}

+ 5 - 4
web-admin/src/views/crm/contract/detail.vue

@@ -308,19 +308,19 @@
               <el-table-column label="数量" prop="quantity" width="110" align="right" />
               <el-table-column label="含税单价/元" prop="price" width="130" align="right">
                 <template #default="scope">
-                  <span v-if="contract.contractType === 'framework'" class="text-muted">随行就市</span>
+                  <span v-if="isFrameworkContractType(contract.contractType)" class="text-muted">随行就市</span>
                   <template v-else>¥{{ parseFloat(scope.row.price || 0).toFixed(2) }}</template>
                 </template>
               </el-table-column>
               <el-table-column label="含税总价/元" prop="subtotal" width="130" align="right">
                 <template #default="scope">
-                  <span v-if="contract.contractType === 'framework'" class="text-muted">随行就市</span>
+                  <span v-if="isFrameworkContractType(contract.contractType)" class="text-muted">随行就市</span>
                   <span v-else class="text-success font-weight-bold">¥{{ parseFloat(scope.row.subtotal || 0).toFixed(2) }}</span>
                 </template>
               </el-table-column>
               <el-table-column label="税费/元" prop="taxAmount" width="120" align="right">
                 <template #default="scope">
-                  <span v-if="contract.contractType === 'framework'" class="text-muted">随行就市</span>
+                  <span v-if="isFrameworkContractType(contract.contractType)" class="text-muted">随行就市</span>
                   <span v-else>¥{{ parseFloat(scope.row.taxAmount || 0).toFixed(2) }}</span>
                 </template>
               </el-table-column>
@@ -337,7 +337,7 @@
             </el-table>
 
             <!-- 框架合同:各产品调价明细(仅详情页展示,不参与打印模板 contractContent) -->
-            <template v-if="contract.contractType === 'framework'">
+            <template v-if="isFrameworkContractType(contract.contractType)">
               <el-divider content-position="left">框架合同调价明细</el-divider>
               <p class="text-muted" style="font-size: 13px; margin-bottom: 12px">按生效区间记录含税单价及调价函;后续结算可据此核对。</p>
               <div
@@ -1033,6 +1033,7 @@ import ImagePreview from '@/components/ImagePreview/index.vue';
 import TinyMceEditor from '@/components/TinyMceEditor/index.vue';
 import { getOpportunity } from '@/api/crm/opportunity';
 import { getQuote } from '@/api/crm/quote';
+import { isFrameworkContractType } from './contractType';
 import {
   parseCrmAttachmentField,
   resolveCrmAttachmentFiles,

+ 63 - 111
web-admin/src/views/crm/contract/form.vue

@@ -374,7 +374,7 @@
             </el-table-column>
           </el-table>
 
-          <template v-if="form.contractType === 'framework'">
+          <template v-if="isFrameworkContractType(form.contractType)">
             <el-divider content-position="left">框架合同调价区间</el-divider>
             <p class="text-muted mb-3" style="font-size: 13px">
               按产品维护生效日期区间与含税单价(可选);若填写区间则须完整(日期、单价、调价函)。合同总金额不与此联动,仍为 0。
@@ -587,6 +587,7 @@ import {
   type ContractProductForm,
   type ContractProductPriceTierForm
 } from '@/api/crm/contract/index';
+import { isFrameworkContractType } from './contractType';
 import { useDictStore } from '@/store/modules/dict';
 import { useUserStore } from '@/store/modules/user';
 import { $modal } from '@/utils/modal';
@@ -606,7 +607,7 @@ import QuoteSelector from '@/components/QuoteSelector.vue';
 import UserSelector from '@/components/UserSelector.vue';
 import ApprovalDialog from './components/ApprovalDialog.vue';
 import { omitEmptyExceptPartyFields } from './partyFields';
-import { getContactByCustomerId } from '@/api/crm/customer';
+import { getContactByCustomerId, fetchCustomerDetail } from '@/api/crm/customer';
 import type { CustomerVO, ContactVO } from '@/api/crm/customer/types';
 import { getDefaultInvoiceInfoByCustomerId } from '@/api/crm/invoiceInfo';
 import { listAllSupplierInfo, type SupplierInfoVO } from '@/api/crm/supplierInfo';
@@ -714,6 +715,10 @@ const originalTemplateContent = ref<string>('');
 // 供方信息列表
 const supplierList = ref<SupplierInfoVO[]>([]);
 
+// 客户简称 / 开票公司名(用于按供需方面板匹配简称)
+const customerShortName = ref('');
+const customerInvoiceName = ref('');
+
 // 表单校验规则
 const rules = ref({
   contractType: [{ required: true, message: '合同类型不能为空', trigger: 'change' }],
@@ -758,7 +763,7 @@ const uploadDataTierLetter = computed(() => ({
   bizType: 'crm_contract_price_letter'
 }));
 
-const isFrameworkContract = computed(() => form.value.contractType === 'framework');
+const isFrameworkContract = computed(() => isFrameworkContractType(form.value.contractType));
 
 // 加载状态
 const saveDraftLoading = ref(false);
@@ -877,7 +882,7 @@ const loadContractDetail = async (id: number | string) => {
       deliveryMethod: product.deliveryMethod || ''
     }));
 
-    if (contractData.contractType === 'framework') {
+    if (isFrameworkContractType(contractData.contractType)) {
       form.value.products.forEach((product: any) => {
         product.price = 0;
         product.subtotal = 0;
@@ -932,7 +937,10 @@ const handleCustomerConfirm = async (customer: CustomerVO) => {
     // 自动获取客户的默认开票信息并填充到需方信息(乙方)
     try {
       // 注意:不要使用 Number() 转换,避免大整数精度丢失
-      const invoiceRes = await getDefaultInvoiceInfoByCustomerId(customer.id);
+      const [invoiceRes, customerRes] = await Promise.all([
+        getDefaultInvoiceInfoByCustomerId(customer.id),
+        fetchCustomerDetail({ id: String(customer.id) })
+      ]);
       console.log('========== 开票信息调试 ==========');
       console.log('客户ID(原始):', customer.id, '类型:', typeof customer.id);
       console.log('1. API返回完整数据:', JSON.stringify(invoiceRes, null, 2));
@@ -940,6 +948,11 @@ const handleCustomerConfirm = async (customer: CustomerVO) => {
       // 判断是否有开票信息数据(data可能为null或空对象)
       const invoiceData = invoiceRes?.data;
       console.log('2. 开票信息data:', invoiceData);
+      customerShortName.value = (customerRes?.data?.shortName || customer.shortName || '').trim();
+      if (customerRes?.data?.customerName) {
+        form.value.customerName = customerRes.data.customerName;
+      }
+      customerInvoiceName.value = invoiceData?.companyName || '';
 
       if (invoiceData && invoiceData.companyName) {
         console.log('3. 开票信息字段详情:');
@@ -1017,6 +1030,7 @@ const handleCustomerConfirm = async (customer: CustomerVO) => {
       console.log('====================================');
     } catch (error) {
       console.error('❌ 获取客户开票信息失败:', error);
+      customerInvoiceName.value = '';
       // 如果获取开票信息失败,使用客户基本信息
       if (isPartiesSwapped.value) {
         // 已调换:客户名称对应供方信息区域(partyA)
@@ -1082,8 +1096,11 @@ const handleCustomerConfirm = async (customer: CustomerVO) => {
       // 即使获取联系人失败,也不影响客户选择流程
     }
 
-    // 更新合同名称中的客户简称
-    updateContractNameByCustomer(customer.shortName);
+    // 更新合同名称(按供需方面板);简称以客户主数据为准
+    if (!customerShortName.value) {
+      customerShortName.value = (customer.shortName || '').trim();
+    }
+    rebuildContractName();
   }
 };
 
@@ -1175,7 +1192,7 @@ const handleQuoteConfirm = (quote: QuoteVO) => {
       $modal
         .confirm('是否要从报价单中带入产品明细?')
         .then(() => {
-          const isFw = form.value.contractType === 'framework';
+          const isFw = isFrameworkContractType(form.value.contractType);
           form.value.products = quote.productList.map((item: any) => ({
             productId: item.productId,
             productName: item.productName,
@@ -1272,8 +1289,8 @@ const handleSupplierChange = async (supplierId: number | undefined) => {
     // 更新合同编号中的供方编码
     updateContractNoBySupplier(supplier.supplierCode);
 
-    // 更新合同名称中的供方简称
-    updateContractNameBySupplier(supplier.shortName);
+    // 更新合同名称(按供需方面板)
+    rebuildContractName();
 
     const allowToxic = Number((supplier as any).allowToxic || 0);
     const allowExplosive = Number((supplier as any).allowExplosive || 0);
@@ -1344,101 +1361,41 @@ const syncContractNoDateFromSignDate = (signDateVal: string | null) => {
 };
 
 /**
- * 更新合同名称中的供方简称
- * 统一格式:{供方简称}-{需方简称}({合同编号})
+ * 面板单位全称 → 匹配交易主体/客户主数据取简称;对不上用全称
  */
-const updateContractNameBySupplier = (newSupplierShortName: string | undefined) => {
-  if (!form.value.contractName || !newSupplierShortName) {
-    return;
-  }
-
-  const contractName = form.value.contractName;
-
-  // 提取合同编号(在括号中,支持中文和英文括号)
-  const contractNoMatch = contractName.match(/[((](.+?)[))]$/);
-  const contractNo = contractNoMatch ? contractNoMatch[1] : '';
-
-  // 提取合同名称主体部分(去掉括号和合同编号)
-  const nameBody = contractNoMatch ? contractName.substring(0, contractNoMatch.index).trim() : contractName.trim();
-
-  // 常见的供方简称列表(用于识别和替换)
-  const commonSupplierNames = ['山峡', 'SX'];
-
-  // 统一格式:供方简称-需方简称(合同编号)
-  const parts = nameBody.split('-').map((p) => p.trim());
-  if (parts.length >= 2) {
-    parts[0] = newSupplierShortName;
-    const newNameBody = parts.join('-');
-    form.value.contractName = contractNo ? `${newNameBody}(${contractNo})` : newNameBody;
-  } else if (parts.length === 1) {
-    const isSupplierName = commonSupplierNames.some((name) => parts[0].includes(name));
-    if (isSupplierName) {
-      form.value.contractName = contractNo ? `${newSupplierShortName}(${contractNo})` : newSupplierShortName;
-    } else {
-      form.value.contractName = contractNo
-        ? `${newSupplierShortName}-${parts[0]}(${contractNo})`
-        : `${newSupplierShortName}-${parts[0]}`;
-    }
-  }
-
-  // 如果合同编号已更新,同步更新合同名称中的合同编号
-  if (contractNo && form.value.contractNo && contractNo !== form.value.contractNo) {
-    // 替换合同名称中的旧合同编号
-    form.value.contractName = form.value.contractName.replace(/[((].+?[))]$/, `(${form.value.contractNo})`);
-  }
+const resolvePartyShortName = (partyName?: string): string => {
+  const party = (partyName || '').trim();
+  if (!party) return '';
+
+  const supplier = form.value.supplierId ? supplierList.value.find((s) => s.id === form.value.supplierId) : undefined;
+  const supplierName = (supplier?.supplierName || '').trim();
+  const supplierShort = (supplier?.shortName || supplierName || '').trim();
+  if (supplierName && party === supplierName) return supplierShort || party;
+  if (supplierShort && party === supplierShort) return supplierShort;
+
+  const customerName = (form.value.customerName || '').trim();
+  const customerShort = (customerShortName.value || '').trim();
+  const invoiceName = (customerInvoiceName.value || '').trim();
+  if (customerName && party === customerName) return customerShort || customerName;
+  if (customerShort && party === customerShort) return customerShort;
+  if (invoiceName && party === invoiceName) return customerShort || invoiceName;
+
+  return party;
 };
 
-/**
- * 更新合同名称中的客户简称(需方)
- * 统一格式:{供方简称}-{需方简称}({合同编号})
- */
-const updateContractNameByCustomer = (newCustomerShortName: string | undefined) => {
-  if (!form.value.contractName || !newCustomerShortName) {
-    return;
-  }
+/** 重建合同名称:始终 {供方简称}-{需方简称}({合同编号}) */
+const rebuildContractName = () => {
+  const partyAShort = resolvePartyShortName(form.value.partyA);
+  const partyBShort = resolvePartyShortName(form.value.partyB);
+  const nameBody = [partyAShort, partyBShort].filter(Boolean).join('-');
+  if (!nameBody) return;
 
-  const contractName = form.value.contractName;
-
-  // 提取合同编号(在括号中,支持中文和英文括号)
-  const contractNoMatch = contractName.match(/[((](.+?)[))]$/);
-  const contractNo = contractNoMatch ? contractNoMatch[1] : '';
-
-  // 提取合同名称主体部分(去掉括号和合同编号)
-  const nameBody = contractNoMatch ? contractName.substring(0, contractNoMatch.index).trim() : contractName.trim();
-
-  // 常见的供方简称列表(用于识别,避免误替换)
-  const commonSupplierNames = ['山峡', 'SX'];
-
-  // 统一格式:供方简称-需方简称(合同编号)
-  const parts = nameBody.split('-').map((p) => p.trim());
-  if (parts.length >= 2) {
-    parts[1] = newCustomerShortName;
-    const newNameBody = parts.join('-');
-    form.value.contractName = contractNo ? `${newNameBody}(${contractNo})` : newNameBody;
-  } else if (parts.length === 1) {
-    const isSupplierName = commonSupplierNames.some((name) => parts[0].includes(name));
-    if (isSupplierName) {
-      form.value.contractName = contractNo
-        ? `${parts[0]}-${newCustomerShortName}(${contractNo})`
-        : `${parts[0]}-${newCustomerShortName}`;
-    } else {
-      form.value.contractName = contractNo ? `${newCustomerShortName}(${contractNo})` : newCustomerShortName;
-    }
-  }
-
-  // 如果合同编号已更新,同步更新合同名称中的合同编号
-  if (contractNo && form.value.contractNo && contractNo !== form.value.contractNo) {
-    // 替换合同名称中的旧合同编号
-    form.value.contractName = form.value.contractName.replace(/[((].+?[))]$/, `(${form.value.contractNo})`);
-  }
+  const contractNo = (form.value.contractNo || '').trim();
+  form.value.contractName = contractNo ? `${nameBody}(${contractNo})` : nameBody;
 };
 
-/** 供需方调换 */
+/** 供需方调换:仅交换面板字段,勿再调 handleSupplierChange(会按交易主体覆盖一侧) */
 const handleSwapParties = async () => {
-  // 保存当前的供方主体ID(调换时保持不变)
-  const currentSupplierId = form.value.supplierId;
-
-  // 交换供方和需方的所有信息(不包括supplierId)
   const temp = {
     partyA: form.value.partyA,
     partyAAddress: form.value.partyAAddress,
@@ -1470,20 +1427,15 @@ const handleSwapParties = async () => {
   form.value.partyBBank = temp.partyABank;
   form.value.partyBAccount = temp.partyAAccount;
 
-  // 切换调换状态
   isPartiesSwapped.value = !isPartiesSwapped.value;
-
-  // 如果存在供方主体,根据新的调换状态重新填充对应的信息区域
-  if (currentSupplierId) {
-    await handleSupplierChange(currentSupplierId);
-  }
+  rebuildContractName();
 
   $modal.msgSuccess('供需方信息已调换');
 };
 
 /** 合同类型变化处理 */
 const handleContractTypeChange = (value: string) => {
-  if (value === 'framework') {
+  if (isFrameworkContractType(value)) {
     form.value.amount = 0;
     form.value.products?.forEach((p) => {
       p.price = 0;
@@ -1582,7 +1534,7 @@ const handleAddProduct = () => {
 
 /** 产品选择确认 */
 const handleProductSelected = (products: any[]) => {
-  const isFw = form.value.contractType === 'framework';
+  const isFw = isFrameworkContractType(form.value.contractType);
   products.forEach((product) => {
     // 允许重复添加相同产品:直接追加到 products 列表
     form.value.products.push({
@@ -1697,7 +1649,7 @@ const handlePackageSpecChange = (product: ExtendedContractProductForm, value: st
 
 /** 计算产品金额(参考报价单逻辑) */
 const calculateProductAmount = (product: ExtendedContractProductForm) => {
-  if (form.value.contractType === 'framework') {
+  if (isFrameworkContractType(form.value.contractType)) {
     product.price = 0;
     product.subtotal = 0;
     product.taxAmount = 0;
@@ -1725,7 +1677,7 @@ const calculateProductAmount = (product: ExtendedContractProductForm) => {
 
 /** 计算合计金额 */
 const calculateTotalAmount = () => {
-  if (form.value.contractType === 'framework') {
+  if (isFrameworkContractType(form.value.contractType)) {
     form.value.amount = 0;
     return;
   }
@@ -1801,7 +1753,7 @@ const buildProductsPayload = () => {
     if (product.id) {
       base.id = product.id;
     }
-    if (form.value.contractType === 'framework') {
+    if (isFrameworkContractType(form.value.contractType)) {
       base.price = 0;
       base.subtotal = 0;
       base.taxAmount = 0;
@@ -2145,7 +2097,7 @@ const handleSubmit = async () => {
     }
   }
 
-  const requiresProducts = form.value.contractType === 'sale' || form.value.contractType === 'purchase' || form.value.contractType === 'framework';
+  const requiresProducts = form.value.contractType === 'sale' || form.value.contractType === 'purchase' || isFrameworkContractType(form.value.contractType);
 
   const validateProductRowCommon = (product: any, rowNum: number): boolean => {
     if (!product.productName || String(product.productName).trim() === '') {
@@ -2178,7 +2130,7 @@ const handleSubmit = async () => {
       if (!validateProductRowCommon(product, rowNum)) {
         return;
       }
-      const isFw = form.value.contractType === 'framework';
+      const isFw = isFrameworkContractType(form.value.contractType);
       if (!isFw) {
         if (!product.price || Number(product.price) <= 0) {
           $modal.msgWarning(`第${rowNum}行产品的含税单价不能为空且必须大于0`);

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません