refactor(B08): 측점별 단면유형 표를 공용 함수로 냄 (B07 표준도가 같이 쓰게)

기울기 판정이 `section_mode` 를 받아야 도는데, 그 표를 만드는 코드가 B08 라우터 안에만
있었음. B07 표준도는 `build_table` 을 직접 부르면서 그 인자를 못 줘 **늘 「가를 근거 없음」**
으로 떨어졌음(랩탑 보조 실측).

⇒ `section_modes_from_designs(designs)` 를 엔진에 두어 **부르는 쪽마다 다시 짜지 않게** 함.
B07 은 저장된 횡단 설계 목록을 이 함수에 넣어 `build_table(..., section_modes=…)` 로 주면 됨.

⚠ 동작은 그대로 — `section_mode` 가 없는 측점은 담지 않고, 못 가르면 여전히
「가를 근거 없음 + 종전값 1:0.3」으로 섬(성토로 눅이지 않음).

내 프로젝트 실측 유지 — 돌쌓기(메) H=2.0 **1:0.35 · 21.190㎡**,
근거 「… right_cut · 자동(성토 쪽) → 성토면」.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-08 20:50:22 +09:00
co-authored by Claude Opus 5
parent 1b03ad025a
commit c3975f4ec1
2 changed files with 21 additions and 5 deletions
@@ -906,6 +906,25 @@ def verify_no_mix_components(quantities: Iterable[StructureQuantity]) -> list[st
return found return found
def section_modes_from_designs(designs: Iterable[dict[str, Any]]) -> dict[float, str]:
"""저장된 횡단 설계 목록 → `{측점: 단면유형}`.
⚠ **부르는 쪽마다 다시 짜지 말라고 여기 둔다.** 구조물 전개(B08)와 표준도(B07)가
같은 표를 써야 기울기 판정이 두 곳에서 갈리지 않는다.
`design.section_mode` 가 없는 측점은 담지 않는다 — 빈 값을 담으면 「가를 근거 없음」과
「모드가 빈 문자열」이 뒤섞인다.
"""
modes: dict[float, str] = {}
for item in designs or ():
design = item.get("design") if isinstance(item, dict) else None
mode = str((design or {}).get("section_mode") or "").strip()
if not mode:
continue
chainage = _num(item.get("chainage_m"))
modes[float(chainage)] = mode
return modes
def _section_mode_at( def _section_mode_at(
structure: dict[str, Any], section_modes: dict[float, str] | None structure: dict[str, Any], section_modes: dict[float, str] | None
) -> str | None: ) -> str | None:
+2 -5
View File
@@ -32,6 +32,7 @@ from B05_Profile.B05_Profile_Structures_Schema import structure_type_map
from B08_Quantity.B08_Quantity_Engine_Handoff import build_handoff, load_mapping, summarize from B08_Quantity.B08_Quantity_Engine_Handoff import build_handoff, load_mapping, summarize
from B08_Quantity.B08_Quantity_Engine_MaterialSummary import build_table as build_material_table from B08_Quantity.B08_Quantity_Engine_MaterialSummary import build_table as build_material_table
from B08_Quantity.B08_Quantity_Engine_UnitQuantity import build_table as build_unit_table from B08_Quantity.B08_Quantity_Engine_UnitQuantity import build_table as build_unit_table
from B08_Quantity.B08_Quantity_Engine_UnitQuantity import section_modes_from_designs
from common_util.common_util_project_settings import ( from common_util.common_util_project_settings import (
concrete_placing_method, concrete_placing_method,
quantity_settings, quantity_settings,
@@ -95,11 +96,7 @@ async def _section_modes(project_id: UUID) -> dict[float, str]:
except Exception: except Exception:
logger.exception("B08 단면유형 조회 실패: project_id=%s", project_id) logger.exception("B08 단면유형 조회 실패: project_id=%s", project_id)
return {} return {}
return { return section_modes_from_designs(designs)
float(item["chainage_m"]): str((item.get("design") or {}).get("section_mode") or "")
for item in designs
if (item.get("design") or {}).get("section_mode")
}
@router.get("/{project_id}/quantity/material-summary") @router.get("/{project_id}/quantity/material-summary")