提交
This commit is contained in:
1 parent
c00f19f8bd
commit
272c68af4b
134 files changed
+930389
-38617
No files matched your search
@@ -49,6 +49,10 @@ from app.schemas.pl.plan import (
|
||||
PlanWithProducts,
|
||||
)
|
||||
from app.services.pl_brand_archive import load_brand_qtys_by_plan_product_ids
|
||||
from app.services.pl_product_display import (
|
||||
load_crm_product_alias_maps,
|
||||
resolve_product_display_names,
|
||||
)
|
||||
from app.schemas.pl.transport import (
|
||||
PlanArrangeInfoRead,
|
||||
TransportInventoryLinkRead,
|
||||
@@ -90,6 +94,22 @@ router = APIRouter(prefix="/plan", tags=["运输计划-计划管理"])
|
||||
_PLAN_NO_SEQ_WIDTH = 3
|
||||
|
||||
|
||||
def _resolve_list_product_name(
|
||||
product: PlPlanProduct,
|
||||
*,
|
||||
standard_by_id: dict[str, str],
|
||||
alias_options_by_id: dict[str, list[str]],
|
||||
) -> str:
|
||||
"""列表展示用:优先 CRM 标准名(详情仍返回库内 product_name,以便编辑反推别名)。"""
|
||||
display_name, _alias = resolve_product_display_names(
|
||||
saved_product_name=product.product_name,
|
||||
product_id=product.product_id,
|
||||
standard_by_id=standard_by_id,
|
||||
alias_options_by_id=alias_options_by_id,
|
||||
)
|
||||
return display_name or (product.product_name or "")
|
||||
|
||||
|
||||
def _resolve_create_date(value: Optional[date]) -> date:
|
||||
return value or date.today()
|
||||
|
||||
@@ -323,10 +343,16 @@ def list_plans(
|
||||
for product in all_products:
|
||||
products_by_plan.setdefault(product.plan_id, []).append(product)
|
||||
|
||||
product_ids = [product.product_id for product in all_products if product.product_id]
|
||||
hazard_map = fetch_hazard_flags_map(
|
||||
db,
|
||||
tenant_no,
|
||||
[product.product_id for product in all_products if product.product_id],
|
||||
product_ids,
|
||||
)
|
||||
standard_by_id, alias_options_by_id = load_crm_product_alias_maps(
|
||||
db,
|
||||
tenant_no=tenant_no,
|
||||
product_ids=product_ids,
|
||||
)
|
||||
brand_qtys_by_pp = load_brand_qtys_by_plan_product_ids(
|
||||
db,
|
||||
@@ -356,6 +382,11 @@ def list_plans(
|
||||
"is_toxic": is_toxic,
|
||||
"is_explosive": is_explosive,
|
||||
"brand_qtys": brand_qtys,
|
||||
"product_name": _resolve_list_product_name(
|
||||
product,
|
||||
standard_by_id=standard_by_id,
|
||||
alias_options_by_id=alias_options_by_id,
|
||||
),
|
||||
}
|
||||
)
|
||||
enriched_products.append(item)
|
||||
|
||||
Reference in new issue
Block a user