diff --git a/A00_Common/line_stack_edit.ts b/A00_Common/line_stack_edit.ts index b68e5e8d6..61f53f667 100644 --- a/A00_Common/line_stack_edit.ts +++ b/A00_Common/line_stack_edit.ts @@ -10,6 +10,7 @@ * 고르면 줄이 생김(닫으면 안 생김) · 있는 줄 = 자원 이름 단추 * ========================================================================== */ +import type { PlacedTable } from "../common_util/common_util_show_digits"; import { createBadge } from "@ui/ui_template_badge"; import { createButton, createIconButton, setUiDiff } from "@ui/ui_template_button"; import { createRowMenu } from "@ui/ui_template_context_menu"; @@ -93,6 +94,8 @@ export interface EditHooks { lists?: (given: Record) => Record | null; /** 845-2 표 한 칸 읽기(캐시) — 「줄 따름」 값의 고른 줄 단위 */ look?: TableLook; + /** 859-3 캐시 표 통째 — 표 값의 원문 글자 자리(보이는 자리) */ + tableCache?: (ref: string) => PlacedTable | undefined; /** 846-2 그 기계 작업량 줄 */ work?: (machine: string) => WorkSpec[]; /** 848-3 ① 위 층 고침(SK 읽기 답 `위덮음` · M01 = 없음) */ diff --git a/A00_Common/line_stack_out.ts b/A00_Common/line_stack_out.ts index 12e322924..3873a1e92 100644 --- a/A00_Common/line_stack_out.ts +++ b/A00_Common/line_stack_out.ts @@ -59,8 +59,9 @@ import { } from "../common_util/common_util_line_stack_unit"; import { workAt } from "../common_util/common_util_line_stack_work"; import { workKey } from "../common_util/common_util_formula_doc_work"; +import { showValue } from "../common_util/common_util_show_digits"; import { partName, partUnit } from "../common_util/common_util_machine_symbol_name"; -import { katexNode, symTex, tex, txt, valTex, type TexCtx } from "./line_stack_tex"; +import { katexNode, symTex, tex, txt, type TexCtx } from "./line_stack_tex"; import { lt } from "./line_stack_text"; import { workQty, workRows } from "./line_stack_work"; @@ -143,9 +144,14 @@ function rows( const alias = tableAlias(doc); // 표 값 기호 화면 이름(요구 683) const machine = doc.부품?.갈래 === "기계경비식"; // 845-2 한 줄 분수 한 층(중간 줄로 나눔) const taken = new Set([...vars.keys(), ...lines.keys(), ...Object.values(alias)]); - /** 수 글 — 고르기 · 코드 값(S_ · 직종 1048 등)은 쉼표 없이 */ + /** 수 글 — 고르기 · 코드 값(S_ · 직종 1048 등)은 쉼표 없이 · 그 밖 = 보이는 자리 규칙(859-3) */ const code = (id: string): boolean => /^S(_|$)/.test(id); - const numText = (id: string, v: number): string => (code(id) ? String(v) : eqText(v)); + const numText = (id: string, v: unknown, u?: string): string => { + if (code(id)) return String(v); + return showValue(doc, id, v, vals, h.cache.tableOf, u); + }; + /** 조판 값 글(천 자리 쉼표 = TeX 「{,}」) */ + const show = (id: string, v: unknown): string => numText(id, v).replace(/,/g, "{,}"); /** 식 줄 「기호 = 기호식 = 값식 = 결과 단위」 — 같은 꼴이 이어지면 한 번만(만약이 수 하나를 탄 줄) */ const formula = ( id: string, @@ -156,13 +162,13 @@ function rows( more: Partial, ): (string | HTMLElement)[] => { const res = isNum(v) - ? katexNode(`${code(id) ? String(v) : valTex(v)}\\ ${u ? txt(u) : ""}`) // 단위 글 = TeX 안전(「%」 주석 · 「^」 첨자 막음) + ? katexNode(`${show(id, v)}\\ ${u ? txt(u) : ""}`) // 단위 글 = TeX 안전(「%」 주석 · 「^」 첨자 막음) : typeof v === "string" // 글 값(기계 원문번호 등 · 838-3) = 그 글 · 기계면 이름 ? el("span", { text: machineText(v, () => h.redraw?.()) ?? v }) : missing(a, id); const sym = tex(n, { side: "sym", vals: vs, alias, ...more }); - const val = tex(n, { side: "val", vals: vs, alias, ...more }); - const same = isNum(v) && val === valTex(v); + const val = tex(n, { side: "val", vals: vs, alias, show, ...more }); + const same = isNum(v) && val === show(id, v); return [ katexNode(symTex(alias[id] ?? id)), ...(sym === val ? [] : [" = ", katexNode(sym)]), @@ -342,7 +348,7 @@ function rows( const glue = (...xs: (string | HTMLElement)[]): HTMLElement => el("span", { className: "lstk-pack", children: xs.filter((x) => x !== "") }); // 846-2 작업량 — 「시간당 작업량」 줄 먼저 · 수량 = 「÷ 시간당 작업량」 - const wq = (): HTMLElement[] | null => workQty(doc, qty, w, scope, alias); // 줄마다 새 요소 + const wq = (): HTMLElement[] | null => workQty(doc, qty, w, scope, alias, show); // 줄마다 새 요소 const byWork = wq() !== null; const workHead = (): void => { if (!w) return; @@ -359,8 +365,8 @@ function rows( glue( " × ", mu.wrap && qn - ? katexNode(`\\left(${tex(qn, { side: "val", vals: scope, inline: true, cost, alias })}\\right)`) // prettier-ignore - : exprNode(qty, "val", scope, true, cost, { alias }), + ? katexNode(`\\left(${tex(qn, { side: "val", vals: scope, inline: true, cost, alias, show })}\\right)`) // prettier-ignore + : exprNode(qty, "val", scope, true, cost, { alias, show }), mu.qty ? ` ${mu.qty}` : "", ), ]; @@ -383,7 +389,7 @@ function rows( const by = (line as { 비목곱?: Record }).비목곱?.[c]; // 848-7 그 비목만 더 곱함 const byNode = by ? nodeOf(by) : null; const times = byNode - ? [glue(" × ", katexNode(`\\left(${tex(byNode, { side: "val", vals: scope, inline: true, cost: c, alias })}\\right)`))] // prettier-ignore + ? [glue(" × ", katexNode(`\\left(${tex(byNode, { side: "val", vals: scope, inline: true, cost: c, alias, show })}\\right)`))] // prettier-ignore : []; push({ h: [`${COST_SHOW[c]} : `, glue(`${eqText(bundle[c])}${priceUnit}`), ...qtyNode(c), ...times, ` = ${one(part)} ${AMOUNT_UNIT}`], // prettier-ignore @@ -399,9 +405,9 @@ function rows( ? [ exprNode(line.단가, "sym", scope, true, undefined, { place, alias }), " = ", - exprNode(line.단가, "val", scope, true, undefined, { alias }), + exprNode(line.단가, "val", scope, true, undefined, { alias, show }), ] - : [glue(exprNode(line.단가, "val", scope, true, undefined, { alias }), priceUnit)]; + : [glue(exprNode(line.단가, "val", scope, true, undefined, { alias, show }), priceUnit)]; const c = String(line.비목); const bare = !!line.합밖 && !line.비목; // 합 밖 소계(810-2) = 글에만 금액 · 비목 칸 빈칸 workHead(); @@ -462,7 +468,7 @@ function rows( push({ h: [ katexNode(symTex(doc.결과)), - ` = ${isNum(r) ? `${eqText(r)} ${doc.결과단위 ?? ""}` : "—"}`, + ` = ${isNum(r) ? `${numText(doc.결과, r, String(doc.결과단위 ?? ""))} ${doc.결과단위 ?? ""}` : "—"}`, ], cls: "total", }); diff --git a/A00_Common/line_stack_rows.ts b/A00_Common/line_stack_rows.ts index d7a1d1548..024a8d5eb 100644 --- a/A00_Common/line_stack_rows.ts +++ b/A00_Common/line_stack_rows.ts @@ -10,6 +10,7 @@ * 표 값(804-3) = [표 · 칸] 단추 → 표 고르기 창(`line_stack_pick.ts`) · 값 칸 누름 = 그 줄 · 칸(`pickCell`) * ========================================================================== */ +import { showValue } from "../common_util/common_util_show_digits"; import { createButton, createIconButton } from "@ui/ui_template_button"; import { eqText } from "@ui/ui_template_equation"; import { el, showToast } from "@ui/ui_template_elements"; @@ -162,7 +163,11 @@ export function buildBlock( const v = vals[id]; const mach = machineText(v, () => h.change(() => undefined)); // 838-3 기계 원문번호 = 이름 if (mach) return mach; - if (isNum(v) || typeof v === "string") return `${eqText(v)} ${unitOf(id)}`.trim(); + if (isNum(v)) { + const t = showValue(d, id, v, vals, h.tableCache); // 859-3 보이는 자리 규칙(표 = 원문 글자 자리) + return `${t} ${unitOf(id)}`.trim(); + } + if (typeof v === "string") return `${eqText(v)} ${unitOf(id)}`.trim(); if (v && typeof v === "object") { const key = vars.get(id)?.연결?.키; // 845-2 묶음 값 = 그 문서 결과 단위(원/시간 등) const u = unitOf(id) || unitText(key ? h.subDoc(key)?.결과단위 : ""); diff --git a/A00_Common/line_stack_screen.ts b/A00_Common/line_stack_screen.ts index 693d37345..2ed9e58c2 100644 --- a/A00_Common/line_stack_screen.ts +++ b/A00_Common/line_stack_screen.ts @@ -433,6 +433,7 @@ export function createStackScreen(opt: StackScreenOptions) { calc: calcSub, lists: (g) => listsOf((q) => cache.links.element(q), g), look: (p) => cache.links.table(p), + tableCache: (k) => cache.tableOf(k), work: (m) => machineWork((q) => cache.links.element(q), m), upper, ctlEdit: !cp && edit(), // 848-3 M01 기초 = 시스템 관리자 diff --git a/A00_Common/line_stack_tex.ts b/A00_Common/line_stack_tex.ts index 78d01d1a3..cffccd88b 100644 --- a/A00_Common/line_stack_tex.ts +++ b/A00_Common/line_stack_tex.ts @@ -27,6 +27,8 @@ export interface TexCtx { decided?: boolean; /** 남은 분수 층(845-2 — 0 이면 안쪽 ÷ 는 한 줄 · 없음 = 끝없음) */ frac?: number; + /** 859-3 값 식의 기호 값 글(보이는 자리 규칙 · TeX 쉼표 「{,}」) — 없으면 `valTex` */ + show?: (id: string, v: unknown) => string; } const HIDE = new Set(["반올림", "올림", "버림"]); @@ -101,8 +103,10 @@ export function tex(n: Node, c: TexCtx): string { const id = c.alias?.[n[1]] ?? n[1]; if (c.side === "sym") return symTex(id); let v = c.vals[n[1]]; - if (v && typeof v === "object" && c.cost) v = (v as Values)[c.cost]; - return v === null || v === undefined || typeof v === "object" ? miss(symTex(id)) : valTex(v); + const part = !!v && typeof v === "object" && !!c.cost; // 묶음 값의 비목(단가 · 자료 그대로) + if (part) v = (v as Values)[c.cost!]; + if (v === null || v === undefined || typeof v === "object") return miss(symTex(id)); + return c.show && isNum(v) && !part ? c.show(n[1], v) : valTex(v); } case "field": { const [, of, key] = n; diff --git a/A00_Common/line_stack_work.ts b/A00_Common/line_stack_work.ts index 179fd06c3..73a69390a 100644 --- a/A00_Common/line_stack_work.ts +++ b/A00_Common/line_stack_work.ts @@ -11,8 +11,8 @@ import { createBadge } from "@ui/ui_template_badge"; import { el } from "@ui/ui_template_elements"; -import { eqText } from "@ui/ui_template_equation"; import { varId, type FormulaDoc, type Node } from "../common_util/common_util_formula_doc"; +import { showDigits, showValue } from "../common_util/common_util_show_digits"; import { calcDoc, isNum, @@ -30,7 +30,7 @@ import { restOfQty, workUnit, } from "../common_util/common_util_line_stack_work"; -import { katexNode, symTex, tex, txt, valTex } from "./line_stack_tex"; +import { katexNode, symTex, tex, txt } from "./line_stack_tex"; import { lt, type LsKey } from "./line_stack_text"; export interface WorkRow { @@ -51,7 +51,15 @@ export function workTag(kind: string, title = ""): HTMLElement { const chain = (...xs: string[]): (string | HTMLElement)[] => xs.flatMap((x, i) => (i ? [" = ", katexNode(x)] : [katexNode(x)])); const unitTex = (u: string): string => (u ? `\\ ${txt(u)}` : ""); -const amount = (v: unknown, u: string): string => `${valTex(v)}${unitTex(u)}`; +/** 859-3 시간당 작업량 Q = 소수 3 자리(건설 8-1 [주]① 계산값의 맺음) */ +const workText = (v: unknown): string => showDigits(v, "식", "Q"); +const workAmount = (v: unknown, u: string): string => + `${workText(v).replace(/,/g, "{,}")}${unitTex(u)}`; +/** 859-3 문서 값 글(보이는 자리 규칙 · TeX 쉼표) */ +const docShow = + (doc: FormulaDoc, vals: Values) => + (id: string, v: unknown): string => + showValue(doc, id, v, vals).replace(/,/g, "{,}"); /** 작업량 틀 풀이 — 값 줄 + 결과 식 줄(없으면 빈 목록) */ export function hourlyRows( @@ -64,13 +72,15 @@ export function hourlyRows( const vals = (a.값 ?? {}) as Values; const vars = new Map((tpl.변수 ?? []).map((v) => [varId(v), v])); const unit = (id: string): string => workUnit(shownUnitOf(vars.get(id), vals, look)); - const pack = parts.uses.map((id) => - katexNode(`${symTex(id)} = ${isNum(vals[id]) ? amount(vals[id], unit(id)) : txt("—")}`), + const show = docShow(tpl, vals); + const pack = parts.uses.map( + (id) => + katexNode(`${symTex(id)} = ${isNum(vals[id]) ? `${show(id, vals[id])}${unitTex(unit(id))}` : txt("—")}`), // prettier-ignore ); const res = vals[parts.id]; const sym = tex(parts.node, { side: "sym", vals, frac: 1 }); - const val = tex(parts.node, { side: "val", vals, frac: 1 }); - const end = isNum(res) ? amount(res, workUnit(tpl.결과단위)) : txt("—"); + const val = tex(parts.node, { side: "val", vals, frac: 1, show }); + const end = isNum(res) ? workAmount(res, workUnit(tpl.결과단위)) : txt("—"); return [ ...(pack.length ? [{ h: pack, cls: "packs" }] : []), { h: chain(symTex(parts.id), sym, val, end), cls: "work" }, @@ -99,14 +109,14 @@ export function workRows(w: WorkInfo, c: WorkCtx): WorkRow[] { c.miss(); } const tag = workTag(w.꼴, tpl?.이름 ?? w.율); - if (!tpl) return [{ h: [tag, `${head} = `, isNum(w.값) ? `${eqText(w.값)} ${u}`.trim() : lt("Work_Wait")] }]; // prettier-ignore + if (!tpl) return [{ h: [tag, `${head} = `, isNum(w.값) ? `${workText(w.값)} ${u}`.trim() : lt("Work_Wait")] }]; // prettier-ignore const a = calcDoc(tpl, c.links!, w.변수 ?? {}, [], new Map(), {}); const name = el("span", { className: "lstk-hint", text: tpl.이름 ?? w.율 }); return [{ h: [tag, name] }, ...hourlyRows(tpl, a, c.look)]; } if (!isNum(w.값)) return []; const tag = workTag(w.꼴 || "일당"); - const res = amount(w.값, u); + const res = workAmount(w.값, u); const parts = w.꼴 === "일당" ? dailyParts(w.율) : null; if (parts) { const val = (n: Node): string => tex(n, { side: "val", vals: c.vals, inline: true }); @@ -130,13 +140,14 @@ export function workQty( w: WorkInfo | null, scope: Values, alias?: Record, + show?: (id: string, v: unknown) => string, ): HTMLElement[] | null { if (!w || !isNum(w.값) || w.값 <= 0) return null; const got = restOfQty(doc, qty); if (!got) return null; - const by = katexNode(`{}\\div ${amount(w.값, workUnit(w.단위))}`); // {} = 두 항 사이 ÷ 간격 + const by = katexNode(`{}\\div ${workAmount(w.값, workUnit(w.단위))}`); // {} = 두 항 사이 ÷ 간격 if (!got.rest) return [by]; - return [by, katexNode(`\\times ${tex(got.rest, { side: "val", vals: scope, inline: true, alias })}`)]; // prettier-ignore + return [by, katexNode(`\\times ${tex(got.rest, { side: "val", vals: scope, inline: true, alias, show: show ?? docShow(doc, scope) })}`)]; // prettier-ignore } const nameOf = (doc: FormulaDoc, id: string): string => diff --git a/B05_Profile/B05_Profile_Engine_Sections_Node.py b/B05_Profile/B05_Profile_Engine_Sections_Node.py index 58052d8f0..e8e826693 100644 --- a/B05_Profile/B05_Profile_Engine_Sections_Node.py +++ b/B05_Profile/B05_Profile_Engine_Sections_Node.py @@ -47,7 +47,7 @@ def plan_structure(item: Any) -> dict[str, Any]: def structure_table() -> tuple[list[dict[str, Any]], dict[str, Any]]: """구조물 종류(`/projects/structure-types` 꼴) · 정의(화면 `useCatalogDefinition` 꼴).""" from B05_Profile.B05_Profile_Structures_Schema import _read_definition, _stamp - from M02_MasterTemplete.StructOptions.M02_SO_Options import with_visible + from M01_MasterData.StructOptions.M01_SO_Options import with_visible types = [item.model_dump(mode="json") for item in with_visible().types] return types, {"types": types, **_read_definition(*_stamp())} diff --git a/B05_Profile/B05_Profile_Structures_Repository.py b/B05_Profile/B05_Profile_Structures_Repository.py index 7629a36a4..37c49f8e0 100644 --- a/B05_Profile/B05_Profile_Structures_Repository.py +++ b/B05_Profile/B05_Profile_Structures_Repository.py @@ -18,7 +18,7 @@ from B05_Profile.B05_Profile_Structures_Schema import ( structure_type_map, ) from common_util.common_util_json import atomic_write_json -from M02_MasterTemplete.StructOptions.M02_SO_Options import hidden_keys +from M01_MasterData.StructOptions.M01_SO_Options import hidden_keys STRUCTURES_FILE_NAME = "structures.json" _STAGE_DIR = os.path.join("B05_Profile", "route") diff --git a/B05_Profile/B05_Profile_Structures_Router.py b/B05_Profile/B05_Profile_Structures_Router.py index 7a99051da..ca252531d 100644 --- a/B05_Profile/B05_Profile_Structures_Router.py +++ b/B05_Profile/B05_Profile_Structures_Router.py @@ -51,7 +51,7 @@ from common_util.common_util_route_follow import ( from common_util.common_util_storage import resolve_stored_project_path from common_util.common_util_structure_station import SAME_STATION_M, plan_stations from config.config_db import get_db_pool -from M02_MasterTemplete.StructOptions.M02_SO_Options import TypesWithVisible, with_visible +from M01_MasterData.StructOptions.M01_SO_Options import TypesWithVisible, with_visible logger = logging.getLogger(__name__) diff --git a/B05_Profile/B05_Profile_Structures_Schema.py b/B05_Profile/B05_Profile_Structures_Schema.py index 0a2f51fea..9d813e978 100644 --- a/B05_Profile/B05_Profile_Structures_Schema.py +++ b/B05_Profile/B05_Profile_Structures_Schema.py @@ -1,6 +1,6 @@ """B05 구조물 타입 레지스트리·인스턴스 검증 모델. -구조물 타입 정의는 코드가 아니라 데이터(M02 마스터 `resources/master_template/구조물정의.json` +구조물 타입 정의는 코드가 아니라 데이터(M01 마스터 `resources/master_data/구조물정의/구조물정의.json` `types` · PLAN 48-1)다. 리스트가 바뀌어도 코드를 고치지 않도록 분리했고, 프론트는 `GET /structure-types`로 같은 정본을 받는다. 정의 틀 = `docs/raw/M02_구조물옵션정의/정의_틀.md`. @@ -27,7 +27,8 @@ STRUCTURE_SIDES = ("left", "right", "center", "cross") DEFINITION_PATH = os.path.join( os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "resources", - "master_template", + "master_data", + "구조물정의", "구조물정의.json", ) @@ -159,8 +160,8 @@ def is_station_planting_type(item: StructureType) -> bool: return row is not None and row["station"] != "none" -#: 지난 판 정의(`판_N.json`) 폴더 — 정본 옆(M02 `M02_SO_Definition.HISTORY` 와 같은 이름) -HISTORY_DIRNAME = "구조물정의_이력" +#: 지난 판 정의(`판_N.json`) 폴더 — 정본 옆(M01 `M01_SO_Definition.HISTORY` 와 같은 이름) +HISTORY_DIRNAME = "이력" def registry_schema_version() -> int: diff --git a/B05_Profile/logic/B05_Profile_UI_Structures_Define.ts b/B05_Profile/logic/B05_Profile_UI_Structures_Define.ts index 752627e1b..47e6c2573 100644 --- a/B05_Profile/logic/B05_Profile_UI_Structures_Define.ts +++ b/B05_Profile/logic/B05_Profile_UI_Structures_Define.ts @@ -2,7 +2,7 @@ * B05_Profile_UI_Structures_Define.ts * 구조물 정의 → 「구조물 배치」 칸 모양 (PLAN 48-3 · 48-4) — 화면 요소 없는 순수 규칙. * - * 정의(`resources/master_template/구조물정의.json` · GET /structure-types 가 실어 줌)를 읽어 + * 정의(`resources/master_data/구조물정의/구조물정의.json` · GET /structure-types 가 실어 줌)를 읽어 * 칸 차례 · 격자 · 안 씀 · 규칙(상위 값 → 하위 선택지 · 보이기 · 기본값)을 낸다. 틀 = * `docs/raw/M02_구조물옵션정의/정의_틀.md`. 선택지를 줄이면(숨김) 옛 값은 그 값만 남겨 보임. * 그리기는 `_Structures_Panel_Options`(레지스트리 칸) · `_Structures_Define_Form`(시설 폼 칸). diff --git a/B07_DesignDetail/B07_DesignDetail_Engine_Cad_CulvertNote.py b/B07_DesignDetail/B07_DesignDetail_Engine_Cad_CulvertNote.py index 26e85673f..ffd2baa45 100644 --- a/B07_DesignDetail/B07_DesignDetail_Engine_Cad_CulvertNote.py +++ b/B07_DesignDetail/B07_DesignDetail_Engine_Cad_CulvertNote.py @@ -243,7 +243,7 @@ def with_option_lines(things: list[Thing]) -> list[Thing]: return things try: # 지연 import — M02 정의 저장소가 B07 엔진 import 차례에 끼지 않게 - from M02_MasterTemplete.StructOptions.M02_SO_Options import with_visible + from M01_MasterData.StructOptions.M01_SO_Options import with_visible payload = { "things": [ diff --git a/B08_Quantity/B08_Quantity_Router_Summary.py b/B08_Quantity/B08_Quantity_Router_Summary.py index 2e0051722..011bfb44d 100644 --- a/B08_Quantity/B08_Quantity_Router_Summary.py +++ b/B08_Quantity/B08_Quantity_Router_Summary.py @@ -52,15 +52,15 @@ from B06_Section.B06_Section_Repository import ( ) from B08_Quantity.B08_Quantity_Router_Hydro import _project_root from B08_Quantity.B08_Quantity_Summary_Sheet import _linked, _Sheet, unlinked_facilities -from common_util.common_util_structure_catalog import type_ids_with from common_util.common_util_drainage_pipes import pipe_points_path_in, read_pipe_points_file +from common_util.common_util_structure_catalog import type_ids_with from common_util.common_util_summary_item import GROUP_JOIN from config.config_db import get_db_pool +from M01_MasterData.StructOptions import M01_SO_Definition as definition from M02_MasterTemplete import M02_Item_Snapshot as snapshots from M02_MasterTemplete import M02_Table_Fill as fill from M02_MasterTemplete import M02_Template_Layers as layers from M02_MasterTemplete.M02_Table_Fill_Spec import soil_tiers_from_designs -from M02_MasterTemplete.StructOptions import M02_SO_Definition as definition router = APIRouter(prefix="/api/projects", tags=["B08 Summary"]) diff --git a/B09_Estimation/B09_Estimation_Sangeun_Text.py b/B09_Estimation/B09_Estimation_Sangeun_Text.py index 72e5f7200..db203b43a 100644 --- a/B09_Estimation/B09_Estimation_Sangeun_Text.py +++ b/B09_Estimation/B09_Estimation_Sangeun_Text.py @@ -41,11 +41,14 @@ def _won(v: Any) -> str: return GAP if v is None else f"{v:,.0f}" -def _word(whole: Any, name: str, value: Any) -> str: - """값 글 — 수 = 화면 수 꼴 · 기계 · 직종 원문번호 = 「이름 규격」(157-3 · 85-1 도우미).""" +def _word(whole: Any, name: str, value: Any, answer: Any = None, key: str = "") -> str: + """값 글 — 수 = 화면 수 꼴(859-3 보이는 자리 · 기호 `key`) · + 기계 · 직종 원문번호 = 「이름 규격」(157-3 · 85-1 도우미).""" if isinstance(value, str): return labor_inputs._labels(whole, {"이름": name, "고르기": [value]}).get(value, value) - return mdt.eq_text(value) if _dec(value) is not None else str(value) + if _dec(value) is None: + return str(value) + return mdt.eq_text(value) if answer is None else _show(answer, key, value) # ── 머리(입력 · 공식) ──────────────────────────────────────────────── @@ -90,7 +93,8 @@ class _Head: return "값 없음" if isinstance(v, dict): return " · ".join(f"{c} {mdt.eq_text(v.get(c))}" for c in mdt.COSTS) - return " ".join(x for x in (_word(self.whole, self.names.get(i, i), v), self.unit(i)) if x) + word = _word(self.whole, self.names.get(i, i), v, self.answer, i) + return " ".join(x for x in (word, self.unit(i)) if x) def formula(self, i: str, text: str) -> str: """「이름 = 이름식 = 값식 = 값 단위」 — 같은 글이 이어지면 한 번만.""" @@ -104,7 +108,9 @@ class _Head: valued = md.text_of(_swap(node, self._num)) parts += [named, valued] v = self.values.get(i) - bare = mdt.eq_text(v) if _dec(v) is not None else f"'{v}'" if isinstance(v, str) else None + bare = f"'{v}'" if isinstance(v, str) else None + if _dec(v) is not None: + bare = _show(self.answer, i, v) out = [parts[0]] for p in parts[1:]: # 같은 글 · 값 그대로인 식 = 한 번만(화면 공식 줄) if p and p != out[-1] and p != bare: @@ -115,7 +121,7 @@ class _Head: def _num(self, name: str): v = self.values.get(name) d = _dec(v) - return ("var", mdt.eq_text(d)) if d is not None else None + return ("var", _show(self.answer, name, v)) if d is not None else None def lines(self, times: Decimal) -> list[str]: doc = self.doc @@ -180,9 +186,14 @@ def _qty(answer: Any, n: int, units: dict, times: Decimal, rate: Decimal | None) raw = (answer.ans.get("줄") or [{}] * (n + 1))[n].get("수량") node = _decide(mdt.node_of(((answer.doc.get("금액") or [])[n]).get("수량")), answer) values = answer.ans.get("값") or {} - shown = mdt.eq_text(raw) + line = (answer.doc.get("금액") or [])[n] + look = _look(answer) + shown = mdt.shown(answer.doc, mdt.node_of(line.get("수량")), raw, look, look.run.links) if node is not None and not mdt.is_atom(node): - put = lambda s: ("var", mdt.eq_text(values[s])) if _dec(values.get(s)) is not None else None # noqa: E731 + + def put(s: str): + return ("var", _show(answer, s, values[s])) if _dec(values.get(s)) is not None else None + shown = f"({md.text_of(_swap(_bare(node), put))})" text = mdt._u(shown, units["qty"]) if times != 1: @@ -192,13 +203,25 @@ def _qty(answer: Any, n: int, units: dict, times: Decimal, rate: Decimal | None) return text +def _look(answer: Any) -> Any: + """셈 답 값 읽개(`master_doc_text._Look`) — 답마다 한 번.""" + look = getattr(answer, "_look", None) + if look is None: + look = answer._look = mdt._Look(answer.doc, answer.ans, ml.Links(answer.whole, answer.docs)) + return look + + +def _show(answer: Any, name: str, v: Any) -> str: + """기호 값 글 — 859-3 보이는 자리 규칙(화면 줄 쌓기와 같음 · `master_doc_text.shown`).""" + look = _look(answer) + return mdt.shown(answer.doc, ("var", name), v, look, look.run.links) + + def _decide(node: Any, answer: Any) -> Any: """만약 = 걸린 갈래만(화면 `decide` · 조건 = 셈 답 값 · `master_doc_text._Look`).""" if node is None: return None - look = getattr(answer, "_look", None) - if look is None: - look = answer._look = mdt._Look(answer.doc, answer.ans, ml.Links(answer.whole, answer.docs)) + look = _look(answer) def walk(n: Any) -> Any: if not isinstance(n, tuple): @@ -259,7 +282,8 @@ def _extra_text(ln: dict) -> str: value, money = ln["price"][part], ln[part] if ln.get("unit") == "%" and ln.get("qty"): base = Decimal(str(value)) * 100 / Decimal(str(ln["qty"])) - return f"{head}{mdt.eq_text(base)} × {mdt.eq_text(ln['qty'])} % = {_amount(money)}" + base_text = mdt.mdd.show(base, "식", "", "원") # 859-3 원 단위 중간 값 + return f"{head}{base_text} × {mdt.eq_text(ln['qty'])} % = {_amount(money)}" return f"{head}{mdt.eq_text(value)} = {_amount(money)}" diff --git a/M01_MasterData/M01_MasterData_Store_Make.py b/M01_MasterData/M01_MasterData_Store_Make.py index c9f868711..b7301fc8d 100644 --- a/M01_MasterData/M01_MasterData_Store_Make.py +++ b/M01_MasterData/M01_MasterData_Store_Make.py @@ -319,12 +319,10 @@ def logic_new(logic: dict, owner: str = OWNERS[0], source: str = "") -> dict: def logic_copy(key: str, 이름: str = "", owner: str = OWNERS[0], more: dict | None = None) -> dict: - """본떠 만들기 = [복사/생성] — 원본 문서를 새 자체 기초로 복제(정본도 본뜸) · 비고 끝에 본뜬 키 · + """본떠 만들기 = [복사/생성] — 원본 문서를 새 자체 기초로 복제(원본과 안 이어짐 · 비고 그대로) · `more` = 기본정보 창에서 고친 원문번호 · 결과단위 · 출처(빈 글은 원본 그대로).""" _, doc = doc_store.find(key) - row = doc_store.head_of(doc) - note = " · ".join(x for x in (str(row.get("비고") or ""), f"{key} 를 본뜸") if x) - copy = {**row, "비고": note, **{k: v for k, v in (more or {}).items() if v}} + copy = {**doc_store.head_of(doc), **{k: v for k, v in (more or {}).items() if v}} if 이름: copy["이름"] = 이름 return logic_new(copy, owner, key) diff --git a/M01_MasterData/M01_MasterData_UI_Page.ts b/M01_MasterData/M01_MasterData_UI_Page.ts index b25f37b62..72981087e 100644 --- a/M01_MasterData/M01_MasterData_UI_Page.ts +++ b/M01_MasterData/M01_MasterData_UI_Page.ts @@ -1,7 +1,7 @@ /* ============================================================================= * M01_MasterData_UI_Page.ts * 마스터 요소 화면 — 좌측 도킹 패널(컨테이너: 인력·재료·기계·소요량·계수·환율·요율·단가산출 로직) - * · 일위대가 조합은 M02 마스터 템플릿(PLAN 27-2b) · 구조물 옵션 정의(716-1 · 화면은 M02 `StructOptions/`) + * · 일위대가 조합은 M02 마스터 템플릿(PLAN 27-2b) · 구조물 옵션 정의(716-1 · 859-5 화면 · 서버 = `StructOptions/`) * / 우측 요소 표 · 표 목록 · 로직 편집 · 옵션 정의 · 별칭 모아 보기(815-2) · * 주소 `?open=로직|옵션|별칭` = 그 칸을 고른 채 열림(716-2) * diff --git a/M01_MasterData/M01_MasterData_UI_Side.ts b/M01_MasterData/M01_MasterData_UI_Side.ts index ab5a94c1a..c12cce4e6 100644 --- a/M01_MasterData/M01_MasterData_UI_Side.ts +++ b/M01_MasterData/M01_MasterData_UI_Side.ts @@ -2,7 +2,7 @@ * M01_MasterData_UI_Side.ts * 왼쪽 패널 — 공용 접기 컨테이너(`ui-collapsible ui-sidebar-section`) * 인력 · 재료 · 기계 · 소요량 · 계수 · 환율 · 요율 · 단가산출 로직(일위대가 조합은 M02 · PLAN 27-2b) - * ─ 구분선 ─ 구조물 옵션 정의(716-1 · 화면 코드는 M02 `StructOptions/` 그대로 · 입구만 여기) + * ─ 구분선 ─ 구조물 옵션 정의(716-1 · 화면 코드 = `StructOptions/`(859-5) · 입구만 여기) * · 별칭 모아 보기(815-2 · 누르면 본 칸에 별칭이 적힌 줄 · 승인 대기 · `M01_MasterData_UI_Alias`) * 펼치면 하위 목록(거름 · 파일) · 환율/요율은 누르면 바로 표 · 로직은 안에 로직 목록 * ========================================================================== */ @@ -11,10 +11,7 @@ import { createSelectField, el, showToast } from "@ui/ui_template_elements"; import { attachCollapsible } from "@ui/ui_template_collapsible"; import { createDivider } from "@ui/ui_template_divider"; import { currentLanguageIndex, t as L } from "@ui/ui_template_locale"; -import { - buildOptionsSection, - type OptionsSectionOptions, -} from "../M02_MasterTemplete/StructOptions/M02_SO_Options"; +import { buildOptionsSection, type OptionsSectionOptions } from "./StructOptions/M01_SO_Options"; import { ALIAS_TITLE, buildAliasBoard, type AliasRow } from "./M01_MasterData_UI_Alias"; import { fetchFiles, fetchSubsAll, type FileInfo, type SubInfo } from "./M01_MasterData_Api_Fetch"; import { tx } from "./M01_MasterData_UI_Logic_Text"; diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Api.ts b/M01_MasterData/StructOptions/M01_SO_Api.ts similarity index 73% rename from M02_MasterTemplete/StructOptions/M02_SO_Api.ts rename to M01_MasterData/StructOptions/M01_SO_Api.ts index a91a2578f..6df598c1a 100644 --- a/M02_MasterTemplete/StructOptions/M02_SO_Api.ts +++ b/M01_MasterData/StructOptions/M01_SO_Api.ts @@ -1,10 +1,14 @@ /* ============================================================================= - * M02_SO_Api.ts - * 구조물 정의 서버 호출 — 서버 = `M02_SO_Router.py`(마스터 템플릿 `구조물정의.json` 한 벌 · PLAN 48) + * M01_SO_Api.ts + * 구조물 정의 서버 호출 — 서버 = `M01_SO_Router.py`(마스터 템플릿 `구조물정의.json` 한 벌 · PLAN 48) * ========================================================================== */ -import { call } from "../M02_MasterTemplete_Api_Fetch"; -import type { StructDef } from "./M02_SO_Def_Model"; +import { call as callApi } from "../../common_util/common_util_m02_call"; +import type { StructDef } from "./M01_SO_Def_Model"; + +/** `/api/m01` 아래 길 부름 */ +const call = (path: string, init: RequestInit = {}): Promise => + callApi(path, init, "/m01"); /* --- 구조물 정의(PLAN 48 · 마스터 템플릿 `구조물정의.json` · 판 번호 · 이력) --- */ @@ -21,7 +25,7 @@ export const fetchStructureDef = (): Promise => call("/structure-defi export const saveStructureDef = (판: number, 정의: StructDef): Promise => call("/structure-definition", { method: "PUT", body: JSON.stringify({ 판, 정의 }) }); -/** 지난 판 목록(`구조물정의_이력/판_N.json`) */ +/** 지난 판 목록(`구조물정의/이력/판_N.json`) */ export const fetchStructureDefHistory = (): Promise => call("/structure-definition/history"); diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Check.py b/M01_MasterData/StructOptions/M01_SO_Check.py similarity index 98% rename from M02_MasterTemplete/StructOptions/M02_SO_Check.py rename to M01_MasterData/StructOptions/M01_SO_Check.py index 90cde5083..22daaf562 100644 --- a/M02_MasterTemplete/StructOptions/M02_SO_Check.py +++ b/M01_MasterData/StructOptions/M01_SO_Check.py @@ -7,7 +7,7 @@ 그림이 늘 기본값을 씀 · 앞 판에서 이미 숨긴 칸은 그대로 둠) - 앞 판이 없으면(옛 판 읽기) 꼴만 검사 - 앞 판과 비교 — 종류 지우기 없음 · 자리꼴 · 정본 · 군 글자 고정 · 선택지 값 고정(이름은 이름 표로) -화면 짝 = `M02_SO_Def_Check.ts`(같은 글) +화면 짝 = `M01_SO_Def_Check.ts`(같은 글) 거울 시험 = `resources/tester/test_322_2_check_mirror.py`. """ @@ -19,7 +19,7 @@ from typing import Any from common_util.common_util_structure_catalog import load_parts, resolve_catalog BRANCHES = ("횡단도", "카드이름", "형상", "3D") -# 화면 글(322-2 다듬기 · TS `M02_SO_Def_Reflect` 짝) — 자리꼴 · 정본 한국어 · 부품 짧은 이름 +# 화면 글(322-2 다듬기 · TS `M01_SO_Def_Reflect` 짝) — 자리꼴 · 정본 한국어 · 부품 짧은 이름 PLACE_KO = {"point": "점", "interval": "구간", "site": "터"} OWNER_KO = {"pipe_points": "관 지점", "structures": "구조물"} diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Def.ts b/M01_MasterData/StructOptions/M01_SO_Def.ts similarity index 93% rename from M02_MasterTemplete/StructOptions/M02_SO_Def.ts rename to M01_MasterData/StructOptions/M01_SO_Def.ts index ac10f3f04..49926f30b 100644 --- a/M02_MasterTemplete/StructOptions/M02_SO_Def.ts +++ b/M01_MasterData/StructOptions/M01_SO_Def.ts @@ -1,23 +1,23 @@ /* ============================================================================= - * M02_SO_Def.ts + * M01_SO_Def.ts * 구조물 정의 편집 화면(PLAN 48-2 · 메인 칸) — 탭 셋(322-2): 「한눈 표」(종류마다 반영 한 줄 · - * `M02_SO_Def_Table`) · 「종류별」(왼쪽 구조물군 · 종류 목록 · 오른쪽 고른 종류 이름 · 반영 · 명세 이름 나무 · - * 줄마다 보임 · 미리보기) · 「부품」(`M02_SO_Def_Parts`) · - * 아래 검사(화면 = 서버 짝 `M02_SO_Def_Check`) · [저장](판 +1 · 목록 + enabled 함께 · 시스템 관리자만) · + * `M01_SO_Def_Table`) · 「종류별」(왼쪽 구조물군 · 종류 목록 · 오른쪽 고른 종류 이름 · 반영 · 명세 이름 나무 · + * 줄마다 보임 · 미리보기) · 「부품」(`M01_SO_Def_Parts`) · + * 아래 검사(화면 = 서버 짝 `M01_SO_Def_Check`) · [저장](판 +1 · 목록 + enabled 함께 · 시스템 관리자만) · * 지난 판 목록(누르면 그 판을 읽기만으로 봄). * 다른 역할은 읽기만. 고칠 사본은 저장 전까지 서버에 안 감 · 정본 = `구조물정의.json`(48-1). * ========================================================================== */ import { createButton, createTag, el, showToast } from "@ui/ui_template_elements"; -import { StaleError } from "../M02_MasterTemplete_Api_Fetch"; +import { StaleError } from "../../common_util/common_util_m02_call"; import { fetchStructureDef, fetchStructureDefAt, fetchStructureDefHistory, saveStructureDef, type DefVersion, -} from "./M02_SO_Api"; -import { buildLayoutBlock } from "./M02_SO_Def_Layout"; +} from "./M01_SO_Api"; +import { buildLayoutBlock } from "./M01_SO_Def_Layout"; import { baseShown, clone, @@ -25,19 +25,19 @@ import { stepFamily, stepType, type StructDef, -} from "./M02_SO_Def_Model"; -import { buildOptionsBlock } from "./M02_SO_Def_Options"; -import { buildRulesBlock } from "./M02_SO_Def_Rules"; -import { buildSpecBlock } from "./M02_SO_Def_Spec"; +} from "./M01_SO_Def_Model"; +import { buildOptionsBlock } from "./M01_SO_Def_Options"; +import { buildRulesBlock } from "./M01_SO_Def_Rules"; +import { buildSpecBlock } from "./M01_SO_Def_Spec"; import { specFor } from "../../A00_Common/design/logic/design_structure_pipe"; -import { catalogProblems, type CheckDef } from "./M02_SO_Def_Check"; -import { buildParts } from "./M02_SO_Def_Parts"; -import { differs, setReflect, tidy } from "./M02_SO_Def_Reflect"; -import { buildReflectBlock, buildTable } from "./M02_SO_Def_Table"; -import { checkBox, pickBox, textBox } from "./M02_SO_Def_Ui"; -import { addFromTemplate, templates } from "./M02_SO_Def_Add"; -import { buildGroupBlock } from "./M02_SO_Groups"; -import { to } from "./M02_SO_Text"; +import { catalogProblems, type CheckDef } from "./M01_SO_Def_Check"; +import { buildParts } from "./M01_SO_Def_Parts"; +import { differs, setReflect, tidy } from "./M01_SO_Def_Reflect"; +import { buildReflectBlock, buildTable } from "./M01_SO_Def_Table"; +import { checkBox, pickBox, textBox } from "./M01_SO_Def_Ui"; +import { addFromTemplate, templates } from "./M01_SO_Def_Add"; +import { buildGroupBlock } from "./M01_SO_Groups"; +import { to } from "./M01_SO_Text"; import { createText } from "@ui/ui_template_text"; import { createEmpty } from "@ui/ui_template_empty"; import { createTabs } from "@ui/ui_template_tabs"; diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Def_Add.ts b/M01_MasterData/StructOptions/M01_SO_Def_Add.ts similarity index 96% rename from M02_MasterTemplete/StructOptions/M02_SO_Def_Add.ts rename to M01_MasterData/StructOptions/M01_SO_Def_Add.ts index ab0621376..df0bfcd71 100644 --- a/M02_MasterTemplete/StructOptions/M02_SO_Def_Add.ts +++ b/M01_MasterData/StructOptions/M01_SO_Def_Add.ts @@ -1,5 +1,5 @@ /* ============================================================================= - * M02_SO_Def_Add.ts + * M01_SO_Def_Add.ts * 종류 더하기(PLAN 323-7) — 본보기(구조물 정본 원본 종류)를 그대로 복사한 새 종류. * * 키 자동(`{본보기}_xxxxxx` · 만든 뒤 안 바뀜) · 이름 「{본보기} 2」(겹치면 3 …) · 군 · 자리꼴 · 옵션 · 표시 · 그룹 · @@ -8,7 +8,7 @@ * 명세도 본보기 키로 고름(`baseType`). 관 지점 정본 종류는 본보기에서 뺌(관 시설 폼 · 정본 목록이 따로). * ========================================================================== */ -import { clone, newKey, type StructDef } from "./M02_SO_Def_Model"; +import { clone, newKey, type StructDef } from "./M01_SO_Def_Model"; /** 본보기로 고를 수 있는 종류 — 구조물 정본 · 원본(본보기 아님) · [키, 이름] (정의 차례). */ export const templates = (def: StructDef): Array<[string, string]> => diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Def_Check.ts b/M01_MasterData/StructOptions/M01_SO_Def_Check.ts similarity index 98% rename from M02_MasterTemplete/StructOptions/M02_SO_Def_Check.ts rename to M01_MasterData/StructOptions/M01_SO_Def_Check.ts index afbc38e80..8143b35af 100644 --- a/M02_MasterTemplete/StructOptions/M02_SO_Def_Check.ts +++ b/M01_MasterData/StructOptions/M01_SO_Def_Check.ts @@ -1,5 +1,5 @@ /* ============================================================================= - * M02_SO_Def_Check.ts + * M01_SO_Def_Check.ts * 구조물 표 검사(PLAN 322-2 · 1-3 규칙) — 정의 `반영` · `부품` 꼴 · 표 줄과 부품이 맞음 · 만든 뒤 고정. * * · 반영 = `{종류: {목록 · 횡단도 · 카드이름 · 형상 · 형상칸 · 3D}}` · 값 = 부품 상자에 있는 것 @@ -9,7 +9,7 @@ * 그림이 늘 기본값을 씀 · 앞 판에서 이미 숨긴 칸은 그대로 둠) * · 앞 판이 없으면(옛 판 읽기) 꼴만 검사 * · 앞 판과 비교 — 종류 지우기 없음 · 자리꼴 · 정본 · 군 글자 고정 · 선택지 값 고정(이름은 이름 표로) - * 서버 짝 = `M02_SO_Check.py`(같은 글) · 거울 시험 = `resources/tester/test_322_2_check_mirror.py`. + * 서버 짝 = `M01_SO_Check.py`(같은 글) · 거울 시험 = `resources/tester/test_322_2_check_mirror.py`. * ========================================================================== */ import PARTS from "../../common_util/common_util_structure_parts.json" with { type: "json" }; @@ -17,7 +17,7 @@ import { resolveCatalog, type CatalogDefinition, } from "../../common_util/common_util_structure_catalog"; -import { OWNER_KO, PLACE_KO, shortName } from "./M02_SO_Def_Reflect"; +import { OWNER_KO, PLACE_KO, shortName } from "./M01_SO_Def_Reflect"; type Branch = "횡단도" | "카드이름" | "형상" | "3D"; interface Part { diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Def_Layout.ts b/M01_MasterData/StructOptions/M01_SO_Def_Layout.ts similarity index 96% rename from M02_MasterTemplete/StructOptions/M02_SO_Def_Layout.ts rename to M01_MasterData/StructOptions/M01_SO_Def_Layout.ts index d6e4338e0..bb735fbfe 100644 --- a/M02_MasterTemplete/StructOptions/M02_SO_Def_Layout.ts +++ b/M01_MasterData/StructOptions/M01_SO_Def_Layout.ts @@ -1,5 +1,5 @@ /* ============================================================================= - * M02_SO_Def_Layout.ts + * M01_SO_Def_Layout.ts * 구조물 정의 편집 화면(PLAN 48-2) — 고른 종류의 **배치 격자**(B05 · B06 좌측 구조물 칸 = 두 칸) * 옵션마다 줄 · 칸 · 너비 + 미리보기(기준 측점은 맨 위 한 줄 · 겹치면 빨강). * 자리를 안 정한 옵션은 차례대로 빈 칸을 채움 · 숫자를 고치면 그 옵션 자리만 정의 `배치` 에 남음. @@ -15,9 +15,9 @@ import { type Spot, type StructDef, type TypeDef, -} from "./M02_SO_Def_Model"; -import { head, numberBox } from "./M02_SO_Def_Ui"; -import { to } from "./M02_SO_Text"; +} from "./M01_SO_Def_Model"; +import { head, numberBox } from "./M01_SO_Def_Ui"; +import { to } from "./M01_SO_Text"; export interface LayoutBlockOptions { def: StructDef; diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Def_Model.ts b/M01_MasterData/StructOptions/M01_SO_Def_Model.ts similarity index 99% rename from M02_MasterTemplete/StructOptions/M02_SO_Def_Model.ts rename to M01_MasterData/StructOptions/M01_SO_Def_Model.ts index b1bee5190..514d3efb6 100644 --- a/M02_MasterTemplete/StructOptions/M02_SO_Def_Model.ts +++ b/M01_MasterData/StructOptions/M01_SO_Def_Model.ts @@ -1,5 +1,5 @@ /* ============================================================================= - * M02_SO_Def_Model.ts + * M01_SO_Def_Model.ts * 구조물 정의 편집 화면(PLAN 48-2)의 자료 꼴 · 순수 손질 함수 — 화면 그리기 없음. * 정본 = 마스터 템플릿 `구조물정의.json`(48-1 · 틀 `docs/raw/M02_구조물옵션정의/정의_틀.md`). * 키는 만들 때 자동 · 안 바뀜 · 이름 자유 · 지움 = 「안 씀」(`enabled: false`). @@ -226,7 +226,7 @@ export function overlaps(cells: Map): string[] { return [...bad]; } -/** 규칙 한 줄이 틀렸나 — 서버 검사(`M02_SO_Definition._rule_errors`)와 같은 뜻 */ +/** 규칙 한 줄이 틀렸나 — 서버 검사(`M01_SO_Definition._rule_errors`)와 같은 뜻 */ export function ruleBad(def: StructDef, r: RuleDef): boolean { const t = def.types.find((x) => x.type_id === r.종류); const src = t?.options.find((o) => o.key === r.만약.옵션); diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Def_Options.ts b/M01_MasterData/StructOptions/M01_SO_Def_Options.ts similarity index 97% rename from M02_MasterTemplete/StructOptions/M02_SO_Def_Options.ts rename to M01_MasterData/StructOptions/M01_SO_Def_Options.ts index d517a3bc6..a8dbbcc64 100644 --- a/M02_MasterTemplete/StructOptions/M02_SO_Def_Options.ts +++ b/M01_MasterData/StructOptions/M01_SO_Def_Options.ts @@ -1,10 +1,10 @@ /* ============================================================================= - * M02_SO_Def_Options.ts + * M01_SO_Def_Options.ts * 구조물 정의 편집 화면(PLAN 48-2) — 고른 종류의 **옵션 목록** * (이름 · 꼴 · 단위 · 기본값 · 보이기 · 들어갈 자리 · 안 씀 · 순서 · [옵션 더함]) + * 고르기 꼴의 **선택지 목록**(이름 바꿈 · 빼기 · 순서 · [선택지 더함]). * 옵션 키는 더할 때 자동 · 안 바뀜 · 선택지는 글이 곧 값(이름 바꿈 = 기본값 · 규칙도 같이) · - * 저장은 화면 [저장](`M02_SO_Def.ts`). + * 저장은 화면 [저장](`M01_SO_Def.ts`). * ========================================================================== */ import { createButton, createTag, el, showConfirmDialog } from "@ui/ui_template_elements"; @@ -16,10 +16,10 @@ import { type OptionForm, type StructDef, type TypeDef, -} from "./M02_SO_Def_Model"; -import { checkBox, head, moveButtons, pickBox, textBox } from "./M02_SO_Def_Ui"; -import { buildPlaceSelect } from "./M02_SO_Groups"; -import { to } from "./M02_SO_Text"; +} from "./M01_SO_Def_Model"; +import { checkBox, head, moveButtons, pickBox, textBox } from "./M01_SO_Def_Ui"; +import { buildPlaceSelect } from "./M01_SO_Groups"; +import { to } from "./M01_SO_Text"; import { createText } from "@ui/ui_template_text"; import { createEmpty } from "@ui/ui_template_empty"; diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Def_Parts.ts b/M01_MasterData/StructOptions/M01_SO_Def_Parts.ts similarity index 95% rename from M02_MasterTemplete/StructOptions/M02_SO_Def_Parts.ts rename to M01_MasterData/StructOptions/M01_SO_Def_Parts.ts index 97cfc12b7..1877483b6 100644 --- a/M02_MasterTemplete/StructOptions/M02_SO_Def_Parts.ts +++ b/M01_MasterData/StructOptions/M01_SO_Def_Parts.ts @@ -1,12 +1,12 @@ /* ============================================================================= - * M02_SO_Def_Parts.ts + * M01_SO_Def_Parts.ts * 구조물 정의 「부품」 탭(PLAN 322-2) — 코드가 그리는 방법(부품 상자 `common_util_structure_parts.json`). * 갈래마다 부품 · 이름 · 읽는 칸 · 맞는 자리꼴 · 정본 · 쓰는 종류 · 켬/끔(정의 `부품` = 끈 것만). * 끈 부품을 쓰는 종류는 그 갈래가 없음(카드 이름은 종류 이름)으로 — 표 줄(`resolveCatalog`)이 따름. * ========================================================================== */ import { el } from "@ui/ui_template_elements"; -import type { StructDef } from "./M02_SO_Def_Model"; +import type { StructDef } from "./M01_SO_Def_Model"; import { OWNER_KO, PART_BOX, @@ -15,9 +15,9 @@ import { setPartOn, shortName, usersOf, -} from "./M02_SO_Def_Reflect"; -import { checkBox, head } from "./M02_SO_Def_Ui"; -import { to } from "./M02_SO_Text"; +} from "./M01_SO_Def_Reflect"; +import { checkBox, head } from "./M01_SO_Def_Ui"; +import { to } from "./M01_SO_Text"; import { createText } from "@ui/ui_template_text"; type Branch = keyof typeof PART_BOX; diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Def_Reflect.ts b/M01_MasterData/StructOptions/M01_SO_Def_Reflect.ts similarity index 98% rename from M02_MasterTemplete/StructOptions/M02_SO_Def_Reflect.ts rename to M01_MasterData/StructOptions/M01_SO_Def_Reflect.ts index 295f569df..a57f2c7e6 100644 --- a/M02_MasterTemplete/StructOptions/M02_SO_Def_Reflect.ts +++ b/M01_MasterData/StructOptions/M01_SO_Def_Reflect.ts @@ -1,5 +1,5 @@ /* ============================================================================= - * M02_SO_Def_Reflect.ts + * M01_SO_Def_Reflect.ts * 구조물 표 편집(PLAN 322-2)의 순수 손질 — 정의 사본의 `반영` · `부품` · 목록 + enabled · 형상칸. * * · 지금 값 = 구조물 표 한 줄(`resolveCatalog` · 정의 반영 ⊕ 처음값 ⊕ 부품 끔) @@ -14,7 +14,7 @@ import { type CatalogDefinition, type CatalogRow, } from "../../common_util/common_util_structure_catalog"; -import { clone, type StructDef } from "./M02_SO_Def_Model"; +import { clone, type StructDef } from "./M01_SO_Def_Model"; export type ReflectField = "목록" | "횡단도" | "카드이름" | "형상" | "3D"; type Reflect = Partial> & { 형상칸?: Record }; @@ -126,7 +126,7 @@ export function setPartOn(def: StructDef, key: string, on: boolean): void { } /** 못 숨김 칸 — 종류가 지금 쓰는 부품들이 읽는 칸 중 기본값도 비워 두는 뜻도 없는 옵션 - * (숨기면 그림이 받을 값이 없음 · 검사 짝 `M02_SO_Def_Check`). */ + * (숨기면 그림이 받을 값이 없음 · 검사 짝 `M01_SO_Def_Check`). */ export function readKeys(def: StructDef, typeId: string): Set { const row = rowsOf(def).get(typeId); if (!row) return new Set(); diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Def_Rules.ts b/M01_MasterData/StructOptions/M01_SO_Def_Rules.ts similarity index 98% rename from M02_MasterTemplete/StructOptions/M02_SO_Def_Rules.ts rename to M01_MasterData/StructOptions/M01_SO_Def_Rules.ts index 72d9786b1..d190da496 100644 --- a/M02_MasterTemplete/StructOptions/M02_SO_Def_Rules.ts +++ b/M01_MasterData/StructOptions/M01_SO_Def_Rules.ts @@ -1,5 +1,5 @@ /* ============================================================================= - * M02_SO_Def_Rules.ts + * M01_SO_Def_Rules.ts * 구조물 정의 편집 화면(PLAN 48-2) — 고른 종류의 **규칙 표**(정의 `규칙` 중 그 종류 것만) * 「만약 상위 옵션 = 값들 중 하나 → 하위 옵션의 선택지 · 보이기 · 기본값」 한 줄씩 · [규칙 더함] · 지우기. * 「그대로」 칸은 정의에 안 남김 · 셋 다 그대로면 틀린 줄(빨강) · 적용은 B05 · B06(48-4). @@ -13,9 +13,9 @@ import { type RuleDef, type StructDef, type TypeDef, -} from "./M02_SO_Def_Model"; -import { head, pickBox } from "./M02_SO_Def_Ui"; -import { to } from "./M02_SO_Text"; +} from "./M01_SO_Def_Model"; +import { head, pickBox } from "./M01_SO_Def_Ui"; +import { to } from "./M01_SO_Text"; import { createEmpty } from "@ui/ui_template_empty"; import { createCheckbox } from "@ui/ui_template_checkbox"; diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Def_Spec.ts b/M01_MasterData/StructOptions/M01_SO_Def_Spec.ts similarity index 95% rename from M02_MasterTemplete/StructOptions/M02_SO_Def_Spec.ts rename to M01_MasterData/StructOptions/M01_SO_Def_Spec.ts index 656484957..7c8a6ecde 100644 --- a/M02_MasterTemplete/StructOptions/M02_SO_Def_Spec.ts +++ b/M01_MasterData/StructOptions/M01_SO_Def_Spec.ts @@ -1,5 +1,5 @@ /* ============================================================================= - * M02_SO_Def_Spec.ts + * M01_SO_Def_Spec.ts * 구조물 명세가 있는 종류(PLAN 52 · `STRUCTURE_SPECS`)의 이름 고치기 칸(52-11) — 나무 꼴 * 컨테이너 제목 › 항목 이름 › 값 이름 · 이름만 고침 · 키 · 필수/선택 · 꼴은 읽기만 · * 아래 미리보기 = B05 · B06 이 그리는 같은 명세 폼(`createSpecForm`)에 고친 이름을 얹음. @@ -18,16 +18,16 @@ import { } from "../../A00_Common/design/logic/design_structure_spec"; import { group } from "../../B05_Profile/B05_Profile_UI_Drainage_Facility_Fields"; import { field, optionControl } from "../../B05_Profile/B05_Profile_UI_Structures_Fields"; -import type { StructDef, TypeDef } from "./M02_SO_Def_Model"; +import type { StructDef, TypeDef } from "./M01_SO_Def_Model"; import { groupNameRows, setSpecName, specNameRows, type SpecNameRow, -} from "./M02_SO_Def_Spec_Model"; -import { hiddenKeys, readKeys, setShown } from "./M02_SO_Def_Reflect"; -import { checkBox, head, textBox } from "./M02_SO_Def_Ui"; -import { to, type OptionsTextKey } from "./M02_SO_Text"; +} from "./M01_SO_Def_Spec_Model"; +import { hiddenKeys, readKeys, setShown } from "./M01_SO_Def_Reflect"; +import { checkBox, head, textBox } from "./M01_SO_Def_Ui"; +import { to, type OptionsTextKey } from "./M01_SO_Text"; import { createEmpty } from "@ui/ui_template_empty"; const TAG: Record, OptionsTextKey> = { diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Def_Spec_Model.ts b/M01_MasterData/StructOptions/M01_SO_Def_Spec_Model.ts similarity index 98% rename from M02_MasterTemplete/StructOptions/M02_SO_Def_Spec_Model.ts rename to M01_MasterData/StructOptions/M01_SO_Def_Spec_Model.ts index 3178030f3..b7bab4f35 100644 --- a/M02_MasterTemplete/StructOptions/M02_SO_Def_Spec_Model.ts +++ b/M01_MasterData/StructOptions/M01_SO_Def_Spec_Model.ts @@ -1,5 +1,5 @@ /* ============================================================================= - * M02_SO_Def_Spec_Model.ts + * M01_SO_Def_Spec_Model.ts * 구조물 명세(PLAN 52 · `design_structure_spec`) 이름 고치기(52-11)의 자료 손질 — 화면 그리기 없음. * * · 명세 = 구조 정본(키 · 컨테이너 · 필수/선택 · 꼴) — 여기서는 **이름만** 고침 @@ -12,7 +12,7 @@ * ========================================================================== */ import type { StructureSpec } from "../../A00_Common/design/logic/design_structure_spec"; -import type { StructDef, TypeDef } from "./M02_SO_Def_Model"; +import type { StructDef, TypeDef } from "./M01_SO_Def_Model"; export interface SpecNameRow { /** 0 = 컨테이너 · 1 = 항목 · 2 = 값 */ diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Def_Table.ts b/M01_MasterData/StructOptions/M01_SO_Def_Table.ts similarity index 97% rename from M02_MasterTemplete/StructOptions/M02_SO_Def_Table.ts rename to M01_MasterData/StructOptions/M01_SO_Def_Table.ts index d6145c6e4..e01e68eee 100644 --- a/M02_MasterTemplete/StructOptions/M02_SO_Def_Table.ts +++ b/M01_MasterData/StructOptions/M01_SO_Def_Table.ts @@ -1,14 +1,14 @@ /* ============================================================================= - * M02_SO_Def_Table.ts + * M01_SO_Def_Table.ts * 구조물 정의 「한눈 표」 탭(PLAN 322-2) — 종류마다 B05 · B06 반영 한 줄. * 군 · 종류(▲▼) · 이름 · 목록 · 자리꼴 · 정본(읽기만 「고정」) · 횡단도 · 카드 이름 · 형상(+ 형상칸) · * 알약 색 · 3D · 검사. 흐린 칸 = 처음 값(「기본」) · 진한 칸 = 바꾼 값 · [처음 값으로] = 그 종류 반영 지움. - * 칸 손질 = `M02_SO_Def_Reflect` · 검사 글 = `M02_SO_Def_Check`(서버 짝) · 「종류별」 탭이 같은 칸(`reflectCells`)을 씀. + * 칸 손질 = `M01_SO_Def_Reflect` · 검사 글 = `M01_SO_Def_Check`(서버 짝) · 「종류별」 탭이 같은 칸(`reflectCells`)을 씀. * ========================================================================== */ import { createButton, createTag, el } from "@ui/ui_template_elements"; import type { CatalogRow } from "../../common_util/common_util_structure_catalog"; -import { stepFamily, stepType, type StructDef, type TypeDef } from "./M02_SO_Def_Model"; +import { stepFamily, stepType, type StructDef, type TypeDef } from "./M01_SO_Def_Model"; import { REVET_FORMS } from "../../B06_Section/logic/B06_Section_UI_Cross_Culvert_Const"; import { isSet, @@ -22,9 +22,9 @@ import { setShapeOpt, valueOf, type ReflectField, -} from "./M02_SO_Def_Reflect"; -import { checkBox, pickBox, textBox } from "./M02_SO_Def_Ui"; -import { to } from "./M02_SO_Text"; +} from "./M01_SO_Def_Reflect"; +import { checkBox, pickBox, textBox } from "./M01_SO_Def_Ui"; +import { to } from "./M01_SO_Text"; import { createText } from "@ui/ui_template_text"; type Pairs = ReadonlyArray; diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Def_Ui.ts b/M01_MasterData/StructOptions/M01_SO_Def_Ui.ts similarity index 97% rename from M02_MasterTemplete/StructOptions/M02_SO_Def_Ui.ts rename to M01_MasterData/StructOptions/M01_SO_Def_Ui.ts index 879d6ca7c..e3d5587e1 100644 --- a/M02_MasterTemplete/StructOptions/M02_SO_Def_Ui.ts +++ b/M01_MasterData/StructOptions/M01_SO_Def_Ui.ts @@ -1,12 +1,12 @@ /* ============================================================================= - * M02_SO_Def_Ui.ts + * M01_SO_Def_Ui.ts * 구조물 정의 편집 화면(PLAN 48-2)의 작은 입력 부품 — 글 · 숫자 · 체크 · 고르기 · 위아래 단추. * 값은 받은 손잡이로 사본만 고침 · 글은 칸을 떠날 때(`change`) 다시 그림(초점 안 끊김). * ========================================================================== */ import { createButton, el } from "@ui/ui_template_elements"; -import { step } from "./M02_SO_Def_Model"; -import { to } from "./M02_SO_Text"; +import { step } from "./M01_SO_Def_Model"; +import { to } from "./M01_SO_Text"; import { createText } from "@ui/ui_template_text"; import { createCheckbox } from "@ui/ui_template_checkbox"; diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Definition.py b/M01_MasterData/StructOptions/M01_SO_Definition.py similarity index 96% rename from M02_MasterTemplete/StructOptions/M02_SO_Definition.py rename to M01_MasterData/StructOptions/M01_SO_Definition.py index 925aa90d2..083561b55 100644 --- a/M02_MasterTemplete/StructOptions/M02_SO_Definition.py +++ b/M01_MasterData/StructOptions/M01_SO_Definition.py @@ -1,7 +1,7 @@ -"""M02 구조물 정의 한 벌(PLAN 48-1) — 정본 `resources/master_template/구조물정의.json`. +"""M01 구조물 정의 한 벌(PLAN 48-1) — 정본 `resources/master_data/구조물정의/구조물정의.json`. 틀 = `docs/raw/M02_구조물옵션정의/정의_틀.md`. 읽기 = 로그인 누구나 · 쓰기 = 시스템 관리자만. -판 = 정수 · 저장마다 +1 · 앞 판은 `구조물정의_이력/판_N.json` 으로 남김(지난 정의 값 읽기용). +판 = 정수 · 저장마다 +1 · 앞 판은 `구조물정의/이력/판_N.json` 으로 남김(지난 정의 값 읽기용). 검사 = 칸 꼴 · 키 겹침 · 표시 · 그룹 · 배치 · 규칙 대상 있음 — 틀리면 422 · 낡은 판 409. """ @@ -17,12 +17,12 @@ from pydantic import ValidationError from B05_Profile import B05_Profile_Structures_Schema as schema from common_util.common_util_json import atomic_write_json from common_util.common_util_time import utc_from_timestamp +from M01_MasterData.StructOptions.M01_SO_Check import catalog_errors from M02_MasterTemplete import M02_MasterTemplete_Store as store -from M02_MasterTemplete.StructOptions.M02_SO_Check import catalog_errors FILE = "구조물정의.json" -HISTORY = "구조물정의_이력" -# 반영 · 부품 = 구조물 표 칸(322-2 · 없으면 처음값 · 검사 = `M02_SO_Check`) +HISTORY = "이력" +# 반영 · 부품 = 구조물 표 칸(322-2 · 없으면 처음값 · 검사 = `M01_SO_Check`) TOP = {"판", "schema_version", "comment", "구조물군", "동작", "types", "반영", "부품"} SECTIONS = {"종류": dict, "표시": dict, "그룹": dict, "배치": dict, "규칙": list} SPOT = ("줄", "칸", "너비") @@ -180,8 +180,8 @@ def _rule_errors(doc: dict[str, Any], keys: dict[str, dict[str, Any]]) -> list[s def check(doc: Any, before: dict[str, Any] | None = None) -> list[str]: """정의 한 벌 검사 — 틀린 것 목록(빈 목록 = 통과). `before` = 지금 판(만든 뒤 고정 · 322-2).""" - from M02_MasterTemplete.StructOptions import M02_SO_Groups as groups - from M02_MasterTemplete.StructOptions import M02_SO_Options as options + from M01_MasterData.StructOptions import M01_SO_Groups as groups + from M01_MasterData.StructOptions import M01_SO_Options as options if not isinstance(doc, dict): return ["정의는 묶음이어야 함"] diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Groups.py b/M01_MasterData/StructOptions/M01_SO_Groups.py similarity index 96% rename from M02_MasterTemplete/StructOptions/M02_SO_Groups.py rename to M01_MasterData/StructOptions/M01_SO_Groups.py index f103f8edc..20d31631b 100644 --- a/M02_MasterTemplete/StructOptions/M02_SO_Groups.py +++ b/M01_MasterData/StructOptions/M01_SO_Groups.py @@ -1,6 +1,6 @@ """M02 구조물 옵션 그룹 — 구조물 종류 안에 이름 붙은 묶음(PLAN 46-2). -정본 = 구조물 정의 한 벌(`M02_SO_Definition` · PLAN 48-1)의 「그룹」 칸 = +정본 = 구조물 정의 한 벌(`M01_SO_Definition` · PLAN 48-1)의 「그룹」 칸 = `{type_id: [{"id": "g1a2b3c", "이름": "유입구 기슭막이", "옵션": [...], "형상"?: {...}}]}` — 없는 종류 = 그룹 없음 · 빈 그룹(옵션 0)도 그룹 · 형상 = 길이 · 높이 · 전 · 후 받기 + 뜻. @@ -26,7 +26,7 @@ logger = logging.getLogger(__name__) def _load() -> tuple[dict[str, Any], str]: - """(그룹 표 · 판) — 정의 한 벌(`M02_SO_Definition`)의 「그룹」 칸 · 판 = 정의 판 글.""" + """(그룹 표 · 판) — 정의 한 벌(`M01_SO_Definition`)의 「그룹」 칸 · 판 = 정의 판 글.""" doc = load_definition() return doc.get("그룹") or {}, str(doc.get("판", 1)) @@ -144,7 +144,7 @@ def _clean(groups: Any, keys: dict[str, set[str]] | None = None) -> dict[str, li def save(groups: Any, version: str) -> dict[str, Any]: """고쳐 씀 — 판이 같을 때만. 돌려주는 것 = 새 `listing()`.""" - from M02_MasterTemplete.StructOptions.M02_SO_Definition import save_sections + from M01_MasterData.StructOptions.M01_SO_Definition import save_sections save_sections({"그룹": _clean(groups)}, version) return listing() diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Groups.ts b/M01_MasterData/StructOptions/M01_SO_Groups.ts similarity index 96% rename from M02_MasterTemplete/StructOptions/M02_SO_Groups.ts rename to M01_MasterData/StructOptions/M01_SO_Groups.ts index 8a3083d47..b8736b85b 100644 --- a/M02_MasterTemplete/StructOptions/M02_SO_Groups.ts +++ b/M01_MasterData/StructOptions/M01_SO_Groups.ts @@ -1,16 +1,16 @@ /* ============================================================================= - * M02_SO_Groups.ts + * M01_SO_Groups.ts * 구조물 정의 화면의 **옵션 그룹** 부품(PLAN 46-2 · 48-2) — 고른 종류의 그룹 목록 * (이름 · 위로 · 아래로 · 지우기 · 형상 칸 길이 · 높이 · 전 · 후 받기 켬끔과 뜻 · [그룹 추가]) · * 옵션 줄마다 「들어갈 자리」 고르기(본체 · 그룹). - * 값은 화면이 쥔 고칠 사본에만 — 저장은 화면 [저장](`M02_SO_Def.ts`). - * 그룹 하나 = 프로젝트 B05 · B06 폼의 보조 컨테이너 하나 · 옵션이 없어도 됨(서버 `M02_SO_Groups.py`). + * 값은 화면이 쥔 고칠 사본에만 — 저장은 화면 [저장](`M01_SO_Def.ts`). + * 그룹 하나 = 프로젝트 B05 · B06 폼의 보조 컨테이너 하나 · 옵션이 없어도 됨(서버 `M01_SO_Groups.py`). * ========================================================================== */ import { createButton, el, showConfirmDialog } from "@ui/ui_template_elements"; -import { SHAPE_KEYS, type GroupDef } from "./M02_SO_Def_Model"; -import { checkBox, textBox } from "./M02_SO_Def_Ui"; -import { to } from "./M02_SO_Text"; +import { SHAPE_KEYS, type GroupDef } from "./M01_SO_Def_Model"; +import { checkBox, textBox } from "./M01_SO_Def_Ui"; +import { to } from "./M01_SO_Text"; import { createText } from "@ui/ui_template_text"; import { createEmpty } from "@ui/ui_template_empty"; diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Options.py b/M01_MasterData/StructOptions/M01_SO_Options.py similarity index 94% rename from M02_MasterTemplete/StructOptions/M02_SO_Options.py rename to M01_MasterData/StructOptions/M01_SO_Options.py index c059859e1..5e15371f8 100644 --- a/M02_MasterTemplete/StructOptions/M02_SO_Options.py +++ b/M01_MasterData/StructOptions/M01_SO_Options.py @@ -1,6 +1,6 @@ """M02 구조물 옵션 보이기 — 구조물 종류마다 B05/B06 폼에 보일 옵션을 사용자가 체크. -정본 = 구조물 정의(`M02_SO_Definition` · PLAN 48-1) 「표시」 칸 = `{type_id: {option_key: false}}` +정본 = 구조물 정의(`M01_SO_Definition` · PLAN 48-1) 「표시」 칸 = `{type_id: {option_key: false}}` — 없는 종류 · 키는 보임. 저장은 **숨김(false)만** 남김 — 「모두 보임」 = `{}`. 옵션 정의 · 옛 값은 그대로 — 폼이 그리는 것만 갈림(`GET /api/projects/structure-types` `visible`). @@ -22,8 +22,8 @@ from B05_Profile.B05_Profile_Structures_Schema import ( load_structure_types, registry_schema_version, ) +from M01_MasterData.StructOptions.M01_SO_Groups import groups_of from M02_MasterTemplete import M02_MasterTemplete_Store as store -from M02_MasterTemplete.StructOptions.M02_SO_Groups import groups_of logger = logging.getLogger(__name__) @@ -35,7 +35,7 @@ class OptionWithVisible(StructureOptionField): class OptionGroup(BaseModel): - """옵션 그룹 한 개(PLAN 46-2 · `M02_SO_Groups`) — 폼의 보조 컨테이너 하나 · 빈 옵션도 됨.""" + """옵션 그룹 한 개(PLAN 46-2 · `M01_SO_Groups`) — 폼의 보조 컨테이너 하나 · 빈 옵션도 됨.""" id: str name: str @@ -54,7 +54,7 @@ class TypesWithVisible(StructureTypesResponse): def _load() -> tuple[dict[str, Any], str]: - """(표시 표 · 판) — 정의 한 벌(`M02_SO_Definition`)의 「표시」 칸 · 판 = 정의 판 글.""" + """(표시 표 · 판) — 정의 한 벌(`M01_SO_Definition`)의 「표시」 칸 · 판 = 정의 판 글.""" doc = load_definition() return doc.get("표시") or {}, str(doc.get("판", 1)) @@ -155,7 +155,7 @@ def _clean(shown: Any, keys: dict[str, set[str]] | None = None) -> dict[str, dic def save(shown: Any, version: str) -> dict[str, Any]: """고쳐 씀 — 판이 같을 때만. 돌려주는 것 = 새 `listing()`.""" - from M02_MasterTemplete.StructOptions.M02_SO_Definition import save_sections + from M01_MasterData.StructOptions.M01_SO_Definition import save_sections save_sections({"표시": _clean(shown)}, version) return listing() diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Options.ts b/M01_MasterData/StructOptions/M01_SO_Options.ts similarity index 91% rename from M02_MasterTemplete/StructOptions/M02_SO_Options.ts rename to M01_MasterData/StructOptions/M01_SO_Options.ts index 3136b9a76..b8be7235c 100644 --- a/M02_MasterTemplete/StructOptions/M02_SO_Options.ts +++ b/M01_MasterData/StructOptions/M01_SO_Options.ts @@ -1,15 +1,15 @@ /* ============================================================================= - * M02_SO_Options.ts + * M01_SO_Options.ts * 좌측 「구조물 옵션 정의」 줄(구조물 집계 양식 아래 별도 · 시스템 층) — 누르면 메인 칸에 - * 정의 편집 화면(PLAN 48-2 · `M02_SO_Def.ts`) · 고쳐 씀은 시스템 관리자만 · 다른 역할은 읽기만. + * 정의 편집 화면(PLAN 48-2 · `M01_SO_Def.ts`) · 고쳐 씀은 시스템 관리자만 · 다른 역할은 읽기만. * 옛 「보이기 · 그룹」 화면(46장)은 정의 화면의 옵션 줄 「보이기」 · 그룹 칸으로 들어감. * ========================================================================== */ import { el } from "@ui/ui_template_elements"; -import { openDefScreen } from "./M02_SO_Def"; +import { openDefScreen } from "./M01_SO_Def"; import "@ui/ui_template_card.css"; -import "./M02_SO_Style.css"; -import { to } from "./M02_SO_Text"; +import "./M01_SO_Style.css"; +import { to } from "./M01_SO_Text"; export interface OptionsSectionOptions { isAdmin: boolean; diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Router.py b/M01_MasterData/StructOptions/M01_SO_Router.py similarity index 91% rename from M02_MasterTemplete/StructOptions/M02_SO_Router.py rename to M01_MasterData/StructOptions/M01_SO_Router.py index 448e0e4cc..153e3819a 100644 --- a/M02_MasterTemplete/StructOptions/M02_SO_Router.py +++ b/M01_MasterData/StructOptions/M01_SO_Router.py @@ -1,4 +1,4 @@ -"""M02 구조물 옵션 보이기 · 그룹 · 정의 길 — 정본 `M02_SO_Definition.py`(PLAN 48-1) 한 벌. +"""M02 구조물 옵션 보이기 · 그룹 · 정의 길 — 정본 `M01_SO_Definition.py`(PLAN 48-1) 한 벌. `router` = 고쳐 씀 · 관리 읽기(`main.py` 가 `system_admin_only` 로 붙임) · `read_router` = 읽기만(로그인 누구나 · `main.py` 가 `protected` 로 붙임) · 정의 쓰기는 여기서 @@ -14,14 +14,14 @@ from pydantic import BaseModel from B05_Profile.B05_Profile_Structures_Schema import definition_version from common_util.common_util_auth import verify_session +from M01_MasterData.StructOptions import M01_SO_Definition as definition +from M01_MasterData.StructOptions import M01_SO_Groups as groups +from M01_MasterData.StructOptions import M01_SO_Options as options from M02_MasterTemplete import M02_Layer_Access as access from M02_MasterTemplete import M02_MasterTemplete_Store as store -from M02_MasterTemplete.StructOptions import M02_SO_Definition as definition -from M02_MasterTemplete.StructOptions import M02_SO_Groups as groups -from M02_MasterTemplete.StructOptions import M02_SO_Options as options -router = APIRouter(prefix="/api/m02", tags=["M02 MasterTemplete"]) -read_router = APIRouter(prefix="/api/m02", tags=["M02 MasterTemplete"]) +router = APIRouter(prefix="/api/m01", tags=["M01 MasterData"]) +read_router = APIRouter(prefix="/api/m01", tags=["M01 MasterData"]) class OptionsBody(BaseModel): diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Style.css b/M01_MasterData/StructOptions/M01_SO_Style.css similarity index 100% rename from M02_MasterTemplete/StructOptions/M02_SO_Style.css rename to M01_MasterData/StructOptions/M01_SO_Style.css diff --git a/M02_MasterTemplete/StructOptions/M02_SO_Text.ts b/M01_MasterData/StructOptions/M01_SO_Text.ts similarity index 99% rename from M02_MasterTemplete/StructOptions/M02_SO_Text.ts rename to M01_MasterData/StructOptions/M01_SO_Text.ts index ff1db8eec..84229c910 100644 --- a/M02_MasterTemplete/StructOptions/M02_SO_Text.ts +++ b/M01_MasterData/StructOptions/M01_SO_Text.ts @@ -1,5 +1,5 @@ /* ============================================================================= - * M02_SO_Text.ts + * M01_SO_Text.ts * 좌측 「구조물 옵션 보이기」 줄 · 상세 화면(보이기 · 그룹) 글자 — [한국어, 영어] * ========================================================================== */ diff --git a/M02_MasterTemplete/M02_Hopyo_Build.py b/M02_MasterTemplete/M02_Hopyo_Build.py index 1fb644fb9..2516c42fc 100644 --- a/M02_MasterTemplete/M02_Hopyo_Build.py +++ b/M02_MasterTemplete/M02_Hopyo_Build.py @@ -242,7 +242,8 @@ class Builder: hopyo, file = self.hopyo, self.doc.get("파일") or "" rows = hopyo.get("줄") or [] where = {"파일": file, "호표": self.no} - body = hmake.Lines(self, rows, where, stamp, hfix.Linker(self.strict and save)) + found = hfix.Linker(self.strict and save, hfix.clues(self.src, self.key)) + body = hmake.Lines(self, rows, where, stamp, found) lines, mats, missing, left = body.lines, body.mats, body.missing, body.left taken, linker, kids, put = body.taken, body.linker, body.kids, body.put nation, mat_lines = body.nation, body.mat_lines @@ -288,6 +289,8 @@ class Builder: if nation: doc["본뜬"]["전국자재"] = list(nation.values()) doc["본뜬"]["품셈"] = poomsem + if self.strict and save: # 859-4 불러온 일위대가 기본 판 = 엑셀(단가산출 불러오기와 같음) + doc["본뜬"][hfix.fixed.BASIS] = hfix.fixed.EXCEL if self.dry: return {"남은줄": left} if left and save and self.strict and not self.lenient: diff --git a/M02_MasterTemplete/M02_Hopyo_Fixed.py b/M02_MasterTemplete/M02_Hopyo_Fixed.py index 87b283812..a35726df7 100644 --- a/M02_MasterTemplete/M02_Hopyo_Fixed.py +++ b/M02_MasterTemplete/M02_Hopyo_Fixed.py @@ -6,7 +6,9 @@ 수량 없음 = 수량 1 · 단가 = 엑셀 금액(「금액만」). 이음 = 노임(LB) · 자재(MT) = 이름 · 규격 · 단위 · 단가 다 같은 것만 · `by_name`(729-2 불러오기 길 · 요구서 내역19 3장 7) = 노임 = 이름 같은 LB 하나(값 = 지금 단가 책) · 기계 = 이름(갈래) · 규격 수 같은 EQ - 하나 · 못 이은 짝 = `후보` 수만 · 사용자가 고른 이음(`force` {노임|기계|자재: 키} · {비율: 기준}) = 그대로. + 하나 · 자재(859-4 · 요구 903) = 단가산출 길 찾기 한 벌(`San_Link.m01` 재료 · 같은 올림 단서 · 값 관문 없음 · + 유가 줄 = 이음 유가 · 별도계상 = 판정만) — 금액은 일위대가 판(`Labor_Fixed.basis_of`)이 고름 · + 못 이은 짝 = `후보` 수만 · 사용자가 고른 이음(`force` {노임|기계|자재: 키} · {비율: 기준}) = 그대로. % 줄 = 비율 줄 `비율 {기준, 비목}` — 엑셀 밑수(단가 계) = 다른 줄 금액[기준] 합일 때만 · 아니면(주재료비 등) 수량 1 · 「식」 · 단가 = 엑셀 금액. 같은 이름 · 규격 · 단위 둘째부터 = 이름 끝 「 (2)」(줄 가름 · 705-1 400 피함). @@ -15,8 +17,11 @@ from __future__ import annotations +import json import re from decimal import Decimal +from functools import lru_cache +from pathlib import Path from typing import Any from M01_MasterData import M01_MasterData_Store as m01 @@ -87,13 +92,41 @@ def linked(one: dict[str, Any], decided: bool = False) -> bool: return decided or bool(fx.get("비율")) or any((fx.get("이음") or {}).values()) -class Linker: - """이음 — 노임(LB 이름) · 기계(EQ 갈래 · 규격) · 자재(이름 · 규격 같은 한 품목 · 단위 · 단가 같음).""" +def clues(folder: str | Path, key: str) -> list[dict]: + """같은 올림 둘 꼴 재료 단서(`Sangeun_FromHopyo` 저장본 `엑셀` · `원파일` 의 `단서` · 859-4) — 없음 = [].""" + from M02_MasterTemplete import M02_Sangeun_FromHopyo as fh - def __init__(self, by_name: bool = False) -> None: + path = fh._path(folder, key) + try: + return list(_clues(str(path), path.stat().st_mtime_ns)) + except OSError: + return [] + + +@lru_cache(maxsize=8) +def _clues(path: str, _mtime: int) -> tuple: + try: + saved = json.loads(Path(path).read_bytes()) + except (OSError, ValueError): + return () + src = saved.get("엑셀") or saved.get("원파일") + return tuple((src.get("단서") or []) if isinstance(src, dict) else []) + + +def excel_mat(line: dict[str, Any]) -> Decimal: + """엑셀 줄 재료비 단가(`line_of` 와 같은 길 — 수량 없음 = 금액).""" + return _parts(line.get("단가") if line.get("수량") is not None else line.get("금액"))["재료비"] + + +class Linker: + """이음 — 노임(LB 이름) · 기계(EQ 갈래 · 규격) · 자재(불러오기 길 = 단가산출 길 찾기 · 그 밖 = 이름 · + 규격 같은 한 품목 · 단위 · 단가 같음).""" + + def __init__(self, by_name: bool = False, clues: list | None = None) -> None: self.by_name = ( by_name # 729-2 불러오기 길만 — 붙여넣기 · B09 통째 = 단가 같을 때만(엑셀 합계 그대로) ) + self.clues = list(clues or []) # 859-4 같은 올림 재료 단서 self.whole = m01.loaded()[1] self.got = hm.targets() self.labor: dict[str, list[tuple[str, Decimal | None]]] = {} @@ -116,10 +149,37 @@ class Linker: out["노임"] = same or self._same(pairs, price["노무비"]) elif kind == "기계" and self.by_name: out["기계"] = self._machine(line) + elif kind in hm.MATERIAL_KINDS and price["재료비"] and self.by_name: + got = self.find(line, price["재료비"]) + key = str(got.get("키") or "") + if key[:2] in ("MT", "MO"): + out["자재" if key[:2] == "MT" else "유가"] = key + else: + self.near += bool(got.get("후보")) elif kind in hm.MATERIAL_KINDS and price["재료비"]: out["자재"] = self._same(self._mats(line), price["재료비"]) return out + def find(self, line: dict[str, Any], price: Decimal | None = None) -> dict[str, Any]: + """자재 줄 → 단가산출 길 판정 {키, 판정, 방법, 후보, 단서}(`San_Link.m01` 재료 · 859-4) · + `price` = 엑셀 재료비 단가(같은 품목 여러 줄 고름).""" + from M02_MasterTemplete import M02_San_Link as sl + from M02_MasterTemplete import M02_San_MatFind as smf + + src = {k: line.get(k) or "" for k in ("이름", "규격", "단위")} + src |= {"종류": "자재", "코드": line.get("코드") or ""} + if price: + src |= {"단가": {"M": _plain(price)}, "비목": "M"} + with smf.clues_on(self.clues): + key, _ = sl.m01("재료", src, "") + return {"후보": [], **(src.get("재료찾기") or {}), "키": key} + + def verdict(self, line: dict[str, Any]) -> str | None: + """못 이은 자재 줄 판정 글(단가산출 길과 같은 말 · 불러오기 길만).""" + if not self.by_name or kind_of(line) not in hm.MATERIAL_KINDS: + return None + return self.find(line, excel_mat(line)).get("판정") or None + def _eqs(self, line: dict[str, Any]) -> list[str]: """기계 줄 → EQ 후보 — 이름 · 규격 글 같음 › 기계 찾기(812-9 `M02_Machine_Find`).""" name, spec = mm_plain(line.get("이름")), mm_plain(line.get("규격")) @@ -141,6 +201,8 @@ class Linker: return [code for code, _ in self.labor.get(shares.trade(line.get("이름")) or "", [])] if kind == "기계": return self._eqs(line) + if kind in hm.MATERIAL_KINDS and self.by_name: + return [c["키"] for c in self.find(line, excel_mat(line))["후보"] if c.get("키")] return [code for code, _ in self._mats(line)] if kind in hm.MATERIAL_KINDS else [] def _machine(self, line: dict[str, Any]) -> str | None: diff --git a/M02_MasterTemplete/M02_Hopyo_Forget.py b/M02_MasterTemplete/M02_Hopyo_Forget.py index 6be387bde..d7d52b2dd 100644 --- a/M02_MasterTemplete/M02_Hopyo_Forget.py +++ b/M02_MasterTemplete/M02_Hopyo_Forget.py @@ -3,7 +3,7 @@ 끝냄 한 길 `finish` = [끝내기] · 화면 떠남 · 하루 지남(`Store.EXPIRE`) · 붙여넣기 만듦 뒤 · 엑셀 보기 [삭제]: HP · 격자 지움(블록 풀이 저장본 = Router 가 `Judge.forget`) · 그 HP 로 만든 이 층 일위대가(SC) · 단가산출(SK) 엑셀 사본 걷음 - (`본뜬` → 출처 `{층 「실무자료」, 파일, 때, 누가}` + 전국자재 · 복사원본 · + (`본뜬` → 출처 `{층 「실무자료」, 파일, 때, 누가}` + 전국자재 · 복사원본 · 판 `단가기준`(859-4) · SC 줄 메모 「실무 …」 걷음 · `본뜬.실무수량` = 모든 값이 그 줄 저장 `수량.손` 과 같을 때만 걷음(742-1 · 다르면 남김 = 금액 그대로)) · SK · SC `본뜬.또` = 그 HP 몫만 뺌 · 문서 몸(줄 · 덮개 · 더한줄 · 별칭 · 구분)과 별칭 장부는 그대로 · @@ -24,7 +24,7 @@ from M02_MasterTemplete import M02_Hopyo_Store as hopyo_store from M02_MasterTemplete import M02_Labor_Ref as refs ORIGIN = "실무자료" -KEEP = ("층", "파일", "전국자재", "복사원본") +KEEP = ("층", "파일", "전국자재", "복사원본", "단가기준") _MEMO = re.compile(r"^실무 ") diff --git a/M02_MasterTemplete/M02_Hopyo_MatSame.py b/M02_MasterTemplete/M02_Hopyo_MatSame.py index 3c8dbf335..4f6853607 100644 --- a/M02_MasterTemplete/M02_Hopyo_MatSame.py +++ b/M02_MasterTemplete/M02_Hopyo_MatSame.py @@ -217,6 +217,16 @@ def same(line: dict[str, Any]) -> dict[str, Any] | None: hits = [book()["줄"][i] for i in book()["찾기"]["spec"].get(me["whole"], [])] hits = [x for x in hits if not x["bag"] and not me["bag"]] return _pick(hits, line) if hits and len({_fold(x) for x in hits}) == 1 else None + ok = _ok(me, scored) + if not ok: + return None + best = max(k for k, _ in ok) + group = [x for k, x in ok if k == best] + return _pick(group, line) if len({_fold(x) for x in group}) == 1 else None + + +def _ok(me: dict[str, Any], scored: list) -> list[tuple[tuple, dict[str, Any]]]: + """㉮ 표기만 다른 같은 품목으로 볼 줄 — 굳센 이름 같음 · 규격 수 맞음 · 수 없는 규격은 낱말 겹침.""" ok = [] for (strong, share, tier, common, words, same_core), x in scored: if not tier or (tier == 1 and not strong): @@ -224,11 +234,15 @@ def same(line: dict[str, Any]) -> dict[str, Any] | None: if not me["bag"] and not x["bag"] and not share and words: continue # 수 없는 규격 = 규격 낱말이 겹쳐야 ok.append(((tier, common, share, strong, same_core), x)) - if not ok: - return None - best = max(k for k, _ in ok) - group = [x for k, x in ok if k == best] - return _pick(group, line) if len({_fold(x) for x in group}) == 1 else None + return ok + + +def peers(line: dict[str, Any]) -> list[str]: + """줄과 표기만 다른 같은 품목 자재 키들(859-4 값 가까운 줄 고름 · 규격 빈 줄 = 없음).""" + me, scored = _scored(line) + if not me["spec"]: + return [] + return [k for _, x in _ok(me, scored) if (k := x["row"]["one"].get("자재"))] def _stems(me: dict[str, Any]) -> set[str]: diff --git a/M02_MasterTemplete/M02_Hopyo_View.py b/M02_MasterTemplete/M02_Hopyo_View.py index 9ed8ba996..85770ea5f 100644 --- a/M02_MasterTemplete/M02_Hopyo_View.py +++ b/M02_MasterTemplete/M02_Hopyo_View.py @@ -4,8 +4,9 @@ [내 일위대가로] 와 같은 이음 규칙 · 금액 = 엑셀). 줄 표지: · 로직 줄 = 단산 N 참조 → 「단가산출」(번 · 가져온 식 SK 로 엶) · 일위 N 참조 → 「일위대가」(번 · 하위 호표 보기) · 요소 줄 = 그 밖(인력 · 재료 · 기계 · 유가 · 율 · 고정 수) — 이음 있음 = 「연결됨」(이음) · - 후보 있음 = 「후보」(키 · 이름) · 없음 = 「못 이음」(엑셀 값 그대로) + 후보 있음 = 「후보」(키 · 이름) · 없음 = 「못 이음」(엑셀 값 그대로) · 자재 줄 = `판정`(단가산출 길과 같은 말 · 859-4) · 엑셀 = 줄 금액(노무비 · 재료비 · 경비 · 계) +문서 = 불러온 일위대가 판 「엑셀」(`본뜬.단가기준` · 859-4 — 화면이 「우리」 로 바꿔 미리 셈) · 이음 = 같은 올림 단서로. 기초 판정 · 2차 풀이 없음 · 저장 없음. """ @@ -17,6 +18,7 @@ from typing import Any from M02_MasterTemplete import M02_Hopyo_Build as hbuild from M02_MasterTemplete import M02_Hopyo_Fixed as hfix from M02_MasterTemplete import M02_Hopyo_Store as hopyo_store +from M02_MasterTemplete import M02_Labor_Fixed as fixed from M02_MasterTemplete import M02_Labor_Ref as refs from M02_MasterTemplete import M02_MasterTemplete_Store as store @@ -48,7 +50,12 @@ def mark(line: dict[str, Any], one: dict[str, Any], linker: hfix.Linker) -> dict link = {k: v for k, v in (fx.get("이음") or {}).items() if v} rate = fx.get("비율") return {**out, "갈래": ELEMENT, "표지": LINKED, "이음": link or {"비율": rate["기준"]}} - near = [{"키": c, "이름": _name(linker, c)} for c in linker.candidates(line)] + if v := linker.verdict(line): # 자재 줄(불러오기 길) = 단가산출 길 판정 · 후보(이름 규격) + cands = linker.find(line, hfix.excel_mat(line))["후보"] + near = [{"키": c["키"], "이름": f"{c.get('이름') or ''} {c.get('규격') or ''}".strip()} for c in cands if c.get("키")] # fmt: skip + out["판정"] = v + else: + near = [{"키": c, "이름": _name(linker, c)} for c in linker.candidates(line)] if near: return {**out, "갈래": ELEMENT, "표지": NEAR, "후보": near} return {**out, "갈래": ELEMENT, "표지": NONE} @@ -56,7 +63,8 @@ def mark(line: dict[str, Any], one: dict[str, Any], linker: hfix.Linker) -> dict def view(source: str | Path, key: str, no: int) -> dict[str, Any]: """파일 층 HP 의 호표 하나 보기(`of`).""" - return of(hopyo_store.read(Path(source), key), no) + linker = hfix.Linker(True, hfix.clues(source, key)) + return of(hopyo_store.read(Path(source), key), no, linker) def of(book: dict[str, Any], no: int, linker: hfix.Linker | None = None) -> dict[str, Any]: @@ -73,7 +81,14 @@ def of(book: dict[str, Any], no: int, linker: hfix.Linker | None = None) -> dict lines.append(one) marks.append(mark(line, one, linker)) name = " ".join(x for x in (hopyo.get("이름"), hopyo.get("규격")) if x) - doc = {"이름": name, "단위": hopyo.get("단위") or None, "담은로직": lines, "자재": []} + born = {"층": hbuild.ORIGIN, "파일": where["파일"], fixed.BASIS: fixed.EXCEL} # 859-4 기본 판 + doc = { + "이름": name, + "단위": hopyo.get("단위") or None, + "담은로직": lines, + "자재": [], + "본뜬": born, + } head = {k: hopyo.get(k) for k in ("번", "이름", "규격", "단위", "금액")} return {**head, "문서": doc, "줄": marks} @@ -83,7 +98,7 @@ def listing(folder: str | Path, key: str, to: str | Path) -> dict[str, Any]: `줄상태 [[차례, 표지, 이어짐]]` · `만든` SC(만들 층 `to` · 이 파일 층 것만).""" book = hopyo_store.read(Path(folder), key) made = hbuild.confirmed(to, refs.where(Path(folder))) - linker, units = hfix.Linker(True), [] + linker, units = hfix.Linker(True, hfix.clues(folder, key)), [] for h in book.get("호표") or []: no = int(h["번"]) marks = of(book, no, linker)["줄"] diff --git a/M02_MasterTemplete/M02_Item_Snapshot.py b/M02_MasterTemplete/M02_Item_Snapshot.py index efe468cbc..afbfcb312 100644 --- a/M02_MasterTemplete/M02_Item_Snapshot.py +++ b/M02_MasterTemplete/M02_Item_Snapshot.py @@ -233,7 +233,7 @@ def rename_moved(base: Path, wanted: dict[str, tuple[str, dict[str, Any]]]) -> l def group_names() -> dict[str, str]: """옵션 그룹 id → 이름(지금 정의) — 복사본 manifest `그룹` 으로 굳힘(142-2).""" - from M02_MasterTemplete.StructOptions.M02_SO_Groups import groups_of + from M01_MasterData.StructOptions.M01_SO_Groups import groups_of return {g["id"]: g["name"] for rows in groups_of().values() for g in rows} diff --git a/M02_MasterTemplete/M02_Labor_Doc.py b/M02_MasterTemplete/M02_Labor_Doc.py index 8bb2de626..3542da2ee 100644 --- a/M02_MasterTemplete/M02_Labor_Doc.py +++ b/M02_MasterTemplete/M02_Labor_Doc.py @@ -479,6 +479,8 @@ def calc( 사본 `수식.json` 문서 셈 · 855-F B9-2). 없으면 지금 M01 · 층.""" whole, have = lc.live(doc) if whole is None else whole, _area_of(doc.get("열")) if given is None else given # fmt: skip expand = refs.Expand(whole, read or refs.read_ref, have) # 사전조합 안 줄 수량 = 알약 값(723-1) + # 판(859-4) — 고정 줄 · 하위 SC · 가져온 식 SK 가 따름 + expand.basis = basis = fixed.basis_of(doc) if pills is None: pills = combo_store.combo_pills({"담은로직": doc.get("담은로직") or []})["물량"] by_logic = {code: pill for pill in pills for code in pill.get("로직") or []} @@ -488,7 +490,7 @@ def calc( lines.append(ref_line(one["참조"], patch.ref(one, expand))) continue if fixed.is_fixed(one): - lines.append(fixed.line(whole, one[fixed.FIXED])) + lines.append(fixed.line(whole, one[fixed.FIXED], basis)) continue code = one["로직"] pill = by_logic.get(code) or {} diff --git a/M02_MasterTemplete/M02_Labor_Expand.py b/M02_MasterTemplete/M02_Labor_Expand.py index e1032791e..e4de7dfcb 100644 --- a/M02_MasterTemplete/M02_Labor_Expand.py +++ b/M02_MasterTemplete/M02_Labor_Expand.py @@ -37,6 +37,7 @@ class Expand: hands: bool | None = None, ) -> None: self.whole, self.read, self.memo = whole, read, {} + self.basis: str | None = None # 판(859-4) — 부르는 쪽 · 없으면 SC 자기 `본뜬.단가기준` self.given = given or {} self.hands = ( read is not refs.read_ref if hands is None else hands @@ -58,7 +59,8 @@ class Expand: def __call__( self, ref: Ref, trail: tuple[str, ...] = (), basis: str | None = None ) -> dict[str, Any]: - """`basis` = 가져온 식 SK(797-1 산근 속 산근)를 부르는 쪽 단가기준(엑셀 | 우리)으로 셈.""" + """`basis` = 가져온 식 SK(797-1 산근 속 산근) · SC 고정 줄(859-4)을 부르는 쪽 단가기준(엑셀 | 우리)으로 셈.""" + basis = basis or self.basis rid = refs.ref_id(ref) if rid in trail: keys = [t.rsplit("|", 1)[-1] for t in (*trail, rid)] @@ -78,8 +80,12 @@ class Expand: if basis and imp.is_imported(doc): doc = {**doc, "가져온": {**doc["가져온"], "단가기준": basis}} self.memo[memo] = calc.unit(doc, self.whole, self, (*trail, rid)) - else: # 사전조합 = 그 SC 로직 사본(795-2) - self.memo[memo] = lc.combo(self, doc, (*trail, rid)) + else: # 사전조합 = 그 SC 로직 사본(795-2) · 판 = 부르는 쪽 › 자기 것(859-4) + was, self.basis = self.basis, basis or fixed.basis_of(doc) + try: + self.memo[memo] = lc.combo(self, doc, (*trail, rid)) + finally: + self.basis = was return self.memo[memo] @staticmethod @@ -163,7 +169,7 @@ class Expand: elif one.get("로직"): # 로직 줄(51-11) = 1 단위 값(기준 ÷ 배 · 승격과 같음) · 덮개 있음 head, sub = {"로직": one["로직"]}, self._logic(one, by_logic.get(one["로직"]), doc) elif fixed.is_fixed(one): # 고정 줄(705-3) = 줄 단가 · 비율 줄 = 끝에(`ratio_row`) - head, sub = {"고정": one["고정"]}, fixed.line(self.whole, one["고정"]) + head, sub = {"고정": one["고정"]}, fixed.line(self.whole, one["고정"], self.basis) else: continue qty = self._qty(one, f"{rid}#{at}") diff --git a/M02_MasterTemplete/M02_Labor_Fixed.py b/M02_MasterTemplete/M02_Labor_Fixed.py index 4e3b521c1..c9ffedb59 100644 --- a/M02_MasterTemplete/M02_Labor_Fixed.py +++ b/M02_MasterTemplete/M02_Labor_Fixed.py @@ -7,6 +7,8 @@ 못 이음 = null(「손 단가」) — 이은 비목만 단가 책 값 (노임 새 판 때 따라감) · 품(수량)은 그대로. M02 셈(층 · 사본) = 노임 「값」 · 자재 기준단가로 이음 · 기계 = 줄 단가(기계 시간 단가 = B09 단가 책 몫). +판(859-4 · 요구 903) = 문서 `본뜬.단가기준` 「엑셀」(불러온 SC 기본 · 이음 있어도 줄 단가 그대로) | 「우리」 · +칸 없음 = 이은 비목 단가 책 값(`basis_of` · 단가산출 `가져온.단가기준` 과 같은 말). 출처 = `{파일, 호표, 줄, 판}`(글 · 수만) · 줄 가름 = 「고정|이름|규격|단위」(짝 `Labor_Calc.ts` `lineId`). 비율 줄(705-3 · 엑셀 % 줄) = `비율 {기준, 비목}` · 수량 = 율(%) — 반영[비목] = 밑 × 율 ÷ 100 (`ratios` · 짝 `Labor_Calc.ts` `ratioLines` · B09 = `pct` 줄) · 단가산출(SK) 율 더한줄(778-4)도 이 꼴. @@ -34,6 +36,7 @@ SOURCE_KEYS = ("파일", "호표", "줄", "판") # 율 기준 묶음(778-4) ← 고정 줄 이음 GROUPS = {"노임": "인력", "자재": "재료", "기계": "장비", "유가": "재료"} BASES = tuple(dict.fromkeys((*COSTS, *GROUPS.values()))) +BASIS, EXCEL, OURS = "단가기준", "엑셀", "우리" def _bad(text: str) -> Exception: @@ -157,6 +160,13 @@ def _has(whole: Any, code: str) -> bool: return False +def basis_of(doc: Any) -> str | None: + """일위대가 문서 판(859-4) — `본뜬.단가기준` 엑셀 | 우리 · 없음 = None(이은 비목 = 단가 책 값).""" + own = doc.get("본뜬") if isinstance(doc, dict) else None + got = own.get(BASIS) if isinstance(own, dict) else None + return got if got in (EXCEL, OURS) else None + + def link_keys(doc: Any) -> list[str]: """문서 고정 줄이 잇는 키 — 사본 `단가.json` · B09 단가 책 수요(705-1).""" out: list[str] = [] @@ -166,14 +176,14 @@ def link_keys(doc: Any) -> list[str]: return out -def line(whole: Any, fx: dict) -> dict[str, Any]: +def line(whole: Any, fx: dict, basis: str | None = None) -> dict[str, Any]: """고정 줄 계산 답 — 기준 = 줄 단가 · 이은 노임 · 자재는 `whole` 값(없으면 줄 단가 그대로) · - 분모 = 줄 단위 · 배 1 · `이은` = 단가 책 값을 쓴 비목.""" + 분모 = 줄 단위 · 배 1 · `이은` = 단가 책 값을 쓴 비목 · `basis` 엑셀 = 이음 안 봄(859-4).""" base = {k: _num((fx.get("단가") or {}).get(k)) or Decimal(0) for k in COSTS} if fx.get("비율"): # 기준 · 반영 = `ratios`(settle 끝) return {FIXED: fx, "이름": fx.get("이름"), "알약": None, "분모": "%", "배": 100, "기준": {**base, "계": Decimal(0)}, "이은": [], "까닭": None} # fmt: skip - link, used = fx.get("이음") or {}, [] + link, used = {} if basis == EXCEL else fx.get("이음") or {}, [] if code := link.get("노임"): try: got = _num((whole.get(code) or {}).get("값")) diff --git a/M02_MasterTemplete/M02_Layer_Index.py b/M02_MasterTemplete/M02_Layer_Index.py index 00a04b1e9..d15144e56 100644 --- a/M02_MasterTemplete/M02_Layer_Index.py +++ b/M02_MasterTemplete/M02_Layer_Index.py @@ -133,8 +133,9 @@ def _fresh(folder: Path, kind: str, name: str, rec: Any, stamp: str | None, whol deps.setdefault(str(p), file_stamp(p)) token = refs.SEEN.set(note) - try: # 셈마다 새 펼침 — 다른 항목 셈 기억을 나눠 쓰면 기댐이 빠짐 - out = refs.summary(folder, kind, name, Expand(whole), []) + try: # 셈마다 새 펼침 — 다른 항목 셈 기억을 나눠 쓰면 기댐이 빠짐 · 지금 층 = 그 층(내 기계 · 자동 따라옴) + with store.at(folder): + out = refs.summary(folder, kind, name, Expand(whole), []) finally: refs.SEEN.reset(token) out.pop("쓰는곳수", None) diff --git a/M02_MasterTemplete/M02_MasterTemplete_Hopyo_View.ts b/M02_MasterTemplete/M02_MasterTemplete_Hopyo_View.ts index c55102313..c68f80bc7 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Hopyo_View.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Hopyo_View.ts @@ -4,7 +4,8 @@ * 경쟁사 로직 인정 · 요소만 연결 — 몸 = 일위대가 컨테이너 부품(`Labor_Table` · 806-1 조합과 한 벌 · 읽기만) + 덧칸 둘: * · 표지 = 로직 줄 「단가산출 N」 · 「일위대가 N」 칩 / 요소 줄 「✓ 연결됨」 · 「후보 n」 · 「못 이음」(엑셀 값 그대로) * · 엑셀 금액 = 그 줄 엑셀 금액 계 - * 줄 = 서버 `GET …/hopyo-view/{키}/{번}`(`M02_Hopyo_View` · 엑셀 숫자 그대로 고정 줄 · 저장 없음 · 금액 = 엑셀). + * 줄 = 서버 `GET …/hopyo-view/{키}/{번}`(`M02_Hopyo_View` · 엑셀 숫자 그대로 고정 줄 · 저장 없음 · 금액 = 엑셀 판 · + * 일위대가표 머리 판 고르기(859-4 `Labor_Basis`) = [우리 단가로] 미리 셈 · 후보 창 머리 = 자재 판정). * · 단가산출 줄 누름 = 그 블록 가져온 식 모달(`Hopyo_Imported` · 미리 보기 · 층에 안 씀 · 저장 = 모달 [저장] · * 835-1 — 옛 「누르면 SK 만듦」 걷음 · [엑셀 단가 그대로 | 우리 단가로]) * · 일위대가 줄 누름 = 그 하위 호표 [수정] 모달 · 후보 줄 누름 = 후보 목록(고르기 = [내 일위대가로] 뒤 일위대가 [연결]) @@ -65,6 +66,8 @@ export interface ViewMark { 번?: number | null; 이음?: Record; 후보?: { 키: string; 이름: string }[]; + /** 자재 줄 판정(단가산출 불러오기와 같은 말 · 859-4) */ + 판정?: string; 엑셀: Money; } export interface ViewReply { @@ -120,6 +123,7 @@ function showNear(name: string, m: ViewMark): void { dialogClass: "m02-modal", mount: (body) => { const rows = (m.후보 ?? []).map((c) => [c.키, c.이름]); + if (m.판정) body.append(createText(m.판정, "muted")); // 859-4 단가산출 불러오기와 같은 판정 말 body.append(createTable([{ label: t("Key") }, { label: t("Name") }], rows, { density: "data" })); // prettier-ignore body.append(createText(t("NearHint"), "hint")); }, diff --git a/M02_MasterTemplete/M02_MasterTemplete_Labor_Basis.ts b/M02_MasterTemplete/M02_MasterTemplete_Labor_Basis.ts new file mode 100644 index 000000000..54640c852 --- /dev/null +++ b/M02_MasterTemplete/M02_MasterTemplete_Labor_Basis.ts @@ -0,0 +1,40 @@ +/* ============================================================================= + * M02_MasterTemplete_Labor_Basis.ts + * 불러온 일위대가 판 고르기(PLAN 859-4 · 요구 903 ㉢) — [엑셀 단가 그대로 | 우리 단가로]. + * · 자리 = 일위대가표 머리 줄(`Labor_Table`) · 문서 `본뜬.단가기준` 이 있을 때만(불러온 SC · [수정] 미리 보기) + * · 고르면 캐시 문서 판만 바꿔 서버가 다시 셈(저장 없음 · 미리 보기) · 일위대가 화면 [저장] 때 그 판으로 + * · 말 · 부품 = 단가산출 줄 쌓기 판 고르기와 같음(`formula_doc_text` · `ui_template_segment`) + * · 셈 = 서버 `M02_Labor_Fixed.basis_of`(엑셀 = 고정 줄 줄 단가 · 우리 = 이은 비목 단가 책 값) + * ========================================================================== */ + +import { createSegment } from "@ui/ui_template_segment"; +import { ft } from "../A00_Common/formula_doc_text"; + +type Basis = "엑셀" | "우리"; + +/** 판 고르기 — 판 칸 없는 문서 = null(안 그림) */ +export function basisPick( + doc: { 본뜬?: Record | null }, + onPick: () => void, +): HTMLElement | null { + const born = doc.본뜬; + const now = born?.단가기준; + if (!born || (now !== "엑셀" && now !== "우리")) return null; + const seg = createSegment({ + options: [ + { value: "엑셀", label: ft("Basis_Excel") }, + { value: "우리", label: ft("Basis_Ours") }, + ], + value: now, + size: 28, + ariaLabel: ft("Basis_Excel"), + onChange: (v) => { + if (v !== "엑셀" && v !== "우리") return; + born.단가기준 = v satisfies Basis; + seg.root.dataset.laborBasis = v; + onPick(); + }, + }); + seg.root.dataset.laborBasis = now; + return seg.root; +} diff --git a/M02_MasterTemplete/M02_MasterTemplete_Labor_LibMeta.ts b/M02_MasterTemplete/M02_MasterTemplete_Labor_LibMeta.ts index d65966386..7d59aa40b 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Labor_LibMeta.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Labor_LibMeta.ts @@ -5,7 +5,7 @@ * ========================================================================== */ import { createSelectField } from "@ui/ui_template_elements"; -import { fetchStructureDef } from "./StructOptions/M02_SO_Api"; +import { fetchStructureDef } from "../M01_MasterData/StructOptions/M01_SO_Api"; import { precomboClasses } from "./M02_MasterTemplete_UI_Side_Precombo"; import { tc } from "./M02_MasterTemplete_Labor_Text"; diff --git a/M02_MasterTemplete/M02_MasterTemplete_Labor_Pick.ts b/M02_MasterTemplete/M02_MasterTemplete_Labor_Pick.ts index 3a4199dec..547ae1cd9 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Labor_Pick.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Labor_Pick.ts @@ -33,7 +33,7 @@ import { openStandardSheet } from "./M02_MasterTemplete_Labor_Sheet"; import type { LaborFixed, LaborRef } from "./M02_MasterTemplete_Labor_Calc"; import { tc } from "./M02_MasterTemplete_Labor_Text"; import { precomboClasses } from "./M02_MasterTemplete_UI_Side_Precombo"; -import { fetchStructureDef } from "./StructOptions/M02_SO_Api"; +import { fetchStructureDef } from "../M01_MasterData/StructOptions/M01_SO_Api"; import "../M01_MasterData/M01_MasterData_UI_Logic_Style.css"; // 창 겉틀 import "./M02_MasterTemplete_Labor.css"; import { openModal } from "@ui/ui_template_modal"; diff --git a/M02_MasterTemplete/M02_MasterTemplete_Labor_Table.ts b/M02_MasterTemplete/M02_MasterTemplete_Labor_Table.ts index a528f61f5..2da8d4496 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Labor_Table.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Labor_Table.ts @@ -56,6 +56,7 @@ import { insideKeys } from "./M02_Labor_LogicMats_Model"; import { valueLine } from "./M02_Labor_Values_Model"; import { createUnitPick, NO_UNIT } from "@ui/ui_template_unit_pick"; import { libMeta } from "./M02_MasterTemplete_Labor_LibMeta"; +import { basisPick } from "./M02_MasterTemplete_Labor_Basis"; import "../M01_MasterData/M01_MasterData_UI_Logic_Style.css"; import "../M01_MasterData/M01_MasterData_UI_LogicLab_Style.css"; import "@ui/ui_template_general_layout.css"; @@ -532,6 +533,7 @@ export function mountLaborTable( className: "m01-logic__section-head", children: [ el("h3", { text: tc("Grid_Title") }), + ...[basisPick(cur, () => changed())].filter((x) => x !== null), // 859-4 불러온 SC 판 ...(edit && own && !(combo && opt.card) ? [el("div", { className: "ui-btn-group", children: [addLogic] })] : []), diff --git a/M02_MasterTemplete/M02_MasterTemplete_UI_Side_Precombo.ts b/M02_MasterTemplete/M02_MasterTemplete_UI_Side_Precombo.ts index c97bf1697..677c8d229 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_UI_Side_Precombo.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_UI_Side_Precombo.ts @@ -9,7 +9,7 @@ import type { TreeMenuItem } from "@ui/ui_template_tree"; import type { Kind } from "./M02_MasterTemplete_Api_Fetch"; -import type { StructDef } from "./StructOptions/M02_SO_Def_Model"; +import type { StructDef } from "../M01_MasterData/StructOptions/M01_SO_Def_Model"; import { tc } from "./M02_MasterTemplete_Labor_Text"; import type { Selection } from "./M02_MasterTemplete_UI_Main"; import { diff --git a/M02_MasterTemplete/M02_MyMachine.py b/M02_MasterTemplete/M02_MyMachine.py index e6137860b..f41ba4c1a 100644 --- a/M02_MasterTemplete/M02_MyMachine.py +++ b/M02_MasterTemplete/M02_MyMachine.py @@ -469,16 +469,44 @@ def update(key: str, raw: Any, ver: str | None = None) -> dict[str, Any]: def delete(key: str) -> dict[str, Any]: - """지움 — 이미 만든 단가산출은 사본의 마지막 값 그대로(「지운키」).""" + """지움 — 쓰던 단가산출은 지우기 직전 값 그대로(`_hold` · 요구 902).""" _user() _old(key) - used = library_uses.machines().get(key, []) with _LOCK: _old(key) + used = library_uses.machines().get(key, []) + _hold(key, used) (_dir() / f"{key}.json").unlink(missing_ok=True) return {"지움": key, "쓰는곳": used} +def _hold(key: str, used: list[dict]) -> None: + """쓰던 단가산출 값 사본(옛 칸 · 수식)의 그 기계 줄 = 지금 따라와 있던 줄로 굳힘 — 지운 키는 사본 + 마지막 줄을 읽음(`M02_Sk_AutoRenew._fresh`) · 굳은 사본(프로젝트 등)은 그대로 · 잠금 안에서 부름.""" + from M02_MasterTemplete import M02_Sangeun_Copy as skc + from M02_MasterTemplete import M02_Sangeun_Doc as sd + from M02_MasterTemplete import M02_Sk_AutoRenew as renew + + if not renew.on(): # 안 따라오는 층 = 사본 그대로 + return + live = skc.whole_() + for one in used: + path = store._path(sd.KIND, str(one["키"])) + doc = json.loads(path.read_bytes()) + if renew.frozen(doc.get(skc.FORM)): + continue + for part in (skc.KEY, skc.FORM): + copy = doc.get(part) + old = copy.get("단가") if isinstance(copy, dict) else None + if isinstance(old, list): + new = [ + renew._fresh(r, live) if isinstance(r, dict) and r.get("키") == key else r + for r in old + ] + copy |= {"단가": new, "단가판": skc._fp(new)} + atomic_write_json(path, doc) + + def same(name: Any, spec: Any, skip: str = "") -> list[dict]: """같은 이름 · 규격 알림 — M01 기계 · 이 층 내 기계(표기 정규화 `M02_Machine_Find.norm`).""" from M02_MasterTemplete.M02_Machine_Find import norm diff --git a/M02_MasterTemplete/M02_San_Link.py b/M02_MasterTemplete/M02_San_Link.py index ba7ece72d..7fb6e78ab 100644 --- a/M02_MasterTemplete/M02_San_Link.py +++ b/M02_MasterTemplete/M02_San_Link.py @@ -29,6 +29,7 @@ def m01(kind: str, src: dict, label: str = "") -> tuple[str | None, str | None]: from M02_MasterTemplete import M02_San_MatFind as mf line = {k: src.get(k) or "" for k in ("이름", "규격", "단위")} + price = excel_price(src) # 859-4 같은 품목 여러 줄 = 엑셀 값 가까운 줄 if kind == "재료" and apart(line): # 817-1 원가 합 밖(원본 금액 그대로) · 827-2 품목은 판정에 clean = hmat_clean(line) got = mf.find(clean, src, _keys(clean, hrow.m01_picks("재료", clean)), label, apart=True) @@ -44,7 +45,7 @@ def m01(kind: str, src: dict, label: str = "") -> tuple[str | None, str | None]: return got["키"], mfind.mark(got, line["이름"], line["규격"]) if kind == "재료" and src.get("종류") == "자재" and (hit := ea.est_code(src.get("코드"))): key = ea.one(line, hit) or hit[0] # 815-1 K1 — EST 원파일 자재 = 우리 자재 출처 코드 - return mf.done(key, "코드", src, line["단위"])["키"], None # 840-3 단위 맞춤 + return mf.done(key, "코드", src, line["단위"], price)["키"], None # 840-3 단위 맞춤 oil = ea.keys("MO", line["이름"], line["규격"]) if kind == "재료" else [] if kind == "재료": if oil or elem.oil_rows(line["이름"]): @@ -63,7 +64,7 @@ def m01(kind: str, src: dict, label: str = "") -> tuple[str | None, str | None]: else: got = hrow.m01_picks(kind, line) if kind == "재료": # 827-2 — 지금 찾기 키 → 판정(규칙 · 단서 · 네 갈래) - return mf.find(line, src, _keys(line, got), label)["키"], None + return mf.find({**line, "단가": price}, src, _keys(line, got), label)["키"], None keys = {x.get("키") for x in got if x.get("키")} if ( len(keys) > 1 and kind == "유가" @@ -76,6 +77,16 @@ def m01(kind: str, src: dict, label: str = "") -> tuple[str | None, str | None]: return None, None +def excel_price(src: dict) -> float | None: + """자원 엑셀 단가(`단가` {L · M · S}[비목] · 비목 없음 = 재료비 M) — 없음 · 0 = None.""" + price = src.get("단가") if isinstance(src.get("단가"), dict) else {} + try: + got = float(str(price.get(src.get("비목") or "M")).replace(",", "")) + except (TypeError, ValueError): + return None + return got if got > 0 else None + + def _keys(line: dict, got: list[dict]) -> set[str]: """재료 1차 찾기 키 — 여럿이면 지역 꼬리 뗀 정확 일치(814-1) · 없으면 자재표 전체 정확 일치(815-1 K3).""" from M02_MasterTemplete import M02_Elem_Alias as ea diff --git a/M02_MasterTemplete/M02_San_MatFind.py b/M02_MasterTemplete/M02_San_MatFind.py index f89376c6c..7c7adf22e 100644 --- a/M02_MasterTemplete/M02_San_MatFind.py +++ b/M02_MasterTemplete/M02_San_MatFind.py @@ -1,6 +1,7 @@ """불러오기 재료 찾기 판정 · 단서 · 자동 규칙(PLAN 827-2 · 요구 810 ~ 812 · 조사 810-2 · 811-2). -`M02_San_Link.m01` 재료 줄이 부름 · 서버 단독 · 읽기만 · 판정은 이름 · 규격 · 단위 · 단서 글만(단가 값 안 봄) · +`M02_San_Link.m01` 재료 줄이 부름(단가산출 · 일위대가 불러오기 한 벌 · 859-4) · 서버 단독 · 읽기만 · +판정은 이름 · 규격 · 단위 · 단서 글만 · 이은 뒤 같은 품목 여러 줄 = 엑셀 단가와 값이 가장 가까운 줄(`closest`) · 별칭을 만들거나 제안하지 않음(별칭 = 사람이 표기 변형을 잇는 칸 · 요구 812-1). 줄 판정 `자원["재료찾기"]` = {판정, 방법, 키, 후보, 단서}: @@ -36,6 +37,7 @@ from typing import Any from M02_MasterTemplete import M02_Hopyo_Match as hm from M02_MasterTemplete import M02_Hopyo_Material as hmat from M02_MasterTemplete import M02_Hopyo_MatSame as ms +from M02_MasterTemplete import M02_Mat_Place as place LINKED, NO_SPEC, MANY, NONE = "이어짐", "규격 없음 — 고르기", "후보 여럿", "우리 표에 없음" UNIT = "단위 다름 — 고르기" @@ -125,21 +127,25 @@ def _texts(me: dict, code: str, label: str) -> tuple[tuple[str, str], ...]: def find( line: dict, src: dict | None = None, keys: Any = (), label: str = "", apart: bool = False ) -> dict: - """재료 줄(별도계상 글 뗀) → 판정(`src` 있으면 `자원["재료찾기"]` 에 둠) · keys = 지금 엔진 찾기 키들.""" + """재료 줄(별도계상 글 뗀 · `단가` = 엑셀 단가) → 판정(`src` 있으면 `자원["재료찾기"]` 에 둠) · + keys = 지금 엔진 찾기 키들.""" text = tuple(str(line.get(k) or "") for k in ("이름", "규격", "단위")) code = str((src or {}).get("코드") or "") me = ms._item(text[0], text[1]) keys = tuple(sorted(k for k in keys if k)) got = _by_unit(line, dict(_find(*text, keys, _texts(me, code, label), apart, id(hm.targets())))) + got = closest(line, got) got |= {"후보": [dict(x) for x in got["후보"]], "단서": list(got["단서"])} if src is not None: src["재료찾기"] = got return got -def done(key: str, how: str, src: dict | None = None, unit: str = "") -> dict: - """이미 정한 이음(코드 길) 판정.""" +def done(key: str, how: str, src: dict | None = None, unit: str = "", price: Any = None) -> dict: + """이미 정한 이음(코드 길) 판정 · `price` = 엑셀 단가(같은 품목 지역 줄 고름).""" got = _by_unit({"단위": unit}, {"판정": LINKED, "방법": how, "키": key, "후보": [], "단서": []}) + head = {k: (src or {}).get(k) or "" for k in ("이름", "규격")} + got = closest({**head, "단위": unit, "단가": price}, got) if src is not None: src["재료찾기"] = got return got @@ -200,6 +206,60 @@ def _by_unit(line: dict, got: dict) -> dict: } +def closest(line: dict, got: dict) -> dict: + """같은 품목 여러 줄 → 엑셀 단가(`line["단가"]`)와 값이 가장 가까운 줄(859-4 · 요구 903) — 이은 판정만 · + 쌍둥이 = 지역 꼬리 뗀 이름 · 규격 같은 줄(`ea.exact` · 지역 · 상하차) + 표기만 다른 같은 품목 줄 + (`ms.peers` · 관급/사급 · 덧말) · 이은 줄과 같은 단위 · 줄 글이 밝힌 지역 · 상하차 · 관급/사급이 맞는 줄 먼저 + (「외송각재, 대전」 = 대전 줄들 안에서) · 값 같음 · 엑셀 값 없음 = 지금 차례 그대로.""" + from M02_MasterTemplete import M02_Elem_Alias as ea + + want, key = _money(line.get("단가")), got.get("키") + if want is None or got["판정"] != LINKED or not key: + return got + row = ea.row(ea.MARKET, key) + if not row: + return got + unit, plain = row.get("단위"), hm.mm.plain_unit + pool = [key, *ea.exact(row.get("이름"), row.get("규격"))] + pool += ( + ms.peers({k: line.get(k) or "" for k in ("이름", "규격", "단위")}) + if line.get("이름") + else [] + ) + pool = [k for k in pool if _told(line, ea.row(ea.MARKET, k))] or pool + + def gap(k: str) -> float | None: + r = ea.row(ea.MARKET, k) + v = _money(place.value(r)) if r else None + return None if v is None or plain(r.get("단위")) != plain(unit) else abs(v - want) + + scored = [(g, i, k) for i, k in enumerate(dict.fromkeys(pool)) if (g := gap(k)) is not None] + best = min(scored)[2] if scored else key + return got if best == key else {**got, "키": best, "방법": f"{got['방법']} · 값 가까운 줄"} + + +def _told(line: dict, row: dict) -> bool: + """우리 줄이 가져온 줄 글이 밝힌 지역 · 상하차 · 관급/사급과 맞음(밝힘 없음 = 맞음).""" + spot = place.line(line.get("이름"), line.get("규격")) + where = str(row.get("지역") or place.mmerge.where(row)) + if spot["지역"] not in ("", place.NONE) and not place.hit(where, spot["지역"]): + return False + if spot["상하차"] not in ("", place.NONE) and row.get("상하차") != spot["상하차"]: + return False + text = f"{line.get('이름') or ''} {line.get('규격') or ''}" + want = next((w for w in hmat.SUPPLY if w in text), None) + have = next((w for w in hmat.SUPPLY if w in str(row.get("이름") or "")), None) + return want is None or have in (None, want) + + +def _money(raw: Any) -> float | None: + try: + got = float(str(raw).replace(",", "")) + except (TypeError, ValueError): + return None + return got if got > 0 else None + + def _alike(me: dict, x: dict) -> bool: """이름 같은 우리 줄이 이 물건일 수 있음 — 우리 규격 빔 · 가져온 수 없음 · 수 하나라도 같음(BUTTON BIT Ø38 ↔ 105mm = 아님).""" return ( diff --git a/M02_MasterTemplete/M02_Table_Fill.py b/M02_MasterTemplete/M02_Table_Fill.py index fb34caad1..10c29e301 100644 --- a/M02_MasterTemplete/M02_Table_Fill.py +++ b/M02_MasterTemplete/M02_Table_Fill.py @@ -150,9 +150,9 @@ def _with_group_items(items: list[dict[str, Any]], project_root=None) -> list[di 복사본 `{구조물 id}__{그룹 id}`. 그룹 = 지금 정의 + 복사본에 굳힌 정의(142-2 · 이름 · 사라진 그룹도) · 미지정 그룹 = 「미지정」 알림에 셈.""" from common_util.common_util_summary_item import GROUP_JOIN + from M01_MasterData.StructOptions.M01_SO_Groups import groups_of from M02_MasterTemplete.M02_Item_Snapshot import copied_groups from M02_MasterTemplete.M02_Table_Fill_Spec import container_rows - from M02_MasterTemplete.StructOptions.M02_SO_Groups import groups_of defined = groups_of() out: list[dict[str, Any]] = [] diff --git a/common_util/common_util_formula_doc_cache.ts b/common_util/common_util_formula_doc_cache.ts index 792438dea..88c0a9d21 100644 --- a/common_util/common_util_formula_doc_cache.ts +++ b/common_util/common_util_formula_doc_cache.ts @@ -44,6 +44,8 @@ export interface DocCache { takeMissing: () => boolean; /** 표 하나 넣음(고르기에서 받은 것) */ putTable: (ref: string, table: DocTable) => void; + /** 표 통째(859-3 보이는 자리 — 줄마다 원문 글자 자리 `자리`) · 없으면 undefined */ + tableOf: (ref: string) => (DocTable & { 끊김?: string }) | undefined; } export function createDocCache(): DocCache { @@ -99,5 +101,8 @@ export function createDocCache(): DocCache { putTable(ref, table) { tables.set(ref, table); }, + tableOf(ref) { + return tables.get(ref) ?? undefined; + }, }; } diff --git a/common_util/common_util_m02_call.ts b/common_util/common_util_m02_call.ts index 04053dbd4..17768ff5a 100644 --- a/common_util/common_util_m02_call.ts +++ b/common_util/common_util_m02_call.ts @@ -20,9 +20,9 @@ export class StaleError extends Error { } } -/** `/api/m02` 아래 길 부름 — 409 = StaleError · 그 밖 실패 = 서버 까닭 글(하위 폴더도 씀) */ -export async function call(path: string, init: RequestInit = {}): Promise { - const response = await fetch(`${API_BASE_URL}/m02${path}`, { +/** `/api/m02` 아래 길 부름(`base` = 다른 묶음 · M01 구조물 정의 `/m01`) — 409 = StaleError · 그 밖 실패 = 서버 까닭 글(하위 폴더도 씀) */ +export async function call(path: string, init: RequestInit = {}, base = "/m02"): Promise { + const response = await fetch(`${API_BASE_URL}${base}${path}`, { credentials: "include", headers: { "Content-Type": "application/json" }, ...init, diff --git a/common_util/common_util_show_digits.ts b/common_util/common_util_show_digits.ts new file mode 100644 index 000000000..56b0e6c89 --- /dev/null +++ b/common_util/common_util_show_digits.ts @@ -0,0 +1,154 @@ +/* ============================================================================= + * common_util_show_digits.ts + * 보이는 수의 자릿수 규칙 한 벌(PLAN 859-3 · 856-5 · 요구 898 · 902) — 셈 값 · 저장 값 · 금액은 그대로 · 그리는 글자만 + * ⚠ 짝 = resources/master_data/scripts/master_doc_digits.py(같은 규칙 · 한쪽을 고치면 다른 쪽도) · + * 거울 시험 resources/tester/test_859_3_show_digits.py + * 갈래(`digitKind`) = 문서 식 줄 → 「식」 · 변수 연결 표 → 「표」 · 입력 · 선택 → 「입력」 · 그 밖(요소 · 단가산출) → 「요소」 + * 규칙(자리 값은 `RULE` 한 곳): + * 표 = 고른 표 줄의 원문 글자 자리(끝 0 살림 — 건설 · 산림 1-2-2 1 [주]② 「항목에서 제시한 소수자리 우선」 · + * 서버가 표 캐시에 줄마다 `자리` 를 실음) · 글자 자리를 모르면(끝 0 빠진 자료 · 사용자가 바꾼 값) 자료 수 그대로 + * 식 = 기호 Q 3 · n 2 · cm 3 자리(건설 8-1 [주]① 계산값의 맺음) › + * 단위가 원(원/…) · 비목 이름(노무비 · 재료비 · 경비)이면 소수 한 자리(1-2-2 2 「일위대가표의 금액란 0.1 원」 준용) › + * 그 밖 = 유효숫자 3 · 소수 최소 2 · 최대 6(1-2-2 3 시공단위 품 표 근사 · 정수는 정수) + * 입력 · 요소 = 자료 수 그대로(소수 여섯 자리까지 · 끝 0 뗌 — `eqText`) + * 수 꼴 = 천 단위 쉼표 · 반올림(Intl — 짧은 10 진 글 기준 0.5 올림) · 화면 · fetch 없음 + * ========================================================================== */ + +import { varId, type DocVar, type FormulaDoc } from "./common_util_formula_doc"; +import { findRow, type DocTable } from "./common_util_formula_doc_table"; +import { evalNode, tryParse, type Values } from "./common_util_formula_doc_view"; + +/** 자리 값 표 — 사용자 확정 값이 바뀌면 여기만 고침(짝 PY `RULE`) */ +export const RULE = { + /** 입력 · 요소 · 자리 모르는 표 값 = 최대 자리(끝 0 뗌) */ + plain: 6, + /** 건설 8-1 [주]① — 식이 낸 값 · 기호 그대로 */ + symbol: { Q: 3, n: 2, cm: 3 } as Record, + /** 원 단위 중간 값(율 줄 단가 · 원/… 식 값) */ + money: 1, + /** 단위 없는 비목 값(기계 시간당 식) = 원 */ + moneyNames: ["노무비", "재료비", "경비"], + /** 그 밖 식 값 — 유효숫자 · 소수 최소(정수는 정수) · 최대 */ + sig: 3, + min: 2, + max: 6, +}; + +export type DigitKind = "식" | "표" | "입력" | "요소"; + +/** 서버 표 캐시 줄마다 원문 글자 자리(끝 0 있는 칸만) — `master_doc_record` 가 실음 */ +export type PlacedTable = DocTable & { 자리?: (Record | null)[] | null }; + +const formats = new Map(); +/** 소수 `hi` 자리 반올림 · 끝 0 은 `lo` 자리까지 뗌 · 천 단위 쉼표 */ +export function fmt(n: number, lo: number, hi: number): string { + const k = `${lo}:${hi}`; + let f = formats.get(k); + if (!f) { + f = new Intl.NumberFormat("ko-KR", { minimumFractionDigits: lo, maximumFractionDigits: hi }); + formats.set(k, f); + } + return f.format(n); +} + +/** 짧은 10 진 글의 [소수 자리, 맨 앞 자리 지수] — 0.0278 → [4, -2] */ +function digits(n: number): [number, number] { + const [m, e] = Math.abs(n).toExponential().split("e"); + const exp = Number(e); + const frac = (m.split(".")[1] ?? "").length; + return [Math.max(0, frac - exp), exp]; +} + +/** 표 값의 원문 글자 자리 — 지금 조건으로 고른 줄의 그 칸 · 값이 그 줄 값과 같을 때만(사용자가 바꾼 값 = undefined) */ +export function tablePlaces( + v: DocVar | undefined, + value: unknown, + vals: Values, + tableOf?: (ref: string) => PlacedTable | null | undefined, +): number | undefined { + const k = v?.연결; + const ref = String(k?.표 ?? ""); + const col = k?.칸; + if (!tableOf || !ref || !col || ref.includes("{")) return undefined; + const 조건: Record = {}; + for (const [c, t] of Object.entries(k?.조건 ?? {})) { + const n = tryParse(t); + if (n) 조건[c] = evalNode(n, vals); + } + try { + const t = tableOf(ref); + if (!t?.줄) return undefined; + const row = findRow(t, 조건, col); + if (typeof row[col] !== "number" || row[col] !== value) return undefined; + return t.자리?.[t.줄.indexOf(row)]?.[col] ?? undefined; + } catch { + return undefined; + } +} + +/** 값 갈래 — 식 · 표 · 입력 · 요소 */ +export function digitKind(doc: Pick, name: string, v?: DocVar): DigitKind { + if ((doc.식 ?? []).some((x) => String(x.기호 ?? "") === name)) return "식"; + const kind = v?.연결?.갈래; + if (kind === "표") return "표"; + if (kind === "입력" || kind === "선택") return "입력"; + return v ? "요소" : "식"; +} + +/** 보이는 수 글 — `places` = 표 원문 글자 자리(모르면 없음) · 수가 아니면 글 그대로 */ +export function showDigits( + value: unknown, + kind: DigitKind = "요소", + name = "", + unit = "", + places?: number, +): string { + if (value === null || value === undefined || value === "") return ""; + if (typeof value !== "number" || !Number.isFinite(value)) return String(value); + const [own, exp] = digits(value); + if (kind === "표") { + const p = Math.max(places ?? 0, own); + return p <= RULE.plain ? fmt(value, p, p) : fmt(value, 0, RULE.plain); + } + if (kind !== "식") return fmt(value, 0, RULE.plain); + if (Object.prototype.hasOwnProperty.call(RULE.symbol, name)) + return fmt(value, 0, RULE.symbol[name]); + if (unit.trim().startsWith("원") || RULE.moneyNames.includes(name)) + return fmt(value, 0, RULE.money); + if (Number.isInteger(value)) return fmt(value, 0, 0); + const hi = Math.max(RULE.min, Math.min(RULE.max, RULE.sig - 1 - exp)); + return fmt(value, RULE.min, hi); +} + +/** 값이 온 기호 — 식 줄이 기호 하나(만약 = 지금 탄 갈래)면 그 기호로 따라감(K = 만약(K_입력 > 0, K_입력, K_2) → K_2) */ +export function digitSource(doc: Pick, name: string, vals: Values): string { + const lines = new Map((doc.식 ?? []).map((x) => [String(x.기호 ?? ""), x.식])); + let at = name; + for (let hop = 0; hop < 8 && lines.has(at); hop++) { + let n = tryParse(lines.get(at)); + while (n && n[0] === "call" && n[1] === "만약" && n[2].length === 3) { + const t = evalNode(n[2][0], vals); + if (t === undefined) return at; + n = n[2][t ? 1 : 2]; + } + if (!n || n[0] !== "var" || n[1] === at) return at; + at = n[1]; + } + return at; +} + +/** 문서 기호 값 글 한 벌 — 값이 온 기호의 갈래 · 표 원문 글자 자리 · 단위(`unit` = 부르는 쪽이 정한 단위) */ +export function showValue( + doc: Pick, + name: string, + value: unknown, + vals: Values, + tableOf?: (ref: string) => PlacedTable | null | undefined, + unit?: string, +): string { + const src = digitSource(doc, name, vals); + const v = (doc.변수 ?? []).find((x) => varId(x) === src); + const kind = digitKind(doc, src, v); + const places = kind === "표" ? tablePlaces(v, value, vals, tableOf) : undefined; + return showDigits(value, kind, src, unit ?? String(v?.단위 ?? ""), places); +} diff --git a/common_util/common_util_summary_item.py b/common_util/common_util_summary_item.py index 4aa4068bf..1c3a7db90 100644 --- a/common_util/common_util_summary_item.py +++ b/common_util/common_util_summary_item.py @@ -71,7 +71,7 @@ def parse_summary_item(value: Any) -> dict[str, Any] | None: return {**out, "spec": spec.strip()} if spec is not None else out -#: 옵션 그룹 id(PLAN 46 · `M02_SO_Groups.GROUP_ID` 와 같은 규칙) +#: 옵션 그룹 id(PLAN 46 · `M01_SO_Groups.GROUP_ID` 와 같은 규칙) _GROUP_ID = re.compile(r"^g[0-9a-z]{1,16}$") #: 그룹 복사본 이름 잇개 — `{구조물 id}__{그룹 id}`(구조물 id 는 hex · 관은 `pipe@측점`) GROUP_JOIN = "__" diff --git a/main.py b/main.py index 944c49de9..a6470e356 100644 --- a/main.py +++ b/main.py @@ -105,8 +105,8 @@ from M02_MasterTemplete.M02_MasterTemplete_Router_Drawing import router as m02_d from M02_MasterTemplete.M02_MasterTemplete_Router_Items import router as m02_items_router from M02_MasterTemplete.M02_MasterTemplete_Router_Layers import router as m02_layers_router from M02_MasterTemplete.M02_Project_Items_Router import router as m02_project_items_router -from M02_MasterTemplete.StructOptions.M02_SO_Router import read_router as m02_so_read_router -from M02_MasterTemplete.StructOptions.M02_SO_Router import router as m02_so_router +from M01_MasterData.StructOptions.M01_SO_Router import read_router as m01_so_read_router +from M01_MasterData.StructOptions.M01_SO_Router import router as m01_so_router from common_util.common_util_audit import note_api_call, record_call_burst from common_util.common_util_auth import ( require_company, @@ -557,9 +557,9 @@ app.include_router( dependencies=protected, ) # 마스터 템플릿 층(시스템·회사·개인·프로젝트)·도면 길은 로그인만(권한은 길 안에서) · 옛 시스템 전용 길은 걷음(894). -# 구조물 옵션 보이기 · 그룹(PLAN 46) — 고쳐 씀은 시스템 관리자 · 읽기는 로그인만 -app.include_router(m02_so_router, dependencies=system_admin_only) -app.include_router(m02_so_read_router, dependencies=protected) +# M01 구조물 정의 · 옵션 보이기 · 그룹(PLAN 46 · 859-5) — 고쳐 씀은 시스템 관리자 · 읽기는 로그인만 +app.include_router(m01_so_router, dependencies=system_admin_only) +app.include_router(m01_so_read_router, dependencies=protected) app.include_router(m02_layers_router, dependencies=protected) app.include_router(m02_items_router, dependencies=protected) app.include_router(m02_combos_router, dependencies=protected) diff --git a/resources/master_data/scripts/master_doc_digits.py b/resources/master_data/scripts/master_doc_digits.py new file mode 100644 index 000000000..a848cab76 --- /dev/null +++ b/resources/master_data/scripts/master_doc_digits.py @@ -0,0 +1,185 @@ +# -*- coding: utf-8 -*- +"""보이는 수의 자릿수 규칙 한 벌(PLAN 859-3 · 856-5 · 요구 898 · 902) — +셈 값 · 저장 값 · 금액은 그대로 · 그리는 글자만. + +⚠ 짝 = `common_util/common_util_show_digits.ts`(같은 규칙 · 한쪽을 고치면 다른 쪽도) · + 거울 시험 `resources/tester/test_859_3_show_digits.py`. +갈래(`kind_of`) = 문서 식 줄 → 「식」 · 변수 연결 표 → 「표」 · 입력 · 선택 → 「입력」 · + 그 밖(요소 · 단가산출) → 「요소」. +규칙(자리 값은 `RULE` 한 곳): + 표 = 고른 표 줄의 원문 글자 자리(끝 0 살림 — + 건설 · 산림 1-2-2 1 [주]② 「항목에서 제시한 소수자리 우선」) · + 글자 자리를 모르면(끝 0 빠진 자료 · 사용자가 바꾼 값) 자료 수 그대로 + 식 = 기호 Q 3 · n 2 · cm 3 자리(건설 8-1 [주]① 계산값의 맺음) › + 단위가 원(원/…) · 비목 이름(노무비 · 재료비 · 경비)이면 소수 한 자리 + (1-2-2 2 「일위대가표의 금액란 0.1 원」 준용) › + 그 밖 = 유효숫자 3 · 소수 최소 2 · 최대 6(1-2-2 3 시공단위 품 표 근사 · 정수는 정수) + 입력 · 요소 = 자료 수 그대로(소수 여섯 자리까지 · 끝 0 뗌 — `eqText`) +수 꼴 = 천 단위 쉼표 · 반올림(0.5 올림 · 짧은 10 진 글 기준 — 화면 `Intl` 과 같음). +""" + +from __future__ import annotations + +from decimal import ROUND_HALF_UP, Decimal, InvalidOperation + +#: 자리 값 표 — 사용자 확정 값이 바뀌면 여기만 고침(짝 TS `RULE`) +RULE = { + "plain": 6, # 입력 · 요소 · 자리 모르는 표 값 = 최대 자리(끝 0 뗌) + "symbol": {"Q": 3, "n": 2, "cm": 3}, # 건설 8-1 [주]① — 식이 낸 값 · 기호 그대로 + "money": 1, # 원 단위 중간 값(율 줄 단가 · 원/… 식 값) + "money_names": ("노무비", "재료비", "경비"), # 단위 없는 비목 값(기계 시간당 식) = 원 + "sig": 3, # 그 밖 식 값 — 유효숫자 + "min": 2, # 〃 소수 최소(정수는 정수) + "max": 6, # 〃 소수 최대 +} + + +def dec(v) -> Decimal | None: + """수 → Decimal(화면 double 의 짧은 10 진 글 · 글 · 참거짓 · 빈 값 = None).""" + if isinstance(v, bool) or v is None or isinstance(v, str): + return None + try: + d = Decimal(repr(float(v))) # 화면 수(double)와 같은 짧은 10 진 글 + except (InvalidOperation, ValueError, TypeError, OverflowError): + return None + return d if d.is_finite() else None + + +def fmt(d: Decimal, lo: int, hi: int) -> str: + """소수 `hi` 자리 반올림 · 끝 0 은 `lo` 자리까지 뗌 · 천 단위 쉼표 + (Intl 과 같음 — 0 으로 반올림된 음수 = 「-0」).""" + q = d.quantize(Decimal(1).scaleb(-hi), ROUND_HALF_UP) + sign = "-" if q.is_signed() else "" + whole, _, frac = f"{abs(q):f}".partition(".") + frac = frac.rstrip("0") + frac += "0" * (lo - len(frac)) + head = f"{int(whole):,}" + return f"{sign}{head}.{frac}" if frac else f"{sign}{head}" + + +def places_of(d: Decimal) -> int: + """짧은 10 진 글의 소수 자리(0.10 → 1 · 3.0 → 0).""" + exp = d.normalize().as_tuple().exponent + return -exp if isinstance(exp, int) and exp < 0 else 0 + + +def text_places(d: Decimal) -> int: + """글자 그대로의 소수 자리(Decimal('0.10') → 2 · 표 파일 원문 글자).""" + exp = d.as_tuple().exponent + return -exp if isinstance(exp, int) and exp < 0 else 0 + + +def row_places(row: dict) -> dict: + """표 줄의 칸마다 원문 글자 자리 — 짧은 글보다 길 때만(끝 0 · 화면 캐시 `자리`).""" + out = {} + for col, v in row.items(): + if isinstance(v, Decimal) and v.is_finite() and text_places(v) > places_of(v): + out[col] = text_places(v) + return out + + +def table_places(table: dict) -> list | None: + """표 줄마다 `row_places`(끝 0 없는 줄 = None) · 표 통째 끝 0 없음 = None.""" + got = [row_places(r) if isinstance(r, dict) else {} for r in table.get("줄") or []] + return [x or None for x in got] if any(got) else None + + +def table_value_places(link: dict, value, evaluate, get_table) -> int | None: + """표 값의 원문 글자 자리 — 지금 조건으로 고른 줄(`find`)의 그 칸 글자 · + 값이 그 줄 값과 같을 때만(사용자가 바꾼 값 = None) · + `evaluate(식 나무)` = 조건 값 · `get_table(키)` = 표(못 읽으면 None).""" + import master_doc as md + import master_doc_link as ml + + ref, col = str(link.get("표") or ""), link.get("칸") + if not ref or not col or "{" in ref: + return None + conds = {} + for c, t in (link.get("조건") or {}).items(): + try: + n = md.parse(t) + except md.DocError: + continue + conds[c] = evaluate(n) + try: + table = get_table(ref) + row = ml.find(table, conds, col) if table else None + except Exception: # noqa: BLE001 — 그림용 · 못 찾으면 자료 수 그대로 + return None + if not row or dec(row.get(col)) is None or dec(row.get(col)) != dec(value): + return None + return row_places(row).get(col) + + +def kind_of(doc: dict, name: str, var: dict | None = None) -> str: + """값 갈래 — 식 · 표 · 입력 · 요소.""" + if any(str(x.get("기호") or "") == name for x in doc.get("식") or []): + return "식" + kind = ((var or {}).get("연결") or {}).get("갈래") + if kind == "표": + return "표" + if kind in ("입력", "선택"): + return "입력" + return "요소" if var is not None else "식" + + +def show(v, kind: str = "요소", name: str = "", unit: str = "", places: int | None = None) -> str: + """보이는 수 글 — `places` = 표 원문 글자 자리(모르면 None) · 수가 아니면 글 그대로.""" + if v is None or v == "": + return "" + if isinstance(v, bool): + return "true" if v else "false" + d = dec(v) + if d is None: + return str(v) + if kind == "표": + p = max(places or 0, places_of(d)) + return fmt(d, p, p) if p <= RULE["plain"] else fmt(d, 0, RULE["plain"]) + if kind != "식": + return fmt(d, 0, RULE["plain"]) + if name in RULE["symbol"]: + return fmt(d, 0, RULE["symbol"][name]) + if str(unit or "").strip().startswith("원") or name in RULE["money_names"]: + return fmt(d, 0, RULE["money"]) + if d == d.to_integral_value(): + return fmt(d, 0, 0) + hi = max(RULE["min"], min(RULE["max"], RULE["sig"] - 1 - d.adjusted())) + return fmt(d, RULE["min"], hi) + + +def source(doc: dict, name: str, evaluate) -> str: + """값이 온 기호 — 식 줄이 기호 하나(만약 = 지금 탄 갈래)면 그 기호로 따라감 · + `evaluate(식 나무)` = 그림용 값(모르면 None).""" + import master_doc as md + + lines = {str(x.get("기호") or ""): x.get("식") for x in doc.get("식") or []} + at = name + for _ in range(8): + if at not in lines: + break + try: + n = md.parse(lines[at]) + except md.DocError: + return at + while n and n[0] == "call" and n[1] == "만약" and len(n[2]) == 3: + t = evaluate(n[2][0]) + if t is None: + return at + n = n[2][1 if t else 2] + if not n or n[0] != "var" or n[1] == at: + return at + at = n[1] + return at + + +def show_value(doc: dict, name: str, v, evaluate, get_table, unit: str | None = None) -> str: + """문서 기호 값 글 한 벌(짝 TS `showValue`) — 값이 온 기호의 갈래 · 표 원문 글자 자리 · 단위.""" + import master_doc as md + + src = source(doc, name, evaluate) + var = next((x for x in doc.get("변수") or [] if md.var_id(x) == src), None) + kind = kind_of(doc, src, var) + places = None + if kind == "표" and var is not None: + places = table_value_places(var.get("연결") or {}, v, evaluate, get_table) + return show(v, kind, src, str((var or {}).get("단위") or "") if unit is None else unit, places) diff --git a/resources/master_data/scripts/master_doc_record.py b/resources/master_data/scripts/master_doc_record.py index ee7b647b3..6ad4247ca 100644 --- a/resources/master_data/scripts/master_doc_record.py +++ b/resources/master_data/scripts/master_doc_record.py @@ -5,15 +5,17 @@ 브라우저가 같은 계산기(`common_util_formula_doc_calc.ts`)로 네트워크 없이 다시 셈. 화면 짝 = `common_util/common_util_formula_doc_cache.ts`(기록 → `DocLinks`). - 요소 = 부른 꼴(payload) 그대로 + {값 | 빈 | 끊김} -- 표 = 표 통째(조건 · 값칸 · 줄) — 옵션 · 입력이 바뀌어도 화면이 줄을 찾음 · 표 아님 = {끊김} +- 표 = 표 통째(조건 · 값칸 · 줄) — 옵션 · 입력이 바뀌어도 화면이 줄을 찾음 · 표 아님 = {끊김} · + 줄마다 원문 글자 자리 `자리`(859-3) - 단가산출 = 문서 통째(없으면 null) `prefetch` = 식 · 옵션과 무관하게 글로 적힌 표 · 단가산출 키를 미리 담음(구멍 `{…}` 든 키는 셈 때만). """ from __future__ import annotations -import master_doc_calc as mc import master_base as mf # 바탕 기반(색인 · 오류) +import master_doc_calc as mc +import master_doc_digits as mdd class Rec: @@ -52,6 +54,10 @@ class Rec: return keep = ("키", "원문번호", "이름", "조건", "범위규칙", "값칸", "줄") self.표[ref] = {k: table[k] for k in keep if k in table} + if places := mdd.table_places( + table + ): # 859-3 줄마다 원문 글자 자리(끝 0 · 화면이 수로 받으면 잃음) + self.표[ref]["자리"] = places def table(self, p: dict): self.see_table(str(p.get("표"))) diff --git a/resources/master_data/scripts/master_doc_text.py b/resources/master_data/scripts/master_doc_text.py index 9e1696287..26be79eb5 100644 --- a/resources/master_data/scripts/master_doc_text.py +++ b/resources/master_data/scripts/master_doc_text.py @@ -9,7 +9,8 @@ `common_util/common_util_formula_doc_view.ts`(`offLine` — 선택으로 꺼진 줄). 금액 줄 = 「이름 : 단가 원/단위 × 수량 단위 = 금액 원」 · 묶음 줄 = 비목마다 「노무비 : …」 · 계 = 「노무비 : 줄 + 줄 = 금액 원」 · 「합계 : 금액 원」. -수 꼴 = 화면과 같음 — 단가 · 수량 = `eqText`(소수 여섯 자리까지 · 셈 값 그대로) · +수 꼴 = 화면과 같음 — 단가 · 수량 = 보이는 자리 규칙(859-3 · `master_doc_digits` · + 짝 `common_util_show_digits.ts`) · 줄 금액 = 소수 한 자리 · 비목 · 합계 = 원(셈 답의 끝수 그대로 · 여기서 자르지 않음). 옮기지 않은 것(화면만) — 식 조판(KaTeX · 수량 식은 값 하나로) · 공식 줄 · 펼침 · 작업량 줄(846-2) · 굳은 기계 이름(847-1) · 비목곱 인수 글(848-7 · 금액은 답 그대로) · @@ -23,6 +24,7 @@ from decimal import ROUND_FLOOR, ROUND_HALF_UP, Decimal, InvalidOperation import master_doc as md import master_doc_calc as mc +import master_doc_digits as mdd COSTS = md.COSTS # 노무비 · 재료비 · 경비 COST_SHOW = {"노무비": "노무비", "재료비": "재료비", "경비": "경 비"} @@ -211,6 +213,24 @@ def _num(v) -> Decimal | None: return _dec(v) +def _table_of(links): + """연결의 마스터 표 읽기(`Links.master` · 기록 `Rec.links.master`) — 없으면 None.""" + master = getattr(links, "master", None) or getattr( + getattr(links, "links", None), "master", None + ) + return master.get if master is not None else (lambda ref: None) + + +def shown(doc: dict, node, v, look: "_Look", links, money: bool = False) -> str: + """금액 줄 단가 · 수량 값 글(859-3) — 기호 하나 = 그 변수 갈래 규칙(표 = 원문 글자 자리) · + 상수 = 자료 그대로 · 식 = 식 규칙(`money` = 단가 = 원 단위).""" + if node and node[0] == "var": + return mdd.show_value(doc, node[1], v, look.value, _table_of(links)) + if node and node[0] == "num": + return mdd.show(v) + return mdd.show(v, "식", "", "원" if money else "") + + def _u(text: str, unit: str) -> str: return f"{text} {unit}" if unit else text @@ -236,6 +256,7 @@ def money_lines(doc: dict, answer: dict, links) -> list[dict]: sub = None mu = money_units(line, node_of(line.get("단가")), node_of(line.get("수량")), pv, sub) qty = got.get("수량") + qty_text = shown(doc, node_of(line.get("수량")), qty, look, links) base = { "i": i, "이름": name, @@ -244,8 +265,9 @@ def money_lines(doc: dict, answer: dict, links) -> list[dict]: "꺼짐": look.off_line(line), "합밖": bool(got.get("합밖")), "묶음": line.get("묶음") or "", + "수량글": qty_text, } - tail = "" if qty is None else " × " + _u(eq_text(qty), mu["qty"]) + tail = "" if qty is None else " × " + _u(qty_text, mu["qty"]) if got.get("까닭") and got.get("금액") is None: why = got["까닭"] out.append({**base, "비목": line.get("비목"), "단가": None, "금액": None, "까닭": why, @@ -260,12 +282,14 @@ def money_lines(doc: dict, answer: dict, links) -> list[dict]: price = _u(eq_text(bundle.get(c)), mu["price"]) text = f"{COST_SHOW[c]} : {price}{tail} = {one(part)} {AMOUNT_UNIT}" out.append({**base, "비목": c, "묶음줄": True, "단가": _num(bundle.get(c)), + "단가글": eq_text(bundle.get(c)), "금액": _num(part), "글": text}) # fmt: skip continue amt, price = got.get("금액"), got.get("단가") - text = f"{name} : {_u(eq_text(price), mu['price'])}{tail} = {one(amt or 0)} {AMOUNT_UNIT}" - out.append({**base, "비목": line.get("비목"), "단가": _num(price), "금액": _num(amt), - "글": text}) # fmt: skip + price_text = shown(doc, node_of(line.get("단가")), price, look, links, money=True) + text = f"{name} : {_u(price_text, mu['price'])}{tail} = {one(amt or 0)} {AMOUNT_UNIT}" + out.append({**base, "비목": line.get("비목"), "단가": _num(price), "단가글": price_text, + "금액": _num(amt), "글": text}) # fmt: skip return out @@ -307,8 +331,8 @@ def sheet_groups(doc: dict, answer: dict, links) -> list[dict]: if x.get("까닭"): text = f"— {x['까닭']}" else: - price = "—" if x["단가"] is None else _u(eq_text(x["단가"]), mu["price"]) - qty = "" if x["수량"] is None else " * " + _u(eq_text(x["수량"]), mu["qty"]) + price = "—" if x["단가"] is None else _u(x["단가글"], mu["price"]) + qty = "" if x["수량"] is None else " * " + _u(x["수량글"], mu["qty"]) text = f"{price}{qty} = {one(x['금액'] or 0)}" groups[c].append( { diff --git a/resources/master_template/구조물정의.json b/resources/master_data/구조물정의/구조물정의.json similarity index 100% rename from resources/master_template/구조물정의.json rename to resources/master_data/구조물정의/구조물정의.json diff --git a/resources/master_template/구조물정의_이력/판_1.json b/resources/master_data/구조물정의/이력/판_1.json similarity index 100% rename from resources/master_template/구조물정의_이력/판_1.json rename to resources/master_data/구조물정의/이력/판_1.json diff --git a/resources/master_template/구조물정의_이력/판_10.json b/resources/master_data/구조물정의/이력/판_10.json similarity index 100% rename from resources/master_template/구조물정의_이력/판_10.json rename to resources/master_data/구조물정의/이력/판_10.json diff --git a/resources/master_template/구조물정의_이력/판_11.json b/resources/master_data/구조물정의/이력/판_11.json similarity index 100% rename from resources/master_template/구조물정의_이력/판_11.json rename to resources/master_data/구조물정의/이력/판_11.json diff --git a/resources/master_template/구조물정의_이력/판_12.json b/resources/master_data/구조물정의/이력/판_12.json similarity index 100% rename from resources/master_template/구조물정의_이력/판_12.json rename to resources/master_data/구조물정의/이력/판_12.json diff --git a/resources/master_template/구조물정의_이력/판_13.json b/resources/master_data/구조물정의/이력/판_13.json similarity index 100% rename from resources/master_template/구조물정의_이력/판_13.json rename to resources/master_data/구조물정의/이력/판_13.json diff --git a/resources/master_template/구조물정의_이력/판_14.json b/resources/master_data/구조물정의/이력/판_14.json similarity index 100% rename from resources/master_template/구조물정의_이력/판_14.json rename to resources/master_data/구조물정의/이력/판_14.json diff --git a/resources/master_template/구조물정의_이력/판_15.json b/resources/master_data/구조물정의/이력/판_15.json similarity index 100% rename from resources/master_template/구조물정의_이력/판_15.json rename to resources/master_data/구조물정의/이력/판_15.json diff --git a/resources/master_template/구조물정의_이력/판_16.json b/resources/master_data/구조물정의/이력/판_16.json similarity index 100% rename from resources/master_template/구조물정의_이력/판_16.json rename to resources/master_data/구조물정의/이력/판_16.json diff --git a/resources/master_template/구조물정의_이력/판_17.json b/resources/master_data/구조물정의/이력/판_17.json similarity index 100% rename from resources/master_template/구조물정의_이력/판_17.json rename to resources/master_data/구조물정의/이력/판_17.json diff --git a/resources/master_template/구조물정의_이력/판_18.json b/resources/master_data/구조물정의/이력/판_18.json similarity index 100% rename from resources/master_template/구조물정의_이력/판_18.json rename to resources/master_data/구조물정의/이력/판_18.json diff --git a/resources/master_template/구조물정의_이력/판_19.json b/resources/master_data/구조물정의/이력/판_19.json similarity index 100% rename from resources/master_template/구조물정의_이력/판_19.json rename to resources/master_data/구조물정의/이력/판_19.json diff --git a/resources/master_template/구조물정의_이력/판_2.json b/resources/master_data/구조물정의/이력/판_2.json similarity index 100% rename from resources/master_template/구조물정의_이력/판_2.json rename to resources/master_data/구조물정의/이력/판_2.json diff --git a/resources/master_template/구조물정의_이력/판_20.json b/resources/master_data/구조물정의/이력/판_20.json similarity index 100% rename from resources/master_template/구조물정의_이력/판_20.json rename to resources/master_data/구조물정의/이력/판_20.json diff --git a/resources/master_template/구조물정의_이력/판_21.json b/resources/master_data/구조물정의/이력/판_21.json similarity index 100% rename from resources/master_template/구조물정의_이력/판_21.json rename to resources/master_data/구조물정의/이력/판_21.json diff --git a/resources/master_template/구조물정의_이력/판_22.json b/resources/master_data/구조물정의/이력/판_22.json similarity index 100% rename from resources/master_template/구조물정의_이력/판_22.json rename to resources/master_data/구조물정의/이력/판_22.json diff --git a/resources/master_template/구조물정의_이력/판_3.json b/resources/master_data/구조물정의/이력/판_3.json similarity index 100% rename from resources/master_template/구조물정의_이력/판_3.json rename to resources/master_data/구조물정의/이력/판_3.json diff --git a/resources/master_template/구조물정의_이력/판_4.json b/resources/master_data/구조물정의/이력/판_4.json similarity index 100% rename from resources/master_template/구조물정의_이력/판_4.json rename to resources/master_data/구조물정의/이력/판_4.json diff --git a/resources/master_template/구조물정의_이력/판_5.json b/resources/master_data/구조물정의/이력/판_5.json similarity index 100% rename from resources/master_template/구조물정의_이력/판_5.json rename to resources/master_data/구조물정의/이력/판_5.json diff --git a/resources/master_template/구조물정의_이력/판_6.json b/resources/master_data/구조물정의/이력/판_6.json similarity index 100% rename from resources/master_template/구조물정의_이력/판_6.json rename to resources/master_data/구조물정의/이력/판_6.json diff --git a/resources/master_template/구조물정의_이력/판_7.json b/resources/master_data/구조물정의/이력/판_7.json similarity index 100% rename from resources/master_template/구조물정의_이력/판_7.json rename to resources/master_data/구조물정의/이력/판_7.json diff --git a/resources/master_template/구조물정의_이력/판_8.json b/resources/master_data/구조물정의/이력/판_8.json similarity index 100% rename from resources/master_template/구조물정의_이력/판_8.json rename to resources/master_data/구조물정의/이력/판_8.json diff --git a/resources/master_template/구조물정의_이력/판_9.json b/resources/master_data/구조물정의/이력/판_9.json similarity index 100% rename from resources/master_template/구조물정의_이력/판_9.json rename to resources/master_data/구조물정의/이력/판_9.json diff --git a/resources/tester/golden_855_b09.json b/resources/tester/golden_855_b09.json index 9ba1b5615..632ceb262 100644 --- a/resources/tester/golden_855_b09.json +++ b/resources/tester/golden_855_b09.json @@ -6,13 +6,13 @@ "daega_inputs": "8b605fa95c5b9db4", "수요": "23b0132a8a7f46f7", "산근 값": "6072e1180a1b81e7", - "산근 글": "f5b884a2c49c91c6", + "산근 글": "82f35a5c891bab99", "산근 관급 값": "6568e5cf9322b81c", - "산근 관급 글": "9397c1d1a5fe0dcd", + "산근 관급 글": "534a307c49079bfd", "미리보기 hand:rate 값": "091690571b7dc54b", "미리보기 hand:rate 글": "d17615784f25e4f5", "미리보기 hand:pick 값": "6c7f426d37e31998", - "미리보기 hand:pick 글": "7836022de46b3072", + "미리보기 hand:pick 글": "ab9a393d7a550b0a", "미리보기 hand:net 값": "e2809bd3259438b0", "미리보기 hand:net 글": "0254ea22d7a23e43", "B08 단위수량": "896710398b04b4fd" diff --git a/resources/tester/golden_857_import.json b/resources/tester/golden_857_import.json index c44d89ffa..f2d237932 100644 --- a/resources/tester/golden_857_import.json +++ b/resources/tester/golden_857_import.json @@ -1608,13 +1608,13 @@ "블록 EST:거창#42": "1df3859c838fe918", "블록 EST:거창#43": "0251a0d82053e891", "블록 EST:거창#44": "b5566779bbdb30d5", - "블록 EST:거창#45": "1fb207dbabcf87db", + "블록 EST:거창#45": "812f6da4b5f62fa5", "블록 EST:거창#46": "c081e49789bc0bf6", "블록 EST:거창#47": "27cd823262a59f6f", "블록 EST:거창#48": "a4e4087d6a9ca6ea", - "블록 EST:거창#49": "2c5bd574a86dac6f", + "블록 EST:거창#49": "d6a8afa08546639e", "블록 EST:거창#5": "5dc364979971e626", - "블록 EST:거창#50": "eee05c86a1b6ea6d", + "블록 EST:거창#50": "a64409a8bc71c630", "블록 EST:거창#51": "d6cad1535c252581", "블록 EST:거창#52": "a1254670b687d777", "블록 EST:거창#53": "a1f3a200c0d7c9e8", @@ -1668,7 +1668,7 @@ "블록 EST:임도용역#41": "1b399aac74974e03", "블록 EST:임도용역#42": "b2051f7b3f58e87d", "블록 EST:임도용역#43": "e3bec2cc394e22f0", - "블록 EST:임도용역#44": "7727a8fd0b58eda2", + "블록 EST:임도용역#44": "f4213fbca7b5bc44", "블록 EST:임도용역#45": "34da28a05b731ca9", "블록 EST:임도용역#46": "53f9294d961d54c0", "블록 EST:임도용역#47": "ee1b60dab59400ce", @@ -1682,13 +1682,13 @@ "블록 EST:임도용역#54": "e9cfce9652109001", "블록 EST:임도용역#55": "abec5ea374f2988d", "블록 EST:임도용역#56": "611c6127f4ea8503", - "블록 EST:임도용역#57": "ef80fa7e454aced6", + "블록 EST:임도용역#57": "173ded3760ce79ae", "블록 EST:임도용역#58": "e5f4bc721adede56", "블록 EST:임도용역#59": "d2f9a06ed9d7a22b", "블록 EST:임도용역#6": "e6130b923e2f115e", "블록 EST:임도용역#60": "7f93bef5e454f8b8", "블록 EST:임도용역#61": "8293f5dbbac85f71", - "블록 EST:임도용역#62": "00218c916e1c3ee1", + "블록 EST:임도용역#62": "1e76564b0c479562", "블록 EST:임도용역#63": "959f97391294f17c", "블록 EST:임도용역#64": "1588639889dfa176", "블록 EST:임도용역#65": "dad908643744087b", @@ -1697,7 +1697,7 @@ "블록 EST:임도용역#68": "d161561c807c88e1", "블록 EST:임도용역#69": "ff87f499c5daa920", "블록 EST:임도용역#7": "b7f71f2e8bd6e288", - "블록 EST:임도용역#70": "84ebec6ffa09df04", + "블록 EST:임도용역#70": "8e5140e8de6e0fa7", "블록 EST:임도용역#71": "3e08e97322e8754b", "블록 EST:임도용역#72": "13bfb403bb9bbd1d", "블록 EST:임도용역#73": "6b7e1d368a2dec0a", @@ -1739,12 +1739,12 @@ "블록 EST:장수#4": "1ae235f39ab69c95", "블록 EST:장수#40": "0251a0d82053e891", "블록 EST:장수#41": "411250f918c5e08b", - "블록 EST:장수#42": "1fb207dbabcf87db", + "블록 EST:장수#42": "812f6da4b5f62fa5", "블록 EST:장수#43": "a002604d0ffb3097", "블록 EST:장수#44": "bf17812c20f15b6a", "블록 EST:장수#45": "4e94fb0d00a77579", - "블록 EST:장수#46": "2c5bd574a86dac6f", - "블록 EST:장수#47": "eee05c86a1b6ea6d", + "블록 EST:장수#46": "d6a8afa08546639e", + "블록 EST:장수#47": "a64409a8bc71c630", "블록 EST:장수#48": "257c217657545a0b", "블록 EST:장수#49": "e36dbac796755b9f", "블록 EST:장수#5": "daab296de62f788c", @@ -1806,12 +1806,12 @@ "블록 EST:진안#41": "1df3859c838fe918", "블록 EST:진안#42": "0251a0d82053e891", "블록 EST:진안#43": "411250f918c5e08b", - "블록 EST:진안#44": "1fb207dbabcf87db", + "블록 EST:진안#44": "812f6da4b5f62fa5", "블록 EST:진안#45": "a002604d0ffb3097", "블록 EST:진안#46": "bf17812c20f15b6a", "블록 EST:진안#47": "4e94fb0d00a77579", - "블록 EST:진안#48": "2c5bd574a86dac6f", - "블록 EST:진안#49": "eee05c86a1b6ea6d", + "블록 EST:진안#48": "d6a8afa08546639e", + "블록 EST:진안#49": "a64409a8bc71c630", "블록 EST:진안#5": "daab296de62f788c", "블록 EST:진안#50": "257c217657545a0b", "블록 EST:진안#51": "e36dbac796755b9f", @@ -1837,7 +1837,7 @@ "블록 EST:진안#7": "057fa9c2cc493dba", "블록 EST:진안#70": "379ec90fcbb47539", "블록 EST:진안#71": "b88d8600a71258fb", - "블록 EST:진안#72": "b0ffc1fb975497c0", + "블록 EST:진안#72": "504cdb1bd263fd9b", "블록 EST:진안#73": "e040b41a4ead78b2", "블록 EST:진안#74": "6945878da91d7673", "블록 EST:진안#8": "aa7cdfee16511204", @@ -1863,11 +1863,11 @@ "블록 STC:동부청영월#1759": "dfea518273d83501", "블록 STC:동부청영월#18": "47d41404d502ce31", "블록 STC:동부청영월#1810": "85d228f81fc53317", - "블록 STC:동부청영월#1841": "c9c769c01059a110", + "블록 STC:동부청영월#1841": "dc10216b32ee01eb", "블록 STC:동부청영월#1843": "51f8103b40a9d641", "블록 STC:동부청영월#1844": "5b9418cc612f3e6b", "블록 STC:동부청영월#1854": "fe3853a30c20aa5c", - "블록 STC:동부청영월#1855": "21c69a1cee1c0366", + "블록 STC:동부청영월#1855": "a456d5c84cc4ee49", "블록 STC:동부청영월#19": "252763cd7fc1c3f2", "블록 STC:동부청영월#1926": "cc2caf8e4da67129", "블록 STC:동부청영월#1927": "9809f9615114ddb5", @@ -1902,11 +1902,11 @@ "블록 STC:동부청영월#3": "efc1d0fbd05f2768", "블록 STC:동부청영월#31": "bc2d4cd4e21c6746", "블록 STC:동부청영월#33": "420541de4786bfc8", - "블록 STC:동부청영월#35": "029aaf5712b7d60b", + "블록 STC:동부청영월#35": "3783bcdded75cf53", "블록 STC:동부청영월#37": "5daa516be0b12898", "블록 STC:동부청영월#411": "184dc4f049dc8021", "블록 STC:동부청영월#450": "4224cbb622cbca03", - "블록 STC:동부청영월#56": "5f87543039b29913", + "블록 STC:동부청영월#56": "2b5b3f478ebf46a5", "블록 STC:동부청영월#58": "81257f1cf5cc1921", "블록 STC:동부청영월#59": "67350559b5a39f17", "블록 STC:동부청영월#60": "1cb27cd193a25c4f", @@ -1920,7 +1920,7 @@ "블록 STC:동부청영월#9": "d563f42c15d0ab74", "블록 STC:봉화#1": "6a3a4cf5413ad60c", "블록 STC:봉화#10": "6a3e504d29821efe", - "블록 STC:봉화#102": "ed5ad3d31bd356b9", + "블록 STC:봉화#102": "62f1e2b86364c355", "블록 STC:봉화#103": "8d0b37a9ffa59bd7", "블록 STC:봉화#105": "5d75fc8605e75fb2", "블록 STC:봉화#107": "2db0d8f63cbcf24a", @@ -1928,8 +1928,8 @@ "블록 STC:봉화#109": "79c23cc9464fff35", "블록 STC:봉화#110": "d4f03dae61a05eac", "블록 STC:봉화#111": "6a3a4cf5413ad60c", - "블록 STC:봉화#112": "1a0adb0616c89a1b", - "블록 STC:봉화#113": "b26a17356b1b7e01", + "블록 STC:봉화#112": "7d6212a390f65f7f", + "블록 STC:봉화#113": "c1f55ddd4002e6d8", "블록 STC:봉화#115": "b7a0079a51e026bb", "블록 STC:봉화#116": "7c65d8e81f16000d", "블록 STC:봉화#117": "31dad24a201b9dfa", @@ -1939,8 +1939,8 @@ "블록 STC:봉화#120": "53adcb53f0fd79d6", "블록 STC:봉화#121": "d336b5e37f240dbe", "블록 STC:봉화#13": "448eabd64c7b30d5", - "블록 STC:봉화#14": "93ec5c0aa7430448", - "블록 STC:봉화#15": "a5f85991dac23ab9", + "블록 STC:봉화#14": "ed960e44bd39c766", + "블록 STC:봉화#15": "d681b37f91e3de94", "블록 STC:봉화#16": "90fd01b26e06ceb6", "블록 STC:봉화#17": "7e6046aa55598d9f", "블록 STC:봉화#18": "ba28bc24ba3cb5e0", @@ -1970,7 +1970,7 @@ "블록 STC:봉화#55": "20b39443409ca8ce", "블록 STC:봉화#6": "de043379f21970d2", "블록 STC:봉화#7": "725c92ac485242ac", - "블록 STC:봉화#77": "9c6aae9a8f1d4608", + "블록 STC:봉화#77": "99ca596478f5bd2b", "블록 STC:봉화#8": "6b8d5d0a0efcd64d", "블록 STC:봉화#81": "73cd52ec88407cfd", "블록 STC:봉화#89": "7848bdf06714786e", @@ -2775,13 +2775,13 @@ "블록 엑셀:거창#42": "1df3859c838fe918", "블록 엑셀:거창#43": "0251a0d82053e891", "블록 엑셀:거창#44": "b5566779bbdb30d5", - "블록 엑셀:거창#45": "1fb207dbabcf87db", + "블록 엑셀:거창#45": "812f6da4b5f62fa5", "블록 엑셀:거창#46": "c081e49789bc0bf6", "블록 엑셀:거창#47": "27cd823262a59f6f", "블록 엑셀:거창#48": "a4e4087d6a9ca6ea", - "블록 엑셀:거창#49": "2c5bd574a86dac6f", + "블록 엑셀:거창#49": "d6a8afa08546639e", "블록 엑셀:거창#5": "5dc364979971e626", - "블록 엑셀:거창#50": "eee05c86a1b6ea6d", + "블록 엑셀:거창#50": "a64409a8bc71c630", "블록 엑셀:거창#51": "d6cad1535c252581", "블록 엑셀:거창#52": "a1254670b687d777", "블록 엑셀:거창#53": "a1f3a200c0d7c9e8", @@ -2857,11 +2857,11 @@ "블록 엑셀:동부청영월#1759": "08280fc9ee8870a2", "블록 엑셀:동부청영월#18": "00763aba4098e4f9", "블록 엑셀:동부청영월#1810": "a6443d53770819f0", - "블록 엑셀:동부청영월#1841": "d1c80b980ec262cc", + "블록 엑셀:동부청영월#1841": "c16c63d2673c3119", "블록 엑셀:동부청영월#1843": "ac5c680ea44671d8", "블록 엑셀:동부청영월#1844": "66f677e7ddb7f26b", "블록 엑셀:동부청영월#1854": "e160fe67ef436b05", - "블록 엑셀:동부청영월#1855": "4f0d38a372236d8f", + "블록 엑셀:동부청영월#1855": "cbbc91a91bfb4a85", "블록 엑셀:동부청영월#19": "9071d25df0239e18", "블록 엑셀:동부청영월#1926": "73615595d7bab033", "블록 엑셀:동부청영월#1927": "ff5058b6a8f188c1", @@ -2896,11 +2896,11 @@ "블록 엑셀:동부청영월#3": "2147055f076d3746", "블록 엑셀:동부청영월#31": "191b276d2d530ca5", "블록 엑셀:동부청영월#33": "e1a958b1eb80798d", - "블록 엑셀:동부청영월#35": "a7083ecd67527feb", + "블록 엑셀:동부청영월#35": "ebbf0bf285f856f7", "블록 엑셀:동부청영월#37": "6a5e34c59deb5c52", "블록 엑셀:동부청영월#411": "052b53397b4455db", "블록 엑셀:동부청영월#450": "82142689c2152de2", - "블록 엑셀:동부청영월#56": "cd5316ad576da0f5", + "블록 엑셀:동부청영월#56": "c01c101d39c10057", "블록 엑셀:동부청영월#58": "b5f864001925b735", "블록 엑셀:동부청영월#59": "bbb270854bd6e81a", "블록 엑셀:동부청영월#60": "83a27bbf02995081", @@ -2914,7 +2914,7 @@ "블록 엑셀:동부청영월#9": "e45f6af198d024cf", "블록 엑셀:봉화#1": "6a3a4cf5413ad60c", "블록 엑셀:봉화#10": "31461fe8eea3d3e7", - "블록 엑셀:봉화#102": "799b403942729c33", + "블록 엑셀:봉화#102": "03b932d2e8d52edc", "블록 엑셀:봉화#103": "b70acf460861a632", "블록 엑셀:봉화#105": "365719504a1cfddb", "블록 엑셀:봉화#107": "4ab5752b11af883d", @@ -2922,8 +2922,8 @@ "블록 엑셀:봉화#109": "83fe1b0159e23015", "블록 엑셀:봉화#110": "ab44f6828485b12d", "블록 엑셀:봉화#111": "6a3a4cf5413ad60c", - "블록 엑셀:봉화#112": "5a4d59a133604dde", - "블록 엑셀:봉화#113": "9a04866923bc5941", + "블록 엑셀:봉화#112": "eb2a91cb7bfc2b96", + "블록 엑셀:봉화#113": "c8fdfc61e74f9ef8", "블록 엑셀:봉화#115": "3241be344f6632a0", "블록 엑셀:봉화#116": "aad7cd487d567533", "블록 엑셀:봉화#117": "89972db7576cdf60", @@ -2933,8 +2933,8 @@ "블록 엑셀:봉화#120": "0948dd4ea7f649cb", "블록 엑셀:봉화#121": "9da269061aa09e18", "블록 엑셀:봉화#13": "669e64dd5dd4af2c", - "블록 엑셀:봉화#14": "5ad7aeb6ce2ddc5b", - "블록 엑셀:봉화#15": "3438713632c502be", + "블록 엑셀:봉화#14": "5ab6ed423a21edfa", + "블록 엑셀:봉화#15": "9084ae199e00f6ca", "블록 엑셀:봉화#16": "ac92e14e8c8d6b7d", "블록 엑셀:봉화#17": "ec823fb4ee8c5cde", "블록 엑셀:봉화#18": "da0592e571c63504", @@ -2964,7 +2964,7 @@ "블록 엑셀:봉화#55": "b378bc17ebbec746", "블록 엑셀:봉화#6": "4cf6b06f20a0a53e", "블록 엑셀:봉화#7": "287acee995642061", - "블록 엑셀:봉화#77": "89c39b8b2ec67595", + "블록 엑셀:봉화#77": "0eb9419aad11739d", "블록 엑셀:봉화#8": "9a79e8e260d43c8d", "블록 엑셀:봉화#81": "b6b3daa9e0b54987", "블록 엑셀:봉화#89": "d9cc4ba3d00949b4", @@ -3010,7 +3010,7 @@ "블록 엑셀:북부청사방#37": "78d31ff8a3850b8e", "블록 엑셀:북부청사방#38": "8d5a8aa166c8b132", "블록 엑셀:북부청사방#39": "4d858e60b965ba62", - "블록 엑셀:북부청사방#4": "d9828e3034cbad23", + "블록 엑셀:북부청사방#4": "5ce0770f1fe26c83", "블록 엑셀:북부청사방#40": "2da49ca9233aae66", "블록 엑셀:북부청사방#41": "ed376b4c04318149", "블록 엑셀:북부청사방#42": "5a7494c46d88dcff", @@ -3100,7 +3100,7 @@ "블록 엑셀:북부청임도#58": "752c206f261d841b", "블록 엑셀:북부청임도#59": "f64f8b599ac68be4", "블록 엑셀:북부청임도#6": "a367aeb31cdc0f84", - "블록 엑셀:북부청임도#60": "371b83aa4706026c", + "블록 엑셀:북부청임도#60": "f4f249ef678122b8", "블록 엑셀:북부청임도#61": "9d4326ad5c4ab79a", "블록 엑셀:북부청임도#62": "ddd94e5a7871263e", "블록 엑셀:북부청임도#63": "cd57f71497ed6490", @@ -3115,7 +3115,7 @@ "블록 엑셀:북부청임도#71": "546e537032d1fa62", "블록 엑셀:북부청임도#72": "d2ff6e023d7d1e5e", "블록 엑셀:북부청임도#73": "12d4f9f8b69bf5fb", - "블록 엑셀:북부청임도#74": "60ef7852d88c3adc", + "블록 엑셀:북부청임도#74": "9ed4ca32e05db610", "블록 엑셀:북부청임도#75": "840dcbb052f27109", "블록 엑셀:북부청임도#76": "73be84d374c28630", "블록 엑셀:북부청임도#77": "4800c2d5d6aa0b53", @@ -3253,50 +3253,50 @@ "올림 2026수목 올림": "bd033d8606e78695", "올림 2026수목 재료": "4f53cda18c2baa0c", "올림 2026수목 칠": "c9e90bcbd1a88642", - "올림 거창 고정": "301f9d50d2aa6e01", - "올림 거창 목록": "1b2914680b1c29fc", + "올림 거창 고정": "efa92bb020ff7da1", + "올림 거창 목록": "84571e21a6595a9c", "올림 거창 올림": "5f32212ea5f045b1", - "올림 거창 재료": "1ec877cf7e9e02ad", + "올림 거창 재료": "54fecdad9e8a24a9", "올림 거창 칠": "bc0678f986a965b4", - "올림 대흥공통 고정": "b46a695b4c7ad3b0", - "올림 대흥공통 목록": "c09a7c665eefc36b", + "올림 대흥공통 고정": "b54d5fb931ae0486", + "올림 대흥공통 목록": "70aad075bc9c8a80", "올림 대흥공통 올림": "157bff3f6900ea13", - "올림 대흥공통 재료": "3f3d3149d18e1c2a", + "올림 대흥공통 재료": "023b3800422e216e", "올림 대흥공통 칠": "bf96a80f4e8a7732", - "올림 동부청영월 고정": "1792d43222245005", - "올림 동부청영월 목록": "fa74122eab6b6e33", + "올림 동부청영월 고정": "f760efcdfdf269d3", + "올림 동부청영월 목록": "63a22c0a6d166b1d", "올림 동부청영월 올림": "be95d8872c70e009", - "올림 동부청영월 재료": "7a4b8bfc9d058a79", + "올림 동부청영월 재료": "d5865c68d3b24bfe", "올림 동부청영월 칠": "94961d7090fe0f0f", - "올림 봉화 고정": "fe99665cfa67664e", - "올림 봉화 목록": "ff7a9a7a8f7fb0d3", + "올림 봉화 고정": "b655e9e6461d72a4", + "올림 봉화 목록": "41ad630ccb7fcdba", "올림 봉화 올림": "9b6994bd6b730cb9", - "올림 봉화 재료": "deb7009db2a1545e", + "올림 봉화 재료": "ecb94d583addb5a1", "올림 봉화 칠": "6e1bdc18a313f431", - "올림 북부청사방 고정": "3681cbce171e2eb9", - "올림 북부청사방 목록": "1ba106b360303538", + "올림 북부청사방 고정": "338c6a0c033e5e6d", + "올림 북부청사방 목록": "3524b1fbc45757c7", "올림 북부청사방 올림": "24295521752b8045", - "올림 북부청사방 재료": "924f4798b4c177a0", + "올림 북부청사방 재료": "ea25782ccc2ec869", "올림 북부청사방 칠": "8edfe7ec0fc65fbb", - "올림 북부청임도 고정": "200093e072f526af", - "올림 북부청임도 목록": "3a170d96d3912635", + "올림 북부청임도 고정": "027186b1881b1851", + "올림 북부청임도 목록": "e9b001e80c8a6dcd", "올림 북부청임도 올림": "d3f2435548533cde", - "올림 북부청임도 재료": "389bf49a4a1117d1", + "올림 북부청임도 재료": "20f45d6bed6f4404", "올림 북부청임도 칠": "e4d629901960f7d5", "올림 영덕계류 고정": "deb8b2df599c7397", "올림 영덕계류 목록": "76f84e208058206f", "올림 영덕계류 올림": "64bf734b8ba86121", "올림 영덕계류 재료": "3a5f797626302cb6", "올림 영덕계류 칠": "1a81d5151b25755c", - "올림 울진대흥 고정": "f79e991f8fce7dc7", - "올림 울진대흥 목록": "b6e84aa2aaa36ede", + "올림 울진대흥 고정": "653b397ec389b6d8", + "올림 울진대흥 목록": "f2e75b39a107772f", "올림 울진대흥 올림": "157bff3f6900ea13", - "올림 울진대흥 재료": "961279430c2bc784", + "올림 울진대흥 재료": "295d9dfe87299ed0", "올림 울진대흥 칠": "e062abee88d50692", - "올림 울진소광 고정": "1ea94553de8845f1", - "올림 울진소광 목록": "5a92223af94df28b", + "올림 울진소광 고정": "b8648facfe362675", + "올림 울진소광 목록": "b9250845123334a5", "올림 울진소광 올림": "71174eecbf7abe3b", - "올림 울진소광 재료": "c00afaaa8533fa04", + "올림 울진소광 재료": "b1d8c9e817841b38", "올림 울진소광 칠": "41241ae33b2b5174" }, "재료표": { @@ -3304,42 +3304,38 @@ "2026수목": {}, "거창": { "같음(못 이음)": 10, - "같음(이음)": 1, - "생김": 5 + "같음(이음)": 6 }, "대흥공통": { "같음(못 이음)": 18, - "생김": 13 + "같음(이음)": 13 }, "동부청영월": { "같음(못 이음)": 36, - "생김": 5 + "같음(이음)": 5 }, "봉화": { "같음(못 이음)": 13, - "같음(이음)": 8, - "생김": 19 + "같음(이음)": 27 }, "북부청사방": { "같음(못 이음)": 48, - "생김": 8 + "같음(이음)": 8 }, "북부청임도": { "같음(못 이음)": 97, - "같음(이음)": 1, - "다른 품목": 12, - "생김": 32 + "같음(이음)": 45 }, "영덕계류": { "같음(이음)": 4 }, "울진대흥": { "같음(못 이음)": 18, - "생김": 13 + "같음(이음)": 13 }, "울진소광": { "같음(못 이음)": 13, - "생김": 11 + "같음(이음)": 11 } }, "판": 1 diff --git a/resources/tester/helper_116_right_click_add.cjs b/resources/tester/helper_116_right_click_add.cjs index f757b5973..d59a9bae7 100644 --- a/resources/tester/helper_116_right_click_add.cjs +++ b/resources/tester/helper_116_right_click_add.cjs @@ -41,7 +41,10 @@ const { loadForm } = loadTs(path.join(B05, "B05_Profile_UI_Structures_Panel_Comm const entry = (required, value) => ({ required, isEmpty: () => value === "" }); // 동작 = 정의 종류 덧칸(앱의 `withDefinition` 과 같음 · 323-7 종류 키 대신 동작 이름) const DEFINED = JSON.parse( - fs.readFileSync(path.join(ROOT, "resources", "master_template", "구조물정의.json"), "utf8"), + fs.readFileSync( + path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"), + "utf8", + ), ); const behaviors = (typeId) => DEFINED.종류?.[typeId]?.동작 ?? []; const type = (type_id, managed_by = null) => ({ diff --git a/resources/tester/helper_126_ford_fill.cjs b/resources/tester/helper_126_ford_fill.cjs index f4e3f5d37..867968b0d 100644 --- a/resources/tester/helper_126_ford_fill.cjs +++ b/resources/tester/helper_126_ford_fill.cjs @@ -35,7 +35,10 @@ const { fordHeightM } = loadTs( // 동작 = 정의 종류 덧칸(앱의 `withDefinition` 과 같음 · 323-7 종류 키 대신 동작 이름) const DEFINED = JSON.parse( - fs.readFileSync(path.join(ROOT, "resources", "master_template", "구조물정의.json"), "utf8"), + fs.readFileSync( + path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"), + "utf8", + ), ); const type = (type_id) => ({ type_id, diff --git a/resources/tester/helper_271_facility_lane.cjs b/resources/tester/helper_271_facility_lane.cjs index cb78f3a2b..29d55a7e6 100644 --- a/resources/tester/helper_271_facility_lane.cjs +++ b/resources/tester/helper_271_facility_lane.cjs @@ -63,7 +63,10 @@ const ids = loadTs(path.join(design, "design_pipe_ids.ts")); const { useDesignStore } = loadTs(path.join(design, "design_store.ts")); const { readState } = loadTs(path.join(ROOT, "A00_Common", "b_page_state.ts")); const TYPES = JSON.parse( - fs.readFileSync(path.join(ROOT, "resources", "master_template", "구조물정의.json"), "utf8"), + fs.readFileSync( + path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"), + "utf8", + ), ).types; /** 가짜 종단도 — 받은 것 · 편집 옮김 기록. */ diff --git a/resources/tester/helper_280_3_draft_frame.cjs b/resources/tester/helper_280_3_draft_frame.cjs index b1e5fa8d3..3e53490a2 100644 --- a/resources/tester/helper_280_3_draft_frame.cjs +++ b/resources/tester/helper_280_3_draft_frame.cjs @@ -60,7 +60,7 @@ function load(full) { const P = (...a) => path.join(ROOT, ...a); const D = load(P("B06_Section", "B06_Section_Section_Drafts.ts")); const def = JSON.parse( - fs.readFileSync(P("resources", "master_template", "구조물정의.json"), "utf8"), + fs.readFileSync(P("resources", "master_data", "구조물정의", "구조물정의.json"), "utf8"), ); S.types = def.types.map((t) => ({ type_id: t.type_id, diff --git a/resources/tester/helper_319_kind_swap.cjs b/resources/tester/helper_319_kind_swap.cjs index cbe3683a4..9a416b1a9 100644 --- a/resources/tester/helper_319_kind_swap.cjs +++ b/resources/tester/helper_319_kind_swap.cjs @@ -12,7 +12,10 @@ const ROOT = path.join(__dirname, "..", ".."); const B05 = (name) => path.join(ROOT, "B05_Profile", `${name}.ts`); const B06 = (name) => path.join(ROOT, "B06_Section", `${name}.ts`); const TYPES = JSON.parse( - fs.readFileSync(path.join(ROOT, "resources", "master_template", "구조물정의.json"), "utf8"), + fs.readFileSync( + path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"), + "utf8", + ), ).types; class FakeStorage { diff --git a/resources/tester/helper_322_2_check.cjs b/resources/tester/helper_322_2_check.cjs index 5d2b7c70f..d353121c6 100644 --- a/resources/tester/helper_322_2_check.cjs +++ b/resources/tester/helper_322_2_check.cjs @@ -1,4 +1,4 @@ -/* PLAN 322-2 구조물 표 검사 · 편집 헬퍼 — 진짜 `M02_SO_Def_Check.ts` · `M02_SO_Def_Reflect.ts` · +/* PLAN 322-2 구조물 표 검사 · 편집 헬퍼 — 진짜 `M01_SO_Def_Check.ts` · `M01_SO_Def_Reflect.ts` · * `design_structure_spec.ts` 를 그 자리에서 트랜스파일해 Node 로 돌림 · 결과 = 표준출력 JSON 한 벌. * 입력 = argv[2] JSON `{cases: {이름: [정의, 앞 판|null]}, definition}`. 짝 = `test_322_2_check_mirror.py`. */ @@ -33,9 +33,9 @@ function load(file) { return box.exports; } -const SO = (name) => path.join(ROOT, "M02_MasterTemplete", "StructOptions", `${name}.ts`); -const check = load(SO("M02_SO_Def_Check")); -const reflect = load(SO("M02_SO_Def_Reflect")); +const SO = (name) => path.join(ROOT, "M01_MasterData", "StructOptions", `${name}.ts`); +const check = load(SO("M01_SO_Def_Check")); +const reflect = load(SO("M01_SO_Def_Reflect")); const spec = load(path.join(ROOT, "A00_Common", "design", "logic", "design_structure_spec.ts")); const { STRUCTURE_SPECS } = load( path.join(ROOT, "A00_Common", "design", "logic", "design_structure_pipe.ts"), diff --git a/resources/tester/helper_322_3_flow.cjs b/resources/tester/helper_322_3_flow.cjs index 6124da24d..ecd867afa 100644 --- a/resources/tester/helper_322_3_flow.cjs +++ b/resources/tester/helper_322_3_flow.cjs @@ -8,7 +8,10 @@ const path = require("path"); const ROOT = path.join(__dirname, "..", ".."); const ts = require(path.join(ROOT, "config", "node_modules", "typescript")); const DEF = JSON.parse( - fs.readFileSync(path.join(ROOT, "resources", "master_template", "구조물정의.json"), "utf8"), + fs.readFileSync( + path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"), + "utf8", + ), ); const TYPES = DEF.types.map((t) => ({ managed_by: null, enabled: true, ...t })); diff --git a/resources/tester/helper_322_catalog_module.cjs b/resources/tester/helper_322_catalog_module.cjs index f06833065..9c86a8662 100644 --- a/resources/tester/helper_322_catalog_module.cjs +++ b/resources/tester/helper_322_catalog_module.cjs @@ -16,7 +16,7 @@ const box = { exports: {} }; new Function("exports", "module", "require", js)(box.exports, box, () => read("common_util", "common_util_structure_parts.json"), ); -box.exports.useCatalogDefinition(read("resources", "master_template", "구조물정의.json")); +box.exports.useCatalogDefinition(read("resources", "master_data", "구조물정의", "구조물정의.json")); /** 로더 요청이 구조물 표 모듈인가. */ box.exports.isCatalogRequest = (request) => /common_util_structure_catalog(\.js)?$/.test(request); diff --git a/resources/tester/helper_323_7_new_type.cjs b/resources/tester/helper_323_7_new_type.cjs index 9395dceff..d857d8940 100644 --- a/resources/tester/helper_323_7_new_type.cjs +++ b/resources/tester/helper_323_7_new_type.cjs @@ -1,4 +1,4 @@ -/* PLAN 323-7 종류 더하기 헬퍼 — 진짜 `M02_SO_Def_Add.ts`(본보기 복사) · 구조물 표 · 측점 계획 · 형상 얹기 · 벽 단 · +/* PLAN 323-7 종류 더하기 헬퍼 — 진짜 `M01_SO_Def_Add.ts`(본보기 복사) · 구조물 표 · 측점 계획 · 형상 얹기 · 벽 단 · * 명세 고르기 · M02 검사를 그 자리에서 트랜스파일해 Node 로 돌림(마스터는 읽기만 · 사본에서 더함) · 결과 = JSON. * 짝 = `test_323_7_new_type.py`(파이썬 검사 · 표 · 벽 제원이 같은 사본을 읽음). */ @@ -35,12 +35,15 @@ function load(file) { } const C = (name) => path.join(ROOT, "common_util", `${name}.ts`); -const M = (name) => path.join(ROOT, "M02_MasterTemplete", "StructOptions", `${name}.ts`); +const M = (name) => path.join(ROOT, "M01_MasterData", "StructOptions", `${name}.ts`); const master = JSON.parse( - fs.readFileSync(path.join(ROOT, "resources", "master_template", "구조물정의.json"), "utf8"), + fs.readFileSync( + path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"), + "utf8", + ), ); const def = JSON.parse(JSON.stringify(master)); -const add = load(M("M02_SO_Def_Add")); +const add = load(M("M01_SO_Def_Add")); const catalog = load(C("common_util_structure_catalog")); const station = load(C("common_util_structure_station")); const attach = load(C("common_util_structure_attach")); @@ -48,7 +51,7 @@ const walls = load(C("common_util_structure_walls")); const pipeSpecs = load( path.join(ROOT, "A00_Common", "design", "logic", "design_structure_pipe.ts"), ); -const check = load(M("M02_SO_Def_Check")); +const check = load(M("M01_SO_Def_Check")); const out = {}; out.templates = add.templates(def).map(([key]) => key); diff --git a/resources/tester/helper_384_3_planted.mjs b/resources/tester/helper_384_3_planted.mjs index 7e1d546be..1bdc1b56e 100644 --- a/resources/tester/helper_384_3_planted.mjs +++ b/resources/tester/helper_384_3_planted.mjs @@ -66,7 +66,7 @@ const detail = { }; // 구조물 표 = 실제 정의(마스터 읽기만) · 측점을 심는 구조물 — 켜진 점형 하나 · 꺼진 것 하나(보기와 같이 둘 다 심음) const definition = JSON.parse( - readFileSync(new URL("../master_template/구조물정의.json", import.meta.url), "utf8"), + readFileSync(new URL("../master_data/구조물정의/구조물정의.json", import.meta.url), "utf8"), ); m.useCatalogDefinition(definition); const planting = (item) => { diff --git a/resources/tester/helper_457_draft_card.cjs b/resources/tester/helper_457_draft_card.cjs index a8c8697f0..0bcaf72b7 100644 --- a/resources/tester/helper_457_draft_card.cjs +++ b/resources/tester/helper_457_draft_card.cjs @@ -52,7 +52,7 @@ const PD = load(P("B05_Profile", "logic", "B05_Profile_Pipeline_Detail.ts")); const CR = load(P("A00_Common", "design", "design_pipeline_cross.ts")); const def = JSON.parse( - fs.readFileSync(P("resources", "master_template", "구조물정의.json"), "utf8"), + fs.readFileSync(P("resources", "master_data", "구조물정의", "구조물정의.json"), "utf8"), ); const types = def.types .filter((t) => t.enabled !== false) diff --git a/resources/tester/helper_458_swap_attach.cjs b/resources/tester/helper_458_swap_attach.cjs index 887902e35..a1152b8d8 100644 --- a/resources/tester/helper_458_swap_attach.cjs +++ b/resources/tester/helper_458_swap_attach.cjs @@ -42,7 +42,7 @@ const SS = load(P("B05_Profile", "logic", "B05_Profile_Sections_Stations.ts")); const SW = load(P("B06_Section", "logic", "B06_Section_Station_Swap.ts")); const AT = load(P("common_util", "common_util_structure_attach.ts")); const def = JSON.parse( - fs.readFileSync(P("resources", "master_template", "구조물정의.json"), "utf8"), + fs.readFileSync(P("resources", "master_data", "구조물정의", "구조물정의.json"), "utf8"), ); const types = def.types .filter((t) => t.enabled !== false) diff --git a/resources/tester/helper_473_lane_ready.cjs b/resources/tester/helper_473_lane_ready.cjs index 088c8701b..392619399 100644 --- a/resources/tester/helper_473_lane_ready.cjs +++ b/resources/tester/helper_473_lane_ready.cjs @@ -62,7 +62,10 @@ const { createFacilityLane } = loadTs(path.join(design, "design_facility_lane.ts const ids = loadTs(path.join(design, "design_pipe_ids.ts")); const { listedBase } = loadTs(path.join(design, "design_profile_base.ts")); const TYPES = JSON.parse( - fs.readFileSync(path.join(ROOT, "resources", "master_template", "구조물정의.json"), "utf8"), + fs.readFileSync( + path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"), + "utf8", + ), ).types; /** 가짜 종단도 — 측점을 받은 차례 기록. */ diff --git a/resources/tester/helper_857_import.py b/resources/tester/helper_857_import.py index 5b557dcf7..a96621ad9 100644 --- a/resources/tester/helper_857_import.py +++ b/resources/tester/helper_857_import.py @@ -7,8 +7,8 @@ 재료 찾기 판정 · 키). - 올림 = 엑셀을 임시 개인 층에 올림(`Hopyo_Router._upload`) → 거절 글 | 목록(`Hopyo_View.listing`) · 칠(`Hopyo_Marks.blocks`) · 고정 줄(`Hopyo_Fixed.line_of` 이름 · 규격 · 단위 · 단가 · 이음 · 비율). -- 재료 이음 표 = 일위대가 호표 자재 · 별도계상 줄 — 호표 길 키(`line_of`) · - 단가산출 길 키(`San_Link.m01`). +- 재료 이음 표 = 일위대가 호표 자재 · 별도계상 줄 — 호표 길 키(`line_of` · 같은 올림 단서) · + 단가산출 길 키(`San_Link.m01` · 엑셀 재료비 단가) — 859-4 뒤 두 길 한 벌(같음만). - 지문 = 갈래 열쇠(「블록 EST:거창#3」 등)마다 sha256 앞 16 자 · 견본 내용은 안 남김. - M01 한 벌 쥠(셈 동안 M01 파일이 안 바뀜 — 빠르게만 · 답 같음). """ @@ -185,10 +185,10 @@ def blocks(full: bool) -> tuple[dict[str, str], int]: # ── 엑셀 올림 · 호표 쪽 ───────────────────────────────────────────────── -def _fixed(book: dict) -> list: +def _fixed(book: dict, clues: list) -> list: from M02_MasterTemplete import M02_Hopyo_Fixed as hf - linker, out = hf.Linker(True), [] + linker, out = hf.Linker(True, clues), [] for h in book.get("호표") or []: for ln in h.get("줄") or []: fx = hf.line_of(ln, h["줄"], {}, set(), linker)["고정"] @@ -209,7 +209,7 @@ def mats(book: dict, clues: list) -> list: from M02_MasterTemplete import M02_San_Link as sl from M02_MasterTemplete import M02_San_MatFind as smf - linker, out = hf.Linker(True), [] + linker, out = hf.Linker(True, clues), [] for h in book.get("호표") or []: for ln in h.get("줄") or []: if hf.kind_of(ln) not in hm.MATERIAL_KINDS: @@ -217,6 +217,8 @@ def mats(book: dict, clues: list) -> list: a = (hf.line_of(ln, h["줄"], {}, set(), linker)["고정"]["이음"] or {}).get("자재") src = {k: ln.get(k) or "" for k in ("이름", "규격", "단위")} src |= {"종류": "자재", "코드": ln.get("코드") or ""} + if price := hf.excel_mat(ln): # 859-4 같은 품목 여러 줄 = 엑셀 값 가까운 줄(두 길 공통) + src |= {"단가": {"M": float(price)}, "비목": "M"} with smf.clues_on(clues): b, _ = sl.m01("재료", src, "") found = src.get("재료찾기") or {} @@ -259,7 +261,7 @@ def upload(tag: str, path: Path) -> dict[str, Any]: "올림": {k: row.get(k) for k in ("시트", "호표수", "읽기불가")}, "목록": {k: listing.get(k) for k in ("호표", "단산", "검산")}, "칠": marks.blocks(folder, key), - "고정": _fixed(book), + "고정": _fixed(book, clues or []), "재료": mats(book, clues or []), } diff --git a/resources/tester/helper_859_3_show_digits.cjs b/resources/tester/helper_859_3_show_digits.cjs new file mode 100644 index 000000000..f57f6f134 --- /dev/null +++ b/resources/tester/helper_859_3_show_digits.cjs @@ -0,0 +1,35 @@ +/* 859-3 거울 헬퍼 — 보이는 자리 규칙(TS `common_util_show_digits.ts`)을 Node 로 돌림(`master_doc_digits.py` 짝). + * stdin = {수: [[값, 갈래, 이름, 단위, 자리|null]], 갈래: [{문서: {식}, 이름, 변수}], 표: {키: 표}, 자리: [{변수, 값, 값들}], + * 문서값: [{문서: {식, 변수}, 값들, 기호: [[이름, 값]]}]} + * stdout = {수: [showDigits], 갈래: [digitKind], 자리: [tablePlaces | null], 문서값: [[showValue]]} */ +const fs = require("fs"); +const path = require("path"); +const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript")); + +const cache = new Map(); +function load(at) { + if (cache.has(at)) return cache.get(at); + const js = ts.transpileModule(fs.readFileSync(at, "utf8"), { + compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 }, + }).outputText; + const box = { exports: {} }; + cache.set(at, box.exports); + const need = (p) => (p.startsWith(".") ? load(path.resolve(path.dirname(at), `${p}.ts`)) : require(p)); + new Function("exports", "module", "require", js)(box.exports, box, need); + return box.exports; +} +const dig = load(path.join(__dirname, "..", "..", "common_util", "common_util_show_digits.ts")); + +const input = JSON.parse(fs.readFileSync(0, "utf8")); +const tables = input.표 || {}; +const res = { + 수: (input.수 || []).map(([v, k, n, u, p]) => dig.showDigits(v, k, n, u, p ?? undefined)), + 갈래: (input.갈래 || []).map((x) => dig.digitKind(x.문서, x.이름, x.변수 ?? undefined)), + 문서값: (input.문서값 || []).map((x) => + x.기호.map(([n, v]) => dig.showValue(x.문서, n, v, x.값들, (k) => tables[k])), + ), + 자리: (input.자리 || []).map( + (x) => dig.tablePlaces(x.변수, x.값, x.값들, (k) => tables[k]) ?? null, + ), +}; +process.stdout.write(JSON.stringify(res)); diff --git a/resources/tester/helper_b05_structures_define.cjs b/resources/tester/helper_b05_structures_define.cjs index c9c102dc7..f2a1b2bae 100644 --- a/resources/tester/helper_b05_structures_define.cjs +++ b/resources/tester/helper_b05_structures_define.cjs @@ -1,6 +1,6 @@ /* 구조물 정의 → 칸 모양 단위검증 헬퍼(PLAN 48-3 · 48-4) — `B05_Profile_UI_Structures_Define.ts` 를 * 그 자리에서 트랜스파일해 Node 로 돌림(import 없는 파일). 결과는 표준출력에 JSON 한 벌. - * 판 1 정의(`resources/master_template/구조물정의.json`)도 읽어 지금 화면과 같은지(차례 · 2열) 봄. + * 판 1 정의(`resources/master_data/구조물정의/구조물정의.json`)도 읽어 지금 화면과 같은지(차례 · 2열) 봄. */ const fs = require("fs"); const path = require("path"); @@ -48,7 +48,10 @@ const type = { const plain = (states) => Object.fromEntries([...states].map(([k, v]) => [k, v])); const def = JSON.parse( - fs.readFileSync(path.join(ROOT, "resources", "master_template", "구조물정의.json"), "utf8"), + fs.readFileSync( + path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"), + "utf8", + ), ); const merged = d.withDefinition( def.types.map((t) => ({ ...t, groups: (def.그룹[t.type_id] ?? []).map((g) => ({ id: g.id })) })), diff --git a/resources/tester/helper_b06_draft_pipe_replay.cjs b/resources/tester/helper_b06_draft_pipe_replay.cjs index 2d6d86544..731e1eb7a 100644 --- a/resources/tester/helper_b06_draft_pipe_replay.cjs +++ b/resources/tester/helper_b06_draft_pipe_replay.cjs @@ -39,7 +39,10 @@ const { loadTs } = makeLoader({ }); const DEF = JSON.parse( - fs.readFileSync(path.join(ROOT, "resources", "master_template", "구조물정의.json"), "utf8"), + fs.readFileSync( + path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"), + "utf8", + ), ); const TYPES = DEF.types.map((t) => ({ managed_by: null, enabled: true, ...t })); const attach = loadTs(path.join(ROOT, "common_util", "common_util_structure_attach.ts")); diff --git a/resources/tester/helper_m02_so_def_model.cjs b/resources/tester/helper_m02_so_def_model.cjs index 92969f79c..f4525535f 100644 --- a/resources/tester/helper_m02_so_def_model.cjs +++ b/resources/tester/helper_m02_so_def_model.cjs @@ -1,11 +1,11 @@ -/* M02 구조물 정의 편집 화면 자료 손질(`M02_SO_Def_Model.ts` · PLAN 48-2) 단위검증 헬퍼 — +/* M02 구조물 정의 편집 화면 자료 손질(`M01_SO_Def_Model.ts` · PLAN 48-2) 단위검증 헬퍼 — * TS 를 그 자리에서 트랜스파일해 Node 로 돌리고 결과를 JSON 으로 냄(pytest 가 판정). */ const fs = require("fs"); const path = require("path"); const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript")); const source = fs.readFileSync( - path.join(__dirname, "..", "..", "M02_MasterTemplete", "StructOptions", "M02_SO_Def_Model.ts"), + path.join(__dirname, "..", "..", "M01_MasterData", "StructOptions", "M01_SO_Def_Model.ts"), "utf8", ); const js = ts.transpileModule(source, { diff --git a/resources/tester/helper_m02_so_def_spec.cjs b/resources/tester/helper_m02_so_def_spec.cjs index d1fe96643..092c42a37 100644 --- a/resources/tester/helper_m02_so_def_spec.cjs +++ b/resources/tester/helper_m02_so_def_spec.cjs @@ -1,4 +1,4 @@ -/* M02 구조물 명세 이름 고치기(`M02_SO_Def_Spec_Model.ts` · PLAN 52-11) 단위검증 헬퍼 — +/* M02 구조물 명세 이름 고치기(`M01_SO_Def_Spec_Model.ts` · PLAN 52-11) 단위검증 헬퍼 — * TS 를 그 자리에서 트랜스파일해 Node 로 돌리고 결과를 JSON 으로 냄(pytest 가 판정). * 정의는 진짜 `구조물정의.json` 을 읽어 메모리 사본만 고침(파일 쓰기 없음). */ const fs = require("fs"); @@ -25,11 +25,14 @@ const load = (...parts) => { new Function("exports", "module", "require", js)(box.exports, box, near); return box.exports; }; -const m = load("M02_MasterTemplete", "StructOptions", "M02_SO_Def_Spec_Model.ts"); +const m = load("M01_MasterData", "StructOptions", "M01_SO_Def_Spec_Model.ts"); const { PIPE_SPEC } = load("A00_Common", "design", "logic", "design_structure_pipe.ts"); const real = () => JSON.parse( - fs.readFileSync(path.join(ROOT, "resources", "master_template", "구조물정의.json"), "utf8"), + fs.readFileSync( + path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"), + "utf8", + ), ); const out = {}; diff --git a/resources/tester/test_106_span_highlight_wording.py b/resources/tester/test_106_span_highlight_wording.py index c3275bb7a..9f9b03708 100644 --- a/resources/tester/test_106_span_highlight_wording.py +++ b/resources/tester/test_106_span_highlight_wording.py @@ -68,7 +68,7 @@ def test_로케일에_기슭막이는_독립_한_곳뿐(): def test_정의_label은_흙막이_choices_값은_그대로(): - definition = json.loads(_read("resources", "master_template", "구조물정의.json")) + definition = json.loads(_read("resources", "master_data", "구조물정의", "구조물정의.json")) labels, choices = [], [] def walk(node): diff --git a/resources/tester/test_120_b08_drain_summary.py b/resources/tester/test_120_b08_drain_summary.py index a3effb254..8fbe6bff0 100644 --- a/resources/tester/test_120_b08_drain_summary.py +++ b/resources/tester/test_120_b08_drain_summary.py @@ -24,8 +24,8 @@ import pytest from B06_Section.B06_Section_Schema import CrossSectionPatch from B08_Quantity import B08_Quantity_Router_Summary as summary +from M01_MasterData.StructOptions import M01_SO_Definition as definition from M02_MasterTemplete import M02_Item_Snapshot as snapshots -from M02_MasterTemplete.StructOptions import M02_SO_Definition as definition ROOT = Path(__file__).resolve().parents[2] FIXTURES = Path(__file__).parent / "fixtures" diff --git a/resources/tester/test_129_menu_equals_panel.py b/resources/tester/test_129_menu_equals_panel.py index 34ce1ff11..d72319d71 100644 --- a/resources/tester/test_129_menu_equals_panel.py +++ b/resources/tester/test_129_menu_equals_panel.py @@ -15,8 +15,8 @@ import subprocess import pytest -from M02_MasterTemplete.StructOptions import M02_SO_Definition as definition -from M02_MasterTemplete.StructOptions.M02_SO_Options import with_visible +from M01_MasterData.StructOptions import M01_SO_Definition as definition +from M01_MasterData.StructOptions.M01_SO_Options import with_visible HERE = os.path.dirname(os.path.abspath(__file__)) ROOT = os.path.abspath(os.path.join(HERE, "..", "..")) diff --git a/resources/tester/test_131_b08_material_fix.py b/resources/tester/test_131_b08_material_fix.py index 1ebbf4871..8e683ef01 100644 --- a/resources/tester/test_131_b08_material_fix.py +++ b/resources/tester/test_131_b08_material_fix.py @@ -20,8 +20,8 @@ from test_121_b08_material_sheets import SUMMARY, UNITS, _run_ts from B08_Quantity import B08_Quantity_Router_Material as router_mod from B08_Quantity import B08_Quantity_Router_Summary as summary_mod from B08_Quantity.B08_Quantity_Material_Calc import clean_overrides, compute, finish +from M01_MasterData.StructOptions import M01_SO_Definition as definition from M02_MasterTemplete import M02_Item_Snapshot as snapshots -from M02_MasterTemplete.StructOptions import M02_SO_Definition as definition ROOT = Path(__file__).resolve().parents[2] FIXTURES = Path(__file__).parent / "fixtures" diff --git a/resources/tester/test_136_3_remove_button.py b/resources/tester/test_136_3_remove_button.py index 2ca13237f..457972857 100644 --- a/resources/tester/test_136_3_remove_button.py +++ b/resources/tester/test_136_3_remove_button.py @@ -42,10 +42,3 @@ def test_이름표_단추는_작은_단추_틀_흐림은_글에만(): assert "height: var(--b05-control-h)" in small and "padding-block: 0" in small legend = _rule(".b05-structure__group > legend {") assert "opacity" not in legend and "currentColor 80%" in legend - - -def test_M02_미리보기_이름표_단추도_작은_단추_틀(): - css = (ROOT / "M02_MasterTemplete" / "StructOptions" / "M02_SO_Style.css").read_text("utf-8") - at = css.index(".m02-sod__block .b05-structure__group > legend > button") - rule = css[at : css.index("}", at)] - assert "height: 26px" in rule and "padding-block: 0" in rule diff --git a/resources/tester/test_143_1_b08_linked_snapshots.py b/resources/tester/test_143_1_b08_linked_snapshots.py index 07b794fff..6926072b0 100644 --- a/resources/tester/test_143_1_b08_linked_snapshots.py +++ b/resources/tester/test_143_1_b08_linked_snapshots.py @@ -19,8 +19,8 @@ from pathlib import Path import pytest from B08_Quantity import B08_Quantity_Router_Summary as summary +from M01_MasterData.StructOptions import M01_SO_Definition as definition from M02_MasterTemplete import M02_Item_Snapshot as snapshots -from M02_MasterTemplete.StructOptions import M02_SO_Definition as definition ROOT = Path(__file__).resolve().parents[2] diff --git a/resources/tester/test_143_2_b08_blank_values.py b/resources/tester/test_143_2_b08_blank_values.py index 31fcd2f31..5f84904ee 100644 --- a/resources/tester/test_143_2_b08_blank_values.py +++ b/resources/tester/test_143_2_b08_blank_values.py @@ -10,8 +10,8 @@ import json from pathlib import Path from B08_Quantity import B08_Quantity_Router_Summary as summary +from M01_MasterData.StructOptions import M01_SO_Definition as definition from M02_MasterTemplete import M02_Item_Snapshot as snapshots -from M02_MasterTemplete.StructOptions import M02_SO_Definition as definition ITEM = {"layer": "system", "owner": None, "key": "SS000001", "name": "견본"} POINTS = [ diff --git a/resources/tester/test_154_2_b08_direct_link.py b/resources/tester/test_154_2_b08_direct_link.py index 8b9e34f65..f00dd6e1f 100644 --- a/resources/tester/test_154_2_b08_direct_link.py +++ b/resources/tester/test_154_2_b08_direct_link.py @@ -18,10 +18,10 @@ import pytest from B08_Quantity import B08_Quantity_Router_Summary as summary from config import config_system +from M01_MasterData.StructOptions import M01_SO_Definition as definition from M02_MasterTemplete import M02_Item_Copy as copies from M02_MasterTemplete import M02_Item_Snapshot as snap from M02_MasterTemplete import M02_Template_Layers as layers -from M02_MasterTemplete.StructOptions import M02_SO_Definition as definition from resources.tester.helper_m02_master_sample import SAMPLE ROOT = Path(__file__).resolve().parents[2] diff --git a/resources/tester/test_156_1_b08_unlink.py b/resources/tester/test_156_1_b08_unlink.py index f37eaf7f7..e4c20277e 100644 --- a/resources/tester/test_156_1_b08_unlink.py +++ b/resources/tester/test_156_1_b08_unlink.py @@ -13,9 +13,9 @@ import asyncio from pathlib import Path from B08_Quantity import B08_Quantity_Router_Summary as summary +from M01_MasterData.StructOptions import M01_SO_Definition as definition from M02_MasterTemplete import M02_Item_Snapshot as snap from M02_MasterTemplete import M02_Project_Items_Router as items_router -from M02_MasterTemplete.StructOptions import M02_SO_Definition as definition from resources.tester.test_154_2_b08_direct_link import ( # noqa: F401 — 시험 저장소 MS, PIPE, diff --git a/resources/tester/test_166_1_note_options.py b/resources/tester/test_166_1_note_options.py index ee1341e67..d2417ade5 100644 --- a/resources/tester/test_166_1_note_options.py +++ b/resources/tester/test_166_1_note_options.py @@ -26,7 +26,7 @@ from B07_DesignDetail.B07_DesignDetail_Engine_Cad_CulvertNote import ( # noqa: structure_note_lines, with_option_lines, ) -from M02_MasterTemplete.StructOptions.M02_SO_Options import with_visible # noqa: E402 +from M01_MasterData.StructOptions.M01_SO_Options import with_visible # noqa: E402 pytestmark = pytest.mark.skipif( not (ROOT / "config" / "node_modules").is_dir(), reason="프론트엔드 의존성 미설치" diff --git a/resources/tester/test_194_1_berm_depth.py b/resources/tester/test_194_1_berm_depth.py index 95e726918..f4ff322a5 100644 --- a/resources/tester/test_194_1_berm_depth.py +++ b/resources/tester/test_194_1_berm_depth.py @@ -32,7 +32,7 @@ from config.config_system import STANDARD_CROSS_SECTION ROOT = Path(__file__).resolve().parents[2] TSC = ROOT / "config" / "node_modules" / "typescript" / "bin" / "tsc" HELPER = Path(__file__).parent / "helper_194_1_berm_pick.cjs" -DEF = ROOT / "resources" / "master_template" / "구조물정의.json" +DEF = ROOT / "resources" / "master_data" / "구조물정의" / "구조물정의.json" node_only = pytest.mark.skipif(not TSC.is_file(), reason="프론트엔드 의존성 미설치") diff --git a/resources/tester/test_211_1_inlet_revet_height.py b/resources/tester/test_211_1_inlet_revet_height.py index 572b9008e..6d08ea549 100644 --- a/resources/tester/test_211_1_inlet_revet_height.py +++ b/resources/tester/test_211_1_inlet_revet_height.py @@ -19,8 +19,8 @@ from B05_Profile.B05_Profile_Structures_Schema import structure_type_map from B06_Section import B06_Section_Engine_Culvert as culvert from B08_Quantity import B08_Quantity_Router_Summary as summary from common_util.common_util_drainage_pipes import PipePoint +from M01_MasterData.StructOptions import M01_SO_Definition as definition from M02_MasterTemplete import M02_Item_Snapshot as snapshots -from M02_MasterTemplete.StructOptions import M02_SO_Definition as definition ROOT = Path(__file__).resolve().parents[2] TSC = ROOT / "config" / "node_modules" / "typescript" / "bin" / "tsc" diff --git a/resources/tester/test_322_0_golden.py b/resources/tester/test_322_0_golden.py index 425dd7f99..7e1b69f71 100644 --- a/resources/tester/test_322_0_golden.py +++ b/resources/tester/test_322_0_golden.py @@ -30,7 +30,7 @@ from B06_Section.B06_Section_Engine_Structures_Wall import attach_wall_specs, wa from B06_Section.B06_Section_Engine_Tilt import attach_underdrain_specs, load_underdrains from common_util.common_util_drainage_pipes import parse_pipe_points from common_util.common_util_structure_pavement import attach_pavement_structures -from M02_MasterTemplete.StructOptions.M02_SO_Options import with_visible +from M01_MasterData.StructOptions.M01_SO_Options import with_visible HERE = Path(__file__).parent ROOT = HERE.parent.parent diff --git a/resources/tester/test_322_0_version.py b/resources/tester/test_322_0_version.py index 2d87b92e8..c02e86f87 100644 --- a/resources/tester/test_322_0_version.py +++ b/resources/tester/test_322_0_version.py @@ -1,7 +1,7 @@ """PLAN 322-0 ③ — 판 확인: 서버 관 기본값 · 판 읽기 길이 정의 사본을 바로 따름(서버 다시 켜기 없음). - `_registry_defaults` = 정의 파일이 바뀌면 다음 부름부터 새 기본값(옛 lru = 서버 다시 켤 때까지 옛 값). -- `GET /api/m02/structure-definition/version` = 지금 판 `{판}` 만(화면 종류 캐시가 판을 볼 때 · 한 벌 안 받음). +- `GET /api/m01/structure-definition/version` = 지금 판 `{판}` 만(화면 종류 캐시가 판을 볼 때 · 한 벌 안 받음). 화면 캐시 쪽은 `test_322_0_golden.py::test_type_cache_follows_definition_version`. """ @@ -17,7 +17,7 @@ from fastapi.testclient import TestClient from B05_Profile import B05_Profile_Structures_Schema as schema from B06_Section.B06_Section_Engine_Culvert import _registry_defaults from common_util.common_util_auth import verify_session -from M02_MasterTemplete.StructOptions.M02_SO_Router import read_router +from M01_MasterData.StructOptions.M01_SO_Router import read_router @pytest.fixture @@ -53,6 +53,6 @@ def test_version_endpoint_reads_current_version(copy: Path) -> None: app.dependency_overrides[verify_session] = lambda: {"role": "USER", "user_id": 2} client = TestClient(app) now = json.loads(copy.read_text("utf-8"))["판"] - assert client.get("/api/m02/structure-definition/version").json() == {"판": now} + assert client.get("/api/m01/structure-definition/version").json() == {"판": now} _rewrite(copy, lambda doc: doc.update(판=now + 3)) - assert client.get("/api/m02/structure-definition/version").json() == {"판": now + 3} + assert client.get("/api/m01/structure-definition/version").json() == {"판": now + 3} diff --git a/resources/tester/test_322_2_check_mirror.py b/resources/tester/test_322_2_check_mirror.py index 518b48d31..48e907dbf 100644 --- a/resources/tester/test_322_2_check_mirror.py +++ b/resources/tester/test_322_2_check_mirror.py @@ -24,12 +24,12 @@ from fastapi.testclient import TestClient from B05_Profile import B05_Profile_Structures_Schema as schema from common_util.common_util_auth import verify_session from common_util.common_util_structure_catalog import catalog -from M02_MasterTemplete.StructOptions.M02_SO_Check import catalog_errors -from M02_MasterTemplete.StructOptions.M02_SO_Router import read_router +from M01_MasterData.StructOptions.M01_SO_Check import catalog_errors +from M01_MasterData.StructOptions.M01_SO_Router import read_router HERE = Path(__file__).parent ROOT = HERE.parent.parent -URL = "/api/m02/structure-definition" +URL = "/api/m01/structure-definition" ADMIN = {"role": "SYSTEM_ADMIN", "user_id": 1} pytestmark = pytest.mark.skipif( diff --git a/resources/tester/test_322_3_plan_mirror.py b/resources/tester/test_322_3_plan_mirror.py index 6854ae3ea..c661ae543 100644 --- a/resources/tester/test_322_3_plan_mirror.py +++ b/resources/tester/test_322_3_plan_mirror.py @@ -20,7 +20,7 @@ from B05_Profile.B05_Profile_Engine_Sections import resolve_extra_stations from B05_Profile.B05_Profile_Structures_Schema import StructureInstance, load_definition from common_util.common_util_drainage_pipes import parse_pipe_points from common_util.common_util_structure_station import plan_stations -from M02_MasterTemplete.StructOptions.M02_SO_Options import with_visible +from M01_MasterData.StructOptions.M01_SO_Options import with_visible HERE = Path(__file__).parent ROOT = HERE.parent.parent diff --git a/resources/tester/test_323_4_attach_mirror.py b/resources/tester/test_323_4_attach_mirror.py index 3aea2d98d..2ddbbf693 100644 --- a/resources/tester/test_323_4_attach_mirror.py +++ b/resources/tester/test_323_4_attach_mirror.py @@ -21,7 +21,7 @@ from B05_Profile.B05_Profile_Structures_Schema import StructureInstance, load_de from B06_Section.B06_Section_Engine_Attach import attach_shapes from common_util.common_util_drainage_pipes import parse_pipe_points from common_util.common_util_structure_catalog import catalog -from M02_MasterTemplete.StructOptions.M02_SO_Options import with_visible +from M01_MasterData.StructOptions.M01_SO_Options import with_visible HERE = Path(__file__).parent ROOT = HERE.parent.parent diff --git a/resources/tester/test_323_7_new_type.py b/resources/tester/test_323_7_new_type.py index 3e01fb740..352b97c5b 100644 --- a/resources/tester/test_323_7_new_type.py +++ b/resources/tester/test_323_7_new_type.py @@ -17,7 +17,7 @@ from B05_Profile import B05_Profile_Structures_Schema as schema from B05_Profile.B05_Profile_Structures_Schema import StructureInstance from B06_Section.B06_Section_Engine_Structures_Wall import wall_specs_from from common_util import common_util_structure_catalog as catalog -from M02_MasterTemplete.StructOptions import M02_SO_Definition as definition +from M01_MasterData.StructOptions import M01_SO_Definition as definition HERE = Path(__file__).parent ROOT = HERE.parent.parent @@ -75,7 +75,7 @@ def test_check_screen_equals_server(ts: dict, copied: dict) -> None: master = json.loads(Path(definition.schema.DEFINITION_PATH).read_text(encoding="utf-8")) assert ts["problems"] == [] real = json.loads( - (ROOT / "resources" / "master_template" / "구조물정의.json").read_text("utf-8") + (ROOT / "resources" / "master_data" / "구조물정의" / "구조물정의.json").read_text("utf-8") ) assert definition.check(copied, real) == [] assert ts["badBase"] is True and ts["chain"] is True diff --git a/resources/tester/test_52_10_structure_spec_road.py b/resources/tester/test_52_10_structure_spec_road.py index 5d1424837..ed99601f8 100644 --- a/resources/tester/test_52_10_structure_spec_road.py +++ b/resources/tester/test_52_10_structure_spec_road.py @@ -13,7 +13,7 @@ import pytest HERE = os.path.dirname(os.path.abspath(__file__)) ROOT = os.path.dirname(os.path.dirname(HERE)) -DEFINITION = os.path.join(ROOT, "resources", "master_template", "구조물정의.json") +DEFINITION = os.path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json") @pytest.fixture(scope="module") diff --git a/resources/tester/test_52_3_structure_spec_ford_pavement.py b/resources/tester/test_52_3_structure_spec_ford_pavement.py index 3508d61f6..7f01391da 100644 --- a/resources/tester/test_52_3_structure_spec_ford_pavement.py +++ b/resources/tester/test_52_3_structure_spec_ford_pavement.py @@ -131,7 +131,7 @@ def test_집계표_짝_명세와_같음(): def test_정의_그룹_경사각도(): with open( - os.path.join(ROOT, "resources/master_template/구조물정의.json"), encoding="utf-8" + os.path.join(ROOT, "resources/master_data/구조물정의/구조물정의.json"), encoding="utf-8" ) as f: groups = json.load(f)["그룹"]["ford_pavement"] assert [(g["id"], g["이름"]) for g in groups] == [("gfordpaveslope", "경사각도")] diff --git a/resources/tester/test_52_4_structure_spec_ford.py b/resources/tester/test_52_4_structure_spec_ford.py index a7a4dd1ca..be66994c3 100644 --- a/resources/tester/test_52_4_structure_spec_ford.py +++ b/resources/tester/test_52_4_structure_spec_ford.py @@ -110,7 +110,8 @@ def test_월류_높이는_폭과_연동_필요_수심_올림(out): def test_정의_파일에_세월교_이름_표가_올라_있음(): names = _node("names") with open( - os.path.join(ROOT, "resources", "master_template", "구조물정의.json"), encoding="utf-8" + os.path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"), + encoding="utf-8", ) as f: doc = json.load(f) # 그림 전용 길이 칸(294-4)은 마스터 정의 이름 표에 안 올림(마스터 손대지 않음) — 대조 밖 diff --git a/resources/tester/test_52_6_cross_underdrain.py b/resources/tester/test_52_6_cross_underdrain.py index 6e5a15584..88107ac90 100644 --- a/resources/tester/test_52_6_cross_underdrain.py +++ b/resources/tester/test_52_6_cross_underdrain.py @@ -46,7 +46,7 @@ def test_컨테이너_맹암거_높이_경사_손_입력(): def test_정의_검사_통과(): - from M02_MasterTemplete.StructOptions import M02_SO_Definition as definition + from M01_MasterData.StructOptions import M01_SO_Definition as definition assert definition.check(load_definition()) == [] diff --git a/resources/tester/test_52_7_safety.py b/resources/tester/test_52_7_safety.py index 020ea13b6..3c64435fa 100644 --- a/resources/tester/test_52_7_safety.py +++ b/resources/tester/test_52_7_safety.py @@ -11,7 +11,7 @@ import subprocess from B05_Profile.B05_Profile_Structures_Schema import structure_type_map from common_util.common_util_structure_catalog import load_parts -from M02_MasterTemplete.StructOptions import M02_SO_Definition as definition +from M01_MasterData.StructOptions import M01_SO_Definition as definition HERE = os.path.dirname(os.path.abspath(__file__)) ROOT = os.path.dirname(os.path.dirname(HERE)) diff --git a/resources/tester/test_52_9_spoil_borrow.py b/resources/tester/test_52_9_spoil_borrow.py index 272ddc58d..9cc495482 100644 --- a/resources/tester/test_52_9_spoil_borrow.py +++ b/resources/tester/test_52_9_spoil_borrow.py @@ -11,9 +11,9 @@ from pathlib import Path from B05_Profile.B05_Profile_Structures_Schema import DEFINITION_PATH, load_structure_types from common_util.common_util_structure_catalog import catalog_row +from M01_MasterData.StructOptions import M01_SO_Definition +from M01_MasterData.StructOptions.M01_SO_Groups import groups_of from M02_MasterTemplete.M02_Table_Fill import _with_group_items -from M02_MasterTemplete.StructOptions import M02_SO_Definition -from M02_MasterTemplete.StructOptions.M02_SO_Groups import groups_of KINDS = { "spoil_bank": ("유용토운반작업장(사토장)", "사토장 부피", "gspoildetail"), @@ -40,8 +40,8 @@ def test_컨테이너_상세_내용_하나_부피를_담음(): def test_정의_검사_통과_판_이력(): doc = json.loads(Path(DEFINITION_PATH).read_text("utf-8")) - assert M02_SO_Definition.check(doc) == [] - assert M02_SO_Definition.history_path(doc["판"] - 1).is_file() + assert M01_SO_Definition.check(doc) == [] + assert M01_SO_Definition.history_path(doc["판"] - 1).is_file() def test_잇기는_그룹마다_집계_한_줄(): diff --git a/resources/tester/test_52_structure_spec_box.py b/resources/tester/test_52_structure_spec_box.py index 5bc8c469d..fa5d6f42a 100644 --- a/resources/tester/test_52_structure_spec_box.py +++ b/resources/tester/test_52_structure_spec_box.py @@ -99,7 +99,8 @@ def test_사용자_입력_빈_칸은_다시_열어도_사용자_입력(out): def test_정의_파일에_이름_표_그룹_선택지가_올라_있음(): names = _node("names") with open( - os.path.join(ROOT, "resources", "master_template", "구조물정의.json"), encoding="utf-8" + os.path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"), + encoding="utf-8", ) as f: doc = json.load(f) # 그림 전용 길이 칸(294-4)은 마스터 정의 이름 표에 안 올림(마스터 손대지 않음) — 대조 밖 diff --git a/resources/tester/test_52_structure_spec_pipe.py b/resources/tester/test_52_structure_spec_pipe.py index 64b33b570..32801eade 100644 --- a/resources/tester/test_52_structure_spec_pipe.py +++ b/resources/tester/test_52_structure_spec_pipe.py @@ -103,7 +103,8 @@ def test_잇기_키와_이름_바꿈(out): def test_정의_파일에_이름_표가_올라_있음(): names = _node("names") with open( - os.path.join(ROOT, "resources", "master_template", "구조물정의.json"), encoding="utf-8" + os.path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"), + encoding="utf-8", ) as f: doc = json.load(f) on_file = doc["종류"]["pipe"]["이름"] diff --git a/resources/tester/test_54_26_slope_table09.py b/resources/tester/test_54_26_slope_table09.py index c848eb74d..1d27e73c3 100644 --- a/resources/tester/test_54_26_slope_table09.py +++ b/resources/tester/test_54_26_slope_table09.py @@ -13,9 +13,9 @@ from B05_Profile.B05_Profile_Structures_Schema import ( StructureInstance, load_structure_types, ) -from M02_MasterTemplete.StructOptions import M02_SO_Definition -from M02_MasterTemplete.StructOptions.M02_SO_Groups import groups_of -from M02_MasterTemplete.StructOptions.M02_SO_Options import hidden_keys +from M01_MasterData.StructOptions import M01_SO_Definition +from M01_MasterData.StructOptions.M01_SO_Groups import groups_of +from M01_MasterData.StructOptions.M01_SO_Options import hidden_keys TABLE = { "soil_guard": ( @@ -87,5 +87,5 @@ def test_옛_값_저장_막지_않음(): def test_정의_검사_통과_판_이력(): doc = json.loads(Path(DEFINITION_PATH).read_text("utf-8")) - assert M02_SO_Definition.check(doc) == [] - assert M02_SO_Definition.history_path(doc["판"] - 1).is_file() + assert M01_SO_Definition.check(doc) == [] + assert M01_SO_Definition.history_path(doc["판"] - 1).is_file() diff --git a/resources/tester/test_54_6_slope_container.py b/resources/tester/test_54_6_slope_container.py index 981ddcade..4f8a0f456 100644 --- a/resources/tester/test_54_6_slope_container.py +++ b/resources/tester/test_54_6_slope_container.py @@ -8,9 +8,9 @@ import json from pathlib import Path from B05_Profile.B05_Profile_Structures_Schema import DEFINITION_PATH, load_structure_types +from M01_MasterData.StructOptions import M01_SO_Definition +from M01_MasterData.StructOptions.M01_SO_Groups import groups_of from M02_MasterTemplete.M02_Table_Fill import _with_group_items -from M02_MasterTemplete.StructOptions import M02_SO_Definition -from M02_MasterTemplete.StructOptions.M02_SO_Groups import groups_of KINDS = { "retaining_wall": "gretaindetail", @@ -41,8 +41,8 @@ def test_C군_종류마다_컨테이너_하나_옵션_전부(): def test_정의_검사_통과_판_이력(): doc = json.loads(Path(DEFINITION_PATH).read_text("utf-8")) - assert M02_SO_Definition.check(doc) == [] - assert M02_SO_Definition.history_path(doc["판"] - 1).is_file() + assert M01_SO_Definition.check(doc) == [] + assert M01_SO_Definition.history_path(doc["판"] - 1).is_file() def test_잇기는_컨테이너마다_집계_한_줄(): diff --git a/resources/tester/test_553_5_m01_m02.py b/resources/tester/test_553_5_m01_m02.py index d2903c4ec..4772ec67c 100644 --- a/resources/tester/test_553_5_m01_m02.py +++ b/resources/tester/test_553_5_m01_m02.py @@ -71,8 +71,12 @@ def test_m02_borrowed_m01_classes_follow_parts(): def _m02_src(suffix: str) -> dict[str, str]: out = {} - for sub in ("", "DataFlow", "StructOptions"): - out.update(_src(f"M02_MasterTemplete/{sub}".rstrip("/"), suffix)) + for folder in ( + "M02_MasterTemplete", + "M02_MasterTemplete/DataFlow", + "M01_MasterData/StructOptions", + ): + out.update(_src(folder, suffix)) return out diff --git a/resources/tester/test_701_1_b08_wall_summary.py b/resources/tester/test_701_1_b08_wall_summary.py index f651ca569..d766028a6 100644 --- a/resources/tester/test_701_1_b08_wall_summary.py +++ b/resources/tester/test_701_1_b08_wall_summary.py @@ -14,7 +14,7 @@ import pytest from B08_Quantity import B08_Quantity_Router_Summary as summary from B09_Estimation.B09_Estimation_Bill_Items import structure_items -from M02_MasterTemplete.StructOptions import M02_SO_Definition as definition +from M01_MasterData.StructOptions import M01_SO_Definition as definition def _item(key: str) -> dict: diff --git a/resources/tester/test_821_1_my_machine.py b/resources/tester/test_821_1_my_machine.py index 51500988d..a8106be9d 100644 --- a/resources/tester/test_821_1_my_machine.py +++ b/resources/tester/test_821_1_my_machine.py @@ -161,6 +161,24 @@ def test_sk_copy_edit_refresh_delete(world): assert float(look["후"]["계"]) == new +def test_auto_sk_keeps_value_after_delete(world, monkeypatch): + """요구 902 — 자동 따라옴 SK 가 따라온 값은 기계를 지워도 그대로(마지막 저장 값으로 안 돌아감).""" + from M02_MasterTemplete import M02_Sk_AutoRenew as renew + + monkeypatch.setattr(renew, "on", lambda: True) + me = world["personal"] + made = _at(me, mym.create, _easy()) + key = made["줄"]["키"] + sk = _sk(me, made["줄"]["원문번호"]) + was = _sum(me, sk) + _at(me, mym.update, key, _easy(가격=3000)) + followed = _sum(me, sk) + assert followed != was # 저장 없이 따라옴 + _at(me, mym.delete, key) + after = _calc(me, _doc(me, sk)) + assert after["기준"]["계"] == followed and after["사본"]["지운키"] == [key] + + def test_m01_only_sk_same(world): """⑤ 내 기계가 있는 층에서도 M01 만 쓰는 SK 금액 · 사본 같음 · 사본 모으기에 내 기계 안 낌.""" me, other = world["personal"], layers.personal_dir(7, 43) diff --git a/resources/tester/test_821_3_my_machine_screen.py b/resources/tester/test_821_3_my_machine_screen.py index 44de28212..09213a93d 100644 --- a/resources/tester/test_821_3_my_machine_screen.py +++ b/resources/tester/test_821_3_my_machine_screen.py @@ -113,7 +113,7 @@ def _stack_doc(key, no): def test_stack_line_copy(world): """⑤ 줄 쌓기로 고른 내 기계 — 미리 셈 됨 · 저장 때 값 사본에 박힘 → - 고치면 자동 따라옴(836-2 · 갱신 할 것 없음) → 지워도 저장한 사본 값 + 지운키.""" + 고치면 자동 따라옴(836-2 · 갱신 할 것 없음) → 지워도 지우기 직전 따라온 값 + 지운키(요구 902).""" from M02_MasterTemplete import M02_Doc_Sk_Path as path from M02_MasterTemplete import M02_Labor_Ref as refs @@ -137,7 +137,7 @@ def test_stack_line_copy(world): assert now["셈"]["계"] > was and now["사본"]["자동"] and not now["사본"]["단가새값"] _at(me, mym.delete, key) gone = _at(me, path.read, sk) - assert gone["셈"]["계"] == was # 지운 키 = 저장한 사본 줄 값 + assert gone["셈"]["계"] == now["셈"]["계"] # 지운 키 = 지우기 직전 따라온 값(요구 902) def _mine_row(): diff --git a/resources/tester/test_826_1_layer_index.py b/resources/tester/test_826_1_layer_index.py index 66e1f7267..67f9d6b55 100644 --- a/resources/tester/test_826_1_layer_index.py +++ b/resources/tester/test_826_1_layer_index.py @@ -169,6 +169,36 @@ def test_m01_change_recounts_amount(fresh, tmp_path, monkeypatch): assert two != one +def test_my_machine_change_recounts_amount(fresh): + """내 기계를 고치면 목록 기준금액(SK · 담은 SC)이 바로 새 값 · 지워도 그대로(요구 902) — + 목록 셈의 지금 층 = 그 층(서버 길은 층을 안 정함).""" + from M02_MasterTemplete import M02_MyMachine as mym + + mine = fresh["personal"] + with store.at(mine): + made = mym.create({"이름": "sub3임시", "규격": "1", "방식": "직접", + "시간당": {"노무비": 0, "재료비": 0, "경비": 200}}) # fmt: skip + key = made["줄"]["키"] + body = {"이름": "기", "단위": "시간", "바탕": {"로직": "GC001199"}, + "입력값": {"기계": made["줄"]["원문번호"]}, "더한줄": []} # fmt: skip + sk = refs.create("sangeun", body)["이름"] + layer, owner = refs.where(mine) + ref = {"참조": {"층": layer, "주인": owner, "키": sk}, "수량": {"손": 1}} + sc = refs.create("precombo", {"이름": "조", "단위": "시간", "담은로직": [ref]})["이름"] + + def amounts(): + rows = _new(mine) + return [next(r for r in rows if r["이름"] == k)["기준금액"] for k in (sk, sc)] + + assert amounts() == [200, 200] + with store.at(mine): + mym.update(key, {**made["줄"], "시간당": {"노무비": 0, "재료비": 0, "경비": 600}}) + assert amounts() == [600, 600] + with store.at(mine): + mym.delete(key) + assert amounts() == [600, 600] + + def test_broken_index_rebuilds(fresh): _up, _a, _b, _sc = _shelf(fresh) mine = fresh["personal"] diff --git a/resources/tester/test_845_2_unit_show.py b/resources/tester/test_845_2_unit_show.py index 67c0ca008..f6dbf5d4c 100644 --- a/resources/tester/test_845_2_unit_show.py +++ b/resources/tester/test_845_2_unit_show.py @@ -86,7 +86,8 @@ def test_GC000088_비목_줄_단위_자리(world): "⟦\\text{휴지율}⟧ = ⟦\\dfrac{\\text{월간급여지급일}}{\\text{월간가동일수}}⟧ = ⟦\\dfrac{25}{20}⟧" in sub ) - assert "\\dfrac{1}{8} \\times 1.333333 \\times 1.25⟧ = ⟦0.208333" in sub + # 859-3 식이 낸 값 = 유효숫자 3(그림만 · 금액 59,020.2 그대로) + assert "\\dfrac{1}{8} \\times 1.33 \\times 1.25⟧ = ⟦0.208\\ " in sub assert ( "\\text{노무비 계수}⟧ = ⟦\\dfrac{\\text{일}}{\\text{일일근무시간}} \\times \\text{상여율} \\times \\text{휴지율}⟧" in sub @@ -97,7 +98,7 @@ def test_GC000088_비목_줄_단위_자리(world): assert "⟦\\text{가격}⟧ = 142,069 천원" in sub assert "⟦\\text{직종}⟧ = 1048" in sub # 코드 값 = 쉼표 없음 assert ( - "조종원 : ⟦283{,}297⟧ 원/인 × ⟦\\left(1 \\times 0.208333\\right)⟧ 인 = 59,020.2 원" in sub + "조종원 : ⟦283{,}297⟧ 원/인 × ⟦\\left(1 \\times 0.208\\right)⟧ 인 = 59,020.2 원" in sub ) assert "⟦\\text{가산}⟧ = ⟦0\\ \\text{\\%}⟧" in sub # % = TeX 글(주석으로 안 먹힘) diff --git a/resources/tester/test_859_3_show_digits.py b/resources/tester/test_859_3_show_digits.py new file mode 100644 index 000000000..849169537 --- /dev/null +++ b/resources/tester/test_859_3_show_digits.py @@ -0,0 +1,161 @@ +"""859-3 지킴 — 보이는 수 자릿수 규칙 한 쌍 +(TS `common_util_show_digits.ts` ↔ PY `master_doc_digits.py`). + +① 거울 — 같은 값 · 갈래 · 기호 · 단위 · 표 자리 → 같은 글(헬퍼 `helper_859_3_show_digits.cjs`) · + 갈래 판정 · 표 값 원문 글자 자리(서버 표 캐시 `자리` → 화면 `tablePlaces`) · 문서 기호 값 글 — + M01 수식 문서 전부(기본 입력 셈 답). +② 규칙 결과 — 표 값 끝 0 살림 · 식 품 유효숫자 3 · 원 단위 소수 한 자리 · 8-1 Q 3 자리 · + 입력 · 요소 그대로. +③ 그림만 — 서버 산출근거 글의 금액은 셈 답 그대로(글 끝 「= 금액」 = 줄 금액 소수 한 자리). +""" + +from __future__ import annotations + +import importlib +import json +import os +import subprocess +from decimal import Decimal +from functools import lru_cache + +from M01_MasterData import M01_MasterData_Doc as m01_doc +from M01_MasterData import M01_MasterData_Store as m01 +from M02_MasterTemplete import M02_Logic_Standard as st + +mc = importlib.import_module("master_doc_calc") +md = importlib.import_module("master_doc") +mdd = importlib.import_module("master_doc_digits") +mdt = importlib.import_module("master_doc_text") +rec = importlib.import_module("master_doc_record") + +HERE = os.path.dirname(os.path.abspath(__file__)) +NUMS = [0, 1, -1, 8, 250, 0.5, 1.5, 2.5, -2.5, 0.05, 0.15, 0.25, 0.35, 1.05, 1.005, 2.675, 99.95, + -0.05, 0.1 + 0.2, 1e-7, 0.0004, 0.000417, 0.027778, 0.0285, 0.0995, 0.99999, 1.4552, + 0.606061, 33971.813333, 535.396667, 12987.917773, 2446.08, 1234567.891234567, + 59018.0857142857, 284.42142857142, 123456789012.345, 26890.75, 1502.04999, + 0.1, 3.0] # fmt: skip +KINDS = [("식", "", ""), ("식", "Q", ""), ("식", "n", ""), ("식", "cm", ""), ("식", "", "원/시간"), + ("식", "", "인"), ("표", "", ""), ("입력", "", ""), ("요소", "", "원/인")] # fmt: skip + + +def _js(v): + if isinstance(v, Decimal): + return float(v) + if isinstance(v, dict): + return {k: _js(x) for k, x in v.items()} + if isinstance(v, (list, tuple)): + return [_js(x) for x in v] + if isinstance(v, (mc.Blank, mc.Stop)): + return None + return v + + +@lru_cache(maxsize=1) +def world(): + whole = m01.loaded()[1] + docs = m01_doc.docs() + links = st._links(whole) + answers = {k: mc.calc(d, links, None) for k, d in docs.items() if d.get("금액")} + return docs, links, answers + + +def _helper(payload: dict) -> dict: + run = subprocess.run( + ["node", os.path.join(HERE, "helper_859_3_show_digits.cjs")], + input=json.dumps(payload, ensure_ascii=False), + capture_output=True, + text=True, + encoding="utf-8", + check=True, + ) + return json.loads(run.stdout) + + +@lru_cache(maxsize=1) +def mirror(): + docs, links, answers = world() + nums = [[v, k, n, u, p] for v in NUMS for k, n, u in KINDS for p in (None, 2, 3)] + kinds, places, tables, py = [], [], {}, {"수": [], "갈래": [], "자리": [], "문서값": []} + whole = [] + keep = rec.Rec(links) + for key, a in answers.items(): + doc = docs[key] + vals = a.get("값") or {} + look = mdt._Look(doc, a, links) + shown = {k: _js(v) for k, v in vals.items() if v is not None} + names = [md.var_id(x) for x in doc.get("변수") or []] + names += [str(x.get("기호") or "") for x in doc.get("식") or []] + pairs = [[n, float(vals[n])] for n in names if isinstance(vals.get(n), Decimal)] + get = links.master.get + py["문서값"].append([mdd.show_value(doc, n, vals[n], look.value, get) for n, _ in pairs]) + part = {"식": doc.get("식") or [], "변수": _js(doc.get("변수") or [])} + whole.append({"문서": part, "값들": shown, "기호": pairs}) + for var in doc.get("변수") or []: + name = md.var_id(var) + kinds.append({"문서": {"식": doc.get("식") or []}, "이름": name, "변수": _js(var)}) + py["갈래"].append(mdd.kind_of(doc, name, var)) + v = vals.get(name) + link = var.get("연결") or {} + if link.get("갈래") != "표" or not isinstance(v, Decimal): + continue + ref = str(link.get("표") or "") + keep.see_table(ref) + tables[ref] = _js(keep.표[ref]) + places.append({"변수": _js(var), "값": float(v), "값들": shown}) + py["자리"].append(mdd.table_value_places(link, v, look.value, links.master.get)) + nums.append([float(v), "표", name, "", py["자리"][-1]]) + for v, k, n, u, p in nums: + py["수"].append(mdd.show(v, k, n, u, p)) + every = [v for d in docs.values() for v in d.get("변수") or []] + refs = {str((v.get("연결") or {}).get("표") or "") for v in every} + for ref in refs: + if ref and "{" not in ref and ref not in tables: + keep.see_table(ref) + tables[ref] = _js(keep.표[ref]) + ts = _helper({"수": nums, "갈래": kinds, "표": tables, "자리": places, "문서값": whole}) + return nums, py, ts + + +def test_수_꼴_거울(): + nums, py, ts = mirror() + assert len(nums) > 7000 + bad = [(n, a, b) for n, a, b in zip(nums, py["수"], ts["수"]) if a != b] + assert not bad, bad[:10] + + +def test_갈래_표_자리_거울(): + _, py, ts = mirror() + assert len(py["갈래"]) > 10000 and py["갈래"] == ts["갈래"] + assert len(py["자리"]) > 7000 and py["자리"] == ts["자리"] + assert sum(1 for p in py["자리"] if p) > 500 # 끝 0 글자 자리가 실제로 실려 감 + + +def test_문서_기호_값_글_거울(): + _, py, ts = mirror() + assert sum(map(len, py["문서값"])) > 15000 + bad = [(a, b) for x, y in zip(py["문서값"], ts["문서값"]) for a, b in zip(x, y) if a != b] + assert not bad and py["문서값"] == ts["문서값"], bad[:10] + + +def test_규칙_결과(): + show = mdd.show + assert show(0.1, "표", "Q_수량^표", "인", 2) == "0.10" # 원문 글자 끝 0 + assert show(0.1, "표") == "0.1" and show(3.0, "표", "", "", 1) == "3.0" + assert show(0.027778, "식", "Q_보링공", "인") == "0.0278" # 유효숫자 3 + assert show(1.4552, "식") == "1.46" and show(8, "식") == "8" + assert show(33971.813333, "식", "", "원") == "33,971.8" # 원 단위 한 자리 + assert show(70.12345, "식", "Q") == "70.123" and show(2.456, "식", "n") == "2.46" + assert show(0.027778, "입력") == "0.027778" and show(1846.39, "요소") == "1,846.39" + assert show("5401-0017") == "5401-0017" and show(None) == "" and show(1048, "입력") == "1,048" + + +def test_서버_글_금액_그대로(): + docs, links, answers = world() + for key in ("GF000220", "GC000994", "GC000996"): + for line in mdt.money_lines(docs[key], answers[key], links): + if line.get("금액") is not None: + assert line["글"].endswith(f"= {mdt.one(line['금액'])} 원") + got = {x["이름"]: x for x in mdt.money_lines(docs["GC000994"], answers["GC000994"], links)} + assert got["보링공"]["수량글"] == "0.0278" + rate = [x for x in mdt.money_lines(docs["GC000996"], answers["GC000996"], links)] + assert any(x.get("단가글") == "33,971.8" for x in rate) diff --git a/resources/tester/test_859_4_hopyo_basis.py b/resources/tester/test_859_4_hopyo_basis.py new file mode 100644 index 000000000..cfa32e0a6 --- /dev/null +++ b/resources/tester/test_859_4_hopyo_basis.py @@ -0,0 +1,118 @@ +"""859-4 일위대가 두 판(요구 903 ㉢) — 고정 줄 셈 · 판이 하위 SC · 가져온 식 SK 에 닿는 길. + +- 문서 `본뜬.단가기준` 엑셀 = 이음 있어도 줄 단가(엑셀 숫자) 그대로 · 우리 = 이은 비목 단가 책 값 · + 칸 없음 = 지금 셈(우리와 같음) · 정리(`clean`)가 판을 지킴. +- 펼침(`Labor_Expand`) = 부르는 쪽 판 › SC 자기 판. +""" + +import sys +from pathlib import Path + +import pytest + +ROOT = Path(__file__).resolve().parents[2] +if str(ROOT) not in sys.path: + sys.path.insert(0, str(ROOT)) + +from M02_MasterTemplete import M02_Labor_Doc as labor # noqa: E402 +from M02_MasterTemplete import M02_Labor_Fixed as fixed # noqa: E402 +from M02_MasterTemplete.M02_Labor_Expand import Expand # noqa: E402 + +LB, MT = "LB000033", "MT006349" # 직종 하나 · 원형돌망태(몸통) 4,280 원/M + + +def _doc(basis=None): + born = {"층": "실무자료", "키": "HP-000001 제1호표", **({"단가기준": basis} if basis else {})} + fx = [ + ({"이름": "석공", "단위": "인", "단가": {"노무비": 10}, "이음": {"노임": LB}}, 0.5), + ({"이름": "돌망태", "단위": "M", "단가": {"재료비": 4000}, "이음": {"자재": MT}}, 2), + ({"이름": "잡재료", "단위": "식", "단가": {"재료비": 77}, "이음": {}}, 1), + ] + lines = [{"고정": {"규격": "", **f}, "수량": {"손": q}} for f, q in fx] + return labor.clean({"이름": "시험", "단위": "M", "본뜬": born, "담은로직": lines}) + + +def _base(doc): + return [(ln["기준"], ln["이은"]) for ln in labor.calc(doc, {})["줄"] if "고정" in ln] + + +def test_판_칸_정리_지킴_과_읽기(): + assert fixed.basis_of(_doc("엑셀")) == "엑셀" and fixed.basis_of(_doc("우리")) == "우리" + assert fixed.basis_of(_doc()) is None and fixed.basis_of({"본뜬": {"단가기준": "글"}}) is None + + +def test_엑셀_판_줄_단가_그대로_우리_판_단가_책_값(): + whole = labor.m01.loaded()[1] + excel, ours, none = _base(_doc("엑셀")), _base(_doc("우리")), _base(_doc()) + assert [b["계"] for b, _ in excel] == [10, 4000, 77] and all(u == [] for _, u in excel) + assert ours == none # 칸 없음 = 지금 셈 + assert ours[0][0]["노무비"] == whole.get(LB)["값"] and ours[0][1] == ["노무비"] + assert ours[1][0]["재료비"] == 4280 and ours[1][1] == ["재료비"] + assert ours[2][0]["계"] == 77 and ours[2][1] == [] + + +def test_펼침_부르는_쪽_판_자기_판(): + docs = {"엑셀": _doc("엑셀"), "우리": _doc("우리")} + ref = {"층": "personal", "주인": "x", "키": "SC-000001"} + + def total(own, caller=None): + ex = Expand(labor.m01.loaded()[1], lambda r: docs[own], hands=True) + return ex(ref, (), caller)["기준"]["계"] + + excel = 0.5 * 10 + 2 * 4000 + 77 + assert float(total("엑셀")) == pytest.approx(excel) + assert float(total("우리", "엑셀")) == pytest.approx(excel) # 부르는 쪽 판이 앞섬 + assert float(total("엑셀", "우리")) == float(total("우리")) != pytest.approx(excel) + + +# ── 재료 찾기 한 벌 · 값 가까운 줄(두 불러오기 공통) ───────────────────────── +def _key(name, spec, unit, price=None): + from M02_MasterTemplete import M02_San_Link as sl + + src = {"이름": name, "규격": spec, "단위": unit, "종류": "자재", "코드": ""} + src |= {"단가": {"M": price}, "비목": "M"} if price else {} + return sl.m01("재료", src)[0], src["재료찾기"]["방법"] + + +def test_같은_품목_여러_줄_엑셀_값_가까운_줄(): + assert _key("원형돌망태(몸통)", "#8,45×45", "M") == ( + "MT006342", + "표기", + ) # 엑셀 값 없음 = 지금 차례 + assert ( + _key("원형돌망태(몸통)", "#8,45×45", "M", 4280)[0] == MT + ) # 관급 값 없음 → 엑셀 값 같은 줄 + assert _key("원형돌망태(뚜껑)", "#8,45×45", "EA", 1480)[0] == "MT006350" + assert ( + _key("외송각재", "30×30×3600mm", "㎥", 568000)[0] == "MT000341" + ) # 지역 줄 가운데 값 가까운 곳 + assert _key("외송각재, 대전", "30×30×3600mm", "㎥", 568000)[0] == "MT000349" # 밝힌 지역 안에서 + + +def test_일위대가_불러오기_자재_줄_단가산출_길_찾기(): + from M02_MasterTemplete import M02_Hopyo_Fixed as hf + + line = {"갈래": "자재", "이름": "원형돌망태(몸통)", "규격": "#8,45×45", "단위": "M", "수량": 1, + "단가": {"재료비": 4280}, "금액": {"재료비": 4280}, "차례": 0} # fmt: skip + got = hf.line_of(line, [], {}, set(), hf.Linker(True))["고정"] + assert got["이음"]["자재"] == MT and got["단가"]["재료비"] == 4280 # 줄 단가 = 엑셀 기억 + odd = {**line, "단가": {"재료비": 9999}, "금액": {"재료비": 9999}} + assert ( + hf.line_of(odd, [], {}, set(), hf.Linker(True))["고정"]["이음"]["자재"] == MT + ) # 값 관문 없음 + assert ( + hf.line_of(odd, [], {}, set(), hf.Linker())["고정"]["이음"]["자재"] is None + ) # 붙여넣기 = 옛 관문 + none = {**line, "이름": "없는자재ㅋㅋ", "규격": "zz"} + linker = hf.Linker(True) + assert hf.line_of(none, [], {}, set(), linker)["고정"]["이음"]["자재"] is None + assert linker.verdict(none) == "우리 표에 없음" + + +def test_불러오기_끝내도_판_남음(): + from M02_MasterTemplete import M02_Hopyo_Forget as forget + + doc = _doc("우리") + doc["본뜬"] |= {"확인": {"누가": {"id": 1}, "때": "t"}, "품셈": []} + born = forget.strip_sc(doc)["본뜬"] + assert born["단가기준"] == "우리" and "품셈" not in born and born["층"] == "실무자료" diff --git a/resources/tester/test_98_b08_pipe_summary.py b/resources/tester/test_98_b08_pipe_summary.py index ecc2964a4..71f7ce573 100644 --- a/resources/tester/test_98_b08_pipe_summary.py +++ b/resources/tester/test_98_b08_pipe_summary.py @@ -19,9 +19,9 @@ from pathlib import Path import pytest from B08_Quantity import B08_Quantity_Router_Summary as summary +from M01_MasterData.StructOptions import M01_SO_Definition as definition from M02_MasterTemplete import M02_Item_Snapshot as snapshots from M02_MasterTemplete import M02_Template_Layers as layers -from M02_MasterTemplete.StructOptions import M02_SO_Definition as definition COMBO = {"layer": "system", "owner": None, "key": "SS000011", "name": "횡단배수 배관"} OUT = {"layer": "company", "owner": "3", "key": "SC3-000001", "name": "기슭막이 메쌓기"} diff --git a/resources/tester/test_b06_box_thickness_registry.py b/resources/tester/test_b06_box_thickness_registry.py index 198b6682a..f1ea7f120 100644 --- a/resources/tester/test_b06_box_thickness_registry.py +++ b/resources/tester/test_b06_box_thickness_registry.py @@ -18,7 +18,9 @@ ROOT = Path(__file__).resolve().parents[2] def _box_options() -> dict[str, dict]: registry = json.loads( - (ROOT / "resources" / "master_template" / "구조물정의.json").read_text(encoding="utf-8") + (ROOT / "resources" / "master_data" / "구조물정의" / "구조물정의.json").read_text( + encoding="utf-8" + ) ) types = registry if isinstance(registry, list) else registry.get("types") or [] box = next(t for t in types if t["type_id"] == "box_culvert") diff --git a/resources/tester/test_b06_pipe_form_keys.py b/resources/tester/test_b06_pipe_form_keys.py index 059016c5a..943a2a733 100644 --- a/resources/tester/test_b06_pipe_form_keys.py +++ b/resources/tester/test_b06_pipe_form_keys.py @@ -32,7 +32,9 @@ QUANTITY_ONLY = { def _pipe_option_keys() -> list[str]: payload = json.loads( - (ROOT / "resources" / "master_template" / "구조물정의.json").read_text(encoding="utf-8") + (ROOT / "resources" / "master_data" / "구조물정의" / "구조물정의.json").read_text( + encoding="utf-8" + ) ) types = payload if isinstance(payload, list) else payload["types"] pipe = next(item for item in types if item["type_id"] == "pipe") diff --git a/resources/tester/test_m01_make.py b/resources/tester/test_m01_make.py index 640abf1dd..cd76d1713 100644 --- a/resources/tester/test_m01_make.py +++ b/resources/tester/test_m01_make.py @@ -114,7 +114,10 @@ def test_자체_로직_만들기_본뜨기_고치기_지우기(client: TestClien assert again["key"] != made["key"] # 원문번호가 같아도 키는 하나씩 copied = _post(client, "/api/m01/logic/copy", {"key": SAMPLE, "이름": "메쌓기 본뜸"}) - assert copied["key"] != SAMPLE and f"{SAMPLE} 를 본뜸" in copied["logic"]["비고"] + origin = _get(client, "/api/m01/logic", key=SAMPLE)["logic"] + assert ( + copied["key"] != SAMPLE and copied["logic"]["비고"] == origin["비고"] + ) # 본뜬 키 글 없음(요구 903) assert copied["logic"]["이름"] == "메쌓기 본뜸" and copied["logic"]["소유"] == "현장" assert copied["logic"]["상세구분"] == "13장 구조물" diff --git a/resources/tester/test_m02_empty_master.py b/resources/tester/test_m02_empty_master.py index 1113a07c6..2764f53e9 100644 --- a/resources/tester/test_m02_empty_master.py +++ b/resources/tester/test_m02_empty_master.py @@ -18,13 +18,13 @@ from fastapi.testclient import TestClient from common_util.common_util_auth import verify_session from config import config_system +from M01_MasterData.StructOptions import M01_SO_Router as so_router from M02_MasterTemplete import M02_Item_Copy as copies from M02_MasterTemplete import M02_MasterTemplete_Router_Items as items_router from M02_MasterTemplete import M02_MasterTemplete_Router_Layers as layers_router from M02_MasterTemplete import M02_MasterTemplete_Store as store from M02_MasterTemplete import M02_MasterTemplete_Tree as tree from M02_MasterTemplete import M02_Template_Layers as layers -from M02_MasterTemplete.StructOptions import M02_SO_Router as so_router from resources.tester.helper_m02_master_sample import copy_master_sample from resources.tester.test_item_copy_complete import ( # noqa: F401 — 복사본 world 고정물 FOLDER, @@ -93,7 +93,7 @@ def test_빈_마스터에서_첫_화면_나무_새_항목_지우기(empty): r["이름"] for r in client.get("/api/m02/layers/system/templates").json()["양식"] ] assert client.get("/api/m02/layers/system/structures/numbers").json() == {} - assert client.get("/api/m02/structure-options").status_code == 200 + assert client.get("/api/m01/structure-options").status_code == 200 assert client.get("/api/m02/items").json() == [] groups = client.get("/api/m02/items?all=1").json() # 고르기 모달 — 마스터 0 assert groups[0]["layer"] == "system" and groups[0]["items"] == [] diff --git a/resources/tester/test_m02_precombo_class.py b/resources/tester/test_m02_precombo_class.py index 9208ab004..24a261c5c 100644 --- a/resources/tester/test_m02_precombo_class.py +++ b/resources/tester/test_m02_precombo_class.py @@ -15,7 +15,9 @@ M02 = ROOT / "M02_MasterTemplete" def test_분류는_구조물군_종류_공통(): - defn = json.loads((ROOT / "resources/master_template/구조물정의.json").read_text("utf-8")) + defn = json.loads( + (ROOT / "resources/master_data/구조물정의/구조물정의.json").read_text("utf-8") + ) proc = subprocess.run( ["node", os.path.join(HERE, "helper_m02_precombo_scope.cjs")], input=json.dumps({"rows": [], "def": defn}, ensure_ascii=False), diff --git a/resources/tester/test_m02_so_def_model.py b/resources/tester/test_m02_so_def_model.py index 6670f0937..f08359439 100644 --- a/resources/tester/test_m02_so_def_model.py +++ b/resources/tester/test_m02_so_def_model.py @@ -1,4 +1,4 @@ -"""M02 구조물 정의 편집 화면 자료 손질(`M02_SO_Def_Model.ts` · PLAN 48-2) 단위검증. +"""M02 구조물 정의 편집 화면 자료 손질(`M01_SO_Def_Model.ts` · PLAN 48-2) 단위검증. 프론트에 JS 테스트 러너가 없어 Node 헬퍼(`helper_m02_so_def_model.cjs`)가 TS 를 트랜스파일해 돌리고 pytest 는 그 결과(JSON)를 판정. @@ -6,7 +6,7 @@ pytest 는 그 결과(JSON)를 판정. 못박는 것 - 배치 격자: 안 정한 옵션은 차례대로 · 정한 자리 먼저 · 너비 ≤ 칸 수 · 안 씀 빠짐 · 겹침 찾음. - 규칙: 없는 값 · 자기 자신 · 없는 하위 선택지 · 그러면 비었음 · 좁힌 선택지 밖 기본값은 틀린 줄 - (서버 `M02_SO_Definition._rule_errors` 와 같은 뜻) · 고르기 아닌 상위는 값 검사 안 함. + (서버 `M01_SO_Definition._rule_errors` 와 같은 뜻) · 고르기 아닌 상위는 값 검사 안 함. - 저장 전 검사: 깨끗한 정의 = 빈 목록 · 이름 겹침 · 배치 겹침 · 빈 선택지 = 까닭 글. - 선택지 이름 바꿈 · 뺌은 그 옵션 기본값 · 같은 종류 규칙도 같이 고침. - 순서: 구조물군 = 키 차례 · 종류 = 같은 군 안에서만. diff --git a/resources/tester/test_m02_so_def_spec.py b/resources/tester/test_m02_so_def_spec.py index e575dad1a..4cc0f91a0 100644 --- a/resources/tester/test_m02_so_def_spec.py +++ b/resources/tester/test_m02_so_def_spec.py @@ -1,4 +1,4 @@ -"""M02 구조물 명세 이름 고치기(`M02_SO_Def_Spec_Model.ts` · PLAN 52-11) 단위검증. +"""M02 구조물 명세 이름 고치기(`M01_SO_Def_Spec_Model.ts` · PLAN 52-11) 단위검증. Node 헬퍼(`helper_m02_so_def_spec.cjs`)가 TS 를 트랜스파일해 진짜 정의 사본(메모리)으로 돌리고 pytest 는 그 결과(JSON)를 판정. diff --git a/resources/tester/test_m02_structure_def_screen.py b/resources/tester/test_m02_structure_def_screen.py index 6caec3093..0d246abcd 100644 --- a/resources/tester/test_m02_structure_def_screen.py +++ b/resources/tester/test_m02_structure_def_screen.py @@ -20,9 +20,9 @@ from fastapi.testclient import TestClient from B05_Profile import B05_Profile_Structures_Schema as schema from common_util.common_util_auth import verify_session -from M02_MasterTemplete.StructOptions.M02_SO_Router import read_router +from M01_MasterData.StructOptions.M01_SO_Router import read_router -URL = "/api/m02/structure-definition" +URL = "/api/m01/structure-definition" ADMIN = {"role": "SYSTEM_ADMIN", "user_id": 1} USER = {"role": "USER", "user_id": 2, "company_id": 1} @@ -43,7 +43,7 @@ def _client(session: dict) -> TestClient: def _screen_edit(doc: dict) -> dict: - """화면이 하는 고침 한 벌 — `M02_SO_Def*.ts` 가 만드는 꼴 그대로.""" + """화면이 하는 고침 한 벌 — `M01_SO_Def*.ts` 가 만드는 꼴 그대로.""" pipe = next(t for t in doc["types"] if t["type_id"] == "pipe") pipe["name"] = "배수관(고침)" kind = next(o for o in pipe["options"] if o["key"] == "pipe_kind") diff --git a/resources/tester/test_m02_structure_definition.py b/resources/tester/test_m02_structure_definition.py index 675dd2af3..cde60f342 100644 --- a/resources/tester/test_m02_structure_definition.py +++ b/resources/tester/test_m02_structure_definition.py @@ -1,9 +1,9 @@ -"""M02 구조물 정의 한 벌(`/api/m02/structure-definition` · PLAN 48-1). +"""M02 구조물 정의 한 벌(`/api/m01/structure-definition` · PLAN 48-1). 못박는 것 - 판 1 = 옛 레지스트리 그대로 옮김(37종 · 옵션 235 · 키 그대로) · 검사 통과. - 읽기 = 로그인 누구나 · 쓰기 = 시스템 관리자만(403). - - 저장마다 판 +1(지금 판에서) · 앞 판은 `구조물정의_이력/판_N.json` · 낡은 판 409 · 틀린 정의 422(안 씀). + - 저장마다 판 +1(지금 판에서) · 앞 판은 `구조물정의/이력/판_N.json` · 낡은 판 409 · 틀린 정의 422(안 씀). - 검사 = 키 겹침 · 꼴 · 규칙 대상 있음 · 그룹 형상. - 저장한 정의를 `/structure-types` 가 바로 읽음 · 프로젝트 저장에 정의 판 · 없는 키 값 보존. """ @@ -22,10 +22,10 @@ from B05_Profile.B05_Profile_Structures_Repository import load_structures, save_ from B05_Profile.B05_Profile_Structures_Router import router as b05_router from B05_Profile.B05_Profile_Structures_Schema import StructureInstance, load_structure_types from common_util.common_util_auth import verify_session -from M02_MasterTemplete.StructOptions import M02_SO_Definition as definition -from M02_MasterTemplete.StructOptions.M02_SO_Router import read_router +from M01_MasterData.StructOptions import M01_SO_Definition as definition +from M01_MasterData.StructOptions.M01_SO_Router import read_router -URL = "/api/m02/structure-definition" +URL = "/api/m01/structure-definition" TYPES = "/api/projects/structure-types" ADMIN = {"role": "SYSTEM_ADMIN", "user_id": 1} USER = {"role": "USER", "user_id": 2, "company_id": 1} @@ -81,13 +81,13 @@ def test_저장마다_판_더하기_1_앞_판은_이력_structure_types_가_바 res = admin.put(URL, json={"판": v, "정의": doc}) assert res.status_code == 200, res.text assert res.json()["판"] == v + 1 - old = json.loads((copy.parent / "구조물정의_이력" / f"판_{v}.json").read_text("utf-8")) + old = json.loads((copy.parent / "이력" / f"판_{v}.json").read_text("utf-8")) assert old["판"] == v and old["types"][0]["name"] != "이름 바꿈" seen = {t["type_id"]: t for t in admin.get(TYPES).json()["types"]} assert seen[tid]["name"] == "이름 바꿈" and len(seen) == len(doc["types"]) assert admin.put(URL, json={"판": v, "정의": doc}).status_code == 409 # 낡은 판 assert admin.put(URL, json={"판": v + 1, "정의": res.json()}).json()["판"] == v + 2 - assert (copy.parent / "구조물정의_이력" / f"판_{v + 1}.json").is_file() + assert (copy.parent / "이력" / f"판_{v + 1}.json").is_file() def _rule(doc: dict) -> tuple[str, dict, dict]: @@ -143,7 +143,7 @@ def test_검사_키_겹침_꼴_규칙_대상_형상(copy) -> None: res = admin.put(URL, json={"판": v, "정의": doc}) assert res.status_code == 422, (i, res.text) assert json.loads(copy.read_text("utf-8"))["판"] == v # 거절되면 안 씀 - assert not (copy.parent / "구조물정의_이력").exists() + assert not (copy.parent / "이력").exists() shaped = bad(종류={tid: {"기준측점": False}}) shaped["그룹"]["pipe"][0]["형상"] = {"길이": {"받기": True, "뜻": "관 길이"}} assert admin.put(URL, json={"판": v, "정의": shaped}).status_code == 200 diff --git a/resources/tester/test_m02_structure_option_groups.py b/resources/tester/test_m02_structure_option_groups.py index ff0022b8f..9ebda935d 100644 --- a/resources/tester/test_m02_structure_option_groups.py +++ b/resources/tester/test_m02_structure_option_groups.py @@ -1,4 +1,4 @@ -"""M02 구조물 옵션 그룹(`/api/m02/structure-option-groups` · 정의 「그룹」 칸 · PLAN 46-2). +"""M02 구조물 옵션 그룹(`/api/m01/structure-option-groups` · 정의 「그룹」 칸 · PLAN 46-2). 못박는 것 - 「그룹」 이 `{}` 면 그룹 없음 · `/structure-types` 종류마다 `groups: []`. @@ -21,11 +21,11 @@ from fastapi.testclient import TestClient from B05_Profile import B05_Profile_Structures_Schema as schema from B05_Profile.B05_Profile_Structures_Router import router as b05_router from B05_Profile.B05_Profile_Structures_Schema import load_structure_types +from M01_MasterData.StructOptions.M01_SO_Router import router as m02_router from M02_MasterTemplete import M02_MasterTemplete_Store as store -from M02_MasterTemplete.StructOptions.M02_SO_Router import router as m02_router ROOT = Path(__file__).resolve().parents[2] -URL = "/api/m02/structure-option-groups" +URL = "/api/m01/structure-option-groups" TYPES = "/api/projects/structure-types" @@ -100,12 +100,3 @@ def test_틀린_그룹은_422_낡은_판은_409(client) -> None: assert client.put(URL, json={"판": "낡음", "그룹": {}}).status_code == 409 res = client.put(URL, json={"판": v1, "그룹": {}}) assert res.status_code == 200 and res.json()["그룹"] == {} - - -def test_좌측_정의_줄은_시스템_층에_늘_고쳐_씀은_시스템_관리자만() -> None: - """PLAN 48-2 — 다른 역할은 읽기만(화면이 칸을 잠금 · 서버 PUT 403).""" - side = (ROOT / "M02_MasterTemplete/M02_MasterTemplete_UI_Side.ts").read_text("utf-8") - assert "section(options.title" not in side # 716-3 — 옵션 줄은 M01 로 옮겨 좌측 칸에서 뺌 - folder = ROOT / "M02_MasterTemplete/StructOptions" - assert "buildGroupBlock(" in (folder / "M02_SO_Def.ts").read_text("utf-8") - assert "buildPlaceSelect(" in (folder / "M02_SO_Def_Options.ts").read_text("utf-8") diff --git a/resources/tester/test_m02_structure_options.py b/resources/tester/test_m02_structure_options.py index 39b7902b6..be88bed23 100644 --- a/resources/tester/test_m02_structure_options.py +++ b/resources/tester/test_m02_structure_options.py @@ -1,4 +1,4 @@ -"""M02 구조물 옵션 보이기(`/api/m02/structure-options` · 정의 「표시」 칸 · PLAN 48-1). +"""M02 구조물 옵션 보이기(`/api/m01/structure-options` · 정의 「표시」 칸 · PLAN 48-1). 못박는 것 - 「표시」 가 `{}` 면 `GET /api/projects/structure-types` 옵션이 모두 visible. @@ -18,11 +18,11 @@ from fastapi.testclient import TestClient from B05_Profile import B05_Profile_Structures_Schema as schema from B05_Profile.B05_Profile_Structures_Router import router as b05_router from B05_Profile.B05_Profile_Structures_Schema import load_structure_types +from M01_MasterData.StructOptions.M01_SO_Router import router as m02_router from M02_MasterTemplete import M02_MasterTemplete_Store as store -from M02_MasterTemplete.StructOptions.M02_SO_Router import router as m02_router ROOT = Path(__file__).resolve().parents[2] -URL = "/api/m02/structure-options" +URL = "/api/m01/structure-options" TYPES = "/api/projects/structure-types" @@ -107,22 +107,6 @@ def test_없는_종류_키_참거짓_아님은_422_낡은_판은_409(client) -> assert client.get(URL).json()["판"] == v1 -def test_좌측_줄은_구조물_집계_양식_아래_한_줄_같은_한_곳에서_지움() -> None: - side = (ROOT / "M02_MasterTemplete/M02_MasterTemplete_UI_Side.ts").read_text("utf-8") - # 716-3 — 옵션 줄은 M01 로 옮겨 좌측 칸에서 뺌(차례 = 일위대가 → 구조물 조합 → 도면 양식) - assert "options.title" not in side and "options.clear" not in side - order = side.split('className: "m02-side__lists ui-sidebar-panel",')[1].split("});")[0] - assert order.index("summary") < order.index("drawing,") - # 실무문서 칸은 걷음(732-1) - assert "practice" not in side - assert "matset" not in side - # 화면은 정의 한 벌로 읽고 씀(PLAN 48-2) · 보이기 체크는 정의 화면 옵션 줄 - api = (ROOT / "M02_MasterTemplete/StructOptions/M02_SO_Api.ts").read_text("utf-8") - assert 'call("/structure-definition")' in api - ui = (ROOT / "M02_MasterTemplete/StructOptions/M02_SO_Def_Options.ts").read_text("utf-8") - assert 'o.phase === "detail"' in ui # B06 전용 표시 - - def test_숨긴_옵션은_필수_아님_저장이_안_막힘(client, tmp_path, monkeypatch) -> None: """B05 필수(기본값 없음) 옵션 — 보이면 막고 숨기면 저장됨(다른 필수는 그대로).""" from B05_Profile import B05_Profile_Structures_Repository as repo diff --git a/resources/tester/test_m02_system_read.py b/resources/tester/test_m02_system_read.py index 5af19a703..1ba79c94c 100644 --- a/resources/tester/test_m02_system_read.py +++ b/resources/tester/test_m02_system_read.py @@ -14,11 +14,11 @@ from fastapi.testclient import TestClient from common_util.common_util_auth import verify_session from config import config_system +from M01_MasterData.StructOptions import M01_SO_Router as so_router from M02_MasterTemplete import M02_MasterTemplete_Router_Items as items_router from M02_MasterTemplete import M02_MasterTemplete_Router_Layers as layers_router from M02_MasterTemplete import M02_MasterTemplete_Store as store from M02_MasterTemplete import M02_Template_Layers as layers -from M02_MasterTemplete.StructOptions import M02_SO_Router as so_router from resources.tester.test_m02_structure import write_sample_table SYS = "/api/m02/layers/system" @@ -57,7 +57,7 @@ def test_세_계정_모두_마스터_층_읽기_200(world, role): f"{SYS}/templates/area/rv", f"{SYS}/structures/numbers", f"{SYS}/structure-combos", - f"{SYS}/structure-options", + "/api/m01/layers/system/structure-options", ): assert client.get(url).status_code == 200, url rows = client.get(f"{SYS}/templates").json()["양식"] diff --git a/resources/tester/test_structure_group_items.py b/resources/tester/test_structure_group_items.py index 2aca980a7..92d88e18b 100644 --- a/resources/tester/test_structure_group_items.py +++ b/resources/tester/test_structure_group_items.py @@ -18,10 +18,10 @@ import pytest from B05_Profile.B05_Profile_Structures_Schema import StructureInstance from common_util.common_util_drainage_pipes import parse_pipe_points from common_util.common_util_summary_item import parse_group_items +from M01_MasterData.StructOptions import M01_SO_Groups as groups from M02_MasterTemplete import M02_Item_Snapshot as snap from M02_MasterTemplete import M02_MasterTemplete_Store as store from M02_MasterTemplete import M02_Table_Fill as fill -from M02_MasterTemplete.StructOptions import M02_SO_Groups as groups from resources.tester.test_structures_summary_snapshot import ( # noqa: F401 — world 고정물 MS, PIPE, diff --git a/resources/tester/test_structures_summary_snapshot.py b/resources/tester/test_structures_summary_snapshot.py index ed8b3c2c4..783b454eb 100644 --- a/resources/tester/test_structures_summary_snapshot.py +++ b/resources/tester/test_structures_summary_snapshot.py @@ -21,10 +21,10 @@ from common_util import common_util_initial_snapshot as initial from common_util.common_util_drainage_pipes import PipePoint, parse_pipe_points from common_util.common_util_summary_item import parse_summary_item from config import config_system +from M01_MasterData.StructOptions import M01_SO_Groups as groups from M02_MasterTemplete import M02_Item_Snapshot as snap from M02_MasterTemplete import M02_Table_Fill as fill from M02_MasterTemplete import M02_Template_Layers as layers -from M02_MasterTemplete.StructOptions import M02_SO_Groups as groups from resources.tester.helper_m02_master_sample import SAMPLE REAL = SAMPLE # 시험 안 견본(PLAN 26-5a) — 실제 마스터 안 읽음 diff --git a/resources/tester/ui_checks/48-1_구조물정의_읽기.js b/resources/tester/ui_checks/48-1_구조물정의_읽기.js index b66fdfe35..9494ce4e2 100644 --- a/resources/tester/ui_checks/48-1_구조물정의_읽기.js +++ b/resources/tester/ui_checks/48-1_구조물정의_읽기.js @@ -1,4 +1,4 @@ -/* 48-1 — 구조물 정의 한 벌(resources/master_template/구조물정의.json)로 옮긴 뒤 화면 변화 0 +/* 48-1 — 구조물 정의 한 벌(resources/master_data/구조물정의/구조물정의.json)로 옮긴 뒤 화면 변화 0 * 시작 화면: M02 마스터 템플릿 · 마스터 층(#/m02-master-template?root=master) · 시스템 관리자 · 저장 안 함 * 부르는 법: orca eval --expression "$(cat 이 파일)" (async 식 · JSON 글을 돌려줌) * 기대 수치: