335 lines
7.5 KiB
TypeScript
335 lines
7.5 KiB
TypeScript
import { sql } from "drizzle-orm";
|
|
import { db } from "../db/db.controller.js";
|
|
import { type NewSetting, settings } from "../db/schema/settings.schema.js";
|
|
import { createLogger } from "../logger/logger.controller.js";
|
|
import { tryCatch } from "../utils/trycatch.utils.js";
|
|
|
|
const newSettings: NewSetting[] = [
|
|
// feature settings
|
|
{
|
|
name: "opendock_sync",
|
|
value: "0",
|
|
active: true,
|
|
description: "Dock Scheduling system",
|
|
moduleName: "opendock",
|
|
settingType: "feature",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "ocp",
|
|
value: "1",
|
|
active: true,
|
|
description: "One click print",
|
|
moduleName: "ocp",
|
|
settingType: "feature",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "ocme",
|
|
value: "0",
|
|
active: true,
|
|
description: "Dayton Agv system",
|
|
moduleName: "ocme",
|
|
settingType: "feature",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "demandManagement",
|
|
value: "1",
|
|
active: true,
|
|
description: "Fake EDI System",
|
|
moduleName: "demandManagement",
|
|
settingType: "feature",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "qualityRequest",
|
|
value: "0",
|
|
active: true,
|
|
description: "Quality System",
|
|
moduleName: "qualityRequest",
|
|
settingType: "feature",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "tms",
|
|
value: "0",
|
|
active: true,
|
|
description: "Transport system integration",
|
|
moduleName: "tms",
|
|
settingType: "feature",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
|
|
// standard settings
|
|
{
|
|
name: "prolinkCheck",
|
|
value: "1",
|
|
active: true,
|
|
description:
|
|
"Will prolink be considered to check if matches, mainly used in plants that do not fully utilize prolink + ocp",
|
|
moduleName: "ocp",
|
|
settingType: "standard",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "bookin",
|
|
value: "1",
|
|
active: true,
|
|
description: "Will we book in the labels after they are printed.",
|
|
moduleName: "ocp",
|
|
settingType: "standard",
|
|
roles: ["admin", "supervisor"],
|
|
seedVersion: 2,
|
|
},
|
|
{
|
|
name: "printDelay",
|
|
value: "90",
|
|
active: true,
|
|
description: "The default time between label printing",
|
|
moduleName: "ocp",
|
|
settingType: "standard",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "dualPrinting",
|
|
value: "0",
|
|
active: true,
|
|
description: "Are we producing on 2 lines that pack into the 1 packer",
|
|
moduleName: "ocp",
|
|
settingType: "standard",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "fifoCheck",
|
|
value: "45",
|
|
active: true,
|
|
description:
|
|
"This check is used to do a more near fifo check when pulling pallets for the agv's",
|
|
moduleName: "ocme",
|
|
settingType: "standard",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "dayCheck",
|
|
value: "3",
|
|
active: true,
|
|
description: "how many days +/- to check for shipments in alplaprod",
|
|
moduleName: "ocme",
|
|
settingType: "standard",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "maxLotsPerTruck",
|
|
value: "3",
|
|
active: true,
|
|
description:
|
|
"What is the maximum amount of lots that can be pulled for a truck this",
|
|
moduleName: "ocme",
|
|
settingType: "standard",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "monitorAddress",
|
|
value: "8",
|
|
active: true,
|
|
description:
|
|
"What address(2) are we monitoring for lot restrictions. multiple addresses can be used but should be separated by a comma ,",
|
|
moduleName: "ocme",
|
|
settingType: "standard",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "ocmeCycleCount",
|
|
value: "0",
|
|
active: true,
|
|
description:
|
|
"Are you enabling the system count page? meaning that we will allow a 'manual cycle count' vs full auto",
|
|
moduleName: "ocme",
|
|
settingType: "standard",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "inhouseDelivery",
|
|
value: "0",
|
|
active: true,
|
|
description:
|
|
"This is for in-house plants that deliver direct to the customer, note if book-in is off this will be ignored ",
|
|
moduleName: "ocp",
|
|
settingType: "standard",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "dycoConnect",
|
|
value: "0",
|
|
active: true,
|
|
description: "Connection to the dyco in dayton for the labeling process",
|
|
moduleName: "ocp",
|
|
settingType: "standard",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "dycoPrint",
|
|
value: "0",
|
|
active: true,
|
|
description:
|
|
"This tells us we want to use the dyco system to print the labels",
|
|
moduleName: "ocp",
|
|
settingType: "standard",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "strapperCheck",
|
|
value: "0",
|
|
active: true,
|
|
description:
|
|
"Strapper alarm check this is more used in tandem with dycoPrint setting",
|
|
moduleName: "ocp",
|
|
settingType: "standard",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "rfid_ocp",
|
|
value: "0",
|
|
active: true,
|
|
description:
|
|
"Enable the rfid pallet mgt system this replaces dycoPrint but can be overridden by dycoPrint",
|
|
moduleName: "ocp",
|
|
settingType: "standard",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "ocpCycleDelay",
|
|
value: "10",
|
|
active: true,
|
|
description:
|
|
"How long is the delay to fire off the printer check status, Defaulting to 10 seconds",
|
|
moduleName: "ocp",
|
|
settingType: "standard",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "pNgAddress",
|
|
value: "139",
|
|
active: true,
|
|
description:
|
|
"This is the P&G address that is used when uploading the new forecast from P&G",
|
|
moduleName: "demandManagement",
|
|
settingType: "standard",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "zechetti_1",
|
|
value: "0",
|
|
active: true,
|
|
description:
|
|
"Active the Zechetti 1 process, to print from and no longer utilize the pc",
|
|
moduleName: "ocp",
|
|
settingType: "standard",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "zechetti_2",
|
|
value: "0",
|
|
active: true,
|
|
description:
|
|
"Active the Zechetti 2 process, to print from and no longer utilize the pc",
|
|
moduleName: "ocp",
|
|
settingType: "standard",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "checkColor",
|
|
value: "0",
|
|
active: true,
|
|
description:
|
|
"During the material check are we going to check the color has enough provided to create the next pallet",
|
|
moduleName: "ocp",
|
|
settingType: "standard",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "checkPKG",
|
|
value: "0",
|
|
active: true,
|
|
description:
|
|
"During the material check are we going to check the packaging has enough provided to create the next pallet",
|
|
moduleName: "ocp",
|
|
settingType: "standard",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
{
|
|
name: "lotPrintDelay",
|
|
value: "0",
|
|
active: true,
|
|
description:
|
|
"Override ride the printer printer delay setting, by default if this is on all printers are controlled by this.",
|
|
moduleName: "ocp",
|
|
settingType: "standard",
|
|
roles: ["admin"],
|
|
seedVersion: 1,
|
|
},
|
|
];
|
|
|
|
export const baseSettingValidationCheck = async () => {
|
|
const log = createLogger({ module: "system", subModule: "settings" });
|
|
const { data, error } = await tryCatch(
|
|
db
|
|
.insert(settings)
|
|
.values(newSettings)
|
|
.onConflictDoUpdate({
|
|
target: settings.name,
|
|
set: {
|
|
roles: sql`excluded.roles`,
|
|
description: sql`excluded.description`,
|
|
moduleName: sql`excluded."moduleName"`,
|
|
settingType: sql`excluded."settingType"`,
|
|
seedVersion: sql`excluded.seed_version`,
|
|
upd_user: "LST_System",
|
|
upd_date: sql`now()`,
|
|
},
|
|
where: sql`
|
|
settings.seed_version IS NULL
|
|
OR settings.seed_version < excluded.seed_version
|
|
`,
|
|
})
|
|
.returning(),
|
|
);
|
|
|
|
if (error) {
|
|
log.error(
|
|
{ error: error },
|
|
"There was an error when adding or updating the settings.",
|
|
);
|
|
}
|
|
|
|
if (data) {
|
|
log.info({}, "All Settings were added/updated");
|
|
}
|
|
};
|