Merge remote-tracking branch 'origin/sub_laptop_2' into sub_laptop_7

This commit is contained in:
2026-10-04 18:28:00 +09:00
70 changed files with 4442 additions and 1588 deletions
+39 -1
View File
@@ -9,6 +9,7 @@
from __future__ import annotations
import json
from datetime import datetime
from pathlib import Path
from typing import Any
@@ -85,10 +86,47 @@ def items(folder: Path) -> list[dict[str, Any]]:
k: (head or r.get("열")) if r.get(k) else None for k in ("도번", "면적번", "재료번")
},
}
out.append({"key": r.get("키"), **{k: r.get(k) for k in ITEM_FIELDS}, "names": names})
out.append(
{
"key": r.get("키"),
**{k: r.get(k) for k in ITEM_FIELDS},
"names": names,
**_list_extras(Path(folder), str(r.get("열"))),
}
)
return out
def _list_extras(folder: Path, col: str) -> dict[str, Any]:
"""목록 칸(39-5) — `수정일` = 도면 · 면적산출 · 일위대가 파일 시각 · `labor` = 일위대가 문서의
번호 · 담은 로직 수 · 합계(`계산값.반영합.계` · 없으면 null) — 파일이 없으면 칸 없음."""
stamps: dict[str, str] = {}
for kind in ("structure", "area", "labor"):
path = folder / kind / f"{col}.json"
if path.is_file():
stamps[kind] = datetime.fromtimestamp(path.stat().st_mtime).isoformat(
timespec="seconds"
)
labor = None
path = folder / "labor" / f"{col}.json"
if path.is_file():
try:
doc = json.loads(path.read_bytes())
except ValueError:
doc = {}
total = ((doc.get("계산값") or {}).get("반영합") or {}).get("계")
try:
total = None if total is None or isinstance(total, bool) else float(total)
except (TypeError, ValueError):
total = None # 수 아닌 값(옛 꼴)은 「—」
labor = {
"번호": doc.get("일위대가번"),
"로직수": len(doc.get("담은로직") or []),
"합계": total,
}
return {"수정일": stamps, "labor": labor}
def _fresh_id(want: str, used: set[str]) -> str:
out, n = want, 2
while out in used: