Merge remote-tracking branch 'origin/sub_laptop_7' into sub_laptop_3
This commit is contained in:
@@ -153,15 +153,43 @@ def clean_doc(kind: str, doc: Any) -> dict[str, Any]:
|
||||
단위=unit or pill.get("단위") or None,
|
||||
배=pill.get("배") or 1, # ponytail: 저장 때 적음 · 마스터 결과단위가 바뀌면 다시 저장
|
||||
담은로직=[{"로직": line["로직"], "입력값": line["입력값"]}],
|
||||
**origin(line["로직"]),
|
||||
)
|
||||
else:
|
||||
if not name:
|
||||
raise _bad("사전조합 이름이 빔")
|
||||
out.update(이름=name, 단위=unit or None, 담은로직=_combo_lines(doc, key))
|
||||
out.update({k: str(doc.get(k) or "").strip() for k in ("구분", "상세구분")})
|
||||
out["본뜬"] = doc["본뜬"] if isinstance(doc.get("본뜬"), dict) else None
|
||||
return out
|
||||
|
||||
|
||||
def origin(code: str) -> dict[str, Any]:
|
||||
"""단가승격 칸 — 원 로직의 구분 · 상세구분 + 연결 {로직 키, 출처 글}(51-12 · 없으면 빈 글)."""
|
||||
from M01_MasterData import M01_MasterData_Store as m01
|
||||
|
||||
try:
|
||||
got = m01.loaded()[1].logic(code)
|
||||
except m01.cm.mf.FormulaError:
|
||||
got = {}
|
||||
return {
|
||||
"구분": got.get("구분") or "",
|
||||
"상세구분": got.get("상세구분") or "",
|
||||
"연결": {"로직": code, "출처": got.get("출처") or ""},
|
||||
}
|
||||
|
||||
|
||||
def filled(kind: str, doc: Any) -> Any:
|
||||
"""옛 서고 문서(51-12 앞) 읽을 때 칸 채움 — 승격 = 원 로직 것 · 사전조합 = 빈 글(화면 몫)."""
|
||||
if not isinstance(doc, dict) or kind not in PREFIX or "구분" in doc:
|
||||
return doc
|
||||
if kind == "precombo":
|
||||
return {**doc, "구분": "", "상세구분": ""}
|
||||
line = (doc.get("담은로직") or [{}])[0]
|
||||
code = str(line.get("로직") or "") if isinstance(line, dict) else ""
|
||||
return {**doc, **origin(code)}
|
||||
|
||||
|
||||
def _combo_lines(doc: dict, key: str) -> list[dict[str, Any]]:
|
||||
"""참조 줄 `{참조, 수량, 메모}` · 로직 줄 `{로직, 입력값, 메모, 수량}`(51-11) — 검사는
|
||||
일위대가와 같은 길(`labor.clean` · 같은 로직 · 같은 참조 두 번 · 입력값) · 수량 기본 {손: 1}."""
|
||||
@@ -217,12 +245,14 @@ def create(kind: str, doc: dict[str, Any]) -> dict[str, Any]:
|
||||
|
||||
|
||||
def summary(folder: Path, kind: str, key: str, expand: Expand | None = None) -> dict[str, Any]:
|
||||
"""층 목록 한 줄에 붙일 것 — `{제목, 단위}` · `expand` 면 1 단위 기준 계(`기준금액` · 51-4)."""
|
||||
"""층 목록 한 줄에 붙일 것 — `{제목, 단위, 구분, 상세구분, 연결}`(51-12) · `expand` 면
|
||||
1 단위 기준 계(`기준금액` · 51-4)."""
|
||||
try:
|
||||
doc = json.loads((Path(folder) / kind / f"{key}.json").read_bytes())
|
||||
doc = filled(kind, json.loads((Path(folder) / kind / f"{key}.json").read_bytes()))
|
||||
except (OSError, ValueError):
|
||||
return {}
|
||||
out = {"제목": doc.get("이름"), "단위": doc.get("단위")}
|
||||
keep = ("구분", "상세구분", "연결")
|
||||
out = {"제목": doc.get("이름"), "단위": doc.get("단위"), **{k: doc.get(k) for k in keep}}
|
||||
if expand is not None:
|
||||
layer, owner = where(folder)
|
||||
base = expand({"층": layer, "주인": owner, "키": key}).get("기준") or {}
|
||||
|
||||
@@ -309,6 +309,7 @@ async def read_layer_template(
|
||||
raise HTTPException(status_code=404, detail="양식을 찾을 수 없습니다.")
|
||||
found["층"] = layer
|
||||
found["출처"] = layers.read_manifest(folder).get(f"{kind}/{name}")
|
||||
found["문서"] = refs.filled(kind, found["문서"]) # 옛 서고 문서 구분 · 상세구분(51-12)
|
||||
return found
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user