Files
Aislo/B08_Quantity/B08_Quantity_Router_Material.py
T
eomsangdonandClaude Opus 5.5 449a8cfe9b feat(B08): 총괄자재 · 콘크리트소요자재 · 자재수량 집계표 세 표(121-1)
- 실무 엑셀(4.2 수량산출(2공구)) 꼴 · 구조물 탭 아래 공용 표 · 구조물 수량 C = 구조물 집계표 계
- 단위수량 · ㎥당 배합 · 할증 % 고칠 칸 · 조작 중 TS 짝 계산 · [저장] 때 서버 정본 · 설정 quantity › material_sheets
- 공용 표 고칠 칸(editable · onEdit) · 끝 0 지움(trim)
- 시험 test_121(엑셀 66행 · 11행 · 총괄 G열 · 거울 · 저장)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016PSXsvyDxjNmufteN5bqmt
2026-10-08 18:35:33 +09:00

49 lines
2.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""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` 와 같은 식)
기본값은 파일에 안 씀(읽을 때 채움).
"""
from __future__ import annotations
from typing import Any
from uuid import UUID
from fastapi import APIRouter, Body
from B08_Quantity.B08_Quantity_Material_Calc import clean_overrides, compute
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, overrides: dict[str, Any]) -> dict[str, Any]:
summary = await structure_summary(project_id)
source = {"columns": summary["columns"], "total": summary["total"]}
return {"source": source, "overrides": overrides, "sheets": compute(source, overrides)}
@router.get("/{project_id}/quantity/materials")
async def material_sheets(project_id: UUID) -> dict[str, Any]:
root = await _project_root(project_id)
return await _sheets(project_id, clean_overrides(quantity_settings(root).get(SETTINGS_KEY)))
@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, overrides)