Commit 33316239 by 江名洋

feat(analysis): 合并生态与自然月至单sheet并优化品牌归属及赔付逻辑

1 parent 66b82271
...@@ -316,7 +316,7 @@ async def analysis_generate( ...@@ -316,7 +316,7 @@ async def analysis_generate(
"status": "success", "status": "success",
"message": "分析报表已生成", "message": "分析报表已生成",
"file_path": output_path, "file_path": output_path,
"download_url": "/api/analysis/download", "download_url": "api/analysis/download",
"ecology_store_count": len(ecology_stores), "ecology_store_count": len(ecology_stores),
"nature_store_count": len(nature_stores), "nature_store_count": len(nature_stores),
"ecology_factory_sheets": list(ecology_factory.keys()) if ecology_factory else [], "ecology_factory_sheets": list(ecology_factory.keys()) if ecology_factory else [],
......
...@@ -323,7 +323,7 @@ class AnalysisService: ...@@ -323,7 +323,7 @@ class AnalysisService:
SUM(IFNULL(sum_tire_warranty, 0)) AS total_tire_orders SUM(IFNULL(sum_tire_warranty, 0)) AS total_tire_orders
FROM dws_merchant_daily_wide FROM dws_merchant_daily_wide
WHERE report_date >= %s AND report_date <= %s WHERE report_date >= %s AND report_date <= %s
AND first_brand_id = %s And scene_type = '0' AND first_brand_id = 2365 and brand_id=2695 And scene_type = '0'
GROUP BY merchant_id, merchant_name, province_name, GROUP BY merchant_id, merchant_name, province_name,
area_supervision, flight_supervision, online_supervision area_supervision, flight_supervision, online_supervision
) m ) m
...@@ -332,7 +332,7 @@ class AnalysisService: ...@@ -332,7 +332,7 @@ class AnalysisService:
WHERE m.merchant_name IN ({placeholders}) WHERE m.merchant_name IN ({placeholders})
""" """
params = [start_date, end_date, AnalysisService.FIRST_BRAND_ID] + list(store_names) params = [start_date, end_date] + list(store_names)
# 打印实际执行的SQL(用于调试) # 打印实际执行的SQL(用于调试)
_debug_sql = sql _debug_sql = sql
...@@ -582,16 +582,16 @@ class AnalysisService: ...@@ -582,16 +582,16 @@ class AnalysisService:
@staticmethod @staticmethod
def _process_one_sheet(ws, store_subset, factory_sheets, start_date, end_date, def _process_one_sheet(ws, store_subset, factory_sheets, start_date, end_date,
formula_map, skip_external_cols): formula_map, skip_external_cols, start_row=4):
"""对单张sheet写入数据:查DB → 写数据行""" """对单张sheet写入数据:查DB → 写数据行,返回下一个可用行号"""
store_names = [str(n) for n in store_subset["门店名"].tolist() if pd.notna(n)] store_names = [str(n) for n in store_subset["门店名"].tolist() if pd.notna(n)]
if not store_names: if not store_names:
logger.info("No stores for this sheet, skipping DB query") logger.info("No stores for this sheet, skipping DB query")
return return start_row
db_perf = AnalysisService._query_store_performance(store_names, start_date, end_date) db_perf = AnalysisService._query_store_performance(store_names, start_date, end_date)
logger.info(f"DB fetched {len(db_perf)} stores ({start_date} ~ {end_date})") logger.info(f"DB fetched {len(db_perf)} stores ({start_date} ~ {end_date})")
AnalysisService._write_data_rows(ws, store_subset, factory_sheets, db_perf, return AnalysisService._write_data_rows(ws, store_subset, factory_sheets, db_perf,
start_date, end_date, formula_map, skip_external_cols) start_date, end_date, formula_map, skip_external_cols, start_row)
@staticmethod @staticmethod
def build_report(store_df: pd.DataFrame, def build_report(store_df: pd.DataFrame,
...@@ -601,9 +601,10 @@ class AnalysisService: ...@@ -601,9 +601,10 @@ class AnalysisService:
""" """
构建生态系数分析报表。 构建生态系数分析报表。
从模板文件读取"模板"sheet,复制出两份: 从模板文件读取"模板"sheet,复制一份后在同一个sheet中填充:
- Sheet1: 生态数据 — 兜底截止日期为"25日"的门店,使用生态主机厂数据 - 上部: 生态数据 — 兜底截止日期为"25日"的门店,使用生态主机厂数据
- Sheet2: 自然月 — 兜底截止日期不是"25日"的门店,使用自然月主机厂数据 - 中部: 标色隔离行
- 下部: 自然月 — 兜底截止日期不是"25日"的门店,使用自然月主机厂数据
""" """
import shutil import shutil
...@@ -618,13 +619,16 @@ class AnalysisService: ...@@ -618,13 +619,16 @@ class AnalysisService:
if nature_factory is None: if nature_factory is None:
nature_factory = {} nature_factory = {}
ecology_sheet_name = f"生态数据({ecology_start}~{ecology_end})" if ecology_start and ecology_end else "生态数据" # sheet名: 数据截止+最大日期
nature_sheet_name = f"自然月({nature_start}~{nature_end})" if nature_start and nature_end else "自然月" ref_date = max(d for d in [ecology_end, nature_end] if d) if (ecology_end or nature_end) else ""
sheet_name = f"数据截止{ref_date}" if ref_date else "生态系数分析"
output_dir = "temp_uploads" output_dir = "temp_uploads"
os.makedirs(output_dir, exist_ok=True) os.makedirs(output_dir, exist_ok=True)
safe_label = (ecology_sheet_name + "_" + nature_sheet_name).replace(" ", "").replace("~", "-")[:70] eco_label = ecology_start.replace("-", "") if ecology_start else ""
nat_label = nature_start.replace("-", "") if nature_start else ""
safe_label = f"生态{eco_label}_自然{nat_label}"[:70]
output_path = os.path.join(output_dir, f"问界生态系数分析_{safe_label}.xlsx") output_path = os.path.join(output_dir, f"问界生态系数分析_{safe_label}.xlsx")
shutil.copy2(TEMPLATE_FILE, output_path) shutil.copy2(TEMPLATE_FILE, output_path)
...@@ -635,59 +639,94 @@ class AnalysisService: ...@@ -635,59 +639,94 @@ class AnalysisService:
formula_map, skip_external_cols = AnalysisService._extract_formulas_from_template(ws_template) formula_map, skip_external_cols = AnalysisService._extract_formulas_from_template(ws_template)
# openpyxl 的 copy_worksheet 不复制条件格式,需手动保存 # openpyxl 的 copy_worksheet 不复制条件格式,需手动保存
# 注意: cf.sqref 是 MultiCellRange 对象,需转字符串;cf.rules 的 rule 对象需 copy 避免引用冲突
from copy import copy as shallow_copy from copy import copy as shallow_copy
cf_rules = [(str(cf.sqref), [shallow_copy(r) for r in cf.rules]) for cf in ws_template.conditional_formatting] cf_rules = [(str(cf.sqref), [shallow_copy(r) for r in cf.rules]) for cf in ws_template.conditional_formatting]
# 复制两份"模板"sheet # 复制一份模板sheet
ws_ecology = wb.copy_worksheet(ws_template) ws = wb.copy_worksheet(ws_template)
ws_nature = wb.copy_worksheet(ws_template) ws.title = sheet_name
ws_ecology.title = ecology_sheet_name
ws_nature.title = nature_sheet_name
# 保留原始"模板"sheet(隐藏) # 保留原始"模板"sheet(隐藏)
ws_template.sheet_state = 'hidden' ws_template.sheet_state = 'hidden'
# 将条件格式逐条复制到两个新 sheet # 将条件格式复制到新sheet
for sqref, rules in cf_rules: for sqref, rules in cf_rules:
for rule in rules: for rule in rules:
ws_ecology.conditional_formatting.add(sqref, rule) ws.conditional_formatting.add(sqref, rule)
ws_nature.conditional_formatting.add(sqref, rule) logger.info(f"Copied {len(cf_rules)} conditional formatting rules")
logger.info(f"Copied {len(cf_rules)} conditional formatting rules to both sheets")
# 清除数据行(保留表头1-3行) # 清除数据行(保留表头1-3行)
AnalysisService._clear_sheet_data(ws_ecology) AnalysisService._clear_sheet_data(ws)
AnalysisService._clear_sheet_data(ws_nature)
# 第3行(表头行)开启自动筛选
ws.auto_filter.ref = f"A3:BA3"
logger.info(f"Created sheets: '{ecology_sheet_name}' and '{nature_sheet_name}' from '{TEMPLATE_SHEET}'") logger.info(f"Created sheet: '{sheet_name}' from '{TEMPLATE_SHEET}'")
# 按兜底截止日期分组门店:25日→生态,其余→自然月 # 按兜底截止日期分组门店:25日→生态,其余→自然月
ecology_mask = store_df["兜底截止日期"].apply(AnalysisService._is_ecology_deadline) ecology_mask = store_df["兜底截止日期"].apply(AnalysisService._is_ecology_deadline)
ecology_stores = store_df[ecology_mask] ecology_stores = store_df[ecology_mask]
nature_stores = store_df[~ecology_mask] nature_stores = store_df[~ecology_mask]
has_ecology = len(ecology_stores) > 0 and ecology_factory
has_nature = len(nature_stores) > 0 and nature_factory
logger.info(f"Store split: ecology={len(ecology_stores)} (兜底=25日), " logger.info(f"Store split: ecology={len(ecology_stores)} (兜底=25日), "
f"nature={len(nature_stores)} (兜底≠25日), " f"nature={len(nature_stores)} (兜底≠25日), "
f"eco_factory={bool(ecology_factory)}, nat_factory={bool(nature_factory)}, " f"eco_factory={bool(ecology_factory)}, nat_factory={bool(nature_factory)}, "
f"eco_range={ecology_start}~{ecology_end}, nat_range={nature_start}~{nature_end}") f"eco_range={ecology_start}~{ecology_end}, nat_range={nature_start}~{nature_end}")
# 处理生态数据sheet # 通用分隔行样式
if len(ecology_stores) > 0 and ecology_factory: SEPARATOR_FILL = PatternFill(start_color="4472C4", end_color="4472C4", fill_type="solid")
AnalysisService._process_one_sheet( SEPARATOR_FONT = Font(name="微软雅黑", size=11, bold=True, color="FFFFFF")
ws_ecology, ecology_stores, ecology_factory,
ecology_start, ecology_end, formula_map, skip_external_cols) def _write_separator(ws, row, label_text):
"""写入一行分隔标签(不合并单元格,文字放中间列居中显示)"""
for col in range(1, 54):
cell = ws.cell(row=row, column=col)
cell.fill = SEPARATOR_FILL
cell.border = THIN_BORDER
cell.alignment = Alignment(horizontal="center", vertical="center")
# 标签文字放在中间列(约27列),视觉上居中
ws.cell(row=row, column=27).value = label_text
ws.cell(row=row, column=27).font = SEPARATOR_FONT
ws.row_dimensions[row].height = 24
next_row = 4
# 生态数据标签行
eco_label_text = f"▲ 生态数据({ecology_start} ~ {ecology_end})" if ecology_start and ecology_end else "▲ 生态数据"
if has_ecology:
_write_separator(ws, next_row, eco_label_text)
next_row += 1
# 处理生态数据(上部)
if has_ecology:
next_row = AnalysisService._process_one_sheet(
ws, ecology_stores, ecology_factory,
ecology_start, ecology_end, formula_map, skip_external_cols, start_row=next_row)
else: else:
reason = "no stores" if len(ecology_stores) == 0 else "no factory data" reason = "no stores" if len(ecology_stores) == 0 else "no factory data"
logger.info(f"Skipping ecology sheet ({reason})") logger.info(f"Skipping ecology section ({reason})")
# 处理自然月sheet # 自然月数据标签行(中间隔离行)
if len(nature_stores) > 0 and nature_factory: nat_label_text = f"▼ 自然月数据({nature_start} ~ {nature_end})" if nature_start and nature_end else "▼ 自然月数据"
AnalysisService._process_one_sheet( if has_ecology and has_nature:
ws_nature, nature_stores, nature_factory, _write_separator(ws, next_row, nat_label_text)
nature_start, nature_end, formula_map, skip_external_cols) next_row += 1
# 处理自然月数据(下部)
if has_nature:
# 如果仅自然月(无生态数据),在顶部也加标签
if not has_ecology:
_write_separator(ws, next_row, nat_label_text)
next_row += 1
next_row = AnalysisService._process_one_sheet(
ws, nature_stores, nature_factory,
nature_start, nature_end, formula_map, skip_external_cols, start_row=next_row)
else: else:
reason = "no stores" if len(nature_stores) == 0 else "no factory data" reason = "no stores" if len(nature_stores) == 0 else "no factory data"
logger.info(f"Skipping nature sheet ({reason})") logger.info(f"Skipping nature section ({reason})")
wb.save(output_path) wb.save(output_path)
logger.info(f"Report generated: {output_path}") logger.info(f"Report generated: {output_path}")
...@@ -732,13 +771,14 @@ class AnalysisService: ...@@ -732,13 +771,14 @@ class AnalysisService:
@staticmethod @staticmethod
def _write_data_rows(ws, store_df, factory_sheets, db_perf: dict = None, def _write_data_rows(ws, store_df, factory_sheets, db_perf: dict = None,
start_date: str = None, end_date: str = None, start_date: str = None, end_date: str = None,
formula_map: dict = None, skip_external_cols: set = None): formula_map: dict = None, skip_external_cols: set = None, start_row=4):
"""写入数据行到模板,从第4行开始 """写入数据行到模板,返回下一个可用行号
Args: Args:
db_perf: 从数据库查询的门店产值数据 db_perf: 从数据库查询的门店产值数据
start_date/end_date: 查询日期范围 start_date/end_date: 查询日期范围
formula_map: 模板第4行的公式映射 {col: formula_text},有公式的列直接写入公式 formula_map: 模板第4行的公式映射 {col: formula_text},有公式的列直接写入公式
skip_external_cols: 跳过公式写入的列(外部引用),使用Python计算值替代 skip_external_cols: 跳过公式写入的列(外部引用),使用Python计算值替代
start_row: 起始行号,默认4
""" """
if db_perf is None: if db_perf is None:
db_perf = {} db_perf = {}
...@@ -788,7 +828,7 @@ class AnalysisService: ...@@ -788,7 +828,7 @@ class AnalysisService:
cell.number_format = '0' cell.number_format = '0'
return cell return cell
row_num = 4 row_num = start_row
for idx, store_row in merged.iterrows(): for idx, store_row in merged.iterrows():
store_name = store_row.get("门店名", "") store_name = store_row.get("门店名", "")
if pd.isna(store_name) or str(store_name).strip() == "": if pd.isna(store_name) or str(store_name).strip() == "":
...@@ -836,8 +876,11 @@ class AnalysisService: ...@@ -836,8 +876,11 @@ class AnalysisService:
# ========== 产值表数据 (P-Z) - 全部从数据库查询 ========== # ========== 产值表数据 (P-Z) - 全部从数据库查询 ==========
# P: 交付数2 (DB) — 已在上方提前获取 # P: 交付数2 (DB) — 已在上方提前获取
# Q: 触客数 (DB) # Q: 触客数 (DB),兜底类型=触客时限制不超过交付数2
customer_count = _safe_float(store_perf.get("touch", 0)) customer_count = _safe_float(store_perf.get("touch", 0))
baodi_type = str(store_row.get("兜底类型", "")).strip()
if baodi_type == "触客" and customer_count > delivery2:
customer_count = delivery2
# R: 触客率 (DB) # R: 触客率 (DB)
touch_rate = _safe_float(store_perf.get("touch_rate", 0.0)) touch_rate = _safe_float(store_perf.get("touch_rate", 0.0))
if touch_rate == 0.0 and customer_count > 0 and delivery2 > 0: if touch_rate == 0.0 and customer_count > 0 and delivery2 > 0:
...@@ -860,10 +903,10 @@ class AnalysisService: ...@@ -860,10 +903,10 @@ class AnalysisService:
# W-AJ (cols 23-36): 渗透率/达标系数/总分/采购差异/当前转化率 # W-AJ (cols 23-36): 渗透率/达标系数/总分/采购差异/当前转化率
# 0625模板中这些列均有公式,无需Python写值 # 0625模板中这些列均有公式,无需Python写值
# ========== 渗透率/达标系数/总分/采购差异/当前转化率 (W-AJ, cols 23-36) ========== # ========== 当前转化率2 计算(用于赔付逻辑)==========
# 这些列在0625模板中都有公式,不需要Python写值,但需要计算当前转化率用于赔付逻辑 # AH-AJ (cols 34-36): 模板公式计算,此处计算用于赔付算法
# 当前转化率2 (AH-AJ): 交付类型→S/K, 触客类型→S/Q # 交付类型→S/K, 触客类型→S/Q
baodi_type = str(store_row.get("兜底类型", "")).strip() # 注意: baodi_type 和 customer_count 已在上面提前定义
if baodi_type == "触客": if baodi_type == "触客":
base_for_rate = _safe_float(customer_count, 0) # Q base_for_rate = _safe_float(customer_count, 0) # Q
current_rate_yb = yb_orders / base_for_rate if base_for_rate > 0 else 0 current_rate_yb = yb_orders / base_for_rate if base_for_rate > 0 else 0
...@@ -890,8 +933,7 @@ class AnalysisService: ...@@ -890,8 +933,7 @@ class AnalysisService:
_style_cell(row_num, 39, target_battery) _style_cell(row_num, 39, target_battery)
# ========== 需达标订单数差额 (AO-AQ, cols 41-43) ========== # ========== 需达标订单数差额 (AO-AQ, cols 41-43) ==========
# 模板公式: =IFERROR(MAX(CEILING(IF(C="触客",Q,K)*AK-S,1),0),0) # 模板公式自动计算,此处仅计算 gap 值供后续赔付金额使用
# 多级赔付时取最高阈值(target_yb等)
gap_base = _safe_float(customer_count, 0) if baodi_type == "触客" else _safe_float(delivery, 0) gap_base = _safe_float(customer_count, 0) if baodi_type == "触客" else _safe_float(delivery, 0)
gap_yb = max(0, math.ceil(gap_base * target_yb - yb_orders)) if target_yb > 0 else 0 gap_yb = max(0, math.ceil(gap_base * target_yb - yb_orders)) if target_yb > 0 else 0
gap_axb = max(0, math.ceil(gap_base * target_axb - axb_orders)) if target_axb > 0 else 0 gap_axb = max(0, math.ceil(gap_base * target_axb - axb_orders)) if target_axb > 0 else 0
...@@ -912,12 +954,22 @@ class AnalysisService: ...@@ -912,12 +954,22 @@ class AnalysisService:
payout_axb = _calc_payout(coeff_axb, current_rate_axb, gap_axb) payout_axb = _calc_payout(coeff_axb, current_rate_axb, gap_axb)
payout_battery = _calc_payout(coeff_battery, current_rate_battery, gap_battery) payout_battery = _calc_payout(coeff_battery, current_rate_battery, gap_battery)
# 非直营门店不赔付
is_direct = str(store_perf.get("operation_mode", "")).strip() == "直营"
if not is_direct:
payout_yb = "/"
payout_axb = "/"
payout_battery = "/"
_style_cell(row_num, 44, payout_yb) _style_cell(row_num, 44, payout_yb)
_style_cell(row_num, 45, payout_axb) _style_cell(row_num, 45, payout_axb)
_style_cell(row_num, 46, payout_battery) _style_cell(row_num, 46, payout_battery)
# ========== 赔付总金额 (AV, col 48) ========== # ========== 赔付总金额 (AV, col 48) ==========
_style_cell(row_num, 48, round(payout_yb + payout_axb + payout_battery, 1)) if not is_direct:
_style_cell(row_num, 48, "/")
else:
_style_cell(row_num, 48, round(payout_yb + payout_axb + payout_battery, 1))
# ========== 兜底月份 (AW, col 49) ========== # ========== 兜底月份 (AW, col 49) ==========
_style_cell(row_num, 49, store_row.get("兜底截止日期", "")) _style_cell(row_num, 49, store_row.get("兜底截止日期", ""))
...@@ -950,4 +1002,8 @@ class AnalysisService: ...@@ -950,4 +1002,8 @@ class AnalysisService:
row_num += 1 row_num += 1
return row_num
...@@ -690,7 +690,7 @@ class ETLService: ...@@ -690,7 +690,7 @@ class ETLService:
SUM(IFNULL(delivery_count, 0)) AS delivery_count, SUM(IFNULL(delivery_count, 0)) AS delivery_count,
SUM(IFNULL(customer_loss_count, 0)) AS customer_loss_count SUM(IFNULL(customer_loss_count, 0)) AS customer_loss_count
FROM ods_merchant_daily_report_huawei FROM ods_merchant_daily_report_huawei
WHERE deleted_flag = 'N' WHERE deleted_flag = 'N'
GROUP BY merchant_id, report_date, scene_type, GROUP BY merchant_id, report_date, scene_type,
IFNULL(first_brand_id, 2365), IFNULL(first_brand_id, 2365),
IFNULL(NULLIF(brand_id, -1), 2695) IFNULL(NULLIF(brand_id, -1), 2695)
...@@ -756,7 +756,10 @@ class ETLService: ...@@ -756,7 +756,10 @@ class ETLService:
""" """
# ========== SQL2: 订单数据写入(仅更新订单列 + 不存在时插入新行)========== # ========== SQL2: 订单数据写入(仅更新订单列 + 不存在时插入新行)==========
sql2 = f""" # 通过 ods_goods_order_customer 获取订单对应的品牌(子品牌),
# 与 ods_merchant_brand_model 直接关联,避免 MAX(child_id) 导致品牌归属错误
order_filter = f"AND DATE(go.install_upgrade_time) BETWEEN '{start}' AND '{end}'" if start and end else ""
sql2: str = f"""
INSERT INTO dws_merchant_daily_wide ( INSERT INTO dws_merchant_daily_wide (
report_date, merchant_id, merchant_name, store_code, report_date, merchant_id, merchant_name, store_code,
province_id, province_name, city_name, region, channel_type, province_id, province_name, city_name, region, channel_type,
...@@ -780,7 +783,7 @@ class ETLService: ...@@ -780,7 +783,7 @@ class ETLService:
os.scene_type, os.scene_type,
IFNULL(bm.brand_id, 2365) AS first_brand_id, IFNULL(bm.brand_id, 2365) AS first_brand_id,
IFNULL(bm.brand_name, '鸿蒙智行') AS first_brand_name, IFNULL(bm.brand_name, '鸿蒙智行') AS first_brand_name,
IFNULL(bm.child_id, 2695) AS brand_id, IFNULL(os.car_childs_brand_id, 2695) AS brand_id,
IFNULL(bm.child_name, '问界') AS brand_name, IFNULL(bm.child_name, '问界') AS brand_name,
0 AS delivery_count, 0 AS delivery_count,
0 AS customer_loss_count, 0 AS customer_loss_count,
...@@ -805,6 +808,8 @@ class ETLService: ...@@ -805,6 +808,8 @@ class ETLService:
go.merchant_id, go.merchant_id,
DATE(go.install_upgrade_time) AS report_date, DATE(go.install_upgrade_time) AS report_date,
go.scene_type, go.scene_type,
goc.car_brand_id,
goc.car_childs_brand_id,
SUM(CASE WHEN (gso.upgrade_goods_type = 178 SUM(CASE WHEN (gso.upgrade_goods_type = 178
OR gso.upgrade_secondary_goods_type = 178 OR gso.upgrade_secondary_goods_type = 178
OR gso.upgrade_third_level_goods_type = 178) THEN 1 ELSE 0 END) AS yb_cnt, OR gso.upgrade_third_level_goods_type = 178) THEN 1 ELSE 0 END) AS yb_cnt,
...@@ -826,25 +831,23 @@ class ETLService: ...@@ -826,25 +831,23 @@ class ETLService:
ON go.order_code = gso.order_code ON go.order_code = gso.order_code
AND gso.deleted_flag = 'N' AND gso.deleted_flag = 'N'
AND gso.status = 1 AND gso.status = 1
INNER JOIN ods_goods_order_customer goc
ON go.order_code = goc.order_code
WHERE go.deleted_flag = 'N' WHERE go.deleted_flag = 'N'
AND go.status IN (4, 6, 12) AND go.status IN (4, 6, 12)
AND (gso.upgrade_goods_type IN (178, 184, 180, 187) AND (gso.upgrade_goods_type IN (178, 184, 180, 187)
OR gso.upgrade_secondary_goods_type IN (178, 184, 180, 187) OR gso.upgrade_secondary_goods_type IN (178, 184, 180, 187)
OR gso.upgrade_third_level_goods_type IN (178, 184, 180, 187)) OR gso.upgrade_third_level_goods_type IN (178, 184, 180, 187))
GROUP BY go.merchant_id, DATE(go.install_upgrade_time), go.scene_type {order_filter}
GROUP BY go.merchant_id, DATE(go.install_upgrade_time), go.scene_type,
goc.car_brand_id, goc.car_childs_brand_id
) os ) os
LEFT JOIN ods_service_merchant sm LEFT JOIN ods_service_merchant sm
ON os.merchant_id = sm.merchant_id AND sm.deleted_flag = 'N' ON os.merchant_id = sm.merchant_id AND sm.deleted_flag = 'N'
LEFT JOIN ( LEFT JOIN ods_merchant_brand_model bm
SELECT merchant_id, ON os.merchant_id = bm.merchant_id
MAX(brand_id) AS brand_id, AND bm.deleted_flag = 'N'
MAX(brand_name) AS brand_name, AND os.car_childs_brand_id = bm.child_id
MAX(child_id) AS child_id,
MAX(child_name) AS child_name
FROM ods_merchant_brand_model
WHERE deleted_flag = 'N'
GROUP BY merchant_id
) bm ON os.merchant_id = bm.merchant_id
LEFT JOIN ( LEFT JOIN (
SELECT merchant_id, SELECT merchant_id,
GROUP_CONCAT(DISTINCT director_name SEPARATOR '/') AS director_name GROUP_CONCAT(DISTINCT director_name SEPARATOR '/') AS director_name
...@@ -866,7 +869,7 @@ class ETLService: ...@@ -866,7 +869,7 @@ class ETLService:
WHERE director_type IN (13, 6) AND deleted_flag = 'N' WHERE director_type IN (13, 6) AND deleted_flag = 'N'
GROUP BY merchant_id GROUP BY merchant_id
) dir_flight ON os.merchant_id = dir_flight.merchant_id ) dir_flight ON os.merchant_id = dir_flight.merchant_id
{filter_str.replace('drv.', 'os.')} WHERE 1=1 {filter_str.replace('drv.', 'os.')}
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
sum_extended_warranty = VALUES(sum_extended_warranty), sum_extended_warranty = VALUES(sum_extended_warranty),
sum_tire_warranty = VALUES(sum_tire_warranty), sum_tire_warranty = VALUES(sum_tire_warranty),
......
...@@ -52,59 +52,59 @@ header { ...@@ -52,59 +52,59 @@ header {
background-color: #34495e; background-color: #34495e;
} }
/* 主体内容布局 */ /* 下拉菜单样式 */
main { .nav-dropdown {
display: flex; position: relative;
flex: 1;
overflow: hidden;
} }
/* 左侧明细导航栏 */ .nav-dropdown-menu {
aside { display: none;
width: 240px; position: absolute;
background-color: white; top: 100%;
border-right: 1px solid #ddd; left: 0;
display: flex; min-width: 180px;
flex-direction: column; background-color: #fff;
overflow-y: auto; border-radius: 4px;
} box-shadow: 0 4px 12px rgba(0,0,0,0.15);
padding: 4px 0;
.menu-group { z-index: 200;
padding: 15px 0; list-style: none;
} }
.menu-title { .nav-dropdown-menu.show {
padding: 0 20px 10px; display: block;
font-size: 12px;
color: #999;
text-transform: uppercase;
letter-spacing: 1px;
} }
.menu-item { .nav-sub-item {
padding: 12px 20px; padding: 10px 20px;
cursor: pointer; cursor: pointer;
color: #333; color: #333;
transition: all 0.3s; font-size: 14px;
white-space: nowrap;
transition: all 0.2s;
} }
.menu-item:hover { .nav-sub-item:hover {
background-color: #f0f2f5; background-color: #f0f2f5;
color: #3498db; color: #1890ff;
} }
.menu-item.active { .nav-sub-item.active-sub {
background-color: #e6f7ff; background-color: #e6f7ff;
color: #1890ff; color: #1890ff;
border-right: 3px solid #1890ff;
} }
/* 右侧内容展示区 */ /* 主体内容布局(全宽,无侧边栏) */
#content-area { main {
flex: 1; flex: 1;
overflow: auto;
}
/* 全宽内容展示区 */
#content-area {
padding: 20px; padding: 20px;
overflow-y: auto;
background-color: #f9f9f9; background-color: #f9f9f9;
min-height: 100%;
} }
.card { .card {
......
...@@ -7,56 +7,76 @@ ...@@ -7,56 +7,76 @@
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
console.log('问界门店运营数据分析平台加载成功'); console.log('问界门店运营数据分析平台加载成功');
// 导航项点击事件 // ====================================================================
const navItems = document.querySelectorAll('.nav-item'); // 顶部导航下拉菜单逻辑
// ====================================================================
const navDropdowns = document.querySelectorAll('.nav-dropdown');
navDropdowns.forEach(dropdown => {
const label = dropdown.querySelector('.nav-dropdown-label');
const menu = dropdown.querySelector('.nav-dropdown-menu');
if (label) {
label.addEventListener('click', (e) => {
e.stopPropagation();
// 关闭其他下拉
document.querySelectorAll('.nav-dropdown-menu.show').forEach(m => {
if (m !== menu) m.classList.remove('show');
});
menu.classList.toggle('show');
});
}
});
// 点击页面其他地方关闭下拉菜单
document.addEventListener('click', () => {
document.querySelectorAll('.nav-dropdown-menu.show').forEach(m => m.classList.remove('show'));
});
// ====================================================================
// 下拉子菜单项点击事件(替代原侧边栏)
// ====================================================================
const contentTitle = document.querySelector('#content-title'); const contentTitle = document.querySelector('#content-title');
navItems.forEach(item => { document.querySelectorAll('.nav-sub-item').forEach(subItem => {
item.addEventListener('click', () => { subItem.addEventListener('click', (e) => {
// 切换顶部导航激活状态 e.stopPropagation();
navItems.forEach(i => i.classList.remove('active')); const section = subItem.getAttribute('data-section');
item.classList.add('active');
const module = item.getAttribute('data-module'); // 关闭下拉菜单
showSidebarMenu(module); document.querySelectorAll('.nav-dropdown-menu.show').forEach(m => m.classList.remove('show'));
// 更新标题
contentTitle.textContent = item.textContent;
if (module === 'upload') { // 高亮父级 nav-dropdown
showUploadPage(); const parentDropdown = subItem.closest('.nav-dropdown');
} else if (module === 'task') { if (parentDropdown) {
loadOdsSyncPage(); navDropdowns.forEach(d => d.classList.remove('active'));
} else if (module === 'analysis') { parentDropdown.classList.add('active');
showAnalysisPage();
} }
});
});
// 侧边栏点击事件 // 高亮当前子项
document.addEventListener('click', (e) => { document.querySelectorAll('.nav-sub-item').forEach(s => s.classList.remove('active-sub'));
if (e.target.classList.contains('menu-item')) { subItem.classList.add('active-sub');
const menuItems = document.querySelectorAll('.menu-item');
menuItems.forEach(i => i.classList.remove('active')); // 根据 section 切换内容
e.target.classList.add('active'); if (section === 'ods') {
const menuText = e.target.textContent.trim();
console.log('切换功能点:', menuText);
if (menuText === 'ODS 同步任务') {
loadOdsSyncPage(); loadOdsSyncPage();
} else if (menuText === 'DWS/DWM/DWA 任务') { } else if (section === 'dw') {
loadDwProcessPage(); loadDwProcessPage();
} else if (menuText === '数据上传' || menuText === '手动上传数据') { } else if (section === 'upload') {
showUploadPage(); showUploadPage();
} else if (section === 'analysis-modal') {
showAnalysisPage();
} else { } else {
hideAllSections(); hideAllSections();
document.getElementById('welcome-message').style.display = 'block'; document.getElementById('welcome-message').style.display = 'block';
document.getElementById('content-title').textContent = menuText; contentTitle.textContent = subItem.textContent.trim();
} }
} });
}); });
// ====================================================================
// 通用工具:隐藏所有内容区块
// ====================================================================
function hideAllSections() { function hideAllSections() {
document.getElementById('task-config-section').style.display = 'none'; document.getElementById('task-config-section').style.display = 'none';
document.getElementById('dw-process-section').style.display = 'none'; document.getElementById('dw-process-section').style.display = 'none';
...@@ -68,15 +88,17 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -68,15 +88,17 @@ document.addEventListener('DOMContentLoaded', () => {
document.getElementById('welcome-message').style.display = 'none'; document.getElementById('welcome-message').style.display = 'none';
} }
// --- ODS 页面逻辑 --- // ====================================================================
// ODS 页面逻辑
// ====================================================================
async function loadOdsSyncPage() { async function loadOdsSyncPage() {
hideAllSections(); hideAllSections();
document.getElementById('task-config-section').style.display = 'block'; document.getElementById('task-config-section').style.display = 'block';
document.getElementById('task-history-section').style.display = 'block'; document.getElementById('task-history-section').style.display = 'block';
document.getElementById('content-title').textContent = 'ODS 同步任务'; contentTitle.textContent = 'ODS 同步任务';
try { try {
const configRes = await fetch('/api/etl/scheduler-config?task_id=sync_ods_data'); const configRes = await fetch('api/etl/scheduler-config?task_id=sync_ods_data');
const config = await configRes.json(); const config = await configRes.json();
document.getElementById('conf-task-id').textContent = config.task_id || '-'; document.getElementById('conf-task-id').textContent = config.task_id || '-';
document.getElementById('conf-status').textContent = config.status || '-'; document.getElementById('conf-status').textContent = config.status || '-';
...@@ -89,12 +111,14 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -89,12 +111,14 @@ document.addEventListener('DOMContentLoaded', () => {
refreshHistory('ods'); refreshHistory('ods');
} }
// --- DW 加工页面逻辑 --- // ====================================================================
// DW 加工页面逻辑
// ====================================================================
function loadDwProcessPage() { function loadDwProcessPage() {
hideAllSections(); hideAllSections();
document.getElementById('dw-process-section').style.display = 'block'; document.getElementById('dw-process-section').style.display = 'block';
document.getElementById('task-history-section').style.display = 'block'; document.getElementById('task-history-section').style.display = 'block';
document.getElementById('content-title').textContent = 'DWS/DWM/DWA 加工任务'; contentTitle.textContent = 'DWS/DWM/DWA 加工任务';
refreshHistory('dw'); refreshHistory('dw');
// 初始化默认日期: 上月26号 至 今天 // 初始化默认日期: 上月26号 至 今天
...@@ -109,27 +133,27 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -109,27 +133,27 @@ document.addEventListener('DOMContentLoaded', () => {
if (endInput && !endInput.value) endInput.value = todayStr; if (endInput && !endInput.value) endInput.value = todayStr;
} }
// --- 任务历史刷新与轮询 --- // ====================================================================
// 任务历史刷新与轮询
// ====================================================================
let pollingTimer = null; let pollingTimer = null;
let currentHistoryType = 'ods'; // 'ods' or 'dw' let currentHistoryType = 'ods'; // 'ods' or 'dw'
let historyCache = {}; // 缓存历史记录详情,避免转义字符破坏 HTML let historyCache = {}; // 缓存历史记录详情
async function refreshHistory(type) { async function refreshHistory(type) {
if (type) currentHistoryType = type; if (type) currentHistoryType = type;
try { try {
const historyRes = await fetch(`/api/etl/history?limit=15`); const historyRes = await fetch('api/etl/history?limit=15');
const history = await historyRes.json(); const history = await historyRes.json();
const tbody = document.getElementById('history-tbody'); const tbody = document.getElementById('history-tbody');
tbody.innerHTML = ''; tbody.innerHTML = '';
let hasRunning = false; let hasRunning = false;
history.forEach(item => { history.forEach(item => {
// 简单的过滤逻辑
if (currentHistoryType === 'ods' && !item.task_id.includes('ods')) return; if (currentHistoryType === 'ods' && !item.task_id.includes('ods')) return;
if (currentHistoryType === 'dw' && !item.task_id.includes('sync')) return; if (currentHistoryType === 'dw' && !item.task_id.includes('sync')) return;
// 存入缓存
historyCache[item.id] = item.result_info; historyCache[item.id] = item.result_info;
if (item.status === 'running') hasRunning = true; if (item.status === 'running') hasRunning = true;
...@@ -169,14 +193,16 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -169,14 +193,16 @@ document.addEventListener('DOMContentLoaded', () => {
}, 3000); }, 3000);
} }
// --- 按钮点击事件 --- // ====================================================================
// 按钮点击事件
// ====================================================================
document.getElementById('btn-run-ods').addEventListener('click', async () => { document.getElementById('btn-run-ods').addEventListener('click', async () => {
const btn = document.getElementById('btn-run-ods'); const btn = document.getElementById('btn-run-ods');
btn.disabled = true; btn.disabled = true;
btn.textContent = '任务已启动...'; btn.textContent = '任务已启动...';
try { try {
const res = await fetch('/api/etl/run-ods', { method: 'POST' }); const res = await fetch('api/etl/run-ods', { method: 'POST' });
const data = await res.json(); const data = await res.json();
if (data.status === 'success') { if (data.status === 'success') {
setTimeout(() => { btn.disabled = false; btn.textContent = '立即同步 ODS'; }, 2000); setTimeout(() => { btn.disabled = false; btn.textContent = '立即同步 ODS'; }, 2000);
...@@ -202,21 +228,18 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -202,21 +228,18 @@ document.addEventListener('DOMContentLoaded', () => {
formData.append('layer', layer); formData.append('layer', layer);
if (fullSync) { if (fullSync) {
// 明确全量覆盖
formData.append('full_sync', 'true'); formData.append('full_sync', 'true');
} else if (startDate && endDate) { } else if (startDate && endDate) {
// 指定了日期范围,按范围处理
formData.append('start_date', startDate); formData.append('start_date', startDate);
formData.append('end_date', endDate); formData.append('end_date', endDate);
} }
// 否则:默认增量同步,不传日期参数,后端自动用最近一天
const btn = document.getElementById('btn-run-dw'); const btn = document.getElementById('btn-run-dw');
btn.disabled = true; btn.disabled = true;
btn.textContent = '加工中...'; btn.textContent = '加工中...';
try { try {
const res = await fetch('/api/etl/run-dw', { method: 'POST', body: formData }); const res = await fetch('api/etl/run-dw', { method: 'POST', body: formData });
const data = await res.json(); const data = await res.json();
if (data.status === 'success') { if (data.status === 'success') {
setTimeout(() => { btn.disabled = false; btn.textContent = '开始加工'; }, 2000); setTimeout(() => { btn.disabled = false; btn.textContent = '开始加工'; }, 2000);
...@@ -232,14 +255,15 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -232,14 +255,15 @@ document.addEventListener('DOMContentLoaded', () => {
} }
}); });
// --- 数据上传逻辑 --- // ====================================================================
// 数据上传逻辑
// ====================================================================
function showUploadPage() { function showUploadPage() {
hideAllSections(); hideAllSections();
document.getElementById('data-upload-section').style.display = 'block'; document.getElementById('data-upload-section').style.display = 'block';
document.getElementById('content-title').textContent = '数据上传'; contentTitle.textContent = '数据上传';
} }
// 文件上传逻辑
const dropZone = document.getElementById('drop-zone'); const dropZone = document.getElementById('drop-zone');
const fileInput = document.getElementById('excel-file'); const fileInput = document.getElementById('excel-file');
const uploadModeSelect = document.getElementById('upload-mode-select'); const uploadModeSelect = document.getElementById('upload-mode-select');
...@@ -288,7 +312,7 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -288,7 +312,7 @@ document.addEventListener('DOMContentLoaded', () => {
document.getElementById('upload-status-tip').style.display = 'block'; document.getElementById('upload-status-tip').style.display = 'block';
try { try {
const res = await fetch('/api/data/upload', { method: 'POST', body: formData }); const res = await fetch('api/data/upload', { method: 'POST', body: formData });
const data = await res.json(); const data = await res.json();
if (data.status === 'success') { if (data.status === 'success') {
alert(data.message); alert(data.message);
...@@ -307,7 +331,9 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -307,7 +331,9 @@ document.addEventListener('DOMContentLoaded', () => {
}); });
} }
// --- 工具函数 --- // ====================================================================
// 工具函数
// ====================================================================
function calculateDuration(start, end) { function calculateDuration(start, end) {
const s = new Date(start); const s = new Date(start);
const e = new Date(end); const e = new Date(end);
...@@ -315,11 +341,6 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -315,11 +341,6 @@ document.addEventListener('DOMContentLoaded', () => {
return diff.toFixed(1) + 's'; return diff.toFixed(1) + 's';
} }
function showSidebarMenu(module) {
console.log('切换到模块:', module);
// 这里可以根据模块动态更新侧边栏内容
}
window.showTaskDetail = function(id) { window.showTaskDetail = function(id) {
const info = historyCache[id]; const info = historyCache[id];
if (!info || info === "null" || info === "") { if (!info || info === "null" || info === "") {
...@@ -333,7 +354,6 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -333,7 +354,6 @@ document.addEventListener('DOMContentLoaded', () => {
try { try {
const data = JSON.parse(info); const data = JSON.parse(info);
// 如果 data 是数组,渲染成表格
if (Array.isArray(data)) { if (Array.isArray(data)) {
data.forEach(item => { data.forEach(item => {
const tr = document.createElement('tr'); const tr = document.createElement('tr');
...@@ -351,7 +371,6 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -351,7 +371,6 @@ document.addEventListener('DOMContentLoaded', () => {
tbody.appendChild(tr); tbody.appendChild(tr);
}); });
} else { } else {
// 如果是普通 JSON 对象,展示在第一行
const tr = document.createElement('tr'); const tr = document.createElement('tr');
tr.innerHTML = `<td colspan="4"><pre style="white-space: pre-wrap;">${JSON.stringify(data, null, 2)}</pre></td>`; tr.innerHTML = `<td colspan="4"><pre style="white-space: pre-wrap;">${JSON.stringify(data, null, 2)}</pre></td>`;
tbody.appendChild(tr); tbody.appendChild(tr);
...@@ -359,7 +378,6 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -359,7 +378,6 @@ document.addEventListener('DOMContentLoaded', () => {
modal.style.display = 'block'; modal.style.display = 'block';
} catch(e) { } catch(e) {
// 解析失败则展示原始文本
tbody.innerHTML = `<tr><td colspan="4">${info}</td></tr>`; tbody.innerHTML = `<tr><td colspan="4">${info}</td></tr>`;
modal.style.display = 'block'; modal.style.display = 'block';
} }
...@@ -377,11 +395,13 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -377,11 +395,13 @@ document.addEventListener('DOMContentLoaded', () => {
} }
}; };
// ==================== 数据分析页面逻辑 ==================== // ====================================================================
// 数据分析页面逻辑
// ====================================================================
function showAnalysisPage() { function showAnalysisPage() {
hideAllSections(); hideAllSections();
document.getElementById('data-analysis-section').style.display = 'block'; document.getElementById('data-analysis-section').style.display = 'block';
document.getElementById('content-title').textContent = '数据分析'; contentTitle.textContent = '模板分析';
// 初始化默认日期: 上月26号 ~ 今天 // 初始化默认日期: 上月26号 ~ 今天
const fmt = d => `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')}`; const fmt = d => `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')}`;
...@@ -475,7 +495,7 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -475,7 +495,7 @@ document.addEventListener('DOMContentLoaded', () => {
if (hasEcology) uploadForm.append('ecology_factory_file', ecologyFactoryInput.files[0]); if (hasEcology) uploadForm.append('ecology_factory_file', ecologyFactoryInput.files[0]);
if (hasNature) uploadForm.append('nature_factory_file', natureFactoryInput.files[0]); if (hasNature) uploadForm.append('nature_factory_file', natureFactoryInput.files[0]);
const uploadRes = await fetch('/api/analysis/upload', { const uploadRes = await fetch('api/analysis/upload', {
method: 'POST', method: 'POST',
body: uploadForm body: uploadForm
}); });
...@@ -497,7 +517,7 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -497,7 +517,7 @@ document.addEventListener('DOMContentLoaded', () => {
if (natStart) genForm.append('nature_start_date', natStart); if (natStart) genForm.append('nature_start_date', natStart);
if (natEnd) genForm.append('nature_end_date', natEnd); if (natEnd) genForm.append('nature_end_date', natEnd);
const genRes = await fetch('/api/analysis/generate', { const genRes = await fetch('api/analysis/generate', {
method: 'POST', method: 'POST',
body: genForm body: genForm
}); });
...@@ -522,4 +542,13 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -522,4 +542,13 @@ document.addEventListener('DOMContentLoaded', () => {
} }
}); });
} }
// ====================================================================
// 默认加载:打开 ODS 同步任务页面
// ====================================================================
loadOdsSyncPage();
const defaultOds = document.querySelector('.nav-sub-item[data-section="ods"]');
if (defaultOds) {
defaultOds.classList.add('active-sub');
}
}); });
...@@ -9,30 +9,35 @@ ...@@ -9,30 +9,35 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>问界门店运营数据分析平台</title> <title>问界门店运营数据分析平台</title>
<link rel="stylesheet" href="/static/css/style.css"> <link rel="stylesheet" href="static/css/style.css">
</head> </head>
<body> <body>
<!-- 顶部导航栏 --> <!-- 顶部导航栏:所有入口集中在下拉菜单中 -->
<header> <header>
<div class="logo">问界运营分析平台</div> <div class="logo">问界运营分析平台</div>
<nav class="nav-links"> <nav class="nav-links">
<div class="nav-item active" data-module="task">任务调度</div> <!-- 任务调度下拉 -->
<div class="nav-item" data-module="analysis">数据分析</div> <div class="nav-item nav-dropdown" data-module="task">
<span class="nav-dropdown-label">任务调度 ▾</span>
<ul class="nav-dropdown-menu">
<li class="nav-sub-item" data-section="ods">ODS 同步任务</li>
<li class="nav-sub-item" data-section="dw">DWS/DWM/DWA 任务</li>
</ul>
</div>
<!-- 数据分析下拉 -->
<div class="nav-item nav-dropdown" data-module="analysis">
<span class="nav-dropdown-label">数据分析 ▾</span>
<ul class="nav-dropdown-menu">
<li class="nav-sub-item" data-section="upload">数据上传</li>
<li class="nav-sub-item" data-section="analysis-modal">模板分析</li>
</ul>
</div>
</nav> </nav>
<div class="user-info">管理员</div> <div class="user-info">管理员</div>
</header> </header>
<main> <main>
<!-- 左侧明细导航栏 --> <!-- 全宽内容展示区(左侧边栏已移除) -->
<aside id="sidebar">
<div class="menu-group">
<div class="menu-title">任务管理</div>
<div class="menu-item active">ODS 同步任务</div>
<div class="menu-item">DWS/DWM/DWA 任务</div>
</div>
</aside>
<!-- 右侧内容展示区 -->
<section id="content-area"> <section id="content-area">
<div class="card"> <div class="card">
<h2 id="content-title">任务调度</h2> <h2 id="content-title">任务调度</h2>
...@@ -152,7 +157,7 @@ ...@@ -152,7 +157,7 @@
</div> </div>
<div id="upload-status-tip" style="margin-top: 20px; display: none; padding: 15px; background: #e6f7ff; border: 1px solid #91d5ff; border-radius: 4px;"> <div id="upload-status-tip" style="margin-top: 20px; display: none; padding: 15px; background: #e6f7ff; border: 1px solid #91d5ff; border-radius: 4px;">
<span style="color: #1890ff;">ℹ️ 正在处理中,您可以前往“数据目录”查看已生成的表。</span> <span style="color: #1890ff;">ℹ️ 正在处理中,您可以前往"数据目录"查看已生成的表。</span>
</div> </div>
</div> </div>
...@@ -166,7 +171,7 @@ ...@@ -166,7 +171,7 @@
<input type="file" id="store-file-input" style="display:none;" accept=".xlsx,.xls"> <input type="file" id="store-file-input" style="display:none;" accept=".xlsx,.xls">
<div style="font-size:30px; margin-bottom:8px;">🏪</div> <div style="font-size:30px; margin-bottom:8px;">🏪</div>
<p id="store-file-name" style="margin:0; font-size:13px; color:#999;">点击选择门店列表文件</p> <p id="store-file-name" style="margin:0; font-size:13px; color:#999;">点击选择门店列表文件</p>
<a href="/api/analysis/template/store" style="font-size:12px; color:#1890ff; text-decoration:none; margin-top:8px; display:inline-block;"> <a href="api/analysis/template/store" style="font-size:12px; color:#1890ff; text-decoration:none; margin-top:8px; display:inline-block;">
📥 下载门店列表模板 📥 下载门店列表模板
</a> </a>
</div> </div>
...@@ -216,7 +221,7 @@ ...@@ -216,7 +221,7 @@
<div id="analysis-result" style="display:none; background: #f6ffed; border: 1px solid #b7eb8f; padding: 20px; border-radius: 8px; text-align: center;"> <div id="analysis-result" style="display:none; background: #f6ffed; border: 1px solid #b7eb8f; padding: 20px; border-radius: 8px; text-align: center;">
<h3 style="color:#52c41a; margin:0 0 10px;">✅ 报表生成成功</h3> <h3 style="color:#52c41a; margin:0 0 10px;">✅ 报表生成成功</h3>
<div id="analysis-result-info" style="font-size:13px; color:#666; margin-bottom:15px;"></div> <div id="analysis-result-info" style="font-size:13px; color:#666; margin-bottom:15px;"></div>
<a id="btn-download-report" href="/api/analysis/download" <a id="btn-download-report" href="api/analysis/download"
style="display:inline-block; padding: 10px 32px; background: #52c41a; color: white; border: none; border-radius: 4px; font-size: 14px; text-decoration: none; cursor: pointer;"> style="display:inline-block; padding: 10px 32px; background: #52c41a; color: white; border: none; border-radius: 4px; font-size: 14px; text-decoration: none; cursor: pointer;">
📥 下载分析报表 📥 下载分析报表
</a> </a>
...@@ -229,7 +234,7 @@ ...@@ -229,7 +234,7 @@
</div> </div>
<div id="welcome-message"> <div id="welcome-message">
<p>欢迎来到问界门店运营数据分析平台。请从左侧选择具体功能进行操作。</p> <p>欢迎来到问界门店运营数据分析平台。请从顶部导航选择功能进行操作。</p>
</div> </div>
</div> </div>
</div> </div>
...@@ -262,6 +267,6 @@ ...@@ -262,6 +267,6 @@
</div> </div>
</div> </div>
<script src="/static/js/app.js"></script> <script src="static/js/app.js"></script>
</body> </body>
</html> </html>
# 文件名: docker-compose.yml version: '3.8'
# 职责: 编排多容器服务,包括后端 API 服务和 MySQL 8 数据库服务。
# 注意: 不要删除这个注释。 services:
app:
build:
context: .
dockerfile: docker/Dockerfile
container_name: data-analyze-webui
ports:
- "9500:9500"
volumes:
- ./app/templates:/app/app/templates
- ./temp_uploads:/app/temp_uploads
env_file:
- .env
restart: unless-stopped
# 文件名: docker/Dockerfile FROM python:3.11-slim
# 职责: 定义后端应用容器镜像构建过程,安装 Python 环境及依赖。
# 注意: 不要删除这个注释。 WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 9500
CMD ["python", "main.py"]
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!