Commit f873b39a by 江名洋

feat(analysis): 汇总华奥集团门店产值表数据

1 parent a9bb5bb9
......@@ -1010,6 +1010,33 @@ class AnalysisService:
cell.number_format = '0'
return cell
# 华奥集团门店产值表数据汇总
# 当门店列表中"特殊情况1"包含"华奥"时,汇总所有华奥门店的产值表数据
# 每个华奥门店各自保留门店基础信息,但产值表数据列使用汇总值
huaao_agg = None
huaao_store_names = set()
for _, _row in merged.iterrows():
_sn = str(_row.get("门店名", ""))
_s1 = str(_row.get("特殊情况1", ""))
if "华奥" in _s1:
huaao_store_names.add(_sn)
if huaao_store_names:
# 汇总华奥门店的 db_perf 数据
huaao_agg = {}
for sn in huaao_store_names:
sp = db_perf.get(sn, {})
for key, val in sp.items():
if isinstance(val, (int, float)):
huaao_agg[key] = huaao_agg.get(key, 0) + val
elif isinstance(val, str):
# 字符串字段取第一个非空值
if not huaao_agg.get(key) and val:
huaao_agg[key] = val
logger.info(f"华奥集团门店 {huaao_store_names} 产值表数据汇总: "
f"delivery={huaao_agg.get('delivery',0)}, touch={huaao_agg.get('touch',0)}, "
f"yb={huaao_agg.get('yb_orders',0)}, axb={huaao_agg.get('axb_orders',0)}, "
f"battery={huaao_agg.get('battery_orders',0)}, tire={huaao_agg.get('tire_orders',0)}")
row_num = start_row
for idx, store_row in merged.iterrows():
store_name = store_row.get("门店名", "")
......@@ -1018,6 +1045,10 @@ class AnalysisService:
store_name_str = str(store_name)
store_perf = db_perf.get(store_name_str, {})
# 华奥集团门店:产值表数据使用汇总值
is_huaao = store_name_str in huaao_store_names
if is_huaao and huaao_agg:
store_perf = {**store_perf, **huaao_agg}
# 设置行高为1.2倍(默认15pt → 18pt)
ws.row_dimensions[row_num].height = 18
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!