Compare commits
6 Commits
0975f4e499
...
4908d6644a
| Author | SHA1 | Date | |
|---|---|---|---|
| 4908d6644a | |||
| 21c374903b | |||
| ed11b2b26f | |||
| 357c118396 | |||
| 866b6d5120 | |||
| 739e6bbe9f |
9
.gitignore
vendored
9
.gitignore
vendored
@@ -5,6 +5,10 @@ dist
|
||||
apiDocsLSTV2
|
||||
testFiles
|
||||
builds
|
||||
nssm.exe
|
||||
backend-0.1.2-217.zip
|
||||
backend-0.1.2-218.zip
|
||||
postgresql-17.2-3-windows-x64.exe
|
||||
|
||||
|
||||
# ---> Node
|
||||
@@ -143,8 +147,3 @@ dist
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
||||
|
||||
nssm.exe
|
||||
|
||||
backend-0.1.2-217.zip
|
||||
postgresql-17.2-3-windows-x64.exe
|
||||
|
||||
@@ -7,7 +7,7 @@ export function getServers(token: string) {
|
||||
queryFn: () => fetchSettings(token),
|
||||
enabled: !!token,
|
||||
staleTime: 1000,
|
||||
refetchInterval: 500,
|
||||
refetchInterval: 2500,
|
||||
refetchOnWindowFocus: true,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -72,6 +72,6 @@
|
||||
},
|
||||
"admConfig": {
|
||||
"build": 20,
|
||||
"oldBuild": "backend-0.1.2-217.zip"
|
||||
"oldBuild": "backend-0.1.2-218.zip"
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ JWT_ACCESS_EXPIRATION="1h"
|
||||
JWT_REFRESH_EXPIRATION="7d"
|
||||
|
||||
# this code will need to be used when a user needs to have access to everything.
|
||||
SECRETOVERRIDECODE="mVSDCpBdxreIJ979ziI71GRubBc2mqVqvZdfA22CB7smBfqlE9S3rKTE909yCHte"
|
||||
SECRETOVERRIDECODE="supersecretKey"
|
||||
|
||||
# Database url - please change the password if this is all you changed
|
||||
DATABASE_URL="postgresql://postgres:PASSWORD@localhost:5432/lst_db"
|
||||
|
||||
@@ -5,6 +5,7 @@ import {eq, sql} from "drizzle-orm";
|
||||
import {checkPassword} from "../utils/checkPassword.js";
|
||||
import {roleCheck} from "./userRoles/getUserAccess.js";
|
||||
import {createLog} from "../../logger/logger.js";
|
||||
import {differenceInDays} from "date-fns";
|
||||
|
||||
/**
|
||||
* Authenticate a user and return a JWT.
|
||||
@@ -50,7 +51,14 @@ export async function login(
|
||||
.set({lastLogin: sql`NOW()`})
|
||||
.where(eq(users.user_id, user[0].user_id))
|
||||
.returning({lastLogin: users.lastLogin});
|
||||
createLog("info", "lst", "auth", `Its been 5days since ${user[0].username} has logged in`);
|
||||
createLog(
|
||||
"info",
|
||||
"lst",
|
||||
"auth",
|
||||
`Its been ${differenceInDays(lastLog[0]?.lastLogin ?? "", new Date(Date.now()))} days since ${
|
||||
user[0].username
|
||||
} has logged in`
|
||||
);
|
||||
//]);
|
||||
} catch (error) {
|
||||
createLog("error", "lst", "auth", "There was an error updating the user last login");
|
||||
|
||||
@@ -31,6 +31,9 @@ export const wrapperStuff = async (tagData: TagData[]) => {
|
||||
"rfid",
|
||||
`${tagdata.tag}, Did not come from a line please check the pallet and manually print the label.`
|
||||
);
|
||||
|
||||
// when we manually run again we want to make sure we read from the 3rd antenna this way we do not get the wrong info.
|
||||
// more testing will need to be done on this.
|
||||
}
|
||||
|
||||
// check if a running number exists
|
||||
|
||||
36
server/services/rfid/controller/tags/manualTag.ts
Normal file
36
server/services/rfid/controller/tags/manualTag.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import {db} from "../../../../../database/dbclient.js";
|
||||
import {rfidTags} from "../../../../../database/schema/rfidTags.js";
|
||||
import {createLog} from "../../../logger/logger.js";
|
||||
|
||||
export const manualTag = async (tag: string, area: string) => {
|
||||
/**
|
||||
* we only allow tags to be manually added from the wrappers
|
||||
*/
|
||||
// create the proper string
|
||||
const number = tag.toString().padStart(9, "0");
|
||||
const tagString = `ALPLA${number}`;
|
||||
const newTag = {
|
||||
tagHex: Buffer.from(tagString, "utf8").toString("hex").toUpperCase(),
|
||||
tag: tagString,
|
||||
lastRead: new Date(Date.now()),
|
||||
counts: [{area: area, timesHere: 1}], //jsonb("counts").notNull(), //.default([{area: 1, timesHere: 5}]).notNull(),
|
||||
lastareaIn: area,
|
||||
antenna: 0,
|
||||
tagStrength: -1,
|
||||
};
|
||||
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,
|
||||
});
|
||||
createLog("info", "rfid", "rfid", `Tags were just added, and label printed.`);
|
||||
// do the label thing here
|
||||
return {success: true, message: `${tagString} was just added, and label printed.`, data: tag};
|
||||
} catch (error) {
|
||||
createLog("error", "rfid", "rfid", `${JSON.stringify(error)}`);
|
||||
return {success: false, message: `Error creating a new tag`, data: error};
|
||||
}
|
||||
};
|
||||
39
server/services/rfid/route/manualTagEnter.ts
Normal file
39
server/services/rfid/route/manualTagEnter.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
//http://usday1vms006:4000/api/v1/zebra/wrapper1
|
||||
import {z, createRoute, OpenAPIHono} from "@hono/zod-openapi";
|
||||
import {responses} from "../../../globalUtils/routeDefs/responses.js";
|
||||
import {authMiddleware} from "../../auth/middleware/authMiddleware.js";
|
||||
import {manualTag} from "../controller/tags/manualTag.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
const RequestBody = z.object({
|
||||
tagNumber: z.string().openapi({example: "2541"}),
|
||||
});
|
||||
|
||||
app.openapi(
|
||||
createRoute({
|
||||
tags: ["rfid"],
|
||||
summary: "Post a manual Tag",
|
||||
method: "post",
|
||||
path: "/manualtag",
|
||||
middleware: authMiddleware,
|
||||
request: {
|
||||
body: {content: {"application/json": {schema: RequestBody}}},
|
||||
},
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c) => {
|
||||
const body =
|
||||
(await c.req.json()) ??
|
||||
c.json({success: false, message: `Please check that you are sending over a json object`}, 400);
|
||||
|
||||
try {
|
||||
const tag = await manualTag(body.tag, body.area);
|
||||
return c.json({success: tag.success, message: tag.message, data: tag.data}, 200);
|
||||
} catch (error) {
|
||||
return c.json({success: true, message: `There was an error with entering a new tag`, error}, 400);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
export default app;
|
||||
@@ -53,7 +53,7 @@
|
||||
"contactPhone": "6366970253",
|
||||
"customerTiAcc": "ALPL01HOUSINT",
|
||||
"lstServerPort": "4000",
|
||||
"active": false,
|
||||
"active": true,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "C:\\Users\\adm_matthes01\\Desktop\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
@@ -293,7 +293,7 @@
|
||||
"contactPhone": "6366970253",
|
||||
"customerTiAcc": "ALPL01SHERMANINT",
|
||||
"lstServerPort": "4000",
|
||||
"active": false,
|
||||
"active": true,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "C:\\Users\\adm_matthes01\\Desktop\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
@@ -309,8 +309,8 @@
|
||||
"streetAddress": "825 Rail Way",
|
||||
"cityState": "West Bend, WI",
|
||||
"zipcode": "53095",
|
||||
"contactEmail": "blake.matthes@alpla.com",
|
||||
"contactPhone": "6366970253",
|
||||
"contactEmail": "shippingreceivingwestbend@groups.alpla.com",
|
||||
"contactPhone": "262-808-4211",
|
||||
"customerTiAcc": "ALPL01WBINT",
|
||||
"lstServerPort": "4000",
|
||||
"active": true,
|
||||
|
||||
Reference in New Issue
Block a user