- 표지 = 수식 문서 머리 · 옛 로직 줄 칸 「부품」 — 기계경비식 9 · 작업량 틀 60(기종 = 기계표 상세구분 · 규격 열쇠) · 계수식 4 · 변환기가 옮김 · 틀 문서 9 장 - 지움 = 작업량당 기계경비 6(GC001145 · 1148 · 1151 · 1156 · 1159 · 1166 · 부르는 곳 0 · 요구 734-4 · 735-4) — 수식 문서 · 옛 로직 · 키대장 폐기 칸 · 빌더 · 변수표 - 이름 꼬리 4 = 원문 제목(지게운반 · 인력운반(기계설비) · 벽돌운반 · 수중펌프 설치 및 해체) · 키 폐기 0 - 서버 = `M01_MasterData_Parts` — M01 `/logics` · M02 `/logic-lib/logics` 목록에서 부품 뺌(1,440) · 키로 열기 · 부르기 그대로 · `/m01/parts`(기종 계산식 · 틀 · 계수식) · `/m02/logic-lib/machine-parts` · 연결 찾기 과녁에서 부품 뺌(1,444 → 1,435 · 판정 코드 그대로) - 금액 전후 = 문서 1,513 · 셈 9,626(기본 + 옵션 표본) 모두 같음 · 791_1 지문 남은 1,513 같음 → 지문 다시 뜸 · 802_2 변환 대조 1,513 · 목록 xlsx 다시 씀(요약 수) - 낡은 시험 = 1,519 · 1,518 기대 → 1,513 · GC001148 견본 → 같은 꼴 GF000089 토사깍기(기계)(블록 Q 39.293 · 합계 2,190) · 지운 6 을 셈하던 줄 걷음 · 목록 수 1,440 · 묶음 328 · 부르는 수 507 - 새 지킴 시험 test_813_2_parts Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
108 lines
4.4 KiB
Python
108 lines
4.4 KiB
Python
"""M02 담을 로직 읽기 API — `/api/m02/logic-lib/…`(로그인만).
|
|
|
|
⚠ 등록은 `main.py`(로그인만). 조합 목록 · 키 하나 · 통째 지우기 길은 없앰(732-1).
|
|
담을 로직 고르기 · 일위대가 입력 모달이 읽는 단가산출 로직(M01 길은 시스템 관리자 전용)은
|
|
`/api/m02/logic-lib/…` 읽기만(로그인) — 모양은 M01 길과 같음.
|
|
85-4 — 원문 패널 읽기(`/logic-lib/source` · M01 길과 같은 몸) · 원문 pdf 통째
|
|
(`/logic-lib/source-pdf` · 책 이름만 받음 · 경로 안 받음)도 로그인만.
|
|
704 — 기준 목록(`/logic-lib/standard`) · 계산서(`/logic-lib/sheet`) 로그인만(`M02_Logic_Standard`).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from typing import Any
|
|
|
|
from fastapi import APIRouter, Depends, HTTPException, Request
|
|
from fastapi.responses import Response
|
|
from pydantic import BaseModel
|
|
|
|
from common_util.common_util_auth import verify_session
|
|
from common_util.common_util_http_cache import cached_file_response
|
|
from M01_MasterData import M01_MasterData_Parts as parts
|
|
from M01_MasterData import M01_MasterData_Store as m01
|
|
from M01_MasterData import M01_MasterData_Store_Make as make
|
|
from M02_MasterTemplete import M02_Labor_Inputs as labor_inputs
|
|
from M02_MasterTemplete import M02_Logic_Standard as standard
|
|
|
|
router = APIRouter(prefix="/api/m02", tags=["M02 MasterTemplete Combos"])
|
|
|
|
if "pytest" not in sys.modules: # 기준 목록을 뒤에서 한 번 셈(저장본이 있으면 읽기만)
|
|
standard.warm()
|
|
|
|
|
|
# ── 담을 로직(읽기만) — M01 `/logics` · `/subs?group=로직` · `/logic` · `/logic/auto` 모양 ──
|
|
def _read(fn, *args):
|
|
try:
|
|
return fn(*args)
|
|
except m01.StoreError as e:
|
|
raise HTTPException(status_code=e.status, detail=e.detail) from e
|
|
|
|
|
|
@router.get("/logic-lib/logics", dependencies=[Depends(verify_session)])
|
|
def get_logics() -> dict:
|
|
return {"logics": parts.strip(_read(m01.logics, "", "", "", None))} # 부품 문서 뺌(813-2)
|
|
|
|
|
|
@router.get("/logic-lib/subs", dependencies=[Depends(verify_session)])
|
|
def get_logic_subs() -> dict:
|
|
return _read(m01.subs, "", "로직")
|
|
|
|
|
|
@router.get("/logic-lib/logic", dependencies=[Depends(verify_session)])
|
|
def get_logic(key: str) -> dict:
|
|
return _read(m01.logic, key)
|
|
|
|
|
|
@router.get("/logic-lib/auto", dependencies=[Depends(verify_session)])
|
|
def get_logic_auto(key: str) -> dict:
|
|
"""견본 입력 — 미리 보기용 자동값."""
|
|
return _read(m01.auto, key)
|
|
|
|
|
|
@router.get("/logic-lib/inputs", dependencies=[Depends(verify_session)])
|
|
def get_logic_inputs(keys: str = "") -> dict:
|
|
"""일위대가 입력 모달 — 로직 키들(쉼표)의 입력 목록 + 자동값(`M02_Labor_Inputs`)."""
|
|
return _read(labor_inputs.logic_inputs, keys.split(","))
|
|
|
|
|
|
@router.get("/logic-lib/standard", dependencies=[Depends(verify_session)])
|
|
def get_standard() -> dict:
|
|
"""기준 목록 `{판, 공종, 줄}` — 대표 규격 펼침 · 금액 = M01 엔진(704-1)."""
|
|
return _read(standard.listing)
|
|
|
|
|
|
class SheetBody(BaseModel):
|
|
key: str
|
|
바꿈: dict[str, Any] = {}
|
|
|
|
|
|
@router.post("/logic-lib/sheet", dependencies=[Depends(verify_session)])
|
|
def post_sheet(body: SheetBody) -> dict:
|
|
"""계산서 한 장 — 노임 × 품 = 금액 줄 · 비목 소계 · 계(704-2 · 저장 안 함)."""
|
|
return _read(standard.sheet, body.key, body.바꿈)
|
|
|
|
|
|
#: 원문 pdf(85-4) — 책 이름 → 파일(쪽 자르기 없음)
|
|
SOURCE_PDF = {
|
|
"건설": make.BODY / "건설공사_표준품셈" / "2026년_건설공사_표준품셈.pdf",
|
|
"산림": make.BODY / "산림_표준품셈" / "첨부" / "(산림청고시 제2025-82호) 산림사업 표준품셈.pdf",
|
|
}
|
|
|
|
|
|
@router.get("/logic-lib/source", dependencies=[Depends(verify_session)])
|
|
def get_logic_source(src: str) -> dict:
|
|
"""원문 패널 — 출처 글로 찾은 품셈 본문 절(M01 `/logic/source` 와 같은 몸 · 로그인만)."""
|
|
return _read(make.source, src)
|
|
|
|
|
|
@router.get("/logic-lib/source-pdf", dependencies=[Depends(verify_session)])
|
|
def get_source_pdf(request: Request, book: str) -> Response:
|
|
"""원문 pdf 통째 내려받기 — `book` = 건설 | 산림(그 밖 400)."""
|
|
path = SOURCE_PDF.get(book)
|
|
if path is None:
|
|
raise HTTPException(status_code=400, detail="책은 건설 · 산림 중 하나")
|
|
if not path.is_file():
|
|
raise HTTPException(status_code=404, detail="원문 pdf 없음")
|
|
return cached_file_response(request, path, "application/pdf", filename=path.name)
|