- 지움: DataFlow/M02_DF_Round.ts(가져가는 곳 0) · _standard/금액단위표준.json · /df/standards 답의 money 칸(단위 고르기는 unit 만 씀) - M02_DF_Values: 흐름도 입력 값 길(values · one_value · materials · slot_price · group_find · standards_check 와 딸린 함수 · 550 → 62 줄) — 남김 = Item_Prices 가 쓰는 _pick · _group_rows · GROUP_RULE · MACHINE_SEP · HOURLY + standards - 시험: 옛 값 찾기만 보던 test_m02_df_values_old 지움 · 794-1b 표준 표 기대를 unit 만으로 - 검증: 빌더 --check 같음 · 핵심 시험 99 통과 · 관련 시험 182 + 3 통과 · typecheck 0 · 서버 로그 오류 0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
53 lines
2.1 KiB
Python
53 lines
2.1 KiB
Python
"""단위 표준 표 읽기 — `GET /api/m02/df/standards` → {unit, saved} · 기계 이름 `GET /machine-names`.
|
|
|
|
부르는 곳 = 단위 고르기(`M02_DF_UnitPick.ts`) · 금액 표준(`M02_DF_Round.ts`)은 걷음(894).
|
|
표 = `_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("/machine-off")
|
|
def get_machine_off() -> list[str]:
|
|
"""끈 기계 원문번호(842-2) — 그 번호 기계가 모두 「비활성」 · 옵션 고르기 목록에서 뺌(고른 값은 남김)."""
|
|
on, off = set(), set()
|
|
for data in store.loaded()[0].values():
|
|
if data.get("그룹") == "기계":
|
|
for row in data.get(store.items_key(data)) or []:
|
|
(off if row.get("비활성") else on).add(str(row.get("원문번호") or ""))
|
|
return sorted(off - on - {""})
|
|
|
|
|
|
@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
|