215 lines
5.8 KiB
TypeScript
215 lines
5.8 KiB
TypeScript
/**
|
|
* check if the modules are in and if not add them.
|
|
* this will only run on a server start up
|
|
*/
|
|
|
|
import { db } from "../../../../database/dbclient.js";
|
|
import { settings } from "../../../../database/schema/settings.js";
|
|
|
|
import { createLog } from "../../logger/logger.js";
|
|
// "view", "technician", "supervisor","manager", "admin", "systemAdmin"
|
|
const newSettings = [
|
|
{
|
|
name: "server",
|
|
value: "localhost",
|
|
description: "Where the app runs at",
|
|
moduleName: "server",
|
|
},
|
|
{
|
|
name: "serverPort",
|
|
value: "4400",
|
|
description: "What are we listening on",
|
|
moduleName: "server",
|
|
},
|
|
{
|
|
name: "dbUser",
|
|
value: "alplaprod",
|
|
description: "What is the db username",
|
|
moduleName: "server",
|
|
},
|
|
{
|
|
name: "dbPass",
|
|
value: "b2JlbGl4",
|
|
description: "What is the db password",
|
|
moduleName: "server",
|
|
},
|
|
{
|
|
name: "tcpPort",
|
|
value: "2222",
|
|
description:
|
|
"TCP port for printers to connect send data and the zedra cameras",
|
|
moduleName: "server",
|
|
},
|
|
{
|
|
name: "prolinkCheck",
|
|
value: "1",
|
|
description:
|
|
"Will prolink be considered to check if matches, maninly used in plants that do not fully utilize prolink + ocp",
|
|
moduleName: "production",
|
|
},
|
|
{
|
|
name: "bookin",
|
|
value: "1",
|
|
description: "do we want to book in after a label is printed",
|
|
moduleName: "ocp",
|
|
},
|
|
{
|
|
name: "dbServer",
|
|
value: "usmcd1vms036",
|
|
description: "What server is the prod db on?",
|
|
moduleName: "server",
|
|
},
|
|
{
|
|
name: "printDelay",
|
|
value: "90",
|
|
description: "How long in seconds between prints",
|
|
moduleName: "ocp",
|
|
},
|
|
{
|
|
name: "plantToken",
|
|
value: "test3",
|
|
description: "What is the plant token",
|
|
moduleName: "server",
|
|
},
|
|
{
|
|
name: "dualPrinting",
|
|
value: "0",
|
|
description: "Dose the plant have 2 machines that go to 1?",
|
|
moduleName: "ocp",
|
|
},
|
|
{
|
|
name: "ocmeService",
|
|
value: "0",
|
|
description:
|
|
"Is the ocme service enabled. this is gernerally only for Dayton.",
|
|
moduleName: "ocme",
|
|
},
|
|
{
|
|
name: "fifoCheck",
|
|
value: "45",
|
|
description:
|
|
"How far back do we want to check for fifo default 45, putting 0 will ignore.",
|
|
moduleName: "ocme",
|
|
},
|
|
{
|
|
name: "dayCheck",
|
|
value: "3",
|
|
description: "how many days +/- to check for shipments in alplaprod",
|
|
moduleName: "ocme",
|
|
},
|
|
{
|
|
name: "maxLotPerTruck",
|
|
value: "3",
|
|
description: "How mant lots can we have per truck?",
|
|
moduleName: "ocme",
|
|
},
|
|
{
|
|
name: "monitorAddress",
|
|
value: "8",
|
|
description:
|
|
"What address is monitored to be limited to the amount of lots that can be added to a truck.",
|
|
moduleName: "ocme",
|
|
},
|
|
{
|
|
name: "ocmeCycleCount",
|
|
value: "1",
|
|
description: "Are we allowing ocme cycle counts?",
|
|
roles: "admin",
|
|
module: "ocme",
|
|
},
|
|
{
|
|
name: "devDir",
|
|
value: "C:\\Users\\matthes01\\Documents\\lstv2",
|
|
description:
|
|
"This is the dev dir and strictly only for updating the servers.",
|
|
moduleName: "server",
|
|
},
|
|
{
|
|
name: "demandMGTActivated",
|
|
value: "0",
|
|
description: "Do we allow for new fake edi?",
|
|
roles: "admin",
|
|
module: "logistics",
|
|
},
|
|
{
|
|
name: "qualityRequest",
|
|
value: "0",
|
|
description: "quality request module?",
|
|
roles: "admin",
|
|
module: "logistics",
|
|
},
|
|
{
|
|
name: "ocpLogsCheck",
|
|
value: "4",
|
|
description:
|
|
"How long do we want to allow logs to show that have not been cleared?",
|
|
roles: "admin",
|
|
module: "ocp",
|
|
},
|
|
{
|
|
name: "inhouseDelivery",
|
|
value: "0",
|
|
description: "Are we doing auto inhouse delivery?",
|
|
roles: "admin",
|
|
module: "ocp",
|
|
},
|
|
// dyco settings
|
|
{
|
|
name: "dycoConnect",
|
|
value: "0",
|
|
description: "Are we running the dyco system?",
|
|
roles: "admin",
|
|
module: "ocp",
|
|
},
|
|
{
|
|
name: "dycoPrint",
|
|
value: "0",
|
|
description: "Are we using the dyco to get the labels or the rfid?",
|
|
roles: "admin",
|
|
module: "ocp",
|
|
},
|
|
{
|
|
name: "strapperCheck",
|
|
value: "1",
|
|
description: "Are we monitoring the strapper for faults?",
|
|
roles: "admin",
|
|
module: "ocp",
|
|
},
|
|
];
|
|
export const areSettingsIn = async () => {
|
|
// get the roles
|
|
try {
|
|
const settingsCheck = await db.select().from(settings);
|
|
|
|
if (settingsCheck.length !== newSettings.length) {
|
|
try {
|
|
const newRole = await db
|
|
.insert(settings)
|
|
.values(newSettings)
|
|
.onConflictDoNothing() // this will only update the ones that are new :D
|
|
.returning({ name: settings.name });
|
|
createLog(
|
|
"info",
|
|
"lst",
|
|
"server",
|
|
"Settingss were just added due to missing them on server startup"
|
|
);
|
|
} catch (error) {
|
|
createLog(
|
|
"error",
|
|
"lst",
|
|
"server",
|
|
"There was an error adding new roles to the db"
|
|
);
|
|
}
|
|
}
|
|
} catch (error) {
|
|
createLog(
|
|
"error",
|
|
"lst",
|
|
"server",
|
|
"There was an error getting or adding new Settingss"
|
|
);
|
|
}
|
|
};
|