- 기계 자료: M01 기계 221 대 값 칸 `작업량` = [{식 · 단위 · 변수(규격에서 정해지는 칸)}] (건설 공통 8-2 장 작업량 틀 · 빌더 build_기계_작업량_846_1.py · --check 0 · 다른 칸 · 시간당 비용 그대로)
- 계산기 짝 master_doc_work.py ↔ common_util_formula_doc_work.ts: 기계 줄 수량에서 시간당 작업량 자리 읽기(일당 = 시공량 ÷ (8 × 대수) · 식 = …/hr 나눔 변수) · 셈 답 줄 칸 `작업량` · 덮음 `작업량: {방식 시간당, 식, 변수?}` = 그 자리를 1 ÷ Q(기계 작업량 식)로 바꿔 셈 · 부착 기계(브레이커 · 집게) 줄 따로 · 식 없는 기계 · 단위 안 맞음 = 시간당 거절
- 덮음 짝(master_doc_cover · common_util_formula_doc_cover): 작업량은 기계 식 문서에 안 얹음 · prune 이 작업량 정리(일당 · 기본과 같은 변수 = 지움) · 몸 검사 · CoverEntry · CoverBase 꼴
- 저장 길: 사본 부름 묶음에 시간당 식 키(M02_Doc_Copy.calls) · 내 기계 clean 이 작업량 받음 · 연결 읽기 작업량 칸(master_doc_link)
- 기계 보기: 작업량 칸 = 제어 구역 몫(ownedCols — 바탕 칸 숫자 입력으로 안 그림 · 그리기는 846-2)
- 지킴: 1,520 문서 · 기계 655 대 · 견본 SK 금액 전후 다름 0 · 빌더 802-2 --check 1,520 같음(옵션 표본 18,873) · 둘 다 가능 줄 전수 시간당 셈 멈춤 0
- 시험: test_846_1_machine_work(일당 · 시간당 손셈 · E · K 덮음 · 정리 · 거절 · 부착 · 거울 · 저장 길 · 내 기계) 신설 · test_816_1 기대값 고침(까닭 — 4륜 덤프 1톤 기계 줄에 작업량 칸이 생겨 값 칸 비교에서 뺌)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
62 lines
2.8 KiB
JavaScript
62 lines
2.8 KiB
JavaScript
/* 846-1 기계 줄 시간당 작업량 거울 헬퍼 — common_util_formula_doc_work.ts · calc 를 그 자리에서 트랜스파일해 Node 로 돌림.
|
|
* stdin = {문서들: {키: 문서}, 대상: [{문서, 덮음?}], 기록: {열쇠: {값 | 빈 | 끊김}}, 글: [{문서, 수량}], 정리: [{덮음, 기본}]}
|
|
* stdout = {답: [calcDoc 답], 글: [{자리: [{꼴, 율, 단위}], 바꿈}], 정리: [pruneWork], 부름: [coverCalls]}
|
|
* 기록 열쇠 = 갈래 + "|" + 값 글(helper_836_1 과 같은 꼴). */
|
|
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 root = path.join(__dirname, "..", "..", "common_util");
|
|
const calc = load(path.join(root, "common_util_formula_doc_calc.ts"));
|
|
const work = load(path.join(root, "common_util_formula_doc_work.ts"));
|
|
|
|
function canon(v) {
|
|
if (typeof v === "number") return calc.plainText(v);
|
|
if (Array.isArray(v)) return v.map(canon);
|
|
if (v && typeof v === "object") {
|
|
const out = {};
|
|
for (const k of Object.keys(v).sort()) out[k] = canon(v[k]);
|
|
return out;
|
|
}
|
|
return v;
|
|
}
|
|
const input = JSON.parse(fs.readFileSync(0, "utf8"));
|
|
const record = input.기록 || {};
|
|
function answer(kind, p) {
|
|
const k = `${kind}|${JSON.stringify(canon(p))}`;
|
|
if (!(k in record)) throw new calc.Broken(`기록 없음 ${k}`);
|
|
const got = record[k];
|
|
if ("빈" in got) throw new calc.Gap(got.빈);
|
|
if ("끊김" in got) throw new calc.Broken(got.끊김);
|
|
return got.값;
|
|
}
|
|
const links = {
|
|
element: (p) => answer("요소", p),
|
|
table: (p) => answer("표", p),
|
|
doc: (key) => (input.문서들 || {})[key] || null,
|
|
};
|
|
const out = { 답: [], 글: [], 정리: [], 부름: [] };
|
|
for (const one of input.대상 || [])
|
|
out.답.push(calc.calcDoc(one.덮음 ? { ...one.문서, 기계덮음: one.덮음 } : one.문서, links));
|
|
for (const one of input.글 || [])
|
|
out.글.push({
|
|
자리: work.sites(one.문서, one.수량).map((s) => ({ 꼴: s.꼴, 율: s.율, 단위: s.단위 })),
|
|
바꿈: work.swap(one.문서, one.수량),
|
|
});
|
|
for (const one of input.정리 || []) out.정리.push(work.pruneWork(one.덮음, one.기본));
|
|
for (const one of input.대상 || []) out.부름.push(work.coverCalls({ 기계덮음: one.덮음 }));
|
|
process.stdout.write(JSON.stringify(out));
|