wip(stmate-test): 개발 중 저장 — 전역 깃 싱크(요구 686-2) · tools/stmate-test
This commit is contained in:
+41
-21
@@ -9,29 +9,20 @@ import zipfile
|
||||
from decimal import Decimal, ROUND_DOWN
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import Response
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from pydantic import BaseModel
|
||||
|
||||
try:
|
||||
from .smt_parser import (
|
||||
build_dbf_bytes,
|
||||
extract_costn_memos,
|
||||
load_stmate_catalog,
|
||||
parse_dbf_bytes,
|
||||
parse_prjlst_smt,
|
||||
rebuild_costn_with_smt,
|
||||
update_prjlst_smt_bytes,
|
||||
)
|
||||
except ImportError:
|
||||
from smt_parser import (
|
||||
build_dbf_bytes,
|
||||
extract_costn_memos,
|
||||
load_stmate_catalog,
|
||||
parse_dbf_bytes,
|
||||
parse_prjlst_smt,
|
||||
rebuild_costn_with_smt,
|
||||
update_prjlst_smt_bytes,
|
||||
)
|
||||
from excel_builder import build_stmate_full_xlsx
|
||||
from smt_parser import (
|
||||
build_dbf_bytes,
|
||||
extract_costn_memos,
|
||||
load_stmate_catalog,
|
||||
parse_dbf_bytes,
|
||||
parse_prjlst_smt,
|
||||
rebuild_costn_with_smt,
|
||||
update_prjlst_smt_bytes,
|
||||
)
|
||||
|
||||
HERE = pathlib.Path(__file__).resolve().parent
|
||||
REPO_ROOT = HERE.parent.parent
|
||||
@@ -664,9 +655,38 @@ def api_save(req: SaveDbfReq):
|
||||
}
|
||||
|
||||
|
||||
class ExportXlsxReq(BaseModel):
|
||||
prj_meta: dict = {}
|
||||
costn_rows: list = []
|
||||
boq_rows: list = []
|
||||
kanjub_data: dict = {}
|
||||
costn_memos: dict = {}
|
||||
recipes: list = []
|
||||
|
||||
|
||||
@app.post("/api/export-xlsx")
|
||||
def api_export_xlsx(req: ExportXlsxReq):
|
||||
try:
|
||||
xlsx_bytes = build_stmate_full_xlsx(
|
||||
req.prj_meta,
|
||||
req.costn_rows,
|
||||
req.boq_rows,
|
||||
req.kanjub_data,
|
||||
req.costn_memos,
|
||||
req.recipes,
|
||||
)
|
||||
return Response(
|
||||
content=xlsx_bytes,
|
||||
media_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
headers={"Content-Disposition": 'attachment; filename="STMATE_Workbook.xlsx"'},
|
||||
)
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
app.mount("/", StaticFiles(directory=str(HERE), html=True), name="static")
|
||||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
|
||||
uvicorn.run(app, host="127.0.0.1", port=8095)
|
||||
uvicorn.run(app, host="0.0.0.0", port=8095)
|
||||
|
||||
Reference in New Issue
Block a user