Files
Aislo/tools/est-test/wonga-formats.cjs
T
eomsangdonandClaude Opus 5.5 4cf7ebd783 feat(est-test): 작업모드 표준내역서·표준설계변경, 설치 원가계산서 양식목록, 최근 계약심사목록
- 작업모드 값(CurrentWorkMode) ESTX 읽기·쓰기
- 일반↔표준 묶음 바꿀 때 원가계산서 보관·꺼내기, 없으면 설치 양식(일반·표준 각 30종)에서 고르기
- 저장한 작업 중 계약심사 작업 목록

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 19:30:56 +09:00

37 lines
1.7 KiB
JavaScript

// 원본 설치 원가계산서 양식목록 — 일반 WongaFileList(양식 번호 7) · 표준 SWongaFileList(0x16) (System\MainSys, DBISAM 표).
// 행마다 이름과 원가 표 한 벌(BLOB = TPF0 메모리 표). 작업모드를 일반 ↔ 표준으로 바꿀 때와 양식목록에서 고를 때 쓴다.
const fs = require("node:fs");
const path = require("node:path");
const { table, memoryRows } = require("./import-estx.cjs");
const root = () => process.env.EST_INSTALL || "C:/Dasansoft/Est Plus 2";
const cache = new Map();
function load(standard) {
const name = standard ? "SWongaFileList" : "WongaFileList";
if (cache.has(name)) return cache.get(name);
const dir = path.join(root(), "System", "MainSys"),
dat = path.join(dir, `${name}.dat`);
if (!fs.existsSync(dat)) throw Error(`설치 원가계산서 양식(${name})을 찾을 수 없습니다.`);
const parsed = table(fs.readFileSync(dat), fs.readFileSync(path.join(dir, `${name}.blb`)), []);
const list = (parsed.rows || parsed)
.filter((r) => r.BLOB?.binary)
.sort((a, b) => (Number(a.Index) || 0) - (Number(b.Index) || 0))
.map((r) => ({
index: Number(r.Index) || 0,
name: String(r.Name ?? ""),
rows: memoryRows(Buffer.from(r.BLOB.binary, "base64")).map(({ Cost, ...rest }) => rest),
}));
cache.set(name, list);
return list;
}
// 목록(이름만) 또는 한 양식(행 포함)
function get(standard, index) {
const list = load(standard);
if (index == null) return list.map(({ index: i, name }) => ({ index: i, name }));
const found = list.find((f) => f.index === Number(index));
if (!found) throw Error("원가계산서 양식이 없습니다.");
return found;
}
module.exports = { get };