Compare commits
10 Commits
05fa774d68
...
e13b5a4283
| Author | SHA1 | Date | |
|---|---|---|---|
| e13b5a4283 | |||
| 7a4dea9d87 | |||
| a19ac539e7 | |||
| 1c910d80ea | |||
| 56e0f3eb47 | |||
| e50e9af839 | |||
| e34f273acb | |||
| 2c5f8a3a8c | |||
| 9e4729690a | |||
| 26ab6ecd8d |
@@ -1,6 +1,6 @@
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { fixTime } from "@/utils/fixTime";
|
||||
import { ColumnDef } from "@tanstack/react-table";
|
||||
import { format } from "date-fns-tz";
|
||||
import { Trash } from "lucide-react";
|
||||
|
||||
// This type is used to define the shape of our data.
|
||||
@@ -38,9 +38,11 @@ export const ocpColumns = (
|
||||
header: "Error Date",
|
||||
cell: ({ row }) => {
|
||||
if (row.getValue("created_at")) {
|
||||
const correctDate = fixTime(row.getValue("created_at"));
|
||||
const correctDate: any = row.getValue("created_at");
|
||||
const strippedDate = correctDate.replace("Z", ""); // Remove Z
|
||||
const formattedDate = format(strippedDate, "MM/dd/yyyy HH:mm");
|
||||
return (
|
||||
<div className="text-left font-medium">{correctDate}</div>
|
||||
<div className="text-left font-medium">{formattedDate}</div>
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
}
|
||||
},
|
||||
"admConfig": {
|
||||
"build": 433,
|
||||
"build": 437,
|
||||
"oldBuild": "backend-0.1.3.zip"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -42,7 +42,7 @@ export const labelerTagRead = async (tagData: any) => {
|
||||
// check the dyco settings
|
||||
const dycoPrint = settingData.filter((n) => n.name === "dycoPrint");
|
||||
// Only process if this is a new timestamp within the last 5 seconds
|
||||
if (tagTime !== lastProcessedTimestamp && Date.now() - tagTime <= 5000) {
|
||||
if (tagTime !== lastProcessedTimestamp && Date.now() - tagTime <= 8000) {
|
||||
lastProcessedTimestamp = tagTime;
|
||||
/**
|
||||
* add logic in to see if this is the first time we run this so we return an error to validate we are in sync.
|
||||
|
||||
@@ -13,7 +13,7 @@ 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
|
||||
* Add the new tag to the reader so we know what was really here
|
||||
*/
|
||||
const { error } = await tryCatch(
|
||||
db
|
||||
@@ -26,7 +26,7 @@ export const station3Tags = async (tagData: TagData[]) => {
|
||||
"error",
|
||||
"rfid",
|
||||
"rfid",
|
||||
`${tagData[0].reader} encountered and error addeding ${tagData[0].tag}.`
|
||||
`${tagData[0].reader} encountered and error adding ${tagData[0].tag}.`
|
||||
);
|
||||
}
|
||||
createLog(
|
||||
|
||||
@@ -12,20 +12,41 @@ import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { db } from "../../../../../database/dbclient.js";
|
||||
import { rfidTags } from "../../../../../database/schema/rfidTags.js";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { rfidReaders } from "../../../../../database/schema/rfidReaders.js";
|
||||
|
||||
export const wrapperStuff = async (tagData: any) => {
|
||||
console.log("WrapperTag", tagData[0].tag);
|
||||
|
||||
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 adding ${tagData[0].tag}.`
|
||||
);
|
||||
}
|
||||
|
||||
if (tagData.length != 1) {
|
||||
createLog(
|
||||
"error",
|
||||
"rfid",
|
||||
"rfid",
|
||||
`There are ${tagData.length} tags and this ${tagData[0].reader} only allows 1 tag to create a label.`
|
||||
`There are ${tagData.length} tags and this ${
|
||||
tagData[0].reader
|
||||
} only allows 1 tag to create a label: tag ${tagData[0].tag}, ${
|
||||
tagData[1].tag
|
||||
}, ${tagData.length === 3 && tagData[2].tag}`
|
||||
);
|
||||
const tag = { ...tagData[0], runningNr: 0 };
|
||||
//tagStuff([tag]);
|
||||
monitorChecks();
|
||||
return;
|
||||
} else {
|
||||
if (!tagData) {
|
||||
createLog("error", "rfid", "rfid", `No tagData was grabbed.`);
|
||||
@@ -41,6 +62,21 @@ export const wrapperStuff = async (tagData: any) => {
|
||||
};
|
||||
}
|
||||
const checkTag: any = tagdata;
|
||||
|
||||
if (checkTag.length === 0) {
|
||||
createLog(
|
||||
"error",
|
||||
"rfid",
|
||||
"rfid",
|
||||
`${tagData[0].tag} is not currently registered to a line please validate the pallet and manually print.`
|
||||
);
|
||||
return {
|
||||
success: false,
|
||||
message:
|
||||
"There is no tag in the system please manually print..",
|
||||
};
|
||||
}
|
||||
|
||||
if (checkTag[0]?.lastareaIn === "NeedsChecked") {
|
||||
createLog(
|
||||
"error",
|
||||
@@ -112,7 +148,7 @@ export const wrapperStuff = async (tagData: any) => {
|
||||
}
|
||||
};
|
||||
|
||||
const monitorErrorTags: any = [];
|
||||
export const monitorErrorTags: any = [];
|
||||
const monitorChecks = () => {
|
||||
/**
|
||||
* If we have to check more than 10 tags in an hour send an email to alert everyone.
|
||||
|
||||
@@ -29,12 +29,19 @@ export const tagStuff = async (tagData: TagData[]): Promise<any> => {
|
||||
};
|
||||
try {
|
||||
// insert the tag with the onConflict update the tag
|
||||
const tag = await db.insert(rfidTags).values(newTag).returning({
|
||||
tag: rfidTags.tag,
|
||||
runningNumber: rfidTags.runningNumber,
|
||||
counts: rfidTags.counts,
|
||||
lastareaIn: rfidTags.lastareaIn,
|
||||
});
|
||||
const tag = await db
|
||||
.insert(rfidTags)
|
||||
.values(newTag)
|
||||
.onConflictDoUpdate({
|
||||
target: rfidTags.tagHex,
|
||||
set: newTag,
|
||||
})
|
||||
.returning({
|
||||
tag: rfidTags.tag,
|
||||
runningNumber: rfidTags.runningNumber,
|
||||
counts: rfidTags.counts,
|
||||
lastareaIn: rfidTags.lastareaIn,
|
||||
});
|
||||
createLog("info", "rfid", "rfid", `Tags were jusdt updated.`);
|
||||
return { success: true, tag };
|
||||
} catch (error) {
|
||||
|
||||
@@ -54,7 +54,7 @@ app.openapi(
|
||||
//console.log("Raw value:", body[i].data.peakRssi, "Parsed:", parseInt(body[i].data.peakRssi));
|
||||
if (
|
||||
tag.includes("ALPLA") &&
|
||||
parseInt(body[i].data.peakRssi) < -50
|
||||
parseInt(body[i].data.peakRssi) < -40
|
||||
) {
|
||||
tagdata = [
|
||||
...tagdata,
|
||||
|
||||
Reference in New Issue
Block a user