feat(master_data): 재료 고르기 후보를 줄 단위와 같은 자재품목으로만 거름

- 엔진 — candidates·pick·element 에 unit · 호표 줄 단위를 그대로 넘김(우드칩 ㎥ 에 원목후로링 ㎡ 가 섞이던 자리)
- 후보 API — /materials 에 unit · 단가 미리보기도 줄 단위로 거름
- check_master 「단위」 검사 새로 — 조건 안 줄이 모두 다른 단위거나 대표 줄 단위가 다른 자리 37건(로직 검사와 따로 — 조건을 좁히라는 알림)
- 품셈재료 고르기 칸이 채워진 호표 줄 24개를 고르기 조건 묶음으로 바꿈
- 일괄 시험 계산 통과 1,270 → 1,272 · 시험 둘 더함

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JgUhN55Z3BCYhUJTjwTNfj
This commit is contained in:
2026-09-20 23:08:00 +09:00
co-authored by Claude Opus 5
parent 53151917ba
commit e2ea63e844
10 changed files with 210 additions and 46 deletions
+10 -8
View File
@@ -347,11 +347,12 @@ def _brief(ref: str, row: dict) -> dict:
}
def _pick_brief(whole, cond: dict) -> dict | None:
"""고르기 조건 줄의 단가 미리보기 — 후보 수와 시험 계산이 쓸 줄(값 열 다섯 포함)."""
def _pick_brief(whole, cond: dict, unit: str | None = None) -> dict | None:
"""고르기 조건 줄의 단가 미리보기 — 후보 수와 시험 계산이 쓸 줄(값 열 다섯 포함).
`unit` = 호표 줄 단위 — 후보를 같은 단위 줄로만 거름."""
try:
keys = cm.mf.candidates(whole, cond, {})
brief = _market_brief(whole.get(cm.mf.pick(whole, cond, {})))
keys = cm.mf.candidates(whole, cond, {}, unit)
brief = _market_brief(whole.get(cm.mf.pick(whole, cond, {}, unit)))
except (cm.mf.FormulaError, KeyError, TypeError):
return None
return {**brief, "조건": cond, "후보": len(keys)}
@@ -364,7 +365,7 @@ def _prices(whole, row: dict) -> dict:
out = {}
for item in row.get("호표") or []:
if isinstance(item.get("요소"), dict):
out[cm.mf.cond_text(item["요소"])] = _pick_brief(whole, item["요소"])
out[cm.mf.cond_text(item["요소"])] = _pick_brief(whole, item["요소"], item.get("단위"))
continue
ref = str(item.get("요소", ""))
if item.get("종류") != "로직" and "{" not in ref:
@@ -447,14 +448,15 @@ def _market_brief(row: dict) -> dict:
}
def materials(sub: str, detail: str, spec: str, region: str, limit: int) -> dict:
def materials(sub: str, detail: str, spec: str, region: str, unit: str, limit: int) -> dict:
"""재료 고르기 조건 안 후보 목록 — 화면·테스트 컨테이너가 같이 씀.
`unit` = 호표 줄 단위 — 주면 그 단위 줄만(단위가 다르면 다른 물건).
`기본` = 시험 계산이 쓸 줄(대표 줄이 없을 때의 첫 줄) · 그 줄을 `items` 맨 앞에 둠."""
whole = cm.master(folder=FOLDER)
cond = {"구분": sub, "상세구분": detail or None, "규격": spec or None}
env = {cm.mf.REGION: region} if region else {}
keys = cm.mf.candidates(whole, cond, env)
first = cm.mf.pick(whole, cond, env) if keys else None
keys = cm.mf.candidates(whole, cond, env, unit or None)
first = cm.mf.pick(whole, cond, env, unit or None) if keys else None
keys = [first] + [k for k in keys if k != first] if first else keys
return {
"total": len(keys),