From 7fed66d58ce78c9588082b5b56069232a72fb45d Mon Sep 17 00:00:00 2001 From: Hermes CI Fix Date: Fri, 7 Aug 2026 18:26:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20import-excel-smart=E6=94=AF=E6=8C=81ent?= =?UTF-8?q?ity=5Fid=20+=20=E5=AF=BC=E5=85=A5=E5=8D=9A=E6=B5=B7=E7=A7=91?= =?UTF-8?q?=E7=9B=AE=E4=BD=99=E9=A2=9D=E8=A1=A8(320=E6=9D=A1/78KPI)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/api/data.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/app/api/data.py b/backend/app/api/data.py index ec0fc18b..7c589d6b 100644 --- a/backend/app/api/data.py +++ b/backend/app/api/data.py @@ -2,7 +2,7 @@ import pandas as pd import io, json, hashlib, re from datetime import datetime -from fastapi import APIRouter, Depends, HTTPException, Query, UploadFile, File +from fastapi import APIRouter, Depends, HTTPException, Query, UploadFile, File, Form from sqlalchemy.orm import Session from sqlalchemy import func from typing import Optional @@ -163,7 +163,11 @@ def _smart_detect_statement_type(filename: str) -> str | None: @router.post("/import-excel-smart") -async def import_excel_smart(file: UploadFile = File(...), db: Session = Depends(get_db)): +async def import_excel_smart( + file: UploadFile = File(...), + entity_id: int = Form(1), + db: Session = Depends(get_db), +): """智能导入 — BOT自动识别列名/期间/报表类型,无需手动映射""" content = await file.read() fname = file.filename or "未知文件" @@ -254,7 +258,7 @@ async def import_excel_smart(file: UploadFile = File(...), db: Session = Depends if not kpi_code: new_code = f"{stype_prefix}{len(kpis) + created_kpis + 1:03d}" new_kpi = KPIDefinition( - entity_id=1, + entity_id=entity_id, kpi_code=new_code, kpi_name=clean_name, dimension="finance",