- 값(원문번호)은 그대로 · 글만 바꿈 — M02 사본 저장 · 로직 부름 · 엑셀 이음 그대로 - 서버 GET /api/m02/df/machine-names(로그인만) = 기계 원문번호 → 이름 규격 · 브라우저는 한 번 받아 둠 - 수식 탭 옵션(formula_doc_options) · 단가산출 상세 옵션(calc_sheet varRow) 같은 도우미 · M01 · M02 같이 - 목록이 모두 원문번호 꼴일 때만(빈 칸 뺌) · 문서 선택 목록 원문번호 전수 이름 있음 - test_804_10 셋 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
1.6 KiB
Python
42 lines
1.6 KiB
Python
"""단위 · 금액 표준 표 읽기 — `GET /api/m02/df/standards` → {unit, money, saved} · 기계 이름 `GET /machine-names`.
|
|
|
|
부르는 곳 = 단위 고르기(`M02_DF_UnitPick.ts`) · 끝수 표준(`M02_DF_Round.ts`).
|
|
표 = `_standard/` 파일(git 이 따라감) · 권한 = 로그인만(읽기만 · `main.py` 한 줄 · M02 줄 쌓기 단위 고르기).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from fastapi import APIRouter, HTTPException
|
|
|
|
from M01_MasterData import M01_MasterData_Store as store
|
|
from M01_MasterData.M01_MasterData_Router import _num
|
|
from M02_MasterTemplete.DataFlow import M02_DF_Values as dv
|
|
|
|
router = APIRouter(prefix="/api/m02/df", tags=["M02 DataFlow"])
|
|
|
|
STANDARD = Path(__file__).resolve().parent / "_standard"
|
|
|
|
|
|
@router.get("/machine-names")
|
|
def get_machine_names() -> dict:
|
|
"""기계 원문번호 → 「이름 규격」(요구 692-2) — 옵션 드롭다운 라벨만 · 값은 원문번호 그대로 · 겹친 번호는 첫 줄."""
|
|
out: dict[str, str] = {}
|
|
for data in store.loaded()[0].values():
|
|
if data.get("그룹") != "기계":
|
|
continue
|
|
for row in data.get(store.items_key(data)) or []:
|
|
code = str(row.get("원문번호") or "")
|
|
if code and code not in out:
|
|
out[code] = f"{row.get('이름') or ''} {row.get('규격') or ''}".strip()
|
|
return out
|
|
|
|
|
|
@router.get("/standards")
|
|
def get_standards() -> dict:
|
|
try:
|
|
return _num(dv.standards(STANDARD))
|
|
except store.StoreError as e:
|
|
raise HTTPException(status_code=e.status, detail=e.detail) from e
|