Generate PPC for CCC.

This commit is contained in:
Patrick Fic
2025-04-03 13:42:42 -07:00
parent b60d9b0f41
commit 85fcecf856
5 changed files with 233 additions and 20 deletions

View File

@@ -0,0 +1,191 @@
import { DBFFile, FieldDescriptor } from "dbffile";
import {
deleteEmsFileIfExists,
generatePpcFilePath,
} from "./ppc-generate-file";
import { PpcJob } from "./ppc-handler";
const GenerateEnvFile = async (job: PpcJob): Promise<boolean> => {
const records = [
{
EST_SYSTEM: "C",
RO_ID: job.ro_number,
ESTFILE_ID: job.ciecaid,
STATUS: false,
INCL_ADMIN: true,
INCL_VEH: true,
INCL_EST: true,
INCL_PROFL: true,
INCL_TOTAL: true,
INCL_VENDR: false,
},
];
//Check if it already exists, delete it if so.
await deleteEmsFileIfExists(generatePpcFilePath(`${job.ciecaid}.ENV`));
const dbf = await DBFFile.create(
generatePpcFilePath(`${job.ciecaid}.ENV`),
envFieldLineDescriptors,
);
await dbf.appendRecords(records);
console.log(`${records.length} LIN file records added.`);
return true;
};
export default GenerateEnvFile;
//Taken from a set of CCC ems files.
const envFieldLineDescriptors: FieldDescriptor[] = [
{
name: "EST_SYSTEM",
type: "C",
size: 1,
decimalPlaces: 0,
},
{
name: "SW_VERSION",
type: "C",
size: 10,
decimalPlaces: 0,
},
{
name: "DB_VERSION",
type: "C",
size: 12,
decimalPlaces: 0,
},
{
name: "DB_DATE",
type: "D",
size: 8,
decimalPlaces: 0,
},
{
name: "UNQFILE_ID",
type: "C",
size: 8,
decimalPlaces: 0,
},
{
name: "RO_ID",
type: "C",
size: 8,
decimalPlaces: 0,
},
{
name: "ESTFILE_ID",
type: "C",
size: 38,
decimalPlaces: 0,
},
{
name: "SUPP_NO",
type: "C",
size: 3,
decimalPlaces: 0,
},
{
name: "EST_CTRY",
type: "C",
size: 3,
decimalPlaces: 0,
},
{
name: "TOP_SECRET",
type: "C",
size: 80,
decimalPlaces: 0,
},
{
name: "H_TRANS_ID",
type: "C",
size: 9,
decimalPlaces: 0,
},
{
name: "H_CTRL_NO",
type: "C",
size: 9,
decimalPlaces: 0,
},
{
name: "TRANS_TYPE",
type: "C",
size: 1,
decimalPlaces: 0,
},
{
name: "STATUS",
type: "L",
size: 1,
decimalPlaces: 0,
},
{
name: "CREATE_DT",
type: "D",
size: 8,
decimalPlaces: 0,
},
{
name: "CREATE_TM",
type: "C",
size: 6,
decimalPlaces: 0,
},
{
name: "TRANSMT_DT",
type: "D",
size: 8,
decimalPlaces: 0,
},
{
name: "TRANSMT_TM",
type: "C",
size: 6,
decimalPlaces: 0,
},
{
name: "INCL_ADMIN",
type: "L",
size: 1,
decimalPlaces: 0,
},
{
name: "INCL_VEH",
type: "L",
size: 1,
decimalPlaces: 0,
},
{
name: "INCL_EST",
type: "L",
size: 1,
decimalPlaces: 0,
},
{
name: "INCL_PROFL",
type: "L",
size: 1,
decimalPlaces: 0,
},
{
name: "INCL_TOTAL",
type: "L",
size: 1,
decimalPlaces: 0,
},
{
name: "INCL_VENDR",
type: "L",
size: 1,
decimalPlaces: 0,
},
{
name: "EMS_VER",
type: "C",
size: 5,
decimalPlaces: 0,
},
];