Compare commits

..

19 Commits

Author SHA1 Message Date
d27611d035 feat(servers): all servers in v2 meow 2025-04-02 21:26:32 -05:00
f771db6034 fix(ocp): delivery changes to happen after bookin is done 2025-04-02 21:26:15 -05:00
4f3b5d75a2 refactor(ocme): crashing for no reason added ?? 2025-04-02 21:25:49 -05:00
a1f62a3e51 fix(ti intergraion): chagnes to the special instructions 2025-04-02 21:25:30 -05:00
de0ee3a61c fix(sendmail): if server not installed just stop 2025-04-02 21:25:07 -05:00
b48dd8fa15 style(auth): format changes to the new config only 2025-04-02 21:24:51 -05:00
3355eb389c test(services): testing remove restart and stop 2025-04-02 21:24:23 -05:00
b2683d0429 feat(datamart): total inv migrated over 2025-04-02 21:23:42 -05:00
7e484a0f90 chore(release): bump build number to 147 2025-04-02 21:02:05 -05:00
77abaed60e chore(release): bump build number to 146 2025-04-02 16:38:47 -05:00
d10770bc49 chore(release): bump build number to 145 2025-04-02 15:29:10 -05:00
1fee4b719b chore(release): bump build number to 144 2025-04-02 14:58:43 -05:00
1dce3dccdc chore(release): bump build number to 143 2025-04-02 14:50:28 -05:00
3babf8a749 chore(release): bump build number to 142 2025-04-02 13:17:42 -05:00
29c9f2d1be chore(release): bump build number to 141 2025-04-02 12:17:34 -05:00
459b0f287c chore(release): bump build number to 140 2025-04-02 08:45:48 -05:00
7535e15337 chore(release): bump build number to 139 2025-04-02 08:15:43 -05:00
68dac0dd28 chore(release): bump build number to 138 2025-04-02 07:56:22 -05:00
f442cedff2 chore(release): bump build number to 137 2025-04-02 07:51:35 -05:00
27 changed files with 780 additions and 194 deletions

View File

@@ -125,7 +125,9 @@ export default function ServerPage() {
token={token as string} token={token as string}
/> />
<StartServer /> <StartServer />
<StopServer /> <StopServer
plantData={server}
/>
<RestartServer /> <RestartServer />
</div> </div>
)} )}

View File

@@ -1,14 +1,46 @@
import {Button} from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import {Tooltip, TooltipContent, TooltipProvider, TooltipTrigger} from "@/components/ui/tooltip"; import {
import {Octagon} from "lucide-react"; Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip";
import axios from "axios";
import { Octagon } from "lucide-react";
export default function StopServer() { export default function StopServer(plantData: any) {
const token = localStorage.getItem("auth_token");
const handleStopServer = async (plant: string) => {
let data: any = {
processType: "stop",
plantToken: plant,
};
const url: string = window.location.host.split(":")[0];
if (url === "localhost") {
data = { ...data, remote: "true" };
}
try {
const res = await axios.post("/api/server/serviceprocess", data, {
headers: { Authorization: `Bearer ${token}` },
});
console.log(res);
} catch (error) {
console.log(error);
}
};
return ( return (
<div> <div>
<TooltipProvider> <TooltipProvider>
<Tooltip> <Tooltip>
<TooltipTrigger asChild> <TooltipTrigger asChild>
<Button variant={"outline"} size={"icon"}> <Button
variant="destructive"
size={"icon"}
onClick={() =>
handleStopServer(plantData.plantToken)
}
>
<Octagon /> <Octagon />
</Button> </Button>
</TooltipTrigger> </TooltipTrigger>

View File

@@ -1,23 +1,34 @@
import {Button} from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import {CircleFadingArrowUp} from "lucide-react"; import { CircleFadingArrowUp } from "lucide-react";
import {toast} from "sonner"; import { toast } from "sonner";
import {Servers} from "./ServerPage"; import { Servers } from "./ServerPage";
import {useQuery} from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import {getSettings} from "@/utils/querys/settings"; import { getSettings } from "@/utils/querys/settings";
import axios from "axios"; import axios from "axios";
import {Tooltip, TooltipContent, TooltipProvider, TooltipTrigger} from "@/components/ui/tooltip"; import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip";
export default function UpdateServer({server, token}: {server: Servers; token: string}) { export default function UpdateServer({
const {data} = useQuery(getSettings(token ?? "")); server,
token,
}: {
server: Servers;
token: string;
}) {
const { data } = useQuery(getSettings(token ?? ""));
const upgrade = async () => { const upgrade = async () => {
let devDir = data.filter((n: any) => n.name === "devDir"); let devDir = data.filter((n: any) => n.name === "devDir");
toast.success("Server being upgraded in the background please wait."); toast.success("Server being upgraded in the background please wait.");
try { try {
const result = await axios.post( const result = await axios.post(
`/api/server/update/${server.plantToken}`, `/api/server/update/${server.plantToken}`,
{devDir: devDir[0].value}, { devDir: devDir[0].value },
{ {
headers: {Authorization: `Bearer ${token}`}, headers: { Authorization: `Bearer ${token}` },
} }
); );
@@ -29,7 +40,9 @@ export default function UpdateServer({server, token}: {server: Servers; token: s
toast.success(result.data.message); toast.success(result.data.message);
} }
} catch (error: any) { } catch (error: any) {
toast.error(`There was an error updating the server: ${error.data.message}`); toast.error(
`There was an error updating the server: ${error.data.message}`
);
} }
}; };
return ( return (
@@ -37,7 +50,12 @@ export default function UpdateServer({server, token}: {server: Servers; token: s
<TooltipProvider> <TooltipProvider>
<Tooltip> <Tooltip>
<TooltipTrigger asChild> <TooltipTrigger asChild>
<Button variant={"outline"} size={"icon"} onClick={upgrade} disabled={server.isUpgrading}> <Button
variant={`${server.isUpgrading ? "ghost" : "outline"}`}
size={"icon"}
onClick={upgrade}
disabled={server.isUpgrading}
>
<CircleFadingArrowUp /> <CircleFadingArrowUp />
</Button> </Button>
</TooltipTrigger> </TooltipTrigger>

View File

@@ -27,7 +27,7 @@
"commit": "cz", "commit": "cz",
"prodinstall": "npm i --omit=dev && npm run db:migrate", "prodinstall": "npm i --omit=dev && npm run db:migrate",
"checkupdates": "npx npm-check-updates", "checkupdates": "npx npm-check-updates",
"testingCode": "dotenvx run -f .env -- tsx watch server/services/notifications/utils/masterNotifications.ts" "testingCode": "dotenvx run -f .env -- tsx watch database/testFiles/checkServerData.ts"
}, },
"config": { "config": {
"commitizen": { "commitizen": {
@@ -35,7 +35,7 @@
} }
}, },
"admConfig": { "admConfig": {
"build": 136, "build": 147,
"oldBuild": "backend-0.1.3.zip" "oldBuild": "backend-0.1.3.zip"
}, },
"devDependencies": { "devDependencies": {

View File

@@ -4,22 +4,22 @@
### To run the server ### To run the server
- [PostgresSQL](https://www.postgresql.org/download/windows/) - current version using is 17 - [PostgresSQL](https://www.postgresql.org/download/windows/) - current version using is 17
- [NodeJS](https://nodejs.org) - [NodeJS](https://nodejs.org)
- [NSSM](https://nssm.cc/) - [NSSM](https://nssm.cc/)
### To manage the server ### To manage the server
- [VSCODE](https://code.visualstudio.com/) - [VSCODE](https://code.visualstudio.com/)
- [Postman](https://www.postman.com/downloads/) - [Postman](https://www.postman.com/downloads/)
## Creating directories needed ## Creating directories needed
- Create a new folder where we will host the server files. - Create a new folder where we will host the server files.
- Copy the nssm.exe into this folder - Copy the nssm.exe into this folder
- Copy the build files to the server (only needed for intial install). - Copy the build files to the server (only needed for intial install).
- This will house all the compiles and minified files needed to start the server up, this includes the frontend. - This will house all the compiles and minified files needed to start the server up, this includes the frontend.
- Save the nssm.exe into this folder as well, this will be used to control the service. - Save the nssm.exe into this folder as well, this will be used to control the service.
## Do the intial install ## Do the intial install
@@ -53,14 +53,12 @@ add in the below and change each setting area that says change me to something t
```env ```env
# PORTS # PORTS
PROD_PORT=4000
# To keep it all simple we will pass VITE to the ports that are used on both sides. # To keep it all simple we will pass VITE to the ports that are used on both sides.
VITE_SERVER_PORT=4400 VITE_SERVER_PORT=4000
# logLevel # logLevel
LOG_LEVEL=debug LOG_LEVEL=info
PROD_PORT=4000
# DUE to lstv1 we need 3000
SEC_PORT=3000
# Auth stuff # Auth stuff
SALTING=12 SALTING=12
SECRET=CHANGEME SECRET=CHANGEME
@@ -94,15 +92,15 @@ npm start
This command will start up the server and seed the database. This command will start up the server and seed the database.
- Settings will be set here. - Settings will be set here.
- All modules will be added. - All modules will be added.
2. Press CTRL + C to stop the server. 2. Press CTRL + C to stop the server.
3. Reopen postgres and review the settings make the changes to match the server your going to be running in. 3. Reopen postgres and review the settings make the changes to match the server your going to be running in.
- Change the server - Change the server
- change the dbServer - change the dbServer
- change plantToken - change plantToken
- then the remaining settings confirm if you need on or want to leave as default. - then the remaining settings confirm if you need on or want to leave as default.
### Creating first user. ### Creating first user.
@@ -113,8 +111,8 @@ npm start
``` ```
2. Open http://[SERVER]:[PORT]/api/docs or postman and create a user. 2. Open http://[SERVER]:[PORT]/api/docs or postman and create a user.
- Please do not try to manually enter a new user this is due to how the password is hashed, as well as setting systemAdmin for the first user. - Please do not try to manually enter a new user this is due to how the password is hashed, as well as setting systemAdmin for the first user.
- Change the server and port to what you changed in the DB. - Change the server and port to what you changed in the DB.
3. Stop the server again with CTRL + C. 3. Stop the server again with CTRL + C.
### Running as a serivice. ### Running as a serivice.
@@ -127,28 +125,58 @@ cd .\dist\server\scripts\
Next use the example command below to get the service up and running. Next use the example command below to get the service up and running.
- Options legend - Options legend
- serviceName = not recommended to change to reduce issues with the update process - serviceName = not recommended to change to reduce issues with the update process
- option = use install for the install, but you can use this script later to stop, start, restart the service. - option = use install for the install, but you can use this script later to stop, start, restart the service.
- appPath = where did you extract the server files - appPath = where did you extract the server files
- description = no need to change this unless you want it to be something else - description = no need to change this unless you want it to be something else
- command = do not change this unless you know what your doing and really need to change this. - command = do not change this unless you know what your doing and really need to change this.
```powershell ```powershell
.\services.ps1 -serviceName "LSTV2" -option "install" -appPath "E:\LST\lstV2" -description "Logistics Support Tool V2" -command "run start" .\services.ps1 -serviceName "LSTV2" -option "install" -appPath "E:\LST\lstV2" -description "Logistics Support Tool V2" -command "run start"
``` ```
### Adding servers to the mix to update on from the front end
you will need to add your servers into the serverData.json.
when the server starts up it will look at this file and make changes as needed.
below is an example of the server
```JSON
{
"sName": "Kansas City",
"serverDNS": "usksc1vms006",
"plantToken": "usksc1",
"idAddress": "10.42.9.26",
"greatPlainsPlantCode": "85",
"streetAddress": "1800 E 94th St Suite 300",
"cityState": "Kansas City, MO",
"zipcode": "64131",
"contactEmail": "example@example.com",
"contactPhone": "555-555-5555",
"customerTiAcc": "ALPL01KCINT",
"lstServerPort": "4000",
"active": false,
"serverLoc": "E:\\LST\\lstv2",
"oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{ "specialInstructions": "" }]
}
```
# Migrating From V1 to V2 # Migrating From V1 to V2
## User migration ## User migration
1. Open the sqlite db and export to sql the users table 1. Open the sqlite db and export to sql the users table
2. OPen the sql in notepad++ or your editor of choice and change the query to be similar to below. 2. OPen the sql in notepad++ or your editor of choice and change the query to be similar to below.
- we only need to have save the username, role, email, password - we only need to have save the username, role, email, password
An example new query will look like An example new query will look like
- Below is how it looks when exported from sqlite - Below is how it looks when exported from sqlite
```sql ```sql
INSERT INTO "User" ("id", "username", "email", "role", "password", "passwordToken", "tokenExpire", "active", "pinCode", "lastLogin", "add_user", "add_date", "upd_user", "upd_date") VALUES INSERT INTO "User" ("id", "username", "email", "role", "password", "passwordToken", "tokenExpire", "active", "pinCode", "lastLogin", "add_user", "add_date", "upd_user", "upd_date") VALUES
@@ -157,7 +185,7 @@ INSERT INTO "User" ("id", "username", "email", "role", "password", "passwordToke
The way we want to put recreate the query to work with the new db The way we want to put recreate the query to work with the new db
- Below example - Below example
```sql ```sql
INSERT INTO "users" ("username", "email", "role", "password") VALUES INSERT INTO "users" ("username", "email", "role", "password") VALUES
@@ -167,11 +195,11 @@ INSERT INTO "users" ("username", "email", "role", "password") VALUES
; ;
``` ```
- You could have many users and just add like above with the identical info from the db - You could have many users and just add like above with the identical info from the db
## Running v1 along Side V2 for the interm ## Running v1 along Side V2 for the interm
- change v2 prod port to 4000 in the env and db - change v2 prod port to 4000 in the env and db
- change v1 env to 4400 in the env. and in the db you will need to change the auth server to 4000 and the serverPort to 4400 - change v1 env to 4400 in the env. and in the db you will need to change the auth server to 4000 and the serverPort to 4400
This will change so that v2 is the main server now, this is needed for ocme mainly. This will change so that v2 is the main server now, this is needed for ocme mainly.

View File

@@ -4,6 +4,7 @@ param (
[string]$appPath, [string]$appPath,
[string]$command, # just the command like run startadm or what ever you have in npm. [string]$command, # just the command like run startadm or what ever you have in npm.
[string]$description [string]$description
[string]$remote
) )
# Example string to run with the parameters in it. # Example string to run with the parameters in it.
@@ -24,6 +25,16 @@ param (
$nssmPath = $AppPath + "\nssm.exe" $nssmPath = $AppPath + "\nssm.exe"
$npmPath = "C:\Program Files\nodejs\npm.cmd" # Path to npm.cmd $npmPath = "C:\Program Files\nodejs\npm.cmd" # Path to npm.cmd
if($remote -eq "true"){
$plantFunness = {
param ($service, $processType, $location)
# Call your PowerShell script inside plantFunness
& "$($location)\dist\server\scripts\services.ps1" -serviceName $service -option $processType -appPath $location
}
Invoke-Command -ComputerName $server -ScriptBlock $plantFunness -ArgumentList $service, $option, $appPath -Credential $credentials
}
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Host "Error: This script must be run as Administrator." Write-Host "Error: This script must be run as Administrator."
exit 1 exit 1

View File

@@ -132,6 +132,17 @@ $plantFunness = {
exit 1 # Exit with a non-zero code if there's an error exit 1 # Exit with a non-zero code if there's an error
} }
# for iowa 2 need to change the port config on the start up of nextjs server
if($token -eq "usiow2"){
$jsonPkgloc = "$($obslst)\apps\frontend\package.json"
#read the file
$jsonContent = Get-Content -Path $jsonPkgloc | ConvertFrom-Json
#change the second we want to update
$jsonContent.scripts.start = "next start -p 3001"
# convert back to json
$jsonContent | ConvertTo-Json | Set-Content -Path $jsonPkgloc
}
############################################################################ ############################################################################
Write-Host "Stopping the services to do the updates, pkgs and db changes." Write-Host "Stopping the services to do the updates, pkgs and db changes."

View File

@@ -1,14 +1,22 @@
import {eq} from "drizzle-orm"; import { eq } from "drizzle-orm";
import {db} from "../../../../database/dbclient.js"; import { db } from "../../../../database/dbclient.js";
import {users} from "../../../../database/schema/users.js"; import { users } from "../../../../database/schema/users.js";
import {createPassword} from "../utils/createPassword.js"; import { createPassword } from "../utils/createPassword.js";
import {setSysAdmin} from "./userRoles/setSysAdmin.js"; import { setSysAdmin } from "./userRoles/setSysAdmin.js";
import { createLog } from "../../logger/logger.js";
export const registerUser = async (username: string, password: string, email: string) => { export const registerUser = async (
username: string,
password: string,
email: string
) => {
const usercount = await db.select().from(users); const usercount = await db.select().from(users);
// make sure the user dose not already exist in the system // make sure the user dose not already exist in the system
const userCheck = await db.select().from(users).where(eq(users.username, username)); const userCheck = await db
.select()
.from(users)
.where(eq(users.username, username));
if (userCheck.length === 1) { if (userCheck.length === 1) {
return { return {
@@ -25,19 +33,27 @@ export const registerUser = async (username: string, password: string, email: st
try { try {
const user = await db const user = await db
.insert(users) .insert(users)
.values({username, email, password}) .values({ username, email, password })
.returning({user: users.username, email: users.email}); .returning({ user: users.username, email: users.email });
if (usercount.length <= 1) { if (usercount.length <= 1) {
console.log(`${username} is the first user and will be set to system admin.`); createLog(
const updateUser = await db.select().from(users).where(eq(users.username, username)); "info",
"auth",
"auth",
`${username} is the first user and will be set to system admin.`
);
const updateUser = await db
.select()
.from(users)
.where(eq(users.username, username));
setSysAdmin(updateUser, "systemAdmin"); setSysAdmin(updateUser, "systemAdmin");
} }
return {sucess: true, message: "User Registered", user}; return { sucess: true, message: "User Registered", user };
} catch (error) { } catch (error) {
console.log(error); createLog("error", "auth", "auth", `${error}`);
return { return {
success: false, success: false,
message: `${username} already exists please login or reset password, if you feel this is an error please contact your admin.`, message: `${username} already exists please login or reset password, if you feel this is an error please contact your admin.`,

View File

@@ -9,63 +9,72 @@ import { responses } from "../../../../globalUtils/routeDefs/responses.js";
const app = new OpenAPIHono(); const app = new OpenAPIHono();
const responseSchema = z.object({ const responseSchema = z.object({
success: z.boolean().openapi({ example: true }), success: z.boolean().openapi({ example: true }),
message: z.string().optional().openapi({ example: "user access" }), message: z.string().optional().openapi({ example: "user access" }),
data: z.array(z.object({})).optional().openapi({ example: [] }), data: z.array(z.object({})).optional().openapi({ example: [] }),
}); });
const UserAccess = z.object({ const UserAccess = z.object({
username: z username: z
.string() .string()
.regex(/^[a-zA-Z0-9_]{3,30}$/) .regex(/^[a-zA-Z0-9_]{3,30}$/)
.openapi({ example: "smith034" }), .openapi({ example: "smith034" }),
module: z.string().openapi({ example: "production" }), module: z.string().openapi({ example: "production" }),
role: z.string().openapi({ example: "viewer" }), role: z.string().openapi({ example: "viewer" }),
override: z.string().optional().openapi({ example: "secretString" }), override: z.string().optional().openapi({ example: "secretString" }),
}); });
app.openapi( app.openapi(
createRoute({ createRoute({
tags: ["Auth:admin"], tags: ["Auth:admin"],
summary: "Sets Users access", summary: "Sets Users access",
method: "post", method: "post",
path: "/setuseraccess", path: "/setuseraccess",
middleware: [ middleware: [
authMiddleware, authMiddleware,
hasCorrectRole(["admin", "systemAdmin"], "admin"), hasCorrectRole(["admin", "systemAdmin"], "admin"),
], ],
description: "When logged in you will be able to grant new permissions", description: "When logged in you will be able to grant new permissions",
request: { request: {
body: { body: {
content: { content: {
"application/json": { schema: UserAccess }, "application/json": { schema: UserAccess },
},
},
}, },
}, responses: responses(),
}, }),
responses: responses(), async (c) => {
}), //apiHit(c, { endpoint: "api/auth/setUserRoles" });
async (c) => { const { username, module, role, override } = await c.req.json();
//apiHit(c, { endpoint: "api/auth/setUserRoles" }); try {
const { username, module, role, override } = await c.req.json(); const access = await setUserAccess(
try { username,
const access = await setUserAccess(username, module, role, override); module,
//return apiReturn(c, true, access?.message, access?.data, 200); role,
return c.json( override
{ success: access.success, message: access.message, data: access.data }, );
200 //return apiReturn(c, true, access?.message, access?.data, 200);
); return c.json(
} catch (error) { {
console.log(error); success: access.success,
//return apiReturn(c, false, "Error in setting the user access", error, 400); message: access.message,
return c.json( data: access.data,
{ },
success: false, 200
message: "Error in setting the user access", );
data: error, } catch (error) {
}, console.log(error);
400 //return apiReturn(c, false, "Error in setting the user access", error, 400);
); return c.json(
{
success: false,
message: "Error in setting the user access",
data: error,
},
400
);
}
} }
}
); );
export default app; export default app;

View File

@@ -0,0 +1,23 @@
import { query } from "../../sqlServer/prodSqlServer.js";
import {
totalInvNoRn,
totalInvRn,
} from "../../sqlServer/querys/dataMart/totalINV.js";
export const getINV = async () => {
let inventory: any = [];
let updatedQuery = totalInvNoRn;
try {
inventory = await query(updatedQuery, "Gets Curruent inv");
return { success: true, message: "Current inv", data: inventory };
} catch (error) {
console.log(error);
return {
success: false,
message: "There was an error getting the inventory",
data: error,
};
}
};

View File

@@ -1,10 +1,11 @@
import { OpenAPIHono } from "@hono/zod-openapi"; import { OpenAPIHono } from "@hono/zod-openapi";
import activequerys from "./route/getCurrentQuerys.js";
import getArticles from "./route/getActiveArticles.js"; import getArticles from "./route/getActiveArticles.js";
import currentInv from "./route/getInventory.js";
const app = new OpenAPIHono(); const app = new OpenAPIHono();
const routes = [getArticles] as const; const routes = [activequerys, getArticles, currentInv] as const;
const appRoutes = routes.forEach((route) => { const appRoutes = routes.forEach((route) => {
app.route("/datamart", route); app.route("/datamart", route);

View File

@@ -0,0 +1,102 @@
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
import { responses } from "../../../globalUtils/routeDefs/responses.js";
const app = new OpenAPIHono({ strict: false });
const current: any = [
{
name: "getActiveAv",
endpoint: "/api/datamart/getarticles",
description: "Gets all current active AV, with specific critiera.",
},
// {
// name: "getStockLaneDims",
// endpoint: "/api/v1/masterData/getStockDims",
// description: "Returns the lane dims along with a column to send actaul dims to be updated.",
// },
// {
// name: "getAddressInfo",
// endpoint: "/api/v1/masterData/getAddressInfo",
// description: "Returns current active addresses with street and zip",
// },
// {
// name: "getMissingPkgData",
// endpoint: "/api/v1/masterData/getMissingPKGData",
// description: "Returns all packaging data that is missing either printer, layout, or carton layout",
// },
// {
// name: "getCustomerInventory",
// endpoint: "/api/v1/masterData/getCustomerInventory",
// description: "Returns specific customer inventory based on there address ID.",
// criteria: "customer",
// },
// {
// name: "getPalletLabels",
// endpoint: "/api/v1/masterData/getPalletLabels",
// description: "Returns specific amount of pallets RN, Needs label number and printer, Specfic to Dayton.",
// criteria: "runningNumber,printerName,count",
// },
// {
// name: "getOpenOrders",
// endpoint: "/api/v1/masterData/getOpenOrders",
// description:
// "Returns open orders based on day count sent over, sDay 15 days in the past eDay 5 days in the future, can be left empty for this default days",
// criteria: "sDay,eDay",
// },
// {
// name: "getOpenIncoming",
// endpoint: "/api/v1/masterData/getOpenIncoming",
// description:
// "Returns open orders based on day count sent over, sDay 15 days in the past eDay 5 days in the future, can be left empty for this default days",
// criteria: "sDay,eDay",
// },
// {
// name: "planningCheckPkg",
// endpoint: "/api/v1/masterData/planningPkgCheck",
// description: "Returns all lots starting later than today and has a pkg that is missing layouts.",
// },
{
name: "getinventory",
endpoint: "/api/datamart/getinventory",
// description: "Returns all inventory, by default excludes running numebrs, also excludes inv locations.",
description:
"Returns all inventory, excludes inv locations. no running numbers",
//criteria: "includeRunnningNumbers", // uncomment this out once the improt process can be faster
},
// {
// name: "getOpenOrderUpdates",
// endpoint: "/api/v1/masterData/getOpenOrderUpdates",
// // description: "Returns all inventory, by default excludes running numebrs, also excludes inv locations.",
// description: "Returns all orders based on customer id, leaving empty will pull everythinng in.",
// criteria: "customer", // uncomment this out once the improt process can be faster
// },
// {
// name: "getSiloAdjustment",
// endpoint: "/api/v1/warehouse/getSiloAdjustment",
// // description: "Returns all inventory, by default excludes running numebrs, also excludes inv locations.",
// description: "Returns all siloadjustments in selected date range IE: 1/1/2025 to 1/31/2025",
// criteria: "startDate,endDate", // uncomment this out once the improt process can be faster
// },
];
app.openapi(
createRoute({
tags: ["dataMart"],
summary: "Returns all avalible querys.",
method: "get",
path: "/getavalibleaquerys",
responses: responses(),
}),
async (c) => {
//const body = await c.req.json();
// make sure we have a vaid user being accessed thats really logged in
//apiHit(c, { endpoint: `api/logger/logs/id` });
return c.json({
success: true,
message: "All Current Active Querys.",
data: current,
});
}
);
export default app;

View File

@@ -0,0 +1,54 @@
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
import { responses } from "../../../globalUtils/routeDefs/responses.js";
import { tryCatch } from "../../../globalUtils/tryCatch.js";
import { getINV } from "../controller/getinventory.js";
const app = new OpenAPIHono({ strict: false });
app.openapi(
createRoute({
tags: ["dataMart"],
summary: "Returns All current inventory.",
method: "get",
path: "/getinventory",
// request: {
// body: {
// content: {
// "application/json": { schema: Body },
// },
// },
// },
responses: responses(),
}),
async (c) => {
// const { data: body, error } = await c.req.json();
// if (error) {
// return c.json({
// success: false,
// message: "Missing data please try again.",
// });
// }
// make sure we have a vaid user being accessed thats really logged in
//apiHit(c, { endpoint: `api/logger/logs/id` });
const { data, error } = await tryCatch(getINV());
if (error) {
return c.json(
{
success: false,
message: "There was an error getting the inv.",
data: error,
},
400
);
}
return c.json({
success: data.success,
message: data.message,
data: data.data,
});
}
);
export default app;

View File

@@ -49,7 +49,7 @@ const tiImport = async () => {
// parsing posting window // parsing posting window
const plantI = plantInfo!; const plantI = plantInfo!;
const postTime = JSON.parse(plantI[0]?.tiPostTime!); //const postTime = JSON.parse(plantI[0]?.tiPostTime!);
// order notifications // order notifications
const { data: notificationSet, error: notificationSettingsErr } = const { data: notificationSet, error: notificationSettingsErr } =
@@ -149,6 +149,16 @@ const tiImport = async () => {
); );
webHeader = webHeader.replaceAll("[requestUser]", requestUser); webHeader = webHeader.replaceAll("[requestUser]", requestUser);
// update the special instructions section
const otherSettings = plantI[0]?.otherSettings as {
specialInstructions: string;
active: boolean;
}[];
const specialInfo = otherSettings[0].specialInstructions.replaceAll(
"[header]",
records[0].Header
);
// this part will link into the <ItemGroups></ItemGroups> // this part will link into the <ItemGroups></ItemGroups>
let itemGroups = ""; let itemGroups = "";
@@ -304,14 +314,13 @@ const tiImport = async () => {
? 40 ? 40
: records[0].costCenter : records[0].costCenter
}` }`
)
// special instructions
.replaceAll(
"[specialInstructions]",
`This is a FTL load. The driver will need 2 adjustable load locks to secure the load. The driver will not be loaded without them. Please reference ALPLA pickup ${records[0].Header}`
); );
// special instructions
if (otherSettings[0].specialInstructions.length != 0) {
payload = payload.replaceAll("[specialInstructions]", specialInfo);
}
// update the carrier info if any is needed. // update the carrier info if any is needed.
// check the address has a real carrier on it and change to true and put the sacs code in // check the address has a real carrier on it and change to true and put the sacs code in

View File

@@ -11,6 +11,7 @@ import { fileURLToPath } from "url";
import hbs from "nodemailer-express-handlebars"; import hbs from "nodemailer-express-handlebars";
import { promisify } from "util"; import { promisify } from "util";
import { createLog } from "../../logger/logger.js"; import { createLog } from "../../logger/logger.js";
import { installed } from "../../../index.js";
interface HandlebarsMailOptions extends Mail.Options { interface HandlebarsMailOptions extends Mail.Options {
template: string; template: string;
@@ -25,6 +26,10 @@ interface EmailData {
} }
export const sendEmail = async (data: any): Promise<any> => { export const sendEmail = async (data: any): Promise<any> => {
if (!installed) {
createLog("error", "notify", "notify", "server not installed.");
return;
}
let transporter: Transporter; let transporter: Transporter;
let fromEmail: string | Address; let fromEmail: string | Address;
const { data: settingData, error: settingError } = await tryCatch( const { data: settingData, error: settingError } = await tryCatch(

View File

@@ -9,6 +9,7 @@ import { createLog } from "../logger/logger.js";
import { note, notificationCreate } from "./utils/masterNotifications.js"; import { note, notificationCreate } from "./utils/masterNotifications.js";
import { startNotificationMonitor } from "./utils/processNotifications.js"; import { startNotificationMonitor } from "./utils/processNotifications.js";
import notifyStats from "./routes/getActiveNotifications.js"; import notifyStats from "./routes/getActiveNotifications.js";
const app = new OpenAPIHono(); const app = new OpenAPIHono();
const routes = [sendemail, notifyStats] as const; const routes = [sendemail, notifyStats] as const;

View File

@@ -39,7 +39,7 @@ export const postLabelData = async (data: any) => {
); );
} }
if (label.length === 0) { if (label?.length === 0) {
return { return {
success: false, success: false,
message: "The label you scanned dose not exist in stock.", message: "The label you scanned dose not exist in stock.",

View File

@@ -69,6 +69,7 @@ export const bookInLabel = async (data: any) => {
message: `${parseInt( message: `${parseInt(
data.SSCC.slice(10, -1) data.SSCC.slice(10, -1)
)}, was just booked in`, )}, was just booked in`,
data: { SSCC: data.SSCC },
}; };
} catch (error) { } catch (error) {
createLog( createLog(

View File

@@ -59,11 +59,11 @@ export const labelingProcess = async ({
"error", "error",
"labeling", "labeling",
"ocp", "ocp",
`There is not a lot assigned to ${macId[0].Name}.` `There is not a lot assigned to ${macId[0]?.Name}.`
); );
return { return {
success: false, success: false,
message: `There is not a lot assigned to ${macId[0].Name}.`, message: `There is not a lot assigned to ${macId[0]?.Name}.`,
}; };
} }
} }
@@ -217,9 +217,9 @@ export const labelingProcess = async ({
// send over to be booked in if we can do it. // send over to be booked in if we can do it.
const bookin = settingData.filter((s) => s.name === "bookin"); const bookin = settingData.filter((s) => s.name === "bookin");
let book: any = [];
if (bookin[0].value === "1") { if (bookin[0].value === "1") {
const book = await bookInLabel(label.data); book = await bookInLabel(label.data);
} else { } else {
createLog("info", "labeling", "ocp", "Bookin is turned off."); createLog("info", "labeling", "ocp", "Bookin is turned off.");
@@ -231,7 +231,8 @@ export const labelingProcess = async ({
(s) => s.name === "inhouseDelivery" (s) => s.name === "inhouseDelivery"
); );
if (inhouseDelivery[0].value === "1") { if (inhouseDelivery[0].value === "1") {
const deliverPallet = await delieryInhouse(label); const deliverPallet = await delieryInhouse(book.data);
// console.log(deliverPallet);
} }
return { return {

View File

@@ -0,0 +1,90 @@
import { spawn } from "child_process";
import { eq } from "drizzle-orm";
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
import { db } from "../../../../../database/dbclient.js";
import { settings } from "../../../../../database/schema/settings.js";
import { createLog } from "../../../logger/logger.js";
import { serverData } from "../../../../../database/schema/serverData.js";
import os from "os";
export const serviceControl = async (
plantToken: string,
processType: string,
remote: string | null
) => {
const { data: serverInfo, error: serverError } = await tryCatch(
db
.select()
.from(serverData)
.where(eq(serverData.plantToken, plantToken))
);
if (serverError) {
return createLog(
"error",
"lst",
"serverUpdater",
`Error getting the server settings`
);
}
let scriptPath = `${serverInfo[0].serverLoc}\\dist\\server\\scripts\\services.ps1`;
if (os.hostname() != serverInfo[0].serverDNS) {
scriptPath = `${process.env.DEVFOLDER}\\dist\\server\\scripts\\services.ps1`;
}
const args = [
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-File",
scriptPath,
"-serviceName",
"LSTV2",
"-option",
processType,
"-appPath",
serverInfo[0].serverLoc as string,
"-remote",
remote ?? "",
];
const scriptProcess = spawn("powershell", args);
// Collect stdout data
scriptProcess.stdout.on("data", (data) => {
const output = data.toString().trim();
createLog("info", "lst", "serverUpdater", `${output}`);
//onData(output);
});
// Collect stderr data
scriptProcess.stderr.on("data", (data) => {
const output = data.toString().trim();
createLog("info", "lst", "serverUpdater", `${output}`);
//onData(output);
});
// Handle process close
scriptProcess.on("close", async (code) => {
if (code === 0) {
// if (count >= servers) {
// //onClose(`Server completed with code: ${code}`);
// }
createLog("info", "lst", "serverUpdater", `Finished setting perms`);
//update the last build.
} else {
const errorMessage = `Process exited with code ${code}`;
// if (count >= servers) {
// //onClose(code);
// }
}
});
// Handle errors with the process itself
scriptProcess.on("error", (error) => {
//onError(err.message);
createLog("error", "lst", "serverUpdater", `${error}`);
});
};

View File

@@ -0,0 +1,66 @@
import { z, createRoute, OpenAPIHono } from "@hono/zod-openapi";
import { authMiddleware } from "../../../auth/middleware/authMiddleware.js";
import { responses } from "../../../../globalUtils/routeDefs/responses.js";
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
import hasCorrectRole from "../../../auth/middleware/roleCheck.js";
import { serviceControl } from "../../controller/server/serviceControl.js";
// Define the request body schema
const requestSchema = z.object({
processType: z.string().openapi({ example: "restart" }),
plantToken: z.string().openapi({ example: "usday1" }),
remote: z.string().optional().openapi({ example: "true" }),
});
const app = new OpenAPIHono();
app.openapi(
createRoute({
tags: ["server"],
summary: "Starts, Stops, Restarts the server.",
method: "post",
path: "/serviceprocess",
middleware: [authMiddleware, hasCorrectRole(["systemAdmin"], "admin")],
request: {
body: {
content: {
"application/json": { schema: requestSchema },
},
},
},
responses: responses(),
}),
async (c) => {
const { data, error } = await tryCatch(c.req.json());
if (error) {
return c.json({
success: false,
message: "Error with the request body.",
});
}
const { data: process, error: processError } = await tryCatch(
serviceControl(
data.plantToken,
data.processType!,
data.remote ?? ""
)
);
if (processError) {
return c.json({
success: false,
message: "There was an error running the service type",
});
}
return c.json({
success: true,
message: `The service was ${data.processType}`,
});
}
);
export default app;

View File

@@ -13,6 +13,7 @@ import { serversCheckPoint } from "./utils/serverData.js";
import getServers from "./route/servers/getServers.js"; import getServers from "./route/servers/getServers.js";
import updateServer from "./route/updates/updateServer.js"; import updateServer from "./route/updates/updateServer.js";
import { setPerms } from "./utils/testServerPerms.js"; import { setPerms } from "./utils/testServerPerms.js";
import serviceControl from './route/servers/serverContorl.js'
// making sure all modules are in properly // making sure all modules are in properly
setTimeout(async () => { setTimeout(async () => {
@@ -35,6 +36,7 @@ const routes = [
// serverData // serverData
getServers, getServers,
updateServer, updateServer,
serviceControl
] as const; ] as const;
// app.route("/server", modules); // app.route("/server", modules);

View File

@@ -18,7 +18,7 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{ "specialInstructions": "something for ti" }] "otherSettings": [{ "specialInstructions": "" }]
}, },
{ {
"sName": "Bethlehem", "sName": "Bethlehem",
@@ -38,7 +38,7 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{ "specialInstructions": "something for ti" }] "otherSettings": [{ "specialInstructions": "" }]
}, },
{ {
"sName": "Huston", "sName": "Huston",
@@ -58,7 +58,7 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{ "specialInstructions": "something for ti" }] "otherSettings": [{ "specialInstructions": "" }]
}, },
{ {
"sName": "Bowling Green 1", "sName": "Bowling Green 1",
@@ -69,16 +69,20 @@
"streetAddress": "215 Technology Way", "streetAddress": "215 Technology Way",
"cityState": "Bowling Green, KY", "cityState": "Bowling Green, KY",
"zipcode": "42101", "zipcode": "42101",
"contactEmail": "blake.matthes@alpla.com", "contactEmail": "ShippingReceivingBowlingGreen1@groups.alpla.com",
"contactPhone": "6366970253", "contactPhone": "(270) 495-6647",
"customerTiAcc": "ALPL01BG1INT", "customerTiAcc": "ALPL01BG1INT",
"lstServerPort": "4000", "lstServerPort": "4000",
"active": true, "active": true,
"serverLoc": "E:\\LST\\lstv2", "serverLoc": "E:\\LST\\lstv2",
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"00:00\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{ "specialInstructions": "something for ti" }] "otherSettings": [
{
"specialInstructions": "Please be sure to schedule a pick up appointment and bring 2 load bars to secure the load."
}
]
}, },
{ {
"sName": "Iowa ISBM", "sName": "Iowa ISBM",
@@ -93,12 +97,12 @@
"contactPhone": "6366970253", "contactPhone": "6366970253",
"customerTiAcc": "ALPL01IA2INT", "customerTiAcc": "ALPL01IA2INT",
"lstServerPort": "4001", "lstServerPort": "4001",
"active": false, "active": true,
"serverLoc": "E:\\LST\\lstv2", "serverLoc": "D:\\LST\\lstv2_2",
"oldVersion": "E:\\LST\\lst_backend_2", "oldVersion": "D:\\LST\\lst_backend_2",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{ "specialInstructions": "something for ti" }] "otherSettings": [{ "specialInstructions": "" }]
}, },
{ {
"sName": "Kansas City", "sName": "Kansas City",
@@ -113,12 +117,12 @@
"contactPhone": "6366970253", "contactPhone": "6366970253",
"customerTiAcc": "ALPL01KCINT", "customerTiAcc": "ALPL01KCINT",
"lstServerPort": "4000", "lstServerPort": "4000",
"active": false, "active": true,
"serverLoc": "E:\\LST\\lstv2", "serverLoc": "E:\\LST\\lstv2",
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{ "specialInstructions": "something for ti" }] "otherSettings": [{ "specialInstructions": "" }]
}, },
{ {
"sName": "Bowling Green 2", "sName": "Bowling Green 2",
@@ -138,7 +142,7 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{ "specialInstructions": "something for ti" }] "otherSettings": [{ "specialInstructions": "" }]
}, },
{ {
"sName": "MCDonough", "sName": "MCDonough",
@@ -158,7 +162,7 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{ "specialInstructions": "something for ti" }] "otherSettings": [{ "specialInstructions": "" }]
}, },
{ {
"sName": "Dayton", "sName": "Dayton",
@@ -178,7 +182,7 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{ "specialInstructions": "something for ti" }] "otherSettings": [{ "specialInstructions": "" }]
}, },
{ {
"sName": "Salt Lake City", "sName": "Salt Lake City",
@@ -189,16 +193,16 @@
"streetAddress": "4324 Commercial Way Suite A", "streetAddress": "4324 Commercial Way Suite A",
"cityState": "Salt Lake City, UT", "cityState": "Salt Lake City, UT",
"zipcode": "84104", "zipcode": "84104",
"contactEmail": "blake.matthes@alpla.com", "contactEmail": "ShippingReceivingSaltLake@groups.alpla.com",
"contactPhone": "6366970253", "contactPhone": "801-673-2143",
"customerTiAcc": "ALPL01SLCINT", "customerTiAcc": "ALPL01SLCINT",
"lstServerPort": "4000", "lstServerPort": "4000",
"active": false, "active": true,
"serverLoc": "E:\\LST\\lstv2", "serverLoc": "E:\\LST\\lstv2",
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"07:00\", \"late\": \"17:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{ "specialInstructions": "something for ti" }] "otherSettings": [{ "specialInstructions": "Copy of bol" }]
}, },
{ {
"sName": "Lima", "sName": "Lima",
@@ -218,7 +222,7 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{ "specialInstructions": "something for ti" }] "otherSettings": [{ "specialInstructions": "" }]
}, },
{ {
"sName": "Florence", "sName": "Florence",
@@ -233,12 +237,12 @@
"contactPhone": "6366970253", "contactPhone": "6366970253",
"customerTiAcc": "ALPL01FLORINT", "customerTiAcc": "ALPL01FLORINT",
"lstServerPort": "4000", "lstServerPort": "4000",
"active": false, "active": true,
"serverLoc": "E:\\LST\\lstv2", "serverLoc": "E:\\LST\\lstv2",
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{ "specialInstructions": "something for ti" }] "otherSettings": [{ "specialInstructions": "" }]
}, },
{ {
"sName": "Iowa EBM", "sName": "Iowa EBM",
@@ -253,12 +257,12 @@
"contactPhone": "6366970253", "contactPhone": "6366970253",
"customerTiAcc": "ALPL01IA1INT", "customerTiAcc": "ALPL01IA1INT",
"lstServerPort": "4000", "lstServerPort": "4000",
"active": false, "active": true,
"serverLoc": "E:\\LST\\lstv2", "serverLoc": "D:\\LST\\lstv2",
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "D:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{ "specialInstructions": "something for ti" }] "otherSettings": [{ "specialInstructions": "" }]
}, },
{ {
"sName": "Jefferson city", "sName": "Jefferson city",
@@ -278,7 +282,7 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{ "specialInstructions": "something for ti" }] "otherSettings": [{ "specialInstructions": "" }]
}, },
{ {
"sName": "Sherman", "sName": "Sherman",
@@ -298,7 +302,7 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{ "specialInstructions": "something for ti" }] "otherSettings": [{ "specialInstructions": "" }]
}, },
{ {
"sName": "West Bend", "sName": "West Bend",
@@ -313,13 +317,16 @@
"contactPhone": "262-808-4211", "contactPhone": "262-808-4211",
"customerTiAcc": "ALPL01WBINT", "customerTiAcc": "ALPL01WBINT",
"lstServerPort": "4000", "lstServerPort": "4000",
"active": false, "active": true,
"serverLoc": "E:\\LST\\lstv2", "serverLoc": "E:\\LST\\lstv2",
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [ "otherSettings": [
{ "specialInstructions": "something for ti", "active": false } {
"specialInstructions": "This is a FTL load. The driver will need 2 adjustable load locks to secure the load. The driver will not be loaded without them. Please reference ALPLA pickup [header]",
"active": false
}
] ]
}, },
{ {
@@ -335,12 +342,12 @@
"contactPhone": "6366970253", "contactPhone": "6366970253",
"customerTiAcc": "ALPL01STPINT", "customerTiAcc": "ALPL01STPINT",
"lstServerPort": "4000", "lstServerPort": "4000",
"active": false, "active": true,
"serverLoc": "E:\\LST\\lstv2", "serverLoc": "E:\\LST\\lstv2",
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{ "specialInstructions": "something for ti" }] "otherSettings": [{ "specialInstructions": "" }]
} }
] ]
} }

View File

@@ -1,9 +1,9 @@
// This will help maintain the server db so when we run an update it will show up here all the time. // This will help maintain the server db so when we run an update it will show up here all the time.
// kinda bad too but this will help us keep the db identical. // kinda bad too but this will help us keep the db identical.
import {db} from "../../../../database/dbclient.js"; import { db } from "../../../../database/dbclient.js";
import {serverData} from "../../../../database/schema/serverData.js"; import { serverData } from "../../../../database/schema/serverData.js";
import {createLog} from "../../logger/logger.js"; import { createLog } from "../../logger/logger.js";
import fs from "fs"; import fs from "fs";
export const serversCheckPoint = async () => { export const serversCheckPoint = async () => {
@@ -28,27 +28,38 @@ export const serversCheckPoint = async () => {
try { try {
for (let i = 0; i < servers.length; i++) { for (let i = 0; i < servers.length; i++) {
const serverUpdate = await db const serverUpdate = await db
.insert(serverData) .insert(serverData)
.values(servers[i]) .values(servers[i])
.onConflictDoUpdate({ .onConflictDoUpdate({
target: serverData.plantToken, target: serverData.plantToken,
set: { set: {
sName: servers[i].sName, sName: servers[i].sName,
serverDNS: servers[i].serverDNS, serverDNS: servers[i].serverDNS,
active: servers[i].active, active: servers[i].active,
contactEmail: servers[i].contactEmail, contactEmail: servers[i].contactEmail,
contactPhone: servers[i].contactPhone, contactPhone: servers[i].contactPhone,
shippingHours: servers[i].shippingHours, shippingHours: servers[i].shippingHours,
customerTiAcc: servers[i].customerTiAcc, customerTiAcc: servers[i].customerTiAcc,
oldVersion: servers[i].oldVersion, serverLoc: servers[i].serverLoc,
tiPostTime: servers[i].tiPostTime, oldVersion: servers[i].oldVersion,
otherSettings: servers[i].otherSettings, tiPostTime: servers[i].tiPostTime,
}, otherSettings: servers[i].otherSettings,
}) // this will only update the ones that are new :D },
.returning({name: serverData.sName}); }) // this will only update the ones that are new :D
.returning({ name: serverData.sName });
} }
createLog("info", "lst", "server", "Servers were just added/updated due to server startup"); createLog(
"info",
"lst",
"server",
"Servers were just added/updated due to server startup"
);
} catch (error) { } catch (error) {
createLog("error", "lst", "server", `There was an error adding/updating serverData to the db, ${error}`); createLog(
"error",
"lst",
"server",
`There was an error adding/updating serverData to the db, ${error}`
);
} }
}; };

View File

@@ -0,0 +1,82 @@
// this query pulls all the inventory except the inv locations.
export const totalInvNoRn = `
select x.idartikelVarianten as av,
ArtikelVariantenAlias as Alias,
--x.Lfdnr as RunningNumber,
round(sum(EinlagerungsMengeVPKSum),0) as Total_Pallets,
sum(EinlagerungsMengeSum) as Total_PalletQTY,
round(sum(VerfuegbareMengeVPKSum),0) as Avalible_Pallets,
sum(VerfuegbareMengeSum) as Avaliable_PalletQTY,
sum(case when c.Description LIKE '%COA%' then GesperrteMengeVPKSum else 0 end) as COA_Pallets,
sum(case when c.Description LIKE '%COA%' then GesperrteMengeSum else 0 end) as COA_QTY,
sum(case when c.Description NOT LIKE '%COA%' or x.IdMainDefect = -1 then GesperrteMengeVPKSum else 0 end) as Held_Pallets,
sum(case when c.Description NOT LIKE '%COA%' or x.IdMainDefect = -1 then GesperrteMengeSum else 0 end) as Held_QTY,
IdProdPlanung as Lot,
IdAdressen,
x.AdressBez
--,*
from [AlplaPROD_test1].dbo.[V_LagerPositionenBarcodes] (nolock) x
left join
[AlplaPROD_test1].dbo.T_EtikettenGedruckt as l(nolock) on
x.Lfdnr = l.Lfdnr AND l.Lfdnr > 1
left join
(SELECT *
FROM [AlplaPROD_test1].[dbo].[T_BlockingDefects] where Active = 1) as c
on x.IdMainDefect = c.IdBlockingDefect
/*
The data below will be controlled by the user in excell by default everything will be passed over
IdAdressen = 3
*/
where /*IdArtikelTyp = 1 and */x.IdWarenlager not in (6, 1)
group by x.idartikelVarianten, ArtikelVariantenAlias, IdProdPlanung, c.Description, IdAdressen,
x.AdressBez --, x.Lfdnr
order by x.IdArtikelVarianten
`;
export const totalInvRn = `
select x.idartikelVarianten as av,
ArtikelVariantenAlias as Alias,
x.Lfdnr as RunningNumber,
round(sum(EinlagerungsMengeVPKSum),0) as Total_Pallets,
sum(EinlagerungsMengeSum) as Total_PalletQTY,
round(sum(VerfuegbareMengeVPKSum),0) as Avalible_Pallets,
sum(VerfuegbareMengeSum) as Avaliable_PalletQTY,
sum(case when c.Description LIKE '%COA%' then GesperrteMengeVPKSum else 0 end) as COA_Pallets,
sum(case when c.Description LIKE '%COA%' then GesperrteMengeSum else 0 end) as COA_QTY,
sum(case when c.Description NOT LIKE '%COA%' or x.IdMainDefect = -1 then GesperrteMengeVPKSum else 0 end) as Held_Pallets,
sum(case when c.Description NOT LIKE '%COA%' or x.IdMainDefect = -1 then GesperrteMengeSum else 0 end) as Held_QTY,
IdProdPlanung as Lot,
IdAdressen,
x.AdressBez
--,*
from [AlplaPROD_test1].dbo.[V_LagerPositionenBarcodes] (nolock) x
left join
[AlplaPROD_test1].dbo.T_EtikettenGedruckt as l(nolock) on
x.Lfdnr = l.Lfdnr AND l.Lfdnr > 1
left join
(SELECT *
FROM [AlplaPROD_test1].[dbo].[T_BlockingDefects] where Active = 1) as c
on x.IdMainDefect = c.IdBlockingDefect
/*
The data below will be controlled by the user in excell by default everything will be passed over
IdAdressen = 3
*/
where IdArtikelTyp = 1 and x.IdWarenlager not in (6, 1)
group by x.idartikelVarianten, ArtikelVariantenAlias, IdProdPlanung, c.Description, IdAdressen,
x.AdressBez , x.Lfdnr
order by x.IdArtikelVarianten
`;
const totalInvValue = ``;
const totalInvValueRn = ``;

View File

@@ -15,6 +15,10 @@
"esModuleInterop": true, "esModuleInterop": true,
"resolveJsonModule": true "resolveJsonModule": true
}, },
"include": ["server", "scripts/**/*.ts", "testFiles/test-tiPostOrders.ts"], "include": [
"exclude": ["node_modules", "frontend", "dist", "testFiles"] "server",
"scripts/**/*.ts",
"database/testFiles/test-tiPostOrders.ts"
],
"exclude": ["node_modules", "frontend", "dist", "database/testFiles"]
} }