2.0 KiB
归档导出按品牌拆行 Implementation Plan
For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: 列表导出与归档导出的「品牌」列改为按 pl_plan_product_brand_qty 填充;多品牌拆成多行,实际量取品牌量;无明细时品牌留空。
Architecture: 在 pl_brand_archive.py 增加 resolve_export_brand_qty_rows(段级优先、回退计划级)。列表导出(plan.py)与归档导出(pl_plan_archive_export.py)构建「段×产品」行后,若有正数量品牌明细则按品牌复制行并改写 brandName/actualQty(及归档单价)。
Tech Stack: Python 3.9、SQLAlchemy、pytest、现有 load_brand_qtys_by_*
Spec: docs/superpowers/specs/2026-10-21-pl-archive-export-brand-split-design.md
Task 1: 共享 resolve helper + 单测
Files:
-
Modify:
backend/app/services/pl_brand_archive.py -
Create/Modify:
backend/tests/test_pl_brand_archive.py -
增加
resolve_export_brand_qty_rows(stop_product_id, plan_product_id, by_stop_id, by_plan_product_id) -
单测:有段级只用段级;无段级回退计划级;皆无返回
[]
Task 2: 列表导出拆行
Files:
-
Modify:
backend/app/api/pl/plan.py(_build_plan_list_export_rows及填充逻辑) -
Modify:
backend/tests/test_pl_plan_list_export.py -
批量加载 stop / plan 级 brand_qty
-
段产品与 legacy 产品:有明细则拆行;无明细
brandName="" -
更新原「required → 君正」断言为 brand_qty 驱动;新增多品牌拆行用例
Task 3: 归档导出拆行
Files:
-
Modify:
backend/app/services/pl_plan_archive_export.py -
Modify:
backend/tests/test_pl_plan_archive_export.py -
build_plan_archive_export_rows/ legacy 同样拆行 -
有
unitPrice时改写单价与金额 -
更新单测
Task 4: 验证
pytest …→ 30 passed