- 총괄 끝수 = 레미콘 ROUND 2 · 철근 · 와이어메쉬 ROUND 3 · 시멘트 ROUND 0 · 그 밖 ROUNDUP 0 (TS · 파이썬 짝) - 총괄 막자갈 줄(할증 4 % · 수량 빈칸 — 채집) - 총괄 · 콘크리트소요 위 「단위수량 빈 줄 n개」 + 구조물 집계표 알림 한 줄 - B06 ford_pipe_length_m(그린 관 한 련 길이 1 m 올림 · 주인 측점만) → 구조물 집계표 관매설 · 커플링 × 련 - test_121 기대값 31.62 · 새 test_131 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016PSXsvyDxjNmufteN5bqmt
65 lines
2.6 KiB
Python
65 lines
2.6 KiB
Python
"""B08 자재 집계표 셋 길(PLAN 121-1) — 총괄자재 · 콘크리트소요자재 · 자재수량 집계표.
|
||
|
||
GET /api/projects/{id}/quantity/materials
|
||
구조물 집계표(98 `structure_summary` 그대로 부름) + 저장된 사용자 값 → 세 표
|
||
PUT /api/projects/{id}/quantity/materials {overrides}
|
||
[저장] — 사용자 값을 프로젝트 설정 quantity › material_sheets 에 · 서버가 정본으로 다시 셈
|
||
|
||
계산 = `B08_Quantity_Material_Calc.py`(화면 짝 `.ts` 와 같은 식) · 총괄 모래 · 자갈 · 시멘트 할증 =
|
||
좌측 패널 값(`surcharge_pct` · 저장은 옵션 길 PUT …/quantity/options)
|
||
기본값은 파일에 안 씀(읽을 때 채움).
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
from pathlib import Path
|
||
from typing import Any
|
||
from uuid import UUID
|
||
|
||
from fastapi import APIRouter, Body
|
||
|
||
from B08_Quantity.B08_Quantity_Material_Calc import (
|
||
PANEL_KEY,
|
||
clean_overrides,
|
||
compute,
|
||
panel_surcharge,
|
||
)
|
||
from B08_Quantity.B08_Quantity_Router_Hydro import _project_root
|
||
from B08_Quantity.B08_Quantity_Router_Summary import structure_summary
|
||
from common_util.common_util_project_settings import quantity_settings, save_section
|
||
|
||
router = APIRouter(prefix="/api/projects", tags=["B08 Material"])
|
||
|
||
SETTINGS_KEY = "material_sheets"
|
||
|
||
|
||
async def _sheets(project_id: UUID, root: str | Path, overrides: dict[str, Any]) -> dict[str, Any]:
|
||
summary = await structure_summary(project_id)
|
||
source = {"columns": summary["columns"], "total": summary["total"]}
|
||
panel = panel_surcharge(quantity_settings(root).get(PANEL_KEY))
|
||
return {
|
||
"source": source,
|
||
"overrides": overrides,
|
||
"surcharge_pct": panel,
|
||
# 구조물 집계표 알림(「집수정 모양 기록 없음 n곳」 등) — 총괄 · 콘크리트 위 빈 까닭(131)
|
||
"notes": list(summary.get("notes") or []),
|
||
"sheets": compute(source, overrides, panel),
|
||
}
|
||
|
||
|
||
@router.get("/{project_id}/quantity/materials")
|
||
async def material_sheets(project_id: UUID) -> dict[str, Any]:
|
||
root = await _project_root(project_id)
|
||
overrides = clean_overrides(quantity_settings(root).get(SETTINGS_KEY))
|
||
return await _sheets(project_id, root, overrides)
|
||
|
||
|
||
@router.put("/{project_id}/quantity/materials")
|
||
async def save_material_sheets(
|
||
project_id: UUID, body: dict[str, Any] = Body(...)
|
||
) -> dict[str, Any]:
|
||
root = await _project_root(project_id)
|
||
overrides = clean_overrides(body.get("overrides"))
|
||
save_section(root, "quantity", {SETTINGS_KEY: overrides}, replace_keys=(SETTINGS_KEY,))
|
||
return await _sheets(project_id, root, overrides)
|