- 160-3 맞춤 없는 사본 자재 = 총괄 끝 줄(이름 · 규격 · 단위 그대로 · 알림에 이름 목록) · 맞춤 = 이름 · 규격 · 단위 · 기계 주연료 · 할증(ℓ) 뺌 · 참조 줄(승격 · 사전조합) 안 재료 셈 · 고른 품목 = MT 코드 · 파이썬 · TS 짝 - 160-4 콘크리트(기계) · 모르터 1:3 열 늘 보임(손 단위수량 → 콘크리트소요) · 엑셀 손값과 다른 배합 · 할증은 표 아래 알림 한 줄 - 160-5 채집석 공제(돌 채집 둘 · 고임돌 · 막자갈 합) = 총괄 줄 · 토공 잔토처리 = ROUND 0(잔토 − 공제) · 공제 줄 보임 · TS 짝 - 시험 test_160_3 · 4 · 5 새 · test_143_3 · 143_4 · 69 고침 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015sDZSjFvoiDjdGpgj3muc3
83 lines
3.6 KiB
Python
83 lines
3.6 KiB
Python
"""B08 토공 탭 길 (PLAN 61-3 · 69-2) — 읽기만, 아무 파일 · DB 에도 쓰지 않음.
|
||
|
||
GET /api/projects/{id}/quantity/earthwork
|
||
토적표 + 토공집계표 + 평균운반거리 · 종방향 무대운반거리
|
||
|
||
운반 Q · L = 종단 레코드에 저장된 유토곡선 배분(`mass_haul.haul_plan`) — B07 토적도와 같은 정본.
|
||
|
||
단면적 = B06 횡단 설계 저장값(`cross_sections.data.design`) · 노선 = 확정 노선(없으면 최신 노선) ·
|
||
토량환산계수 = 유토곡선과 같은 `mixed_conversion_factors(quantity_settings)` · 암 = 연암 · 경암 비율 가중 C ·
|
||
`rock_c` = 가중 전 리핑암 · 발파암 C(조작 중 브라우저가 다시 가중 · 125-1).
|
||
암 → 연암 · 경암 = 암 × 연암 %(`rock_ratios_pct` · 기본 90 · PLAN 122) — 토적표 줄 · 합계 · 토공집계표.
|
||
잔토처리 = 잔토 − 채집석 공제(자재 총괄 저장본 · `picked_deduction` · 160-5).
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
import asyncio
|
||
from typing import Any
|
||
from uuid import UUID
|
||
|
||
from fastapi import APIRouter, HTTPException
|
||
|
||
from B06_Section.B06_Section_Repository import (
|
||
get_confirmed_route_context,
|
||
get_cross_section_designs,
|
||
get_longitudinal_section,
|
||
get_workflow_route_context,
|
||
)
|
||
from B08_Quantity.B08_Quantity_Engine_Earthwork import StationArea, build_table
|
||
from B08_Quantity.B08_Quantity_Engine_Earthwork_Summary import (
|
||
haul_lists,
|
||
split_rock_columns,
|
||
summary_rows,
|
||
)
|
||
from B08_Quantity.B08_Quantity_Router_Hydro import _project_root
|
||
from B08_Quantity.B08_Quantity_Router_Material import picked_deduction
|
||
from common_util.common_util_project_settings import (
|
||
earthwork_conversion_factors,
|
||
mixed_conversion_factors,
|
||
quantity_settings,
|
||
soft_rock_pct,
|
||
)
|
||
from config.config_db import get_db_pool
|
||
|
||
router = APIRouter(prefix="/api/projects", tags=["B08 Earthwork"])
|
||
|
||
|
||
@router.get("/{project_id}/quantity/earthwork")
|
||
async def earthwork_table(project_id: UUID) -> dict[str, Any]:
|
||
root = await _project_root(project_id)
|
||
async with get_db_pool().acquire() as connection:
|
||
context = await get_confirmed_route_context(connection, project_id)
|
||
confirmed = context is not None
|
||
context = context or await get_workflow_route_context(connection, project_id)
|
||
if not context:
|
||
raise HTTPException(status_code=404, detail="노선이 없습니다 — 노선 · 횡단 설계부터.")
|
||
route_id = int(context["route_id"])
|
||
rows = await get_cross_section_designs(connection, route_id)
|
||
section = await get_longitudinal_section(connection, project_id, route_id)
|
||
settings = await asyncio.to_thread(quantity_settings, root)
|
||
soft = soft_rock_pct(settings)
|
||
stations = [StationArea.from_design(row["chainage_m"], row["design"]) for row in rows]
|
||
table = build_table(stations, mixed_conversion_factors(settings))
|
||
for record in [*table["rows"], table["totals"]]:
|
||
split_rock_columns(record, soft)
|
||
mass_haul = ((section or {}).get("data") or {}).get("mass_haul") or {}
|
||
haul = haul_lists(mass_haul.get("haul_plan"))
|
||
deduct = await picked_deduction(project_id, root)
|
||
return {
|
||
**table,
|
||
"summary": summary_rows(table["totals"], haul, soft, deduct),
|
||
"rock_ratios_pct": {"연암": soft, "경암": 100.0 - soft},
|
||
"rock_c": {
|
||
kind: entry["compacted"]
|
||
for kind, entry in earthwork_conversion_factors(settings).items()
|
||
if kind != "soil"
|
||
},
|
||
"haul": haul,
|
||
"haul_saved": bool(mass_haul.get("haul_plan")),
|
||
"route_id": route_id,
|
||
"confirmed": confirmed,
|
||
}
|