test(rfid): more rfid work and tested working
This commit is contained in:
@@ -3,11 +3,32 @@
|
||||
* Phase 2 we will generate a label to be reprinted at staion 4
|
||||
*/
|
||||
|
||||
import { eq } from "drizzle-orm";
|
||||
import { db } from "../../../../../database/dbclient.js";
|
||||
import { rfidReaders } from "../../../../../database/schema/rfidReaders.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { createLog } from "../../../logger/logger.js";
|
||||
import type { TagData } from "../tagData.js";
|
||||
import { tagStuff } from "../tags/crudTag.js";
|
||||
|
||||
export const station3Tags = async (tagData: TagData[]) => {
|
||||
/**
|
||||
* Add the new tag to the reader so we know waht was really here
|
||||
*/
|
||||
const { error } = await tryCatch(
|
||||
db
|
||||
.update(rfidReaders)
|
||||
.set({ lastTagScanned: tagData[0].tag })
|
||||
.where(eq(rfidReaders.reader, tagData[0].reader))
|
||||
);
|
||||
if (error) {
|
||||
createLog(
|
||||
"error",
|
||||
"rfid",
|
||||
"rfid",
|
||||
`${tagData[0].reader} encountered and error addeding ${tagData[0].tag}.`
|
||||
);
|
||||
}
|
||||
createLog(
|
||||
"info",
|
||||
"rfid",
|
||||
|
||||
@@ -67,18 +67,19 @@ export const wrapperStuff = async (tagData: any) => {
|
||||
"rfid",
|
||||
`${tagData[0].tag}, Did not come from a line please check the pallet and manually print the label.`
|
||||
);
|
||||
tagStuff(tagData);
|
||||
monitorChecks();
|
||||
return {
|
||||
success: false,
|
||||
message: `${tagData[0].tag}, Did not come from a line please check the pallet and manually print the label.`,
|
||||
};
|
||||
}
|
||||
if (lines[0].runningNumber) {
|
||||
if (lines[0]?.runningNumber) {
|
||||
createLog(
|
||||
"info",
|
||||
"rfid",
|
||||
"rfid",
|
||||
`Reprint label ${lines[0].runningNumber}`
|
||||
`Reprint label ${lines[0]?.runningNumber}`
|
||||
);
|
||||
} else {
|
||||
createLog(
|
||||
@@ -88,7 +89,7 @@ export const wrapperStuff = async (tagData: any) => {
|
||||
`A new label will be created and linked to this ${tagData[0].tag} tag`
|
||||
);
|
||||
const lineNum = parseInt(
|
||||
checkTag[0]?.lastareaIn.repalceAll("line3", "")
|
||||
checkTag[0]?.lastareaIn.replace("line3.", "")
|
||||
);
|
||||
createLog(
|
||||
"info",
|
||||
|
||||
Reference in New Issue
Block a user