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