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

@@ -10,7 +10,9 @@ export const bookInLabel = async (data: any) => {
// update sscc so we can book in
const SSCC = data.SSCC.slice(2);
// api url
const url = await prodEndpointCreation("public/v1.0/Warehousing/BookIn");
const url = await prodEndpointCreation(
"/public/v1.1/Manufacturing/ProductionControlling/BookIn"
);
// create bookin
const newBookin = {
@@ -26,12 +28,12 @@ export const bookInLabel = async (data: any) => {
},
});
if (res.data.Result !== 0) {
if (res.status != 200) {
createLog(
"error",
"labeling",
"ocp",
`${data.printer.name}, Error:${res.data.Message}`
`${data.printer[0].name}, Error:${res.data}`
);
//printerUpdate(data.printer, 7, "Error while booking in.");
@@ -44,7 +46,7 @@ export const bookInLabel = async (data: any) => {
// update the label.
try {
await db
const booked = await db
.update(prodlabels)
.set({
status: "Booked in",
@@ -52,7 +54,22 @@ export const bookInLabel = async (data: any) => {
})
.where(
eq(prodlabels.runningNr, parseInt(data.SSCC.slice(10, -1)))
);
)
.returning({ runningNr: prodlabels.runningNr });
createLog(
"info",
"labeling",
"ocp",
`${booked[0].runningNr} , was just booked in.`
);
return {
success: true,
message: `${parseInt(
data.SSCC.slice(10, -1)
)}, was just booked in`,
};
} catch (error) {
createLog(
"error",
@@ -61,24 +78,12 @@ export const bookInLabel = async (data: any) => {
`Error creating new runningNumber in the DB.`
);
}
// label was booked in
createLog(
"info",
"labeling",
"ocp",
`${parseInt(data.SSCC.slice(10, -1))}, was just booked in`
);
return {
success: true,
message: `${parseInt(data.SSCC.slice(10, -1))}, was just booked in`,
};
} catch (error) {
createLog(
"error",
"labeling",
"ocp",
`${data.printer.name}, "Error: ${error}`
`${data.printer[0].name}, "Error: ${error}`
);
return {
success: false,