Add remaining EMS file parsing.

This commit is contained in:
Patrick Fic
2025-03-19 14:52:29 -07:00
parent e67309ed4d
commit 2e5fe7c99d
8 changed files with 281 additions and 76 deletions

View File

@@ -15,6 +15,8 @@ import DecodePfm from "./decode-pfm";
import { DecodedPfm } from "./decode-pfm.interface";
import DecodePfo from "./decode-pfo";
import { DecodedPfo } from "./decode-pfo.interface";
import DecodePfp from "./decode-pfp";
import { DecodedPfp } from "./decode-pfp.interface";
import DecodePft from "./decode-pft";
import { DecodedPft } from "./decode-pft.interface";
import DecodeStl from "./decode-stl";
@@ -23,6 +25,8 @@ import DecodeTtl from "./decode-ttl";
import { DecodedTtl } from "./decode-ttl.interface";
import DecodeVeh from "./decode-veh";
import { DecodedVeh } from "./decode-veh.interface";
import { DecodedEnv } from "./decode-env.interface";
import DecodeEnv from "./decode-env";
async function ImportJob(filepath: string): Promise<void> {
const parsedFilePath = path.parse(filepath);
@@ -35,6 +39,7 @@ async function ImportJob(filepath: string): Promise<void> {
try {
//The below all end up returning parts of the job object.
//Some of them return additional info - e.g. owner or vehicle record data at both the job and corresponding table level.
const env: DecodedEnv = await DecodeEnv(extensionlessFilePath);
const ad1: DecodedAd1 = await DecodeAD1(extensionlessFilePath);
const ad2: DecodedAD2 = await DecodeAD2(extensionlessFilePath);
const veh: DecodedVeh = await DecodeVeh(extensionlessFilePath);
@@ -46,19 +51,22 @@ async function ImportJob(filepath: string): Promise<void> {
const pfo: DecodedPfo = await DecodePfo(extensionlessFilePath); // TODO: This will be the `cieca_pfo` object
const stl: DecodedStl[] = await DecodeStl(extensionlessFilePath); // TODO: This will be the `cieca_stl` object
const ttl: DecodedTtl = await DecodeTtl(extensionlessFilePath);
const pfp: DecodedPfp = await DecodePfp(extensionlessFilePath);
log.debug("EMS Object", {
ad1,
ad2,
veh,
lin,
pfh,
pfl,
pft,
pfm,
pfo,
stl,
ttl,
log.debug("Job Object", {
...env,
...ad1,
...ad2,
...veh,
joblines: { data: lin },
...pfh,
cieca_pfl: pfl,
cieca_pft: pft,
materials: pfm,
cieca_pfo: pfo,
...stl,
...ttl,
parts_tax_rates: pfp,
});
} catch (error) {
log.error("Error encountered while decoding job. ", errorTypeCheck(error));