From 8129dbb7871e973bb05b43957f91346a71ade618 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 29 Jul 2025 20:51:27 -0500 Subject: [PATCH 001/166] ci(release): bump build number to 531 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c77109d..e46a025 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 530, + "build": 531, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 3e51ebc18be0ce1d18a87d193b1b710c1cb7a232 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 29 Jul 2025 21:11:53 -0500 Subject: [PATCH 002/166] ci(release): bump build number to 532 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e46a025..3c2212c 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 531, + "build": 532, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 998e84f5648148c9a94df7177a3d311e16bf4614 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 30 Jul 2025 14:34:15 -0500 Subject: [PATCH 003/166] feat(migration start): this starts the migration of all settings to look at the go backend vs this --- .../server/controller/settings/getSettings.ts | 61 +++++++++++++++---- 1 file changed, 50 insertions(+), 11 deletions(-) diff --git a/server/services/server/controller/settings/getSettings.ts b/server/services/server/controller/settings/getSettings.ts index 7009827..fe2efb9 100644 --- a/server/services/server/controller/settings/getSettings.ts +++ b/server/services/server/controller/settings/getSettings.ts @@ -1,17 +1,56 @@ -import {db} from "../../../../../database/dbclient.js"; -import {settings} from "../../../../../database/schema/settings.js"; -import {createLog} from "../../../logger/logger.js"; +import axios from "axios"; +import { db } from "../../../../../database/dbclient.js"; +import { settings } from "../../../../../database/schema/settings.js"; +import { tryCatch } from "../../../../globalUtils/tryCatch.js"; +import { createLog } from "../../../logger/logger.js"; +import type { Settings } from "../../../../types/settings.js"; +export let serverSettings: Settings[]; export const getSettings = async () => { - createLog("info", "lst", "server", "Settings are being grabbed"); - let serverSettings; + const settingsType = process.env.LST_USE_GO; + createLog( + "info", + "lst", + "server", + `Settings are being grabbed from: ${ + settingsType === "true" ? "Go backend" : "Localbackend" + }` + ); - try { - serverSettings = await db.select().from(settings); - //.where(sql`${userRole} = ANY(roles)`); - } catch (error) { - createLog("error", "lst", "server", "There was an error getting the settings"); - throw new Error("There was an error getting the settings"); + const baseUrl = process.env.LST_BASE_URL; + + if (settingsType === "true") { + const { data, error } = (await tryCatch( + axios.get(`${baseUrl}/api/v1/settings`) + )) as any; + + if (error) { + createLog( + "error", + "lst", + "server", + "There was an error getting the settings" + ); + throw new Error("There was an error getting the settings"); + } + + serverSettings = data.data.data; } + + if (settingsType !== "true") { + try { + serverSettings = (await db.select().from(settings)) as any; + //.where(sql`${userRole} = ANY(roles)`); + } catch (error) { + createLog( + "error", + "lst", + "server", + "There was an error getting the settings" + ); + throw new Error("There was an error getting the settings"); + } + } + return serverSettings; }; -- 2.49.1 From f574645b44c51b18cea55b0c4c4020a64a3a2e0a Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 30 Jul 2025 19:37:13 -0500 Subject: [PATCH 004/166] ci(release): bump build number to 533 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3c2212c..ddb5458 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 532, + "build": 533, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 0d17fef1a1c75dd0f27988fd2e3527b508b915cb Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 31 Jul 2025 11:54:40 -0500 Subject: [PATCH 005/166] fix(mainmaterial check): if the machine dose not require mm to be staged properly ignore --- server/services/ocp/controller/materials/mainMaterial.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/services/ocp/controller/materials/mainMaterial.ts b/server/services/ocp/controller/materials/mainMaterial.ts index ca44bc6..cbe69b6 100644 --- a/server/services/ocp/controller/materials/mainMaterial.ts +++ b/server/services/ocp/controller/materials/mainMaterial.ts @@ -19,7 +19,7 @@ export const isMainMatStaged = async (lot: any) => { (m: any) => m.HumanReadableId === lot.machineID ); // we have a check on ksc side to ignore the tetra machine for now as its not updating in 2.0 - if (machine.StagingMainMaterialMandatory === 0) { + if (!machine[0].StagingMainMaterialMandatory) { createLog( "info", "mainMaterial", -- 2.49.1 From 1f447503467e9b66f64ef80170702824a44cfc6a Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 31 Jul 2025 11:58:56 -0500 Subject: [PATCH 006/166] ci(release): bump build number to 534 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ddb5458..469de2f 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 533, + "build": 534, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 1f93eca5613c215eebd1b807f58bd474c1bb24b2 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 4 Aug 2025 06:54:23 -0500 Subject: [PATCH 007/166] ci(release): bump build number to 535 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 469de2f..1af3e2d 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 534, + "build": 535, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 74ac2864c96647c00c7f615e2b142ff364310833 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 4 Aug 2025 07:56:50 -0500 Subject: [PATCH 008/166] ci(release): bump build number to 536 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1af3e2d..eccce58 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 535, + "build": 536, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 98a5ca7bb81d9ef0e7c05c739b3cd839b1606d4f Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 4 Aug 2025 09:48:20 -0500 Subject: [PATCH 009/166] ci(release): bump build number to 537 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index eccce58..bdea083 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 536, + "build": 537, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From c7bb12822b13c0c1c929d2c8a9ab150cd0feeff2 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 4 Aug 2025 12:44:03 -0500 Subject: [PATCH 010/166] fix(dyco): correction to disable the camera if ocme is off --- .../specialProcesses/dyco/plcTags/palletSendTag.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/services/ocp/controller/specialProcesses/dyco/plcTags/palletSendTag.ts b/server/services/ocp/controller/specialProcesses/dyco/plcTags/palletSendTag.ts index 0ce64a3..5b72dcb 100644 --- a/server/services/ocp/controller/specialProcesses/dyco/plcTags/palletSendTag.ts +++ b/server/services/ocp/controller/specialProcesses/dyco/plcTags/palletSendTag.ts @@ -1,6 +1,7 @@ import { createLog } from "../../../../../logger/logger.js"; import { pickedup } from "../../../../../ocme/controller/pickedup.js"; import { triggerScanner } from "../../../../../ocme/controller/triggerCamera.js"; +import { serverSettings } from "../../../../../server/controller/settings/getSettings.js"; let lastProcessedTimestamp = 0; @@ -10,13 +11,16 @@ export const palletSendTag = async (tagData: any) => { * We will only trigger the camera and removal of pending tags */ + const ocmeActive = serverSettings.filter((n) => n.name === "ocmeService"); + const tagTime = new Date(tagData.state.timestamp).getTime(); // Only process if this is a new timestamp within the last 5 seconds if ( tagTime !== lastProcessedTimestamp && Date.now() - tagTime <= 5000 && - tagData.value + tagData.value && + ocmeActive[0].value === "1" ) { lastProcessedTimestamp = tagTime; //console.log(tagData.state.timestamp); @@ -47,7 +51,8 @@ export const palletSendTag = async (tagData: any) => { if ( tagTime !== lastProcessedTimestamp && Date.now() - tagTime <= 5000 && - !tagData.value + !tagData.value && + ocmeActive[0].value === "1" ) { await pickedup({ runningNr: 1234, all: true, areaFrom: "wrapper_1" }); } -- 2.49.1 From a36552fd9b9c77f8ecee8b36f45e613383841f95 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 4 Aug 2025 12:48:04 -0500 Subject: [PATCH 011/166] fix(dm page): correction to the insturcitons --- frontend/src/components/logistics/dm/dmPage.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/logistics/dm/dmPage.tsx b/frontend/src/components/logistics/dm/dmPage.tsx index b37df66..1bee0c3 100644 --- a/frontend/src/components/logistics/dm/dmPage.tsx +++ b/frontend/src/components/logistics/dm/dmPage.tsx @@ -26,7 +26,7 @@ export default function DmPage() {
  • Download the standard template if you have not yet done - so, top right click standard, then template. + so, Above click Standard Order Template.
  • Add in the orders like you see in the example below. @@ -37,8 +37,8 @@ export default function DmPage() { customerReleaseNumber. Quatity and dates can change.
  • - Once you have all the orders enters click the upload - button on the top right + Once you have all the orders entered, click Standard + Order Import
-- 2.49.1 From a0179a41bac93d2a7320802e9d70aa966ed79ae4 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 4 Aug 2025 12:48:49 -0500 Subject: [PATCH 012/166] refactor(migration progress): moved to start looking at the go backedn --- server/globalUtils/createSSCC.ts | 17 ++++--- server/globalUtils/createUrl.ts | 22 ++++---- server/index.ts | 23 ++++++--- server/scripts/updateServers.ts | 2 + .../controllers/userAdmin/updateUserAdm.ts | 5 +- .../controller/getDeliveryByDateRange.ts | 20 ++++---- .../dataMart/controller/getOpenOrders.ts | 23 +++++---- server/services/general/route/scalar.ts | 16 +++--- server/services/logger/goTransport.ts | 35 +++++++++++++ server/services/logger/logger.ts | 8 +++ server/services/logger/loggerService.ts | 15 +++--- server/services/sqlServer/prodSqlServer.ts | 50 +++++++++++++------ .../sqlServer/querys/dataMart/article.ts | 5 ++ .../sqlServer/utils/prodServerConfig.ts | 26 ++++++---- server/services/tcpServer/tcpServer.ts | 33 ++++++------ 15 files changed, 201 insertions(+), 99 deletions(-) create mode 100644 server/services/logger/goTransport.ts diff --git a/server/globalUtils/createSSCC.ts b/server/globalUtils/createSSCC.ts index 6107265..13497ae 100644 --- a/server/globalUtils/createSSCC.ts +++ b/server/globalUtils/createSSCC.ts @@ -1,16 +1,19 @@ -import { eq } from "drizzle-orm"; -import { db } from "../../database/dbclient.js"; -import { settings } from "../../database/schema/settings.js"; import { query } from "../services/sqlServer/prodSqlServer.js"; import { plantInfo } from "../services/sqlServer/querys/dataMart/plantInfo.js"; import { createLog } from "../services/logger/logger.js"; +import { getSettings } from "../services/server/controller/settings/getSettings.js"; export const createSSCC = async (runningNumber: number) => { // get the token - const plantToken = await db - .select() - .from(settings) - .where(eq(settings.name, "plantToken")); + + let serverSettings = (await getSettings()) as any; + const plantToken = serverSettings?.filter( + (n: any) => n.name === "plantToken" + ); + // const plantToken = await db + // .select() + // .from(settings) + // .where(eq(settings.name, "plantToken")); let global: any = []; // get from plant address in basis enter the entire string here. try { diff --git a/server/globalUtils/createUrl.ts b/server/globalUtils/createUrl.ts index 99931af..c253955 100644 --- a/server/globalUtils/createUrl.ts +++ b/server/globalUtils/createUrl.ts @@ -1,6 +1,7 @@ import { eq } from "drizzle-orm"; import { db } from "../../database/dbclient.js"; -import { settings } from "../../database/schema/settings.js"; + +import { getSettings } from "../services/server/controller/settings/getSettings.js"; // create the test server stuff const testServers = [ @@ -12,19 +13,22 @@ const testServers = [ export const prodEndpointCreation = async (endpoint: string) => { let url = ""; //get the plant token - const plantToken = await db - .select() - .from(settings) - .where(eq(settings.name, "plantToken")); + let serverSettings = await getSettings(); + const plantToken = serverSettings?.filter((n) => n.name === "plantToken"); + // await db + // .select() + // .from(settings) + // .where(eq(settings.name, "plantToken")); // check if we are a test server const testServer = testServers.some( (server) => server.token === plantToken[0]?.value ); - const server = await db - .select() - .from(settings) - .where(eq(settings.name, "dbServer")); + const server = serverSettings?.filter((n) => n.name === "dbServer"); + // await db + // .select() + // .from(settings) + // .where(eq(settings.name, "dbServer")); if (testServer) { //filter out what testserver we are diff --git a/server/index.ts b/server/index.ts index 1132c49..726c180 100644 --- a/server/index.ts +++ b/server/index.ts @@ -29,6 +29,11 @@ import eom from "./services/eom/eomService.js"; import dataMart from "./services/dataMart/dataMartService.js"; import qualityRequest from "./services/quality/qualityService.js"; import produser from "./services/prodUser/prodUser.js"; +import { + getSettings, + serverSettings, +} from "./services/server/controller/settings/getSettings.js"; +import type { Settings } from "./types/settings.js"; // create the main prodlogin here const username = "lst_user"; @@ -36,15 +41,16 @@ const password = "Alpla$$Prod"; export const lstAuth = btoa(`${username}:${password}`); // checking to make sure we have the settings intialized -const { data: settingsData, error: settingError } = await tryCatch( - db.select().from(settings) -); +// const { data: settingsData, error: settingError } = await tryCatch( +// db.select().from(settings) +// ); -if (settingError) { - throw Error("Error getting settings from the db. critical error."); -} +// if (settingError) { +// throw Error("Error getting settings from the db. critical error."); +// } + +const serverIntialized: any = await getSettings(); -const serverIntialized: any = settingsData; export const installed = serverIntialized.length === 0 && process.env.NODE_ENV !== "development" ? false @@ -211,7 +217,8 @@ serve( /** * Only for ocme until we get them switched over to the single port setup. */ -const setting = await db.select().from(settings); +// const setting = await db.select().from(settings); +const setting = serverSettings; const isActive = setting.filter((n) => n.name === "ocmeService"); if (ocmeport && isActive[0]?.value === "1") { serve( diff --git a/server/scripts/updateServers.ts b/server/scripts/updateServers.ts index b0ec951..3253503 100644 --- a/server/scripts/updateServers.ts +++ b/server/scripts/updateServers.ts @@ -4,6 +4,7 @@ import { db } from "../../database/dbclient.js"; import { serverData } from "../../database/schema/serverData.js"; import { eq, sql } from "drizzle-orm"; import { createLog } from "../services/logger/logger.js"; +import { serverSettings } from "../services/server/controller/settings/getSettings.js"; type UpdateServerResponse = { success: boolean; @@ -48,6 +49,7 @@ export const updateServer = async ( }; } + console.log(serverInfo); const scriptPath = `${process.env.DEVFOLDER}\\server\\scripts\\update.ps1 `; const args = [ "-NoProfile", diff --git a/server/services/auth/controllers/userAdmin/updateUserAdm.ts b/server/services/auth/controllers/userAdmin/updateUserAdm.ts index 9b97f0d..32f75ef 100644 --- a/server/services/auth/controllers/userAdmin/updateUserAdm.ts +++ b/server/services/auth/controllers/userAdmin/updateUserAdm.ts @@ -7,6 +7,7 @@ import { createPassword } from "../../utils/createPassword.js"; import { createLog } from "../../../logger/logger.js"; import { sendEmail } from "../../../notifications/controller/sendMail.js"; import { settings } from "../../../../../database/schema/settings.js"; +import { getSettings } from "../../../server/controller/settings/getSettings.js"; export const updateUserADM = async (userData: User) => { /** @@ -40,8 +41,8 @@ export const updateUserADM = async (userData: User) => { }; } - const { data: s, error: se } = await tryCatch(db.select().from(settings)); - + //const { data: s, error: se } = await tryCatch(db.select().from(settings)); + const { data: s, error: se } = await tryCatch(getSettings()); if (se) { return { success: false, diff --git a/server/services/dataMart/controller/getDeliveryByDateRange.ts b/server/services/dataMart/controller/getDeliveryByDateRange.ts index 9f8862b..3d014ad 100644 --- a/server/services/dataMart/controller/getDeliveryByDateRange.ts +++ b/server/services/dataMart/controller/getDeliveryByDateRange.ts @@ -7,16 +7,16 @@ import { deliveryByDateRange } from "../../sqlServer/querys/dataMart/deleveryByD import { addDays, format } from "date-fns"; export const getDeliveryByDateRange = async (data: any | null) => { - const { data: plantToken, error: plantError } = await tryCatch( - db.select().from(settings).where(eq(settings.name, "plantToken")) - ); - if (plantError) { - return { - success: false, - message: "Error getting Settings", - data: plantError, - }; - } + // const { data: plantToken, error: plantError } = await tryCatch( + // db.select().from(settings).where(eq(settings.name, "plantToken")) + // ); + // if (plantError) { + // return { + // success: false, + // message: "Error getting Settings", + // data: plantError, + // }; + // } let deliverys: any = []; let updatedQuery = deliveryByDateRange; diff --git a/server/services/dataMart/controller/getOpenOrders.ts b/server/services/dataMart/controller/getOpenOrders.ts index 890d4f3..0609043 100644 --- a/server/services/dataMart/controller/getOpenOrders.ts +++ b/server/services/dataMart/controller/getOpenOrders.ts @@ -4,18 +4,21 @@ import { settings } from "../../../../database/schema/settings.js"; import { tryCatch } from "../../../globalUtils/tryCatch.js"; import { query } from "../../sqlServer/prodSqlServer.js"; import { openOrders } from "../../sqlServer/querys/dataMart/openOrders.js"; +import { serverSettings } from "../../server/controller/settings/getSettings.js"; export const getOpenOrders = async (data: any | null) => { - const { data: plantToken, error: plantError } = await tryCatch( - db.select().from(settings).where(eq(settings.name, "plantToken")) - ); - if (plantError) { - return { - success: false, - message: "Error getting Settings", - data: plantError, - }; - } + // const { data: plantToken, error: plantError } = await tryCatch( + // db.select().from(settings).where(eq(settings.name, "plantToken")) + // ); + // if (plantError) { + // return { + // success: false, + // message: "Error getting Settings", + // data: plantError, + // }; + // } + + const plantToken = serverSettings.filter((n) => n.name === "plantToken"); let orders: any = []; let updatedQuery = openOrders; diff --git a/server/services/general/route/scalar.ts b/server/services/general/route/scalar.ts index 84a641b..6fad1b5 100644 --- a/server/services/general/route/scalar.ts +++ b/server/services/general/route/scalar.ts @@ -1,11 +1,13 @@ -import {OpenAPIHono} from "@hono/zod-openapi"; -import {apiReference} from "@scalar/hono-api-reference"; -import {settings} from "../../../../database/schema/settings.js"; -import {db} from "../../../../database/dbclient.js"; -import {eq} from "drizzle-orm"; +import { OpenAPIHono } from "@hono/zod-openapi"; +import { apiReference } from "@scalar/hono-api-reference"; +import { settings } from "../../../../database/schema/settings.js"; +import { db } from "../../../../database/dbclient.js"; +import { eq } from "drizzle-orm"; +import { getSettings } from "../../server/controller/settings/getSettings.js"; const app = new OpenAPIHono(); -const plantToken = await db.select().from(settings).where(eq(settings.name, "plantToken")); +const serverSettings = await getSettings(); +const plantToken = serverSettings.filter((n) => n.name === "plantToken") as any; //await db.select().from(settings).where(eq(settings.name, "plantToken")); let pToken = plantToken[0]?.value; const testServers = ["test1", "test2", "test3"]; @@ -17,7 +19,7 @@ app.get( apiReference({ theme: "kepler", layout: "classic", - defaultHttpClient: {targetKey: "node", clientKey: "axios"}, + defaultHttpClient: { targetKey: "node", clientKey: "axios" }, pageTitle: "Lst API Reference", hiddenClients: [ "libcurl", diff --git a/server/services/logger/goTransport.ts b/server/services/logger/goTransport.ts new file mode 100644 index 0000000..6de1f9b --- /dev/null +++ b/server/services/logger/goTransport.ts @@ -0,0 +1,35 @@ +// goTransport.js +import { pino } from "pino"; +import build from "pino-abstract-transport"; + +const pinoLogLevels: any = { + 10: "trace", + 20: "debug", + 30: "info", + 40: "warn", + 50: "error", + 60: "fatal", +}; + +export default async function buildGoTransport() { + try { + return build(async function (source) { + for await (let obj of source) { + // Insert log entry into the PostgreSQL database using Drizzle ORM + + // convert to the name to make it more easy to find later :P + const levelName = pinoLogLevels[obj.level] || "unknown"; + // await db.insert(logs).values({ + // level: levelName, + // username: obj?.username.toLowerCase(), + // service: obj?.service.toLowerCase(), + // message: obj.msg, + // }); + + console.log(`Go log level: ${levelName}`); + } + }); + } catch (err) { + console.error("Error inserting log into database:", err); + } +} diff --git a/server/services/logger/logger.ts b/server/services/logger/logger.ts index 9b94de6..4ec9853 100644 --- a/server/services/logger/logger.ts +++ b/server/services/logger/logger.ts @@ -18,6 +18,14 @@ const transport = pino.transport({ { target: "./dbTransport.js", }, + // Only log to Go if LST_USE_GO=true + ...(process.env.LST_USE_GO === "true" + ? [ + { + target: "./goTransport.js", // New transport for Go + }, + ] + : []), ], }); diff --git a/server/services/logger/loggerService.ts b/server/services/logger/loggerService.ts index a8ba17e..d8c7fd2 100644 --- a/server/services/logger/loggerService.ts +++ b/server/services/logger/loggerService.ts @@ -1,10 +1,10 @@ -import {OpenAPIHono} from "@hono/zod-openapi"; +import { OpenAPIHono } from "@hono/zod-openapi"; // routes import clearLog from "./routes/clearLog.js"; -import {db} from "../../../database/dbclient.js"; -import {settings} from "../../../database/schema/settings.js"; -import {logCleanup} from "./controller/logCleanup.js"; +import { db } from "../../../database/dbclient.js"; +import { settings } from "../../../database/schema/settings.js"; +import { logCleanup } from "./controller/logCleanup.js"; import createNewLog from "./routes/createLog.js"; import getLogs from "./routes/getLogs.js"; import stream from "./routes/streamLogs.js"; @@ -12,14 +12,17 @@ import stream from "./routes/streamLogs.js"; const app = new OpenAPIHono(); const routes = [clearLog, createNewLog, getLogs, stream] as const; -const setting = await db.select().from(settings); +//const setting = await db.select().from(settings); const appRoutes = routes.forEach((route) => { app.route("/logger", route); }); app.all("/logger/*", (c) => { - return c.json({success: false, message: "You have encounters a log route that dose not exist."}); + return c.json({ + success: false, + message: "You have encounters a log route that dose not exist.", + }); }); // run the clean up job ones on server restart/crash/update and then once a date diff --git a/server/services/sqlServer/prodSqlServer.ts b/server/services/sqlServer/prodSqlServer.ts index 08c47da..1d8e465 100644 --- a/server/services/sqlServer/prodSqlServer.ts +++ b/server/services/sqlServer/prodSqlServer.ts @@ -6,6 +6,7 @@ import { settings } from "../../../database/schema/settings.js"; import { eq } from "drizzle-orm"; import { installed } from "../../index.js"; import { checkHostnamePort } from "../../globalUtils/pingServer.js"; +import { serverSettings } from "../server/controller/settings/getSettings.js"; let pool: any; let connected: boolean = false; @@ -23,10 +24,16 @@ export const initializeProdPool = async () => { return { success: false, message: "The server is not installed." }; } - const dbServer = await db - .select() - .from(settings) - .where(eq(settings.name, "dbServer")); + // const dbServer = await db + // .select() + // .from(settings) + // .where(eq(settings.name, "dbServer")); + + // the move to the go version for settings + const dbServer = serverSettings.filter( + (n: any) => n.name === "dbServer" + ) as any; + const serverUp = await checkHostnamePort(`${dbServer[0].value}:1433`); if (!serverUp) { @@ -44,10 +51,14 @@ export const initializeProdPool = async () => { } // make sure the server is not set to localhost this will prevent some weird issues later but can be localhost on the dev - const serverLoc = await db - .select() - .from(settings) - .where(eq(settings.name, "dbServer")); + // const serverLoc = await db + // .select() + // .from(settings) + // .where(eq(settings.name, "dbServer")); + + const serverLoc = serverSettings.filter( + (n: any) => n.name === "dbServer" + ) as any; if ( serverLoc[0].value === "localhost" && process.env.NODE_ENV !== "development" @@ -134,10 +145,14 @@ export async function query(queryToRun: string, name: string) { /** * Just an extra catch incase someone tried to run a query while we were not connected to the server or sql server */ - const dbServer = await db - .select() - .from(settings) - .where(eq(settings.name, "dbServer")); + // const dbServer = await db + // .select() + // .from(settings) + // .where(eq(settings.name, "dbServer")); + + const dbServer = serverSettings.filter( + (n: any) => n.name === "dbServer" + ) as any; const serverUp = await checkHostnamePort(`${dbServer[0].value}:1433`); if (!serverUp) { @@ -170,10 +185,13 @@ export async function query(queryToRun: string, name: string) { /** * We no longer need to send over the plant token change as we do it inside the query function. */ - const plantToken = await db - .select() - .from(settings) - .where(eq(settings.name, "plantToken")); + // const plantToken = await db + // .select() + // .from(settings) + // .where(eq(settings.name, "plantToken")); + const plantToken = serverSettings.filter( + (n: any) => n.name === "plantToken" + ) as any; const query = queryToRun.replaceAll("test1", plantToken[0].value); try { diff --git a/server/services/sqlServer/querys/dataMart/article.ts b/server/services/sqlServer/querys/dataMart/article.ts index e24f64f..4a42127 100644 --- a/server/services/sqlServer/querys/dataMart/article.ts +++ b/server/services/sqlServer/querys/dataMart/article.ts @@ -38,6 +38,11 @@ V_Artikel.ArtikelvariantenTypBez = 'Glue' or V_Artikel.ArtikelvariantenTypBez = 'Top Frame' or V_Artikel.ArtikelvariantenTypBez = 'IML Label' or V_Artikel.ArtikelvariantenTypBez = 'Purch EBM Bottle' or +V_Artikel.ArtikelvariantenTypBez = 'Purchased Spout' or +V_Artikel.ArtikelvariantenTypBez = 'Gaylord' or +V_Artikel.ArtikelvariantenTypBez = 'Misc. Packaging' or +V_Artikel.ArtikelvariantenTypBez = 'Sleeve' or +V_Artikel.ArtikelvariantenTypBez = 'Plastic Bag' or V_Artikel.ArtikelvariantenTypBez = 'Purch Spout' THEN 'PKG' WHEN V_Artikel.ArtikelvariantenTypBez='HD-PE' or diff --git a/server/services/sqlServer/utils/prodServerConfig.ts b/server/services/sqlServer/utils/prodServerConfig.ts index 1c9d957..bd3cd38 100644 --- a/server/services/sqlServer/utils/prodServerConfig.ts +++ b/server/services/sqlServer/utils/prodServerConfig.ts @@ -1,16 +1,22 @@ -import {db} from "../../../../database/dbclient.js"; -import {settings} from "../../../../database/schema/settings.js"; -import {createLog} from "../../logger/logger.js"; +import { db } from "../../../../database/dbclient.js"; +import { settings } from "../../../../database/schema/settings.js"; +import { createLog } from "../../logger/logger.js"; +import { serverSettings } from "../../server/controller/settings/getSettings.js"; export const prodSqlConfig = async () => { try { - const serverSetting = await db.select().from(settings); + //const serverSetting = await db.select().from(settings); + const serverSetting = serverSettings as any; // create dummy type data - const server = serverSetting.filter((s) => s.name === "dbServer"); - const plantToken = serverSetting.filter((s) => s.name === "plantToken"); - const dbUser = serverSetting.filter((s) => s.name === "dbUser"); + const server = serverSetting.filter((s: any) => s.name === "dbServer"); + const plantToken = serverSetting.filter( + (s: any) => s.name === "plantToken" + ); + const dbUser = serverSetting.filter((s: any) => s.name === "dbUser"); // if erroring out double check the password was actually encoded before saving - const dbPassword = serverSetting.filter((s) => s.name === "dbPass"); + const dbPassword = serverSetting.filter( + (s: any) => s.name === "dbPass" + ); const sqlConfig = { server: server[0].value, @@ -37,7 +43,9 @@ export const prodSqlConfig = async () => { "info", "lst", "sqlProd", - `${JSON.stringify(error)} "There was an error getting/setting up the config for the prod sql server."` + `${JSON.stringify( + error + )} "There was an error getting/setting up the config for the prod sql server."` ); } }; diff --git a/server/services/tcpServer/tcpServer.ts b/server/services/tcpServer/tcpServer.ts index 96b5628..be727e1 100644 --- a/server/services/tcpServer/tcpServer.ts +++ b/server/services/tcpServer/tcpServer.ts @@ -10,6 +10,7 @@ import { settings } from "../../../database/schema/settings.js"; import { eq } from "drizzle-orm"; import { postLabelData } from "../ocme/controller/postRunningNr.js"; import { tryCatch } from "../../globalUtils/tryCatch.js"; +import { serverSettings } from "../server/controller/settings/getSettings.js"; let tcpServer: net.Server; let tcpSockets: Set = new Set(); @@ -18,31 +19,33 @@ let isServerRunning = false; /** * add in proper logging */ -const tcpPort = await db - .select() - .from(settings) - .where(eq(settings.name, "tcpPort")); +// const tcpPort = await db +// .select() +// .from(settings) +// .where(eq(settings.name, "tcpPort")); + const app = new OpenAPIHono(); export const startTCPServer = () => { + const tcpPort = serverSettings.filter((n) => n.name === "tcpPort"); if (isServerRunning) return { success: false, message: "Server is already running" }; tcpServer = net.createServer(async (socket) => { createLog("debug", "tcp", "tcp", "Client connected"); - const { data: setting, error: settingError } = await tryCatch( - db.select().from(settings) - ); - if (settingError) { - return { - success: false, - message: "Error getting settings", - data: [], - }; - } + // const { data: setting, error: settingError } = await tryCatch( + // db.select().from(settings) + // ); + // if (settingError) { + // return { + // success: false, + // message: "Error getting settings", + // data: [], + // }; + // } - const settingCheck = setting.filter( + const settingCheck = serverSettings.filter( (newData) => newData.name === "ocmeService" ); -- 2.49.1 From 69fc7418c9273a7824360a9d09d652cc4c49c0d2 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 4 Aug 2025 14:41:53 -0500 Subject: [PATCH 013/166] ci(release): bump build number to 538 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bdea083..0ec10eb 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 537, + "build": 538, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 22888848291aa3df4ebbdd224656731fbb305fa7 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 4 Aug 2025 18:12:32 -0500 Subject: [PATCH 014/166] fix(inv cards): correction to properly display the names --- .../src/utils/tableData/InventoryCards/inventoryData.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/utils/tableData/InventoryCards/inventoryData.tsx b/frontend/src/utils/tableData/InventoryCards/inventoryData.tsx index 964a51a..dff0804 100644 --- a/frontend/src/utils/tableData/InventoryCards/inventoryData.tsx +++ b/frontend/src/utils/tableData/InventoryCards/inventoryData.tsx @@ -66,6 +66,7 @@ export function InvTable({ }); //console.log(table.getState().sorting); //console.log(parseInt(style.height.replace("px", "")) - 50); + console.log(info); return ( ({

- {info.type} {data.length > 0 ? "lanes" : "lane"} older - than: {info.age}, needing to be completed + {info.rowType} {data.length > 0 ? "lanes" : "lane"}{" "} + older than: {info.age}, {data.length} needing to be + completed

-- 2.49.1 From 078f35626b34223eb2b734a74105ecf79adb84d8 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 5 Aug 2025 14:16:26 -0500 Subject: [PATCH 015/166] ci(release): bump build number to 539 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0ec10eb..df688c2 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 538, + "build": 539, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 803c963f964f26095b2aa6a7d0a60e03615d4c17 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 5 Aug 2025 14:45:04 -0500 Subject: [PATCH 016/166] fix(https fixes): made it so the settings can be grabbed via https --- server/services/logger/goTransport.ts | 11 +++++++++-- .../server/controller/settings/getSettings.ts | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/server/services/logger/goTransport.ts b/server/services/logger/goTransport.ts index 6de1f9b..32fb828 100644 --- a/server/services/logger/goTransport.ts +++ b/server/services/logger/goTransport.ts @@ -1,4 +1,5 @@ -// goTransport.js +process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; +import axios from "axios"; import { pino } from "pino"; import build from "pino-abstract-transport"; @@ -26,7 +27,13 @@ export default async function buildGoTransport() { // message: obj.msg, // }); - console.log(`Go log level: ${levelName}`); + axios.post(`${process.env.LST_BASE_URL}/api/v1/log`, { + service: obj?.service.toLowerCase(), + level: levelName, + message: obj.msg, + }); + + // console.log(`Go log level: ${levelName}`); } }); } catch (err) { diff --git a/server/services/server/controller/settings/getSettings.ts b/server/services/server/controller/settings/getSettings.ts index fe2efb9..e7bcf34 100644 --- a/server/services/server/controller/settings/getSettings.ts +++ b/server/services/server/controller/settings/getSettings.ts @@ -1,3 +1,4 @@ +process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; import axios from "axios"; import { db } from "../../../../../database/dbclient.js"; import { settings } from "../../../../../database/schema/settings.js"; -- 2.49.1 From e209686d3ced79b8a64282a464c609f36ae71efd Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 5 Aug 2025 14:50:05 -0500 Subject: [PATCH 017/166] ci(release): bump build number to 540 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index df688c2..bf4ac3a 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 539, + "build": 540, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 8f76d6998c8e12164feb3172cf95cbf55de96b4f Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 6 Aug 2025 15:08:13 -0500 Subject: [PATCH 018/166] ci(release): bump build number to 541 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bf4ac3a..811bda9 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 540, + "build": 541, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From c52e2a86711961f1f076d32fb7e8e3751a97508a Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 6 Aug 2025 15:19:54 -0500 Subject: [PATCH 019/166] ci(release): bump build number to 542 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 811bda9..5fdae87 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 541, + "build": 542, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 9e5577e6bb4ff3b6c4004288e177fbab322a4b44 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 6 Aug 2025 15:25:45 -0500 Subject: [PATCH 020/166] feat(dm): changes to have a default time if nothing is passed in the excel --- server/services/logistics/utils/excelDateStuff.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/services/logistics/utils/excelDateStuff.ts b/server/services/logistics/utils/excelDateStuff.ts index 45282c2..dea7e9e 100644 --- a/server/services/logistics/utils/excelDateStuff.ts +++ b/server/services/logistics/utils/excelDateStuff.ts @@ -7,6 +7,10 @@ export const excelDateStuff = (serial: number, time: any = 0) => { // get the local timezone const localoffset = new Date().getTimezoneOffset() / 60; // then divide by 60 to get the true number; + if (serial % 1 === 0) { + time = 800; + } + const addHours = serial + localoffset / 24; //console.log(getJsDateFromExcel(addHours)); if (typeof serial !== "number" || serial <= 0) { @@ -23,6 +27,8 @@ export const excelDateStuff = (serial: number, time: any = 0) => { date.setMinutes(minutes); } //console.log(date.toLocaleString("en-US"), getJsDateFromExcel(addHours)); + + //console.log(serial); //console.log(date.toISOString()); return date.toISOString(); //.toLocaleString("en-US"); // or .toISOString() if preferred }; -- 2.49.1 From 15e2a65cbb65dcf72b80a60a384f7b52f53e322f Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 7 Aug 2025 21:18:09 -0500 Subject: [PATCH 021/166] ci(release): bump build number to 543 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5fdae87..ee48947 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 542, + "build": 543, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 67a12ccc5c23d96cc2d0cf7da6539e30791c4c40 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 9 Aug 2025 14:28:17 -0500 Subject: [PATCH 022/166] ci(release): bump build number to 544 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ee48947..4c800b4 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 543, + "build": 544, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 1802b9ba4ed869c7f02fc67db26b8ed725170809 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 9 Aug 2025 14:41:23 -0500 Subject: [PATCH 023/166] ci(release): bump build number to 545 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4c800b4..2abf402 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 544, + "build": 545, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 7c48f608bca700a7df7d32524f5358119b74590e Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 9 Aug 2025 14:58:02 -0500 Subject: [PATCH 024/166] ci(release): bump build number to 546 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2abf402..0f3c8e0 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 545, + "build": 546, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 83ff2641f3691ea8d876db2bfe0c966347dd9ffa Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 9 Aug 2025 15:02:21 -0500 Subject: [PATCH 025/166] ci(release): bump build number to 547 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0f3c8e0..6b531b6 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 546, + "build": 547, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From a8a1c1d7fb0d60aba22b922b7cd92faa7f056389 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 9 Aug 2025 15:05:59 -0500 Subject: [PATCH 026/166] ci(release): bump build number to 548 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6b531b6..6cb2157 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 547, + "build": 548, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 52345bc94c9e8abc82150fb371a9ba0d0757f16a Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sun, 10 Aug 2025 18:11:16 -0500 Subject: [PATCH 027/166] feat(eom): added in hostorical data and deletion for data over 45 days --- database/migrations/0070_brief_mephisto.sql | 10 + .../migrations/0071_fantastic_old_lace.sql | 2 + database/migrations/meta/0070_snapshot.json | 2250 ++++++++++++++++ database/migrations/meta/0071_snapshot.json | 2252 +++++++++++++++++ database/migrations/meta/_journal.json | 14 + database/schema/historicalINV.ts | 7 +- .../eom/controller/removeHistorical.ts | 15 - server/services/eom/eomService.ts | 9 + server/services/eom/utils/historicalInv.ts | 101 + server/services/eom/utils/removeHistorical.ts | 51 + 10 files changed, 4693 insertions(+), 18 deletions(-) create mode 100644 database/migrations/0070_brief_mephisto.sql create mode 100644 database/migrations/0071_fantastic_old_lace.sql create mode 100644 database/migrations/meta/0070_snapshot.json create mode 100644 database/migrations/meta/0071_snapshot.json delete mode 100644 server/services/eom/controller/removeHistorical.ts create mode 100644 server/services/eom/utils/historicalInv.ts create mode 100644 server/services/eom/utils/removeHistorical.ts diff --git a/database/migrations/0070_brief_mephisto.sql b/database/migrations/0070_brief_mephisto.sql new file mode 100644 index 0000000..7a560b4 --- /dev/null +++ b/database/migrations/0070_brief_mephisto.sql @@ -0,0 +1,10 @@ +CREATE TABLE "labelRatio" ( + " ratio_id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "name" text DEFAULT 'labels', + "autoLabel" integer DEFAULT 0, + "manualLabel" integer DEFAULT 0, + "lastReset" timestamp DEFAULT now() +); +--> statement-breakpoint +ALTER TABLE "invHistoricalData" ADD COLUMN "lot_number" text;--> statement-breakpoint +CREATE UNIQUE INDEX "labelname" ON "labelRatio" USING btree ("name"); \ No newline at end of file diff --git a/database/migrations/0071_fantastic_old_lace.sql b/database/migrations/0071_fantastic_old_lace.sql new file mode 100644 index 0000000..f883d5d --- /dev/null +++ b/database/migrations/0071_fantastic_old_lace.sql @@ -0,0 +1,2 @@ +ALTER TABLE "invHistoricalData" ALTER COLUMN "upd_user" SET DEFAULT 'lst';--> statement-breakpoint +ALTER TABLE "invHistoricalData" ALTER COLUMN "upd_date" SET DEFAULT now(); \ No newline at end of file diff --git a/database/migrations/meta/0070_snapshot.json b/database/migrations/meta/0070_snapshot.json new file mode 100644 index 0000000..9c64ea2 --- /dev/null +++ b/database/migrations/meta/0070_snapshot.json @@ -0,0 +1,2250 @@ +{ + "id": "18eda0c0-b600-4f50-9662-d639796a0669", + "prevId": "169b8f50-692f-4474-b76b-3f4642dcdab8", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.apiHits": { + "name": "apiHits", + "schema": "", + "columns": { + "apiHit_id": { + "name": "apiHit_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastBody": { + "name": "lastBody", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "stats": { + "name": "stats", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 1 + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "endpoint": { + "name": "endpoint", + "columns": [ + { + "expression": "endpoint", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "ip", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.commandLog": { + "name": "commandLog", + "schema": "", + "columns": { + "commandLog_id": { + "name": "commandLog_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "commandUsed": { + "name": "commandUsed", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bodySent": { + "name": "bodySent", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "reasonUsed": { + "name": "reasonUsed", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.fifoIndex": { + "name": "fifoIndex", + "schema": "", + "columns": { + "fifoIndex_id": { + "name": "fifoIndex_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "lot": { + "name": "lot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "av": { + "name": "av", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "runningNr": { + "name": "runningNr", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "prodDate": { + "name": "prodDate", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "fifoFollowed": { + "name": "fifoFollowed", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "fifo_runningNr": { + "name": "fifo_runningNr", + "columns": [ + { + "expression": "runningNr", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.invHistoricalData": { + "name": "invHistoricalData", + "schema": "", + "columns": { + "inv_id": { + "name": "inv_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "histDate": { + "name": "histDate", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "plantToken": { + "name": "plantToken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "article": { + "name": "article", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "articleDescription": { + "name": "articleDescription", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "materialType": { + "name": "materialType", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "total_QTY": { + "name": "total_QTY", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "avaliable_QTY": { + "name": "avaliable_QTY", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "coa_QTY": { + "name": "coa_QTY", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "held_QTY": { + "name": "held_QTY", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lot_number": { + "name": "lot_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "consignment": { + "name": "consignment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "upd_user": { + "name": "upd_user", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.logs": { + "name": "logs", + "schema": "", + "columns": { + "log_id": { + "name": "log_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "level": { + "name": "level", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'LST_Serivce'" + }, + "service": { + "name": "service", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'system'" + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "checked": { + "name": "checked", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.modules": { + "name": "modules", + "schema": "", + "columns": { + "module_id": { + "name": "module_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "roles": { + "name": "roles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[\"view\",\"systemAdmin\"]'::jsonb" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "module_name": { + "name": "module_name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notifications": { + "name": "notifications", + "schema": "", + "columns": { + "notify_id": { + "name": "notify_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "checkInterval": { + "name": "checkInterval", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'1'" + }, + "timeType": { + "name": "timeType", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'hour'" + }, + "emails": { + "name": "emails", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "lastRan": { + "name": "lastRan", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "notifiySettings": { + "name": "notifiySettings", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + } + }, + "indexes": { + "notify_name": { + "name": "notify_name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ocmeData": { + "name": "ocmeData", + "schema": "", + "columns": { + "ocme_id": { + "name": "ocme_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "sscc": { + "name": "sscc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runningNr": { + "name": "runningNr", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "completed": { + "name": "completed", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "lineNum": { + "name": "lineNum", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "pickedUp": { + "name": "pickedUp", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "areaFrom": { + "name": "areaFrom", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "ocme_runningNr": { + "name": "ocme_runningNr", + "columns": [ + { + "expression": "runningNr", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ocmeCycleCounts": { + "name": "ocmeCycleCounts", + "schema": "", + "columns": { + "ocme_id": { + "name": "ocme_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "laneId": { + "name": "laneId", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "warehouseName": { + "name": "warehouseName", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "laneName": { + "name": "laneName", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "good": { + "name": "good", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "cycleCount": { + "name": "cycleCount", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.manualPrinting": { + "name": "manualPrinting", + "schema": "", + "columns": { + "print_id": { + "name": "print_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "line": { + "name": "line", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "printReason": { + "name": "printReason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "initials": { + "name": "initials", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "additionalComments": { + "name": "additionalComments", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "add_user": { + "name": "add_user", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.printerData": { + "name": "printerData", + "schema": "", + "columns": { + "printer_id": { + "name": "printer_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "humanReadableId": { + "name": "humanReadableId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ipAddress": { + "name": "ipAddress", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "port": { + "name": "port", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "statusText": { + "name": "statusText", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastTimePrinted": { + "name": "lastTimePrinted", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "assigned": { + "name": "assigned", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "remark": { + "name": "remark", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "printDelay": { + "name": "printDelay", + "type": "numeric", + "primaryKey": false, + "notNull": false, + "default": "'90'" + }, + "monitorState": { + "name": "monitorState", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "processes": { + "name": "processes", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "humanReadableId": { + "name": "humanReadableId", + "columns": [ + { + "expression": "humanReadableId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.prodlabels": { + "name": "prodlabels", + "schema": "", + "columns": { + "label_id": { + "name": "label_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "printerID": { + "name": "printerID", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "printerName": { + "name": "printerName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "line": { + "name": "line", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "runningNr": { + "name": "runningNr", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "add_user": { + "name": "add_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'lst'" + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "runningNr": { + "name": "runningNr", + "columns": [ + { + "expression": "runningNr", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.prodPermissions": { + "name": "prodPermissions", + "schema": "", + "columns": { + "prodPerm_id": { + "name": "prodPerm_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "roles": { + "name": "roles", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "rolesLegacy": { + "name": "rolesLegacy", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "prodPermName": { + "name": "prodPermName", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.qualityRequest": { + "name": "qualityRequest", + "schema": "", + "columns": { + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "article": { + "name": "article", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runningNr": { + "name": "runningNr", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lotNr": { + "name": "lotNr", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "warehouseAtRequest": { + "name": "warehouseAtRequest", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "locationAtRequest": { + "name": "locationAtRequest", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "warehouseMovedTo": { + "name": "warehouseMovedTo", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "locationMovedTo": { + "name": "locationMovedTo", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "durationToMove": { + "name": "durationToMove", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "locationDropOff": { + "name": "locationDropOff", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "palletStatus": { + "name": "palletStatus", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "palletStatusText": { + "name": "palletStatusText", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "palletRequest": { + "name": "palletRequest", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "add_user": { + "name": "add_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'LST'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_user": { + "name": "upd_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'LST'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.labelRatio": { + "name": "labelRatio", + "schema": "", + "columns": { + " ratio_id": { + "name": " ratio_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'labels'" + }, + "autoLabel": { + "name": "autoLabel", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "manualLabel": { + "name": "manualLabel", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "lastReset": { + "name": "lastReset", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "labelname": { + "name": "labelname", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.rfidReaders": { + "name": "rfidReaders", + "schema": "", + "columns": { + "rfidReader_id": { + "name": "rfidReader_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "reader": { + "name": "reader", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "readerIP": { + "name": "readerIP", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastHeartBeat": { + "name": "lastHeartBeat", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "lastTrigger": { + "name": "lastTrigger", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "lastTiggerGood": { + "name": "lastTiggerGood", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "lastTagScanned": { + "name": "lastTagScanned", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "goodReads": { + "name": "goodReads", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "badReads": { + "name": "badReads", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + } + }, + "indexes": { + "reader": { + "name": "reader", + "columns": [ + { + "expression": "reader", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.rfidTags": { + "name": "rfidTags", + "schema": "", + "columns": { + "rfidTag_id": { + "name": "rfidTag_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tagHex": { + "name": "tagHex", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag": { + "name": "tag", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastRead": { + "name": "lastRead", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "counts": { + "name": "counts", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "lastareaIn": { + "name": "lastareaIn", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "runningNumber": { + "name": "runningNumber", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "antenna": { + "name": "antenna", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "tagStrength": { + "name": "tagStrength", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "tagHex": { + "name": "tagHex", + "columns": [ + { + "expression": "tagHex", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.roles": { + "name": "roles", + "schema": "", + "columns": { + "role_id": { + "name": "role_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "role_name": { + "name": "role_name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.serverData": { + "name": "serverData", + "schema": "", + "columns": { + "server_id": { + "name": "server_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "sName": { + "name": "sName", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "serverDNS": { + "name": "serverDNS", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "plantToken": { + "name": "plantToken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "idAddress": { + "name": "idAddress", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "greatPlainsPlantCode": { + "name": "greatPlainsPlantCode", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "streetAddress": { + "name": "streetAddress", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cityState": { + "name": "cityState", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "zipcode": { + "name": "zipcode", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "contactEmail": { + "name": "contactEmail", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contactPhone": { + "name": "contactPhone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "customerTiAcc": { + "name": "customerTiAcc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lstServerPort": { + "name": "lstServerPort", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "serverLoc": { + "name": "serverLoc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "oldVersion": { + "name": "oldVersion", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastUpdated": { + "name": "lastUpdated", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "shippingHours": { + "name": "shippingHours", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'[{\"early\": \"06:30\", \"late\": \"23:00\"}]'" + }, + "tiPostTime": { + "name": "tiPostTime", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'[{\"from\": \"24\", \"to\": \"24\"}]'" + }, + "otherSettings": { + "name": "otherSettings", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[{\"specialInstructions\":\"something for ti\",\"active\":false}]'::jsonb" + }, + "isUpgrading": { + "name": "isUpgrading", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + } + }, + "indexes": { + "plantToken": { + "name": "plantToken", + "columns": [ + { + "expression": "plantToken", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.settings": { + "name": "settings", + "schema": "", + "columns": { + "role_id": { + "name": "role_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "moduleName": { + "name": "moduleName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "roles": { + "name": "roles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[\"systemAdmin\"]'::jsonb" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "name": { + "name": "name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.siloAdjustments": { + "name": "siloAdjustments", + "schema": "", + "columns": { + "siloAdjust_id": { + "name": "siloAdjust_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "level": { + "name": "level", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "locationID": { + "name": "locationID", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "currentStockLevel": { + "name": "currentStockLevel", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "newLevel": { + "name": "newLevel", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "''" + }, + "dateAdjusted": { + "name": "dateAdjusted", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "lastDateAdjusted": { + "name": "lastDateAdjusted", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "commentAddedBy": { + "name": "commentAddedBy", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "commentDate": { + "name": "commentDate", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "commentKey": { + "name": "commentKey", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "add_user": { + "name": "add_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'LST_Serivce'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.subModules": { + "name": "subModules", + "schema": "", + "columns": { + "submodule_id": { + "name": "submodule_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "moduleName": { + "name": "moduleName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "link": { + "name": "link", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "roles": { + "name": "roles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[\"systemAdmin\"]'::jsonb" + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "subSubModule": { + "name": "subSubModule", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "subModule_name": { + "name": "subModule_name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.userRoles": { + "name": "userRoles", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role_id": { + "name": "role_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "module_id": { + "name": "module_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "user_module_unique": { + "name": "user_module_unique", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "module_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "userRoles_user_id_users_user_id_fk": { + "name": "userRoles_user_id_users_user_id_fk", + "tableFrom": "userRoles", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "user_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "userRoles_role_id_roles_role_id_fk": { + "name": "userRoles_role_id_roles_role_id_fk", + "tableFrom": "userRoles", + "tableTo": "roles", + "columnsFrom": [ + "role_id" + ], + "columnsTo": [ + "role_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "userRoles_module_id_modules_module_id_fk": { + "name": "userRoles_module_id_modules_module_id_fk", + "tableFrom": "userRoles", + "tableTo": "modules", + "columnsFrom": [ + "module_id" + ], + "columnsTo": [ + "module_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "passwordToken": { + "name": "passwordToken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "passwordTokenExpires": { + "name": "passwordTokenExpires", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "pingcode": { + "name": "pingcode", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'user'" + }, + "lastLogin": { + "name": "lastLogin", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "username": { + "name": "username", + "columns": [ + { + "expression": "username", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/database/migrations/meta/0071_snapshot.json b/database/migrations/meta/0071_snapshot.json new file mode 100644 index 0000000..111fb14 --- /dev/null +++ b/database/migrations/meta/0071_snapshot.json @@ -0,0 +1,2252 @@ +{ + "id": "beb6fee0-80fe-42a1-8bdb-e7424f9401b7", + "prevId": "18eda0c0-b600-4f50-9662-d639796a0669", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.apiHits": { + "name": "apiHits", + "schema": "", + "columns": { + "apiHit_id": { + "name": "apiHit_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastBody": { + "name": "lastBody", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "stats": { + "name": "stats", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 1 + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "endpoint": { + "name": "endpoint", + "columns": [ + { + "expression": "endpoint", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "ip", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.commandLog": { + "name": "commandLog", + "schema": "", + "columns": { + "commandLog_id": { + "name": "commandLog_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "commandUsed": { + "name": "commandUsed", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bodySent": { + "name": "bodySent", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "reasonUsed": { + "name": "reasonUsed", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.fifoIndex": { + "name": "fifoIndex", + "schema": "", + "columns": { + "fifoIndex_id": { + "name": "fifoIndex_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "lot": { + "name": "lot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "av": { + "name": "av", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "runningNr": { + "name": "runningNr", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "prodDate": { + "name": "prodDate", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "fifoFollowed": { + "name": "fifoFollowed", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "fifo_runningNr": { + "name": "fifo_runningNr", + "columns": [ + { + "expression": "runningNr", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.invHistoricalData": { + "name": "invHistoricalData", + "schema": "", + "columns": { + "inv_id": { + "name": "inv_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "histDate": { + "name": "histDate", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "plantToken": { + "name": "plantToken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "article": { + "name": "article", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "articleDescription": { + "name": "articleDescription", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "materialType": { + "name": "materialType", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "total_QTY": { + "name": "total_QTY", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "avaliable_QTY": { + "name": "avaliable_QTY", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "coa_QTY": { + "name": "coa_QTY", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "held_QTY": { + "name": "held_QTY", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lot_number": { + "name": "lot_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "consignment": { + "name": "consignment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "upd_user": { + "name": "upd_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'lst'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.logs": { + "name": "logs", + "schema": "", + "columns": { + "log_id": { + "name": "log_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "level": { + "name": "level", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'LST_Serivce'" + }, + "service": { + "name": "service", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'system'" + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "checked": { + "name": "checked", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.modules": { + "name": "modules", + "schema": "", + "columns": { + "module_id": { + "name": "module_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "roles": { + "name": "roles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[\"view\",\"systemAdmin\"]'::jsonb" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "module_name": { + "name": "module_name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notifications": { + "name": "notifications", + "schema": "", + "columns": { + "notify_id": { + "name": "notify_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "checkInterval": { + "name": "checkInterval", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'1'" + }, + "timeType": { + "name": "timeType", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'hour'" + }, + "emails": { + "name": "emails", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "lastRan": { + "name": "lastRan", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "notifiySettings": { + "name": "notifiySettings", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + } + }, + "indexes": { + "notify_name": { + "name": "notify_name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ocmeData": { + "name": "ocmeData", + "schema": "", + "columns": { + "ocme_id": { + "name": "ocme_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "sscc": { + "name": "sscc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runningNr": { + "name": "runningNr", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "completed": { + "name": "completed", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "lineNum": { + "name": "lineNum", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "pickedUp": { + "name": "pickedUp", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "areaFrom": { + "name": "areaFrom", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "ocme_runningNr": { + "name": "ocme_runningNr", + "columns": [ + { + "expression": "runningNr", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ocmeCycleCounts": { + "name": "ocmeCycleCounts", + "schema": "", + "columns": { + "ocme_id": { + "name": "ocme_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "laneId": { + "name": "laneId", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "warehouseName": { + "name": "warehouseName", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "laneName": { + "name": "laneName", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "good": { + "name": "good", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "cycleCount": { + "name": "cycleCount", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.manualPrinting": { + "name": "manualPrinting", + "schema": "", + "columns": { + "print_id": { + "name": "print_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "line": { + "name": "line", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "printReason": { + "name": "printReason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "initials": { + "name": "initials", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "additionalComments": { + "name": "additionalComments", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "add_user": { + "name": "add_user", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.printerData": { + "name": "printerData", + "schema": "", + "columns": { + "printer_id": { + "name": "printer_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "humanReadableId": { + "name": "humanReadableId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ipAddress": { + "name": "ipAddress", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "port": { + "name": "port", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "statusText": { + "name": "statusText", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastTimePrinted": { + "name": "lastTimePrinted", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "assigned": { + "name": "assigned", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "remark": { + "name": "remark", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "printDelay": { + "name": "printDelay", + "type": "numeric", + "primaryKey": false, + "notNull": false, + "default": "'90'" + }, + "monitorState": { + "name": "monitorState", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "processes": { + "name": "processes", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "humanReadableId": { + "name": "humanReadableId", + "columns": [ + { + "expression": "humanReadableId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.prodlabels": { + "name": "prodlabels", + "schema": "", + "columns": { + "label_id": { + "name": "label_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "printerID": { + "name": "printerID", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "printerName": { + "name": "printerName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "line": { + "name": "line", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "runningNr": { + "name": "runningNr", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "add_user": { + "name": "add_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'lst'" + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "runningNr": { + "name": "runningNr", + "columns": [ + { + "expression": "runningNr", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.prodPermissions": { + "name": "prodPermissions", + "schema": "", + "columns": { + "prodPerm_id": { + "name": "prodPerm_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "roles": { + "name": "roles", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "rolesLegacy": { + "name": "rolesLegacy", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "prodPermName": { + "name": "prodPermName", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.qualityRequest": { + "name": "qualityRequest", + "schema": "", + "columns": { + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "article": { + "name": "article", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runningNr": { + "name": "runningNr", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lotNr": { + "name": "lotNr", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "warehouseAtRequest": { + "name": "warehouseAtRequest", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "locationAtRequest": { + "name": "locationAtRequest", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "warehouseMovedTo": { + "name": "warehouseMovedTo", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "locationMovedTo": { + "name": "locationMovedTo", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "durationToMove": { + "name": "durationToMove", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "locationDropOff": { + "name": "locationDropOff", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "palletStatus": { + "name": "palletStatus", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "palletStatusText": { + "name": "palletStatusText", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "palletRequest": { + "name": "palletRequest", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "add_user": { + "name": "add_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'LST'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_user": { + "name": "upd_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'LST'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.labelRatio": { + "name": "labelRatio", + "schema": "", + "columns": { + " ratio_id": { + "name": " ratio_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'labels'" + }, + "autoLabel": { + "name": "autoLabel", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "manualLabel": { + "name": "manualLabel", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "lastReset": { + "name": "lastReset", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "labelname": { + "name": "labelname", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.rfidReaders": { + "name": "rfidReaders", + "schema": "", + "columns": { + "rfidReader_id": { + "name": "rfidReader_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "reader": { + "name": "reader", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "readerIP": { + "name": "readerIP", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastHeartBeat": { + "name": "lastHeartBeat", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "lastTrigger": { + "name": "lastTrigger", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "lastTiggerGood": { + "name": "lastTiggerGood", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "lastTagScanned": { + "name": "lastTagScanned", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "goodReads": { + "name": "goodReads", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "badReads": { + "name": "badReads", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + } + }, + "indexes": { + "reader": { + "name": "reader", + "columns": [ + { + "expression": "reader", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.rfidTags": { + "name": "rfidTags", + "schema": "", + "columns": { + "rfidTag_id": { + "name": "rfidTag_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tagHex": { + "name": "tagHex", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag": { + "name": "tag", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastRead": { + "name": "lastRead", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "counts": { + "name": "counts", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "lastareaIn": { + "name": "lastareaIn", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "runningNumber": { + "name": "runningNumber", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "antenna": { + "name": "antenna", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "tagStrength": { + "name": "tagStrength", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "tagHex": { + "name": "tagHex", + "columns": [ + { + "expression": "tagHex", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.roles": { + "name": "roles", + "schema": "", + "columns": { + "role_id": { + "name": "role_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "role_name": { + "name": "role_name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.serverData": { + "name": "serverData", + "schema": "", + "columns": { + "server_id": { + "name": "server_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "sName": { + "name": "sName", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "serverDNS": { + "name": "serverDNS", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "plantToken": { + "name": "plantToken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "idAddress": { + "name": "idAddress", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "greatPlainsPlantCode": { + "name": "greatPlainsPlantCode", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "streetAddress": { + "name": "streetAddress", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cityState": { + "name": "cityState", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "zipcode": { + "name": "zipcode", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "contactEmail": { + "name": "contactEmail", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contactPhone": { + "name": "contactPhone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "customerTiAcc": { + "name": "customerTiAcc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lstServerPort": { + "name": "lstServerPort", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "serverLoc": { + "name": "serverLoc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "oldVersion": { + "name": "oldVersion", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastUpdated": { + "name": "lastUpdated", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "shippingHours": { + "name": "shippingHours", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'[{\"early\": \"06:30\", \"late\": \"23:00\"}]'" + }, + "tiPostTime": { + "name": "tiPostTime", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'[{\"from\": \"24\", \"to\": \"24\"}]'" + }, + "otherSettings": { + "name": "otherSettings", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[{\"specialInstructions\":\"something for ti\",\"active\":false}]'::jsonb" + }, + "isUpgrading": { + "name": "isUpgrading", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + } + }, + "indexes": { + "plantToken": { + "name": "plantToken", + "columns": [ + { + "expression": "plantToken", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.settings": { + "name": "settings", + "schema": "", + "columns": { + "role_id": { + "name": "role_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "moduleName": { + "name": "moduleName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "roles": { + "name": "roles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[\"systemAdmin\"]'::jsonb" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "name": { + "name": "name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.siloAdjustments": { + "name": "siloAdjustments", + "schema": "", + "columns": { + "siloAdjust_id": { + "name": "siloAdjust_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "level": { + "name": "level", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "locationID": { + "name": "locationID", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "currentStockLevel": { + "name": "currentStockLevel", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "newLevel": { + "name": "newLevel", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "''" + }, + "dateAdjusted": { + "name": "dateAdjusted", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "lastDateAdjusted": { + "name": "lastDateAdjusted", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "commentAddedBy": { + "name": "commentAddedBy", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "commentDate": { + "name": "commentDate", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "commentKey": { + "name": "commentKey", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "add_user": { + "name": "add_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'LST_Serivce'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.subModules": { + "name": "subModules", + "schema": "", + "columns": { + "submodule_id": { + "name": "submodule_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "moduleName": { + "name": "moduleName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "link": { + "name": "link", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "roles": { + "name": "roles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[\"systemAdmin\"]'::jsonb" + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "subSubModule": { + "name": "subSubModule", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "subModule_name": { + "name": "subModule_name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.userRoles": { + "name": "userRoles", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role_id": { + "name": "role_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "module_id": { + "name": "module_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "user_module_unique": { + "name": "user_module_unique", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "module_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "userRoles_user_id_users_user_id_fk": { + "name": "userRoles_user_id_users_user_id_fk", + "tableFrom": "userRoles", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "user_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "userRoles_role_id_roles_role_id_fk": { + "name": "userRoles_role_id_roles_role_id_fk", + "tableFrom": "userRoles", + "tableTo": "roles", + "columnsFrom": [ + "role_id" + ], + "columnsTo": [ + "role_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "userRoles_module_id_modules_module_id_fk": { + "name": "userRoles_module_id_modules_module_id_fk", + "tableFrom": "userRoles", + "tableTo": "modules", + "columnsFrom": [ + "module_id" + ], + "columnsTo": [ + "module_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "passwordToken": { + "name": "passwordToken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "passwordTokenExpires": { + "name": "passwordTokenExpires", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "pingcode": { + "name": "pingcode", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'user'" + }, + "lastLogin": { + "name": "lastLogin", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "username": { + "name": "username", + "columns": [ + { + "expression": "username", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/database/migrations/meta/_journal.json b/database/migrations/meta/_journal.json index 4f25c33..6b055e5 100644 --- a/database/migrations/meta/_journal.json +++ b/database/migrations/meta/_journal.json @@ -491,6 +491,20 @@ "when": 1752195894698, "tag": "0069_chemical_maximus", "breakpoints": true + }, + { + "idx": 70, + "version": "7", + "when": 1754767718941, + "tag": "0070_brief_mephisto", + "breakpoints": true + }, + { + "idx": 71, + "version": "7", + "when": 1754768521841, + "tag": "0071_fantastic_old_lace", + "breakpoints": true } ] } \ No newline at end of file diff --git a/database/schema/historicalINV.ts b/database/schema/historicalINV.ts index c88a1ae..b9d357b 100644 --- a/database/schema/historicalINV.ts +++ b/database/schema/historicalINV.ts @@ -12,7 +12,7 @@ export const invHistoricalData = pgTable( "invHistoricalData", { inv_id: uuid("inv_id").defaultRandom().primaryKey(), - histDate: date("histDate").notNull(), // what month are we running in should just be the first of current month + histDate: date("histDate").notNull(), // this date should always be yesterday when we post it. plantToken: text("plantToken"), article: text("article").notNull(), articleDescription: text("articleDescription").notNull(), @@ -21,10 +21,11 @@ export const invHistoricalData = pgTable( avaliable_QTY: text("avaliable_QTY"), coa_QTY: text("coa_QTY"), held_QTY: text("held_QTY"), + lot_Number: text("lot_number"), consignment: text("consignment"), location: text("location"), - upd_user: text("upd_user"), - upd_date: timestamp("upd_date"), + upd_user: text("upd_user").default("lst"), + upd_date: timestamp("upd_date").defaultNow(), } // (table) => [ // // uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`), diff --git a/server/services/eom/controller/removeHistorical.ts b/server/services/eom/controller/removeHistorical.ts deleted file mode 100644 index bd99b88..0000000 --- a/server/services/eom/controller/removeHistorical.ts +++ /dev/null @@ -1,15 +0,0 @@ -// import {prisma} from "database"; -// import {createLog} from "logging"; - -// export const deleteHistory = async (date: string) => { -// // delete the inventory if it equals this date -// try { -// const remove = await prisma.$executeRaw` -// DELETE FROM historyInventory -// WHERE histDate < ${date} -// `; -// createLog("general/eom", "info", `${remove} were just remove from the historical inventory for date: ${date}`); -// } catch (error) { -// createLog("general/eom", "error", `Removing historical inventory error: ${error}`); -// } -// }; diff --git a/server/services/eom/eomService.ts b/server/services/eom/eomService.ts index 1fb67d7..159f291 100644 --- a/server/services/eom/eomService.ts +++ b/server/services/eom/eomService.ts @@ -4,10 +4,19 @@ const app = new OpenAPIHono(); import stats from "./route/stats.js"; import history from "./route/invHistory.js"; +import { createJob } from "../notifications/utils/processNotifications.js"; +import { historicalInvIMmport } from "./utils/historicalInv.js"; const routes = [stats, history] as const; const appRoutes = routes.forEach((route) => { app.route("/eom", route); }); +// setTimeout(() => { +// historicalInvIMmport(); +// }, 5 * 1000); +// the time we want to run the hostircal data should be the same time the historical data run on the server +// getting this from the shift time +createJob("eom_historical_inv", "0 7 * * *", historicalInvIMmport); + export default app; diff --git a/server/services/eom/utils/historicalInv.ts b/server/services/eom/utils/historicalInv.ts new file mode 100644 index 0000000..9e63f15 --- /dev/null +++ b/server/services/eom/utils/historicalInv.ts @@ -0,0 +1,101 @@ +import { sql } from "drizzle-orm"; +import { db } from "../../../../database/dbclient.js"; +import { invHistoricalData } from "../../../../database/schema/historicalINV.js"; +import { tryCatch } from "../../../globalUtils/tryCatch.js"; +import { createLog } from "../../logger/logger.js"; +import { query } from "../../sqlServer/prodSqlServer.js"; +import { totalInvNoRn } from "../../sqlServer/querys/dataMart/totalINV.js"; +import { format } from "date-fns-tz"; +import { serverSettings } from "../../server/controller/settings/getSettings.js"; +import { deleteHistory } from "./removeHistorical.js"; + +export const historicalInvIMmport = async () => { + const plantToken = serverSettings.filter((n) => n.name === "plantToken"); + const { data, error } = (await tryCatch( + db.select().from(invHistoricalData) + )) as any; + + if (error) { + createLog( + "error", + "eom", + "eom", + `There was an error getting the historical data` + ); + } + // check if we have data already for today this way we dont duplicate anything. + const today = new Date(); + today.setDate(today.getDate() - 1); + + const dateCheck = data?.filter( + (i: any) => i.histDate === format(today, "yyyy-MM-dd") + ); + + if (dateCheck.length === 0) { + // get the historical data from the sql + const { data: inv, error: invError } = (await tryCatch( + query(totalInvNoRn, "eom historical data") + )) as any; + + if (invError) { + createLog( + "error", + "eom", + "eom", + `There was an error getting the sql data` + ); + return; + } + + if (inv.data.length === 0) { + createLog("error", "eom", "eom", inv.message); + return; + } + + const importInv = inv.data ? inv.data : []; + const eomImportData = importInv.map((i: any) => { + return { + histDate: sql`(NOW() - INTERVAL '1 day')::date`, + plantToken: plantToken[0].value, + article: i.av, + articleDescription: i.Alias, + materialType: "", + total_QTY: i.Total_PalletQTY, + avaliable_QTY: i.Avaliable_PalletQTY, + coa_QTY: i.COA_QTY, + held_QTY: i.Held_QTY, + consignment: i.Consigment, + lot_Number: i.lot, + }; + }); + + const { data: dataImport, error: errorImport } = await tryCatch( + db.insert(invHistoricalData).values(eomImportData) + ); + + if (errorImport) { + createLog( + "error", + "eom", + "eom", + `There was an error importing all the inventory data.` + ); + return; + } + + if (dataImport) { + createLog( + "info", + "eom", + "eom", + `All data was imported succefully.` + ); + return; + } + } else { + createLog("info", "eom", "eom", `Yesterdays Data already in..`); + } + + // do the check to delete old data + deleteHistory(); +}; diff --git a/server/services/eom/utils/removeHistorical.ts b/server/services/eom/utils/removeHistorical.ts new file mode 100644 index 0000000..b7354d9 --- /dev/null +++ b/server/services/eom/utils/removeHistorical.ts @@ -0,0 +1,51 @@ +// import {prisma} from "database"; +// import {createLog} from "logging"; + +import { lte, sql } from "drizzle-orm"; +import { db } from "../../../../database/dbclient.js"; +import { invHistoricalData } from "../../../../database/schema/historicalINV.js"; +import { tryCatch } from "../../../globalUtils/tryCatch.js"; +import { createLog } from "../../logger/logger.js"; + +// export const deleteHistory = async (date: string) => { +// // delete the inventory if it equals this date +// try { +// const remove = await prisma.$executeRaw` +// DELETE FROM historyInventory +// WHERE histDate < ${date} +// `; +// createLog("general/eom", "info", `${remove} were just remove from the historical inventory for date: ${date}`); +// } catch (error) { +// createLog("general/eom", "error", `Removing historical inventory error: ${error}`); +// } +// }; + +export const deleteHistory = async () => { + const { data, error } = await tryCatch( + db + .delete(invHistoricalData) + .where( + lte( + invHistoricalData.histDate, + sql`(NOW() - INTERVAL '45 day')::date` + ) + ) + ); + + if (error) { + createLog( + "error", + "eom", + "eom", + "There was an error deleting the historical data." + ); + return; + } + + createLog( + "info", + "eom", + "eom", + "Data older than 45 days has been deleted." + ); +}; -- 2.49.1 From 8d63f7f6b0981d604b628ff2f710b8eb41d32837 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sun, 10 Aug 2025 18:11:57 -0500 Subject: [PATCH 028/166] feat(psi): psi querys added and av grab right now --- .../dataMart/controller/psiGetArticleData.ts | 47 ++++++++++++++ server/services/dataMart/dataMartService.ts | 2 + .../dataMart/route/getPsiArticleData.ts | 61 +++++++++++++++++++ .../sqlServer/querys/psiReport/articleData.ts | 40 ++++++++++++ .../querys/psiReport/deliveredData.ts | 19 ++++++ .../querys/psiReport/deliveryData.ts | 27 ++++++++ .../querys/psiReport/planningNumbersByAv.ts | 33 ++++++++++ .../querys/psiReport/prodcuctionNumbers.ts | 21 +++++++ 8 files changed, 250 insertions(+) create mode 100644 server/services/dataMart/controller/psiGetArticleData.ts create mode 100644 server/services/dataMart/route/getPsiArticleData.ts create mode 100644 server/services/sqlServer/querys/psiReport/articleData.ts create mode 100644 server/services/sqlServer/querys/psiReport/deliveredData.ts create mode 100644 server/services/sqlServer/querys/psiReport/deliveryData.ts create mode 100644 server/services/sqlServer/querys/psiReport/planningNumbersByAv.ts create mode 100644 server/services/sqlServer/querys/psiReport/prodcuctionNumbers.ts diff --git a/server/services/dataMart/controller/psiGetArticleData.ts b/server/services/dataMart/controller/psiGetArticleData.ts new file mode 100644 index 0000000..a597d3a --- /dev/null +++ b/server/services/dataMart/controller/psiGetArticleData.ts @@ -0,0 +1,47 @@ +import { tryCatch } from "../../../globalUtils/tryCatch.js"; +import { createLog } from "../../logger/logger.js"; +import { query } from "../../sqlServer/prodSqlServer.js"; +import { articleInfo } from "../../sqlServer/querys/psiReport/articleData.js"; + +// type ArticleData = { +// id: string +// } +export const getGetPSIArticleData = async (avs: string) => { + let articles: any = []; + + if (!avs) { + return { + success: false, + message: `Missing av's please send at least one over`, + data: [], + }; + } + + const { data, error } = (await tryCatch( + query(articleInfo.replace("[articles]", avs), "PSI article info") + )) as any; + + if (error) { + createLog( + "error", + "datamart", + "datamart", + `There was an error getting the article info: ${JSON.stringify( + error + )}` + ); + return { + success: false, + messsage: `There was an error getting the article info`, + data: error, + }; + } + + articles = data.data; + + return { + success: true, + message: "PSI Article Data", + data: articles, + }; +}; diff --git a/server/services/dataMart/dataMartService.ts b/server/services/dataMart/dataMartService.ts index 20d6c00..51ab8c6 100644 --- a/server/services/dataMart/dataMartService.ts +++ b/server/services/dataMart/dataMartService.ts @@ -9,6 +9,7 @@ import fakeEDI from "./route/fakeEDI.js"; import addressCorrections from "./route/getCityStateData.js"; import fifoIndex from "./route/getFifoIndex.js"; import financeAudit from "./route/getFinanceAudit.js"; +import psiArticleData from "./route/getPsiArticleData.js"; const app = new OpenAPIHono(); @@ -23,6 +24,7 @@ const routes = [ addressCorrections, fifoIndex, financeAudit, + psiArticleData, ] as const; const appRoutes = routes.forEach((route) => { diff --git a/server/services/dataMart/route/getPsiArticleData.ts b/server/services/dataMart/route/getPsiArticleData.ts new file mode 100644 index 0000000..3cbc060 --- /dev/null +++ b/server/services/dataMart/route/getPsiArticleData.ts @@ -0,0 +1,61 @@ +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; +import { responses } from "../../../globalUtils/routeDefs/responses.js"; +import { tryCatch } from "../../../globalUtils/tryCatch.js"; +import { getDeliveryByDateRange } from "../controller/getDeliveryByDateRange.js"; +import { apiHit } from "../../../globalUtils/apiHits.js"; +import { getGetPSIArticleData } from "../controller/psiGetArticleData.js"; + +const app = new OpenAPIHono({ strict: false }); +const Body = z.object({ + includeRunnningNumbers: z.string().openapi({ example: "x" }), +}); +app.openapi( + createRoute({ + tags: ["dataMart"], + summary: "Returns the psiarticleData.", + method: "get", + path: "/psiarticledata", + request: { + body: { + content: { + "application/json": { schema: Body }, + }, + }, + }, + responses: responses(), + }), + async (c) => { + const articles: any = c.req.queries(); + + // make sure we have a vaid user being accessed thats really logged in + apiHit(c, { endpoint: "/psiarticledata" }); + //console.log(articles["avs"][0]); + const { data, error } = await tryCatch( + getGetPSIArticleData(articles ? articles["avs"][0] : null) + ); + + if (error) { + console.log(error); + return c.json( + { + success: false, + message: "There was an error getting the articles.", + data: error, + }, + 400 + ); + } + + //console.log(data); + + return c.json( + { + success: data.success, + message: data.message, + data: data.data, + }, + data.success ? 200 : 400 + ); + } +); +export default app; diff --git a/server/services/sqlServer/querys/psiReport/articleData.ts b/server/services/sqlServer/querys/psiReport/articleData.ts new file mode 100644 index 0000000..90a99b2 --- /dev/null +++ b/server/services/sqlServer/querys/psiReport/articleData.ts @@ -0,0 +1,40 @@ +export const articleInfo = ` +use [test1_AlplaPROD2.0_Read] + +select a.Id, +a.HumanReadableId as av, +a.Alias as alias, +p.LoadingUnitsPerTruck as loadingUnitsPerTruck, +p.LoadingUnitsPerTruck * p.LoadingUnitPieces as qtyPerTruck, +p.LoadingUnitPieces, +case when i.MinQuantity IS NOT NULL then round(cast(i.MinQuantity as float), 2) else 0 end as min, +case when i.MaxQuantity IS NOT NULL then round(cast(i.MaxQuantity as float),2) else 0 end as max +from masterData.Article (nolock) as a + +/* sales price */ +left join +(select * + from (select + id, + PackagingId, + ArticleId, + DefaultCustomer, + ROW_NUMBER() OVER (PARTITION BY ArticleId ORDER BY ValidAfter DESC) AS RowNum + from masterData.SalesPrice (nolock) + where DefaultCustomer = 1) as x + where RowNum = 1 + ) as s +on a.id = s.ArticleId + +/* pkg instuctions */ +left join +masterData.PackagingInstruction (nolock) as p +on s.PackagingId = p.id + +/* stock limits */ +left join +masterData.StockLimit (nolock) as i +on a.id = i.ArticleId + +where a.active = 1 and a.HumanReadableId in ([articles]) +`; diff --git a/server/services/sqlServer/querys/psiReport/deliveredData.ts b/server/services/sqlServer/querys/psiReport/deliveredData.ts new file mode 100644 index 0000000..24960bf --- /dev/null +++ b/server/services/sqlServer/querys/psiReport/deliveredData.ts @@ -0,0 +1,19 @@ +export const psiDeliveredData = ` +use AlplaPROD_test1 + +declare @start_date nvarchar(30) = [startDate] --'2025-01-01' +declare @end_date nvarchar(30) = [endDate] --'2025-08-09' + + +select IdArtikelVarianten, +ArtikelVariantenBez, +sum(Menge) totalDelivered, +case when convert(time, upd_date) between '00:00' and '07:00' then convert(date, upd_date - 1) else convert(date, upd_date) end as ShippingDate + +from dbo.V_LadePlanungenLadeAuftragAbruf (nolock) + +where upd_date between CONVERT(datetime, @start_date + ' 7:00') and CONVERT(datetime, @end_date + ' 7:00') and IdArtikelVarianten in ([articles]) + +group by IdArtikelVarianten, upd_date, +ArtikelVariantenBez +`; diff --git a/server/services/sqlServer/querys/psiReport/deliveryData.ts b/server/services/sqlServer/querys/psiReport/deliveryData.ts new file mode 100644 index 0000000..9ad7fe1 --- /dev/null +++ b/server/services/sqlServer/querys/psiReport/deliveryData.ts @@ -0,0 +1,27 @@ +export const psiDeliveredData = ` + +use [test1_AlplaPROD2.0_Read] + +declare @start_date nvarchar(30) = [startDate] --'2025-01-01' +declare @end_date nvarchar(30) = [endDate] --'2025-08-09' + +select +ArticleHumanReadableId, +ArticleAlias, +cast(Quantity as int) Quantity, +--cast(DeliveryDate as time) as deliveryTime, +--cast(DeliveryDate as date) as originalDeliveryDate, +case when cast(DeliveryDate as time) between '00:00' and '07:00' + then DATEADD(DAY, -1, CONVERT(DATE, DeliveryDate)) + else cast(DeliveryDate as date) + end as ShippingDate +--,* +from [order].[Release] + +where case when cast(DeliveryDate as time) between '00:00' and '07:00' + then DATEADD(DAY, -1, CONVERT(DATE, DeliveryDate)) + else cast(DeliveryDate as date) + end between @start_date and @end_date + and ArticleHumanReadableId in ([articles]) + +order by DeliveryDate`; diff --git a/server/services/sqlServer/querys/psiReport/planningNumbersByAv.ts b/server/services/sqlServer/querys/psiReport/planningNumbersByAv.ts new file mode 100644 index 0000000..e3d1570 --- /dev/null +++ b/server/services/sqlServer/querys/psiReport/planningNumbersByAv.ts @@ -0,0 +1,33 @@ +export const planningNumbersByAVDate = ` +use AlplaPROD_test1 +declare @start_date nvarchar(30) = [startDate] --'2025-01-01' +declare @end_date nvarchar(30) = [endDate] --'2025-08-09' +/* +articles will need to be passed over as well as the date structure we want to see +*/ + +-- planned lots in planning + +select V_ProdLosProduktionJeProdTag_PLANNING.IdArtikelvarianten As Article, +ProduktionAlias as Description, +standort as MachineId, +MaschinenBezeichnung as MachineName, +--MaschZyklus as PlanningCycleTime, +V_ProdLosProduktionJeProdTag_PLANNING.IdProdPlanung as LotNumber, +FORMAT(ProdTag, 'MM/dd/yyyy') as ProductionDay, +V_ProdLosProduktionJeProdTag_PLANNING.planMenge as TotalPlanned, +ProduktionMenge as QTYPerDay, +round(ProduktionMengeVPK, 2) PalDay, +Status as finished +--MaschStdAuslastung as nee + +from dbo.V_ProdLosProduktionJeProdTag_PLANNING (nolock) + +left join +dbo.V_ProdPlanung (nolock) on +V_ProdLosProduktionJeProdTag_PLANNING .IdProdPlanung = V_ProdPlanung.IdProdPlanung + +where V_ProdLosProduktionJeProdTag_PLANNING.IdArtikelvarianten in ([articles]) and ProdTag between @start_date and @end_date --and IdProdPlanung = 18442 + +order by ProdTag +`; diff --git a/server/services/sqlServer/querys/psiReport/prodcuctionNumbers.ts b/server/services/sqlServer/querys/psiReport/prodcuctionNumbers.ts new file mode 100644 index 0000000..be13677 --- /dev/null +++ b/server/services/sqlServer/querys/psiReport/prodcuctionNumbers.ts @@ -0,0 +1,21 @@ +export const productionNumbers = ` +use [test1_AlplaPROD2.0_Reporting] + +declare @startDate nvarchar(30) = [startDate] --'2024-12-30' +declare @endDate nvarchar(30) = [endDate] --'2025-08-09' + +select MachineLocation, +ArticleHumanReadableId as article, +sum(Quantity) as Produced, +count(Quantity) as palletsProdued, +FORMAT(convert(date, ProductionDay), 'M/d/yyyy') as ProductionDay, +ProductionLotHumanReadableId as productionLot + +from [reporting_productionControlling].[ScannedUnit] (nolock) + +where convert(date, ProductionDay) between @startDate and @endDate and ArticleHumanReadableId in ([articles]) and BookedOut is null + +group by MachineLocation, ArticleHumanReadableId,ProductionDay, ProductionLotHumanReadableId + +order by ProductionDay +`; -- 2.49.1 From 397f1da595fd8a1e1c2a630a3650eb8715604c82 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sun, 10 Aug 2025 18:12:29 -0500 Subject: [PATCH 029/166] fix(inv query): error in improper placed , in the query --- .../sqlServer/querys/dataMart/totalINV.ts | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/server/services/sqlServer/querys/dataMart/totalINV.ts b/server/services/sqlServer/querys/dataMart/totalINV.ts index a05fd8e..2e5cf41 100644 --- a/server/services/sqlServer/querys/dataMart/totalINV.ts +++ b/server/services/sqlServer/querys/dataMart/totalINV.ts @@ -1,21 +1,22 @@ // this query pulls all the inventory except the inv locations. export const totalInvNoRn = ` -select x.idartikelVarianten as av, -ArtikelVariantenAlias as Alias, +select +x.idartikelVarianten as av, +x.ArtikelVariantenAlias as Alias --x.Lfdnr as RunningNumber, -round(sum(EinlagerungsMengeVPKSum),0) as Total_Pallets, -sum(EinlagerungsMengeSum) as Total_PalletQTY, -round(sum(VerfuegbareMengeVPKSum),0) as Avalible_Pallets, -sum(VerfuegbareMengeSum) as Avaliable_PalletQTY, -sum(case when c.Description LIKE '%COA%' then GesperrteMengeVPKSum else 0 end) as COA_Pallets, -sum(case when c.Description LIKE '%COA%' then GesperrteMengeSum else 0 end) as COA_QTY, -sum(case when c.Description NOT LIKE '%COA%' or x.IdMainDefect = -1 then GesperrteMengeVPKSum else 0 end) as Held_Pallets, -sum(case when c.Description NOT LIKE '%COA%' or x.IdMainDefect = -1 then GesperrteMengeSum else 0 end) as Held_QTY +,round(sum(EinlagerungsMengeVPKSum),0) as Total_Pallets +,sum(EinlagerungsMengeSum) as Total_PalletQTY +,round(sum(VerfuegbareMengeVPKSum),0) as Avalible_Pallets +,sum(VerfuegbareMengeSum) as Avaliable_PalletQTY +,sum(case when c.Description LIKE '%COA%' then GesperrteMengeVPKSum else 0 end) as COA_Pallets +,sum(case when c.Description LIKE '%COA%' then GesperrteMengeSum else 0 end) as COA_QTY +,sum(case when c.Description NOT LIKE '%COA%' or x.IdMainDefect = -1 then GesperrteMengeVPKSum else 0 end) as Held_Pallets +,sum(case when c.Description NOT LIKE '%COA%' or x.IdMainDefect = -1 then GesperrteMengeSum else 0 end) as Held_QTY ,sum(case when x.WarenLagerLagerTyp = 8 then VerfuegbareMengeSum else 0 end) as Consigment ,IdProdPlanung as Lot ---,IdAdressen, -x.AdressBez +----,IdAdressen, +,x.AdressBez --,* from [AlplaPROD_test1].dbo.[V_LagerPositionenBarcodes] (nolock) x -- 2.49.1 From 2eb6fa77946d5f8572ffc5baa47da602482bce2b Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sun, 10 Aug 2025 18:12:52 -0500 Subject: [PATCH 030/166] fix(gotransport): error handling so we dont get spammed with errors --- server/services/logger/goTransport.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/server/services/logger/goTransport.ts b/server/services/logger/goTransport.ts index 32fb828..e75f400 100644 --- a/server/services/logger/goTransport.ts +++ b/server/services/logger/goTransport.ts @@ -2,6 +2,7 @@ process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; import axios from "axios"; import { pino } from "pino"; import build from "pino-abstract-transport"; +import { tryCatch } from "../../globalUtils/tryCatch.js"; const pinoLogLevels: any = { 10: "trace", @@ -26,12 +27,19 @@ export default async function buildGoTransport() { // service: obj?.service.toLowerCase(), // message: obj.msg, // }); + const { data, error } = (await tryCatch( + axios.post(`${process.env.LST_BASE_URL}/api/v1/log`, { + service: obj?.service.toLowerCase(), + level: levelName, + message: obj.msg, + }) + )) as any; - axios.post(`${process.env.LST_BASE_URL}/api/v1/log`, { - service: obj?.service.toLowerCase(), - level: levelName, - message: obj.msg, - }); + if (error) { + console.log( + "The go server must be offline so we cant post the new logs." + ); + } // console.log(`Go log level: ${levelName}`); } -- 2.49.1 From 103171c924a9de78b0a7600abb455fdd6f4bfea1 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sun, 10 Aug 2025 18:13:32 -0500 Subject: [PATCH 031/166] refactor(notifications): refactored the cron job system so we can utilize outside the service --- server/services/notifications/utils/processNotifications.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/services/notifications/utils/processNotifications.ts b/server/services/notifications/utils/processNotifications.ts index 1339cd1..c65f6f2 100644 --- a/server/services/notifications/utils/processNotifications.ts +++ b/server/services/notifications/utils/processNotifications.ts @@ -105,7 +105,7 @@ export const startNotificationMonitor = async () => { }, 5 * 1000); }; -const createJob = async ( +export const createJob = async ( id: string, schedule: string, task: () => Promise -- 2.49.1 From 6ccf500e5eb82125f7bcd3d764282a4b8a750be9 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sun, 10 Aug 2025 18:14:08 -0500 Subject: [PATCH 032/166] feat(prodrole): added in planner role --- server/services/prodUser/utils/prodRoles.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/server/services/prodUser/utils/prodRoles.ts b/server/services/prodUser/utils/prodRoles.ts index d20edb3..e61b050 100644 --- a/server/services/prodUser/utils/prodRoles.ts +++ b/server/services/prodUser/utils/prodRoles.ts @@ -50,6 +50,18 @@ const newProdRoles: any = [ }, // logistics + { + name: "planner", + description: "Planning role.", + roles: [ + "Administration\\Scan\\ApiConsumer", + "Administration\\Printing\\ApiConsumer", + "Logistics\\Warehousing\\ProcessAdmin", + "Manufacturing\\IssueMaterial\\ProcessAdmin", + "Manufacturing\\ProductionLabelling\\ProcessAdmin", + ], + rolesLegacy: [55, 95, 15, 105, 145, 9], + }, // plant manager { name: "plantManager", -- 2.49.1 From 8145dc800dced31860a926c80eca72cb39433b29 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sun, 10 Aug 2025 18:14:38 -0500 Subject: [PATCH 033/166] refactor(siloadjustment): refactored to get the settings from the state vs direct from db --- .../siloAdjustments/createSiloAdjustment.ts | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/server/services/logistics/controller/siloAdjustments/createSiloAdjustment.ts b/server/services/logistics/controller/siloAdjustments/createSiloAdjustment.ts index 68cf1c0..764935d 100644 --- a/server/services/logistics/controller/siloAdjustments/createSiloAdjustment.ts +++ b/server/services/logistics/controller/siloAdjustments/createSiloAdjustment.ts @@ -9,6 +9,10 @@ import { sendEmail } from "../../../notifications/controller/sendMail.js"; import { settings } from "../../../../../database/schema/settings.js"; import { generateOneTimeKey } from "../../../../globalUtils/singleUseKey.js"; import { eq } from "drizzle-orm"; +import { + getSettings, + serverSettings, +} from "../../../server/controller/settings/getSettings.js"; export const createSiloAdjustment = async ( data: any | null, @@ -18,18 +22,21 @@ export const createSiloAdjustment = async ( * Creates a silo adjustment based off warehouse, location, and qty. * qty will come from the hmi, prolink, or silo patrol */ - const { data: set, error: setError } = await tryCatch( - db.select().from(settings) - ); + // const { data: set, error: setError } = await tryCatch( + // db.select().from(settings) + // ); - if (setError) { - return { - success: false, - message: `There was an error getting setting data to post to the server.`, - data: setError, - }; - } + // const { data: set, error: setError } = await tryCatch(getSettings()); + // if (setError) { + // return { + // success: false, + // message: `There was an error getting setting data to post to the server.`, + // data: setError, + // }; + // } + + const set = serverSettings.length === 0 ? [] : serverSettings; // getting stock data first so we have it prior to the adjustment const { data: s, error: stockError } = await tryCatch( query(siloQuery, "Silo data Query") -- 2.49.1 From 2ff7b9baf9ca288f8a33bec3ab1a2ba331ace6b9 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sun, 10 Aug 2025 18:15:07 -0500 Subject: [PATCH 034/166] refactor(migrations): not needed but we have it and needed to correct the settings --- .../siloAdjustments/migrateAdjustments.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/server/services/logistics/controller/siloAdjustments/migrateAdjustments.ts b/server/services/logistics/controller/siloAdjustments/migrateAdjustments.ts index 2060884..f54ffa0 100644 --- a/server/services/logistics/controller/siloAdjustments/migrateAdjustments.ts +++ b/server/services/logistics/controller/siloAdjustments/migrateAdjustments.ts @@ -12,18 +12,25 @@ import { delay } from "../../../../globalUtils/delay.js"; import { tryCatch } from "../../../../globalUtils/tryCatch.js"; import { settings } from "../../../../../database/schema/settings.js"; import { eq } from "drizzle-orm"; +import { + getSettings, + serverSettings, +} from "../../../server/controller/settings/getSettings.js"; export const migrateAdjustments = async () => { /** * Migrates the silo adjustments from v1 to v2 */ - const { data, error } = await tryCatch(db.select().from(settings)); + //const { data, error } = await tryCatch(db.select().from(settings)); + // const { data, error } = await tryCatch(getSettings()); - if (error) { - createLog("error", "silo", "logistics", "Getting settings."); - return; - } + // if (error) { + // createLog("error", "silo", "logistics", "Getting settings."); + // return; + // } + + const data = serverSettings.length === 0 ? [] : serverSettings; const migrationCompleted = data?.filter( (n) => n.name === "siloAdjMigrations" @@ -44,7 +51,7 @@ export const migrateAdjustments = async () => { } const { data: s, error: siloError } = await tryCatch( axios.get( - `http://${server[0].value}:${port[0].value}/api/v1/warehouse/getSilosAdjustment?startDate=1/1/2020&endDate=4/1/2026` + `http://${server[0]?.value}:${port[0]?.value}/api/v1/warehouse/getSilosAdjustment?startDate=1/1/2020&endDate=4/1/2026` ) ); -- 2.49.1 From e14abd36449b3e3b34af3aa3fc4017f8cbe1ef92 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 11 Aug 2025 08:22:44 -0500 Subject: [PATCH 035/166] ci(release): bump build number to 549 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6cb2157..d175291 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 548, + "build": 549, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 7f81a2e09ab196a68d834e7499e0660f14bebcdd Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 11 Aug 2025 12:24:30 -0500 Subject: [PATCH 036/166] ci(release): bump build number to 550 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d175291..fd12ead 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 549, + "build": 550, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 27b37f984962bfaef444157bb3b094358f0a68ab Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 12 Aug 2025 11:24:50 -0500 Subject: [PATCH 037/166] ci(release): bump build number to 551 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fd12ead..ce35fa4 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 550, + "build": 551, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From ca968499917b612fe0d6d4537c2586c2e62d541b Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 12 Aug 2025 13:55:49 -0500 Subject: [PATCH 038/166] ci(release): bump build number to 552 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ce35fa4..86e3414 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 551, + "build": 552, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 1498a1912139724960796df44803291de0b6157b Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 12 Aug 2025 14:28:42 -0500 Subject: [PATCH 039/166] ci(release): bump build number to 553 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 86e3414..30f7e3d 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 552, + "build": 553, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 835ae58f04d8c0a6c45c25d9e7d0b9ad5651c287 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 12 Aug 2025 16:26:39 -0500 Subject: [PATCH 040/166] ci(release): bump build number to 554 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 30f7e3d..8291d36 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 553, + "build": 554, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 83469105f0e53a641fa1b2874b0937516bb468bd Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 12 Aug 2025 17:53:08 -0500 Subject: [PATCH 041/166] ci(release): bump build number to 555 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8291d36..d82db96 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 554, + "build": 555, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From a84998438cde5081bc9b5e77fe3326dfc14835b9 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 13 Aug 2025 11:33:45 -0500 Subject: [PATCH 042/166] ci(release): bump build number to 556 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d82db96..b2232ba 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 555, + "build": 556, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From f16e2bf53bbff2e3e172785ab9189f58c4a97186 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 13 Aug 2025 15:50:35 -0500 Subject: [PATCH 043/166] ci(release): bump build number to 557 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b2232ba..8dbd6df 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 556, + "build": 557, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From ed9399216580e8b6755a025d913771911de64c26 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 13 Aug 2025 16:32:23 -0500 Subject: [PATCH 044/166] ci(release): bump build number to 558 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8dbd6df..ed1ab92 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 557, + "build": 558, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 4669ff95dc54d12842ad052e9f54e8fe931be5c5 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 13 Aug 2025 22:52:44 -0500 Subject: [PATCH 045/166] ci(release): bump build number to 559 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ed1ab92..2a97ed7 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 558, + "build": 559, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 5156c8bf7b5c3fff67da8878867257dfa166fc96 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 14 Aug 2025 09:32:25 -0500 Subject: [PATCH 046/166] ci(release): bump build number to 560 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2a97ed7..807d9cc 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 559, + "build": 560, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From a18327926812b136ea73e3c4fb1137b01daf7759 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sun, 17 Aug 2025 18:10:25 -0500 Subject: [PATCH 047/166] ci(release): bump build number to 561 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 807d9cc..5d31419 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 560, + "build": 561, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 88f61c8eaa32a581094b04b5e18c654040dbeb92 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 19 Aug 2025 16:00:49 -0500 Subject: [PATCH 048/166] feat(ocp): materials contorls and transfer to next lot logic --- .../eom/materialCheck/MaterialCheck.tsx | 3 + .../eom/materialsData/MaterialData.tsx | 211 +++++++++++++++ .../consumption/TransferToNextLot.tsx | 250 ++++++++++++++++++ .../ocp/controller/labeling/labelProcess.ts | 13 +- .../ocp/controller/materials/lotTransfer.ts | 206 +++++++++++++++ .../ocp/controller/materials/mainMaterial.ts | 114 +++++++- server/services/ocp/ocpService.ts | 4 + .../ocp/routes/materials/lotTransfer.ts | 64 +++++ server/services/server/utils/settingsCheck.ts | 14 + .../sqlServer/querys/ocp/mainMaterial.ts | 127 +++++++-- .../sqlServer/querys/warehouse/labelInfo.ts | 44 ++- 11 files changed, 997 insertions(+), 53 deletions(-) create mode 100644 frontend/src/components/eom/materialCheck/MaterialCheck.tsx create mode 100644 frontend/src/components/eom/materialsData/MaterialData.tsx create mode 100644 frontend/src/components/logistics/materialHelper/consumption/TransferToNextLot.tsx create mode 100644 server/services/ocp/controller/materials/lotTransfer.ts create mode 100644 server/services/ocp/routes/materials/lotTransfer.ts diff --git a/frontend/src/components/eom/materialCheck/MaterialCheck.tsx b/frontend/src/components/eom/materialCheck/MaterialCheck.tsx new file mode 100644 index 0000000..bb3b9fc --- /dev/null +++ b/frontend/src/components/eom/materialCheck/MaterialCheck.tsx @@ -0,0 +1,3 @@ +export default function MaterialCheck() { + return
MaterialCheck
; +} diff --git a/frontend/src/components/eom/materialsData/MaterialData.tsx b/frontend/src/components/eom/materialsData/MaterialData.tsx new file mode 100644 index 0000000..4023908 --- /dev/null +++ b/frontend/src/components/eom/materialsData/MaterialData.tsx @@ -0,0 +1,211 @@ +import { LstCard } from "@/components/extendedUI/LstCard"; +import { Button } from "@/components/ui/button"; +import { Calendar } from "@/components/ui/calendar"; +import { Popover, PopoverTrigger } from "@/components/ui/popover"; +import { Skeleton } from "@/components/ui/skeleton"; +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "@/components/ui/table"; +import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; +import { useSessionStore } from "@/lib/store/sessionStore"; +import { useModuleStore } from "@/lib/store/useModuleStore"; +import { cn } from "@/lib/utils"; +import { PopoverContent } from "@radix-ui/react-popover"; +import { Link, useRouter } from "@tanstack/react-router"; +import { startOfMonth } from "date-fns"; +import { format } from "date-fns-tz"; +import { CalendarIcon } from "lucide-react"; +import { useState } from "react"; +import { toast } from "sonner"; +import KFP from "../KFP"; + +export default function MaterialData() { + const { modules } = useModuleStore(); + const { user } = useSessionStore(); + const router = useRouter(); + const [date, setDate] = useState(); + + if (!user) { + router.navigate({ to: "/" }); + } + const eomMod = modules.filter((m) => m.name === "eom"); + // the users current role for eom is? + const role: any = + user?.roles.filter((r) => r.module_id === eomMod[0].module_id) || ""; + + const tabs = [ + { + key: "kfp", + label: "Key Figures", + roles: ["admin", "systemAdmin"], + content: , + }, + { + key: "fg", + label: "Finished Goods", + roles: ["admin", "systemAdmin"], + content: , + }, + { + key: "mm", + label: "Main Material", + roles: ["admin", "systemAdmin"], + content: , + }, + { + key: "mb", + label: "Master Batch", + roles: ["admin", "systemAdmin"], + content: , + }, + { + key: "ab", + label: "Additive", + roles: ["admin", "systemAdmin"], + content: , + }, + { + key: "pp", + label: "Purchased Preforms", + roles: ["admin", "systemAdmin"], + content: , + }, + { + key: "pre", + label: "Preforms", + roles: ["admin", "systemAdmin"], + content: , + }, + { + key: "pkg", + label: "Packaging", + roles: ["admin", "systemAdmin"], + content: , + }, + { + key: "ui", + label: "Undefined Items", + roles: ["admin"], + content: , + }, + ]; + return ( +
+
+ + + + + + + + +
+ +
+
+ + + + {tabs.map((tab) => { + if (tab.roles.includes(role[0].role)) + return ( + + {tab.label} + + ); + })} + + {tabs.map((tab) => { + if (tab.roles.includes(role[0].role)) + return ( + + {tab.content} + + ); + })} + +
+ ); +} + +function DummyContent() { + return ( + + + + + Av + Description + Material Type + Waste + Loss / Gain $$ + + + + + {Array(10) + .fill(0) + .map((_, i) => ( + + + + {i} + + + + + + + + + + + + + + + {/* + + */} + + ))} + +
+
+ ); +} diff --git a/frontend/src/components/logistics/materialHelper/consumption/TransferToNextLot.tsx b/frontend/src/components/logistics/materialHelper/consumption/TransferToNextLot.tsx new file mode 100644 index 0000000..b517184 --- /dev/null +++ b/frontend/src/components/logistics/materialHelper/consumption/TransferToNextLot.tsx @@ -0,0 +1,250 @@ +import { LstCard } from "@/components/extendedUI/LstCard"; +import { Button } from "@/components/ui/button"; +import { CardHeader } from "@/components/ui/card"; +import { useAppForm } from "@/utils/formStuff"; +import axios from "axios"; +import { useState } from "react"; +import { toast } from "sonner"; + +export default function TransferToNextLot() { + const [gaylordFilled, setGaylordFilled] = useState([0]); + + const form = useAppForm({ + defaultValues: { + runnungNumber: "", + lotNumber: "", + originalAmount: "", + }, + onSubmit: async ({ value }) => { + //console.log(transferData); + //toast.success("603468: qty: 361, was transfered to lot:24897"); + try { + const res = await axios.post("/api/ocp/materiallottransfer", { + runnungNumber: Number(value.runnungNumber), + lotNumber: Number(value.lotNumber), + originalAmount: Number(value.originalAmount), + level: Number( + gaylordFilled.length === 1 + ? 0.25 + : gaylordFilled.length === 2 + ? 0.5 + : gaylordFilled.length === 3 + ? 0.75 + : gaylordFilled.length === 4 && 0.95 + ), + }); + + if (res.data.success) { + toast.success(`${res.data.message}`); + form.reset(); + } + //console.log(res.data); + + if (!res.data.success) { + toast.error(res.data.message); + } + } catch (error) { + if (error) { + console.log(error); + //toast.error(error) + } + } + }, + }); + return ( +
+ + +

+ Material Transfer to Next lot +

+
+
+
+
+
+ +
+ + + + +
+
+ +
+
+
+
+
+ +
{ + e.preventDefault(); + form.handleSubmit(); + }} + > +
+ ( + + )} + /> +
+
+ ( + + )} + /> +
+ ( + + )} + /> +
+
+
+ + + Transfer To Lot + + +
+
+
+
+
+
+
+ + +

+ Moving material to the next lot. +

+
+ +
+
    +
  1. + 1. Grab the gaylord running number + from the gaylord at the line/next to + the tschritter +
  2. +
  3. + 2. Grab the next lot number you are + going to be running (or the one that + state no Main material prepared) +
  4. +
  5. + 3. Enter the total gaylord weight + (this is how much the gaylord + weighed when it came in from the + supplier.) +
  6. +
  7. + 4. *Click the level of the gaylord + (this is just an estimate to move to + the next lot.) +
  8. +
  9. + 5. type in running number on the + gaylord. +
  10. +
  11. 6. Type in the new lot number.
  12. +
  13. 7. Press "Transfer To Lot"
  14. +
+

+

+ * to reduce the time needed to get the + lot going we will use an estimate of how + full the gaylord is. +

+

+ NOTE: This is not the return process, + this process will just get the gaylord + to the next lot. +

+
+
+
+
+
+
+
+ ); +} diff --git a/server/services/ocp/controller/labeling/labelProcess.ts b/server/services/ocp/controller/labeling/labelProcess.ts index 04b4a80..2da4e2d 100644 --- a/server/services/ocp/controller/labeling/labelProcess.ts +++ b/server/services/ocp/controller/labeling/labelProcess.ts @@ -170,20 +170,15 @@ export const labelingProcess = async ({ }; } - // check mm is good + // check the material... mm,color (auto and manual combined), pkg const mmStaged = await isMainMatStaged(filteredLot[0]); - if (!mmStaged) { - createLog( - "error", - "labeling", - "ocp", - `Main material is not prepaired for lot ${filteredLot[0].lot}` - ); + if (!mmStaged.success) { + createLog("error", "labeling", "ocp", mmStaged.message); return { success: false, - message: `Main material is not prepaired for lot ${filteredLot[0].lot}`, + message: mmStaged.message, }; } diff --git a/server/services/ocp/controller/materials/lotTransfer.ts b/server/services/ocp/controller/materials/lotTransfer.ts new file mode 100644 index 0000000..b115267 --- /dev/null +++ b/server/services/ocp/controller/materials/lotTransfer.ts @@ -0,0 +1,206 @@ +import { eq } from "drizzle-orm"; +import { db } from "../../../../../database/dbclient.js"; +import { printerData } from "../../../../../database/schema/printers.js"; +import { runProdApi } from "../../../../globalUtils/runProdApi.js"; +import { tryCatch } from "../../../../globalUtils/tryCatch.js"; +import { createLog } from "../../../logger/logger.js"; +import { query } from "../../../sqlServer/prodSqlServer.js"; +import { labelInfo } from "../../../sqlServer/querys/warehouse/labelInfo.js"; + +type NewLotData = { + runnungNumber: number; + lotNumber: number; + originalAmount: number; + level: number; +}; + +/** + * Move manual material to a new lot. + * + * The data sent over should be + * Running number + * Lot number + * Orignal Quantity + * level of gaylord + */ +export const lotMaterialTransfer = async (data: NewLotData) => { + // get the barcode, and layoutID from the running number + const { data: label, error: labelError } = (await tryCatch( + query( + labelInfo.replace("[runningNr]", `${data.runnungNumber}`), + "Get label info" + ) + )) as any; + + if (labelError) { + createLog( + "error", + "materials", + "ocp", + "There was an error getting the label info" + ); + return { + success: false, + message: "There was an error getting the label info", + data: labelError, + }; + } + + // if ( + // label.data[0]?.stockStatus === "notOnStock" || + // label.data.length === 0 + // ) { + // createLog( + // "error", + // "materials", + // "ocp", + // `${data.runnungNumber}: dose not exist or no longer in stock.` + // ); + // return { + // success: false, + // message: `${data.runnungNumber}: dose not exist or no longer in stock.`, + // data: [], + // }; + // } + + if (label.data[0]?.stockStatus === "onStock") { + createLog( + "error", + "materials", + "ocp", + `${data.runnungNumber}: currently in stock and not consumed to a lot.` + ); + return { + success: false, + message: `${data.runnungNumber}: currently in stock and not consumed to a lot.`, + data: [], + }; + } + + // get the pdf24 printer id + const { data: printer, error: printerError } = (await tryCatch( + db.select().from(printerData).where(eq(printerData.name, "PDF24")) + )) as any; + + if (printerError) { + createLog( + "error", + "materials", + "ocp", + "There was an error the printer info" + ); + return { + success: false, + message: "There was an error the printer info", + data: printerError, + }; + } + // calculate the remaining amount bascially it will be orignal number * level sent over + // level should be sent in a decimal .25 .5 .75 .95 the 95 will allow basically the what looks to be a full gaylord but we always want to consume something + const newQty = (data.originalAmount * data.level).toFixed(0); + + // reprint the label and send it to pdf24 + const reprintData = { + clientId: 999, + runningNo: label?.data[0].runnungNumber, + printerId: printer[0].humanReadableId, + layoutId: label?.data[0].labelLayout, + noOfCopies: 0, + quantity: newQty, + } as any; + + const { data: reprint, error: reprintError } = (await tryCatch( + runProdApi({ + endpoint: "/public/v1.0/ProductionLabelling/ReprintLabel", + data: [reprintData], + }) + )) as any; + + if (!reprint.success) { + createLog( + "error", + "materials", + "ocp", + `RN:${data.runnungNumber}, Error: ${reprint.data.data.message}` + ); + return { + success: false, + message: `RN:${data.runnungNumber}, Error: ${reprint.data.data.message}`, + data: reprint, + }; + } + // return the label back to fm1 lane id 10001 + + const matReturnData = { + barcode: label?.data[0].Barcode, + laneId: 10001, + }; + const { data: matReturn, error: matReturError } = (await tryCatch( + runProdApi({ + endpoint: + "/public/v1.0/IssueMaterial/ReturnPartiallyConsumedManualMaterial", + data: [matReturnData], + }) + )) as any; + + if (!matReturn.success) { + createLog( + "error", + "materials", + "ocp", + `RN:${data.runnungNumber}, Error ${matReturn.data.data.errors[0].message}` + ); + return { + success: false, + message: `RN:${data.runnungNumber}, Error ${matReturn.data.data.errors[0].message}`, + data: matReturn, + }; + } + // consume to the lot provided. + const consumeLot = { + productionLot: data.lotNumber, + barcode: label?.data[0].Barcode, + }; + const { data: matConsume, error: matConsumeError } = (await tryCatch( + runProdApi({ + endpoint: + "/public/v1.0/IssueMaterial/ConsumeNonPreparedManualMaterial", + data: [consumeLot], + }) + )) as any; + + if (!matConsume.success) { + createLog( + "error", + "materials", + "ocp", + `RN:${data.runnungNumber}, Error ${matConsume.data.data.errors[0].message}` + ); + return { + success: false, + message: `RN:${data.runnungNumber}, Error ${matConsume.data.data.errors[0].message}`, + data: matConsume, + }; + } + + createLog( + "info", + "materials", + "ocp", + `RN:${data.runnungNumber}: qty: ${newQty}, was transfered to lot:${data.lotNumber}` + ); + return { + success: true, + message: `RN:${data.runnungNumber}: qty: ${newQty}, was transfered to lot:${data.lotNumber}`, + data: [], + }; +}; + +// setTimeout(async () => { +// lotMaterialTransfer({ +// runnungNumber: 603468, +// lotNumber: 24897, +// originalAmount: 380, +// level: 0.95, +// }); +// }, 5000); diff --git a/server/services/ocp/controller/materials/mainMaterial.ts b/server/services/ocp/controller/materials/mainMaterial.ts index cbe69b6..c47f660 100644 --- a/server/services/ocp/controller/materials/mainMaterial.ts +++ b/server/services/ocp/controller/materials/mainMaterial.ts @@ -1,12 +1,14 @@ import { tryCatch } from "../../../../globalUtils/tryCatch.js"; import { createLog } from "../../../logger/logger.js"; +import { serverSettings } from "../../../server/controller/settings/getSettings.js"; import { query } from "../../../sqlServer/prodSqlServer.js"; import { machineCheck } from "../../../sqlServer/querys/ocp/machineId.js"; import { mmQuery } from "../../../sqlServer/querys/ocp/mainMaterial.js"; export const isMainMatStaged = async (lot: any) => { + const set = serverSettings.length === 0 ? [] : serverSettings; // make staged false by deefault and error logged if theres an issue - let isStaged = false; + let isStaged = { message: "Material is staged", success: true }; const { data, error } = (await tryCatch( query( @@ -26,7 +28,10 @@ export const isMainMatStaged = async (lot: any) => { "ocp", `The machine dose not require mm to print and book in.` ); - return true; + return { + message: "Machine dose not require material to be staged", + success: true, + }; } // strangly the lot is not always sending over in slc so adding this in for now to see what line is cauing this issue @@ -51,20 +56,101 @@ export const isMainMatStaged = async (lot: any) => { const res: any = r.data; - createLog( - "info", - "mainMaterial", - "ocp", - `MainMaterial results: ${JSON.stringify(res)}` - ); - - if (res[0].Staged >= 1) { - isStaged = true; - } - - // if (res[0].noShortage === "good") { + // if (res[0].Staged >= 1) { // isStaged = true; // } + + createLog("info", "mainMaterial", "ocp", `Maint material query ran.`); + + const mainMateiral = res.filter((n: any) => n.IsMainMaterial); + + if (mainMateiral[0]?.noMaterialShortage === "no") { + isStaged = { + message: `Main material: ${mainMateiral[0].MaterialHumanReadableId} - ${mainMateiral[0].MaterialDescription}: is not staged for ${lot.lot} `, + success: false, + }; + } + + // we need to filter the color stuff and then look for includes instead of a standard name. this way we can capture a everything and not a single type + // for manual consume color if active to check colors + const checkColorSetting = set.filter((n) => n.name === "checkColor"); + + if (checkColorSetting[0].value === "1") { + const autoConsumeColor = res.filter( + (n: any) => !n.IsMainMaterial && !n.isManual + ); + if ( + autoConsumeColor.some( + (n: any) => n.autoConsumeCheck === "autoConsumeNOK" + ) + ) { + const onlyNOK = autoConsumeColor.filter( + (n: any) => n.autoConsumeCheck === "autoConsumeNOK" + ); + isStaged = { + message: `lot: ${lot.lot}, is missing: ${onlyNOK + .map( + (o: any) => + `${o.MaterialHumanReadableId} - ${o.MaterialDescription}` + ) + .join(",\n ")} for autoconsume`, + success: false, + }; + } + + // // for manual consume color + const manualConsumeColor = res.filter( + (n: any) => !n.IsMainMaterial && n.isManual + ); + if ( + manualConsumeColor.some( + (n: any) => n.noMaterialShortage === "yes" + ) + ) { + isStaged = { + message: `lot: ${lot.lot}, is missing: ${manualConsumeColor + .map( + (o: any) => + `${o.MaterialHumanReadableId} - ${o.MaterialDescription}` + ) + .join(",\n ")} for manual Material`, + success: false, + }; + } + } else { + createLog( + "info", + "mainMaterial", + "ocp", + "Color check is not active." + ); + } + + // // if we want to check the packaging + const checkPKGSetting = set.filter((n) => n.name === "checkPKG"); + if (checkPKGSetting[0].value === "1") { + const packagingCheck = res.filter( + (n: any) => !n.IsMainMaterial && n.isManual + ); + if (packagingCheck.some((n: any) => n.noPKGShortage === "noPkg")) { + isStaged = { + message: `lot: ${lot.lot}, is missing: ${packagingCheck + .map( + (o: any) => + `${o.MaterialHumanReadableId} - ${o.MaterialDescription}` + ) + .join(",\n ")} for pkg`, + success: false, + }; + } + } else { + createLog( + "info", + "mainMaterial", + "ocp", + "PKG check is not active." + ); + } } catch (err) { createLog( "error", diff --git a/server/services/ocp/ocpService.ts b/server/services/ocp/ocpService.ts index fafa6f5..0cc18ac 100644 --- a/server/services/ocp/ocpService.ts +++ b/server/services/ocp/ocpService.ts @@ -24,6 +24,7 @@ import { deleteLabels } from "../../globalUtils/dbCleanUp/labelCleanUp.js"; import bookInLabel from "./routes/labeling/bookIn.js"; import labelRatio from "./routes/labeling/getLabelRatio.js"; import resetRatio from "./routes/labeling/resetLabelRatio.js"; +import materialTransferLot from "./routes/materials/lotTransfer.js"; const app = new OpenAPIHono(); @@ -47,6 +48,8 @@ const routes = [ //dyco dycoCon, dycoClose, + // materials + materialTransferLot, ] as const; const setting = await db.select().from(settings); @@ -101,4 +104,5 @@ setInterval(() => { setInterval(() => { updatePrinters(); }, 1000 * 60 * 60 * 24); + export default app; diff --git a/server/services/ocp/routes/materials/lotTransfer.ts b/server/services/ocp/routes/materials/lotTransfer.ts new file mode 100644 index 0000000..34b8b21 --- /dev/null +++ b/server/services/ocp/routes/materials/lotTransfer.ts @@ -0,0 +1,64 @@ +// an external way to creating logs +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; +import { responses } from "../../../../globalUtils/routeDefs/responses.js"; +import { tryCatch } from "../../../../globalUtils/tryCatch.js"; +import { apiHit } from "../../../../globalUtils/apiHits.js"; + +import { lotMaterialTransfer } from "../../controller/materials/lotTransfer.js"; + +const app = new OpenAPIHono({ strict: false }); + +const LotTransfer = z.object({ + runnungNumber: z.number().openapi({ example: 1234 }), + lotNumber: z.number().openapi({ example: 1235 }), + originalAmount: z.number().openapi({ example: 457 }), + level: z.number().openapi({ examples: [0.24, 0.5, 0.75, 0.95] }), +}); + +app.openapi( + createRoute({ + tags: ["ocp"], + summary: "Transfers a gaylord of material to provided lot", + method: "post", + path: "/materiallottransfer", + request: { + body: { content: { "application/json": { schema: LotTransfer } } }, + }, + responses: responses(), + }), + async (c) => { + //const hours = c.req.query("hours"); + const { data: bodyData, error: bodyError } = await tryCatch( + c.req.json() + ); + apiHit(c, { endpoint: "/materiallottransfer", lastBody: bodyData }); + + if (bodyError) { + return c.json({ + success: false, + message: "You are missing data", + }); + } + + const { data: transferMaterial, error: transferError } = await tryCatch( + lotMaterialTransfer(bodyData) + ); + + if (transferError) { + console.log(transferError); + return c.json({ + success: false, + message: + "There was an error transfering the material to the next lot.", + data: transferError, + }); + } + + return c.json({ + success: transferMaterial.success, + message: transferMaterial.message, + data: transferMaterial.data, + }); + } +); +export default app; diff --git a/server/services/server/utils/settingsCheck.ts b/server/services/server/utils/settingsCheck.ts index ea3d9ce..377d6ce 100644 --- a/server/services/server/utils/settingsCheck.ts +++ b/server/services/server/utils/settingsCheck.ts @@ -245,6 +245,20 @@ const newSettings = [ roleToChange: "admin", }, // temp settings can be deleted at a later date once that code is removed + { + name: "checkColor", + value: `0`, + description: "Checks autoconsume and manual consume color", + serviceBelowsTo: "admin", + roleToChange: "admin", + }, + { + name: "checkPKG", + value: `0`, + description: "Checks checks if we have enough packaging or not", + serviceBelowsTo: "admin", + roleToChange: "admin", + }, { name: "siloAdjMigrations", value: `0`, diff --git a/server/services/sqlServer/querys/ocp/mainMaterial.ts b/server/services/sqlServer/querys/ocp/mainMaterial.ts index 019e77e..fc6e3e1 100644 --- a/server/services/sqlServer/querys/ocp/mainMaterial.ts +++ b/server/services/sqlServer/querys/ocp/mainMaterial.ts @@ -1,22 +1,117 @@ +// export const mmQuery = ` +// SELECT lot.ProductionLotHumanReadableId, +// case when SourcingState in (1, 2) then 1 +// when x.ProvidedAmount > 0 then 1 +// when x.EffectiveConsumption > 0 then 1 +// else 0 end as Staged, +// x.ProvidedAmount as Provided, +// x.EffectiveConsumption as consumption, +// x.TotalDemand as totalNeeded, +// /* remaining needed to complete the lot */ +// x.TotalDemand - x.EffectiveConsumption as remainingNeeded, +// /* do we have enough staged or scanned to the lot? */ +// case when (case when x.ProvidedAmount <> 0 then x.ProvidedAmount else x.EffectiveConsumption end) > x.TotalDemand then 'good' else 'bad' end as noShortage , +// x.IsManualProcess as isManual, +// MaterialHumanReadableId +// FROM [test1_AlplaPROD2.0_Read].[issueMaterial].[MaterialDemand] x (nolock) +// left join +// [test1_AlplaPROD2.0_Read].[issueMaterial].[ProductionLot] as lot on +// x.ProductionLotId = lot.Id +// where lot.ProductionLotHumanReadableId = [lotNumber] +// and IsMainMaterial = 1 +// `; + export const mmQuery = ` -SELECT lot.ProductionLotHumanReadableId, - case when SourcingState in (1, 2) then 1 - when x.ProvidedAmount > 0 then 1 - when x.EffectiveConsumption > 0 then 1 - else 0 end as Staged, - x.ProvidedAmount as Provided, - x.EffectiveConsumption as consumption, - x.TotalDemand as totalNeeded, +use [test1_AlplaPROD2.0_Read] +/* +checks all needed material including pkg + +we only want to monitor the manual materials and the mm materail to make sure they are good. + +for auto consume materails this will be compared with another query. + +*/ +SELECT lot.ProductionLotHumanReadableId +,MaterialHumanReadableId +,MaterialDescription + --IsMainMaterial, + --case when SourcingState in (1, 2) then 1 + --when x.ProvidedAmount > 0 then 1 + --when x.EffectiveConsumption > 0 then 1 + --else 0 end as Staged, + ,x.ProvidedAmount as Provided + ,x.EffectiveConsumption as consumption + ,x.TotalDemand as totalDemand , + case when cp.Pieces = 1 then (lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces else + (a.Weight *(cp.Percentage / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end totalNeeded + ,l.qty as invForAutoConsume /* remaining needed to complete the lot */ - x.TotalDemand - x.EffectiveConsumption as remainingNeeded, + --,x.TotalDemand - x.EffectiveConsumption as remainingNeeded /* do we have enough staged or scanned to the lot? */ - case when (case when x.ProvidedAmount <> 0 then x.ProvidedAmount else x.EffectiveConsumption end) > x.TotalDemand then 'good' else 'bad' end as noShortage , - x.IsManualProcess as isManual, - MaterialHumanReadableId -FROM [test1_AlplaPROD2.0_Read].[issueMaterial].[MaterialDemand] x (nolock) + ,case when (case when x.ProvidedAmount <> 0 + then x.ProvidedAmount else x.EffectiveConsumption end) > + case when cp.Pieces = 1 then (lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces else + (a.Weight *(cp.Percentage / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end + then 'good' + else 'no' end as noMaterialShortage + -- pkg check + ,case when pkg.QuantityPosition is null then null else + (case when l.qty > (lot.TotalProducedLoadingUnits+1) * pkg.QuantityPosition then 'pkgGood' else 'noPkg' end) end as noPKGShortage + + ,case when cp.Percentage is null then + case when l.qty > ((lot.TotalProducedLoadingUnits +1) * pkg.QuantityPosition) then 'autoConsumeOk' else 'autoConsumeNOK' end else + (case when l.qty > (a.Weight *(cp.Percentage / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 and IsManualProcess = 0 + then 'autoConsumeOk' else 'autoConsumeNOK' end) end as autoConsumeCheck + ,x.IsManualProcess as isManual + ,IsMainMaterial + ,lot.TotalPlannedLoadingUnits + ,lot.TotalProducedLoadingUnits + ,lot.TotalPlannedLoadingUnits - lot.TotalProducedLoadingUnits as remainingPallets + ,cp.Percentage + ,case when cp.Pieces is not null then cp.Pieces else pkg.QuantityPosition end as peices +FROM [issueMaterial].[MaterialDemand] x (nolock) + left join - [test1_AlplaPROD2.0_Read].[issueMaterial].[ProductionLot] as lot on - x.ProductionLotId = lot.Id + [productionControlling].[ProducedLot] as lot on + lot.Id = x.ProductionLotId + +/* av data */ +left join + [masterData].[Article] as a on + a.id = lot.ArticleId + +/* compound*/ +left join +[masterData].[CompoundPosition] as cp on +cp.CompoundId = a.CompoundId +and cp.ArticleId = x.MaterialId + +/* packagaing */ +left join +[masterData].[PackagingInstructionPosition] as pkg on +pkg.PackagingInstructionId = lot.PackagingId +and pkg.ArticleId = x.MaterialId + +-- get the pkg stuff so we have the total amount per pallet. +left join +[masterData].[PackagingInstruction] as p on +p.id = lot.PackagingId + +/* current stock info for auto consumption*/ +left join +(select +IdArtikelVarianten +,ArtikelVariantenBez +,sum(VerfuegbareMengeSum) as qty + +from AlplaPROD_test1.dbo.V_LagerPositionenBarcodes as i (nolock) + +left join +AlplaPROD_test1.dbo.V_LagerAbteilungen as l (nolock) on +l.IdLagerAbteilung = i.IdLagerAbteilung +where autoverbrauch = 1 and aktiv = 1 +group by IdArtikelVarianten,ArtikelVariantenBez +) as l on +l.IdArtikelVarianten = MaterialHumanReadableId where lot.ProductionLotHumanReadableId = [lotNumber] - and IsMainMaterial = 1 `; diff --git a/server/services/sqlServer/querys/warehouse/labelInfo.ts b/server/services/sqlServer/querys/warehouse/labelInfo.ts index cb07a53..beea16c 100644 --- a/server/services/sqlServer/querys/warehouse/labelInfo.ts +++ b/server/services/sqlServer/querys/warehouse/labelInfo.ts @@ -1,20 +1,36 @@ export const labelInfo = ` -select top(500) e.Barcode, -e.IdArtikelvarianten as av, -e.lfdnr as rn, -IdEtikettenLayout as labelLayout, -AnzStkJePalette, -Sonstiges_9,AnzStkJeKarton -,case when EinlagerungsMengeSum IS NULL then 'notOnStock' else 'onStock' end as stockStatus -,EinlagerungsMengeSum ---,* -from [AlplaPROD_test1].dbo.[T_EtikettenGedruckt] e (nolock) +declare @runningNumber nvarchar(max) = [runningNr] + +select e.Barcode, +e.RunningNumber as runnungNumber, +externalRunningNumber= null, +e.ArticleHumanReadableId as av, +e.LabelManagementHumanReadableId as labelLayout, +case when EinlagerungsMengeSum IS NULL then 'notOnStock' else 'onStock' end as stockStatus +from [test1_AlplaPROD2.0_Read].[labelling].[InternalLabel] (nolock) as e left join -[AlplaPROD_test1].dbo.V_LagerPositionenBarcodes as l on -e.LfdNr = l.Lfdnr +alplaprod_test1.dbo.V_LagerPositionenBarcodes (nolock) as l on +e.RunningNumber = l.Lfdnr -where e.LfdNr in ([runningNr]) +WHERE e.RunningNumber IN (@runningNumber) -order by add_date desc +union all + +select ext.Barcode +,RunningNumber as runnungNumber +,SsccEanRunningNumber as externalRunningNumber +,ArticleHumanReadableId +,case when LabelManagementHumanReadableId is null then (select HumanReadableId from [test1_AlplaPROD2.0_Read].[masterData].[LabelManagement] (nolock) where LabelMarkerId = 7) else LabelManagementHumanReadableId end as labelLayout +,case when EinlagerungsMengeSum IS NULL then 'notOnStock' else 'onStock' end as stockStatus +from [test1_AlplaPROD2.0_Read].[labelling].[ExternalLabel] (nolock) as ext + +left join +alplaprod_test1.dbo.V_LagerPositionenBarcodes (nolock) as l on +ext.RunningNumber = l.Lfdnr + +WHERE ext.SsccEanRunningNumber IN (@runningNumber) and +ext.RunningNumber NOT IN ( + SELECT RunningNumber FROM [test1_AlplaPROD2.0_Read].[labelling].[InternalLabel] WHERE RunningNumber IN (@runningNumber) + ) `; -- 2.49.1 From a6f18554b8c79119b530c524a4b6e2c19bf4e25b Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 19 Aug 2025 17:00:13 -0500 Subject: [PATCH 049/166] ci(release): bump build number to 562 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5d31419..7e4a3a4 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 561, + "build": 562, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 595e22e8e97fb65ab20d13a9aafae4dd6569b26b Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 19 Aug 2025 17:04:13 -0500 Subject: [PATCH 050/166] ci(release): bump build number to 563 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7e4a3a4..9bdf75e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 562, + "build": 563, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 7d5b0c46c1cb4153fa59a4a9b201e87079a807fb Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 19 Aug 2025 17:37:40 -0500 Subject: [PATCH 051/166] ci(release): bump build number to 564 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9bdf75e..72dfb1f 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 563, + "build": 564, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 213814b868b7e9ae2fa1edcc748d72b3c7308df9 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 20 Aug 2025 19:02:42 -0500 Subject: [PATCH 052/166] ci(release): bump build number to 565 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 72dfb1f..aed7eb3 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 564, + "build": 565, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From c5668e6cf164dca5123b76067b7badefd6117d20 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 20 Aug 2025 20:04:05 -0500 Subject: [PATCH 053/166] chore(release): 2.25.0 --- CHANGELOG.md | 31 +++++++++++++++++++++++++++++++ package-lock.json | 4 ++-- package.json | 4 ++-- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb15ac3..4394b89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,36 @@ # All CHanges to LST can be found below. +## [2.25.0](https://git.tuffraid.net/cowch/lstV2/compare/v2.24.1...v2.25.0) (2025-08-21) + + +### 🐛 Bug fixes + +* **dm page:** correction to the insturcitons ([a36552f](https://git.tuffraid.net/cowch/lstV2/commits/a36552fd9b9c77f8ecee8b36f45e613383841f95)) +* **dyco:** correction to disable the camera if ocme is off ([c7bb128](https://git.tuffraid.net/cowch/lstV2/commits/c7bb12822b13c0c1c929d2c8a9ab150cd0feeff2)) +* **gotransport:** error handling so we dont get spammed with errors ([2eb6fa7](https://git.tuffraid.net/cowch/lstV2/commits/2eb6fa77946d5f8572ffc5baa47da602482bce2b)) +* **https fixes:** made it so the settings can be grabbed via https ([803c963](https://git.tuffraid.net/cowch/lstV2/commits/803c963f964f26095b2aa6a7d0a60e03615d4c17)) +* **inv cards:** correction to properly display the names ([2288884](https://git.tuffraid.net/cowch/lstV2/commits/22888848291aa3df4ebbdd224656731fbb305fa7)) +* **inv query:** error in improper placed , in the query ([397f1da](https://git.tuffraid.net/cowch/lstV2/commits/397f1da595fd8a1e1c2a630a3650eb8715604c82)) +* **mainmaterial check:** if the machine dose not require mm to be staged properly ignore ([0d17fef](https://git.tuffraid.net/cowch/lstV2/commits/0d17fef1a1c75dd0f27988fd2e3527b508b915cb)) + + +### 🛠️ Code Refactor + +* **migration progress:** moved to start looking at the go backedn ([a0179a4](https://git.tuffraid.net/cowch/lstV2/commits/a0179a41bac93d2a7320802e9d70aa966ed79ae4)) +* **migrations:** not needed but we have it and needed to correct the settings ([2ff7b9b](https://git.tuffraid.net/cowch/lstV2/commits/2ff7b9baf9ca288f8a33bec3ab1a2ba331ace6b9)) +* **notifications:** refactored the cron job system so we can utilize outside the service ([103171c](https://git.tuffraid.net/cowch/lstV2/commits/103171c924a9de78b0a7600abb455fdd6f4bfea1)) +* **siloadjustment:** refactored to get the settings from the state vs direct from db ([8145dc8](https://git.tuffraid.net/cowch/lstV2/commits/8145dc800dced31860a926c80eca72cb39433b29)) + + +### 🌟 Enhancements + +* **dm:** changes to have a default time if nothing is passed in the excel ([9e5577e](https://git.tuffraid.net/cowch/lstV2/commits/9e5577e6bb4ff3b6c4004288e177fbab322a4b44)) +* **eom:** added in hostorical data and deletion for data over 45 days ([52345bc](https://git.tuffraid.net/cowch/lstV2/commits/52345bc94c9e8abc82150fb371a9ba0d0757f16a)) +* **migration start:** this starts the migration of all settings to look at the go backend vs this ([998e84f](https://git.tuffraid.net/cowch/lstV2/commits/998e84f5648148c9a94df7177a3d311e16bf4614)) +* **ocp:** materials contorls and transfer to next lot logic ([88f61c8](https://git.tuffraid.net/cowch/lstV2/commits/88f61c8eaa32a581094b04b5e18c654040dbeb92)) +* **prodrole:** added in planner role ([6ccf500](https://git.tuffraid.net/cowch/lstV2/commits/6ccf500e5eb82125f7bcd3d764282a4b8a750be9)) +* **psi:** psi querys added and av grab right now ([8d63f7f](https://git.tuffraid.net/cowch/lstV2/commits/8d63f7f6b0981d604b628ff2f710b8eb41d32837)) + ### [2.24.1](https://git.tuffraid.net/cowch/lstV2/compare/v2.24.0...v2.24.1) (2025-07-25) diff --git a/package-lock.json b/package-lock.json index 6e8a89d..9979cf6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "lstv2", - "version": "2.24.1", + "version": "2.25.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "lstv2", - "version": "2.24.1", + "version": "2.25.0", "dependencies": { "@dotenvx/dotenvx": "^1.45.1", "@hono/node-server": "^1.14.4", diff --git a/package.json b/package.json index aed7eb3..5b8064a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lstv2", - "version": "2.24.1", + "version": "2.25.0", "type": "module", "scripts": { "dev": "concurrently -n \"server,frontend\" -c \"#007755,#2f6da3\" \"npm run dev:server\" \"cd frontend && npm run dev\"", @@ -93,4 +93,4 @@ "xlsx": "^0.18.5", "zod": "^3.25.67" } -} \ No newline at end of file +} -- 2.49.1 From bcf5378966e4dd6038ed588d3a6e5a497d44e340 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 20 Aug 2025 20:04:51 -0500 Subject: [PATCH 054/166] ci(release): bump build number to 566 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5b8064a..a30b3d5 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 565, + "build": 566, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { @@ -93,4 +93,4 @@ "xlsx": "^0.18.5", "zod": "^3.25.67" } -} +} \ No newline at end of file -- 2.49.1 From 0c54cecbd4a58f3bae6b452df07f8993e43bd630 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 20 Aug 2025 20:51:22 -0500 Subject: [PATCH 055/166] ci(release): bump build number to 567 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a30b3d5..22809bb 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 566, + "build": 567, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 662a951b9871d5dfc21f01a76ba23be77b475757 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 21 Aug 2025 05:10:25 -0500 Subject: [PATCH 056/166] feat(tms): a clean up function was added to remove releases added as blockers older than 45d --- .../notifications/tiFullFlow/tiImport.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/server/services/notifications/controller/notifications/tiFullFlow/tiImport.ts b/server/services/notifications/controller/notifications/tiFullFlow/tiImport.ts index c6f10be..cf440b7 100644 --- a/server/services/notifications/controller/notifications/tiFullFlow/tiImport.ts +++ b/server/services/notifications/controller/notifications/tiFullFlow/tiImport.ts @@ -276,16 +276,28 @@ export const tiImport = async () => { * Update the db so we dont try to pull the next one */ + const currentDate = new Date(Date.now()); const uniqueOrders = Array.from( new Set([ ...notiSet[0].notifiySettings.releases, { releaseNumber: header[0].releaseNumber, - timeStamp: new Date(Date.now()), + timeStamp: currentDate, }, ]) ); + // 45 days ago + const dateLimit = new Date( + currentDate.getTime() - 45 * 24 * 60 * 60 * 1000 + ); + + // filter dates + let filteredOrders = uniqueOrders.filter((item) => { + const time = new Date(item.timeStamp).getTime(); + return time >= dateLimit.getTime(); + }); + const { data, error } = await tryCatch( db .update(notifications) @@ -293,7 +305,7 @@ export const tiImport = async () => { lastRan: sql`NOW()`, notifiySettings: { ...notiSet[0].notifiySettings, - releases: uniqueOrders, + releases: filteredOrders, }, }) .where(eq(notifications.name, "tiIntergration")) -- 2.49.1 From 27586e923a106f2b8dd804e9c8292edd5d009cf0 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 21 Aug 2025 05:13:06 -0500 Subject: [PATCH 057/166] feat(ocp): zechetti 1 added in --- .../logistics/siloAdjustments/AttachSilo.tsx | 1 - .../specialProcesses/zechettis/zechetti1.ts | 177 ++++++++++++++++++ server/services/ocp/ocpService.ts | 9 + 3 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 server/services/ocp/controller/specialProcesses/zechettis/zechetti1.ts diff --git a/frontend/src/components/logistics/siloAdjustments/AttachSilo.tsx b/frontend/src/components/logistics/siloAdjustments/AttachSilo.tsx index 564a7e3..63dd35a 100644 --- a/frontend/src/components/logistics/siloAdjustments/AttachSilo.tsx +++ b/frontend/src/components/logistics/siloAdjustments/AttachSilo.tsx @@ -40,7 +40,6 @@ export function AttachSilo(props: any) { machineId: "", }, onSubmit: async ({ value }) => { - console.log(value); try { const res = await axios.post( "/api/logistics/attachsilo", diff --git a/server/services/ocp/controller/specialProcesses/zechettis/zechetti1.ts b/server/services/ocp/controller/specialProcesses/zechettis/zechetti1.ts new file mode 100644 index 0000000..b541af8 --- /dev/null +++ b/server/services/ocp/controller/specialProcesses/zechettis/zechetti1.ts @@ -0,0 +1,177 @@ +import { Controller, Tag } from "st-ethernet-ip"; +import { labelingProcess } from "../../labeling/labelProcess.js"; +import { createLog } from "../../../../logger/logger.js"; + +let plcAddress = "192.168.193.97"; // zechetti 2 +let lastProcessedTimestamp = 0; +let PLC = new Controller() as any; +const labelerTag = new Tag("N7[0]"); // change the car to a or b depending on what zechetti. +//const t = new Tag("CONV_M01_SHTL_UNLD_IN_FROM_PREV_CONV_TRACK_CODE.PAL_ORIGIN_LINE_N") // this is for the new zechette to reach the pallet form + +let pollingInterval: any = null; +let heartbeatInterval: any = null; +let reconnecting = false; +let lastTag = 0; +// Track last successful read +let lastHeartbeat: number = Date.now(); + +export async function zechitti1Connect() { + try { + createLog( + "info", + "zechitti1", + "ocp", + `Connecting to PLC at ${plcAddress}...` + ); + await PLC.connect(plcAddress, 0); + createLog("info", "zechitti1", "ocp", "Zechetti 2 connected."); + + // Start polling tags + startPolling(); + + // Start heartbeat + // startHeartbeat(); + + // Handle disconnects/errors + PLC.on("close", () => { + console.warn("PLC connection closed."); + handleReconnect(); + }); + + PLC.on("error", (err: any) => { + createLog("error", "zechitti1", "ocp", `PLC error: ${err.message}`); + handleReconnect(); + }); + } catch (err: any) { + createLog( + "error", + "zechitti1", + "ocp", + `Initial connection failed: ${err.message}` + ); + handleReconnect(); + } +} + +function startPolling() { + if (pollingInterval) clearInterval(pollingInterval); + + pollingInterval = setInterval(async () => { + try { + await PLC.readTag(labelerTag); + //lastHeartbeat = Date.now(); + + const tagTime: any = new Date(labelerTag.timestamp); + + // so we make sure we are not missing a pallet remove it from the lastTag so we can get this next label correctly + if ( + labelerTag.value == 0 && + Date.now() - lastProcessedTimestamp >= 45000 + ) { + lastTag = labelerTag.value; + } + + // if the tag is not zero and its been longer than 30 seconds and the last tag is not equal to the current tag we can print + if ( + labelerTag.value !== 0 && + lastTag !== labelerTag.value && + tagTime !== lastProcessedTimestamp && + Date.now() - lastProcessedTimestamp >= 30000 + ) { + lastProcessedTimestamp = tagTime; + lastTag = labelerTag.value; + console.log( + `Time since last check: ${ + Date.now() - tagTime + }, greater than 30000, ${ + Date.now() - lastProcessedTimestamp >= 30000 + }, the line to be printed is ${labelerTag.value}` + ); + //console.log(labelerTag); + const zechette = { + line: labelerTag.value.toString(), + printer: 22, // this is the id of the zechetti 2 to print we should move this to the db + printerName: "Zechetti1", + }; + labelingProcess({ zechette: zechette }); + } + } catch (err: any) { + createLog( + "error", + "zechitti1", + "ocp", + `Polling error: ${err.message}` + ); + handleReconnect(); + } + }, 1000); +} + +// function startHeartbeat() { +// if (heartbeatInterval) clearInterval(heartbeatInterval); + +// heartbeatInterval = setInterval(() => { +// const diff = Date.now() - lastHeartbeat; +// if (diff > 60000) { +// // 1 minute +// console.warn(`⚠️ Heartbeat timeout: no data for ${diff / 1000}s`); +// handleReconnect(); +// } +// }, 10000); // check every 10s +// } + +async function handleReconnect() { + if (reconnecting) return; + reconnecting = true; + + if (pollingInterval) { + clearInterval(pollingInterval); + pollingInterval = null; + } + + let delay = 2000; // start at 2s + let attempts = 0; + const maxAttempts = 10; // or limit by time, e.g. 2 min total + + while (!PLC.connected && attempts < maxAttempts) { + attempts++; + createLog( + "info", + "zechitti1", + "ocp", + `Reconnect attempt ${attempts}/${maxAttempts} in ${ + delay / 1000 + }s...` + ); + await new Promise((res) => setTimeout(res, delay)); + + try { + PLC = new Controller(); // fresh instance + await PLC.connect(plcAddress, 0); + createLog("info", "zechitti1", "ocp", "Reconnected to PLC!"); + reconnecting = false; + startPolling(); + return; + } catch (err: any) { + createLog( + "error", + "zechitti1", + "ocp", + `Reconnect attempt failed: ${err.message}` + ); + delay = Math.min(delay * 2, 30000); // exponential backoff up to 30s + } + } + + if (!PLC.connected) { + createLog( + "error", + "zechitti1", + "ocp", + "Max reconnect attempts reached. Stopping retries." + ); + reconnecting = false; + // optional: exit process or alert someone here + // process.exit(1); + } +} diff --git a/server/services/ocp/ocpService.ts b/server/services/ocp/ocpService.ts index 0cc18ac..c895e2b 100644 --- a/server/services/ocp/ocpService.ts +++ b/server/services/ocp/ocpService.ts @@ -25,6 +25,7 @@ import bookInLabel from "./routes/labeling/bookIn.js"; import labelRatio from "./routes/labeling/getLabelRatio.js"; import resetRatio from "./routes/labeling/resetLabelRatio.js"; import materialTransferLot from "./routes/materials/lotTransfer.js"; +import { zechitti1Connect } from "./controller/specialProcesses/zechettis/zechetti1.js"; const app = new OpenAPIHono(); @@ -69,6 +70,7 @@ app.all("/ocp/*", (c) => { */ const dycoActive = setting.filter((n) => n.name == "dycoConnect"); const ocpActive = setting.filter((n) => n.name === "ocpActive"); +const zechetti = setting.filter((n) => n.name == "zechetti"); // run the printer update on restart just to keep everything good // do the intnal connection to the dyco @@ -78,6 +80,13 @@ setTimeout(() => { } }, 3 * 1000); +// if zechetti plc is wanted we will connect +setTimeout(() => { + if (zechetti[0]?.value === "1") { + zechitti1Connect(); + } +}, 3 * 1000); + // check for printers being assigned setInterval(() => { if (ocpActive[0]?.value === "1") { -- 2.49.1 From 73d38ba3fe7ab4d5ca3a4a1e1c99fdd7bf5e92dc Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 21 Aug 2025 05:13:34 -0500 Subject: [PATCH 058/166] refactor(notifcations): changed hour to min in ti intergrations --- server/services/notifications/utils/masterNotifications.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/services/notifications/utils/masterNotifications.ts b/server/services/notifications/utils/masterNotifications.ts index 96dbb87..677d87f 100644 --- a/server/services/notifications/utils/masterNotifications.ts +++ b/server/services/notifications/utils/masterNotifications.ts @@ -68,8 +68,8 @@ export const note: any = [ { name: "tiIntergration", description: "Checks for new releases to be put into ti", - checkInterval: 2, - timeType: "hour", + checkInterval: 60, + timeType: "min", emails: "", active: false, notifiySettings: { -- 2.49.1 From 846ac479b1bf211a7891ae362525ea14580ff0cc Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 21 Aug 2025 05:14:03 -0500 Subject: [PATCH 059/166] fix(transferlots): missed adding this --- .../materialHelper/consumption/index.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/frontend/src/routes/(logistics)/materialHelper/consumption/index.tsx b/frontend/src/routes/(logistics)/materialHelper/consumption/index.tsx index 57c3d5e..bcb56d2 100644 --- a/frontend/src/routes/(logistics)/materialHelper/consumption/index.tsx +++ b/frontend/src/routes/(logistics)/materialHelper/consumption/index.tsx @@ -1,5 +1,6 @@ import ConsumeMaterial from "@/components/logistics/materialHelper/consumption/ConsumeMaterial"; import PreformReturn from "@/components/logistics/materialHelper/consumption/MaterialReturn"; +import TransferToNextLot from "@/components/logistics/materialHelper/consumption/TransferToNextLot"; import { createFileRoute } from "@tanstack/react-router"; export const Route = createFileRoute( @@ -21,10 +22,18 @@ export const Route = createFileRoute( function RouteComponent() { const url: string = window.location.host.split(":")[0]; + const auth = localStorage.getItem("auth_token"); return ( -
- - {url === "localhost" && } +
+ {auth ? ( + <> + + {url === "localhost" && } + + + ) : ( + + )}
); } -- 2.49.1 From 0ba338d48037f7def74196ca3f41de5807e2cb31 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 21 Aug 2025 05:18:49 -0500 Subject: [PATCH 060/166] feat(rfid): new check to remove tags that have been at a line longer than 6 hours --- server/services/rfid/rfidService.ts | 6 +++++ server/services/rfid/utils/monitorTags.ts | 22 +++++++++++++++++++ server/services/server/utils/settingsCheck.ts | 14 ++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 server/services/rfid/utils/monitorTags.ts diff --git a/server/services/rfid/rfidService.ts b/server/services/rfid/rfidService.ts index f9c6089..b4344b5 100644 --- a/server/services/rfid/rfidService.ts +++ b/server/services/rfid/rfidService.ts @@ -7,6 +7,7 @@ import updateReader from "./route/updateReader.js"; import manualTrigger from "./route/manualTagRead.js"; import getReaders from "./route/getReaders.js"; import resetRatio from "./route/resetRatio.js"; +import { monitorRfidTags } from "./utils/monitorTags.js"; const app = new OpenAPIHono(); const routes = [ @@ -24,4 +25,9 @@ const appRoutes = routes.forEach((route) => { app.route("/rfid", route); }); +// monitor every 5 min tags older than 6 hours to remove the line they were so we reduce the risk of them being labeled with the wrong info +setInterval(() => { + monitorRfidTags(); +}, 5 * 1000 * 60); + export default app; diff --git a/server/services/rfid/utils/monitorTags.ts b/server/services/rfid/utils/monitorTags.ts new file mode 100644 index 0000000..23a0975 --- /dev/null +++ b/server/services/rfid/utils/monitorTags.ts @@ -0,0 +1,22 @@ +import { and, lt, ne, sql } from "drizzle-orm"; +import { db } from "../../../../database/dbclient.js"; +import { rfidTags } from "../../../../database/schema/rfidTags.js"; +import { tryCatch } from "../../../globalUtils/tryCatch.js"; + +/** + * This will monitor tags that are older than 6hours and are still linked to a line. + * it will then remove the line from the last area in as we will asume it dose not exist. + */ +export const monitorRfidTags = async () => { + const { data, error } = await tryCatch( + db + .update(rfidTags) + .set({ lastareaIn: "miss scanned" }) + .where( + and( + ne(rfidTags.lastareaIn, "wrapper1"), // not equal to 'wrapper1' + lt(rfidTags.lastRead, sql`NOW() - INTERVAL '6 hours'`) // older than 6 hours) + ) + ) + ); +}; diff --git a/server/services/server/utils/settingsCheck.ts b/server/services/server/utils/settingsCheck.ts index 377d6ce..c1dd885 100644 --- a/server/services/server/utils/settingsCheck.ts +++ b/server/services/server/utils/settingsCheck.ts @@ -198,6 +198,13 @@ const newSettings = [ serviceBelowsTo: "system", roleToChange: "admin", }, + { + name: "rifd", + value: `0`, + description: "This is for dayton to be runnning rfid pallet tracking.", + serviceBelowsTo: "logistics", + roleToChange: "admin", + }, // ocp { @@ -244,6 +251,13 @@ const newSettings = [ serviceBelowsTo: "logistics", roleToChange: "admin", }, + { + name: "zechetti", + value: `0`, + description: "Are we going to be running the Zechetti plcs", + serviceBelowsTo: "logistics", + roleToChange: "admin", + }, // temp settings can be deleted at a later date once that code is removed { name: "checkColor", -- 2.49.1 From 4486fe24362b4811d7cff0467c7f2f85e0c9e3c4 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 21 Aug 2025 05:54:48 -0500 Subject: [PATCH 061/166] fix(ocp): zechetti type correction to include the printer name --- .../ocp/controller/labeling/labelProcess.ts | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/server/services/ocp/controller/labeling/labelProcess.ts b/server/services/ocp/controller/labeling/labelProcess.ts index 2da4e2d..b4cd319 100644 --- a/server/services/ocp/controller/labeling/labelProcess.ts +++ b/server/services/ocp/controller/labeling/labelProcess.ts @@ -19,11 +19,18 @@ interface Printer { // Add any other expected properties } +interface Zechetti { + line: string; + printer: number; + printerName: string; +} + export const labelingProcess = async ({ line = null as string | null, printer = null as Printer | null, userPrinted = null, rfidTag = null, + zechette = null as Zechetti | null, } = {}) => { /** * Creates a label once all logic is passed @@ -69,6 +76,34 @@ export const labelingProcess = async ({ } } + // if we are running the zechettii + if (zechette) { + const macId = await getMac(zechette.line); + // filter out the lot for the line + filteredLot = lots.data.filter( + (l: any) => l.MachineID === macId[0]?.HumanReadableId + ); + + if (filteredLot.length === 0) { + createLog( + "error", + "labeling", + "ocp", + `There is not a lot assigned to ${line}.` + ); + return { + success: false, + message: `There is not a lot assigned to ${line}.`, + }; + } + + // remap the printer so its the zechetti one + filteredLot = filteredLot.map((p: any) => ({ + ...p, + printerID: zechette.printer, + PrinterName: zechette.printerName, + })); + } // if we came from a printer if (printer) { // filter the lot based on the printerID -- 2.49.1 From 3148aa79d73823499824cc0601fcabec97bb4f9d Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 21 Aug 2025 05:55:20 -0500 Subject: [PATCH 062/166] refactor(materials): changes for permissions on material consume --- server/services/server/utils/subModuleCheck.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/services/server/utils/subModuleCheck.ts b/server/services/server/utils/subModuleCheck.ts index fcd5d46..ca3546d 100644 --- a/server/services/server/utils/subModuleCheck.ts +++ b/server/services/server/utils/subModuleCheck.ts @@ -61,7 +61,14 @@ const newSubModules = [ description: "", link: "/materialHelper/consumption", icon: "Package", - roles: ["technician", "supervisor", "manager", "admin", "systemAdmin"], + roles: [ + "viewer", + "technician", + "supervisor", + "manager", + "admin", + "systemAdmin", + ], active: false, subSubModule: [], }, -- 2.49.1 From 8d6ead3aa11aed95ffa3537fbe72cfa9bbceb380 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 21 Aug 2025 05:55:41 -0500 Subject: [PATCH 063/166] fix(produser): changes to include DM --- server/services/prodUser/utils/prodRoles.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/services/prodUser/utils/prodRoles.ts b/server/services/prodUser/utils/prodRoles.ts index e61b050..f7a6677 100644 --- a/server/services/prodUser/utils/prodRoles.ts +++ b/server/services/prodUser/utils/prodRoles.ts @@ -59,6 +59,8 @@ const newProdRoles: any = [ "Logistics\\Warehousing\\ProcessAdmin", "Manufacturing\\IssueMaterial\\ProcessAdmin", "Manufacturing\\ProductionLabelling\\ProcessAdmin", + "DemandManagement\\Forecast\\ProcessAdmin", + "DemandManagement\\Order\\ProcessAdmin", ], rolesLegacy: [55, 95, 15, 105, 145, 9], }, -- 2.49.1 From 123bb127e85b14cd57a914ca6a33dc6c1bcf9a03 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 21 Aug 2025 07:33:43 -0500 Subject: [PATCH 064/166] ci(release): bump build number to 568 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 22809bb..aaaae2f 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 567, + "build": 568, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 3f3b64bf2bfafd8e800ff075f0e7d906376ca1d9 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 25 Aug 2025 12:15:27 -0500 Subject: [PATCH 065/166] ci(release): bump build number to 569 --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index aaaae2f..85b07dd 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 568, + "build": 569, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { @@ -78,6 +78,7 @@ "fast-xml-parser": "^5.2.5", "fs-extra": "^11.3.0", "jsonwebtoken": "^9.0.2", + "morgan": "^1.10.1", "mssql": "^11.0.1", "nodemailer": "^7.0.3", "nodemailer-express-handlebars": "^7.0.0", -- 2.49.1 From e78083f496a3ec7b4f8d2c6c2810d40d20a24cf7 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 25 Aug 2025 12:18:17 -0500 Subject: [PATCH 066/166] ci(release): bump build number to 570 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 85b07dd..2e38afc 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 569, + "build": 570, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From b7de2a8dbe56eb0fdf5f69fdaaf3b0a9ee6f26b2 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 25 Aug 2025 13:15:06 -0500 Subject: [PATCH 067/166] ci(release): bump build number to 571 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2e38afc..2c00a95 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 570, + "build": 571, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 171763184c67f0607aa6d0ae3eb1d22a555303fe Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 25 Aug 2025 13:58:47 -0500 Subject: [PATCH 068/166] ci(release): bump build number to 572 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2c00a95..e025289 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 571, + "build": 572, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 68901a857ae5161f024da9cdefc0a981a4907205 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 25 Aug 2025 14:09:13 -0500 Subject: [PATCH 069/166] fix(dm): corrected the remark section so its properly sent over --- .../controller/dm/ordersIn/mappings/standardOrders.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/services/logistics/controller/dm/ordersIn/mappings/standardOrders.ts b/server/services/logistics/controller/dm/ordersIn/mappings/standardOrders.ts index 909c56c..3a3e45b 100644 --- a/server/services/logistics/controller/dm/ordersIn/mappings/standardOrders.ts +++ b/server/services/logistics/controller/dm/ordersIn/mappings/standardOrders.ts @@ -157,7 +157,7 @@ export const standardOrders = async (data: any, user: any) => { deliveryDate: excelDateStuff(o.DeliveryDate), customerLineItemNo: o.CustomerLineNumber, // this is how it is currently sent over from abbott customerReleaseNo: o.CustomerRealeaseNumber, // same as above - remark: o.remark === "" ? null : o.remark, + remark: o.Remark === "" ? null : o.Remark, }, ], }; @@ -169,7 +169,7 @@ export const standardOrders = async (data: any, user: any) => { orders: [...predefinedObject.orders, ...nOrder], }; - //console.log(updatedPredefinedObject); + console.log(updatedPredefinedObject.orders[0]); // post the orders to the server const posting: any = await postOrders(updatedPredefinedObject, user); -- 2.49.1 From 369d16018c8be9fdb936afbc3749b3f9fcea58c8 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 25 Aug 2025 14:38:00 -0500 Subject: [PATCH 070/166] fix(bookin): corrected the error received from the book in fail --- server/services/ocp/controller/labeling/bookIn.ts | 2 +- .../ocp/controller/labeling/labelProcess.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/server/services/ocp/controller/labeling/bookIn.ts b/server/services/ocp/controller/labeling/bookIn.ts index 21477ab..6b6f3be 100644 --- a/server/services/ocp/controller/labeling/bookIn.ts +++ b/server/services/ocp/controller/labeling/bookIn.ts @@ -96,7 +96,7 @@ export const bookInLabel = async (data: any) => { "ocp", `${ data.printer ? data.printer[0].name : "Manual book in" - }, "Error: ${error}` + }, "Error: ${error?.response.data}` ); // console.log(error.response.data); return { diff --git a/server/services/ocp/controller/labeling/labelProcess.ts b/server/services/ocp/controller/labeling/labelProcess.ts index b4cd319..89c22d1 100644 --- a/server/services/ocp/controller/labeling/labelProcess.ts +++ b/server/services/ocp/controller/labeling/labelProcess.ts @@ -12,6 +12,7 @@ import { bookInLabel } from "./bookIn.js"; import { delieryInhouse } from "../specialProcesses/inhouse/inhouseDelivery.js"; import { dualPrintingProcess } from "../specialProcesses/dualPrinting/dualPrinting.js"; import { getMac } from "../../utils/getMachineId.js"; +import { success } from "zod/v4"; interface Printer { name: string; @@ -283,6 +284,20 @@ export const labelingProcess = async ({ // will add later!!! :P } + if (!book.success) { + // createLog( + // "error", + // "labeling", + // "ocp", + // `Error Booking in label: ${book.errors[0].message}` + // ); + return { + success: false, + message: `Error Booking in label: ${book.errors[0].message}`, + data: book, + }; + } + // inhouse - if the inhouse funtion is turned on we will deliver to inhouse as long as we did not hit an error state const inhouseDelivery = settingData.filter( (s) => s.name === "inhouseDelivery" -- 2.49.1 From 37f82a9710cf20e6d0d056893c9da43c70b9e619 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 25 Aug 2025 14:39:54 -0500 Subject: [PATCH 071/166] refactor(tms intergration): corrected how we added gl coding --- .../notifications/tiFullFlow/tiImport.ts | 28 +++++++++++++------ .../notifications/tiFullFlow/tiXmlPayload.ts | 7 +++-- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/server/services/notifications/controller/notifications/tiFullFlow/tiImport.ts b/server/services/notifications/controller/notifications/tiFullFlow/tiImport.ts index cf440b7..4c36b50 100644 --- a/server/services/notifications/controller/notifications/tiFullFlow/tiImport.ts +++ b/server/services/notifications/controller/notifications/tiFullFlow/tiImport.ts @@ -239,15 +239,16 @@ export const tiImport = async () => { .replaceAll("[customerState]", orderData[0].city.split(",")[1]) .replaceAll("[customerZip]", orderData[0].zipCode) .replaceAll("[customerPO]", orderData[0].Header) - .replaceAll( - "[glCoding]", - `52410-${ - orderData[0].artileType.toLowerCase() === "preform" || - orderData[0].artileType.toLowerCase() === "metalCage" - ? 31 - : plantI[0].greatPlainsPlantCode - }` - ) // {"52410 - " + (artileType.toLowerCase() === "preform" || artileType.toLowerCase() === "metalCage" ? 31: plantInfo[0].greatPlainsPlantCode)} + // .replaceAll( + // "[glCoding]", + // `52410-${ + // orderData[0].artileType.toLowerCase() === "preform" || + // orderData[0].artileType.toLowerCase() === "metalCage" + // ? 31 + // : plantI[0].greatPlainsPlantCode + // }` + // ) // {"52410 - " + (artileType.toLowerCase() === "preform" || artileType.toLowerCase() === "metalCage" ? 31: plantInfo[0].greatPlainsPlantCode)} + .replaceAll("[glCoding]", `52410`) .replaceAll( "[pfc]", `${ @@ -257,6 +258,15 @@ export const tiImport = async () => { : orderData[0].costCenter }` ) + .replaceAll( + "[locCode]", + `${ + orderData[0].artileType.toLowerCase() === "preform" || + orderData[0].artileType.toLowerCase() === "metalCage" + ? 31 + : plantI[0].greatPlainsPlantCode + }` + ) .replaceAll("[priceSheet]", await scacCheck(orderData)); //send over to be processed diff --git a/server/services/notifications/controller/notifications/tiFullFlow/tiXmlPayload.ts b/server/services/notifications/controller/notifications/tiFullFlow/tiXmlPayload.ts index 5ed407b..9b04fbb 100644 --- a/server/services/notifications/controller/notifications/tiFullFlow/tiXmlPayload.ts +++ b/server/services/notifications/controller/notifications/tiFullFlow/tiXmlPayload.ts @@ -110,8 +110,11 @@ export let xmlPayloadTI = ` [shipNumber] [customerPO] [multieReleaseNumber] -[glCoding] -[pfc] + + +[glCoding] +[pfc] +[locCode] -- 2.49.1 From 24a97afe064d5c44872e24e6e3299ed5f2977a78 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 25 Aug 2025 14:40:21 -0500 Subject: [PATCH 072/166] fix(fake edi): removed console log --- .../logistics/controller/dm/ordersIn/mappings/standardOrders.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/services/logistics/controller/dm/ordersIn/mappings/standardOrders.ts b/server/services/logistics/controller/dm/ordersIn/mappings/standardOrders.ts index 3a3e45b..6275704 100644 --- a/server/services/logistics/controller/dm/ordersIn/mappings/standardOrders.ts +++ b/server/services/logistics/controller/dm/ordersIn/mappings/standardOrders.ts @@ -169,7 +169,7 @@ export const standardOrders = async (data: any, user: any) => { orders: [...predefinedObject.orders, ...nOrder], }; - console.log(updatedPredefinedObject.orders[0]); + //console.log(updatedPredefinedObject.orders[0]); // post the orders to the server const posting: any = await postOrders(updatedPredefinedObject, user); -- 2.49.1 From 788d6367a380a81722a76bd6adbe18831d88eeb5 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 25 Aug 2025 15:47:18 -0500 Subject: [PATCH 073/166] refactor(labeling): removed the wrong import --- server/services/ocp/controller/labeling/labelProcess.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/server/services/ocp/controller/labeling/labelProcess.ts b/server/services/ocp/controller/labeling/labelProcess.ts index 89c22d1..f2593ca 100644 --- a/server/services/ocp/controller/labeling/labelProcess.ts +++ b/server/services/ocp/controller/labeling/labelProcess.ts @@ -12,7 +12,6 @@ import { bookInLabel } from "./bookIn.js"; import { delieryInhouse } from "../specialProcesses/inhouse/inhouseDelivery.js"; import { dualPrintingProcess } from "../specialProcesses/dualPrinting/dualPrinting.js"; import { getMac } from "../../utils/getMachineId.js"; -import { success } from "zod/v4"; interface Printer { name: string; -- 2.49.1 From f4f3de49cae277ffa158116d1802495b27fa8e75 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 25 Aug 2025 18:34:09 -0500 Subject: [PATCH 074/166] fix(material check): alt mm causing issues and utilizing an 80% to just be ok --- .../sqlServer/querys/ocp/mainMaterial.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/server/services/sqlServer/querys/ocp/mainMaterial.ts b/server/services/sqlServer/querys/ocp/mainMaterial.ts index fc6e3e1..42c31e1 100644 --- a/server/services/sqlServer/querys/ocp/mainMaterial.ts +++ b/server/services/sqlServer/querys/ocp/mainMaterial.ts @@ -35,23 +35,23 @@ SELECT lot.ProductionLotHumanReadableId ,MaterialHumanReadableId ,MaterialDescription --IsMainMaterial, - --case when SourcingState in (1, 2) then 1 - --when x.ProvidedAmount > 0 then 1 - --when x.EffectiveConsumption > 0 then 1 - --else 0 end as Staged, + ,case when SourcingState in (1, 2) then 1 + when x.ProvidedAmount > 0 then 1 + when x.EffectiveConsumption > 0 then 1 + else 0 end as Staged ,x.ProvidedAmount as Provided ,x.EffectiveConsumption as consumption ,x.TotalDemand as totalDemand , - case when cp.Pieces = 1 then (lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces else - (a.Weight *(cp.Percentage / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end totalNeeded + case when cp.Pieces = 1 then (lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces else + (a.Weight *((case when cp.Percentage is null then 80.25 else cp.Percentage end) / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end totalNeeded ,l.qty as invForAutoConsume /* remaining needed to complete the lot */ --,x.TotalDemand - x.EffectiveConsumption as remainingNeeded /* do we have enough staged or scanned to the lot? */ ,case when (case when x.ProvidedAmount <> 0 then x.ProvidedAmount else x.EffectiveConsumption end) > - case when cp.Pieces = 1 then (lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces else - (a.Weight *(cp.Percentage / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end + (case when cp.Pieces = 1 then (lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces else + (a.Weight *((case when cp.Percentage is null then 80.25 else cp.Percentage end) / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end) then 'good' else 'no' end as noMaterialShortage -- pkg check @@ -60,14 +60,14 @@ SELECT lot.ProductionLotHumanReadableId ,case when cp.Percentage is null then case when l.qty > ((lot.TotalProducedLoadingUnits +1) * pkg.QuantityPosition) then 'autoConsumeOk' else 'autoConsumeNOK' end else - (case when l.qty > (a.Weight *(cp.Percentage / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 and IsManualProcess = 0 + (case when l.qty > (a.Weight *((case when cp.Percentage is null then 80.25 else cp.Percentage end) / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 and IsManualProcess = 0 then 'autoConsumeOk' else 'autoConsumeNOK' end) end as autoConsumeCheck ,x.IsManualProcess as isManual ,IsMainMaterial ,lot.TotalPlannedLoadingUnits ,lot.TotalProducedLoadingUnits ,lot.TotalPlannedLoadingUnits - lot.TotalProducedLoadingUnits as remainingPallets - ,cp.Percentage + ,case when cp.Percentage is null then 80.25 else cp.Percentage end as Percentage -- this is to over come the alternate mm put in planning ,case when cp.Pieces is not null then cp.Pieces else pkg.QuantityPosition end as peices FROM [issueMaterial].[MaterialDemand] x (nolock) -- 2.49.1 From e92eccf7852803e4d3a41f481a5ecdbac7f71601 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 27 Aug 2025 14:43:04 -0500 Subject: [PATCH 075/166] ci(release): bump build number to 573 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e025289..ab68dd5 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 572, + "build": 573, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From bf8203bbeea4b8e59e7d695a7c6aa52f3a943edd Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 27 Aug 2025 15:50:49 -0500 Subject: [PATCH 076/166] ci(release): bump build number to 574 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ab68dd5..805ffd4 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 573, + "build": 574, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 2f908398bc3757282a8ed5116a81e4fedb373b4c Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 27 Aug 2025 16:08:58 -0500 Subject: [PATCH 077/166] ci(release): bump build number to 575 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 805ffd4..da4732a 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 574, + "build": 575, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From df423192bfc5e2389872147e92b7d22e648a2927 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 27 Aug 2025 17:17:03 -0500 Subject: [PATCH 078/166] refactor(labeling): moved bookin fails inside bookin as it could be off --- .../ocp/controller/labeling/labelProcess.ts | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/server/services/ocp/controller/labeling/labelProcess.ts b/server/services/ocp/controller/labeling/labelProcess.ts index f2593ca..a4a2e4a 100644 --- a/server/services/ocp/controller/labeling/labelProcess.ts +++ b/server/services/ocp/controller/labeling/labelProcess.ts @@ -277,26 +277,26 @@ export const labelingProcess = async ({ let book: any = []; if (bookin[0].value === "1") { book = await bookInLabel(label.data); + + if (!book.success) { + // createLog( + // "error", + // "labeling", + // "ocp", + // `Error Booking in label: ${book.errors[0].message}` + // ); + return { + success: false, + message: `Error Booking in label: ${book.errors[0]?.message}`, + data: book, + }; + } } else { createLog("info", "labeling", "ocp", "Bookin is turned off."); // will add later!!! :P } - if (!book.success) { - // createLog( - // "error", - // "labeling", - // "ocp", - // `Error Booking in label: ${book.errors[0].message}` - // ); - return { - success: false, - message: `Error Booking in label: ${book.errors[0].message}`, - data: book, - }; - } - // inhouse - if the inhouse funtion is turned on we will deliver to inhouse as long as we did not hit an error state const inhouseDelivery = settingData.filter( (s) => s.name === "inhouseDelivery" -- 2.49.1 From 0a6ddea8c0d2773aba00266df7e2839879d10cb1 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 27 Aug 2025 17:17:32 -0500 Subject: [PATCH 079/166] refactor(materials): changes to allow exact and eom transfers --- .../consumption/TransferToNextLot.tsx | 443 +++++++++++++----- frontend/src/components/ui/switch.tsx | 29 ++ .../controller/materials/consumeMaterial.ts | 2 + .../ocp/controller/materials/lotTransfer.ts | 130 +++-- .../ocp/routes/materials/lotTransfer.ts | 8 +- 5 files changed, 437 insertions(+), 175 deletions(-) create mode 100644 frontend/src/components/ui/switch.tsx diff --git a/frontend/src/components/logistics/materialHelper/consumption/TransferToNextLot.tsx b/frontend/src/components/logistics/materialHelper/consumption/TransferToNextLot.tsx index b517184..e6ac373 100644 --- a/frontend/src/components/logistics/materialHelper/consumption/TransferToNextLot.tsx +++ b/frontend/src/components/logistics/materialHelper/consumption/TransferToNextLot.tsx @@ -1,19 +1,32 @@ import { LstCard } from "@/components/extendedUI/LstCard"; import { Button } from "@/components/ui/button"; -import { CardHeader } from "@/components/ui/card"; +import { CardContent, CardHeader } from "@/components/ui/card"; +import { Input } from "@/components/ui/input"; +import { Switch } from "@/components/ui/switch"; +import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { useAppForm } from "@/utils/formStuff"; import axios from "axios"; import { useState } from "react"; import { toast } from "sonner"; +import { Info } from "lucide-react"; +import { + Tooltip, + TooltipContent, + TooltipTrigger, +} from "@/components/ui/tooltip"; export default function TransferToNextLot() { const [gaylordFilled, setGaylordFilled] = useState([0]); + const [actualAmount, setActualAmount] = useState(0); + const [tab, setTab] = useState("esitmate"); + const [typeSwitch, setTypeSwitch] = useState(false); const form = useAppForm({ defaultValues: { runnungNumber: "", lotNumber: "", originalAmount: "", + amount: "", }, onSubmit: async ({ value }) => { //console.log(transferData); @@ -32,11 +45,15 @@ export default function TransferToNextLot() { ? 0.75 : gaylordFilled.length === 4 && 0.95 ), + amount: actualAmount, + type: typeSwitch ? "eom" : "lot", }); if (res.data.success) { toast.success(`${res.data.message}`); form.reset(); + setGaylordFilled([0]); + setActualAmount(0); } //console.log(res.data); @@ -64,73 +81,127 @@ export default function TransferToNextLot() {
-
- + + + +
+
+ +
+ + -

- Almost full -

- - - - -
-
- -
+ +

+ Enter the total amount of + the cage/gaylord +

+
+ + + setActualAmount( + Number( + e.target.value + ) + ) + } + /> + + +
@@ -165,20 +236,104 @@ export default function TransferToNextLot() { /> )} /> -
- ( - - )} - /> -
+ {tab !== "actual" && ( +
+ ( + + )} + /> +
+ )}
-
+
+
+ + + {typeSwitch ? ( +
+ + "EOM + Transfer" + + + + + + +

+ Click + the + toggle + if + you + will + be + transfering + at + EOM, + NOTE: + This + will + trigger + the + delayed + transfer. +

+
+
+
+ ) : ( +
+ + "Lot + Transfer" + + + + + + +

+ Click + the + toggle + if + you + will + be + transfering + at + EOM, + NOTE: + This + will + trigger + the + delayed + transfer. +

+
+
+
+ )} +
+
+ Transfer To Lot @@ -197,49 +352,93 @@ export default function TransferToNextLot() { Moving material to the next lot.

+ {tab !== "actual" ? ( +
+
    +
  1. + 1. Grab the gaylord running + number from the gaylord at the + line/next to the tschritter +
  2. +
  3. + 2. Grab the next lot number you + are going to be running (or the + one that state no Main material + prepared) +
  4. +
  5. + 3. Enter the total gaylord + weight (this is how much the + gaylord weighed when it came in + from the supplier.) +
  6. +
  7. + 4. *Click the level of the + gaylord (this is just an + estimate to move to the next + lot.) +
  8. +
  9. + 5. type in running number on the + gaylord. +
  10. +
  11. + 6. Type in the new lot number. +
  12. +
  13. 7. Press "Transfer To Lot"
  14. +
+

+

+ * to reduce the time needed to get + the lot going we will use an + estimate of how full the gaylord is. +

+

+ NOTE: This is not the return + process, this process will just get + the gaylord to the next lot. +

+
+ ) : ( +
+
    +
  1. + 1. Grab the gaylord running + number from the gaylord at the + line/next to the tschritter +
  2. +
  3. + 2. Grab the next lot number you + are going to be running (or the + one that state no Main material + prepared) +
  4. +
  5. + 3. Take the gaylord to the scale + and weight it +
  6. +
  7. + 4. Enter the weight of the + gaylord minus the tar weight. +
  8. +
  9. + 5. type in running number on the + gaylord. +
  10. +
  11. + 6. Type in the new lot number. +
  12. +
  13. 7. Press "Transfer To Lot"
  14. +
+

-
-
    -
  1. - 1. Grab the gaylord running number - from the gaylord at the line/next to - the tschritter -
  2. -
  3. - 2. Grab the next lot number you are - going to be running (or the one that - state no Main material prepared) -
  4. -
  5. - 3. Enter the total gaylord weight - (this is how much the gaylord - weighed when it came in from the - supplier.) -
  6. -
  7. - 4. *Click the level of the gaylord - (this is just an estimate to move to - the next lot.) -
  8. -
  9. - 5. type in running number on the - gaylord. -
  10. -
  11. 6. Type in the new lot number.
  12. -
  13. 7. Press "Transfer To Lot"
  14. -
-

-

- * to reduce the time needed to get the - lot going we will use an estimate of how - full the gaylord is. -

-

- NOTE: This is not the return process, - this process will just get the gaylord - to the next lot. -

-
+

+ NOTE: This is not the return + process, this process will just get + the gaylord to the next lot. +

+
+ )}
diff --git a/frontend/src/components/ui/switch.tsx b/frontend/src/components/ui/switch.tsx new file mode 100644 index 0000000..b0363e3 --- /dev/null +++ b/frontend/src/components/ui/switch.tsx @@ -0,0 +1,29 @@ +import * as React from "react" +import * as SwitchPrimitive from "@radix-ui/react-switch" + +import { cn } from "@/lib/utils" + +function Switch({ + className, + ...props +}: React.ComponentProps) { + return ( + + + + ) +} + +export { Switch } diff --git a/server/services/logistics/controller/materials/consumeMaterial.ts b/server/services/logistics/controller/materials/consumeMaterial.ts index 64888fd..e5fe5a3 100644 --- a/server/services/logistics/controller/materials/consumeMaterial.ts +++ b/server/services/logistics/controller/materials/consumeMaterial.ts @@ -17,6 +17,8 @@ export const consumeMaterial = async (data: Data, prod: any) => { const { runningNr, lotNum } = data; // replace the rn + console.log(data); + const rnReplace = labelData.replaceAll("[rn]", runningNr); let barcode; diff --git a/server/services/ocp/controller/materials/lotTransfer.ts b/server/services/ocp/controller/materials/lotTransfer.ts index b115267..7b75687 100644 --- a/server/services/ocp/controller/materials/lotTransfer.ts +++ b/server/services/ocp/controller/materials/lotTransfer.ts @@ -12,6 +12,8 @@ type NewLotData = { lotNumber: number; originalAmount: number; level: number; + amount: number; + type: "lot" | "eom"; }; /** @@ -22,8 +24,11 @@ type NewLotData = { * Lot number * Orignal Quantity * level of gaylord + * amount can be sent over as a precise amount + * type what way are we lots */ export const lotMaterialTransfer = async (data: NewLotData) => { + let timeoutTrans: number = data.type === "lot" ? 1 : 10; // get the barcode, and layoutID from the running number const { data: label, error: labelError } = (await tryCatch( query( @@ -46,22 +51,21 @@ export const lotMaterialTransfer = async (data: NewLotData) => { }; } - // if ( - // label.data[0]?.stockStatus === "notOnStock" || - // label.data.length === 0 - // ) { - // createLog( - // "error", - // "materials", - // "ocp", - // `${data.runnungNumber}: dose not exist or no longer in stock.` - // ); - // return { - // success: false, - // message: `${data.runnungNumber}: dose not exist or no longer in stock.`, - // data: [], - // }; - // } + if (label.data.length === 0) { + createLog( + "error", + "materials", + "ocp", + `${data.runnungNumber}: dose not exist or no longer in stock.` + ); + return { + success: false, + message: `${data.runnungNumber}: dose not exist or no longer in stock.`, + data: [], + }; + } + + //console.log(label); if (label.data[0]?.stockStatus === "onStock") { createLog( @@ -97,7 +101,12 @@ export const lotMaterialTransfer = async (data: NewLotData) => { } // calculate the remaining amount bascially it will be orignal number * level sent over // level should be sent in a decimal .25 .5 .75 .95 the 95 will allow basically the what looks to be a full gaylord but we always want to consume something - const newQty = (data.originalAmount * data.level).toFixed(0); + const newQty = + data.amount > 0 + ? data.amount + : (data.originalAmount * data.level).toFixed(0); + + //console.log(data.amount); // reprint the label and send it to pdf24 const reprintData = { @@ -109,6 +118,8 @@ export const lotMaterialTransfer = async (data: NewLotData) => { quantity: newQty, } as any; + //console.log(reprintData); + const { data: reprint, error: reprintError } = (await tryCatch( runProdApi({ endpoint: "/public/v1.0/ProductionLabelling/ReprintLabel", @@ -121,11 +132,11 @@ export const lotMaterialTransfer = async (data: NewLotData) => { "error", "materials", "ocp", - `RN:${data.runnungNumber}, Error: ${reprint.data.data.message}` + `RN:${data.runnungNumber}, Reprinting Error: ${reprint.data.data.message}` ); return { success: false, - message: `RN:${data.runnungNumber}, Error: ${reprint.data.data.message}`, + message: `RN:${data.runnungNumber}, Reprinting Error: ${reprint.data.data.message}`, data: reprint, }; } @@ -135,6 +146,8 @@ export const lotMaterialTransfer = async (data: NewLotData) => { barcode: label?.data[0].Barcode, laneId: 10001, }; + + //console.log(matReturnData); const { data: matReturn, error: matReturError } = (await tryCatch( runProdApi({ endpoint: @@ -148,11 +161,11 @@ export const lotMaterialTransfer = async (data: NewLotData) => { "error", "materials", "ocp", - `RN:${data.runnungNumber}, Error ${matReturn.data.data.errors[0].message}` + `RN:${data.runnungNumber}, Return Error ${matReturn.data.data.errors[0].message}` ); return { success: false, - message: `RN:${data.runnungNumber}, Error ${matReturn.data.data.errors[0].message}`, + message: `RN:${data.runnungNumber}, Return Error ${matReturn.data.data.errors[0].message}`, data: matReturn, }; } @@ -161,39 +174,56 @@ export const lotMaterialTransfer = async (data: NewLotData) => { productionLot: data.lotNumber, barcode: label?.data[0].Barcode, }; - const { data: matConsume, error: matConsumeError } = (await tryCatch( - runProdApi({ - endpoint: - "/public/v1.0/IssueMaterial/ConsumeNonPreparedManualMaterial", - data: [consumeLot], - }) - )) as any; - if (!matConsume.success) { - createLog( - "error", - "materials", - "ocp", - `RN:${data.runnungNumber}, Error ${matConsume.data.data.errors[0].message}` - ); + // sets the time out based on the type of transfer sent over. + setTimeout( + async () => { + const { data: matConsume, error: matConsumeError } = + (await tryCatch( + runProdApi({ + endpoint: + "/public/v1.0/IssueMaterial/ConsumeNonPreparedManualMaterial", + data: [consumeLot], + }) + )) as any; + + if (!matConsume.success) { + createLog( + "error", + "materials", + "ocp", + `RN:${data.runnungNumber}, Consume Error ${matConsume.data.data.errors[0].message}` + ); + return { + success: false, + message: `RN:${data.runnungNumber}, Consume Error ${matConsume.data.data.errors[0].message}`, + data: matConsume, + }; + } + + createLog( + "info", + "materials", + "ocp", + `RN:${data.runnungNumber}: qty: ${newQty}, was transfered to lot:${data.lotNumber}` + ); + }, + data.type === "lot" ? timeoutTrans * 1000 : timeoutTrans * 1000 * 60 + ); + + if (data.type === "eom") { return { - success: false, - message: `RN:${data.runnungNumber}, Error ${matConsume.data.data.errors[0].message}`, - data: matConsume, + success: true, + message: `RN:${data.runnungNumber}: qty: ${newQty}, will be transfered to:${data.lotNumber}, in ${timeoutTrans}min`, + data: [], + }; + } else { + return { + success: true, + message: `RN:${data.runnungNumber}: qty: ${newQty}, was transfered to lot:${data.lotNumber}`, + data: [], }; } - - createLog( - "info", - "materials", - "ocp", - `RN:${data.runnungNumber}: qty: ${newQty}, was transfered to lot:${data.lotNumber}` - ); - return { - success: true, - message: `RN:${data.runnungNumber}: qty: ${newQty}, was transfered to lot:${data.lotNumber}`, - data: [], - }; }; // setTimeout(async () => { diff --git a/server/services/ocp/routes/materials/lotTransfer.ts b/server/services/ocp/routes/materials/lotTransfer.ts index 34b8b21..991f63f 100644 --- a/server/services/ocp/routes/materials/lotTransfer.ts +++ b/server/services/ocp/routes/materials/lotTransfer.ts @@ -54,10 +54,12 @@ app.openapi( }); } + console.log(transferMaterial); + return c.json({ - success: transferMaterial.success, - message: transferMaterial.message, - data: transferMaterial.data, + success: transferMaterial?.success, + message: transferMaterial?.message, + data: transferMaterial?.data, }); } ); -- 2.49.1 From 53ed2c4e6a0d3fafafbcb655b5d06cff6324363d Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 28 Aug 2025 10:14:41 -0500 Subject: [PATCH 080/166] feat(materials): added in a bigger window on eom transfer lots --- .../ocp/controller/materials/lotTransfer.ts | 264 +++++++++++++++--- server/services/ocp/ocpService.ts | 2 + .../ocp/routes/materials/currentPending.ts | 51 ++++ .../ocp/routes/materials/lotTransfer.ts | 4 +- .../sqlServer/querys/misc/shiftChange.ts | 4 + 5 files changed, 286 insertions(+), 39 deletions(-) create mode 100644 server/services/ocp/routes/materials/currentPending.ts create mode 100644 server/services/sqlServer/querys/misc/shiftChange.ts diff --git a/server/services/ocp/controller/materials/lotTransfer.ts b/server/services/ocp/controller/materials/lotTransfer.ts index 7b75687..69144c3 100644 --- a/server/services/ocp/controller/materials/lotTransfer.ts +++ b/server/services/ocp/controller/materials/lotTransfer.ts @@ -6,9 +6,12 @@ import { tryCatch } from "../../../../globalUtils/tryCatch.js"; import { createLog } from "../../../logger/logger.js"; import { query } from "../../../sqlServer/prodSqlServer.js"; import { labelInfo } from "../../../sqlServer/querys/warehouse/labelInfo.js"; +import { format, formatDuration, intervalToDuration } from "date-fns"; +import { shiftChange } from "../../../sqlServer/querys/misc/shiftChange.js"; +import { success } from "zod/v4"; type NewLotData = { - runnungNumber: number; + runningNumber: number; lotNumber: number; originalAmount: number; level: number; @@ -16,6 +19,17 @@ type NewLotData = { type: "lot" | "eom"; }; +interface PendingJob { + timeoutId: NodeJS.Timeout; + runningNumber: string | number; + data: any; + consumeLot: any; + newQty: any; + scheduledFor: Date; +} + +export const pendingJobs = new Map(); + /** * Move manual material to a new lot. * @@ -28,11 +42,116 @@ type NewLotData = { * type what way are we lots */ export const lotMaterialTransfer = async (data: NewLotData) => { - let timeoutTrans: number = data.type === "lot" ? 1 : 10; + // check if we already have this running number scheduled + if (pendingJobs.has(data.runningNumber)) { + const job = pendingJobs.get(data.runningNumber) as PendingJob; + + const duration = intervalToDuration({ + start: new Date(), + end: job.scheduledFor, + }); + createLog( + "error", + "materials", + "ocp", + `${ + data.runningNumber + } is pending to be transfered already, remaining time ${formatDuration( + duration, + { format: ["hours", "minutes", "seconds"] } + )}` + ); + return { + success: false, + message: `${ + data.runningNumber + } is pending to be transfered already, remaining time ${formatDuration( + duration, + { format: ["hours", "minutes", "seconds"] } + )}`, + data: [], + }; + } + // get the shift time + const { data: shift, error: shiftError } = (await tryCatch( + query(shiftChange, "shift change from material.") + )) as any; + + if (shiftError) { + createLog( + "error", + "materials", + "ocp", + "There was an error getting the shift times will use fallback times" + ); + } + + // shift split + const shiftTimeSplit = shift?.data[0]?.shiftChange.split(":"); + //console.log(shiftTimeSplit); + // Current time + const now = new Date(); + + // Target time: today at 06:35 + const target = new Date( + now.getFullYear(), + now.getMonth(), + 1, //now.getDate(), + shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[0]) - 1 : 5, // this will parse the hour to remove teh zero + shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[1]) + 3 : 3, + 0, + 0 + ); + + // to early time + const early = new Date( + now.getFullYear(), + now.getMonth(), + 1, //now.getDate(), + shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[0]) - 1 : 5, // this will parse the hour to remove teh zero + shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[1]) : 0, + 0, + 0 + ); + + // next month just to be here + const nextMonth = new Date( + now.getFullYear(), + now.getMonth() + 1, + 1, //now.getDate(), + shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[0]) - 1 : 5, // this will parse the hour to remove teh zero + shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[1]) : 0, + 0, + 0 + ); + + // console.log(early, target); + // if we are to early return early only if we are sending over eom + if (data.type === "eom" && (early > now || target < now)) { + createLog( + "error", + "materials", + "ocp", + `Eom transfers is not allowed right now please try again at ${format( + nextMonth, + "M/d/yyyy hh:mm" + )} ` + ); + return { + success: false, + message: `Eom transfers is not allowed right now please try again at ${format( + nextMonth, + "M/d/yyyy hh:mm" + )} `, + data: [], + }; + } + + let timeoutTrans: number = data.type === "lot" ? 30 : 10; // get the barcode, and layoutID from the running number const { data: label, error: labelError } = (await tryCatch( query( - labelInfo.replace("[runningNr]", `${data.runnungNumber}`), + labelInfo.replace("[runningNr]", `${data.runningNumber}`), "Get label info" ) )) as any; @@ -56,11 +175,11 @@ export const lotMaterialTransfer = async (data: NewLotData) => { "error", "materials", "ocp", - `${data.runnungNumber}: dose not exist or no longer in stock.` + `${data.runningNumber}: dose not exist or no longer in stock.` ); return { success: false, - message: `${data.runnungNumber}: dose not exist or no longer in stock.`, + message: `${data.runningNumber}: dose not exist or no longer in stock.`, data: [], }; } @@ -72,11 +191,11 @@ export const lotMaterialTransfer = async (data: NewLotData) => { "error", "materials", "ocp", - `${data.runnungNumber}: currently in stock and not consumed to a lot.` + `${data.runningNumber}: currently in stock and not consumed to a lot.` ); return { success: false, - message: `${data.runnungNumber}: currently in stock and not consumed to a lot.`, + message: `${data.runningNumber}: currently in stock and not consumed to a lot.`, data: [], }; } @@ -132,11 +251,11 @@ export const lotMaterialTransfer = async (data: NewLotData) => { "error", "materials", "ocp", - `RN:${data.runnungNumber}, Reprinting Error: ${reprint.data.data.message}` + `RN:${data.runningNumber}, Reprinting Error: ${reprint.data.data.message}` ); return { success: false, - message: `RN:${data.runnungNumber}, Reprinting Error: ${reprint.data.data.message}`, + message: `RN:${data.runningNumber}, Reprinting Error: ${reprint.data.data.message}`, data: reprint, }; } @@ -161,11 +280,11 @@ export const lotMaterialTransfer = async (data: NewLotData) => { "error", "materials", "ocp", - `RN:${data.runnungNumber}, Return Error ${matReturn.data.data.errors[0].message}` + `RN:${data.runningNumber}, Return Error ${matReturn.data.data.errors[0].message}` ); return { success: false, - message: `RN:${data.runnungNumber}, Return Error ${matReturn.data.data.errors[0].message}`, + message: `RN:${data.runningNumber}, Return Error ${matReturn.data.data.errors[0].message}`, data: matReturn, }; } @@ -175,9 +294,66 @@ export const lotMaterialTransfer = async (data: NewLotData) => { barcode: label?.data[0].Barcode, }; + const delay = + data.type === "lot" + ? timeoutTrans * 1000 + : target.getTime() - now.getTime(); + + const transfer = await transferMaterial(delay, data, consumeLot, newQty); + + if (!transfer.success) { + return { + success: transfer.success, + message: transfer.message, + data: transfer.data, + }; + } + + const duration = intervalToDuration({ start: now, end: target }); + const pretty = formatDuration(duration, { + format: ["hours", "minutes", "seconds"], + }); + + if (data.type === "eom") { + return { + success: true, + message: `RN:${data.runningNumber}: qty: ${newQty}, will be transfered to lot: ${data.lotNumber}, in ${pretty} `, + data: [], + }; + } else { + return { + success: true, + message: `RN:${data.runningNumber}: qty: ${newQty}, was transfered to lot: ${data.lotNumber}`, + data: [], + }; + } +}; + +const transferMaterial = async ( + delay: number, + data: any, + consumeLot: any, + newQty: any +) => { + //console.log(data); + if (pendingJobs.has(data.runningNumber)) { + createLog( + "error", + "materials", + "ocp", + `${data.runningNumber} is pending to be transfered already` + ); + return { + success: false, + message: `${data.runningNumber} is pending to be transfered already`, + data: [], + }; + } + + const scheduledFor = new Date(Date.now() + delay); // sets the time out based on the type of transfer sent over. - setTimeout( - async () => { + const timeoutId = setTimeout(async () => { + try { const { data: matConsume, error: matConsumeError } = (await tryCatch( runProdApi({ @@ -187,45 +363,59 @@ export const lotMaterialTransfer = async (data: NewLotData) => { }) )) as any; - if (!matConsume.success) { + if (!matConsume?.success) { createLog( "error", "materials", "ocp", - `RN:${data.runnungNumber}, Consume Error ${matConsume.data.data.errors[0].message}` + `RN:${data.runningNumber}, Consume Error ${ + matConsume?.data?.data?.errors?.[0]?.message ?? + "Unknown" + }` ); - return { - success: false, - message: `RN:${data.runnungNumber}, Consume Error ${matConsume.data.data.errors[0].message}`, - data: matConsume, - }; + return; // still hits finally } createLog( "info", "materials", "ocp", - `RN:${data.runnungNumber}: qty: ${newQty}, was transfered to lot:${data.lotNumber}` + `RN:${data.runningNumber}: qty: ${newQty}, was transferred to lot:${data.lotNumber}` ); - }, - data.type === "lot" ? timeoutTrans * 1000 : timeoutTrans * 1000 * 60 - ); + } catch (err) { + createLog( + "error", + "materials", + "ocp", + `RN:${data.runningNumber}, ${err}` + ); + } finally { + // Always clear the pending entry, even if error + pendingJobs.delete(data.runningNumber); + } + }, delay); - if (data.type === "eom") { - return { - success: true, - message: `RN:${data.runnungNumber}: qty: ${newQty}, will be transfered to:${data.lotNumber}, in ${timeoutTrans}min`, - data: [], - }; - } else { - return { - success: true, - message: `RN:${data.runnungNumber}: qty: ${newQty}, was transfered to lot:${data.lotNumber}`, - data: [], - }; - } + pendingJobs.set(data.runningNumber, { + timeoutId, + runningNumber: data.runningNumber, + data, + consumeLot, + newQty, + scheduledFor, + }); + + // Immediately say we scheduled it + return { + success: true, + message: `Transfer for ${data.runningNumber} scheduled`, + data: [], + }; }; +// setInterval(() => { +// console.log(pendingJobs); +// }, 5000); + // setTimeout(async () => { // lotMaterialTransfer({ // runnungNumber: 603468, diff --git a/server/services/ocp/ocpService.ts b/server/services/ocp/ocpService.ts index c895e2b..4460ded 100644 --- a/server/services/ocp/ocpService.ts +++ b/server/services/ocp/ocpService.ts @@ -25,6 +25,7 @@ import bookInLabel from "./routes/labeling/bookIn.js"; import labelRatio from "./routes/labeling/getLabelRatio.js"; import resetRatio from "./routes/labeling/resetLabelRatio.js"; import materialTransferLot from "./routes/materials/lotTransfer.js"; +import pendingTransfers from "./routes/materials/currentPending.js"; import { zechitti1Connect } from "./controller/specialProcesses/zechettis/zechetti1.js"; const app = new OpenAPIHono(); @@ -51,6 +52,7 @@ const routes = [ dycoClose, // materials materialTransferLot, + pendingTransfers, ] as const; const setting = await db.select().from(settings); diff --git a/server/services/ocp/routes/materials/currentPending.ts b/server/services/ocp/routes/materials/currentPending.ts new file mode 100644 index 0000000..7c018dd --- /dev/null +++ b/server/services/ocp/routes/materials/currentPending.ts @@ -0,0 +1,51 @@ +// an external way to creating logs +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; +import { responses } from "../../../../globalUtils/routeDefs/responses.js"; +import { tryCatch } from "../../../../globalUtils/tryCatch.js"; +import { apiHit } from "../../../../globalUtils/apiHits.js"; + +import { pendingJobs } from "../../controller/materials/lotTransfer.js"; +import { format, formatDuration, intervalToDuration } from "date-fns"; + +const app = new OpenAPIHono({ strict: false }); + +app.openapi( + createRoute({ + tags: ["ocp"], + summary: "Returns pending transfers", + method: "get", + path: "/pendingtransfers", + + responses: responses(), + }), + async (c) => { + apiHit(c, { endpoint: "/pendingtransfers" }); + + const pending = Array.from(pendingJobs.entries()).map( + ([runningNumber, job]) => { + const duration = intervalToDuration({ + start: new Date(), + end: job.scheduledFor, + }); + return { + runningNumber, + lot: job.data?.lotNumber, + newQty: job.newQty, + consumeLot: job.consumeLot, + scheduledFor: format(job.scheduledFor, "M/d/yyyy HH:mm"), + remainingMs: formatDuration(duration, { + format: ["hours", "minutes", "seconds"], + }), + }; + } + ); + + //console.log(pending); + return c.json({ + success: true, + message: "Current Pending trnasfers", + data: [pending], + }); + } +); +export default app; diff --git a/server/services/ocp/routes/materials/lotTransfer.ts b/server/services/ocp/routes/materials/lotTransfer.ts index 991f63f..c2999ab 100644 --- a/server/services/ocp/routes/materials/lotTransfer.ts +++ b/server/services/ocp/routes/materials/lotTransfer.ts @@ -9,7 +9,7 @@ import { lotMaterialTransfer } from "../../controller/materials/lotTransfer.js"; const app = new OpenAPIHono({ strict: false }); const LotTransfer = z.object({ - runnungNumber: z.number().openapi({ example: 1234 }), + runningNumber: z.number().openapi({ example: 1234 }), lotNumber: z.number().openapi({ example: 1235 }), originalAmount: z.number().openapi({ example: 457 }), level: z.number().openapi({ examples: [0.24, 0.5, 0.75, 0.95] }), @@ -45,7 +45,7 @@ app.openapi( ); if (transferError) { - console.log(transferError); + //console.log(transferError); return c.json({ success: false, message: diff --git a/server/services/sqlServer/querys/misc/shiftChange.ts b/server/services/sqlServer/querys/misc/shiftChange.ts new file mode 100644 index 0000000..7e36780 --- /dev/null +++ b/server/services/sqlServer/querys/misc/shiftChange.ts @@ -0,0 +1,4 @@ +export const shiftChange = ` +select top(1) convert(varchar(8) ,convert(time,startdate), 108) as shiftChange + from [test1_AlplaPROD2.0_Read].[masterData].[ShiftDefinition] where teamNumber = 1 +`; -- 2.49.1 From 8c296c5b783f42f85c30a955d6e9d540c50dcfbe Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 28 Aug 2025 10:15:13 -0500 Subject: [PATCH 081/166] test(forklifts): forklift starting process --- database/schema/forkliftHours.ts | 0 database/schema/forkliftLeases.ts | 0 database/schema/forklifts.ts | 0 frontend/package-lock.json | 48 ++++++--- frontend/package.json | 1 + package-lock.json | 160 ++++++++++++++++-------------- 6 files changed, 124 insertions(+), 85 deletions(-) create mode 100644 database/schema/forkliftHours.ts create mode 100644 database/schema/forkliftLeases.ts create mode 100644 database/schema/forklifts.ts diff --git a/database/schema/forkliftHours.ts b/database/schema/forkliftHours.ts new file mode 100644 index 0000000..e69de29 diff --git a/database/schema/forkliftLeases.ts b/database/schema/forkliftLeases.ts new file mode 100644 index 0000000..e69de29 diff --git a/database/schema/forklifts.ts b/database/schema/forklifts.ts new file mode 100644 index 0000000..e69de29 diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 31e15ac..bd9a808 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -21,6 +21,7 @@ "@radix-ui/react-select": "^2.2.5", "@radix-ui/react-separator": "^1.1.7", "@radix-ui/react-slot": "^1.2.3", + "@radix-ui/react-switch": "^1.2.6", "@radix-ui/react-tabs": "^1.1.12", "@radix-ui/react-tooltip": "^1.2.7", "@react-pdf/renderer": "^4.3.0", @@ -2072,6 +2073,41 @@ } } }, + "node_modules/@radix-ui/react-switch": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@radix-ui/react-switch/-/react-switch-1.2.6.tgz", + "integrity": "sha512-bByzr1+ep1zk4VubeEVViV592vu2lHE2BZY5OnzehZqOOgogN80+mNtCqPkhn2gklJqOpxWgPoYTSnhBCqpOXQ==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.3", + "@radix-ui/react-compose-refs": "1.1.2", + "@radix-ui/react-context": "1.1.2", + "@radix-ui/react-primitive": "2.1.3", + "@radix-ui/react-use-controllable-state": "1.2.2", + "@radix-ui/react-use-previous": "1.1.1", + "@radix-ui/react-use-size": "1.1.1" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-switch/node_modules/@radix-ui/primitive": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@radix-ui/primitive/-/primitive-1.1.3.tgz", + "integrity": "sha512-JTF99U/6XIjCBo0wqkU5sK10glYe27MRRsfwoiq5zzOEZLHU3A3KCMa5X/azekYRCJ0HlwI0crAXS/5dEHTzDg==", + "license": "MIT" + }, "node_modules/@radix-ui/react-tabs": { "version": "1.1.12", "resolved": "https://registry.npmjs.org/@radix-ui/react-tabs/-/react-tabs-1.1.12.tgz", @@ -5316,18 +5352,6 @@ "node": ">= 4" } }, - "node_modules/immer": { - "version": "10.1.1", - "resolved": "https://registry.npmjs.org/immer/-/immer-10.1.1.tgz", - "integrity": "sha512-s2MPrmjovJcoMaHtx6K11Ra7oD05NT97w1IC5zpMkT6Atjr7H8LjaDd81iIxUYpMKSRRNMJE703M1Fhr/TctHw==", - "license": "MIT", - "optional": true, - "peer": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/immer" - } - }, "node_modules/import-fresh": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", diff --git a/frontend/package.json b/frontend/package.json index cae6a08..7376d8b 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -25,6 +25,7 @@ "@radix-ui/react-select": "^2.2.5", "@radix-ui/react-separator": "^1.1.7", "@radix-ui/react-slot": "^1.2.3", + "@radix-ui/react-switch": "^1.2.6", "@radix-ui/react-tabs": "^1.1.12", "@radix-ui/react-tooltip": "^1.2.7", "@react-pdf/renderer": "^4.3.0", diff --git a/package-lock.json b/package-lock.json index 9979cf6..ce8c5f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,6 +29,7 @@ "fast-xml-parser": "^5.2.5", "fs-extra": "^11.3.0", "jsonwebtoken": "^9.0.2", + "morgan": "^1.10.1", "mssql": "^11.0.1", "nodemailer": "^7.0.3", "nodemailer-express-handlebars": "^7.0.0", @@ -1548,14 +1549,6 @@ "url": "https://paulmillr.com/funding/" } }, - "node_modules/@petamoriken/float16": { - "version": "3.9.2", - "resolved": "https://registry.npmjs.org/@petamoriken/float16/-/float16-3.9.2.tgz", - "integrity": "sha512-VgffxawQde93xKxT3qap3OH+meZf7VaSB5Sqd4Rqc+FP5alWbpOyan/7tRbOAvynjpG3GpdtAuGU/NdhQpmrog==", - "license": "MIT", - "optional": true, - "peer": true - }, "node_modules/@scalar/core": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/@scalar/core/-/core-0.3.3.tgz", @@ -2118,6 +2111,24 @@ ], "license": "MIT" }, + "node_modules/basic-auth": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", + "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", + "license": "MIT", + "dependencies": { + "safe-buffer": "5.1.2" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/basic-auth/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "license": "MIT" + }, "node_modules/bcryptjs": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-3.0.2.tgz", @@ -3379,6 +3390,15 @@ "node": ">=0.4.0" } }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/detect-file": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", @@ -3716,6 +3736,12 @@ "node": ">=16" } }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", @@ -4227,70 +4253,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/gel": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/gel/-/gel-2.0.1.tgz", - "integrity": "sha512-gfem3IGvqKqXwEq7XseBogyaRwGsQGuE7Cw/yQsjLGdgiyqX92G1xENPCE0ltunPGcsJIa6XBOTx/PK169mOqw==", - "license": "Apache-2.0", - "optional": true, - "peer": true, - "dependencies": { - "@petamoriken/float16": "^3.8.7", - "debug": "^4.3.4", - "env-paths": "^3.0.0", - "semver": "^7.6.2", - "shell-quote": "^1.8.1", - "which": "^4.0.0" - }, - "bin": { - "gel": "dist/cli.mjs" - }, - "engines": { - "node": ">= 18.0.0" - } - }, - "node_modules/gel/node_modules/env-paths": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-3.0.0.tgz", - "integrity": "sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==", - "license": "MIT", - "optional": true, - "peer": true, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/gel/node_modules/isexe": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.1.tgz", - "integrity": "sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==", - "license": "ISC", - "optional": true, - "peer": true, - "engines": { - "node": ">=16" - } - }, - "node_modules/gel/node_modules/which": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/which/-/which-4.0.0.tgz", - "integrity": "sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg==", - "license": "ISC", - "optional": true, - "peer": true, - "dependencies": { - "isexe": "^3.1.1" - }, - "bin": { - "node-which": "bin/which.js" - }, - "engines": { - "node": "^16.13.0 || >=18.0.0" - } - }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -6080,6 +6042,37 @@ "node": ">=0.10.0" } }, + "node_modules/morgan": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.10.1.tgz", + "integrity": "sha512-223dMRJtI/l25dJKWpgij2cMtywuG/WiUKXdvwfbhGKBhy1puASqXwFzmWZ7+K73vUPoR7SS2Qz2cI/g9MKw0A==", + "license": "MIT", + "dependencies": { + "basic-auth": "~2.0.1", + "debug": "2.6.9", + "depd": "~2.0.0", + "on-finished": "~2.3.0", + "on-headers": "~1.1.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/morgan/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/morgan/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -6236,6 +6229,27 @@ "node": ">=14.0.0" } }, + "node_modules/on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/on-headers": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.1.0.tgz", + "integrity": "sha512-737ZY3yNnXy37FHkQxPzt4UZ2UWPWiCZWLvFZ4fu5cueciegX0zGPnrlY6bwRg4FdQOe9YU8MkmJwGhoMybl8A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -7396,7 +7410,7 @@ "version": "1.8.2", "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.2.tgz", "integrity": "sha512-AzqKpGKjrj7EM6rKVQEPpB288oCfnrEIuyoT9cyF4nmGa7V8Zk6f7RRqYisX8X9m+Q7bd632aZW4ky7EhbQztA==", - "devOptional": true, + "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" -- 2.49.1 From 468f933168cc40be0c1b159c31948a2c97600390 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 28 Aug 2025 10:15:41 -0500 Subject: [PATCH 082/166] fix(eom stats): corrections to the eom inv stuff to be proper tiems --- frontend/src/components/eom/EomPage.tsx | 126 +----------------------- server/services/eom/eomService.ts | 34 ++++++- 2 files changed, 32 insertions(+), 128 deletions(-) diff --git a/frontend/src/components/eom/EomPage.tsx b/frontend/src/components/eom/EomPage.tsx index 144ccb1..8acb92d 100644 --- a/frontend/src/components/eom/EomPage.tsx +++ b/frontend/src/components/eom/EomPage.tsx @@ -1,131 +1,9 @@ -import {useSessionStore} from "@/lib/store/sessionStore"; -import {LstCard} from "../extendedUI/LstCard"; -import {Tabs, TabsContent, TabsList, TabsTrigger} from "../ui/tabs"; -import {useModuleStore} from "@/lib/store/useModuleStore"; -import {Table, TableBody, TableCell, TableHead, TableHeader, TableRow} from "../ui/table"; -import {Skeleton} from "../ui/skeleton"; - -import {Link, useRouter} from "@tanstack/react-router"; -import {Popover, PopoverContent, PopoverTrigger} from "../ui/popover"; -import {Button} from "../ui/button"; -import {cn} from "@/lib/utils"; -import {CalendarIcon} from "lucide-react"; -import {format, startOfMonth} from "date-fns"; -import {Calendar} from "../ui/calendar"; -import {useState} from "react"; -import {toast} from "sonner"; -import KFP from "./KFP"; +import MaterialCheck from "./materialCheck/MaterialCheck"; export default function EomPage() { - const {modules} = useModuleStore(); - const {user} = useSessionStore(); - const router = useRouter(); - const [date, setDate] = useState(); - - if (!user) { - router.navigate({to: "/"}); - } - const eomMod = modules.filter((m) => m.name === "eom"); - // the users current role for eom is? - const role: any = user?.roles.filter((r) => r.module_id === eomMod[0].module_id) || ""; - - const tabs = [ - {key: "kfp", label: "Key Figures", roles: ["admin", "systemAdmin"], content: }, - {key: "fg", label: "Finished Goods", roles: ["admin", "systemAdmin"], content: }, - {key: "mm", label: "Main Material", roles: ["admin", "systemAdmin"], content: }, - {key: "mb", label: "Master Batch", roles: ["admin", "systemAdmin"], content: }, - {key: "ab", label: "Additive", roles: ["admin", "systemAdmin"], content: }, - {key: "pp", label: "Purchased Preforms", roles: ["admin", "systemAdmin"], content: }, - {key: "pre", label: "Preforms", roles: ["admin", "systemAdmin"], content: }, - {key: "pkg", label: "Packaging", roles: ["admin", "systemAdmin"], content: }, - {key: "ui", label: "Undefined Items", roles: ["admin"], content: }, - ]; return (
-
- - - - - - - - -
- -
-
- - - - {tabs.map((tab) => { - if (tab.roles.includes(role[0].role)) - return {tab.label}; - })} - - {tabs.map((tab) => { - if (tab.roles.includes(role[0].role)) - return {tab.content}; - })} - +
); } - -function DummyContent() { - return ( - - - - - Av - Description - Material Type - Waste - Loss / Gain $$ - - - - - {Array(10) - .fill(0) - .map((_, i) => ( - - - - {i} - - - - - - - - - - - - - - - {/* - - */} - - ))} - -
-
- ); -} diff --git a/server/services/eom/eomService.ts b/server/services/eom/eomService.ts index 159f291..2821216 100644 --- a/server/services/eom/eomService.ts +++ b/server/services/eom/eomService.ts @@ -6,17 +6,43 @@ import stats from "./route/stats.js"; import history from "./route/invHistory.js"; import { createJob } from "../notifications/utils/processNotifications.js"; import { historicalInvIMmport } from "./utils/historicalInv.js"; +import { tryCatch } from "../../globalUtils/tryCatch.js"; +import { query } from "../sqlServer/prodSqlServer.js"; +import { shiftChange } from "../sqlServer/querys/misc/shiftChange.js"; +import { createLog } from "../logger/logger.js"; const routes = [stats, history] as const; const appRoutes = routes.forEach((route) => { app.route("/eom", route); }); -// setTimeout(() => { -// historicalInvIMmport(); -// }, 5 * 1000); +setTimeout(async () => { + const { data: shift, error: shiftError } = (await tryCatch( + query(shiftChange, "shift change from material.") + )) as any; + + if (shiftError) { + createLog( + "error", + "eom", + "eom", + "There was an error getting the shift times will use fallback times" + ); + } + + // shift split + const shiftTimeSplit = shift?.data[0]?.shiftChange.split(":"); + + const cronSetup = `${ + shiftTimeSplit.length > 0 ? `${parseInt(shiftTimeSplit[1])}` : "0" + } ${ + shiftTimeSplit.length > 0 ? `${parseInt(shiftTimeSplit[0])}` : "7" + } * * *`; + + //console.log(cronSetup); + createJob("eom_historical_inv", cronSetup, historicalInvIMmport); +}, 5 * 1000); // the time we want to run the hostircal data should be the same time the historical data run on the server // getting this from the shift time -createJob("eom_historical_inv", "0 7 * * *", historicalInvIMmport); export default app; -- 2.49.1 From 795da35141ba3d2c4ddaefa2fe2a749213c0c6d8 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 28 Aug 2025 10:17:15 -0500 Subject: [PATCH 083/166] ci(release): bump build number to 576 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index da4732a..39403b3 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 575, + "build": 576, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 9bd66942f538edb0c52154c5130bc3aca0983b60 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 28 Aug 2025 10:18:13 -0500 Subject: [PATCH 084/166] chore(release): 2.26.0 --- CHANGELOG.md | 37 +++++++++++++++++++++++++++++++++++++ package-lock.json | 4 ++-- package.json | 4 ++-- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4394b89..e3882ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,42 @@ # All CHanges to LST can be found below. +## [2.26.0](https://git.tuffraid.net/cowch/lstV2/compare/v2.25.0...v2.26.0) (2025-08-28) + + +### 🛠️ Code Refactor + +* **labeling:** moved bookin fails inside bookin as it could be off ([df42319](https://git.tuffraid.net/cowch/lstV2/commits/df423192bfc5e2389872147e92b7d22e648a2927)) +* **labeling:** removed the wrong import ([788d636](https://git.tuffraid.net/cowch/lstV2/commits/788d6367a380a81722a76bd6adbe18831d88eeb5)) +* **materials:** changes for permissions on material consume ([3148aa7](https://git.tuffraid.net/cowch/lstV2/commits/3148aa79d73823499824cc0601fcabec97bb4f9d)) +* **materials:** changes to allow exact and eom transfers ([0a6ddea](https://git.tuffraid.net/cowch/lstV2/commits/0a6ddea8c0d2773aba00266df7e2839879d10cb1)) +* **notifcations:** changed hour to min in ti intergrations ([73d38ba](https://git.tuffraid.net/cowch/lstV2/commits/73d38ba3fe7ab4d5ca3a4a1e1c99fdd7bf5e92dc)) +* **tms intergration:** corrected how we added gl coding ([37f82a9](https://git.tuffraid.net/cowch/lstV2/commits/37f82a9710cf20e6d0d056893c9da43c70b9e619)) + + +### 🌟 Enhancements + +* **materials:** added in a bigger window on eom transfer lots ([53ed2c4](https://git.tuffraid.net/cowch/lstV2/commits/53ed2c4e6a0d3fafafbcb655b5d06cff6324363d)) +* **ocp:** zechetti 1 added in ([27586e9](https://git.tuffraid.net/cowch/lstV2/commits/27586e923a106f2b8dd804e9c8292edd5d009cf0)) +* **rfid:** new check to remove tags that have been at a line longer than 6 hours ([0ba338d](https://git.tuffraid.net/cowch/lstV2/commits/0ba338d48037f7def74196ca3f41de5807e2cb31)) +* **tms:** a clean up function was added to remove releases added as blockers older than 45d ([662a951](https://git.tuffraid.net/cowch/lstV2/commits/662a951b9871d5dfc21f01a76ba23be77b475757)) + + +### 📝 Testing Code + +* **forklifts:** forklift starting process ([8c296c5](https://git.tuffraid.net/cowch/lstV2/commits/8c296c5b783f42f85c30a955d6e9d540c50dcfbe)) + + +### 🐛 Bug fixes + +* **bookin:** corrected the error received from the book in fail ([369d160](https://git.tuffraid.net/cowch/lstV2/commits/369d16018c8be9fdb936afbc3749b3f9fcea58c8)) +* **dm:** corrected the remark section so its properly sent over ([68901a8](https://git.tuffraid.net/cowch/lstV2/commits/68901a857ae5161f024da9cdefc0a981a4907205)) +* **eom stats:** corrections to the eom inv stuff to be proper tiems ([468f933](https://git.tuffraid.net/cowch/lstV2/commits/468f933168cc40be0c1b159c31948a2c97600390)) +* **fake edi:** removed console log ([24a97af](https://git.tuffraid.net/cowch/lstV2/commits/24a97afe064d5c44872e24e6e3299ed5f2977a78)) +* **material check:** alt mm causing issues and utilizing an 80% to just be ok ([f4f3de4](https://git.tuffraid.net/cowch/lstV2/commits/f4f3de49cae277ffa158116d1802495b27fa8e75)) +* **ocp:** zechetti type correction to include the printer name ([4486fe2](https://git.tuffraid.net/cowch/lstV2/commits/4486fe24362b4811d7cff0467c7f2f85e0c9e3c4)) +* **produser:** changes to include DM ([8d6ead3](https://git.tuffraid.net/cowch/lstV2/commits/8d6ead3aa11aed95ffa3537fbe72cfa9bbceb380)) +* **transferlots:** missed adding this ([846ac47](https://git.tuffraid.net/cowch/lstV2/commits/846ac479b1bf211a7891ae362525ea14580ff0cc)) + ## [2.25.0](https://git.tuffraid.net/cowch/lstV2/compare/v2.24.1...v2.25.0) (2025-08-21) diff --git a/package-lock.json b/package-lock.json index ce8c5f7..3d7bdf3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "lstv2", - "version": "2.25.0", + "version": "2.26.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "lstv2", - "version": "2.25.0", + "version": "2.26.0", "dependencies": { "@dotenvx/dotenvx": "^1.45.1", "@hono/node-server": "^1.14.4", diff --git a/package.json b/package.json index 39403b3..816a91f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lstv2", - "version": "2.25.0", + "version": "2.26.0", "type": "module", "scripts": { "dev": "concurrently -n \"server,frontend\" -c \"#007755,#2f6da3\" \"npm run dev:server\" \"cd frontend && npm run dev\"", @@ -94,4 +94,4 @@ "xlsx": "^0.18.5", "zod": "^3.25.67" } -} \ No newline at end of file +} -- 2.49.1 From 34849e15d146e9d380ddd97a051c0881b3619b02 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 28 Aug 2025 10:19:10 -0500 Subject: [PATCH 085/166] ci(release): bump build number to 577 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 816a91f..e918e82 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 576, + "build": 577, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { @@ -94,4 +94,4 @@ "xlsx": "^0.18.5", "zod": "^3.25.67" } -} +} \ No newline at end of file -- 2.49.1 From c6f6ef626295f452cdf26f6776b74cfb3b1a10f5 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 28 Aug 2025 10:56:49 -0500 Subject: [PATCH 086/166] fix(frontend): typos --- .../materialHelper/consumption/TransferToNextLot.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/logistics/materialHelper/consumption/TransferToNextLot.tsx b/frontend/src/components/logistics/materialHelper/consumption/TransferToNextLot.tsx index e6ac373..33f4b20 100644 --- a/frontend/src/components/logistics/materialHelper/consumption/TransferToNextLot.tsx +++ b/frontend/src/components/logistics/materialHelper/consumption/TransferToNextLot.tsx @@ -23,7 +23,7 @@ export default function TransferToNextLot() { const form = useAppForm({ defaultValues: { - runnungNumber: "", + runningNumber: "", lotNumber: "", originalAmount: "", amount: "", @@ -33,7 +33,7 @@ export default function TransferToNextLot() { //toast.success("603468: qty: 361, was transfered to lot:24897"); try { const res = await axios.post("/api/ocp/materiallottransfer", { - runnungNumber: Number(value.runnungNumber), + runningNumber: Number(value.runningNumber), lotNumber: Number(value.lotNumber), originalAmount: Number(value.originalAmount), level: Number( @@ -215,7 +215,7 @@ export default function TransferToNextLot() { >
( Date: Thu, 28 Aug 2025 11:09:44 -0500 Subject: [PATCH 087/166] ci(release): bump build number to 578 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e918e82..2b0343e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 577, + "build": 578, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From af47c1582e6489a3db92ff3a5991221577e4601b Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 29 Aug 2025 08:59:50 -0500 Subject: [PATCH 088/166] ci(release): bump build number to 579 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b0343e..3734d3e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 578, + "build": 579, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 7cc3778506fc92392ca8431aee0edb203861e10d Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 29 Aug 2025 11:26:26 -0500 Subject: [PATCH 089/166] feat(eom): lastSales, lastPurch added to be pulled with new template --- .../barcodeGenerator/CommonCommands.tsx | 5 ++- .../eom/controller/getHistoricalInvByDate.ts | 32 ++++++++++++++ .../eom/controller/getLastPurchasesPrice.ts | 24 +++++++++++ .../eom/controller/getLastestSalesPrice.ts | 23 ++++++++++ server/services/eom/eomService.ts | 5 ++- .../services/eom/route/getLastPurchPrice.ts | 41 ++++++++++++++++++ .../services/eom/route/getLastSalesPrice.ts | 43 +++++++++++++++++++ server/services/eom/route/invHistory.ts | 17 +++++--- server/services/eom/utils/historicalInv.ts | 15 ++++++- .../sqlServer/querys/dataMart/article.ts | 10 +++-- .../sqlServer/querys/eom/lastSalesprice.ts | 17 ++++++++ .../sqlServer/querys/eom/lstPurchasePrice.ts | 17 ++++++++ 12 files changed, 237 insertions(+), 12 deletions(-) create mode 100644 server/services/eom/controller/getHistoricalInvByDate.ts create mode 100644 server/services/eom/controller/getLastPurchasesPrice.ts create mode 100644 server/services/eom/controller/getLastestSalesPrice.ts create mode 100644 server/services/eom/route/getLastPurchPrice.ts create mode 100644 server/services/eom/route/getLastSalesPrice.ts create mode 100644 server/services/sqlServer/querys/eom/lastSalesprice.ts create mode 100644 server/services/sqlServer/querys/eom/lstPurchasePrice.ts diff --git a/frontend/src/components/logistics/barcodeGenerator/CommonCommands.tsx b/frontend/src/components/logistics/barcodeGenerator/CommonCommands.tsx index 139405f..cdd2a06 100644 --- a/frontend/src/components/logistics/barcodeGenerator/CommonCommands.tsx +++ b/frontend/src/components/logistics/barcodeGenerator/CommonCommands.tsx @@ -6,7 +6,10 @@ import Barcode from "react-barcode"; import { BarcodePDFExport } from "./BarcodeExport"; import { BulkBarcodePDFExport } from "./BulkExport"; -const commoncmd = [{ name: "Relocate", commandId: 33 }]; +const commoncmd = [ + { name: "Relocate", commandId: 33 }, + //-{ name: "Stock in", commandId: 22 }, +]; export default function CommonCommands() { const [checked, setChecked] = useState([]); diff --git a/server/services/eom/controller/getHistoricalInvByDate.ts b/server/services/eom/controller/getHistoricalInvByDate.ts new file mode 100644 index 0000000..e9f245c --- /dev/null +++ b/server/services/eom/controller/getHistoricalInvByDate.ts @@ -0,0 +1,32 @@ +import { eq } from "drizzle-orm"; +import { db } from "../../../../database/dbclient.js"; +import { invHistoricalData } from "../../../../database/schema/historicalINV.js"; +import { tryCatch } from "../../../globalUtils/tryCatch.js"; +import { format } from "date-fns"; + +export const historicalInvByDate = async (date: string) => { + const histDate = new Date(date); + + const { data, error } = (await tryCatch( + db + .select() + .from(invHistoricalData) + .where( + eq(invHistoricalData.histDate, format(histDate, "yyyy-MM-dd")) + ) + )) as any; + + if (error) { + return { + success: false, + message: "There was an error with getting the inventory", + data: error, + }; + } + + return { + success: true, + message: `Historical inventory for ${date}`, + data: data, + }; +}; diff --git a/server/services/eom/controller/getLastPurchasesPrice.ts b/server/services/eom/controller/getLastPurchasesPrice.ts new file mode 100644 index 0000000..1ccf2a4 --- /dev/null +++ b/server/services/eom/controller/getLastPurchasesPrice.ts @@ -0,0 +1,24 @@ +import { tryCatch } from "../../../globalUtils/tryCatch.js"; +import { format } from "date-fns"; +import { query } from "../../sqlServer/prodSqlServer.js"; +import { lastPurchasePrice } from "../../sqlServer/querys/eom/lstPurchasePrice.js"; + +export const lastPurchase = async () => { + const { data, error } = (await tryCatch( + query(lastPurchasePrice, "Last purchase price") + )) as any; + + if (error) { + return { + success: false, + message: "Error getting the last purchase price", + data: error, + }; + } + + return { + success: true, + message: `Last purchase price for all av in the last 5 years`, + data: data.data, + }; +}; diff --git a/server/services/eom/controller/getLastestSalesPrice.ts b/server/services/eom/controller/getLastestSalesPrice.ts new file mode 100644 index 0000000..707a1cf --- /dev/null +++ b/server/services/eom/controller/getLastestSalesPrice.ts @@ -0,0 +1,23 @@ +import { tryCatch } from "../../../globalUtils/tryCatch.js"; +import { query } from "../../sqlServer/prodSqlServer.js"; +import { lastSalesPriceCheck } from "../../sqlServer/querys/eom/lastSalesprice.js"; + +export const lastSales = async (date: string) => { + const { data, error } = (await tryCatch( + query(lastSalesPriceCheck.replace("[date]", date), "Last sales price") + )) as any; + + if (error) { + return { + success: false, + message: "Error getting the last sales price", + data: error, + }; + } + + return { + success: true, + message: `Last sales price for all av in the last 5 years`, + data: data.data, + }; +}; diff --git a/server/services/eom/eomService.ts b/server/services/eom/eomService.ts index 2821216..c220a2e 100644 --- a/server/services/eom/eomService.ts +++ b/server/services/eom/eomService.ts @@ -10,7 +10,10 @@ import { tryCatch } from "../../globalUtils/tryCatch.js"; import { query } from "../sqlServer/prodSqlServer.js"; import { shiftChange } from "../sqlServer/querys/misc/shiftChange.js"; import { createLog } from "../logger/logger.js"; -const routes = [stats, history] as const; +import lastPurch from "./route/getLastPurchPrice.js"; +import lastSales from "./route/getLastSalesPrice.js"; + +const routes = [stats, history, lastPurch, lastSales] as const; const appRoutes = routes.forEach((route) => { app.route("/eom", route); diff --git a/server/services/eom/route/getLastPurchPrice.ts b/server/services/eom/route/getLastPurchPrice.ts new file mode 100644 index 0000000..ad54cd9 --- /dev/null +++ b/server/services/eom/route/getLastPurchPrice.ts @@ -0,0 +1,41 @@ +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; +import { apiHit } from "../../../globalUtils/apiHits.js"; +import { responses } from "../../../globalUtils/routeDefs/responses.js"; + +import { lastPurchase } from "../controller/getLastPurchasesPrice.js"; + +const app = new OpenAPIHono({ strict: false }); + +app.openapi( + createRoute({ + tags: ["eom"], + summary: "Returns last sales price.", + method: "get", + path: "/lastpurchprice", + responses: responses(), + }), + async (c) => { + //const body = await c.req.json(); + // make sure we have a vaid user being accessed thats really logged in + + apiHit(c, { endpoint: "/lastpurchprice" }); + try { + const res = await lastPurchase(); + + return c.json( + { success: res.success, message: res.message, data: res.data }, + 200 + ); + } catch (error) { + return c.json( + { + success: false, + message: "There was an error posting the eom stat.", + data: error, + }, + 400 + ); + } + } +); +export default app; diff --git a/server/services/eom/route/getLastSalesPrice.ts b/server/services/eom/route/getLastSalesPrice.ts new file mode 100644 index 0000000..61150b3 --- /dev/null +++ b/server/services/eom/route/getLastSalesPrice.ts @@ -0,0 +1,43 @@ +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; +import { apiHit } from "../../../globalUtils/apiHits.js"; +import { responses } from "../../../globalUtils/routeDefs/responses.js"; + +import { lastPurchase } from "../controller/getLastPurchasesPrice.js"; +import { lastSales } from "../controller/getLastestSalesPrice.js"; + +const app = new OpenAPIHono({ strict: false }); + +app.openapi( + createRoute({ + tags: ["eom"], + summary: "Returns last sales price.", + method: "get", + path: "/lastsalesprice", + responses: responses(), + }), + async (c) => { + //const body = await c.req.json(); + const month: string = c.req.query("month") ?? ""; + // make sure we have a vaid user being accessed thats really logged in + + apiHit(c, { endpoint: "/lastsalesprice" }); + try { + const res = await lastSales(month); + + return c.json( + { success: res.success, message: res.message, data: res.data }, + 200 + ); + } catch (error) { + return c.json( + { + success: false, + message: "There was an error posting the eom stat.", + data: error, + }, + 400 + ); + } + } +); +export default app; diff --git a/server/services/eom/route/invHistory.ts b/server/services/eom/route/invHistory.ts index bb7a420..9f1d54b 100644 --- a/server/services/eom/route/invHistory.ts +++ b/server/services/eom/route/invHistory.ts @@ -1,6 +1,7 @@ import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; import { apiHit } from "../../../globalUtils/apiHits.js"; import { responses } from "../../../globalUtils/routeDefs/responses.js"; +import { historicalInvByDate } from "../controller/getHistoricalInvByDate.js"; const app = new OpenAPIHono({ strict: false }); const EomStat = z.object({ @@ -12,20 +13,24 @@ const EomStat = z.object({ app.openapi( createRoute({ tags: ["eom"], - summary: "Gets the correct eom history.", - method: "post", + summary: "Gets History Data by date.", + method: "get", path: "/histinv", - request: { - params: EomStat, - }, responses: responses(), }), async (c) => { //const body = await c.req.json(); // make sure we have a vaid user being accessed thats really logged in + const month: string = c.req.query("month") ?? ""; + apiHit(c, { endpoint: "/histinv" }); try { - return c.json({ success: true, message: "", data: [] }, 200); + const res = await historicalInvByDate(month); + + return c.json( + { success: res.success, message: res.message, data: res.data }, + 200 + ); } catch (error) { return c.json( { diff --git a/server/services/eom/utils/historicalInv.ts b/server/services/eom/utils/historicalInv.ts index 9e63f15..767cc56 100644 --- a/server/services/eom/utils/historicalInv.ts +++ b/server/services/eom/utils/historicalInv.ts @@ -8,6 +8,7 @@ import { totalInvNoRn } from "../../sqlServer/querys/dataMart/totalINV.js"; import { format } from "date-fns-tz"; import { serverSettings } from "../../server/controller/settings/getSettings.js"; import { deleteHistory } from "./removeHistorical.js"; +import { activeArticle } from "../../sqlServer/querys/dataMart/article.js"; export const historicalInvIMmport = async () => { const plantToken = serverSettings.filter((n) => n.name === "plantToken"); @@ -52,6 +53,12 @@ export const historicalInvIMmport = async () => { return; } + const { data: articles, error: avError } = (await tryCatch( + query(activeArticle, "Get active articles") + )) as any; + + const av = articles.data.length > 0 ? articles.data : ([] as any); + const importInv = inv.data ? inv.data : []; const eomImportData = importInv.map((i: any) => { return { @@ -59,7 +66,13 @@ export const historicalInvIMmport = async () => { plantToken: plantToken[0].value, article: i.av, articleDescription: i.Alias, - materialType: "", + materialType: + av.filter((a: any) => a.IdArtikelvarianten === i.av) + .length > 0 + ? av.filter( + (a: any) => a.IdArtikelvarianten === i.av + )[0]?.TypeOfMaterial + : "Item not defined", total_QTY: i.Total_PalletQTY, avaliable_QTY: i.Avaliable_PalletQTY, coa_QTY: i.COA_QTY, diff --git a/server/services/sqlServer/querys/dataMart/article.ts b/server/services/sqlServer/querys/dataMart/article.ts index 4a42127..268a158 100644 --- a/server/services/sqlServer/querys/dataMart/article.ts +++ b/server/services/sqlServer/querys/dataMart/article.ts @@ -43,7 +43,9 @@ V_Artikel.ArtikelvariantenTypBez = 'Gaylord' or V_Artikel.ArtikelvariantenTypBez = 'Misc. Packaging' or V_Artikel.ArtikelvariantenTypBez = 'Sleeve' or V_Artikel.ArtikelvariantenTypBez = 'Plastic Bag' or -V_Artikel.ArtikelvariantenTypBez = 'Purch Spout' +V_Artikel.ArtikelvariantenTypBez = 'Purch Spout' or +V_Artikel.ArtikelvariantenTypBez = 'Seal' or +V_Artikel.ArtikelvariantenTypBez = 'Tape' THEN 'PKG' WHEN V_Artikel.ArtikelvariantenTypBez='HD-PE' or V_Artikel.ArtikelvariantenTypBez='HD-PE PCR' or @@ -77,7 +79,8 @@ V_Artikel.ArtikelvariantenTypBez = 'Purchased Caps' or V_Artikel.ArtikelvariantenTypBez = 'Purchased_preform' THEN 'Purchased_preform' When -V_Artikel.ArtikelvariantenTypBez = 'Closures' +V_Artikel.ArtikelvariantenTypBez = 'Closures' or +V_Artikel.ArtikelvariantenTypBez = 'Cap' THEN 'Caps' When V_Artikel.ArtikelvariantenTypBez = 'Dummy' @@ -95,7 +98,8 @@ V_Artikel.ProdBereichBez = 'IM-Caps' or V_Artikel.ProdBereichBez = 'IM-PET' or V_Artikel.ProdBereichBez = 'PRINT OFFICE' or V_Artikel.ProdBereichBez = 'EBM' or -V_Artikel.ProdBereichBez = 'ISBM' +V_Artikel.ProdBereichBez = 'ISBM' or +V_Artikel.ProdBereichBez = 'IM-Finishing' Then 'FG' Else 'not Defined Profit Center' end, diff --git a/server/services/sqlServer/querys/eom/lastSalesprice.ts b/server/services/sqlServer/querys/eom/lastSalesprice.ts new file mode 100644 index 0000000..87e8303 --- /dev/null +++ b/server/services/sqlServer/querys/eom/lastSalesprice.ts @@ -0,0 +1,17 @@ +export const lastSalesPriceCheck = ` +use AlplaPROD_test1 + +select * from +(select IdArtikelvarianten as av, +VKPreis as salesPrice, +MPB, FWMPAlpla, +FWMPB, +ROW_NUMBER() over(partition by IdArtikelVarianten order by gueltigabdatum desc) rn, +convert(date, gueltigabdatum, 120) as validDate +from dbo.T_HistoryVK (nolock) +where convert(date, gueltigabdatum, 120) <= '[date]' and StandardKunde = 1) a +where rn =1 +order by av asc, +validDate desc + +`; diff --git a/server/services/sqlServer/querys/eom/lstPurchasePrice.ts b/server/services/sqlServer/querys/eom/lstPurchasePrice.ts new file mode 100644 index 0000000..d08f393 --- /dev/null +++ b/server/services/sqlServer/querys/eom/lstPurchasePrice.ts @@ -0,0 +1,17 @@ +export const lastPurchasePrice = ` +use AlplaPROD_test1 + +SELECT plant=(SELECT Wert FROM dbo.T_SystemParameter (nolock) WHERE (Bezeichnung = 'Werkskuerzel')), +plantName=(SELECT Wert FROM dbo.T_SystemParameter AS T_SystemParameter (nolock) WHERE (Bezeichnung = 'Mandant-intern')),* + from + (Select IdBestellung as 'Purchase order number', + IdArtikelVarianten AS AV, + BestellMenge, + BestellMengeVPK, + PreisProEinheit, + convert(varchar,Lieferdatum,23) as deliveryDate, + ROW_NUMBER() over(partition by IdArtikelVarianten order by Lieferdatum desc) rn +from dbo.V_Bestellpositionen_PURCHASE (nolock) + where PositionsStatus = '7' or PositionsStatus = '6' or PositionsStatus = '5' and convert(varchar,Lieferdatum,23) > DATEADD(year, -5, GetDate()) )a + where rn = 1 +`; -- 2.49.1 From 668eae9719d97567a0741f45a884360554976a0a Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 29 Aug 2025 11:31:22 -0500 Subject: [PATCH 090/166] ci(release): bump build number to 580 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3734d3e..dc43449 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 579, + "build": 580, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 64b5b0d24896b33047d668a53b2de44a433b73d6 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 29 Aug 2025 11:37:47 -0500 Subject: [PATCH 091/166] ci(release): bump build number to 581 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dc43449..6f922aa 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 580, + "build": 581, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 3c9e75dc3cc90c0d2df562ccde99640d2238d2fe Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 29 Aug 2025 18:32:34 -0500 Subject: [PATCH 092/166] ci(release): bump build number to 582 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6f922aa..10b5b5e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 581, + "build": 582, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From e1cdeb740b499665c13ac487bc2b9cdd720f05c5 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 29 Aug 2025 18:57:25 -0500 Subject: [PATCH 093/166] ci(release): bump build number to 583 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 10b5b5e..44d9e8d 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 582, + "build": 583, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From c35db2e2093ce56961b24eb997e35eda9167a0f8 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 29 Aug 2025 19:01:12 -0500 Subject: [PATCH 094/166] ci(release): bump build number to 584 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 44d9e8d..c1b6258 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 583, + "build": 584, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 0efe74d4b159ac3662b66bcfff7c8e2bc1e19643 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 1 Sep 2025 07:31:05 -0500 Subject: [PATCH 095/166] ci(release): bump build number to 585 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c1b6258..ed4221b 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 584, + "build": 585, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From cfed981928a56389e09ef428c43ceabc1caec28e Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 1 Sep 2025 11:02:32 -0500 Subject: [PATCH 096/166] refactor(sql): articles added in UOM --- .../sqlServer/querys/dataMart/article.ts | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/server/services/sqlServer/querys/dataMart/article.ts b/server/services/sqlServer/querys/dataMart/article.ts index 268a158..9404ac1 100644 --- a/server/services/sqlServer/querys/dataMart/article.ts +++ b/server/services/sqlServer/querys/dataMart/article.ts @@ -1,4 +1,6 @@ export const activeArticle = ` +use AlplaPROD_test1 + SELECT V_Artikel.IdArtikelvarianten, V_Artikel.Bezeichnung, V_Artikel.ArtikelvariantenTypBez, @@ -45,7 +47,10 @@ V_Artikel.ArtikelvariantenTypBez = 'Sleeve' or V_Artikel.ArtikelvariantenTypBez = 'Plastic Bag' or V_Artikel.ArtikelvariantenTypBez = 'Purch Spout' or V_Artikel.ArtikelvariantenTypBez = 'Seal' or -V_Artikel.ArtikelvariantenTypBez = 'Tape' +V_Artikel.ArtikelvariantenTypBez = 'Tape' or +V_Artikel.ArtikelvariantenTypBez = 'Box' or +V_Artikel.ArtikelvariantenTypBez = 'Label IML' or +V_Artikel.ArtikelvariantenTypBez = 'Pallet Runner' THEN 'PKG' WHEN V_Artikel.ArtikelvariantenTypBez='HD-PE' or V_Artikel.ArtikelvariantenTypBez='HD-PE PCR' or @@ -111,16 +116,17 @@ sales.[KdArtBez] as CustomerArticleDescription, round(V_Artikel.Zyklus, 2) as CycleTime, Sypronummer as salesAgreement, V_Artikel.ProdArtikelBez as ProductFamily +,REPLACE(pur.UOM,'UOM:','') as UOM --,* -FROM AlplaPROD_test1.dbo.V_Artikel (nolock) +FROM dbo.V_Artikel (nolock) join -AlplaPROD_test1.dbo.V_Artikelvarianten on AlplaPROD_test1.dbo.V_Artikel.IdArtikelvarianten = -AlplaPROD_test1.dbo.V_Artikelvarianten.IdArtikelvarianten +dbo.V_Artikelvarianten (nolock) on AlplaPROD_usbow1.dbo.V_Artikel.IdArtikelvarianten = +dbo.V_Artikelvarianten.IdArtikelvarianten join -AlplaPROD_test1.dbo.V_FibuKonten_BASIS on AlplaPROD_test1.dbo.V_Artikelvarianten.IdFibuKonto = -AlplaPROD_test1.dbo.V_FibuKonten_BASIS.IdFibuKonto +dbo.V_FibuKonten_BASIS (nolock) on dbo.V_Artikelvarianten.IdFibuKonto = +dbo.V_FibuKonten_BASIS.IdFibuKonto -- adding in the sales price @@ -134,7 +140,7 @@ left join ,[KdArtNr] ,[KdArtBez] --,* - from AlplaPROD_test1.dbo.T_HistoryVK (nolock) + from dbo.T_HistoryVK (nolock) where --GueltigabDatum > getDate() - 120 --and @@ -142,7 +148,25 @@ left join and StandardKunde = 1 -- default address ) a where RN = 1) as sales -on AlplaPROD_test1.dbo.V_Artikel.IdArtikelvarianten = sales.av +on dbo.V_Artikel.IdArtikelvarianten = sales.av + +/* adding the purchase price info */ +left join +(select * from +(select + ROW_NUMBER() OVER (PARTITION BY IdArtikelvarianten ORDER BY GueltigabDatum DESC) AS RN, + IdArtikelvarianten as av + ,GueltigabDatum as validDate + ,EKPreis as price + ,LiefArtNr as supplierNr + ,case when len(Bemerkung) > 4 and Bemerkung like '%UOM%' then LEFT(Bemerkung, CHARINDEX(' ', Bemerkung) - 1) else 'UOM:1' end as UOM + --,* + from dbo.T_HistoryEK (nolock) + where + StandardLieferant = 1 -- default address + ) a + where RN = 1) as pur +on dbo.V_Artikel.IdArtikelvarianten = pur.av where V_Artikel.aktiv = 1 -- 2.49.1 From 1f8b8a7248c11c7e264c8c5ae7c042c5a0878c46 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 1 Sep 2025 11:05:36 -0500 Subject: [PATCH 097/166] fix(bookin): corrected the bookin in error response this could still print a label if the system detects the material properly but some other issue with alplaprod happened --- server/services/ocp/controller/labeling/labelProcess.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/services/ocp/controller/labeling/labelProcess.ts b/server/services/ocp/controller/labeling/labelProcess.ts index a4a2e4a..3054a3f 100644 --- a/server/services/ocp/controller/labeling/labelProcess.ts +++ b/server/services/ocp/controller/labeling/labelProcess.ts @@ -285,9 +285,15 @@ export const labelingProcess = async ({ // "ocp", // `Error Booking in label: ${book.errors[0].message}` // ); + createLog( + "error", + "labeling", + "ocp", + `There was an error booking in the label: ${book?.errors[0]?.message}` + ); return { success: false, - message: `Error Booking in label: ${book.errors[0]?.message}`, + message: `Error Booking in label: ${book?.errors[0]?.message}`, data: book, }; } -- 2.49.1 From 6910550de769dce04b1045f96ab19cf7b8d1ef8c Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 1 Sep 2025 11:08:16 -0500 Subject: [PATCH 098/166] fix(main material check): corrections to properly ignore pkg during color checks --- .../ocp/controller/materials/mainMaterial.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/server/services/ocp/controller/materials/mainMaterial.ts b/server/services/ocp/controller/materials/mainMaterial.ts index c47f660..e9bb500 100644 --- a/server/services/ocp/controller/materials/mainMaterial.ts +++ b/server/services/ocp/controller/materials/mainMaterial.ts @@ -64,7 +64,7 @@ export const isMainMatStaged = async (lot: any) => { const mainMateiral = res.filter((n: any) => n.IsMainMaterial); - if (mainMateiral[0]?.noMaterialShortage === "no") { + if (mainMateiral[0]?.noMaterialShortage === "noMM") { isStaged = { message: `Main material: ${mainMateiral[0].MaterialHumanReadableId} - ${mainMateiral[0].MaterialDescription}: is not staged for ${lot.lot} `, success: false, @@ -77,7 +77,11 @@ export const isMainMatStaged = async (lot: any) => { if (checkColorSetting[0].value === "1") { const autoConsumeColor = res.filter( - (n: any) => !n.IsMainMaterial && !n.isManual + (n: any) => + !n.IsMainMaterial && + !n.isManual && + n.noPKGShortage !== "pkgGood" && + n.noPKGShortage !== "noPkg" ); if ( autoConsumeColor.some( @@ -100,7 +104,11 @@ export const isMainMatStaged = async (lot: any) => { // // for manual consume color const manualConsumeColor = res.filter( - (n: any) => !n.IsMainMaterial && n.isManual + (n: any) => + !n.IsMainMaterial && + n.isManual && + n.noPKGShortage !== "pkgGood" && + n.noPKGShortage !== "noPkg" ); if ( manualConsumeColor.some( -- 2.49.1 From 57966ac9de72543014451b7ccd75539296ccaa51 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 1 Sep 2025 11:08:47 -0500 Subject: [PATCH 099/166] refactor(mm query): changes to the query to see pkg and materials properly and not duplicates --- .../sqlServer/querys/ocp/mainMaterial.ts | 104 +++++++++--------- 1 file changed, 53 insertions(+), 51 deletions(-) diff --git a/server/services/sqlServer/querys/ocp/mainMaterial.ts b/server/services/sqlServer/querys/ocp/mainMaterial.ts index 42c31e1..6f026d1 100644 --- a/server/services/sqlServer/querys/ocp/mainMaterial.ts +++ b/server/services/sqlServer/querys/ocp/mainMaterial.ts @@ -23,69 +23,59 @@ export const mmQuery = ` use [test1_AlplaPROD2.0_Read] +declare @lot as NVARCHAR(max) = [lotNumber] /* -checks all needed material including pkg - -we only want to monitor the manual materials and the mm materail to make sure they are good. - -for auto consume materails this will be compared with another query. - +Material demands for this lot */ -SELECT lot.ProductionLotHumanReadableId -,MaterialHumanReadableId -,MaterialDescription - --IsMainMaterial, - ,case when SourcingState in (1, 2) then 1 +select +MaterialHumanReadableId +,MaterialDescription +-- check box is staged so we could book in even if we used preprint. +,case when SourcingState in (1, 2) then 1 when x.ProvidedAmount > 0 then 1 when x.EffectiveConsumption > 0 then 1 else 0 end as Staged - ,x.ProvidedAmount as Provided - ,x.EffectiveConsumption as consumption - ,x.TotalDemand as totalDemand , - case when cp.Pieces = 1 then (lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces else - (a.Weight *((case when cp.Percentage is null then 80.25 else cp.Percentage end) / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end totalNeeded - ,l.qty as invForAutoConsume - /* remaining needed to complete the lot */ - --,x.TotalDemand - x.EffectiveConsumption as remainingNeeded - /* do we have enough staged or scanned to the lot? */ - ,case when (case when x.ProvidedAmount <> 0 - then x.ProvidedAmount else x.EffectiveConsumption end) > - (case when cp.Pieces = 1 then (lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces else - (a.Weight *((case when cp.Percentage is null then 80.25 else cp.Percentage end) / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end) - then 'good' - else 'no' end as noMaterialShortage - -- pkg check - ,case when pkg.QuantityPosition is null then null else - (case when l.qty > (lot.TotalProducedLoadingUnits+1) * pkg.QuantityPosition then 'pkgGood' else 'noPkg' end) end as noPKGShortage - - ,case when cp.Percentage is null then - case when l.qty > ((lot.TotalProducedLoadingUnits +1) * pkg.QuantityPosition) then 'autoConsumeOk' else 'autoConsumeNOK' end else - (case when l.qty > (a.Weight *((case when cp.Percentage is null then 80.25 else cp.Percentage end) / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 and IsManualProcess = 0 - then 'autoConsumeOk' else 'autoConsumeNOK' end) end as autoConsumeCheck ,x.IsManualProcess as isManual ,IsMainMaterial + -- lot stuff ,lot.TotalPlannedLoadingUnits ,lot.TotalProducedLoadingUnits ,lot.TotalPlannedLoadingUnits - lot.TotalProducedLoadingUnits as remainingPallets - ,case when cp.Percentage is null then 80.25 else cp.Percentage end as Percentage -- this is to over come the alternate mm put in planning - ,case when cp.Pieces is not null then cp.Pieces else pkg.QuantityPosition end as peices -FROM [issueMaterial].[MaterialDemand] x (nolock) + ,x.ProvidedAmount as Provided -- this is what has been provided most of the time this is due to a silo attachment + ,x.EffectiveConsumption as consumption -- this is how much was consummed via cmd 112 + ,x.TotalDemand as totalDemand -- the total demand needed to finish the lot out + ,case when pkg.QuantityPosition >= 0.001 then ((lot.TotalProducedLoadingUnits+1) * pkg.QuantityPosition) else + (a.Weight *(cp.Percentage / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end totalNeeded + + ,case when IsMainMaterial = 1 then case when (case when x.ProvidedAmount <> 0 + then x.ProvidedAmount else x.EffectiveConsumption end) > + (case when pkg.QuantityPosition >= 0.001 then (lot.TotalProducedLoadingUnits+1) * pkg.QuantityPosition else + (a.Weight *(cp.Percentage / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end) + then 'mmGood' + else 'noMM' end else null end as noMaterialShortage + + -- pkg check + ,case when pkg.QuantityPosition is null then null else + (case when l.qty > ((lot.TotalProducedLoadingUnits+1) * pkg.QuantityPosition) then 'pkgGood' else 'noPkg' end) end as noPKGShortage + -- autoconsume + ,case when cp.Percentage is null then + case when l.qty > ((lot.TotalProducedLoadingUnits +1) * pkg.QuantityPosition) then 'autoConsumeOk' else 'autoConsumeNOK' end else + (case when l.qty > (a.Weight *(cp.Percentage / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 and IsManualProcess = 0 + then 'autoConsumeOk' else 'autoConsumeNOK' end) end as autoConsumeCheck + -- stock amounts + ,l.qty as invForAutoConsume + ,x.IsManualProcess as isManual + ,IsMainMaterial + ,case when cp.Percentage is null then 0 else cp.Percentage end as Percentage + ,pkg.QuantityPosition +from [issueMaterial].[MaterialDemand] x (nolock) + +/* production lot info */ left join [productionControlling].[ProducedLot] as lot on lot.Id = x.ProductionLotId -/* av data */ -left join - [masterData].[Article] as a on - a.id = lot.ArticleId - -/* compound*/ -left join -[masterData].[CompoundPosition] as cp on -cp.CompoundId = a.CompoundId -and cp.ArticleId = x.MaterialId - /* packagaing */ left join [masterData].[PackagingInstructionPosition] as pkg on @@ -97,6 +87,17 @@ left join [masterData].[PackagingInstruction] as p on p.id = lot.PackagingId +/* av data */ +left join + [masterData].[Article] as a on + a.id = lot.ArticleId + +/* compound*/ +left join +[masterData].[CompoundPosition] as cp on +cp.CompoundId = a.CompoundId +and cp.ArticleId = x.MaterialId + /* current stock info for auto consumption*/ left join (select @@ -104,14 +105,15 @@ IdArtikelVarianten ,ArtikelVariantenBez ,sum(VerfuegbareMengeSum) as qty -from AlplaPROD_test1.dbo.V_LagerPositionenBarcodes as i (nolock) +from AlplaPROD_usweb1.dbo.V_LagerPositionenBarcodes as i (nolock) left join -AlplaPROD_test1.dbo.V_LagerAbteilungen as l (nolock) on +AlplaPROD_usweb1.dbo.V_LagerAbteilungen as l (nolock) on l.IdLagerAbteilung = i.IdLagerAbteilung where autoverbrauch = 1 and aktiv = 1 group by IdArtikelVarianten,ArtikelVariantenBez ) as l on l.IdArtikelVarianten = MaterialHumanReadableId -where lot.ProductionLotHumanReadableId = [lotNumber] + +where lot.ProductionLotHumanReadableId = @lot `; -- 2.49.1 From 28c7d30c1a28ff43d1c06e201eda17a5a00e9f75 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 3 Sep 2025 10:54:37 -0500 Subject: [PATCH 100/166] ci(release): bump build number to 586 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ed4221b..2637958 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 585, + "build": 586, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 8133443ec999307ba95c6d69b233f0d0e9fc62c9 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 3 Sep 2025 10:56:13 -0500 Subject: [PATCH 101/166] ci(release): bump build number to 587 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2637958..7a7a3e7 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 586, + "build": 587, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From dddd1d422e4c6547741756d3b6f5551b71a380e2 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 4 Sep 2025 13:12:21 -0500 Subject: [PATCH 102/166] ci(release): bump build number to 588 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7a7a3e7..acf215c 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 587, + "build": 588, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From f48c944bd0ce31b96d74c611eaf7b50a3e52c8c0 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 5 Sep 2025 07:50:36 -0500 Subject: [PATCH 103/166] ci(release): bump build number to 589 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index acf215c..adcadef 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 588, + "build": 589, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 5fa9e83d5b719b6eddac3b6505db748cbab8b82b Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 5 Sep 2025 08:22:39 -0500 Subject: [PATCH 104/166] ci(release): bump build number to 590 --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index adcadef..8661376 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,8 @@ "db:dev": "npm run build && npm run db:generate && npm run db:migrate", "deploy": "standard-version --conventional-commits && npm run build", "zipServer": "dotenvx run -f .env -- tsx server/scripts/zipUpBuild.ts \"C:\\Users\\matthes01\\Documents\\lstv2\"", - "v1Build": "cd C:\\Users\\matthes01\\Documents\\logisticsSupportTool && npm run oldBuilder", - "scriptBuild": "powershell -ExecutionPolicy Bypass -File server/scripts/build.ps1 -dir \"C:\\Users\\matthes01\\Documents\\lstv2\"", + "newBuild": "npm run build && npm run zipServer && npm run copyToNew", + "copyToNew": "powershell -ExecutionPolicy Bypass -File server/scripts/copyToLst.ps1 -dir \"C:\\Users\\matthes01\\Documents\\lstv2\"", "removeOld": "rimraf dist && rimraf frontend/dist", "prodBuild": "npm run v1Build && npm run build && npm run zipServer && npm run dev", "commit": "cz", @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 589, + "build": 590, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 2045c13ef2d2504ce981a524fd69e15e6f79876e Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 5 Sep 2025 08:22:41 -0500 Subject: [PATCH 105/166] ci(release): bump build number to 591 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8661376..3b6cb05 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 590, + "build": 591, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 7462b3d90bf660aeae4001abd79b9afd49a17d84 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 5 Sep 2025 08:23:56 -0500 Subject: [PATCH 106/166] ci(release): bump build number to 592 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3b6cb05..4f96b8a 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 591, + "build": 592, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 1094de2ebddc429443d34854083da566cc3adcb3 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 5 Sep 2025 08:23:59 -0500 Subject: [PATCH 107/166] ci(release): bump build number to 593 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4f96b8a..2a39d8c 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 592, + "build": 593, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 172fd1d5c21fbe73c6cccc4494854aa9e9f176c9 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 5 Sep 2025 08:28:22 -0500 Subject: [PATCH 108/166] ci(release): bump build number to 594 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2a39d8c..3976b41 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 593, + "build": 594, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 4e3c5e41918c6ac3d2c4cd73a7a25d78c4d5c7ea Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 5 Sep 2025 08:28:25 -0500 Subject: [PATCH 109/166] ci(release): bump build number to 595 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3976b41..1d7f7e1 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 594, + "build": 595, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From f9e97fc22485f69d16ab70f8551409a63f4821fa Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 5 Sep 2025 09:43:25 -0500 Subject: [PATCH 110/166] ci(release): bump build number to 598 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1d7f7e1..774528e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 595, + "build": 598, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 6851777fafe17568c358932d061bb1edf15d460d Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 5 Sep 2025 09:43:27 -0500 Subject: [PATCH 111/166] ci(release): bump build number to 599 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 774528e..e3c1bbd 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 598, + "build": 599, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 00eaf62d4ce04affc8340dabd274422245480cd1 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 5 Sep 2025 09:44:58 -0500 Subject: [PATCH 112/166] ci(release): bump build number to 600 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e3c1bbd..0d3d92a 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 599, + "build": 600, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From a3994a1f693c66820fb7dafa415b6e5696e94a46 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 5 Sep 2025 09:45:02 -0500 Subject: [PATCH 113/166] ci(release): bump build number to 600 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0d3d92a..f480bc6 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "db:dev": "npm run build && npm run db:generate && npm run db:migrate", "deploy": "standard-version --conventional-commits && npm run build", "zipServer": "dotenvx run -f .env -- tsx server/scripts/zipUpBuild.ts \"C:\\Users\\matthes01\\Documents\\lstv2\"", - "newBuild": "npm run build && npm run zipServer && npm run copyToNew", + "newBuild": "npm run build:server && npm run build:frontend && npm run zipServer && npm run copyToNew", "copyToNew": "powershell -ExecutionPolicy Bypass -File server/scripts/copyToLst.ps1 -dir \"C:\\Users\\matthes01\\Documents\\lstv2\"", "removeOld": "rimraf dist && rimraf frontend/dist", "prodBuild": "npm run v1Build && npm run build && npm run zipServer && npm run dev", -- 2.49.1 From be8a44f2dc59b6cbbd4b953a895e59b103fca34f Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 5 Sep 2025 09:52:25 -0500 Subject: [PATCH 114/166] ci(release): bump build number to 601 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f480bc6..58ded51 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 600, + "build": 601, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 6d49fae16dbe50d14dbfe00a86aca45eee6fff01 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 5 Sep 2025 09:55:52 -0500 Subject: [PATCH 115/166] ci(release): bump build number to 602 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 58ded51..79730a0 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 601, + "build": 602, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 0444da8bbc428953c4d425da17b3803d22e506f0 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 08:34:18 -0500 Subject: [PATCH 116/166] ci(release): bump build number to 607 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 79730a0..8fa3c66 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 602, + "build": 607, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 708b57b926c3b5fe61a9ed58b9bcb72359d844a2 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 08:50:28 -0500 Subject: [PATCH 117/166] ci(release): bump build number to 608 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8fa3c66..6fbe6bf 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 607, + "build": 608, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From dd2e5d04ae292e0409857e19ec8f006e350081f7 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 08:54:39 -0500 Subject: [PATCH 118/166] ci(release): bump build number to 609 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6fbe6bf..3eb217e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 608, + "build": 609, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From e03e92c18d660f78f59a7db5c384ded7c29921e7 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 09:00:11 -0500 Subject: [PATCH 119/166] ci(build): changes to build then copy to new version being rewritten --- .includes | 8 +++++ server/scripts/copyToLst.ps1 | 61 ++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 .includes create mode 100644 server/scripts/copyToLst.ps1 diff --git a/.includes b/.includes new file mode 100644 index 0000000..b0a0db7 --- /dev/null +++ b/.includes @@ -0,0 +1,8 @@ +database +dist +frontend/dist +CHANGELOG.md +drizzle.config.ts +package.json +package-lock.json +README.md \ No newline at end of file diff --git a/server/scripts/copyToLst.ps1 b/server/scripts/copyToLst.ps1 new file mode 100644 index 0000000..3bb498e --- /dev/null +++ b/server/scripts/copyToLst.ps1 @@ -0,0 +1,61 @@ +param( + [string]$IncludesFile = ".includes", + [string]$Destination = "C:\Users\matthes01\Documents\lst\lstV2", + [string]$BaseDir = "C:\Users\matthes01\Documents\lst" +) + +# .\copy-includes.ps1 will run with defaults +# .\copy-includes.ps1 -IncludesFile ".\mylist.txt" -Destination "D:\build\lstV2" will override defaults + +if (-Not (Test-Path $IncludesFile)) { + Write-Error "Includes file not found: $IncludesFile" + exit 1 +} + +# Ensure destination exists +if (!(Test-Path -Path $Destination)) { + New-Item -ItemType Directory -Path $Destination | Out-Null + Write-Host "Folder created: $Destination" +} + +# Empty the destination folder +Get-ChildItem -Path $Destination -Recurse -Force | Remove-Item -Recurse -Force + +# If BaseDir wasn’t explicitly passed in, use IncludesFile directory +if (-not $PSBoundParameters.ContainsKey('BaseDir')) { + $BaseDir = Split-Path -Parent (Resolve-Path $IncludesFile) +} + +# Read includes list (ignore blank lines & comments) +$items = Get-Content $IncludesFile | + ForEach-Object { $_.Trim() } | + Where-Object { $_ -and -not $_.StartsWith("#") } + +foreach ($item in $items) { + if ([System.IO.Path]::IsPathRooted($item)) { + # Absolute path (rare case) + $sourcePath = $item + $relative = Split-Path $item -Leaf # just take folder/file name + } else { + # Relative to BaseDir + $sourcePath = Join-Path $BaseDir $item + $relative = $item # keep full relative path e.g. "frontend\dist" + } + + if (-Not (Test-Path $sourcePath)) { + Write-Warning "Skipping missing path: $sourcePath" + continue + } + + # Destination path should preserve the relative structure + $targetPath = Join-Path $Destination $relative + + # Ensure the parent folder exists + $targetDir = Split-Path $targetPath -Parent + if (-not (Test-Path $targetDir)) { + New-Item -ItemType Directory -Path $targetDir -Force | Out-Null + } + + Write-Host "Copying $sourcePath -> $targetPath" -ForegroundColor Cyan + Copy-Item -Path $sourcePath -Destination $targetPath -Recurse -Force +} \ No newline at end of file -- 2.49.1 From 796a8dccd2807890abdff7c8dacf8b2246eb265e Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 09:00:46 -0500 Subject: [PATCH 120/166] refactor(silo card): changes to allow viewers to see and able to attach and detach --- .../logistics/siloAdjustments/SiloCard.tsx | 185 +++++++++++------- 1 file changed, 109 insertions(+), 76 deletions(-) diff --git a/frontend/src/components/logistics/siloAdjustments/SiloCard.tsx b/frontend/src/components/logistics/siloAdjustments/SiloCard.tsx index 67b4b63..1b788f1 100644 --- a/frontend/src/components/logistics/siloAdjustments/SiloCard.tsx +++ b/frontend/src/components/logistics/siloAdjustments/SiloCard.tsx @@ -21,13 +21,28 @@ import { toast } from "sonner"; import ChartData from "./ChartData"; import { AttachSilo } from "./AttachSilo"; import { DetachSilo } from "./DetachSilo"; +import { useSessionStore } from "@/lib/store/sessionStore"; +import { useModuleStore } from "@/lib/store/useModuleStore"; +import { useGetUserRoles } from "@/lib/store/useGetRoles"; export default function SiloCard(data: any) { const token = localStorage.getItem("auth_token"); const [submitting, setSubmitting] = useState(false); const { refetch } = useQuery(getStockSilo()); + const { user } = useSessionStore(); + const { userRoles } = useGetUserRoles(); + const { modules } = useModuleStore(); const silo = data.silo; + // roles that can do the silo adjustments + const roles = ["systemAdmin", "technician", "admin", "manager"]; + + const module = modules.filter((n) => n.name === "logistics"); + + const accessRoles = userRoles.filter( + (n) => n.module_id === module[0]?.module_id + ) as any; + const form = useForm({ defaultValues: { newLevel: "", @@ -46,7 +61,7 @@ export default function SiloCard(data: any) { dataToSubmit, { headers: { Authorization: `Bearer ${token}` } } ); - console.log(res.data); + //console.log(res.data); if (res.data.success) { toast.success(res.data.message); @@ -70,6 +85,8 @@ export default function SiloCard(data: any) { } }, }); + + console.log(accessRoles); return (
@@ -109,82 +126,98 @@ export default function SiloCard(data: any) {
) : ( -
{ - e.preventDefault(); - e.stopPropagation(); - }} - > - - value.length > 1 - ? undefined - : "You must enter a value greate than 1", - }} - children={(field) => { - return ( -
-
- -
- -
-
-
- - field.handleChange( - e.target.value - ) - } - /> - -
+ <> + {user && + roles.includes(accessRoles[0]?.role) && ( + { + e.preventDefault(); + e.stopPropagation(); + }} + > + + value.length > 1 + ? undefined + : "You must enter a value greate than 1", + }} + children={(field) => { + return ( +
+
+ +
+ +
+
+
+ + field.handleChange( + e + .target + .value + ) + } + /> + +
- {field.state.meta.errors - .length ? ( - - {field.state.meta.errors.join( - "," - )} - - ) : null} -
- ); - }} - /> - + {field.state.meta + .errors + .length ? ( + + {field.state.meta.errors.join( + "," + )} + + ) : null} +
+ ); + }} + /> + + )} + )}
-- 2.49.1 From 271cdbdbfa2478ecf56e9b01a4474508acacda2e Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 09:01:12 -0500 Subject: [PATCH 121/166] refactor(cosume): changes to allow non logged in users to use this function --- .../routes/(logistics)/materialHelper/consumption/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/routes/(logistics)/materialHelper/consumption/index.tsx b/frontend/src/routes/(logistics)/materialHelper/consumption/index.tsx index bcb56d2..ae1e45b 100644 --- a/frontend/src/routes/(logistics)/materialHelper/consumption/index.tsx +++ b/frontend/src/routes/(logistics)/materialHelper/consumption/index.tsx @@ -32,7 +32,10 @@ function RouteComponent() { ) : ( - + <> + + + )}
); -- 2.49.1 From 415d2e4a1d851cc46ac64ffc814a280a02293bbc Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 09:01:42 -0500 Subject: [PATCH 122/166] fix(register): changes to not give everyone system admin --- database/schema/userRoles.ts | 2 +- frontend/src/routes/register.tsx | 11 +++++------ server/services/auth/controllers/register.ts | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/database/schema/userRoles.ts b/database/schema/userRoles.ts index ef0002c..6649c4d 100644 --- a/database/schema/userRoles.ts +++ b/database/schema/userRoles.ts @@ -27,7 +27,7 @@ export const userRoles = pgTable( { user_id: uuid("user_id") .notNull() - .references(() => users.user_id), + .references(() => users.user_id, { onDelete: "cascade" }), role_id: uuid("role_id") .notNull() .references(() => roles.role_id), diff --git a/frontend/src/routes/register.tsx b/frontend/src/routes/register.tsx index 536541c..941c99d 100644 --- a/frontend/src/routes/register.tsx +++ b/frontend/src/routes/register.tsx @@ -33,13 +33,12 @@ function RouteComponent() { Authentication Notice: - To interact with the Alpla prod through this - application, you must use your{" "} - - Windows login credentials + + The username, email, and password are + only for LST you DO NOTNeed to + use Windows username if you do not wish + to. - . These credentials are used solely for - authentication purposes. {/*
  • diff --git a/server/services/auth/controllers/register.ts b/server/services/auth/controllers/register.ts index 54ff8c6..0a68a68 100644 --- a/server/services/auth/controllers/register.ts +++ b/server/services/auth/controllers/register.ts @@ -37,7 +37,7 @@ export const registerUser = async ( .values({ username, email, password }) .returning({ user: users.username, email: users.email }); - if (usercount.length <= 1) { + if (usercount.length === 0) { createLog( "info", "auth", -- 2.49.1 From 6caa5984e7a3e7b48b119c176835663ffec71151 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 09:02:09 -0500 Subject: [PATCH 123/166] fix(eomservice): changes to stop a crash incase the sql returned nothing due to start up --- server/services/eom/eomService.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/services/eom/eomService.ts b/server/services/eom/eomService.ts index c220a2e..8ed1680 100644 --- a/server/services/eom/eomService.ts +++ b/server/services/eom/eomService.ts @@ -37,9 +37,9 @@ setTimeout(async () => { const shiftTimeSplit = shift?.data[0]?.shiftChange.split(":"); const cronSetup = `${ - shiftTimeSplit.length > 0 ? `${parseInt(shiftTimeSplit[1])}` : "0" + shiftTimeSplit?.length > 0 ? `${parseInt(shiftTimeSplit[1])}` : "0" } ${ - shiftTimeSplit.length > 0 ? `${parseInt(shiftTimeSplit[0])}` : "7" + shiftTimeSplit?.length > 0 ? `${parseInt(shiftTimeSplit[0])}` : "7" } * * *`; //console.log(cronSetup); -- 2.49.1 From b3ce767b323c990c0ccf35ad6c2c67136a27272e Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 09:02:42 -0500 Subject: [PATCH 124/166] fix(bookin): corrections to only show the message on error vs the json --- server/services/logistics/route/consumeMaterial.ts | 2 +- server/services/ocp/controller/labeling/labelProcess.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/services/logistics/route/consumeMaterial.ts b/server/services/logistics/route/consumeMaterial.ts index a1d26a1..1184b9b 100644 --- a/server/services/logistics/route/consumeMaterial.ts +++ b/server/services/logistics/route/consumeMaterial.ts @@ -19,7 +19,7 @@ app.openapi( summary: "Consumes material based on its running number", method: "post", path: "/consume", - middleware: authMiddleware, + //middleware: authMiddleware, description: "Provided a running number and lot number you can consume material.", responses: { diff --git a/server/services/ocp/controller/labeling/labelProcess.ts b/server/services/ocp/controller/labeling/labelProcess.ts index 3054a3f..0b95bc2 100644 --- a/server/services/ocp/controller/labeling/labelProcess.ts +++ b/server/services/ocp/controller/labeling/labelProcess.ts @@ -289,11 +289,11 @@ export const labelingProcess = async ({ "error", "labeling", "ocp", - `There was an error booking in the label: ${book?.errors[0]?.message}` + `There was an error booking in the label: ${book.data?.errors[0]?.message}` ); return { success: false, - message: `Error Booking in label: ${book?.errors[0]?.message}`, + message: `Error Booking in label: ${book.data?.errors[0]?.message}`, data: book, }; } -- 2.49.1 From a53915ad8cbec5bd8d6ba4643c460ad0162249e2 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 09:03:11 -0500 Subject: [PATCH 125/166] fix(material check): split manual material out of the mm to properly catch it --- .../ocp/controller/materials/mainMaterial.ts | 2 +- .../sqlServer/querys/ocp/mainMaterial.ts | 38 +++++++++++++------ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/server/services/ocp/controller/materials/mainMaterial.ts b/server/services/ocp/controller/materials/mainMaterial.ts index e9bb500..5296aec 100644 --- a/server/services/ocp/controller/materials/mainMaterial.ts +++ b/server/services/ocp/controller/materials/mainMaterial.ts @@ -112,7 +112,7 @@ export const isMainMatStaged = async (lot: any) => { ); if ( manualConsumeColor.some( - (n: any) => n.noMaterialShortage === "yes" + (n: any) => n.noManualShortage === "noOK" ) ) { isStaged = { diff --git a/server/services/sqlServer/querys/ocp/mainMaterial.ts b/server/services/sqlServer/querys/ocp/mainMaterial.ts index 6f026d1..457e960 100644 --- a/server/services/sqlServer/querys/ocp/mainMaterial.ts +++ b/server/services/sqlServer/querys/ocp/mainMaterial.ts @@ -25,6 +25,13 @@ export const mmQuery = ` use [test1_AlplaPROD2.0_Read] declare @lot as NVARCHAR(max) = [lotNumber] /* +checks all needed material including pkg + +we only want to monitor the manual materials and the mm materail to make sure they are good. + +for auto consume materails this will be compared with another query. +*/ +/* Material demands for this lot */ select @@ -45,30 +52,39 @@ MaterialHumanReadableId ,x.EffectiveConsumption as consumption -- this is how much was consummed via cmd 112 ,x.TotalDemand as totalDemand -- the total demand needed to finish the lot out - ,case when pkg.QuantityPosition >= 0.001 then ((lot.TotalProducedLoadingUnits+1) * pkg.QuantityPosition) else - (a.Weight *(cp.Percentage / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end totalNeeded + ,case when cp.Pieces >= 0.001 then (lot.TotalProducedQuantity+1) * cp.Pieces else + (a.Weight *((case when cp.Percentage is null then 80 else cp.Percentage end) / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end totalNeeded - ,case when IsMainMaterial = 1 then case when (case when x.ProvidedAmount <> 0 + ,case when IsMainMaterial = 1 then + case when (case when x.ProvidedAmount <> 0 then x.ProvidedAmount else x.EffectiveConsumption end) > - (case when pkg.QuantityPosition >= 0.001 then (lot.TotalProducedLoadingUnits+1) * pkg.QuantityPosition else - (a.Weight *(cp.Percentage / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end) + (case when cp.Pieces >= 0.001 then (lot.TotalProducedQuantity+1) * cp.Pieces else + (a.Weight *((case when cp.Percentage is null then 80 else cp.Percentage end) / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end) then 'mmGood' - else 'noMM' end else null end as noMaterialShortage + else 'noMM' end else null end as noMMShortage -- pkg check ,case when pkg.QuantityPosition is null then null else (case when l.qty > ((lot.TotalProducedLoadingUnits+1) * pkg.QuantityPosition) then 'pkgGood' else 'noPkg' end) end as noPKGShortage - -- autoconsume + -- manualMateiral + ,case when IsMainMaterial = 0 and IsManualProcess = 1 then + case when (case when x.ProvidedAmount <> 0 + then x.ProvidedAmount else x.EffectiveConsumption end) > + (case when cp.Pieces >= 0.001 then (lot.TotalProducedQuantity+1) * cp.Pieces else + (a.Weight *((case when cp.Percentage is null then 80 else cp.Percentage end) / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end) + then 'manualGood' + else 'noOK' end else null end as noManualShortage +-- autoconsume ,case when cp.Percentage is null then case when l.qty > ((lot.TotalProducedLoadingUnits +1) * pkg.QuantityPosition) then 'autoConsumeOk' else 'autoConsumeNOK' end else (case when l.qty > (a.Weight *(cp.Percentage / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 and IsManualProcess = 0 then 'autoConsumeOk' else 'autoConsumeNOK' end) end as autoConsumeCheck -- stock amounts ,l.qty as invForAutoConsume - ,x.IsManualProcess as isManual - ,IsMainMaterial + ,case when cp.Percentage is null then 0 else cp.Percentage end as Percentage ,pkg.QuantityPosition + ,(lot.TotalProducedQuantity+1) * cp.Pieces from [issueMaterial].[MaterialDemand] x (nolock) /* production lot info */ @@ -105,10 +121,10 @@ IdArtikelVarianten ,ArtikelVariantenBez ,sum(VerfuegbareMengeSum) as qty -from AlplaPROD_usweb1.dbo.V_LagerPositionenBarcodes as i (nolock) +from AlplaPROD_test1.dbo.V_LagerPositionenBarcodes as i (nolock) left join -AlplaPROD_usweb1.dbo.V_LagerAbteilungen as l (nolock) on +AlplaPROD_test1.dbo.V_LagerAbteilungen as l (nolock) on l.IdLagerAbteilung = i.IdLagerAbteilung where autoverbrauch = 1 and aktiv = 1 group by IdArtikelVarianten,ArtikelVariantenBez -- 2.49.1 From b677bc14981faff30c91f6ffe4602319dd3c6016 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 09:03:35 -0500 Subject: [PATCH 126/166] refactor(rfid): changes to show all tags vs only 3 if there are more --- server/services/rfid/controller/stations/wrappers.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/services/rfid/controller/stations/wrappers.ts b/server/services/rfid/controller/stations/wrappers.ts index 01ac5a5..ec89a81 100644 --- a/server/services/rfid/controller/stations/wrappers.ts +++ b/server/services/rfid/controller/stations/wrappers.ts @@ -43,9 +43,9 @@ export const wrapperStuff = async (tagData: any) => { "rfid", `There are ${tagData.length} tags and this ${ tagData[0].reader - } only allows 1 tag to create a label: tag ${tagData[0].tag}, ${ - tagData[1].tag - }, ${tagData.length === 3 && tagData[2].tag}` + } only allows 1 tag to create a label: tag ${tagData + .map((o: any) => `${o.tag}`) + .join(",\n ")}` ); const tag = { ...tagData[0], runningNr: 0 }; //tagStuff([tag]); -- 2.49.1 From 79f1f8f91ba33533de7f4a7cc91503cfd8dd4ce5 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 09:04:00 -0500 Subject: [PATCH 127/166] fix(article check): corrected the query to not have a specfic plant in it --- server/services/sqlServer/querys/dataMart/article.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/services/sqlServer/querys/dataMart/article.ts b/server/services/sqlServer/querys/dataMart/article.ts index 9404ac1..03a7bab 100644 --- a/server/services/sqlServer/querys/dataMart/article.ts +++ b/server/services/sqlServer/querys/dataMart/article.ts @@ -121,7 +121,7 @@ V_Artikel.ProdArtikelBez as ProductFamily FROM dbo.V_Artikel (nolock) join -dbo.V_Artikelvarianten (nolock) on AlplaPROD_usbow1.dbo.V_Artikel.IdArtikelvarianten = +dbo.V_Artikelvarianten (nolock) on dbo.V_Artikel.IdArtikelvarianten = dbo.V_Artikelvarianten.IdArtikelvarianten join @@ -159,7 +159,8 @@ left join ,GueltigabDatum as validDate ,EKPreis as price ,LiefArtNr as supplierNr - ,case when len(Bemerkung) > 4 and Bemerkung like '%UOM%' then LEFT(Bemerkung, CHARINDEX(' ', Bemerkung) - 1) else 'UOM:1' end as UOM + ,case when Bemerkung is not null and Bemerkung like '%UOM:%' then LEFT(Bemerkung, CHARINDEX(' ', Bemerkung)) else 'UOM:1' end as UOM + ,Bemerkung --,* from dbo.T_HistoryEK (nolock) where -- 2.49.1 From 71bc7c29bc6faf9cfa6dd84556f7c79875069dfb Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 09:22:13 -0500 Subject: [PATCH 128/166] ci(release): bump build number to 610 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3eb217e..82183c3 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 609, + "build": 610, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 04b8d041f9e480085f7024af38b755e58820c4ef Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 09:24:09 -0500 Subject: [PATCH 129/166] ci(release): bump build number to 611 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 82183c3..49a5ac0 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 610, + "build": 611, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From b649dca4c90237344bf6fff0c95b4951101c7650 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 14:28:44 -0500 Subject: [PATCH 130/166] ci(release): bump build number to 615 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 49a5ac0..df2421e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 611, + "build": 615, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 669f5ca33f9619d7a3ba8cddb711e4abcd5986bc Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 14:31:51 -0500 Subject: [PATCH 131/166] ci(release): bump build number to 616 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index df2421e..0f07cbc 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 615, + "build": 616, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From da17defe827844c82892bb2c41b1a07096b23034 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 14:37:44 -0500 Subject: [PATCH 132/166] ci(release): bump build number to 617 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0f07cbc..dc724e3 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 616, + "build": 617, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 76d929abeaadb45693b62c4c1a7725b870a3a439 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 14:43:44 -0500 Subject: [PATCH 133/166] ci(release): bump build number to 618 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dc724e3..6d7fb24 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 617, + "build": 618, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From a6edcb71bf8ec4b93dd1dc33667eee57b3b5780d Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 14:51:26 -0500 Subject: [PATCH 134/166] ci(release): bump build number to 619 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6d7fb24..59d1cc0 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 618, + "build": 619, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From b77266690525a6a57fbefe1ecaad6d4311cd0f84 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 14:56:05 -0500 Subject: [PATCH 135/166] ci(release): bump build number to 620 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 59d1cc0..3ab19ff 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 619, + "build": 620, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 592e4c8cd7926843a2bccef5c6531aee4b43496c Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 16:02:36 -0500 Subject: [PATCH 136/166] ci(release): bump build number to 621 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3ab19ff..d315e0a 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 620, + "build": 621, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From b9c6d0ba57c1a084ed7dc6a8ee45b49e38d56e90 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 16:33:56 -0500 Subject: [PATCH 137/166] ci(release): bump build number to 622 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d315e0a..209db5a 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 621, + "build": 622, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 932a72ba884673471f0056e721cc3f2c8e34b4f3 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sun, 7 Sep 2025 15:38:27 -0500 Subject: [PATCH 138/166] fix(db): changes to the user so it deletes correctly --- .../migrations/0072_round_black_knight.sql | 3 + database/migrations/meta/0072_snapshot.json | 2252 +++++++++++++++++ database/migrations/meta/_journal.json | 7 + package.json | 2 +- 4 files changed, 2263 insertions(+), 1 deletion(-) create mode 100644 database/migrations/0072_round_black_knight.sql create mode 100644 database/migrations/meta/0072_snapshot.json diff --git a/database/migrations/0072_round_black_knight.sql b/database/migrations/0072_round_black_knight.sql new file mode 100644 index 0000000..9c6aade --- /dev/null +++ b/database/migrations/0072_round_black_knight.sql @@ -0,0 +1,3 @@ +ALTER TABLE "userRoles" DROP CONSTRAINT "userRoles_user_id_users_user_id_fk"; +--> statement-breakpoint +ALTER TABLE "userRoles" ADD CONSTRAINT "userRoles_user_id_users_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("user_id") ON DELETE cascade ON UPDATE no action; \ No newline at end of file diff --git a/database/migrations/meta/0072_snapshot.json b/database/migrations/meta/0072_snapshot.json new file mode 100644 index 0000000..6209025 --- /dev/null +++ b/database/migrations/meta/0072_snapshot.json @@ -0,0 +1,2252 @@ +{ + "id": "e4bfefb5-7c21-4933-9900-7753416a7d40", + "prevId": "beb6fee0-80fe-42a1-8bdb-e7424f9401b7", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.apiHits": { + "name": "apiHits", + "schema": "", + "columns": { + "apiHit_id": { + "name": "apiHit_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastBody": { + "name": "lastBody", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "stats": { + "name": "stats", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 1 + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "endpoint": { + "name": "endpoint", + "columns": [ + { + "expression": "endpoint", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "ip", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.commandLog": { + "name": "commandLog", + "schema": "", + "columns": { + "commandLog_id": { + "name": "commandLog_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "commandUsed": { + "name": "commandUsed", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bodySent": { + "name": "bodySent", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "reasonUsed": { + "name": "reasonUsed", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.fifoIndex": { + "name": "fifoIndex", + "schema": "", + "columns": { + "fifoIndex_id": { + "name": "fifoIndex_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "lot": { + "name": "lot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "av": { + "name": "av", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "runningNr": { + "name": "runningNr", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "prodDate": { + "name": "prodDate", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "fifoFollowed": { + "name": "fifoFollowed", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "fifo_runningNr": { + "name": "fifo_runningNr", + "columns": [ + { + "expression": "runningNr", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.invHistoricalData": { + "name": "invHistoricalData", + "schema": "", + "columns": { + "inv_id": { + "name": "inv_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "histDate": { + "name": "histDate", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "plantToken": { + "name": "plantToken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "article": { + "name": "article", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "articleDescription": { + "name": "articleDescription", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "materialType": { + "name": "materialType", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "total_QTY": { + "name": "total_QTY", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "avaliable_QTY": { + "name": "avaliable_QTY", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "coa_QTY": { + "name": "coa_QTY", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "held_QTY": { + "name": "held_QTY", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lot_number": { + "name": "lot_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "consignment": { + "name": "consignment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "upd_user": { + "name": "upd_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'lst'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.logs": { + "name": "logs", + "schema": "", + "columns": { + "log_id": { + "name": "log_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "level": { + "name": "level", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'LST_Serivce'" + }, + "service": { + "name": "service", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'system'" + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "checked": { + "name": "checked", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.modules": { + "name": "modules", + "schema": "", + "columns": { + "module_id": { + "name": "module_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "roles": { + "name": "roles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[\"view\",\"systemAdmin\"]'::jsonb" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "module_name": { + "name": "module_name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notifications": { + "name": "notifications", + "schema": "", + "columns": { + "notify_id": { + "name": "notify_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "checkInterval": { + "name": "checkInterval", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'1'" + }, + "timeType": { + "name": "timeType", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'hour'" + }, + "emails": { + "name": "emails", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "lastRan": { + "name": "lastRan", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "notifiySettings": { + "name": "notifiySettings", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + } + }, + "indexes": { + "notify_name": { + "name": "notify_name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ocmeData": { + "name": "ocmeData", + "schema": "", + "columns": { + "ocme_id": { + "name": "ocme_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "sscc": { + "name": "sscc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runningNr": { + "name": "runningNr", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "completed": { + "name": "completed", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "lineNum": { + "name": "lineNum", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "pickedUp": { + "name": "pickedUp", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "areaFrom": { + "name": "areaFrom", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "ocme_runningNr": { + "name": "ocme_runningNr", + "columns": [ + { + "expression": "runningNr", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ocmeCycleCounts": { + "name": "ocmeCycleCounts", + "schema": "", + "columns": { + "ocme_id": { + "name": "ocme_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "laneId": { + "name": "laneId", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "warehouseName": { + "name": "warehouseName", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "laneName": { + "name": "laneName", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "good": { + "name": "good", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "cycleCount": { + "name": "cycleCount", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.manualPrinting": { + "name": "manualPrinting", + "schema": "", + "columns": { + "print_id": { + "name": "print_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "line": { + "name": "line", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "printReason": { + "name": "printReason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "initials": { + "name": "initials", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "additionalComments": { + "name": "additionalComments", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "add_user": { + "name": "add_user", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.printerData": { + "name": "printerData", + "schema": "", + "columns": { + "printer_id": { + "name": "printer_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "humanReadableId": { + "name": "humanReadableId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ipAddress": { + "name": "ipAddress", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "port": { + "name": "port", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "statusText": { + "name": "statusText", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastTimePrinted": { + "name": "lastTimePrinted", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "assigned": { + "name": "assigned", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "remark": { + "name": "remark", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "printDelay": { + "name": "printDelay", + "type": "numeric", + "primaryKey": false, + "notNull": false, + "default": "'90'" + }, + "monitorState": { + "name": "monitorState", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "processes": { + "name": "processes", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "humanReadableId": { + "name": "humanReadableId", + "columns": [ + { + "expression": "humanReadableId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.prodlabels": { + "name": "prodlabels", + "schema": "", + "columns": { + "label_id": { + "name": "label_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "printerID": { + "name": "printerID", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "printerName": { + "name": "printerName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "line": { + "name": "line", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "runningNr": { + "name": "runningNr", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "add_user": { + "name": "add_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'lst'" + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "runningNr": { + "name": "runningNr", + "columns": [ + { + "expression": "runningNr", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.prodPermissions": { + "name": "prodPermissions", + "schema": "", + "columns": { + "prodPerm_id": { + "name": "prodPerm_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "roles": { + "name": "roles", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "rolesLegacy": { + "name": "rolesLegacy", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "prodPermName": { + "name": "prodPermName", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.qualityRequest": { + "name": "qualityRequest", + "schema": "", + "columns": { + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "article": { + "name": "article", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runningNr": { + "name": "runningNr", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lotNr": { + "name": "lotNr", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "warehouseAtRequest": { + "name": "warehouseAtRequest", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "locationAtRequest": { + "name": "locationAtRequest", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "warehouseMovedTo": { + "name": "warehouseMovedTo", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "locationMovedTo": { + "name": "locationMovedTo", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "durationToMove": { + "name": "durationToMove", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "locationDropOff": { + "name": "locationDropOff", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "palletStatus": { + "name": "palletStatus", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "palletStatusText": { + "name": "palletStatusText", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "palletRequest": { + "name": "palletRequest", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "add_user": { + "name": "add_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'LST'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_user": { + "name": "upd_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'LST'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.labelRatio": { + "name": "labelRatio", + "schema": "", + "columns": { + " ratio_id": { + "name": " ratio_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'labels'" + }, + "autoLabel": { + "name": "autoLabel", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "manualLabel": { + "name": "manualLabel", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "lastReset": { + "name": "lastReset", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "labelname": { + "name": "labelname", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.rfidReaders": { + "name": "rfidReaders", + "schema": "", + "columns": { + "rfidReader_id": { + "name": "rfidReader_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "reader": { + "name": "reader", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "readerIP": { + "name": "readerIP", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastHeartBeat": { + "name": "lastHeartBeat", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "lastTrigger": { + "name": "lastTrigger", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "lastTiggerGood": { + "name": "lastTiggerGood", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "lastTagScanned": { + "name": "lastTagScanned", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "goodReads": { + "name": "goodReads", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "badReads": { + "name": "badReads", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + } + }, + "indexes": { + "reader": { + "name": "reader", + "columns": [ + { + "expression": "reader", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.rfidTags": { + "name": "rfidTags", + "schema": "", + "columns": { + "rfidTag_id": { + "name": "rfidTag_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tagHex": { + "name": "tagHex", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag": { + "name": "tag", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastRead": { + "name": "lastRead", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "counts": { + "name": "counts", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "lastareaIn": { + "name": "lastareaIn", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "runningNumber": { + "name": "runningNumber", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "antenna": { + "name": "antenna", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "tagStrength": { + "name": "tagStrength", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "tagHex": { + "name": "tagHex", + "columns": [ + { + "expression": "tagHex", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.roles": { + "name": "roles", + "schema": "", + "columns": { + "role_id": { + "name": "role_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "role_name": { + "name": "role_name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.serverData": { + "name": "serverData", + "schema": "", + "columns": { + "server_id": { + "name": "server_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "sName": { + "name": "sName", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "serverDNS": { + "name": "serverDNS", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "plantToken": { + "name": "plantToken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "idAddress": { + "name": "idAddress", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "greatPlainsPlantCode": { + "name": "greatPlainsPlantCode", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "streetAddress": { + "name": "streetAddress", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cityState": { + "name": "cityState", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "zipcode": { + "name": "zipcode", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "contactEmail": { + "name": "contactEmail", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contactPhone": { + "name": "contactPhone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "customerTiAcc": { + "name": "customerTiAcc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lstServerPort": { + "name": "lstServerPort", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "serverLoc": { + "name": "serverLoc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "oldVersion": { + "name": "oldVersion", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastUpdated": { + "name": "lastUpdated", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "shippingHours": { + "name": "shippingHours", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'[{\"early\": \"06:30\", \"late\": \"23:00\"}]'" + }, + "tiPostTime": { + "name": "tiPostTime", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'[{\"from\": \"24\", \"to\": \"24\"}]'" + }, + "otherSettings": { + "name": "otherSettings", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[{\"specialInstructions\":\"something for ti\",\"active\":false}]'::jsonb" + }, + "isUpgrading": { + "name": "isUpgrading", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + } + }, + "indexes": { + "plantToken": { + "name": "plantToken", + "columns": [ + { + "expression": "plantToken", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.settings": { + "name": "settings", + "schema": "", + "columns": { + "role_id": { + "name": "role_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "moduleName": { + "name": "moduleName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "roles": { + "name": "roles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[\"systemAdmin\"]'::jsonb" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "name": { + "name": "name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.siloAdjustments": { + "name": "siloAdjustments", + "schema": "", + "columns": { + "siloAdjust_id": { + "name": "siloAdjust_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "level": { + "name": "level", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "locationID": { + "name": "locationID", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "currentStockLevel": { + "name": "currentStockLevel", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "newLevel": { + "name": "newLevel", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "''" + }, + "dateAdjusted": { + "name": "dateAdjusted", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "lastDateAdjusted": { + "name": "lastDateAdjusted", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "commentAddedBy": { + "name": "commentAddedBy", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "commentDate": { + "name": "commentDate", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "commentKey": { + "name": "commentKey", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "add_user": { + "name": "add_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'LST_Serivce'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.subModules": { + "name": "subModules", + "schema": "", + "columns": { + "submodule_id": { + "name": "submodule_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "moduleName": { + "name": "moduleName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "link": { + "name": "link", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "roles": { + "name": "roles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[\"systemAdmin\"]'::jsonb" + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "subSubModule": { + "name": "subSubModule", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "subModule_name": { + "name": "subModule_name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.userRoles": { + "name": "userRoles", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role_id": { + "name": "role_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "module_id": { + "name": "module_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "user_module_unique": { + "name": "user_module_unique", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "module_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "userRoles_user_id_users_user_id_fk": { + "name": "userRoles_user_id_users_user_id_fk", + "tableFrom": "userRoles", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "user_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "userRoles_role_id_roles_role_id_fk": { + "name": "userRoles_role_id_roles_role_id_fk", + "tableFrom": "userRoles", + "tableTo": "roles", + "columnsFrom": [ + "role_id" + ], + "columnsTo": [ + "role_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "userRoles_module_id_modules_module_id_fk": { + "name": "userRoles_module_id_modules_module_id_fk", + "tableFrom": "userRoles", + "tableTo": "modules", + "columnsFrom": [ + "module_id" + ], + "columnsTo": [ + "module_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "passwordToken": { + "name": "passwordToken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "passwordTokenExpires": { + "name": "passwordTokenExpires", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "pingcode": { + "name": "pingcode", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'user'" + }, + "lastLogin": { + "name": "lastLogin", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "username": { + "name": "username", + "columns": [ + { + "expression": "username", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/database/migrations/meta/_journal.json b/database/migrations/meta/_journal.json index 6b055e5..cc94f56 100644 --- a/database/migrations/meta/_journal.json +++ b/database/migrations/meta/_journal.json @@ -505,6 +505,13 @@ "when": 1754768521841, "tag": "0071_fantastic_old_lace", "breakpoints": true + }, + { + "idx": 72, + "version": "7", + "when": 1757167736042, + "tag": "0072_round_black_knight", + "breakpoints": true } ] } \ No newline at end of file diff --git a/package.json b/package.json index 209db5a..09c124e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 622, + "build": 633, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From d86ca7d3bf4d3bddbba697932dcd910bc567f57c Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 8 Sep 2025 13:30:05 -0500 Subject: [PATCH 139/166] ci(release): bump build number to 636 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 09c124e..915e199 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 633, + "build": 636, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 41d921756b35183ff0755f4b03cbac862be6caa7 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 8 Sep 2025 19:16:44 -0500 Subject: [PATCH 140/166] ci(release): bump build number to 638 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 915e199..e985c07 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 636, + "build": 638, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From ddd9b0e3723c3145e313e8afc8ed6f0fca8d9032 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 9 Sep 2025 07:48:24 -0500 Subject: [PATCH 141/166] ci(release): bump build number to 640 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e985c07..e27551f 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 638, + "build": 640, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 6918a5a7d47393793ff8e639fa8120e95c1b95e6 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 9 Sep 2025 09:12:18 -0500 Subject: [PATCH 142/166] ci(release): bump build number to 641 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e27551f..1eda7c9 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 640, + "build": 641, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 6c793c66a40208b549ef74fb9889f4a9f4f94b15 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 9 Sep 2025 15:57:41 -0500 Subject: [PATCH 143/166] ci(release): bump build number to 642 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1eda7c9..bbed713 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 641, + "build": 642, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From a2a17beeebfac8d5c22f4e4f7ff21d8505890c25 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 9 Sep 2025 17:28:29 -0500 Subject: [PATCH 144/166] ci(release): bump build number to 643 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bbed713..e9cf6e2 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 642, + "build": 643, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 788efdf4b33adcf7754a0e013c9886c3852818ab Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 9 Sep 2025 17:40:05 -0500 Subject: [PATCH 145/166] ci(release): bump build number to 644 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e9cf6e2..52f8f5d 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 643, + "build": 644, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From a6920d7cd8ee3847c74a3791fd4b2ea45458fd03 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 9 Sep 2025 17:52:15 -0500 Subject: [PATCH 146/166] ci(release): bump build number to 645 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 52f8f5d..b9947b5 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 644, + "build": 645, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From 99ecf52218556e048ba9262e74f9b3d020dea31d Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 9 Sep 2025 21:19:39 -0500 Subject: [PATCH 147/166] fix(label query): fixes to only pull in active layouts --- server/services/sqlServer/querys/warehouse/labelInfo.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/services/sqlServer/querys/warehouse/labelInfo.ts b/server/services/sqlServer/querys/warehouse/labelInfo.ts index beea16c..5881637 100644 --- a/server/services/sqlServer/querys/warehouse/labelInfo.ts +++ b/server/services/sqlServer/querys/warehouse/labelInfo.ts @@ -21,7 +21,7 @@ select ext.Barcode ,RunningNumber as runnungNumber ,SsccEanRunningNumber as externalRunningNumber ,ArticleHumanReadableId -,case when LabelManagementHumanReadableId is null then (select HumanReadableId from [test1_AlplaPROD2.0_Read].[masterData].[LabelManagement] (nolock) where LabelMarkerId = 7) else LabelManagementHumanReadableId end as labelLayout +,case when LabelManagementHumanReadableId is null then (select HumanReadableId from [test1_AlplaPROD2.0_Read].[masterData].[LabelManagement] (nolock) where LabelMarkerId = 7 and Active = 1) else LabelManagementHumanReadableId end as labelLayout ,case when EinlagerungsMengeSum IS NULL then 'notOnStock' else 'onStock' end as stockStatus from [test1_AlplaPROD2.0_Read].[labelling].[ExternalLabel] (nolock) as ext -- 2.49.1 From 00899a5b778eab792b350a0b47589de1524d91c8 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 9 Sep 2025 21:20:23 -0500 Subject: [PATCH 148/166] fix(materials): more fixes to try and please all plants to use this version and not call me --- .gitignore | 1 + package.json | 2 +- .../ocp/controller/materials/mainMaterial.ts | 176 ++++++++++++------ .../sqlServer/querys/ocp/mainMaterial.ts | 11 +- 4 files changed, 129 insertions(+), 61 deletions(-) diff --git a/.gitignore b/.gitignore index e59c294..42d183a 100644 --- a/.gitignore +++ b/.gitignore @@ -157,3 +157,4 @@ backend-0.1.3.zip BulkForecastTemplate BulkOrdersTemplate check.json +server/services/ocp/controller/materials/materialcheck.bak diff --git a/package.json b/package.json index b9947b5..86c1afa 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 645, + "build": 646, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { diff --git a/server/services/ocp/controller/materials/mainMaterial.ts b/server/services/ocp/controller/materials/mainMaterial.ts index 5296aec..1fcc3cd 100644 --- a/server/services/ocp/controller/materials/mainMaterial.ts +++ b/server/services/ocp/controller/materials/mainMaterial.ts @@ -60,13 +60,47 @@ export const isMainMatStaged = async (lot: any) => { // isStaged = true; // } + type CheckConditionArgs = { + results: any[]; + filterFn: (n: any) => boolean; + failCondition: (n: any) => boolean; + failMessage: string; + successMessage: string; + lot: { lot: string | number }; + }; + + const checkCondition = ({ + results, + filterFn, + failCondition, + failMessage, + successMessage, + lot, + }: CheckConditionArgs): { message: string; success: boolean } => { + const subset = results.filter(filterFn); + + if (subset.some(failCondition)) { + const failing = subset.filter(failCondition); + return { + message: `lot: ${lot.lot}, is missing: ${failing + .map( + (o: any) => + `${o.MaterialHumanReadableId} - ${o.MaterialDescription}` + ) + .join(",\n ")} ${failMessage}`, + success: false, + }; + } else { + return { message: successMessage, success: true }; + } + }; + createLog("info", "mainMaterial", "ocp", `Maint material query ran.`); - const mainMateiral = res.filter((n: any) => n.IsMainMaterial); - - if (mainMateiral[0]?.noMaterialShortage === "noMM") { - isStaged = { - message: `Main material: ${mainMateiral[0].MaterialHumanReadableId} - ${mainMateiral[0].MaterialDescription}: is not staged for ${lot.lot} `, + const mainMaterial = res.find((n: any) => n.IsMainMaterial); + if (mainMaterial?.noMMShortage === "noMM") { + return { + message: `Main material: ${mainMaterial.MaterialHumanReadableId} - ${mainMaterial.MaterialDescription}: is not staged for ${lot.lot}`, success: false, }; } @@ -75,56 +109,39 @@ export const isMainMatStaged = async (lot: any) => { // for manual consume color if active to check colors const checkColorSetting = set.filter((n) => n.name === "checkColor"); + // 2. Auto color if (checkColorSetting[0].value === "1") { - const autoConsumeColor = res.filter( - (n: any) => - !n.IsMainMaterial && - !n.isManual && - n.noPKGShortage !== "pkgGood" && - n.noPKGShortage !== "noPkg" - ); - if ( - autoConsumeColor.some( - (n: any) => n.autoConsumeCheck === "autoConsumeNOK" - ) - ) { - const onlyNOK = autoConsumeColor.filter( - (n: any) => n.autoConsumeCheck === "autoConsumeNOK" - ); - isStaged = { - message: `lot: ${lot.lot}, is missing: ${onlyNOK - .map( - (o: any) => - `${o.MaterialHumanReadableId} - ${o.MaterialDescription}` - ) - .join(",\n ")} for autoconsume`, - success: false, - }; - } + // auto check + // 2. Auto color + const autoColor = checkCondition({ + results: res, + lot, + filterFn: (n) => + n.isManual && + !("noPKGAutoShortage" in n) && + !("noPKGManualShortage" in n), // pool = non-main, auto + failCondition: (n) => n.autoConsumeCheck === "autoConsumeNOK", // column = autoConsumeCheck + failMessage: "for autoconsume", + successMessage: "auto color is good", + }); + if (!autoColor.success) return autoColor; + console.log(autoColor); - // // for manual consume color - const manualConsumeColor = res.filter( - (n: any) => + // 3. Manual color + const manualColor = checkCondition({ + results: res, + lot, + filterFn: (n) => !n.IsMainMaterial && n.isManual && - n.noPKGShortage !== "pkgGood" && - n.noPKGShortage !== "noPkg" - ); - if ( - manualConsumeColor.some( - (n: any) => n.noManualShortage === "noOK" - ) - ) { - isStaged = { - message: `lot: ${lot.lot}, is missing: ${manualConsumeColor - .map( - (o: any) => - `${o.MaterialHumanReadableId} - ${o.MaterialDescription}` - ) - .join(",\n ")} for manual Material`, - success: false, - }; - } + !("noPKGAutoShortage" in n) && + !("noPKGManualShortage" in n), // pool = non-main, manual + failCondition: (n) => n.noManualShortage === "noOK", // column = noManualShortage + failMessage: "for manual material", + successMessage: "manual color is good", + }); + if (!manualColor.success) return manualColor; + console.log(manualColor); } else { createLog( "info", @@ -137,11 +154,58 @@ export const isMainMatStaged = async (lot: any) => { // // if we want to check the packaging const checkPKGSetting = set.filter((n) => n.name === "checkPKG"); if (checkPKGSetting[0].value === "1") { - const packagingCheck = res.filter( - (n: any) => !n.IsMainMaterial && n.isManual + const pkgAuto = checkCondition({ + results: res, + lot, + filterFn: (n) => + !n.IsMainMaterial && + !n.isManual && + "noPKGAutoShortage" in n, + failCondition: (n) => n.noPKGAutoShortage === "noAutoPkg", + failMessage: "for pkg", + successMessage: "auto PKG is good", + }); + if (!pkgAuto.success) return pkgAuto; + console.log(pkgAuto); + + // 5. Packaging manual + const pkgManual = checkCondition({ + results: res, + lot, + filterFn: (n) => + !n.IsMainMaterial && + n.isManual && + "noPKGManualShortage" in n, + failCondition: (n) => n.noPKGManualShortage === "noManPkg", + failMessage: "for pkg", + successMessage: "manual PKG is good", + }); + + if (!pkgManual.success) return pkgManual; + console.log(pkgManual); + } else { + createLog( + "info", + "mainMaterial", + "ocp", + "PKG check is not active." ); - if (packagingCheck.some((n: any) => n.noPKGShortage === "noPkg")) { - isStaged = { + } + + // manual pkg + if (checkPKGSetting[0].value === "1") { + const packagingCheck = res.filter( + (n: any) => + !n.IsMainMaterial && + n.isManual && + "noPKGManualShortage" in n + ); + if ( + packagingCheck.some( + (n: any) => n.noPKGManualShortage === "noManPkg" + ) + ) { + return (isStaged = { message: `lot: ${lot.lot}, is missing: ${packagingCheck .map( (o: any) => @@ -149,7 +213,7 @@ export const isMainMatStaged = async (lot: any) => { ) .join(",\n ")} for pkg`, success: false, - }; + }); } } else { createLog( diff --git a/server/services/sqlServer/querys/ocp/mainMaterial.ts b/server/services/sqlServer/querys/ocp/mainMaterial.ts index 457e960..bfb3a11 100644 --- a/server/services/sqlServer/querys/ocp/mainMaterial.ts +++ b/server/services/sqlServer/querys/ocp/mainMaterial.ts @@ -23,7 +23,7 @@ export const mmQuery = ` use [test1_AlplaPROD2.0_Read] -declare @lot as NVARCHAR(max) = [lotNumber] +declare @lot as NVARCHAR(max) = [lotNumber] /* checks all needed material including pkg @@ -63,9 +63,12 @@ MaterialHumanReadableId then 'mmGood' else 'noMM' end else null end as noMMShortage - -- pkg check + -- pkg check auto ,case when pkg.QuantityPosition is null then null else - (case when l.qty > ((lot.TotalProducedLoadingUnits+1) * pkg.QuantityPosition) then 'pkgGood' else 'noPkg' end) end as noPKGShortage + (case when l.qty > ((lot.TotalProducedLoadingUnits+1) * pkg.QuantityPosition) and IsManualProcess = 0 then 'pkgAutoGood' else 'noAutoPkg' end) end as noPKGAutoShortage + -- plg check manual + ,case when pkg.QuantityPosition is null then null else + (case when x.EffectiveConsumption > ((lot.TotalProducedLoadingUnits+1) * pkg.QuantityPosition) and IsManualProcess = 1 then 'pkgManGood' else 'noManPkg' end) end as noPKGManualShortage -- manualMateiral ,case when IsMainMaterial = 0 and IsManualProcess = 1 then case when (case when x.ProvidedAmount <> 0 @@ -131,5 +134,5 @@ group by IdArtikelVarianten,ArtikelVariantenBez ) as l on l.IdArtikelVarianten = MaterialHumanReadableId -where lot.ProductionLotHumanReadableId = @lot +where lot.ProductionLotHumanReadableId = @lot and MaterialDescription not like '%nopal%' `; -- 2.49.1 From a7ff88025e0c0d97ae1fedd43e9ab7a0ade3469a Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 9 Sep 2025 21:20:39 -0500 Subject: [PATCH 149/166] chore(release): 2.27.0 --- CHANGELOG.md | 31 +++++++++++++++++++++++++++++++ package-lock.json | 4 ++-- package.json | 4 ++-- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3882ad..8ae3449 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,36 @@ # All CHanges to LST can be found below. +## [2.27.0](https://git.tuffraid.net/cowch/lstV2/compare/v2.26.0...v2.27.0) (2025-09-10) + + +### 🌟 Enhancements + +* **eom:** lastSales, lastPurch added to be pulled with new template ([7cc3778](https://git.tuffraid.net/cowch/lstV2/commits/7cc3778506fc92392ca8431aee0edb203861e10d)) + + +### 🛠️ Code Refactor + +* **cosume:** changes to allow non logged in users to use this function ([271cdbd](https://git.tuffraid.net/cowch/lstV2/commits/271cdbdbfa2478ecf56e9b01a4474508acacda2e)) +* **mm query:** changes to the query to see pkg and materials properly and not duplicates ([57966ac](https://git.tuffraid.net/cowch/lstV2/commits/57966ac9de72543014451b7ccd75539296ccaa51)) +* **rfid:** changes to show all tags vs only 3 if there are more ([b677bc1](https://git.tuffraid.net/cowch/lstV2/commits/b677bc14981faff30c91f6ffe4602319dd3c6016)) +* **silo card:** changes to allow viewers to see and able to attach and detach ([796a8dc](https://git.tuffraid.net/cowch/lstV2/commits/796a8dccd2807890abdff7c8dacf8b2246eb265e)) +* **sql:** articles added in UOM ([cfed981](https://git.tuffraid.net/cowch/lstV2/commits/cfed981928a56389e09ef428c43ceabc1caec28e)) + + +### 🐛 Bug fixes + +* **article check:** corrected the query to not have a specfic plant in it ([79f1f8f](https://git.tuffraid.net/cowch/lstV2/commits/79f1f8f91ba33533de7f4a7cc91503cfd8dd4ce5)) +* **bookin:** corrected the bookin in error response ([1f8b8a7](https://git.tuffraid.net/cowch/lstV2/commits/1f8b8a7248c11c7e264c8c5ae7c042c5a0878c46)) +* **bookin:** corrections to only show the message on error vs the json ([b3ce767](https://git.tuffraid.net/cowch/lstV2/commits/b3ce767b323c990c0ccf35ad6c2c67136a27272e)) +* **db:** changes to the user so it deletes correctly ([932a72b](https://git.tuffraid.net/cowch/lstV2/commits/932a72ba884673471f0056e721cc3f2c8e34b4f3)) +* **eomservice:** changes to stop a crash incase the sql returned nothing due to start up ([6caa598](https://git.tuffraid.net/cowch/lstV2/commits/6caa5984e7a3e7b48b119c176835663ffec71151)) +* **frontend:** typos ([c6f6ef6](https://git.tuffraid.net/cowch/lstV2/commits/c6f6ef626295f452cdf26f6776b74cfb3b1a10f5)) +* **label query:** fixes to only pull in active layouts ([99ecf52](https://git.tuffraid.net/cowch/lstV2/commits/99ecf52218556e048ba9262e74f9b3d020dea31d)) +* **main material check:** corrections to properly ignore pkg during color checks ([6910550](https://git.tuffraid.net/cowch/lstV2/commits/6910550de769dce04b1045f96ab19cf7b8d1ef8c)) +* **material check:** split manual material out of the mm to properly catch it ([a53915a](https://git.tuffraid.net/cowch/lstV2/commits/a53915ad8cbec5bd8d6ba4643c460ad0162249e2)) +* **materials:** more fixes to try and please all plants to use this version and not call me ([00899a5](https://git.tuffraid.net/cowch/lstV2/commits/00899a5b778eab792b350a0b47589de1524d91c8)) +* **register:** changes to not give everyone system admin ([415d2e4](https://git.tuffraid.net/cowch/lstV2/commits/415d2e4a1d851cc46ac64ffc814a280a02293bbc)) + ## [2.26.0](https://git.tuffraid.net/cowch/lstV2/compare/v2.25.0...v2.26.0) (2025-08-28) diff --git a/package-lock.json b/package-lock.json index 3d7bdf3..1ae5ffc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "lstv2", - "version": "2.26.0", + "version": "2.27.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "lstv2", - "version": "2.26.0", + "version": "2.27.0", "dependencies": { "@dotenvx/dotenvx": "^1.45.1", "@hono/node-server": "^1.14.4", diff --git a/package.json b/package.json index 86c1afa..ae50150 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lstv2", - "version": "2.26.0", + "version": "2.27.0", "type": "module", "scripts": { "dev": "concurrently -n \"server,frontend\" -c \"#007755,#2f6da3\" \"npm run dev:server\" \"cd frontend && npm run dev\"", @@ -94,4 +94,4 @@ "xlsx": "^0.18.5", "zod": "^3.25.67" } -} \ No newline at end of file +} -- 2.49.1 From 3b939ff2d3e5994cd2fbd3a4445ff363906d86c9 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Tue, 9 Sep 2025 21:21:08 -0500 Subject: [PATCH 150/166] ci(release): bump build number to 647 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ae50150..54104bd 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 646, + "build": 647, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { @@ -94,4 +94,4 @@ "xlsx": "^0.18.5", "zod": "^3.25.67" } -} +} \ No newline at end of file -- 2.49.1 From e996f9940096ac2fc81847f95c0a7e18b73d2bb7 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 10 Sep 2025 06:59:19 -0500 Subject: [PATCH 151/166] ci(release): bump build number to 648 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 54104bd..37c3aaf 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 647, + "build": 648, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From e9ca6dbbb253eb2e00890e91ce919ecbc5b08d45 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 10 Sep 2025 11:13:59 -0500 Subject: [PATCH 152/166] ci(release): bump build number to 649 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 37c3aaf..c344506 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 648, + "build": 649, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From a9783a7d350f244e12e190e5068c4b704efa3ccf Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 10 Sep 2025 11:15:07 -0500 Subject: [PATCH 153/166] ci(release): bump build number to 650 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c344506..0c82e13 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 649, + "build": 650, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From faf4e9f9ab6580806b90d67b04957b64d0dcdb93 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 11 Sep 2025 06:30:48 -0500 Subject: [PATCH 154/166] ci(release): bump build number to 651 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0c82e13..49eb482 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 650, + "build": 651, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From dce93d3de24b7d216d5b0d5bc3d340089f59f2e7 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 11 Sep 2025 06:32:08 -0500 Subject: [PATCH 155/166] ci(release): bump build number to 652 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 49eb482..3b83deb 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "admConfig": { - "build": 651, + "build": 652, "oldBuild": "backend-0.1.3.zip" }, "devDependencies": { -- 2.49.1 From fbb8c21d5c82faa06612407badbfdcbd27f650d1 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 11 Sep 2025 06:38:36 -0500 Subject: [PATCH 156/166] feat(loreal forecast): added in an email to be sent when we are missing skus --- .../dm/forecast/mappings/loralForecast.ts | 58 +++++++++++++++++++ .../utils/views/missingLorealSkus.hbs | 41 +++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 server/services/notifications/utils/views/missingLorealSkus.hbs diff --git a/server/services/logistics/controller/dm/forecast/mappings/loralForecast.ts b/server/services/logistics/controller/dm/forecast/mappings/loralForecast.ts index 683dc65..cff06f7 100644 --- a/server/services/logistics/controller/dm/forecast/mappings/loralForecast.ts +++ b/server/services/logistics/controller/dm/forecast/mappings/loralForecast.ts @@ -7,6 +7,8 @@ import { postForecast } from "../postForecast.js"; import { query } from "../../../../../sqlServer/prodSqlServer.js"; import { activeArticle } from "../../../../../sqlServer/querys/dataMart/article.js"; import { addDays } from "date-fns"; +import { sendEmail } from "../../../../../notifications/controller/sendMail.js"; +import { createLog } from "../../../../../logger/logger.js"; let customerID = 4; export const lorealForecast = async (data: any, user: any) => { @@ -111,6 +113,9 @@ export const lorealForecast = async (data: any, user: any) => { ); if (activeAV.length === 0) { + if (typeof forcast.customerArticleNo === "number") { + missingSku.push(forcast); + } continue; } @@ -181,6 +186,9 @@ export const lorealForecast = async (data: any, user: any) => { ); if (activeAV.length === 0) { + if (typeof forcast.customerArticleNo === "number") { + missingSku.push(forcast); + } continue; } @@ -190,6 +198,56 @@ export const lorealForecast = async (data: any, user: any) => { //console.log(comForecast); + // email the for the missing ones + const missedGrouped = Object.values( + missingSku.reduce((acc: any, item: any) => { + const key = item.customerArticleNo; + + if (!acc[key]) { + // first time we see this customer + acc[key] = item; + } else { + // compare dates and keep the earliest + if ( + new Date(item.requirementDate) < + new Date(acc[key].requirementDate) + ) { + acc[key] = item; + } + } + + return acc; + }, {}) + ); + + const emailSetup = { + email: "Blake.matthes@alpla.com; Stuart.Gladney@alpla.com; Harold.Mccalister@alpla.com; Jenn.Osbourn@alpla.com", + subject: + missedGrouped.length > 0 + ? `Alert! There are ${missedGrouped.length}, missing skus.` + : `Alert! There is a missing SKU.`, + template: "missingLorealSkus", + context: { + items: missedGrouped, + }, + }; + + const { data: sentEmail, error: sendEmailError } = await tryCatch( + sendEmail(emailSetup) + ); + if (sendEmailError) { + createLog( + "error", + "blocking", + "notify", + "Failed to send email, will try again on next interval" + ); + return { + success: false, + message: "Failed to send email, will try again on next interval", + }; + } + // if the customerarticle number is not matching just ignore it const predefinedObject = { receivingPlantId: plantToken[0].value, diff --git a/server/services/notifications/utils/views/missingLorealSkus.hbs b/server/services/notifications/utils/views/missingLorealSkus.hbs new file mode 100644 index 0000000..4dfb4d4 --- /dev/null +++ b/server/services/notifications/utils/views/missingLorealSkus.hbs @@ -0,0 +1,41 @@ + + + + + + {{!-- --}} + {{> styles}} + + +

    All,

    +

    The below SKU's do not currently have an av and will be ignored in the forcast import.

    +

    The date and qty are the first time needed showing from teh vmi report

    + + + + + + + + + + + {{#each items}} + + + + + + {{/each}} + +
    Customer Article NumberFirst Date NeededQuantity
    {{customerArticleNo}}{{requirementDate}}{{quantity}}
    + + +
    + +

    Thank you,

    +

    LST Team

    +
    + + + \ No newline at end of file -- 2.49.1 From 275c93dc79409a5ab7f86565dcf94096e345b714 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 11 Sep 2025 06:39:07 -0500 Subject: [PATCH 157/166] refactor(detach silo): changes to now show the error in the console in the browser --- frontend/src/components/logistics/siloAdjustments/DetachSilo.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/components/logistics/siloAdjustments/DetachSilo.tsx b/frontend/src/components/logistics/siloAdjustments/DetachSilo.tsx index a1c1a01..586c34e 100644 --- a/frontend/src/components/logistics/siloAdjustments/DetachSilo.tsx +++ b/frontend/src/components/logistics/siloAdjustments/DetachSilo.tsx @@ -48,6 +48,7 @@ export function DetachSilo(props: any) { ); if (res.status === 200) { + console.log(res.data.data); toast.success(res.data.message); refetch(); -- 2.49.1 From 03e83782138de7d2bc8e30cacea141c4fb5a8a50 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 11 Sep 2025 06:39:36 -0500 Subject: [PATCH 158/166] fix(inhouse): changes to no longer error --- .../controller/specialProcesses/inhouse/inhouseDelivery.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/services/ocp/controller/specialProcesses/inhouse/inhouseDelivery.ts b/server/services/ocp/controller/specialProcesses/inhouse/inhouseDelivery.ts index a2e51de..2fddb3f 100644 --- a/server/services/ocp/controller/specialProcesses/inhouse/inhouseDelivery.ts +++ b/server/services/ocp/controller/specialProcesses/inhouse/inhouseDelivery.ts @@ -33,13 +33,13 @@ export const delieryInhouse = async (data: any) => { "error", "labeling", "ocp", - `${data.printer.name}, Error:${res.data.Message}` + `${data.printer?.name}, Error:${res.data.Message}` ); //printerUpdate(data.printer, 7, "Error while deliverying inhouse."); return { success: true, - message: `${data.printer.name} had an error while trying to deliver.`, + message: `${data.printer?.name} had an error while trying to deliver.`, data: res.data, }; } // label was just delivered -- 2.49.1 From 1cde8ab2e64281d81953aaed76825a9200ec81da Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 11 Sep 2025 06:42:02 -0500 Subject: [PATCH 159/166] fix(mm query): more changes to the material query to please more plants --- server/services/sqlServer/querys/ocp/mainMaterial.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/services/sqlServer/querys/ocp/mainMaterial.ts b/server/services/sqlServer/querys/ocp/mainMaterial.ts index bfb3a11..7fcc646 100644 --- a/server/services/sqlServer/querys/ocp/mainMaterial.ts +++ b/server/services/sqlServer/querys/ocp/mainMaterial.ts @@ -134,5 +134,8 @@ group by IdArtikelVarianten,ArtikelVariantenBez ) as l on l.IdArtikelVarianten = MaterialHumanReadableId -where lot.ProductionLotHumanReadableId = @lot and MaterialDescription not like '%nopal%' +where lot.ProductionLotHumanReadableId = @lot and + MaterialDescription NOT LIKE '%nopal%' + and MaterialDescription NOT LIKE '%bb%' + and MaterialDescription NOT LIKE '%mcg%' `; -- 2.49.1 From 4cae96b1ee0e3ff6e56c1b20bc7daf3cad98a394 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 11 Sep 2025 06:42:31 -0500 Subject: [PATCH 160/166] refactor(detach): just a log to monitor better --- server/services/logistics/route/detachSilo.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/server/services/logistics/route/detachSilo.ts b/server/services/logistics/route/detachSilo.ts index dedb4d2..ba3937d 100644 --- a/server/services/logistics/route/detachSilo.ts +++ b/server/services/logistics/route/detachSilo.ts @@ -57,6 +57,7 @@ app.openapi( }); } + console.log(silo); return c.json({ success: silo.success, message: silo.message, -- 2.49.1 From bdc1e72fc1e94c424b307a1d96a6c259e2adb9fd Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 17 Sep 2025 20:02:14 -0500 Subject: [PATCH 161/166] refactor(frontend): comment required now when doing manual labels --- .../production/ocp/ManualPrinting/ManualPrintForm.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/production/ocp/ManualPrinting/ManualPrintForm.tsx b/frontend/src/components/production/ocp/ManualPrinting/ManualPrintForm.tsx index 5c58361..6780665 100644 --- a/frontend/src/components/production/ocp/ManualPrinting/ManualPrintForm.tsx +++ b/frontend/src/components/production/ocp/ManualPrinting/ManualPrintForm.tsx @@ -243,7 +243,8 @@ export default function ManualPrintForm() {