feat(822-2): 기계 시간당 식 자료 — 새 식 넷 · 33 대 옮김 · 직종 13 대 · 전력 칸 · POWER TROWEL
- 08장 로직: GC001196 전력 기종 · GC001197 전력 + 조종원 · GC001198 손료계수 한 칸 연료 · GC001199 직접 값 - 손료만 식(GC000273) 목록에서 연료 · 조종원 · 전력 있는 기계 뺌 → 276 · 268 · 새 식 목록(보정 식 274 그대로) - 기계표: 주연료 칸 ㎾ 글 10 대 → 전력(㎾) 숫자 칸(값원문 보존) · 원문 잡재료 「-」 = 0 · 조종원직종 13 대(요구 799) - EQ000534 이름 POWER TLOWEL → POWER TROWEL(옛이름 보존) - 가격 없는 기계(스프레어 둘 · TBM 4.5m) · 중유 믹싱플랜트 · 73.7+ 표층재생기는 목록 밖(꼴로 고름 → 까닭 글) - 수식 문서 802-2 다시(1,518 저장 · 기본 다름 0) · 기존 M01 문서 1,514 금액 전후 같음 - M01 기계 저장 손질: 보낸 단위 · 출처 칸이 있으면 그 글 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,11 +3,14 @@
|
||||
|
||||
계수 = `master_machine_coef`(TS 짝 `common_util/common_util_machine_coef.ts`) ·
|
||||
시간당 = 서버 기계경비식(`M02_Machine_Hourly.hourly` · 전국평균 · 기본 옵션) ·
|
||||
쓰는 계산식 = `M02_Machine_Hourly.pick`(목록 › 꼴 · 822-2) · [새 기계] 저장 = 꼴에 맞는 식 목록에 원문번호 등록 ·
|
||||
M01 에서 만든 기계(출처 모두 「자체」)를 지우면 그 번호 기계가 더 없을 때 목록에서 뺌(`register`) ·
|
||||
마스터 파일은 읽기만 — 쓰기는 `Store_Make.save`.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import copy
|
||||
import json
|
||||
import re
|
||||
from decimal import Decimal
|
||||
@@ -102,6 +105,78 @@ def hourly(keys: list[str]) -> dict[str, dict]:
|
||||
return out
|
||||
|
||||
|
||||
def formula(row: dict) -> dict:
|
||||
"""기계 줄(저장 전 고친 값도) → 쓰는 계산식 {키, 이름, 방법 목록|꼴|그 기계 식, 까닭}(822-2 상세 페이지)."""
|
||||
from M02_MasterTemplete import M02_Machine_Hourly as mh # M02 가 M01 을 부름 — 늦게
|
||||
|
||||
code = str(row.get("원문번호") or "")
|
||||
got = mh.pick({**row, "값": store._dec(row.get("값") or {})})
|
||||
how = "목록" if mh.listed(code) else "그 기계 식" if got and mh._own(code) else "꼴"
|
||||
base = {"방법": how, "까닭": mh.why({**row, "값": store._dec(row.get("값") or {})}, got)}
|
||||
return base | ({"키": got["키"], "이름": got.get("이름")} if got else {})
|
||||
|
||||
|
||||
def _family_files() -> dict[str, str]:
|
||||
"""기계경비식 키 → 로직 파일 이름."""
|
||||
return {
|
||||
str(r.get("키")): name
|
||||
for name, data in store.loaded()[0].items()
|
||||
if data.get("그룹") == "로직" and "건설기계" in name
|
||||
for r in data.get("줄") or []
|
||||
}
|
||||
|
||||
|
||||
def register(batch: list[dict]) -> None:
|
||||
"""[새 기계] 저장 = 꼴 식 「기계」 목록에 그 원문번호 더함 · M01 에서 만든 기계(출처 모두 「자체」)를
|
||||
지우면 같은 번호 기계가 더 없을 때 목록에서 뺌 — 로직 파일 고침을 같은 저장 묶음에 붙임(정본 저장 길)."""
|
||||
from M02_MasterTemplete import M02_Machine_Hourly as mh # M02 가 M01 을 부름 — 늦게
|
||||
from M02_MasterTemplete import M02_MyMachine as mym
|
||||
|
||||
part = next((p for p in batch if p.get("file") == FILE), None)
|
||||
if part is None:
|
||||
return
|
||||
rows = _rows()
|
||||
gone = {str(c.get("key")) for c in part.get("changes") or [] if c.get("op") == "delete"}
|
||||
add: dict[str, list[str]] = {}
|
||||
drop: set[str] = set()
|
||||
for ch in part.get("changes") or []:
|
||||
row = ch.get("row") if ch.get("op") == "add" else None
|
||||
code = str((row or {}).get("원문번호") or "").strip()
|
||||
if row and code and not mh.listed(code) and not mh._own(code):
|
||||
key = mym.logic_key({**row, "값": store._dec(row.get("값") or {})})
|
||||
if key and code not in add.get(key, []):
|
||||
add.setdefault(key, []).append(code)
|
||||
old = next((r for r in rows if r.get("키") == ch.get("key")), None)
|
||||
if (
|
||||
ch.get("op") == "delete"
|
||||
and old
|
||||
and set((old.get("출처") or {}).values()) == {OWN_SOURCE}
|
||||
):
|
||||
code = str(old.get("원문번호") or "")
|
||||
if code and not any(
|
||||
str(r.get("원문번호")) == code and r.get("키") not in gone for r in rows
|
||||
):
|
||||
drop.add(code)
|
||||
if not add and not drop:
|
||||
return
|
||||
files = _family_files()
|
||||
for name in dict.fromkeys(files.values()):
|
||||
changes = []
|
||||
for logic in store.read(name)[0].get("줄") or []:
|
||||
ins = logic.get("입력") or []
|
||||
pick = next((i for i in ins if i.get("이름") == "기계" and "고르기" in i), None)
|
||||
if pick is None:
|
||||
continue
|
||||
codes = [c for c in pick["고르기"] if str(c) not in drop]
|
||||
codes += [c for c in add.get(str(logic["키"]), []) if c not in codes]
|
||||
if codes != pick["고르기"]:
|
||||
new = copy.deepcopy(logic)
|
||||
next(i for i in new["입력"] if i.get("이름") == "기계")["고르기"] = codes
|
||||
changes.append({"op": "edit", "key": logic["키"], "row": new})
|
||||
if changes:
|
||||
batch.append({"file": name, "version": store.read(name)[1], "changes": changes})
|
||||
|
||||
|
||||
# ── 쓰는 곳 ─────────────────────────────────────────────────────────
|
||||
def _logic_index() -> tuple[dict[str, list[str]], dict[str, list[str]]]:
|
||||
"""(원문번호 → 로직 「키 이름」 · 기계 키 → 로직) — 기계 고르기 · 식 안 EQ 키."""
|
||||
@@ -218,5 +293,9 @@ def fix(part: dict) -> None:
|
||||
values.update(got)
|
||||
was_unit = (old or {}).get("단위") or {}
|
||||
was_src = (old or {}).get("출처") or {}
|
||||
row["단위"] = {k: was_unit.get(k, units.get(k, "")) for k in values}
|
||||
row["출처"] = {k: was_src.get(k, OWN_SOURCE) for k in values}
|
||||
unit, src = (
|
||||
row.get("단위") or {},
|
||||
row.get("출처") or {},
|
||||
) # 보낸 칸이 있으면 그 글(822-2 빌더)
|
||||
row["단위"] = {k: unit.get(k) or was_unit.get(k, units.get(k, "")) for k in values}
|
||||
row["출처"] = {k: src.get(k) or was_src.get(k, OWN_SOURCE) for k in values}
|
||||
|
||||
Reference in New Issue
Block a user