Files
Aislo/resources/tester/helper_stmate_edit_bid.cjs
T

27 lines
1.1 KiB
JavaScript

// STMATE 재현 앱 산근 편집기 낙찰율 입력(scr_edit_san.setBidRate) → 계산완료(연쇄 재계산) — stdin {load, codes, rate}
globalThis.window = globalThis;
require("../../tools/stmate-test/calc.js");
require("../../tools/stmate-test/smt_eval.js");
require("../../tools/stmate-test/smt_engine.js");
require("../../tools/stmate-test/view_prj_boq.js");
const San = require("../../tools/stmate-test/scr_edit_san.js");
let buf = "";
process.stdin.setEncoding("utf8");
process.stdin.on("data", (d) => (buf += d));
process.stdin.on("end", () => {
const { load, codes, rate } = JSON.parse(buf);
const by = new Map(load.costn_rows.map((r) => [String(r.CODE).trim(), r]));
codes.forEach((c) => San.setBidRate(by.get(c), rate, true));
window.STMATE_ENGINE.cascadeRecalculateAll({ dbfData: load, state: load.sim_state, uiState: {} });
const cols = ["TAMT1", "MAMT1", "LAMT1", "SAMT1", "TAMT2", "MAMT2", "LAMT2", "SAMT2"];
const out = {};
codes.forEach(
(c) =>
(out[c] = Object.assign(
{ UC: by.get(c).UC },
...cols.map((k) => ({ [k]: Number(by.get(c)[k]) })),
)),
);
process.stdout.write(JSON.stringify(out));
});