feat(b09): 운반공 줄 = 거리이정표 행 1:1 (253-1)
- 자동 상자 = 옛 키 · 사용자 상자 = haul:r-{id} · 둘째 행 haul:r-{id}.{n}
- 이름 = 항목 + 운반 · 수량 빈칸 · 연결 = 경로 ref(설계내역서 덮개가 이김)
- B09 가 거리이정표 표(compute_milestone)를 읽어 행 · 거리(L1 포장 · L2 비포장)를 셈 덧값으로
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JywHxQuWPk6UYXTebyrBoU
This commit is contained in:
@@ -27,11 +27,13 @@ from uuid import UUID
|
||||
from fastapi import APIRouter, Body, Depends, HTTPException
|
||||
from pydantic import BaseModel
|
||||
|
||||
from B08_Quantity.B08_Quantity_Haul import bill_key
|
||||
from B08_Quantity.B08_Quantity_Haul import haul_rows
|
||||
from B08_Quantity.B08_Quantity_Milestone_Calc import compute_milestone
|
||||
from B08_Quantity.B08_Quantity_Router_Earthwork import earthwork_table
|
||||
from B08_Quantity.B08_Quantity_Router_Hydro import _project_root
|
||||
from B08_Quantity.B08_Quantity_Router_Material import material_sheets
|
||||
from B08_Quantity.B08_Quantity_Router_Milestone import read_data as read_milestone
|
||||
from B08_Quantity.B08_Quantity_Router_Milestone import site_info
|
||||
from B09_Estimation import B09_Estimation_Bill_Library as library
|
||||
from B09_Estimation import B09_Estimation_Prices as prices
|
||||
from B09_Estimation import B09_Estimation_Sangeun as sangeun
|
||||
@@ -110,18 +112,27 @@ def compute_twice(root: Path, inputs: dict[str, Any], user: dict[str, Any]) -> t
|
||||
return sheets, compute_summary(sheets, hopyo_lines(sheets))
|
||||
|
||||
|
||||
def haul_refs(root: Path) -> dict[str, Any]:
|
||||
"""거리이정표 운반 상자 단가연결(251-5) → `{설계내역서 줄 키: ref}` — 못 읽으면 빈 묶음."""
|
||||
def haul_routes(root: Path) -> list[dict[str, Any]]:
|
||||
"""거리이정표 행 → 운반공 줄(253-1 · `haul_rows` · 거리 L1 · L2 포함) — 못 읽으면 빈 목록."""
|
||||
try:
|
||||
routes = read_milestone(root).get("routes") or []
|
||||
except Exception: # noqa: BLE001 — 거리이정표 없음 = 연결 없음
|
||||
return {}
|
||||
return {bill_key(r["haul"]): r["ref"] for r in routes if r.get("haul") and r.get("ref")}
|
||||
data = read_milestone(root)
|
||||
mid = site_info(root, data["site"]["mid_station_m"])["mid_default_m"]
|
||||
return haul_rows(data, compute_milestone(data, mid))
|
||||
except Exception: # noqa: BLE001 — 거리이정표 없음 = 운반 연결 없음
|
||||
return []
|
||||
|
||||
|
||||
def haul_user(rows: list[dict[str, Any]]) -> dict[str, Any]:
|
||||
"""셈 덧값 — `haul_refs{줄 키: ref}`(251-5) · `haul_dist{줄 키: {L1, L2}}`(253-2 거리 채움)."""
|
||||
return {
|
||||
"haul_refs": {r["key"]: r["ref"] for r in rows if r.get("ref")},
|
||||
"haul_dist": {r["key"]: {"L1": r["L1"], "L2": r["L2"]} for r in rows},
|
||||
}
|
||||
|
||||
|
||||
def calc_user(root: Path) -> dict[str, Any]:
|
||||
"""셈 · 수요 · 사본 정리용 사용자 값 — 저장 값 + 거리이정표 운반 연결(화면엔 안 보냄)."""
|
||||
return {**store.read_user(root), "haul_refs": haul_refs(root)}
|
||||
"""셈 · 수요 · 사본 정리용 사용자 값 — 저장 값 + 거리이정표 운반 연결 · 거리(화면엔 안 보냄)."""
|
||||
return {**store.read_user(root), **haul_user(haul_routes(root))}
|
||||
|
||||
|
||||
async def _demand(root: Path) -> list[str]:
|
||||
@@ -143,11 +154,12 @@ async def payload(project_id: UUID, root: Path) -> dict[str, Any]:
|
||||
)
|
||||
book = await asyncio.to_thread(store.read_book, root)
|
||||
inputs = await asyncio.to_thread(prices.build_inputs, book, keys, b08["materials"])
|
||||
inputs["bill"] = bill_items({**b08, "haul_refs": await asyncio.to_thread(haul_refs, root)})
|
||||
hauls = await asyncio.to_thread(haul_routes, root)
|
||||
inputs["bill"] = bill_items({**b08, **haul_user(hauls), "haul_routes": hauls})
|
||||
inputs["hopyo"] = hopyo_prices(root)
|
||||
inputs["daega"] = await asyncio.to_thread(daega_inputs, root)
|
||||
user = await asyncio.to_thread(store.read_user, root)
|
||||
calc = {**user, "haul_refs": await asyncio.to_thread(haul_refs, root)}
|
||||
calc = {**user, **haul_user(hauls)}
|
||||
sheets, summary = await asyncio.to_thread(compute_twice, root, inputs, calc)
|
||||
if schedule_draft:
|
||||
schedule_draft.attach(inputs, sheets, user)
|
||||
@@ -176,7 +188,7 @@ async def estimation(project_id: UUID) -> dict[str, Any]:
|
||||
async def save_estimation(project_id: UUID, body: dict[str, Any] = Body(...)) -> dict[str, Any]:
|
||||
root = await _project_root(project_id)
|
||||
user = await asyncio.to_thread(store.write_user, root, body.get("user"))
|
||||
calc = {**user, "haul_refs": await asyncio.to_thread(haul_refs, root)}
|
||||
calc = {**user, **haul_user(await asyncio.to_thread(haul_routes, root))}
|
||||
await asyncio.to_thread(library.prune, root, calc) # 204-2 줄이 안 잇는 서고 사본
|
||||
keys = await _demand(root)
|
||||
book = await asyncio.to_thread(store.read_book, root)
|
||||
|
||||
Reference in New Issue
Block a user