refactor(ocp): lots of work for rfid and dyco contorl

This commit is contained in:
2025-03-27 21:12:22 -05:00
parent 27d6b6e884
commit ba3d721940
19 changed files with 360 additions and 162 deletions

View File

@@ -43,7 +43,7 @@ export const createLabel = async (data: any, userPrinted: any) => {
const plantToken = settingsData.filter((n) => n.name === "plantToken");
const newLabel = {
scannerId: 99,
lotNr: data.LOT,
lotNr: data.lot,
machineId: data.machineID,
printerId: data.printerID,
//layoutId: cartonCustomers.includes(data.CustomerId.toString()) ? data.cartonLabel : data.palletLabel,
@@ -87,14 +87,24 @@ export const createLabel = async (data: any, userPrinted: any) => {
let newlabel = res.data;
try {
await db.insert(prodlabels).values({
printerID: parseInt(printer[0]?.humanReadableId!, 10),
runningNr: parseInt(newlabel.SSCC.slice(10, -1)),
printerName: printer[0].name.toLowerCase(),
line: data.MachineLocation,
status: "printed",
add_user: userPrinted || "LST_System",
});
const insertLabel = await db
.insert(prodlabels)
.values({
printerID: parseInt(printer[0]?.humanReadableId!, 10),
runningNr: parseInt(newlabel.SSCC.slice(10, -1)),
printerName: printer[0].name.toLowerCase(),
line: data.MachineLocation,
status: "printed",
add_user: userPrinted || "LST_System",
})
.returning({ runningNr: prodlabels.runningNr });
createLog(
"info",
"labeling",
"ocp",
`${insertLabel[0]?.runningNr} was just inserted into the db.`
);
} catch (error) {
createLog(
"error",
@@ -119,7 +129,7 @@ export const createLabel = async (data: any, userPrinted: any) => {
};
// check if we can remove labels or not
deleteLabels();
//deleteLabels();
return { sucess: true, message: "Label created", data: returnData }; // returning label data to be able to book in if active
} catch (error) {
createLog(