Compare commits
19 Commits
63e005b790
...
d27611d035
| Author | SHA1 | Date | |
|---|---|---|---|
| d27611d035 | |||
| f771db6034 | |||
| 4f3b5d75a2 | |||
| a1f62a3e51 | |||
| de0ee3a61c | |||
| b48dd8fa15 | |||
| 3355eb389c | |||
| b2683d0429 | |||
| 7e484a0f90 | |||
| 77abaed60e | |||
| d10770bc49 | |||
| 1fee4b719b | |||
| 1dce3dccdc | |||
| 3babf8a749 | |||
| 29c9f2d1be | |||
| 459b0f287c | |||
| 7535e15337 | |||
| 68dac0dd28 | |||
| f442cedff2 |
@@ -125,7 +125,9 @@ export default function ServerPage() {
|
||||
token={token as string}
|
||||
/>
|
||||
<StartServer />
|
||||
<StopServer />
|
||||
<StopServer
|
||||
plantData={server}
|
||||
/>
|
||||
<RestartServer />
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -1,14 +1,46 @@
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Tooltip, TooltipContent, TooltipProvider, TooltipTrigger} from "@/components/ui/tooltip";
|
||||
import {Octagon} from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
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 (
|
||||
<div>
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button variant={"outline"} size={"icon"}>
|
||||
<Button
|
||||
variant="destructive"
|
||||
size={"icon"}
|
||||
onClick={() =>
|
||||
handleStopServer(plantData.plantToken)
|
||||
}
|
||||
>
|
||||
<Octagon />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
|
||||
@@ -1,23 +1,34 @@
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {CircleFadingArrowUp} from "lucide-react";
|
||||
import {toast} from "sonner";
|
||||
import {Servers} from "./ServerPage";
|
||||
import {useQuery} from "@tanstack/react-query";
|
||||
import {getSettings} from "@/utils/querys/settings";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { CircleFadingArrowUp } from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
import { Servers } from "./ServerPage";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getSettings } from "@/utils/querys/settings";
|
||||
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}) {
|
||||
const {data} = useQuery(getSettings(token ?? ""));
|
||||
export default function UpdateServer({
|
||||
server,
|
||||
token,
|
||||
}: {
|
||||
server: Servers;
|
||||
token: string;
|
||||
}) {
|
||||
const { data } = useQuery(getSettings(token ?? ""));
|
||||
const upgrade = async () => {
|
||||
let devDir = data.filter((n: any) => n.name === "devDir");
|
||||
toast.success("Server being upgraded in the background please wait.");
|
||||
try {
|
||||
const result = await axios.post(
|
||||
`/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);
|
||||
}
|
||||
} 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 (
|
||||
@@ -37,7 +50,12 @@ export default function UpdateServer({server, token}: {server: Servers; token: s
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<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 />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
"commit": "cz",
|
||||
"prodinstall": "npm i --omit=dev && npm run db:migrate",
|
||||
"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": {
|
||||
"commitizen": {
|
||||
@@ -35,7 +35,7 @@
|
||||
}
|
||||
},
|
||||
"admConfig": {
|
||||
"build": 136,
|
||||
"build": 147,
|
||||
"oldBuild": "backend-0.1.3.zip"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -53,14 +53,12 @@ add in the below and change each setting area that says change me to something t
|
||||
|
||||
```env
|
||||
# PORTS
|
||||
PROD_PORT=4000
|
||||
# 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
|
||||
LOG_LEVEL=debug
|
||||
PROD_PORT=4000
|
||||
# DUE to lstv1 we need 3000
|
||||
SEC_PORT=3000
|
||||
LOG_LEVEL=info
|
||||
# Auth stuff
|
||||
SALTING=12
|
||||
SECRET=CHANGEME
|
||||
@@ -138,6 +136,36 @@ Next use the example command below to get the service up and running.
|
||||
.\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
|
||||
|
||||
## User migration
|
||||
|
||||
@@ -4,6 +4,7 @@ param (
|
||||
[string]$appPath,
|
||||
[string]$command, # just the command like run startadm or what ever you have in npm.
|
||||
[string]$description
|
||||
[string]$remote
|
||||
)
|
||||
|
||||
# Example string to run with the parameters in it.
|
||||
@@ -24,6 +25,16 @@ param (
|
||||
$nssmPath = $AppPath + "\nssm.exe"
|
||||
$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")) {
|
||||
Write-Host "Error: This script must be run as Administrator."
|
||||
exit 1
|
||||
|
||||
@@ -132,6 +132,17 @@ $plantFunness = {
|
||||
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."
|
||||
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
import {eq} from "drizzle-orm";
|
||||
import {db} from "../../../../database/dbclient.js";
|
||||
import {users} from "../../../../database/schema/users.js";
|
||||
import {createPassword} from "../utils/createPassword.js";
|
||||
import {setSysAdmin} from "./userRoles/setSysAdmin.js";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { db } from "../../../../database/dbclient.js";
|
||||
import { users } from "../../../../database/schema/users.js";
|
||||
import { createPassword } from "../utils/createPassword.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);
|
||||
|
||||
// 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) {
|
||||
return {
|
||||
@@ -26,18 +34,26 @@ export const registerUser = async (username: string, password: string, email: st
|
||||
try {
|
||||
const user = await db
|
||||
.insert(users)
|
||||
.values({username, email, password})
|
||||
.returning({user: users.username, email: users.email});
|
||||
.values({ username, email, password })
|
||||
.returning({ user: users.username, email: users.email });
|
||||
|
||||
if (usercount.length <= 1) {
|
||||
console.log(`${username} is the first user and will be set to system admin.`);
|
||||
const updateUser = await db.select().from(users).where(eq(users.username, username));
|
||||
createLog(
|
||||
"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");
|
||||
}
|
||||
|
||||
return {sucess: true, message: "User Registered", user};
|
||||
return { sucess: true, message: "User Registered", user };
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
createLog("error", "auth", "auth", `${error}`);
|
||||
return {
|
||||
success: false,
|
||||
message: `${username} already exists please login or reset password, if you feel this is an error please contact your admin.`,
|
||||
|
||||
@@ -48,10 +48,19 @@ app.openapi(
|
||||
//apiHit(c, { endpoint: "api/auth/setUserRoles" });
|
||||
const { username, module, role, override } = await c.req.json();
|
||||
try {
|
||||
const access = await setUserAccess(username, module, role, override);
|
||||
const access = await setUserAccess(
|
||||
username,
|
||||
module,
|
||||
role,
|
||||
override
|
||||
);
|
||||
//return apiReturn(c, true, access?.message, access?.data, 200);
|
||||
return c.json(
|
||||
{ success: access.success, message: access.message, data: access.data },
|
||||
{
|
||||
success: access.success,
|
||||
message: access.message,
|
||||
data: access.data,
|
||||
},
|
||||
200
|
||||
);
|
||||
} catch (error) {
|
||||
|
||||
23
server/services/dataMart/controller/getinventory.ts
Normal file
23
server/services/dataMart/controller/getinventory.ts
Normal 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,
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -1,10 +1,11 @@
|
||||
import { OpenAPIHono } from "@hono/zod-openapi";
|
||||
|
||||
import activequerys from "./route/getCurrentQuerys.js";
|
||||
import getArticles from "./route/getActiveArticles.js";
|
||||
import currentInv from "./route/getInventory.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
const routes = [getArticles] as const;
|
||||
const routes = [activequerys, getArticles, currentInv] as const;
|
||||
|
||||
const appRoutes = routes.forEach((route) => {
|
||||
app.route("/datamart", route);
|
||||
|
||||
102
server/services/dataMart/route/getCurrentQuerys.ts
Normal file
102
server/services/dataMart/route/getCurrentQuerys.ts
Normal 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;
|
||||
54
server/services/dataMart/route/getInventory.ts
Normal file
54
server/services/dataMart/route/getInventory.ts
Normal 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;
|
||||
@@ -49,7 +49,7 @@ const tiImport = async () => {
|
||||
|
||||
// parsing posting window
|
||||
const plantI = plantInfo!;
|
||||
const postTime = JSON.parse(plantI[0]?.tiPostTime!);
|
||||
//const postTime = JSON.parse(plantI[0]?.tiPostTime!);
|
||||
|
||||
// order notifications
|
||||
const { data: notificationSet, error: notificationSettingsErr } =
|
||||
@@ -149,6 +149,16 @@ const tiImport = async () => {
|
||||
);
|
||||
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>
|
||||
let itemGroups = "";
|
||||
|
||||
@@ -304,13 +314,12 @@ const tiImport = async () => {
|
||||
? 40
|
||||
: 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}`
|
||||
);
|
||||
if (otherSettings[0].specialInstructions.length != 0) {
|
||||
payload = payload.replaceAll("[specialInstructions]", specialInfo);
|
||||
}
|
||||
|
||||
// update the carrier info if any is needed.
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import { fileURLToPath } from "url";
|
||||
import hbs from "nodemailer-express-handlebars";
|
||||
import { promisify } from "util";
|
||||
import { createLog } from "../../logger/logger.js";
|
||||
import { installed } from "../../../index.js";
|
||||
|
||||
interface HandlebarsMailOptions extends Mail.Options {
|
||||
template: string;
|
||||
@@ -25,6 +26,10 @@ interface EmailData {
|
||||
}
|
||||
|
||||
export const sendEmail = async (data: any): Promise<any> => {
|
||||
if (!installed) {
|
||||
createLog("error", "notify", "notify", "server not installed.");
|
||||
return;
|
||||
}
|
||||
let transporter: Transporter;
|
||||
let fromEmail: string | Address;
|
||||
const { data: settingData, error: settingError } = await tryCatch(
|
||||
|
||||
@@ -9,6 +9,7 @@ import { createLog } from "../logger/logger.js";
|
||||
import { note, notificationCreate } from "./utils/masterNotifications.js";
|
||||
import { startNotificationMonitor } from "./utils/processNotifications.js";
|
||||
import notifyStats from "./routes/getActiveNotifications.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
const routes = [sendemail, notifyStats] as const;
|
||||
|
||||
@@ -39,7 +39,7 @@ export const postLabelData = async (data: any) => {
|
||||
);
|
||||
}
|
||||
|
||||
if (label.length === 0) {
|
||||
if (label?.length === 0) {
|
||||
return {
|
||||
success: false,
|
||||
message: "The label you scanned dose not exist in stock.",
|
||||
|
||||
@@ -69,6 +69,7 @@ export const bookInLabel = async (data: any) => {
|
||||
message: `${parseInt(
|
||||
data.SSCC.slice(10, -1)
|
||||
)}, was just booked in`,
|
||||
data: { SSCC: data.SSCC },
|
||||
};
|
||||
} catch (error) {
|
||||
createLog(
|
||||
|
||||
@@ -59,11 +59,11 @@ export const labelingProcess = async ({
|
||||
"error",
|
||||
"labeling",
|
||||
"ocp",
|
||||
`There is not a lot assigned to ${macId[0].Name}.`
|
||||
`There is not a lot assigned to ${macId[0]?.Name}.`
|
||||
);
|
||||
return {
|
||||
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.
|
||||
const bookin = settingData.filter((s) => s.name === "bookin");
|
||||
|
||||
let book: any = [];
|
||||
if (bookin[0].value === "1") {
|
||||
const book = await bookInLabel(label.data);
|
||||
book = await bookInLabel(label.data);
|
||||
} else {
|
||||
createLog("info", "labeling", "ocp", "Bookin is turned off.");
|
||||
|
||||
@@ -231,7 +231,8 @@ export const labelingProcess = async ({
|
||||
(s) => s.name === "inhouseDelivery"
|
||||
);
|
||||
if (inhouseDelivery[0].value === "1") {
|
||||
const deliverPallet = await delieryInhouse(label);
|
||||
const deliverPallet = await delieryInhouse(book.data);
|
||||
// console.log(deliverPallet);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
90
server/services/server/controller/server/serviceControl.ts
Normal file
90
server/services/server/controller/server/serviceControl.ts
Normal 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}`);
|
||||
});
|
||||
};
|
||||
66
server/services/server/route/servers/serverContorl.ts
Normal file
66
server/services/server/route/servers/serverContorl.ts
Normal 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;
|
||||
@@ -13,6 +13,7 @@ import { serversCheckPoint } from "./utils/serverData.js";
|
||||
import getServers from "./route/servers/getServers.js";
|
||||
import updateServer from "./route/updates/updateServer.js";
|
||||
import { setPerms } from "./utils/testServerPerms.js";
|
||||
import serviceControl from './route/servers/serverContorl.js'
|
||||
|
||||
// making sure all modules are in properly
|
||||
setTimeout(async () => {
|
||||
@@ -35,6 +36,7 @@ const routes = [
|
||||
// serverData
|
||||
getServers,
|
||||
updateServer,
|
||||
serviceControl
|
||||
] as const;
|
||||
|
||||
// app.route("/server", modules);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"oldVersion": "E:\\LST\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{ "specialInstructions": "something for ti" }]
|
||||
"otherSettings": [{ "specialInstructions": "" }]
|
||||
},
|
||||
{
|
||||
"sName": "Bethlehem",
|
||||
@@ -38,7 +38,7 @@
|
||||
"oldVersion": "E:\\LST\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{ "specialInstructions": "something for ti" }]
|
||||
"otherSettings": [{ "specialInstructions": "" }]
|
||||
},
|
||||
{
|
||||
"sName": "Huston",
|
||||
@@ -58,7 +58,7 @@
|
||||
"oldVersion": "E:\\LST\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{ "specialInstructions": "something for ti" }]
|
||||
"otherSettings": [{ "specialInstructions": "" }]
|
||||
},
|
||||
{
|
||||
"sName": "Bowling Green 1",
|
||||
@@ -69,16 +69,20 @@
|
||||
"streetAddress": "215 Technology Way",
|
||||
"cityState": "Bowling Green, KY",
|
||||
"zipcode": "42101",
|
||||
"contactEmail": "blake.matthes@alpla.com",
|
||||
"contactPhone": "6366970253",
|
||||
"contactEmail": "ShippingReceivingBowlingGreen1@groups.alpla.com",
|
||||
"contactPhone": "(270) 495-6647",
|
||||
"customerTiAcc": "ALPL01BG1INT",
|
||||
"lstServerPort": "4000",
|
||||
"active": true,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "E:\\LST\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"shippingHours": "[{\"early\": \"00:00\", \"late\": \"23:00\"}]",
|
||||
"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",
|
||||
@@ -93,12 +97,12 @@
|
||||
"contactPhone": "6366970253",
|
||||
"customerTiAcc": "ALPL01IA2INT",
|
||||
"lstServerPort": "4001",
|
||||
"active": false,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "E:\\LST\\lst_backend_2",
|
||||
"active": true,
|
||||
"serverLoc": "D:\\LST\\lstv2_2",
|
||||
"oldVersion": "D:\\LST\\lst_backend_2",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{ "specialInstructions": "something for ti" }]
|
||||
"otherSettings": [{ "specialInstructions": "" }]
|
||||
},
|
||||
{
|
||||
"sName": "Kansas City",
|
||||
@@ -113,12 +117,12 @@
|
||||
"contactPhone": "6366970253",
|
||||
"customerTiAcc": "ALPL01KCINT",
|
||||
"lstServerPort": "4000",
|
||||
"active": false,
|
||||
"active": true,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "E:\\LST\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{ "specialInstructions": "something for ti" }]
|
||||
"otherSettings": [{ "specialInstructions": "" }]
|
||||
},
|
||||
{
|
||||
"sName": "Bowling Green 2",
|
||||
@@ -138,7 +142,7 @@
|
||||
"oldVersion": "E:\\LST\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{ "specialInstructions": "something for ti" }]
|
||||
"otherSettings": [{ "specialInstructions": "" }]
|
||||
},
|
||||
{
|
||||
"sName": "MCDonough",
|
||||
@@ -158,7 +162,7 @@
|
||||
"oldVersion": "E:\\LST\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{ "specialInstructions": "something for ti" }]
|
||||
"otherSettings": [{ "specialInstructions": "" }]
|
||||
},
|
||||
{
|
||||
"sName": "Dayton",
|
||||
@@ -178,7 +182,7 @@
|
||||
"oldVersion": "E:\\LST\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{ "specialInstructions": "something for ti" }]
|
||||
"otherSettings": [{ "specialInstructions": "" }]
|
||||
},
|
||||
{
|
||||
"sName": "Salt Lake City",
|
||||
@@ -189,16 +193,16 @@
|
||||
"streetAddress": "4324 Commercial Way Suite A",
|
||||
"cityState": "Salt Lake City, UT",
|
||||
"zipcode": "84104",
|
||||
"contactEmail": "blake.matthes@alpla.com",
|
||||
"contactPhone": "6366970253",
|
||||
"contactEmail": "ShippingReceivingSaltLake@groups.alpla.com",
|
||||
"contactPhone": "801-673-2143",
|
||||
"customerTiAcc": "ALPL01SLCINT",
|
||||
"lstServerPort": "4000",
|
||||
"active": false,
|
||||
"active": true,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "E:\\LST\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"shippingHours": "[{\"early\": \"07:00\", \"late\": \"17:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{ "specialInstructions": "something for ti" }]
|
||||
"otherSettings": [{ "specialInstructions": "Copy of bol" }]
|
||||
},
|
||||
{
|
||||
"sName": "Lima",
|
||||
@@ -218,7 +222,7 @@
|
||||
"oldVersion": "E:\\LST\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{ "specialInstructions": "something for ti" }]
|
||||
"otherSettings": [{ "specialInstructions": "" }]
|
||||
},
|
||||
{
|
||||
"sName": "Florence",
|
||||
@@ -233,12 +237,12 @@
|
||||
"contactPhone": "6366970253",
|
||||
"customerTiAcc": "ALPL01FLORINT",
|
||||
"lstServerPort": "4000",
|
||||
"active": false,
|
||||
"active": true,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "E:\\LST\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{ "specialInstructions": "something for ti" }]
|
||||
"otherSettings": [{ "specialInstructions": "" }]
|
||||
},
|
||||
{
|
||||
"sName": "Iowa EBM",
|
||||
@@ -253,12 +257,12 @@
|
||||
"contactPhone": "6366970253",
|
||||
"customerTiAcc": "ALPL01IA1INT",
|
||||
"lstServerPort": "4000",
|
||||
"active": false,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "E:\\LST\\lst_backend",
|
||||
"active": true,
|
||||
"serverLoc": "D:\\LST\\lstv2",
|
||||
"oldVersion": "D:\\LST\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{ "specialInstructions": "something for ti" }]
|
||||
"otherSettings": [{ "specialInstructions": "" }]
|
||||
},
|
||||
{
|
||||
"sName": "Jefferson city",
|
||||
@@ -278,7 +282,7 @@
|
||||
"oldVersion": "E:\\LST\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{ "specialInstructions": "something for ti" }]
|
||||
"otherSettings": [{ "specialInstructions": "" }]
|
||||
},
|
||||
{
|
||||
"sName": "Sherman",
|
||||
@@ -298,7 +302,7 @@
|
||||
"oldVersion": "E:\\LST\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{ "specialInstructions": "something for ti" }]
|
||||
"otherSettings": [{ "specialInstructions": "" }]
|
||||
},
|
||||
{
|
||||
"sName": "West Bend",
|
||||
@@ -313,13 +317,16 @@
|
||||
"contactPhone": "262-808-4211",
|
||||
"customerTiAcc": "ALPL01WBINT",
|
||||
"lstServerPort": "4000",
|
||||
"active": false,
|
||||
"active": true,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "E:\\LST\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"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",
|
||||
"customerTiAcc": "ALPL01STPINT",
|
||||
"lstServerPort": "4000",
|
||||
"active": false,
|
||||
"active": true,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "E:\\LST\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{ "specialInstructions": "something for ti" }]
|
||||
"otherSettings": [{ "specialInstructions": "" }]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
// kinda bad too but this will help us keep the db identical.
|
||||
|
||||
import {db} from "../../../../database/dbclient.js";
|
||||
import {serverData} from "../../../../database/schema/serverData.js";
|
||||
import {createLog} from "../../logger/logger.js";
|
||||
import { db } from "../../../../database/dbclient.js";
|
||||
import { serverData } from "../../../../database/schema/serverData.js";
|
||||
import { createLog } from "../../logger/logger.js";
|
||||
import fs from "fs";
|
||||
|
||||
export const serversCheckPoint = async () => {
|
||||
@@ -40,15 +40,26 @@ export const serversCheckPoint = async () => {
|
||||
contactPhone: servers[i].contactPhone,
|
||||
shippingHours: servers[i].shippingHours,
|
||||
customerTiAcc: servers[i].customerTiAcc,
|
||||
serverLoc: servers[i].serverLoc,
|
||||
oldVersion: servers[i].oldVersion,
|
||||
tiPostTime: servers[i].tiPostTime,
|
||||
otherSettings: servers[i].otherSettings,
|
||||
},
|
||||
}) // this will only update the ones that are new :D
|
||||
.returning({name: serverData.sName});
|
||||
.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) {
|
||||
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}`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
82
server/services/sqlServer/querys/dataMart/totalINV.ts
Normal file
82
server/services/sqlServer/querys/dataMart/totalINV.ts
Normal 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 = ``;
|
||||
@@ -15,6 +15,10 @@
|
||||
"esModuleInterop": true,
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"include": ["server", "scripts/**/*.ts", "testFiles/test-tiPostOrders.ts"],
|
||||
"exclude": ["node_modules", "frontend", "dist", "testFiles"]
|
||||
"include": [
|
||||
"server",
|
||||
"scripts/**/*.ts",
|
||||
"database/testFiles/test-tiPostOrders.ts"
|
||||
],
|
||||
"exclude": ["node_modules", "frontend", "dist", "database/testFiles"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user