From 4486fe24362b4811d7cff0467c7f2f85e0c9e3c4 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 21 Aug 2025 05:54:48 -0500 Subject: [PATCH] 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