refactor(B08,B09): 폴더째 old_code 로 옮기고 빈 화면 둘만 남김 (PLAN 7-3)
B08_Quantity 86 · B09_Estimation 111 파일을 old_code/ 로 옮김(지우지 않음). 화면은 메뉴·주소·단계 막대만 남은 빈 틀 둘 — main.py 라우터 13 개는 끊음. B07 이 빌려 쓰던 비탈 길이·면적은 필요한 함수만 B07_DesignDetail_Engine_SlopeGeometry 로 옮겨 적음(면적 적분·노면 면적·측점 묶음은 안 옮김) · 시험 하나를 새로 둠. B07 구조물도 조립(Cad_StandardSheet)은 2026-09-13 에 이미 도면 목록에서 빠져 부르는 곳이 없어 old_code 로 같이 보냄 — 구조물 그림은 되살리지 않음. B06 구조물 몫 조회는 빈 값으로 두어 화면이 그대로 서게 함. B08·B09 를 부르던 시험 25 개도 old_code/resources/tester 로 옮김. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PAdA5ThqmtVSsbzjusk1cJ
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
"""B09 실행예산 단계 탭 API — 설계 내역 → 실행예산 (PLAN 12장 · 랩탑 메인).
|
||||
|
||||
⚠ 설계 내역·단가표를 **읽기만** 한다(복사본에 중기 실행단가·실행수량을 얹음). 저장은
|
||||
`estimation.execution` 한 칸 — 설계 내역·계약·원가계산서 저장본은 안 건드린다.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import logging
|
||||
from typing import Any
|
||||
from uuid import UUID
|
||||
|
||||
from fastapi import APIRouter
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from B09_Estimation.B09_Estimation_Execution import (
|
||||
CORRECTION_HINTS,
|
||||
CORRECTIONS,
|
||||
CUT_UNITS,
|
||||
SETTINGS_KEY,
|
||||
clean_settings,
|
||||
execution_bill,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
router = APIRouter(prefix="/api/projects", tags=["B09 Estimation — Execution"])
|
||||
|
||||
_NOT_FOUND = {"status": "error", "message": "프로젝트 저장 폴더를 찾지 못했습니다."}
|
||||
|
||||
|
||||
async def _root(project_id: UUID) -> str | None:
|
||||
from B09_Estimation.B09_Estimation_Router import _project_root_of
|
||||
|
||||
return await _project_root_of(project_id)
|
||||
|
||||
|
||||
@router.get("/{project_id}/estimation/execution")
|
||||
async def get_execution(project_id: UUID) -> JSONResponse:
|
||||
"""실행예산 한 장 — 설계 줄 옆에 실행수량·실행단가·실행금액 · 중기 실행단가 표 · 합계."""
|
||||
from B09_Estimation.B09_Estimation_Router import _build_for, get_bill
|
||||
from common_util.common_util_project_settings import estimation_settings
|
||||
|
||||
root = await _root(project_id)
|
||||
if root is None:
|
||||
return JSONResponse(status_code=404, content=_NOT_FOUND)
|
||||
response = await get_bill(project_id)
|
||||
bill = json.loads(bytes(response.body).decode("utf-8"))
|
||||
if response.status_code != 200 or "rows" not in bill:
|
||||
return JSONResponse(status_code=response.status_code or 502, content=bill)
|
||||
stored, _ = clean_settings(dict(estimation_settings(root).get(SETTINGS_KEY) or {}))
|
||||
# 조립본은 캐시 공유본 — `execution_bill` 이 단가표 복사본에만 중기 실행단가를 얹음(설계 불변).
|
||||
result = execution_bill(bill["rows"], stored, build=await _build_for(project_id))
|
||||
return JSONResponse(
|
||||
content={
|
||||
"status": "success",
|
||||
**result,
|
||||
"settings": stored,
|
||||
"fields": {
|
||||
"cut_units": list(CUT_UNITS),
|
||||
"corrections": [
|
||||
{"key": k, "label": label, "hint": CORRECTION_HINTS[k]}
|
||||
for k, label in CORRECTIONS
|
||||
],
|
||||
},
|
||||
"bill_missing_count": len((bill.get("summary") or {}).get("missing") or []),
|
||||
"limit_note": (
|
||||
"실행예산 표본 0건 — 구조가 서는지까지만 확인됨 · 성분 가르기·기본보정은 확인 대기"
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@router.put("/{project_id}/estimation/execution")
|
||||
async def put_execution(project_id: UUID, body: dict[str, Any]) -> JSONResponse:
|
||||
"""중기 실행단가 입력·실행수량 저장 — 틀린 칸이 있으면 아무것도 안 저장."""
|
||||
from common_util.common_util_project_settings import save_section
|
||||
|
||||
root = await _root(project_id)
|
||||
if root is None:
|
||||
return JSONResponse(status_code=404, content=_NOT_FOUND)
|
||||
cleaned, errors = clean_settings(body)
|
||||
if errors:
|
||||
return JSONResponse(
|
||||
status_code=400,
|
||||
content={"status": "error", "message": " · ".join(errors), "errors": errors},
|
||||
)
|
||||
try:
|
||||
save_section(root, "estimation", {SETTINGS_KEY: cleaned}, replace_keys=(SETTINGS_KEY,))
|
||||
except Exception:
|
||||
logger.exception("B09 실행예산 저장 실패: project_id=%s", project_id)
|
||||
return JSONResponse(
|
||||
status_code=500,
|
||||
content={"status": "error", "message": "실행예산을 저장하지 못했습니다."},
|
||||
)
|
||||
return JSONResponse(content={"status": "success", "settings": cleaned})
|
||||
Reference in New Issue
Block a user