Files
Aislo/B09_Estimation/B09_Estimation_SeedSpray.py
T

58 lines
2.8 KiB
Python

"""B09 원가계산 — **초류종자살포 5-24 종자**(2026-09-15 브레인 판정 ④ · 화약류 길).
표 「종자 kg 0.025」 는 규격을 안 적음 — 자원 목록에 종자 후보가 넷(생태복원형 초본류·목본류 · 초본류 · 목본류)이라
조인 규칙(규격이 같아야)에 걸려 못 붙었음. 배합은 [주]①③ 이 현장 판단(도로비탈면 녹화 지침 · 방향·고도·계절)으로 넘김.
⇒ 넷 모두 「자재 단가」 탭에 칸이 서고 **설계자가 넣은 하나**가 표 수량으로 붙음 · 안 넣으면 「규격 미정」 ·
둘 이상 넣으면 고르지 않고 사유(임의로 규격을 고르지 않음).
"""
from __future__ import annotations
from typing import Any
CODES = ("FP-05-24-01", "FP-05-24-02")
NAME = "종자"
#: (자원 목록 코드, 규격) — 자원 목록 `resource_catalog_ext` 의 종자 넷.
SEEDS: tuple[tuple[str, str], ...] = (
("AR-M-f89c57d4", "생태복원형,초본류"),
("AR-M-d52b8fc1", "생태복원형,목본류"),
("AR-M-8f852514", "초본류"),
("AR-M-e39ee36e", "목본류"),
)
SEED_MISSING = (
"종자 — 규격 미정(원문 표가 규격을 안 적음 · 후보 넷 "
+ " · ".join(spec for _, spec in SEEDS)
+ ") · 「자재 단가」 탭에서 하나를 넣으면 붙음"
)
SEED_TWO = "종자 — 후보가 둘 이상 들어옴({specs}) · 하나만 넣을 것"
def attach_seed_spray(build: Any, nodes_by_code: dict[str, dict[str, Any]]) -> None:
"""칸 넷을 세우고(`material_uses`) · 넣은 하나만 붙이고 · 없거나 둘이면 사유로 갈아 끼움."""
from B09_Estimation.B09_Estimation_Explosives import _table_amount
from B09_Estimation.B09_Estimation_PriceBook import PriceDetail
book = build.book
for code in CODES:
for material, _ in SEEDS:
uses = build.material_uses.setdefault(material, [])
if code not in uses:
uses.append(code)
labels = [
label for label in build.unattached.get(code) or [] if "".join(label.split()) != NAME
]
amount = _table_amount(nodes_by_code.get(code) or {}, NAME)
picked = [(material, spec) for material, spec in SEEDS if material in book.titles]
titles = [t for t in book.titles if t == f"B-{code}" or t.startswith(f"B-{code}#")]
if len(picked) == 1 and amount is not None and titles:
material, spec = picked[0]
for title in titles:
book.add_detail(
PriceDetail(title, material, amount, note=f"종자 {spec} — 설계자 선택")
)
elif len(picked) > 1:
labels.append(SEED_TWO.format(specs=" · ".join(spec for _, spec in picked)))
else:
labels.append(SEED_MISSING)
build.unattached[code] = labels