feat: import-excel-smart支持entity_id + 导入博海科目余额表(320条/78KPI)
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
import io, json, hashlib, re
|
import io, json, hashlib, re
|
||||||
from datetime import datetime
|
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.orm import Session
|
||||||
from sqlalchemy import func
|
from sqlalchemy import func
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
@@ -163,7 +163,11 @@ def _smart_detect_statement_type(filename: str) -> str | None:
|
|||||||
|
|
||||||
|
|
||||||
@router.post("/import-excel-smart")
|
@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自动识别列名/期间/报表类型,无需手动映射"""
|
"""智能导入 — BOT自动识别列名/期间/报表类型,无需手动映射"""
|
||||||
content = await file.read()
|
content = await file.read()
|
||||||
fname = file.filename or "未知文件"
|
fname = file.filename or "未知文件"
|
||||||
@@ -254,7 +258,7 @@ async def import_excel_smart(file: UploadFile = File(...), db: Session = Depends
|
|||||||
if not kpi_code:
|
if not kpi_code:
|
||||||
new_code = f"{stype_prefix}{len(kpis) + created_kpis + 1:03d}"
|
new_code = f"{stype_prefix}{len(kpis) + created_kpis + 1:03d}"
|
||||||
new_kpi = KPIDefinition(
|
new_kpi = KPIDefinition(
|
||||||
entity_id=1,
|
entity_id=entity_id,
|
||||||
kpi_code=new_code,
|
kpi_code=new_code,
|
||||||
kpi_name=clean_name,
|
kpi_name=clean_name,
|
||||||
dimension="finance",
|
dimension="finance",
|
||||||
|
|||||||
Reference in New Issue
Block a user