Commit 39136fe9 by 周立明

新增数据源查询

1 parent f6fa9c2b
......@@ -78,3 +78,32 @@
- 注:`ind_23`、`stores_23` 变量现仅用于已废弃的指标路径,保留无副作用。
- 实测(task_id=32):2.3产值=78,524,941;gross_profit=23,235,523.22、marketing_fee=3,022,248.73(数据干净,非2.1脏数据);→ 2.3毛利率=29.59%、2.3毛利率(含人力)=33.44%;delivery_cnt=7588、touch_cnt=13736、deal_cnt=8267;2.3成交客单价=9498.60。2.3达成率=76.94%。**至此 1.1/2.1/2.3 三条业务线全部从结果表取数,指标系统(A036/A075/A084)仅剩 全国经营总产值/店均产值 在用。**
- 至此三大业务线(1.1轻改 inshop+park、2.1权益 equity、2.3延保 warranty)取数口径全部迁移完毕。
## 本月流失门店/流失豪华/流失非豪华 接入 dj_smartcarlife
- 用户要求三项流失门店指标读取 `dj_smartcarlife.sale_close_store_record`:闭店时间字段 `close_time`,主营品牌 `main_brands`(多个逗号分隔)。DB 配置在 `config.py`(`Config.BIZ_SQL_DATABASE_URL`,用法同 `report_utils._get_biz_sql_conn` 的 create_engine 模式)。
- 代码改动(`build_store_effect_board.py`):
- 新增 `fetch_closed_stores(month_start, month_end_excl)`:create_engine(Config.BIZ_SQL_DATABASE_URL)→`SELECT close_time, main_brands FROM sale_close_store_record WHERE close_time >= :s AND close_time < :e`;DB 不可达返回 [](指标置0)。
- `compute_metrics` 签名加 `month_start=None, month_end_excl=None`;在零值循环后:若两者非空,查闭店记录,逐条按 `main_brands` 逗号拆分→`brand_category()` 归类(任一品牌=豪华→流失豪华,否则流失非豪华);`本月流失门店`=总条数、`流失豪华门店`/`流失非豪华门店` 拆分。
- `main()` 新增由 `--month`(优先) 或 `--period-start/end` 推导统计月份区间:month_start=当月1号,month_end_excl=下月1号(闭区间 [s,e));传给 compute_metrics。**注意:不能改 ps/pe(否则会破坏结果表 fetch 的"无周期→取最大task_id"逻辑),故单独用 month_start/month_end_excl 传参。**
- 字段说明三行更新为 dj_smartcarlife 口径;三项加入控制台回显。
- 验证:本沙箱无法连通 192.168.5.23(timed out),三项优雅降级为 0 并打 warning;后端有 DB 权限时自动填充。口径风险:按"行数=门店数"计(一条闭店记录=一个门店),未做 store 去重(假定该表一店一行);如后端出现一店多行需改 COUNT(DISTINCT 门店标识)。
## task 32 页面"重新生成"显示失败 → 根因=后端进程缓存旧代码
- 现象:用户在页面点 task 32「重新生成」后状态显示 FAILED。但在沙箱用 `C:/Python314/python.exe` 直接跑 `StoreEffectSummaryProcessor().process(task)` 与 `DataProcessor(app).process_task(32)` 均成功(状态→COMPLETED,结果文件已上传 OSS)。
- 根因:后端是常驻 `python app.py` 进程(原 PID 26920 监听 :5000,带 Werkzeug 调试重载)。`store_effect_summary_processor` / `build_store_effect_board` 在首次调用后被缓存进 `sys.modules`,后续调用不会按源文件 mtime 重新加载;`processor.py` 的函数体也在进程启动时载入。故我在 `build_store_effect_board.py` / `processor.py` 上的改动(含 流失门店、客单价公式、store_effect_earnings 路由到 StoreEffectSummaryProcessor)**旧后端进程完全看不到**,仍跑旧逻辑而失败。
- 修复:结束旧进程(taskkill 26920/29388),用受管 Python 后台重启 `python app.py`(cwd=data-process,自动载 .env、启 ALL_SCHEDULERS、监听 :5000)。新 PID 25352 已起,端口恢复,当前代码全部生效。task 32 现状态 COMPLETED。
- 结论/惯例:**改完 build_store_effect_board.py / store_effect_summary_processor.py / processor.py 后,必须重启后端常驻进程**才能让页面"重新生成"生效(调试重载未覆盖动态 import 的模块缓存)。下游用户点"重新生成"本质是触发后端进程内代码,不重启则永远跑旧版。
## task 33 本月流失门店=0 与数据库不符 → 根因=页面路径漏传统计月
- 现象:用户把8月数据源导入6月周期(task 33)跑出 本月流失门店=0,但自查数据库闭店数比0大。
- 根因(与 task 32 同源但不同点):`store_effect_summary_processor.py` 第230行原调用 `compute_metrics(tmp_dir, period_start, period_end)` **只传2个参数**,`month_start/month_end_excl` 默认 `None`;而 `compute_metrics` 内流失门店统计块由 `if month_start and month_end_excl:` 守卫,两者为 None 时整块跳过,`本月流失门店` 保留零值循环初值 0(查询根本没执行,不是 SQL 写错)。CLI 路径(`--month`)会传月份故正常,但页面"重新生成"走 processor 路径漏传。
- 修复:`store_effect_summary_processor.py` 调用前由 `stat_month=task.month`(回退 period_start) 推导 `[当月1号, 下月1号)` 并传给 `compute_metrics`;补 `from datetime import ...,date,timedelta`。重启后端(PID 12464)生效。
- ⚠️ 月份口径待用户确认:task 33 周期=6月→现查 **2026-06** 闭店记录。用户是把"8月数据源"塞进"6月周期",对比库时可能按8月查;若应按数据源月份(8月)取数,需改 `compute_metrics` 月份来源(一行改动),待用户确认。
- 口径补充:①总量=闭店记录行数(假定一店一行,未去重);②豪华拆分依赖 `config_brand_category` 配置表,若该表未配宝马→豪华映射,则流失豪华门店可能全为0(总量不受影响)。沙箱无法连 192.168.5.23,真实值需后端页面"重新生成"后核对。
## 本月新增门店 / 新增豪华门店 / 新增非豪华门店(3库关联,已实现)
- 口径(用户确认):按 `main_merchant_id`(门店商户号) 去重,取该门店所有 `sub_merchant_id` 行中 `MIN(created_date)` 为首建日期;首建日期落在统计月→本月新增门店。品牌判定:`main_merchant_id`→`scrm_account.platform_merchant_brand`(first_brand_id/sec_brand_id)→`cyb_os.platform_carbrand`(bid=一级/二级品牌id 得品牌名)→`brand_category()`(config_brand_category) 定豪华;first 或 sec 任一豪华即豪华门店。
- 实现:`config.py` 新增 `SCRM_DATABASE_URL`(默认假设同 dj_smartcarlife 主机 `192.168.5.23:3306` 库名 scrm_account,可 .env 覆盖) 与 `CYB_OS_DATABASE_URL`(用户给 read_cyb_os/192.168.5.5:3311/ebf6C0D6)。`build_store_effect_board.py` 新增 `fetch_new_stores(month_start,month_end_excl,exact_map,keys)`:`_engine(url_key)` 通用建连;`_in_params` 生成具名 IN 参数。compute_metrics 在流失门店块后调用,写入三指标。
- 容错设计:首建日期(dj_smartcarlife) 独立 try,**总量无论如何保留**;scrm/cyb_os 失败仅豪华拆分降级为 0/总数(不丢总量)。
- **实测(沙箱)**:dj_smartcarlife 可达 → 2026-08 首建日期命中 **42** 个门店;但 `scrm_account` 报 `Access denied for user 'read_dj_smartcarlife'@'192.168.%' to database 'scrm_account'`(即 scrm_account 与 dj_smartcarlife 同主机 192.168.5.23,但 read_dj_smartcarlife 用户无该库权限)→ 豪华拆分降级 0/42。**缺 scrm_account 连接账号(有 SELECT 权限的用户/密码)是硬阻塞**,cyb_os 已可用。
- 重启后端(PID 7648)生效。字段说明三行已更新。
# 2026-09-09 工作日志
## scrm_account 账号补齐 + 新增门店品牌归类链路打通
- 用户给出 scrm_account 只读账号:`read_scrm_account` / `TnZobW2b` / `192.168.5.1:3310` / 库名 `scrm_account`。
- `config.py` 原 `SCRM_DATABASE_URL` 默认值(误用 read_dj_smartcarlife@192.168.5.23:3306)改为正确账号串:`mysql+pymysql://read_scrm_account:TnZobW2b@192.168.5.1:3310/scrm_account?charset=utf8mb4`。
- 实测 scrm_account 可达:`platform_merchant_brand` 58万行,列 `id/merchant_id/first_brand_id/sec_brand_id/del_flag/...`。cyb_os `platform_carbrand` 列 `bid/brand/brand_code/...`,品牌名在 **`brand`** 列(非 name/brand_name)。
- 修复 `fetch_new_stores` 三处口径错误:
1. `platform_merchant_brand` 加 `del_flag=0` 过滤(表有逻辑删除列)。
2. 品牌名字段由 `name`/`brand_name` 优先改取 `brand`(否则全空→豪华归0)。
3. 一个 `merchant_id` 多行 → 按商户 **union** 所有 first/sec 品牌 id(原 `brand_map[mid]=[r1,r2]` 覆盖只留最后一行)。
- 真实结果(链路全通):2026-08 → 新增41 豪华41 非豪华0;2026-06 → 新增90 豪华85 非豪华5。
- ⚠️ 豪华占比异常高的根因 = **用户 config_brand_category 配置本身**:69 条里把 比亚迪/吉利/广汽丰田/大众/零跑/长安/奇瑞/埃安 等大量主流/自主品牌都标成"豪华"。`brand_category` 双向子串匹配工作正常,归类是按用户配置正确得出,非代码 bug。已向用户说明,是否收窄豪华定义由用户决定(改 config 表即可,无需改代码)。
- 重启后端(PID 16560)生效。新代码+配置均可经页面"重新生成"跑通。
## 关键惯例(持续有效)
- 改 `build_store_effect_board.py` / `store_effect_summary_processor.py` / `processor.py` / `config.py` 任一文件后,**必须重启后端常驻进程**才能页面"重新生成"生效(调试重载不刷新动态 import 的模块缓存)。
- 页面"重新生成"路径(`store_effect_summary_processor.py`)统计月来自 `task.month`,非 CLI 的 `--month`;两路径需各自保证传 `month_start/month_end_excl`。
......@@ -30,7 +30,7 @@ import os
import sys
import argparse
import logging
from datetime import datetime, date
from datetime import datetime, date, timedelta
from decimal import Decimal, InvalidOperation
import pandas as pd
......@@ -626,7 +626,133 @@ def fetch_extended_warranty_23_sum(col_attr, period_start, period_end):
return Decimal('0')
def compute_metrics(src, period_start, period_end):
def fetch_closed_stores(month_start, month_end_excl):
"""
读取 dj_smartcarlife.sale_close_store_record 中闭店时间落在
[month_start, month_end_excl) 的门店闭店记录。
返回 [(close_time, main_brands), ...],每行一条闭店记录(一条记录=一个闭店门店)。
数据库不可达时返回空列表(指标置 0)。
"""
try:
from config import Config
from sqlalchemy import create_engine, text
engine = create_engine(Config.BIZ_SQL_DATABASE_URL, echo=False, pool_pre_ping=True)
with engine.connect() as conn:
sql = text(
"SELECT close_time, main_brands "
"FROM sale_close_store_record "
"WHERE close_time >= :s AND close_time < :e"
)
rows = conn.execute(sql, {'s': month_start, 'e': month_end_excl}).fetchall()
logger.info(f"[流失门店] sale_close_store_record 命中 {len(rows)} 条 "
f"({month_start}~{month_end_excl})")
return rows
except Exception as e:
logger.warning(f"[流失门店] 读取 sale_close_store_record 失败,置0: {e}")
return []
def _in_params(ids, prefix):
"""把列表转成 SQLAlchemy text 的具名 IN 参数。空列表返回 (None, None)。"""
if not ids:
return None, None
params = {f'{prefix}{i}': v for i, v in enumerate(ids)}
placeholders = ', '.join(f':{prefix}{i}' for i in range(len(ids)))
return params, placeholders
def _engine(url_key):
from config import Config
from sqlalchemy import create_engine
return create_engine(getattr(Config, url_key), echo=False, pool_pre_ping=True)
def fetch_new_stores(month_start, month_end_excl, exact_map, keys):
"""
本月新增门店(dj_smartcarlife.dj_car_life_scene_merchant_ref_new)。
口径(已与用户确认):
- 按 main_merchant_id(门店商户号)去重;该门店所有 sub_merchant_id 行中
MIN(created_date) 作为「首建日期」。
- 首建日期落在 [month_start, month_end_excl) → 本月新增门店。
- 品牌判定:用 main_merchant_id 查 scrm_account.platform_merchant_brand
取 first_brand_id / sec_brand_id → 查 cyb_os.platform_carbrand 得品牌名
→ brand_category() 定豪华;first 或 sec 任一为豪华即「新增豪华门店」。
返回 (total, lux, nonlux)。容错:首建日期(dj_smartcarlife) 取总数;
若商户品牌关联(scrm_account)/品牌字典(cyb_os) 不可达,则豪华拆分降级为 0/总数
(总量仍保留)。
"""
from sqlalchemy import text
# ---- 1) 各门店首建日期(dj_smartcarlife)----
try:
eng_ref = _engine('BIZ_SQL_DATABASE_URL')
with eng_ref.connect() as conn:
sql = text(
"SELECT main_merchant_id, MIN(created_date) AS first_created "
"FROM dj_car_life_scene_merchant_ref_new "
"GROUP BY main_merchant_id "
"HAVING MIN(created_date) >= :s AND MIN(created_date) < :e"
)
rows = conn.execute(sql, {'s': month_start, 'e': month_end_excl}).fetchall()
new_ids = [r[0] for r in rows if r[0] is not None]
logger.info(f"[新增门店] 首建日期命中 {len(new_ids)} 个门店 ({month_start}~{month_end_excl})")
except Exception as e:
logger.warning(f"[新增门店] 读取首建日期失败,置0: {e}")
return 0, 0, 0
if not new_ids:
return 0, 0, 0
total = len(new_ids)
# ---- 2)+3)+4) 豪华归类(scrm_account + cyb_os,单独立容错)----
lux = 0
try:
# 商户→品牌ID(一个 merchant_id 可能多行,按商户 union 所有 first/sec 品牌 id)
brand_set_map = {} # main_merchant_id -> set([first_brand_id, sec_brand_id, ...])
eng_scrm = _engine('SCRM_DATABASE_URL')
with eng_scrm.connect() as conn:
p, ph = _in_params(new_ids, 'm')
if p is not None:
sql = text(
"SELECT merchant_id, first_brand_id, sec_brand_id "
"FROM platform_merchant_brand "
"WHERE del_flag = 0 AND merchant_id IN ({ph})".format(ph=ph)
)
for r in conn.execute(sql, p).fetchall():
mid = r[0]
bids = brand_set_map.setdefault(mid, set())
for b in (r[1], r[2]):
if b not in (None, '', 0):
bids.add(b)
logger.info(f"[新增门店] platform_merchant_brand 命中 {len(brand_set_map)} 个商户")
# 品牌ID→品牌名(cyb_os.platform_carbrand,bid=first/sec_brand_id,品牌名字段为 brand)
all_bids = set()
for bids in brand_set_map.values():
all_bids |= bids
bid_name = {} # bid -> 品牌名
if all_bids:
eng_cyb = _engine('CYB_OS_DATABASE_URL')
with eng_cyb.connect() as conn:
p, ph = _in_params(list(all_bids), 'b')
if p is not None:
sql = text(f"SELECT bid, brand FROM platform_carbrand WHERE bid IN ({ph})")
for r in conn.execute(sql, p).fetchall():
bid, nm = r[0], r[1]
if bid is not None and nm:
bid_name[bid] = str(nm).strip()
logger.info(f"[新增门店] platform_carbrand 命中 {len(bid_name)} 个品牌")
for mid in new_ids:
brand_names = [bid_name[b] for b in brand_set_map.get(mid, set()) if b in bid_name]
if any(brand_category(nm, exact_map, keys) == '豪华' for nm in brand_names):
lux += 1
except Exception as e:
logger.warning(f"[新增门店] 品牌归类失败,豪华拆分降级为 0/总数: {e}")
nonlux = total - lux
logger.info(f"[新增门店] 合计={total} 豪华={lux} 非豪华={nonlux}")
return total, lux, nonlux
def compute_metrics(src, period_start, period_end, month_start=None, month_end_excl=None):
exact_map, keys = load_brand_category()
s1, s2 = parse_saas(src)
allrows = s1 + s2
......@@ -707,6 +833,37 @@ def compute_metrics(src, period_start, period_end):
'本月新增门店', '新增豪华门店', '新增非豪华门店']:
m[k] = Decimal('0')
# ---- 本月流失门店(dj_smartcarlife.sale_close_store_record,闭店时间在统计月份)----
# 一条闭店记录=一个门店;main_brands 多个逗号分隔,按各品牌归类(任一为豪华→豪华门店)
if month_start and month_end_excl:
try:
closed_rows = fetch_closed_stores(month_start, month_end_excl)
closed_total = closed_lux = closed_nonlux = 0
for _ct, mb in closed_rows:
closed_total += 1
brands = [b.strip() for b in (mb or '').split(',') if b and b.strip()]
if any(brand_category(b, exact_map, keys) == '豪华' for b in brands):
closed_lux += 1
else:
closed_nonlux += 1
m['本月流失门店'] = Decimal(str(closed_total))
m['流失豪华门店'] = Decimal(str(closed_lux))
m['流失非豪华门店'] = Decimal(str(closed_nonlux))
logger.info(f"[流失门店] 合计={closed_total} 豪华={closed_lux} 非豪华={closed_nonlux}")
except Exception as e:
logger.warning(f"[流失门店] 统计失败,置0: {e}")
# ---- 本月新增门店(dj_smartcarlife.dj_car_life_scene_merchant_ref_new 首建日期在统计月份)----
# 3 库关联:dj_smartcarlife(首建日期) → scrm_account(商户品牌ID) → cyb_os(品牌名) → config_brand_category(豪华)
if month_start and month_end_excl:
try:
nt, nlux, nnon = fetch_new_stores(month_start, month_end_excl, exact_map, keys)
m['本月新增门店'] = Decimal(str(nt))
m['新增豪华门店'] = Decimal(str(nlux))
m['新增非豪华门店'] = Decimal(str(nnon))
except Exception as e:
logger.warning(f"[新增门店] 统计失败,置0: {e}")
# ---- 指标系统:产值A036 / 成交A075 / 触客A084 ----
# biz: 1=延保(2.3) 2=轻改(1.1) 3=权益(2.1);多业务用 list → bizs="1,2,3"
start_str = period_start.strftime('%Y-%m-%d') if period_start else ''
......@@ -1065,12 +1222,12 @@ FIELD_NOTES = [
('6.1处置周期(批售)', '拍卖平台≠个人:(拍卖日期-收车日期)天数之和/明细数'),
('6.1处置周期(零售)', '拍卖平台=个人:(拍卖日期-收车日期)天数之和/明细数'),
('6.1库存数量', '拍卖日期为空且处置类型≠寄售 的明细数量'),
('本月流失门店', '系统数据:闭店日期在统计月份的全部门店数量【待接入系统数据,当前0】'),
('流失豪华门店', '同上且品牌归属=豪华【待接入,当前0】'),
('流失非豪华门店', '同上且品牌归属=非豪华【待接入,当前0】'),
('本月新增门店', '系统数据-商户管理:首个商户关系创建日期在统计月份的全部门店数量【待接入,当前0】'),
('新增豪华门店', '同上且品牌归属=豪华【待接入,当前0】'),
('新增非豪华门店', '同上且品牌归属=非豪华【待接入,当前0】'),
('本月流失门店', 'dj_smartcarlife.sale_close_store_record:close_time 在统计月份内的闭店门店数(一条记录=一个门店)'),
('流失豪华门店', '本月流失门店中 main_brands 任一品牌归类=豪华 的门店数'),
('流失非豪华门店', '本月流失门店中 main_brands 无豪华品牌 的门店数'),
('本月新增门店', 'dj_smartcarlife.dj_car_life_scene_merchant_ref_new:按 main_merchant_id 去重取 MIN(created_date) 为首建日期,落在统计月份的门店数'),
('新增豪华门店', '本月新增门店中,main_merchant_id→scrm_account.platform_merchant_brand(first/sec_brand_id)→cyb_os.platform_carbrand(品牌名)→config_brand_category 任一品牌=豪华'),
('新增非豪华门店', '本月新增门店中,品牌未归类豪华(含无品牌记录)的门店数'),
]
......@@ -1089,7 +1246,23 @@ def main():
month_label = args.month or (ps.strftime('%Y%m') if ps else '')
logger.info(f"[构建] 数据源={args.src} 期间={ps}~{pe}")
m = compute_metrics(args.src, ps, pe)
# 统计月份区间(用于闭店记录查询):优先 --month,其次回退到 --period-start/end
month_start = month_end_excl = None
if args.month:
try:
y, mo = map(int, args.month.split('-'))
month_start = date(y, mo, 1)
if mo == 12:
month_end_excl = date(y + 1, 1, 1)
else:
month_end_excl = date(y, mo + 1, 1)
except Exception:
month_start = month_end_excl = None
elif ps:
month_start = ps
month_end_excl = (pe + timedelta(days=1)) if pe else None
m = compute_metrics(args.src, ps, pe, month_start, month_end_excl)
out_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'outputs', 'store_effect_summary')
os.makedirs(out_dir, exist_ok=True)
......@@ -1112,7 +1285,9 @@ def main():
'6.1产值', '6.1处置车量', '6.1收车台次', '6.1库存数量',
'全国直营总人数', '全国直营营销人数', '全国直营店均人数', '全国人均产值(w)',
'豪华车员工数量', '豪华车营销人数', '豪华车店均人数', '豪华车人均产值',
'非豪华员工数量', '非豪华车营销人数', '非豪华车店均人数', '非豪华车人均产值(w)']:
'非豪华员工数量', '非豪华车营销人数', '非豪华车店均人数', '非豪华车人均产值(w)',
'本月流失门店', '流失豪华门店', '流失非豪华门店',
'本月新增门店', '新增豪华门店', '新增非豪华门店']:
print(f'{k:16s} = {m.get(k)}')
print('=' * 60)
print('OUT:', out)
......
......@@ -101,6 +101,20 @@ class Config:
'mysql+pymysql://read_dj_smartcarlife:X9RNTOLr@192.168.5.23:3306/dj_smartcarlife?charset=utf8mb4'
)
# ---------- 商户关系 / 品牌数据源(新增门店判定,3 库关联)----------
# scrm_account:platform_merchant_brand(商户↔品牌,merchant_id=main_merchant_id)
# 用户提供的只读账号:read_scrm_account @ 192.168.5.1:3310
SCRM_DATABASE_URL = os.getenv(
'SCRM_DATABASE_URL',
'mysql+pymysql://read_scrm_account:TnZobW2b@192.168.5.1:3310/scrm_account?charset=utf8mb4'
)
# cyb_os:platform_carbrand(bid↔品牌名 字典表,bid 对应 first_brand_id / sec_brand_id)
# 用户提供的只读账号
CYB_OS_DATABASE_URL = os.getenv(
'CYB_OS_DATABASE_URL',
'mysql+pymysql://read_cyb_os:ebf6C0D6@192.168.5.5:3311/cyb_os?charset=utf8mb4'
)
# ---------- 文件上传 ----------
MAX_CONTENT_LENGTH = 100 * 1024 * 1024 # 单文件最大 100M
ALLOWED_EXTS = {'.xlsx', '.xls'} # 仅支持 Excel
......
......@@ -27,7 +27,7 @@ import logging
import os
import tempfile
from collections import OrderedDict
from datetime import datetime
from datetime import datetime, date, timedelta
from decimal import Decimal, ROUND_HALF_UP
import openpyxl
......@@ -227,8 +227,21 @@ class StoreEffectSummaryProcessor:
# 双列看板(总看板):从任务附件目录重算,必须在 cleanup 之前(compute_metrics 需读 tmp_dir)
try:
from build_store_effect_board import compute_metrics
board_m = compute_metrics(tmp_dir, period_start, period_end)
logger.info(f"[店效人效汇总] 双列看板指标计算完成,共 {len(board_m)} 项")
# 流失门店统计月份:优先用任务统计月(task.month),回退到周期起止
_m_start = _m_end = None
if stat_month:
try:
_y, _mo = map(int, stat_month.split('-'))
_m_start = date(_y, _mo, 1)
_m_end = date(_y + 1, 1, 1) if _mo == 12 else date(_y, _mo + 1, 1)
except Exception:
_m_start = _m_end = None
if _m_start is None and period_start:
_m_start = period_start
_m_end = (period_end + timedelta(days=1)) if period_end else None
board_m = compute_metrics(tmp_dir, period_start, period_end, _m_start, _m_end)
logger.info(f"[店效人效汇总] 双列看板指标计算完成,共 {len(board_m)} 项 "
f"(流失门店统计月={_m_start}~{_m_end})")
except Exception as e:
import traceback
logger.error(f"[店效人效汇总] 双列看板计算失败,结果表回退单行: {e}")
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!