Compare commits
11 Commits
97cf624440
...
9cea76e01f
| Author | SHA1 | Date | |
|---|---|---|---|
| 9cea76e01f | |||
| 3cb7fd2e1b | |||
| 1b90129516 | |||
| ead63d4b41 | |||
| 3573fd1a5b | |||
| 0ae8aea3ac | |||
| f74a22bbb1 | |||
| afa80114fb | |||
| 46f8d6cde6 | |||
| f272cf9ad9 | |||
| e81a6456d8 |
30
CHANGELOG.md
30
CHANGELOG.md
@@ -1,5 +1,35 @@
|
|||||||
# All CHanges to LST can be found below.
|
# All CHanges to LST can be found below.
|
||||||
|
|
||||||
|
## [2.17.0](https://git.tuffraid.net/cowch/lstV2/compare/v2.16.1...v2.17.0) (2025-04-23)
|
||||||
|
|
||||||
|
|
||||||
|
### 🛠️ Code Refactor
|
||||||
|
|
||||||
|
* **profile updates:** added a link to the profile change email ([5a48dcf](https://git.tuffraid.net/cowch/lstV2/commits/5a48dcf55379aa1b622bfef6efbc1c66e7ada74e))
|
||||||
|
* **profile:** changed to patch vs posting ([57d3727](https://git.tuffraid.net/cowch/lstV2/commits/57d3727f490bf020044287dbc63f3f6268467de2))
|
||||||
|
|
||||||
|
|
||||||
|
### 📝 Testing Code
|
||||||
|
|
||||||
|
* **forecast:** loreal forecast starting ([c248cc0](https://git.tuffraid.net/cowch/lstV2/commits/c248cc012946dcfe1afb24724075180b6bccbf03))
|
||||||
|
|
||||||
|
|
||||||
|
### 🌟 Enhancements
|
||||||
|
|
||||||
|
* **build:** removed v1 from being built in ([a03130a](https://git.tuffraid.net/cowch/lstV2/commits/a03130a961bab430a1352a88ab8dda058f3b5ef6))
|
||||||
|
* **dm:** buttons to the nav bar if customs are made ([3c9e627](https://git.tuffraid.net/cowch/lstV2/commits/3c9e627021b31d6ba711324c00ca6514a4ab7b89))
|
||||||
|
* **dm:** standard forecast and orders in ([28b0508](https://git.tuffraid.net/cowch/lstV2/commits/28b050859a190c6cebbd0e524999c0a9c5b61bf0))
|
||||||
|
* **lst:** removed v1 from the update ([b290b21](https://git.tuffraid.net/cowch/lstV2/commits/b290b21ca2ace219f508ac2c97c85f062d1f4c2a))
|
||||||
|
* **orders:** energizer orders in ([e0df6b8](https://git.tuffraid.net/cowch/lstV2/commits/e0df6b8cd7bfe07415b7d0d074cb4b60c94f2b44))
|
||||||
|
* **password change:** added in password link to email and change in lst ([86905b5](https://git.tuffraid.net/cowch/lstV2/commits/86905b591ba9891cfdd1d0d8a02d78781179e488))
|
||||||
|
* **registerpage:** added in but hidden ([7152e72](https://git.tuffraid.net/cowch/lstV2/commits/7152e72822aecf5de6a9ac32057b8f9a26bb3907))
|
||||||
|
|
||||||
|
|
||||||
|
### 🐛 Bug fixes
|
||||||
|
|
||||||
|
* **lot assignment:** removed the return i had oops ([97cf624](https://git.tuffraid.net/cowch/lstV2/commits/97cf624440d5631494109054505b58c8ee91dd48))
|
||||||
|
* **register:** typo ([eac7444](https://git.tuffraid.net/cowch/lstV2/commits/eac74440386c6e83655e18096a3da476865259f0))
|
||||||
|
|
||||||
### [2.16.1](https://git.tuffraid.net/cowch/lstV2/compare/v2.16.0...v2.16.1) (2025-04-23)
|
### [2.16.1](https://git.tuffraid.net/cowch/lstV2/compare/v2.16.0...v2.16.1) (2025-04-23)
|
||||||
|
|
||||||
## [2.16.0](https://git.tuffraid.net/cowch/lstV2/compare/v2.15.0...v2.16.0) (2025-04-22)
|
## [2.16.0](https://git.tuffraid.net/cowch/lstV2/compare/v2.15.0...v2.16.0) (2025-04-22)
|
||||||
|
|||||||
106
frontend/src/components/ocme/ManuallyEnterRn.tsx
Normal file
106
frontend/src/components/ocme/ManuallyEnterRn.tsx
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
import { useForm } from "@tanstack/react-form";
|
||||||
|
import { Input } from "../ui/input";
|
||||||
|
import { Label } from "../ui/label";
|
||||||
|
import axios from "axios";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
import { Button } from "../ui/button";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
|
export default function ManuallyEnterRn() {
|
||||||
|
const [sending, setSendingRn] = useState(false);
|
||||||
|
const form = useForm({
|
||||||
|
defaultValues: {
|
||||||
|
runningNr: "",
|
||||||
|
},
|
||||||
|
onSubmit: async ({ value }) => {
|
||||||
|
console.log(value);
|
||||||
|
setSendingRn(true);
|
||||||
|
try {
|
||||||
|
const res = await axios.post("/ocme/api/v1/postRunningNumber", {
|
||||||
|
runningNr: value.runningNr,
|
||||||
|
areaFrom: "wrapper_1",
|
||||||
|
completed: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res.data.success) {
|
||||||
|
form.reset();
|
||||||
|
toast.success(
|
||||||
|
`${value.runningNr} was just created please login`
|
||||||
|
);
|
||||||
|
setTimeout(() => {
|
||||||
|
setSendingRn(false);
|
||||||
|
}, 3 * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!res.data.success) {
|
||||||
|
toast.error(res.data.message);
|
||||||
|
setTimeout(() => {
|
||||||
|
setSendingRn(false);
|
||||||
|
}, 3 * 1000);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
//console.log(error);
|
||||||
|
toast.error("There was an error registering");
|
||||||
|
setTimeout(() => {
|
||||||
|
setSendingRn(false);
|
||||||
|
}, 3 * 1000);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<form
|
||||||
|
onSubmit={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
//e.stopPropagation();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<form.Field
|
||||||
|
name="runningNr"
|
||||||
|
validators={{
|
||||||
|
// We can choose between form-wide and field-specific validators
|
||||||
|
onChange: ({ value }) =>
|
||||||
|
value.length > 3
|
||||||
|
? undefined
|
||||||
|
: "pallet number must be greater than 4 numbers",
|
||||||
|
}}
|
||||||
|
children={(field) => {
|
||||||
|
return (
|
||||||
|
<div className="m-2 min-w-48 max-w-96 p-2 flex flex-row">
|
||||||
|
<div>
|
||||||
|
<Label htmlFor="runningNr" className="mb-2">
|
||||||
|
Running Number
|
||||||
|
</Label>
|
||||||
|
<Input
|
||||||
|
name={field.name}
|
||||||
|
value={field.state.value}
|
||||||
|
onBlur={field.handleBlur}
|
||||||
|
type="number"
|
||||||
|
onChange={(e) =>
|
||||||
|
field.handleChange(e.target.value)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
{field.state.meta.errors.length ? (
|
||||||
|
<em>
|
||||||
|
{field.state.meta.errors.join(",")}
|
||||||
|
</em>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
<div className="ml-1 mt-5">
|
||||||
|
<Button
|
||||||
|
className="ml-1"
|
||||||
|
type="submit"
|
||||||
|
onClick={form.handleSubmit}
|
||||||
|
disabled={sending}
|
||||||
|
>
|
||||||
|
Submit
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -16,6 +16,8 @@ import { getOcmeInfo } from "@/utils/querys/production/getOcmeInfo";
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import { Trash } from "lucide-react";
|
import { Trash } from "lucide-react";
|
||||||
|
import ManuallyEnterRn from "./ManuallyEnterRn";
|
||||||
|
import { Separator } from "../ui/separator";
|
||||||
|
|
||||||
const currentPallets = [
|
const currentPallets = [
|
||||||
{ key: "line", label: "Line" },
|
{ key: "line", label: "Line" },
|
||||||
@@ -88,76 +90,79 @@ export default function WrapperManualTrigger() {
|
|||||||
|
|
||||||
const info = data?.filter((r: any) => r.areaFrom === "wrapper_1");
|
const info = data?.filter((r: any) => r.areaFrom === "wrapper_1");
|
||||||
return (
|
return (
|
||||||
<LstCard className="m-2 p-2">
|
<LstCard className="m-2 p-2 w-auto">
|
||||||
<ScrollArea className="max-h-[200px]">
|
<ScrollArea className="max-h-[200px]">
|
||||||
<span>Wrapper Pallet Info</span>
|
<span>Wrapper Pallet Info</span>
|
||||||
|
<div>
|
||||||
<Table>
|
<Table>
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
{currentPallets.map((l) => (
|
{currentPallets.map((l) => (
|
||||||
<TableHead key={l.key}>{l.label}</TableHead>
|
<TableHead key={l.key}>{l.label}</TableHead>
|
||||||
))}
|
))}
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{Array(3)
|
{Array(3)
|
||||||
.fill(0)
|
.fill(0)
|
||||||
.map((_, i) => (
|
.map((_, i) => (
|
||||||
<TableRow key={i}>
|
<TableRow key={i}>
|
||||||
|
<TableCell className="font-medium">
|
||||||
|
<Skeleton className="h-4" />
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Skeleton className="h-4" />
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Skeleton className="h-4" />
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Skeleton className="h-4" />
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Skeleton className="h-4" />
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
) : (
|
||||||
|
<TableBody>
|
||||||
|
{info.map((i: any) => (
|
||||||
|
<TableRow key={i.runningNr}>
|
||||||
<TableCell className="font-medium">
|
<TableCell className="font-medium">
|
||||||
<Skeleton className="h-4" />
|
{i.lineNum}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
<TableCell>{i.runningNr}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Skeleton className="h-4" />
|
{format(
|
||||||
|
i?.upd_date.replace("Z", ""),
|
||||||
|
"M/d/yyyy hh:mm"
|
||||||
|
)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
<TableCell>{i.waitingFor}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Skeleton className="h-4" />
|
<Button
|
||||||
</TableCell>
|
variant="destructive"
|
||||||
<TableCell>
|
size="icon"
|
||||||
<Skeleton className="h-4" />
|
onClick={() => clearLabel(i)}
|
||||||
</TableCell>
|
>
|
||||||
<TableCell>
|
<Trash />
|
||||||
<Skeleton className="h-4" />
|
</Button>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
))}
|
))}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
) : (
|
)}
|
||||||
<TableBody>
|
</Table>
|
||||||
{info.map((i: any) => (
|
</div>
|
||||||
<TableRow key={i.runningNr}>
|
|
||||||
<TableCell className="font-medium">
|
|
||||||
{i.lineNum}
|
|
||||||
</TableCell>
|
|
||||||
<TableCell>{i.runningNr}</TableCell>
|
|
||||||
<TableCell>
|
|
||||||
{format(
|
|
||||||
i?.upd_date.replace("Z", ""),
|
|
||||||
"M/d/yyyy hh:mm"
|
|
||||||
)}
|
|
||||||
</TableCell>
|
|
||||||
<TableCell>{i.waitingFor}</TableCell>
|
|
||||||
<TableCell>
|
|
||||||
<Button
|
|
||||||
variant="destructive"
|
|
||||||
size="icon"
|
|
||||||
onClick={() => clearLabel(i)}
|
|
||||||
>
|
|
||||||
<Trash />
|
|
||||||
</Button>
|
|
||||||
</TableCell>
|
|
||||||
</TableRow>
|
|
||||||
))}
|
|
||||||
</TableBody>
|
|
||||||
)}
|
|
||||||
</Table>
|
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<hr />
|
<hr />
|
||||||
<p className="text-center mb-3">Manual Trigger</p>
|
<p className="text-center mb-3">Manual Trigger</p>
|
||||||
|
<ManuallyEnterRn />
|
||||||
|
<Separator className="m-1" />
|
||||||
<div className="flex flex-row justify-between">
|
<div className="flex flex-row justify-between">
|
||||||
<Button onClick={cameraTrigger}>Camera</Button>
|
<Button onClick={cameraTrigger}>Camera</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -16,6 +16,6 @@ export const fixTime = (date: any) => {
|
|||||||
|
|
||||||
return format(
|
return format(
|
||||||
addHours(rawDate, offsetHours).toISOString(),
|
addHours(rawDate, offsetHours).toISOString(),
|
||||||
"MM/dd/yyyy hh:mm"
|
"MM/dd/yyyy HH:mm"
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ColumnDef } from "@tanstack/react-table";
|
import { ColumnDef } from "@tanstack/react-table";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns-tz";
|
||||||
|
|
||||||
// This type is used to define the shape of our data.
|
// This type is used to define the shape of our data.
|
||||||
// You can use a Zod schema here if you want.
|
// You can use a Zod schema here if you want.
|
||||||
@@ -35,7 +35,7 @@ export const columns: ColumnDef<Adjustmnets>[] = [
|
|||||||
if (row.getValue("ProductionDate")) {
|
if (row.getValue("ProductionDate")) {
|
||||||
const correctDate = format(
|
const correctDate = format(
|
||||||
row.getValue("ProductionDate"),
|
row.getValue("ProductionDate"),
|
||||||
"M/d/yyyy hh:mm"
|
"M/d/yyyy HH:mm"
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<div className="text-left font-medium">{correctDate}</div>
|
<div className="text-left font-medium">{correctDate}</div>
|
||||||
|
|||||||
@@ -36,10 +36,7 @@ export const labelolumns: ColumnDef<Adjustmnets>[] = [
|
|||||||
if (row.getValue("upd_date")) {
|
if (row.getValue("upd_date")) {
|
||||||
const correctDate: any = row.getValue("upd_date");
|
const correctDate: any = row.getValue("upd_date");
|
||||||
const strippedDate = correctDate.replace("Z", ""); // Remove Z
|
const strippedDate = correctDate.replace("Z", ""); // Remove Z
|
||||||
const formattedDate = format(
|
const formattedDate = format(strippedDate, "MM/dd/yyyy HH:mm");
|
||||||
strippedDate,
|
|
||||||
"MM/dd/yyyy hh:mm a"
|
|
||||||
);
|
|
||||||
return (
|
return (
|
||||||
<div className="text-left font-medium">{formattedDate}</div>
|
<div className="text-left font-medium">{formattedDate}</div>
|
||||||
);
|
);
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "lstv2",
|
"name": "lstv2",
|
||||||
"version": "2.16.1",
|
"version": "2.17.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "lstv2",
|
"name": "lstv2",
|
||||||
"version": "2.16.1",
|
"version": "2.17.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dotenvx/dotenvx": "^1.39.0",
|
"@dotenvx/dotenvx": "^1.39.0",
|
||||||
"@hono/node-server": "^1.14.0",
|
"@hono/node-server": "^1.14.0",
|
||||||
|
|||||||
184
package.json
184
package.json
@@ -1,95 +1,95 @@
|
|||||||
{
|
{
|
||||||
"name": "lstv2",
|
"name": "lstv2",
|
||||||
"version": "2.16.1",
|
"version": "2.17.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "concurrently -n \"server,frontend\" -c \"#007755,#2f6da3\" \"npm run dev:server\" \"cd frontend && npm run dev\"",
|
"dev": "concurrently -n \"server,frontend\" -c \"#007755,#2f6da3\" \"npm run dev:server\" \"cd frontend && npm run dev\"",
|
||||||
"dev:server": "dotenvx run -f .env -- tsx watch server/index.ts",
|
"dev:server": "dotenvx run -f .env -- tsx watch server/index.ts",
|
||||||
"dev:frontend": "cd frontend && npm run dev",
|
"dev:frontend": "cd frontend && npm run dev",
|
||||||
"dev:dbgen": " drizzle-kit generate --config=drizzle-dev.config.ts",
|
"dev:dbgen": " drizzle-kit generate --config=drizzle-dev.config.ts",
|
||||||
"dev:dbmigrate": " drizzle-kit migrate --config=drizzle-dev.config.ts",
|
"dev:dbmigrate": " drizzle-kit migrate --config=drizzle-dev.config.ts",
|
||||||
"build": "npm run build:server && npm run build:frontend && npm run zipServer && npm run dev",
|
"build": "npm run build:server && npm run build:frontend && npm run zipServer && npm run dev",
|
||||||
"build:server": "rimraf dist && tsc --build && npm run copy:scripts && xcopy server\\services\\notifications\\utils\\views\\ dist\\server\\services\\notifications\\utils\\views\\ /E /I /Y",
|
"build:server": "rimraf dist && tsc --build && npm run copy:scripts && xcopy server\\services\\notifications\\utils\\views\\ dist\\server\\services\\notifications\\utils\\views\\ /E /I /Y",
|
||||||
"build:frontend": "cd frontend && npm run build",
|
"build:frontend": "cd frontend && npm run build",
|
||||||
"copy:scripts": "tsx server/scripts/copyScripts.ts",
|
"copy:scripts": "tsx server/scripts/copyScripts.ts",
|
||||||
"copy:servers": "xcopy server\\services\\server\\utils\\serverData.json dist\\server\\services\\server\\utils /E /I /Y",
|
"copy:servers": "xcopy server\\services\\server\\utils\\serverData.json dist\\server\\services\\server\\utils /E /I /Y",
|
||||||
"start": "set NODE_ENV=production && npm run start:server",
|
"start": "set NODE_ENV=production && npm run start:server",
|
||||||
"start:server": "dotenvx run -f .env -- node dist/server/index.js",
|
"start:server": "dotenvx run -f .env -- node dist/server/index.js",
|
||||||
"db:generate": "npx drizzle-kit generate",
|
"db:generate": "npx drizzle-kit generate",
|
||||||
"db:migrate": "npx drizzle-kit push",
|
"db:migrate": "npx drizzle-kit push",
|
||||||
"db:dev": "npm run build && npm run db:generate && npm run db:migrate",
|
"db:dev": "npm run build && npm run db:generate && npm run db:migrate",
|
||||||
"deploy": "standard-version --conventional-commits && npm run build",
|
"deploy": "standard-version --conventional-commits && npm run build",
|
||||||
"zipServer": "dotenvx run -f .env -- tsx server/scripts/zipUpBuild.ts \"C:\\Users\\matthes01\\Documents\\lstv2\"",
|
"zipServer": "dotenvx run -f .env -- tsx server/scripts/zipUpBuild.ts \"C:\\Users\\matthes01\\Documents\\lstv2\"",
|
||||||
"v1Build": "cd C:\\Users\\matthes01\\Documents\\logisticsSupportTool && npm run oldBuilder",
|
"v1Build": "cd C:\\Users\\matthes01\\Documents\\logisticsSupportTool && npm run oldBuilder",
|
||||||
"scriptBuild": "powershell -ExecutionPolicy Bypass -File server/scripts/build.ps1 -dir \"C:\\Users\\matthes01\\Documents\\lstv2\"",
|
"scriptBuild": "powershell -ExecutionPolicy Bypass -File server/scripts/build.ps1 -dir \"C:\\Users\\matthes01\\Documents\\lstv2\"",
|
||||||
"removeOld": "rimraf dist && rimraf frontend/dist",
|
"removeOld": "rimraf dist && rimraf frontend/dist",
|
||||||
"prodBuild": "npm run v1Build && npm run build && npm run zipServer && npm run dev",
|
"prodBuild": "npm run v1Build && npm run build && npm run zipServer && npm run dev",
|
||||||
"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/logistics/controller/warehouse/cycleCountChecks/cyclecountCheck.ts"
|
"testingCode": "dotenvx run -f .env -- tsx watch server/services/logistics/controller/warehouse/cycleCountChecks/cyclecountCheck.ts"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"commitizen": {
|
"commitizen": {
|
||||||
"path": "./node_modules/cz-conventional-changelog"
|
"path": "./node_modules/cz-conventional-changelog"
|
||||||
}
|
|
||||||
},
|
|
||||||
"admConfig": {
|
|
||||||
"build": 297,
|
|
||||||
"oldBuild": "backend-0.1.3.zip"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/adm-zip": "^0.5.7",
|
|
||||||
"@types/bcrypt": "^5.0.2",
|
|
||||||
"@types/fs-extra": "^11.0.4",
|
|
||||||
"@types/js-cookie": "^3.0.6",
|
|
||||||
"@types/mssql": "^9.1.7",
|
|
||||||
"@types/node": "^22.13.11",
|
|
||||||
"@types/node-cron": "^3.0.11",
|
|
||||||
"@types/nodemailer": "^6.4.17",
|
|
||||||
"@types/pg": "^8.11.11",
|
|
||||||
"@types/ws": "^8.18.0",
|
|
||||||
"concurrently": "^9.1.2",
|
|
||||||
"cz-conventional-changelog": "^3.3.0",
|
|
||||||
"standard-version": "^9.5.0",
|
|
||||||
"tsx": "^4.19.3",
|
|
||||||
"typescript": "^5.8.2"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@dotenvx/dotenvx": "^1.39.0",
|
|
||||||
"@hono/node-server": "^1.14.0",
|
|
||||||
"@hono/zod-openapi": "^0.19.2",
|
|
||||||
"@scalar/hono-api-reference": "^0.7.2",
|
|
||||||
"@tanstack/react-form": "^1.2.1",
|
|
||||||
"@tanstack/react-table": "^8.21.2",
|
|
||||||
"@types/jsonwebtoken": "^9.0.9",
|
|
||||||
"@types/nodemailer-express-handlebars": "^4.0.5",
|
|
||||||
"adm-zip": "^0.5.16",
|
|
||||||
"axios": "^1.8.4",
|
|
||||||
"bcryptjs": "^3.0.2",
|
|
||||||
"croner": "^9.0.0",
|
|
||||||
"date-fns": "^4.1.0",
|
|
||||||
"date-fns-tz": "^3.2.0",
|
|
||||||
"drizzle-kit": "^0.30.5",
|
|
||||||
"drizzle-orm": "^0.41.0",
|
|
||||||
"drizzle-zod": "^0.7.0",
|
|
||||||
"excel-date-to-js": "^1.1.5",
|
|
||||||
"fast-xml-parser": "^5.0.9",
|
|
||||||
"fs-extra": "^11.3.0",
|
|
||||||
"jsonwebtoken": "^9.0.2",
|
|
||||||
"mssql": "^11.0.1",
|
|
||||||
"nodemailer": "^6.10.0",
|
|
||||||
"nodemailer-express-handlebars": "^7.0.0",
|
|
||||||
"pg": "^8.14.1",
|
|
||||||
"pino": "^9.6.0",
|
|
||||||
"pino-abstract-transport": "^2.0.0",
|
|
||||||
"pino-pretty": "^13.0.0",
|
|
||||||
"postgres": "^3.4.5",
|
|
||||||
"react-resizable-panels": "^2.1.7",
|
|
||||||
"rimraf": "^6.0.1",
|
|
||||||
"st-ethernet-ip": "^2.7.3",
|
|
||||||
"ws": "^8.18.1",
|
|
||||||
"xlsx": "^0.18.5",
|
|
||||||
"zod": "^3.24.2"
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"admConfig": {
|
||||||
|
"build": 303,
|
||||||
|
"oldBuild": "backend-0.1.3.zip"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/adm-zip": "^0.5.7",
|
||||||
|
"@types/bcrypt": "^5.0.2",
|
||||||
|
"@types/fs-extra": "^11.0.4",
|
||||||
|
"@types/js-cookie": "^3.0.6",
|
||||||
|
"@types/mssql": "^9.1.7",
|
||||||
|
"@types/node": "^22.13.11",
|
||||||
|
"@types/node-cron": "^3.0.11",
|
||||||
|
"@types/nodemailer": "^6.4.17",
|
||||||
|
"@types/pg": "^8.11.11",
|
||||||
|
"@types/ws": "^8.18.0",
|
||||||
|
"concurrently": "^9.1.2",
|
||||||
|
"cz-conventional-changelog": "^3.3.0",
|
||||||
|
"standard-version": "^9.5.0",
|
||||||
|
"tsx": "^4.19.3",
|
||||||
|
"typescript": "^5.8.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@dotenvx/dotenvx": "^1.39.0",
|
||||||
|
"@hono/node-server": "^1.14.0",
|
||||||
|
"@hono/zod-openapi": "^0.19.2",
|
||||||
|
"@scalar/hono-api-reference": "^0.7.2",
|
||||||
|
"@tanstack/react-form": "^1.2.1",
|
||||||
|
"@tanstack/react-table": "^8.21.2",
|
||||||
|
"@types/jsonwebtoken": "^9.0.9",
|
||||||
|
"@types/nodemailer-express-handlebars": "^4.0.5",
|
||||||
|
"adm-zip": "^0.5.16",
|
||||||
|
"axios": "^1.8.4",
|
||||||
|
"bcryptjs": "^3.0.2",
|
||||||
|
"croner": "^9.0.0",
|
||||||
|
"date-fns": "^4.1.0",
|
||||||
|
"date-fns-tz": "^3.2.0",
|
||||||
|
"drizzle-kit": "^0.30.5",
|
||||||
|
"drizzle-orm": "^0.41.0",
|
||||||
|
"drizzle-zod": "^0.7.0",
|
||||||
|
"excel-date-to-js": "^1.1.5",
|
||||||
|
"fast-xml-parser": "^5.0.9",
|
||||||
|
"fs-extra": "^11.3.0",
|
||||||
|
"jsonwebtoken": "^9.0.2",
|
||||||
|
"mssql": "^11.0.1",
|
||||||
|
"nodemailer": "^6.10.0",
|
||||||
|
"nodemailer-express-handlebars": "^7.0.0",
|
||||||
|
"pg": "^8.14.1",
|
||||||
|
"pino": "^9.6.0",
|
||||||
|
"pino-abstract-transport": "^2.0.0",
|
||||||
|
"pino-pretty": "^13.0.0",
|
||||||
|
"postgres": "^3.4.5",
|
||||||
|
"react-resizable-panels": "^2.1.7",
|
||||||
|
"rimraf": "^6.0.1",
|
||||||
|
"st-ethernet-ip": "^2.7.3",
|
||||||
|
"ws": "^8.18.1",
|
||||||
|
"xlsx": "^0.18.5",
|
||||||
|
"zod": "^3.24.2"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,24 +1,38 @@
|
|||||||
import {eq} from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
import {db} from "../../database/dbclient.js";
|
import { db } from "../../database/dbclient.js";
|
||||||
import {settings} from "../../database/schema/settings.js";
|
import { settings } from "../../database/schema/settings.js";
|
||||||
import {query} from "../services/sqlServer/prodSqlServer.js";
|
import { query } from "../services/sqlServer/prodSqlServer.js";
|
||||||
import {plantInfo} from "../services/sqlServer/querys/dataMart/plantInfo.js";
|
import { plantInfo } from "../services/sqlServer/querys/dataMart/plantInfo.js";
|
||||||
import {createLog} from "../services/logger/logger.js";
|
import { createLog } from "../services/logger/logger.js";
|
||||||
|
|
||||||
export const createSSCC = async (runningNumber: number) => {
|
export const createSSCC = async (runningNumber: number) => {
|
||||||
// get the token
|
// get the token
|
||||||
const plantToken = await db.select().from(settings).where(eq(settings.name, "plantToken"));
|
const plantToken = await db
|
||||||
let global; // get from plant address in basis enter the entire string here.
|
.select()
|
||||||
|
.from(settings)
|
||||||
|
.where(eq(settings.name, "plantToken"));
|
||||||
|
let global: any = []; // get from plant address in basis enter the entire string here.
|
||||||
|
|
||||||
try {
|
try {
|
||||||
global = await query(plantInfo.replaceAll("[token]", plantToken[0].value), "plantInfo");
|
const res: any = await query(
|
||||||
|
plantInfo.replaceAll("[token]", plantToken[0].value),
|
||||||
|
"plantInfo"
|
||||||
|
);
|
||||||
|
global = res.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
createLog("error", "lst", "globalUtils", `There was an error getting the GLN: Error: ${error}`);
|
createLog(
|
||||||
|
"error",
|
||||||
|
"lst",
|
||||||
|
"globalUtils",
|
||||||
|
`There was an error getting the GLN: Error: ${error}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the sscc without the check diget and make sure we have it all correct
|
// create the sscc without the check diget and make sure we have it all correct
|
||||||
|
|
||||||
let step1SSCC = global[0].gln.toString().slice(0, 7).padStart(10, "0") + runningNumber.toString().padStart(9, "0");
|
let step1SSCC =
|
||||||
|
global[0].gln.toString().slice(0, 7).padStart(10, "0") +
|
||||||
|
runningNumber.toString().padStart(9, "0");
|
||||||
|
|
||||||
let sum = 0;
|
let sum = 0;
|
||||||
for (let i = 0; i < step1SSCC.length; i++) {
|
for (let i = 0; i < step1SSCC.length; i++) {
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import { activeArticle } from "../../sqlServer/querys/dataMart/article.js";
|
|||||||
export const getActiveAv = async () => {
|
export const getActiveAv = async () => {
|
||||||
let articles: any = [];
|
let articles: any = [];
|
||||||
try {
|
try {
|
||||||
articles = await query(activeArticle, "Get active articles");
|
const res = await query(activeArticle, "Get active articles");
|
||||||
|
articles = res?.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
articles = error;
|
articles = error;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,12 +12,15 @@ export const getCurrentCustomerInv = async (customer: any | null) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const inventory = await query(updatedQuery, "Get active inventory");
|
const inventory: any = await query(
|
||||||
|
updatedQuery,
|
||||||
|
"Get active inventory"
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: "All customer inventory minus holds",
|
message: "All customer inventory minus holds",
|
||||||
data: inventory,
|
data: inventory.data,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export const getDeliveryByDateRange = async (data: any | null) => {
|
|||||||
data: plantError,
|
data: plantError,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
let deliverys = [];
|
let deliverys: any = [];
|
||||||
|
|
||||||
let updatedQuery = deliveryByDateRange;
|
let updatedQuery = deliveryByDateRange;
|
||||||
|
|
||||||
@@ -40,7 +40,11 @@ export const getDeliveryByDateRange = async (data: any | null) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
deliverys = await query(updatedQuery, "Get Delivery by date range");
|
const res: any = await query(
|
||||||
|
updatedQuery,
|
||||||
|
"Get Delivery by date range"
|
||||||
|
);
|
||||||
|
deliverys - res.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export const getOpenOrders = async (data: any | null) => {
|
|||||||
data: plantError,
|
data: plantError,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
let orders = [];
|
let orders: any = [];
|
||||||
|
|
||||||
let updatedQuery = openOrders;
|
let updatedQuery = openOrders;
|
||||||
|
|
||||||
@@ -37,7 +37,11 @@ export const getOpenOrders = async (data: any | null) => {
|
|||||||
try {
|
try {
|
||||||
orders = await query(updatedQuery, "Get active openorders");
|
orders = await query(updatedQuery, "Get active openorders");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return { success: false, message: "Current open orders", data: orders };
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Current open orders",
|
||||||
|
data: orders.data,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// add plant token in
|
// add plant token in
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export const getINV = async (rn: boolean) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
inventory = await query(updatedQuery, "Gets Curruent inv");
|
inventory = await query(updatedQuery, "Gets Curruent inv");
|
||||||
return { success: true, message: "Current inv", data: inventory };
|
return { success: true, message: "Current inv", data: inventory.data };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ export const abbottOrders = async (data: any, user: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// articleInfo
|
// articleInfo
|
||||||
const { data: a, error: ae } = await tryCatch(
|
const { data: article, error: ae } = await tryCatch(
|
||||||
query(
|
query(
|
||||||
bulkOrderArticleInfo.replace("[articles]", articles),
|
bulkOrderArticleInfo.replace("[articles]", articles),
|
||||||
"Get Article data for bulk orders"
|
"Get Article data for bulk orders"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
const a: any = article?.data;
|
||||||
if (ae) {
|
if (ae) {
|
||||||
return {
|
return {
|
||||||
sucess: false,
|
sucess: false,
|
||||||
@@ -45,10 +45,12 @@ export const abbottOrders = async (data: any, user: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// order state
|
// order state
|
||||||
const { data: openOrders, error: oe } = await tryCatch(
|
const { data: o, error: oe } = await tryCatch(
|
||||||
query(orderState, "Gets the next 500 orders that have not been started")
|
query(orderState, "Gets the next 500 orders that have not been started")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const openOrders: any = o?.data;
|
||||||
|
|
||||||
if (oe) {
|
if (oe) {
|
||||||
return {
|
return {
|
||||||
sucess: false,
|
sucess: false,
|
||||||
|
|||||||
@@ -24,10 +24,12 @@ export const energizerOrders = async (data: any, user: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// order state
|
// order state
|
||||||
const { data: openOrders, error: oe } = await tryCatch(
|
const { data: o, error: oe } = await tryCatch(
|
||||||
query(orderState, "Gets the next 500 orders that have not been started")
|
query(orderState, "Gets the next 500 orders that have not been started")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const openOrders: any = o?.data;
|
||||||
|
|
||||||
if (oe) {
|
if (oe) {
|
||||||
return {
|
return {
|
||||||
sucess: false,
|
sucess: false,
|
||||||
@@ -37,9 +39,10 @@ export const energizerOrders = async (data: any, user: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// order state
|
// order state
|
||||||
const { data: i, error: ie } = await tryCatch(
|
const { data: invoice, error: ie } = await tryCatch(
|
||||||
query(invoiceAddress, "Gets invoices addresses")
|
query(invoiceAddress, "Gets invoices addresses")
|
||||||
);
|
);
|
||||||
|
const i: any = invoice?.data;
|
||||||
|
|
||||||
if (ie) {
|
if (ie) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -25,10 +25,12 @@ export const standardOrders = async (data: any, user: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// order state
|
// order state
|
||||||
const { data: openOrders, error: oe } = await tryCatch(
|
const { data: o, error: oe } = await tryCatch(
|
||||||
query(orderState, "Gets the next 500 orders that have not been started")
|
query(orderState, "Gets the next 500 orders that have not been started")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const openOrders: any = o?.data;
|
||||||
|
|
||||||
if (oe) {
|
if (oe) {
|
||||||
return {
|
return {
|
||||||
sucess: false,
|
sucess: false,
|
||||||
@@ -38,10 +40,10 @@ export const standardOrders = async (data: any, user: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// order state
|
// order state
|
||||||
const { data: i, error: ie } = await tryCatch(
|
const { data: invoice, error: ie } = await tryCatch(
|
||||||
query(invoiceAddress, "Gets invoices addresses")
|
query(invoiceAddress, "Gets invoices addresses")
|
||||||
);
|
);
|
||||||
|
const i: any = invoice?.data;
|
||||||
if (ie) {
|
if (ie) {
|
||||||
return {
|
return {
|
||||||
sucess: false,
|
sucess: false,
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ export const consumeMaterial = async (data: Data, prod: any) => {
|
|||||||
let barcode;
|
let barcode;
|
||||||
// get the barcode from the running number
|
// get the barcode from the running number
|
||||||
try {
|
try {
|
||||||
barcode = await query(rnReplace, "labelData");
|
const r: any = await query(rnReplace, "labelData");
|
||||||
|
barcode = r?.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
createLog(
|
createLog(
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ export const returnMaterial = async (data: Data, prod: any) => {
|
|||||||
let barcode;
|
let barcode;
|
||||||
// get the barcode from the running number
|
// get the barcode from the running number
|
||||||
try {
|
try {
|
||||||
barcode = await query(rnReplace, "labelData");
|
const r: any = await query(rnReplace, "labelData");
|
||||||
|
barcode = r?.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
createLog(
|
createLog(
|
||||||
@@ -31,10 +32,10 @@ export const returnMaterial = async (data: Data, prod: any) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data: laneData, error: laneError } = await tryCatch(
|
const { data: l, error: laneError } = await tryCatch(
|
||||||
query(laneQuery, "laneInfo")
|
query(laneQuery, "laneInfo")
|
||||||
);
|
);
|
||||||
|
const laneData: any = l?.data;
|
||||||
if (laneError) {
|
if (laneError) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export const createSiloAdjustment = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getting stock data first so we have it prior to the adjustment
|
// getting stock data first so we have it prior to the adjustment
|
||||||
const { data: stock, error: stockError } = await tryCatch(
|
const { data: s, error: stockError } = await tryCatch(
|
||||||
query(siloQuery, "Silo data Query")
|
query(siloQuery, "Silo data Query")
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ export const createSiloAdjustment = async (
|
|||||||
data: stockError,
|
data: stockError,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
const stock: any = s?.data as any;
|
||||||
const { data: a, error: errorAdj } = await tryCatch(
|
const { data: a, error: errorAdj } = await tryCatch(
|
||||||
postAdjustment(data, user.prod)
|
postAdjustment(data, user.prod)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export const getStockSiloData = async () => {
|
|||||||
message: "There was a n error getting the silo data.",
|
message: "There was a n error getting the silo data.",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
const stockData: any = data?.data;
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: "Current silo data from alplastock.",
|
message: "Current silo data from alplastock.",
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export const getLanesToCycleCount = async () => {
|
|||||||
createLog("info", "warehouse", "logistics", "Lane triggered update.");
|
createLog("info", "warehouse", "logistics", "Lane triggered update.");
|
||||||
lastCheck = currentTime;
|
lastCheck = currentTime;
|
||||||
const ageQuery = cycleCountCheck.replaceAll("[ageOfRow]", "90");
|
const ageQuery = cycleCountCheck.replaceAll("[ageOfRow]", "90");
|
||||||
const { data: prodLanes, error: pl } = await tryCatch(
|
const { data: p, error: pl } = await tryCatch(
|
||||||
query(ageQuery, "Get Stock lane date.")
|
query(ageQuery, "Get Stock lane date.")
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -31,6 +31,8 @@ export const getLanesToCycleCount = async () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const prodLanes: any = p?.data;
|
||||||
|
|
||||||
// run the update on the lanes
|
// run the update on the lanes
|
||||||
for (let i = 0; i < prodLanes.length; i++) {
|
for (let i = 0; i < prodLanes.length; i++) {
|
||||||
const createLane = {
|
const createLane = {
|
||||||
|
|||||||
@@ -81,11 +81,11 @@ export default async function reprintLabelMonitor(notifyData: any) {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
//console.log(query);
|
//console.log(query);
|
||||||
let downTime: any; //DownTime[];
|
let downTime: any = []; //DownTime[];
|
||||||
try {
|
try {
|
||||||
downTime = await query(dQuery, "downTimeCheck");
|
const res: any = await query(dQuery, "downTimeCheck");
|
||||||
//console.log(labels.length);
|
//console.log(labels.length);
|
||||||
|
downTime = res.data;
|
||||||
if (
|
if (
|
||||||
downTime.length > 0 &&
|
downTime.length > 0 &&
|
||||||
downTime[0]?.downTimeId > notifyData.notifiySettings.prodID
|
downTime[0]?.downTimeId > notifyData.notifiySettings.prodID
|
||||||
|
|||||||
@@ -76,7 +76,8 @@ export default async function reprintLabelMonitor(notifyData: any) {
|
|||||||
|
|
||||||
let prod: PPOO[];
|
let prod: PPOO[];
|
||||||
try {
|
try {
|
||||||
prod = await query(notifyQuery, "Label Reprints");
|
const res: any = await query(notifyQuery, "Label Reprints");
|
||||||
|
prod = res.data;
|
||||||
//console.log(labels.length);
|
//console.log(labels.length);
|
||||||
// const now = Date.now()
|
// const now = Date.now()
|
||||||
if (prod.length > 0) {
|
if (prod.length > 0) {
|
||||||
|
|||||||
@@ -44,10 +44,10 @@ export default async function qualityBlockingMonitor(notifyData: any) {
|
|||||||
blockingOrders
|
blockingOrders
|
||||||
);
|
);
|
||||||
|
|
||||||
const { data: blocking, error: blockingError } = await tryCatch(
|
const { data: b, error: blockingError } = await tryCatch(
|
||||||
query(blockingQuery, "Quality Blocking")
|
query(blockingQuery, "Quality Blocking")
|
||||||
);
|
);
|
||||||
|
const blocking: any = b?.data as any;
|
||||||
if (blockingError) {
|
if (blockingError) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
|
|||||||
@@ -64,10 +64,10 @@ const notification = async (notifyData: any) => {
|
|||||||
|
|
||||||
//let labels: Labels[];
|
//let labels: Labels[];
|
||||||
|
|
||||||
const { data: labels, error: labelError } = await tryCatch(
|
const { data: l, error: labelError } = await tryCatch(
|
||||||
query(reprintQuery, "Label Reprints")
|
query(reprintQuery, "Label Reprints")
|
||||||
);
|
);
|
||||||
|
const labels: any = l?.data as any;
|
||||||
if (labelError) {
|
if (labelError) {
|
||||||
createLog(
|
createLog(
|
||||||
"error",
|
"error",
|
||||||
|
|||||||
@@ -69,7 +69,8 @@ export default async function reprintLabelMonitor(notifyData: any) {
|
|||||||
|
|
||||||
let stage: PPOO[];
|
let stage: PPOO[];
|
||||||
try {
|
try {
|
||||||
stage = await query(noteQuery, "Staging checks");
|
const res = await query(noteQuery, "Staging checks");
|
||||||
|
stage = res?.data as any;
|
||||||
//console.log(labels.length);
|
//console.log(labels.length);
|
||||||
// const now = Date.now()
|
// const now = Date.now()
|
||||||
if (stage.length > 0) {
|
if (stage.length > 0) {
|
||||||
|
|||||||
@@ -77,9 +77,11 @@ export const tiImport = async () => {
|
|||||||
.replaceAll("[exclude]", releaseString);
|
.replaceAll("[exclude]", releaseString);
|
||||||
|
|
||||||
// get the headers pending
|
// get the headers pending
|
||||||
const { data: header, error: headerError } = await tryCatch(
|
const { data: h, error: headerError } = await tryCatch(
|
||||||
query(orders, "Ti get open headers")
|
query(orders, "Ti get open headers")
|
||||||
);
|
);
|
||||||
|
const header: any = h?.data as any;
|
||||||
|
|
||||||
if (headerError) {
|
if (headerError) {
|
||||||
createLog(
|
createLog(
|
||||||
"error",
|
"error",
|
||||||
@@ -127,9 +129,11 @@ export const tiImport = async () => {
|
|||||||
.replaceAll("[to]", notiSet[0].notifiySettings.end);
|
.replaceAll("[to]", notiSet[0].notifiySettings.end);
|
||||||
|
|
||||||
// get the headers pending
|
// get the headers pending
|
||||||
const { data: orderData, error: ordersError } = await tryCatch(
|
const { data: o, error: ordersError } = await tryCatch(
|
||||||
query(orderToSend, "Ti get open headers")
|
query(orderToSend, "Ti get open headers")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const orderData: any = o?.data as any;
|
||||||
if (ordersError)
|
if (ordersError)
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
|
|||||||
@@ -7,15 +7,21 @@ import { ocmeCycleCounts } from "../../../../database/schema/ocmeCycleCounts.js"
|
|||||||
import { db } from "../../../../database/dbclient.js";
|
import { db } from "../../../../database/dbclient.js";
|
||||||
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||||
import { createLog } from "../../logger/logger.js";
|
import { createLog } from "../../logger/logger.js";
|
||||||
|
import { prodEndpointCreation } from "../../../globalUtils/createUrl.js";
|
||||||
|
|
||||||
export const prepareLane =
|
export const prepareLane = await prodEndpointCreation(
|
||||||
"https://usday1prod.alpla.net/application/public/v1.1/Warehousing/PrepareLaneForInventory";
|
"/public/v1.1/Warehousing/PrepareLaneForInventory"
|
||||||
export const openLane =
|
);
|
||||||
"https://usday1prod.alpla.net/application/public/v1.0/Warehousing/InventoryOpen";
|
|
||||||
export const closeLane =
|
export const openLane = await prodEndpointCreation(
|
||||||
"https://usday1prod.alpla.net/application/public/v1.0/Warehousing/InventoryClose";
|
"/public/v1.0/Warehousing/InventoryOpen"
|
||||||
export const releaseLane =
|
);
|
||||||
"https://usday1prod.alpla.net/application/public/v1.1/Warehousing/ReleaseLaneFromInventory";
|
export const closeLane = await prodEndpointCreation(
|
||||||
|
"/public/v1.0/Warehousing/InventoryClose"
|
||||||
|
);
|
||||||
|
export const releaseLane = await prodEndpointCreation(
|
||||||
|
"/public/v1.1/Warehousing/ReleaseLaneFromInventory"
|
||||||
|
);
|
||||||
export const scannerID = 500;
|
export const scannerID = 500;
|
||||||
export const cycleCount = async (lane: any, user: User) => {
|
export const cycleCount = async (lane: any, user: User) => {
|
||||||
/**
|
/**
|
||||||
@@ -27,7 +33,7 @@ export const cycleCount = async (lane: any, user: User) => {
|
|||||||
const ocme = await ocmeInv(lane);
|
const ocme = await ocmeInv(lane);
|
||||||
|
|
||||||
// get alpla stock data
|
// get alpla stock data
|
||||||
const alplaStock = await alplaStockInv(ocme[0].alpla_laneID);
|
const alplaStock: any = await alplaStockInv(ocme[0].alpla_laneID);
|
||||||
|
|
||||||
// create a new array that has the merge happen.
|
// create a new array that has the merge happen.
|
||||||
const mergeOcmeData = ocme.map((d: any) => {
|
const mergeOcmeData = ocme.map((d: any) => {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {query} from "../../../sqlServer/prodSqlServer.js";
|
import { query } from "../../../sqlServer/prodSqlServer.js";
|
||||||
import {alplaStock} from "../../../sqlServer/querys/ocme/alplaStockInvByID.js";
|
import { alplaStock } from "../../../sqlServer/querys/ocme/alplaStockInvByID.js";
|
||||||
|
|
||||||
export const alplaStockInv = async (laneID: string) => {
|
export const alplaStockInv = async (laneID: string) => {
|
||||||
/**
|
/**
|
||||||
@@ -9,8 +9,8 @@ export const alplaStockInv = async (laneID: string) => {
|
|||||||
const stock = alplaStock.replaceAll("[laneID]", `${laneID}`);
|
const stock = alplaStock.replaceAll("[laneID]", `${laneID}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const stockData = await query(stock, "Stock Data");
|
const stockData: any = await query(stock, "Stock Data");
|
||||||
return stockData;
|
return stockData.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
return [];
|
return [];
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
// full lane count
|
// full lane count
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import {delay} from "../../../../globalUtils/delay.js";
|
import { delay } from "../../../../globalUtils/delay.js";
|
||||||
import {createLog} from "../../../logger/logger.js";
|
import { createLog } from "../../../logger/logger.js";
|
||||||
import {openLane, prepareLane, scannerID} from "../cycleCount.js";
|
import { openLane, prepareLane, scannerID } from "../cycleCount.js";
|
||||||
import type {User} from "../../../../types/users.js";
|
import type { User } from "../../../../types/users.js";
|
||||||
|
import { prodEndpointCreation } from "../../../../globalUtils/createUrl.js";
|
||||||
|
|
||||||
let delayTime = 100;
|
let delayTime = 100;
|
||||||
|
|
||||||
export const fullLaneCount = async (user: User, lane: string, ocmeLanes: any) => {
|
export const fullLaneCount = async (
|
||||||
|
user: User,
|
||||||
|
lane: string,
|
||||||
|
ocmeLanes: any
|
||||||
|
) => {
|
||||||
// prepare the lane.
|
// prepare the lane.
|
||||||
try {
|
try {
|
||||||
const openlane = await axios({
|
const openlane = await axios({
|
||||||
@@ -59,7 +64,9 @@ export const fullLaneCount = async (user: User, lane: string, ocmeLanes: any) =>
|
|||||||
try {
|
try {
|
||||||
const openLane = await axios({
|
const openLane = await axios({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "https://usday1prod.alpla.net/application/public/v1.0/Warehousing/InventoryCount",
|
url: await prodEndpointCreation(
|
||||||
|
"/public/v1.0/Warehousing/InventoryCount"
|
||||||
|
),
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Basic ${user.prod}`,
|
Authorization: `Basic ${user.prod}`,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -84,7 +91,9 @@ export const fullLaneCount = async (user: User, lane: string, ocmeLanes: any) =>
|
|||||||
try {
|
try {
|
||||||
const openLane = await axios({
|
const openLane = await axios({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "https://usday1prod.alpla.net/application/public/v1.0/Warehousing/InventoryClose",
|
url: await prodEndpointCreation(
|
||||||
|
"/public/v1.0/Warehousing/InventoryClose"
|
||||||
|
),
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Basic ${user.prod}`,
|
Authorization: `Basic ${user.prod}`,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -103,7 +112,9 @@ export const fullLaneCount = async (user: User, lane: string, ocmeLanes: any) =>
|
|||||||
try {
|
try {
|
||||||
const openLane = await axios({
|
const openLane = await axios({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "https://usday1prod.alpla.net/application/public/v1.1/Warehousing/ReleaseLaneFromInventory",
|
url: await prodEndpointCreation(
|
||||||
|
"/public/v1.1/Warehousing/ReleaseLaneFromInventory"
|
||||||
|
),
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Basic ${user.prod}`,
|
Authorization: `Basic ${user.prod}`,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -113,7 +124,12 @@ export const fullLaneCount = async (user: User, lane: string, ocmeLanes: any) =>
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
createLog("info", user.username!, "ocme-count", openLane.data.message);
|
createLog(
|
||||||
|
"info",
|
||||||
|
user.username!,
|
||||||
|
"ocme-count",
|
||||||
|
openLane.data.message
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
createLog("error", user.username!, "ocme-count", `${error}`);
|
createLog("error", user.username!, "ocme-count", `${error}`);
|
||||||
}
|
}
|
||||||
@@ -122,5 +138,5 @@ export const fullLaneCount = async (user: User, lane: string, ocmeLanes: any) =>
|
|||||||
createLog("error", user.username!, "ocme-count", `${error}`);
|
createLog("error", user.username!, "ocme-count", `${error}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {success: true, message: `Lane completed`};
|
return { success: true, message: `Lane completed` };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import {createLog} from "../../logger/logger.js";
|
import { createLog } from "../../logger/logger.js";
|
||||||
import {shipmentPallets} from "../../sqlServer/querys/ocme/shipmentPallets.js";
|
import { shipmentPallets } from "../../sqlServer/querys/ocme/shipmentPallets.js";
|
||||||
import {getShipmentData} from "./getShipmentData.js";
|
import { getShipmentData } from "./getShipmentData.js";
|
||||||
import {query} from "../../sqlServer/prodSqlServer.js";
|
import { query } from "../../sqlServer/prodSqlServer.js";
|
||||||
import {db} from "../../../../database/dbclient.js";
|
import { db } from "../../../../database/dbclient.js";
|
||||||
import {settings} from "../../../../database/schema/settings.js";
|
import { settings } from "../../../../database/schema/settings.js";
|
||||||
import {lotRestriction} from "./lotrestriction.js";
|
import { lotRestriction } from "./lotrestriction.js";
|
||||||
|
|
||||||
export const getShipmentPallets = async (shipmentID: any) => {
|
export const getShipmentPallets = async (shipmentID: any) => {
|
||||||
let ocmeLanes: any = [];
|
let ocmeLanes: any = [];
|
||||||
@@ -23,43 +23,65 @@ export const getShipmentPallets = async (shipmentID: any) => {
|
|||||||
const shipments = await getShipmentData();
|
const shipments = await getShipmentData();
|
||||||
|
|
||||||
// filter the shipment so we can get the correct data from it.
|
// filter the shipment so we can get the correct data from it.
|
||||||
const filteredShipment = shipments.data.filter((order: any) => order.LoadingOrderId === parseInt(shipmentID));
|
const filteredShipment = shipments.data.filter(
|
||||||
|
(order: any) => order.LoadingOrderId === parseInt(shipmentID)
|
||||||
|
);
|
||||||
|
|
||||||
// getting the criteria we want to look at.
|
// getting the criteria we want to look at.
|
||||||
let tmpCheck: any = [];
|
let tmpCheck: any = [];
|
||||||
if (filteredShipment.length === 0) {
|
if (filteredShipment.length === 0) {
|
||||||
createLog("error", "ocme", "ocme", "Invalid shipment id was provided and cant do anything else.");
|
createLog(
|
||||||
|
"error",
|
||||||
|
"ocme",
|
||||||
|
"ocme",
|
||||||
|
"Invalid shipment id was provided and cant do anything else."
|
||||||
|
);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "Invalid shipmentID sent over please try again",
|
message: "Invalid shipmentID sent over please try again",
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
tmpCheck = filteredShipment[0].Remark.split(",")
|
tmpCheck = filteredShipment[0].Remark.split(",")
|
||||||
.map((item: any) => item.trim()) // removes accedental spaces if there are any
|
.map((item: any) => item.trim()) // removes accedental spaces if there are any
|
||||||
.map((i: any) => i.toLowerCase());
|
.map((i: any) => i.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
// removing the agv out of the array
|
// removing the agv out of the array
|
||||||
let checks = tmpCheck.filter((i: any) => i !== "agv");
|
let checks = tmpCheck.filter((i: any) => i !== "agv");
|
||||||
|
|
||||||
let shipmentQ = shipmentPallets
|
let shipmentQ = shipmentPallets
|
||||||
.replaceAll("[article]", filteredShipment[0].LoadingPlan[0].ArticleVariantId)
|
.replaceAll(
|
||||||
.replaceAll("[fifo]", setting.filter((n) => n.name === "fifoCheck")[0].value);
|
"[article]",
|
||||||
|
filteredShipment[0].LoadingPlan[0].ArticleVariantId
|
||||||
|
)
|
||||||
|
.replaceAll(
|
||||||
|
"[fifo]",
|
||||||
|
setting.filter((n) => n.name === "fifoCheck")[0].value
|
||||||
|
);
|
||||||
|
|
||||||
const addressCheck = setting.filter((n) => n.name === "monitorAddress");
|
const addressCheck = setting.filter((n) => n.name === "monitorAddress");
|
||||||
|
|
||||||
if (parseInt(addressCheck[0].value) === filteredShipment[0].LoadingPlan[0].AddressId) {
|
if (
|
||||||
|
parseInt(addressCheck[0].value) ===
|
||||||
|
filteredShipment[0].LoadingPlan[0].AddressId
|
||||||
|
) {
|
||||||
// if there really ends up being more than 5000 pallets then well we need to fix this later, also an insane issue to have this many that would need to be monitored
|
// if there really ends up being more than 5000 pallets then well we need to fix this later, also an insane issue to have this many that would need to be monitored
|
||||||
shipmentQ = shipmentQ.replaceAll("[totalPallets]", "5000");
|
shipmentQ = shipmentQ.replaceAll("[totalPallets]", "5000");
|
||||||
} else {
|
} else {
|
||||||
shipmentQ = shipmentQ.replaceAll("[totalPallets]", filteredShipment[0].LoadingPlan[0].PackagingQuantity);
|
shipmentQ = shipmentQ.replaceAll(
|
||||||
|
"[totalPallets]",
|
||||||
|
filteredShipment[0].LoadingPlan[0].PackagingQuantity
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// temp situation only getting the lanes we want to look in
|
// temp situation only getting the lanes we want to look in
|
||||||
// Convert laneArray to a comma-separated string with each value quoted
|
// Convert laneArray to a comma-separated string with each value quoted
|
||||||
let noBlock;
|
let noBlock;
|
||||||
if (checks.includes("all")) {
|
if (checks.includes("all")) {
|
||||||
noBlock = shipmentQ.replaceAll("and GesperrtAktivSum in (0) ", "--and GesperrtAktivSum in (0) ");
|
noBlock = shipmentQ.replaceAll(
|
||||||
|
"and GesperrtAktivSum in (0) ",
|
||||||
|
"--and GesperrtAktivSum in (0) "
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
noBlock = shipmentQ;
|
noBlock = shipmentQ;
|
||||||
}
|
}
|
||||||
@@ -78,13 +100,19 @@ export const getShipmentPallets = async (shipmentID: any) => {
|
|||||||
|
|
||||||
let shipmentLane = shipmentQ.replaceAll("[lanes]", laneString);
|
let shipmentLane = shipmentQ.replaceAll("[lanes]", laneString);
|
||||||
|
|
||||||
let shipmentPals = [];
|
let shipmentPals: any = [];
|
||||||
//console.log(shipmentLane);
|
//console.log(shipmentLane);
|
||||||
try {
|
try {
|
||||||
shipmentPals = await query(shipmentLane, "Get shipmentPals");
|
const res: any = await query(shipmentLane, "Get shipmentPals");
|
||||||
|
shipmentPals = res.data;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
createLog("error", "ocme", "ocme", `Error from running the shippment pallets query: ${err}`);
|
createLog(
|
||||||
return {success: false, message: err, data: []};
|
"error",
|
||||||
|
"ocme",
|
||||||
|
"ocme",
|
||||||
|
`Error from running the shippment pallets query: ${err}`
|
||||||
|
);
|
||||||
|
return { success: false, message: err, data: [] };
|
||||||
}
|
}
|
||||||
|
|
||||||
let filteredPallets = shipmentPals;
|
let filteredPallets = shipmentPals;
|
||||||
@@ -94,7 +122,10 @@ export const getShipmentPallets = async (shipmentID: any) => {
|
|||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: `There are a total of ${filteredPallets.length} pallet(s) that are in this shipment.`,
|
message: `There are a total of ${filteredPallets.length} pallet(s) that are in this shipment.`,
|
||||||
data: filteredPallets.splice(0, filteredShipment[0].LoadingPlan[0].PackagingQuantity),
|
data: filteredPallets.splice(
|
||||||
|
0,
|
||||||
|
filteredShipment[0].LoadingPlan[0].PackagingQuantity
|
||||||
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,21 +143,35 @@ export const getShipmentPallets = async (shipmentID: any) => {
|
|||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: `There are a total of ${filteredPallets.length} pallet(s) that are in this shipment.`,
|
message: `There are a total of ${filteredPallets.length} pallet(s) that are in this shipment.`,
|
||||||
data: filteredPallets.splice(0, filteredShipment[0].LoadingPlan[0].PackagingQuantity),
|
data: filteredPallets.splice(
|
||||||
|
0,
|
||||||
|
filteredShipment[0].LoadingPlan[0].PackagingQuantity
|
||||||
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// for "what ever case" follow the logic. to check addresses and resitrions
|
// for "what ever case" follow the logic. to check addresses and resitrions
|
||||||
if (parseInt(addressCheck[0].value) === filteredShipment[0].LoadingPlan[0].AddressId) {
|
if (
|
||||||
|
parseInt(addressCheck[0].value) ===
|
||||||
|
filteredShipment[0].LoadingPlan[0].AddressId
|
||||||
|
) {
|
||||||
createLog(
|
createLog(
|
||||||
"info",
|
"info",
|
||||||
"ocme",
|
"ocme",
|
||||||
"ocme",
|
"ocme",
|
||||||
"This shipment has restrictions on it and will go throught the lots filtering process"
|
"This shipment has restrictions on it and will go throught the lots filtering process"
|
||||||
);
|
);
|
||||||
filteredPallets = await lotRestriction(shipmentPals, filteredShipment[0].LoadingPlan[0].PackagingQuantity);
|
filteredPallets = await lotRestriction(
|
||||||
|
shipmentPals,
|
||||||
|
filteredShipment[0].LoadingPlan[0].PackagingQuantity
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
createLog("info", "ocme", "ocme", "This shipment is cleared to send what ever.");
|
createLog(
|
||||||
|
"info",
|
||||||
|
"ocme",
|
||||||
|
"ocme",
|
||||||
|
"This shipment is cleared to send what ever."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -25,10 +25,11 @@ export const postLabelData = async (data: any) => {
|
|||||||
data: [],
|
data: [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
let label;
|
let label: any = [];
|
||||||
const filterQuery = labelData.replaceAll("[rn]", newData.runningNr);
|
const filterQuery = labelData.replaceAll("[rn]", newData.runningNr);
|
||||||
try {
|
try {
|
||||||
label = await query(filterQuery, "Label data");
|
const res: any = await query(filterQuery, "Label data");
|
||||||
|
label = res.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
createLog(
|
createLog(
|
||||||
"error",
|
"error",
|
||||||
|
|||||||
@@ -38,9 +38,28 @@ export const triggerScanner = async () => {
|
|||||||
createLog("info", "wrapperScanner", "ocme", `Triggered`);
|
createLog("info", "wrapperScanner", "ocme", `Triggered`);
|
||||||
camera.write("TRIGGER", "utf8");
|
camera.write("TRIGGER", "utf8");
|
||||||
camera.end();
|
camera.end();
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!camera.destroyed) {
|
||||||
|
camera.destroy();
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
resolve({ success: true, message: "Camera was triggered." });
|
resolve({ success: true, message: "Camera was triggered." });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
camera.on("end", () => {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!camera.destroyed) {
|
||||||
|
createLog(
|
||||||
|
"info",
|
||||||
|
"ocme",
|
||||||
|
"ocme",
|
||||||
|
`Ocme Camera was destroyed, on trigger status`
|
||||||
|
);
|
||||||
|
camera.destroy();
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
|
||||||
camera.on("error", (error) => {
|
camera.on("error", (error) => {
|
||||||
createLog("error", "wrapperScanner", "ocme", `${error}`);
|
createLog("error", "wrapperScanner", "ocme", `${error}`);
|
||||||
resolve({
|
resolve({
|
||||||
@@ -50,7 +69,5 @@ export const triggerScanner = async () => {
|
|||||||
)}`,
|
)}`,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
resolve({ success: true, message: "Camera was triggered." });
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,12 +2,20 @@ import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
|||||||
import { query } from "../../../sqlServer/prodSqlServer.js";
|
import { query } from "../../../sqlServer/prodSqlServer.js";
|
||||||
import { lotQuery } from "../../../sqlServer/querys/ocp/lots.js";
|
import { lotQuery } from "../../../sqlServer/querys/ocp/lots.js";
|
||||||
|
|
||||||
|
type LotInfo = {
|
||||||
|
success: boolean;
|
||||||
|
message: string;
|
||||||
|
data: any[];
|
||||||
|
};
|
||||||
export const getLots = async () => {
|
export const getLots = async () => {
|
||||||
const { data: lotInfo, error: lotError } = await tryCatch(
|
const { data: l, error: lotError } = await tryCatch(
|
||||||
query(lotQuery, "Alplalabel online lots")
|
query(lotQuery, "Alplalabel online lots")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const lotInfo = l as LotInfo;
|
||||||
|
|
||||||
if (lotError) {
|
if (lotError) {
|
||||||
|
console.log("lot error", lotError);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "There was an error getting the lots",
|
message: "There was an error getting the lots",
|
||||||
@@ -15,9 +23,17 @@ export const getLots = async () => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
if (lotInfo.success) {
|
||||||
success: true,
|
return {
|
||||||
message: "Current active lots that are technically released.",
|
success: true,
|
||||||
data: lotInfo,
|
message: "Current active lots that are technically released.",
|
||||||
};
|
data: lotInfo,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: `Error getting lot info due to: ${lotInfo.message}.`,
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ export const prolinkCheck = async (lot: any) => {
|
|||||||
|
|
||||||
// run the query
|
// run the query
|
||||||
try {
|
try {
|
||||||
const prolink = await query(prolinkQuery, "Prolink Checks");
|
const p: any = await query(prolinkQuery, "Prolink Checks");
|
||||||
|
const prolink = p.data;
|
||||||
// filter out the lot
|
// filter out the lot
|
||||||
const filterdLot = prolink.filter(
|
const filterdLot = prolink.filter(
|
||||||
(p: any) => p.AlplaLabelOnline === lot
|
(p: any) => p.AlplaLabelOnline === lot
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ export const isMainMatStaged = async (lot: any) => {
|
|||||||
const updateQuery = mmQuery.replaceAll("[lotNumber]", lot.lot);
|
const updateQuery = mmQuery.replaceAll("[lotNumber]", lot.lot);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await query(updateQuery, "Main Material Check");
|
const r: any = await query(updateQuery, "Main Material Check");
|
||||||
|
|
||||||
|
const res: any = r.data;
|
||||||
|
|
||||||
createLog(
|
createLog(
|
||||||
"info",
|
"info",
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ export const printStatus = [
|
|||||||
code: 8,
|
code: 8,
|
||||||
text: "First time printing",
|
text: "First time printing",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
code: 9,
|
||||||
|
text: "Offline",
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export const printerUpdate = async (printer: any, status: any) => {
|
export const printerUpdate = async (printer: any, status: any) => {
|
||||||
|
|||||||
@@ -163,28 +163,55 @@ export const printerStatus = async (p: any) => {
|
|||||||
resolve({ success: true, message: "Print cycle completed." });
|
resolve({ success: true, message: "Print cycle completed." });
|
||||||
});
|
});
|
||||||
|
|
||||||
printer.on("error", async (error) => {
|
// as a safety destory it if its still there
|
||||||
// just going to say theres an error with the printer
|
printer.on("end", () => {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!printer.destroyed) {
|
||||||
|
createLog(
|
||||||
|
"info",
|
||||||
|
"printerState",
|
||||||
|
"ocp",
|
||||||
|
`${p.name}: was force closed, during normal cycle counting`
|
||||||
|
);
|
||||||
|
printer.destroy();
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
|
||||||
if (!errorCheck) {
|
printer.on("error", async (error: any) => {
|
||||||
|
// just going to say theres an error with the printer
|
||||||
|
//console.log(error.code);
|
||||||
|
if (error.code.includes("ETIMEDOUT") && !errorCheck) {
|
||||||
|
createLog("error", "ocp", "ocp", `${p.name} is offline`);
|
||||||
|
|
||||||
|
await printerUpdate(p, 9);
|
||||||
|
errorCheck = true;
|
||||||
|
printer.end();
|
||||||
|
|
||||||
|
resolve({
|
||||||
|
success: false,
|
||||||
|
message: "The printer is offline.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!error.code.includes("ETIMEDOUT") && !errorCheck) {
|
||||||
createLog(
|
createLog(
|
||||||
"error",
|
"error",
|
||||||
"ocp",
|
"ocp",
|
||||||
"ocp",
|
"ocp",
|
||||||
`${p.name} encountered an error: ${error}`
|
`${p.name} encountered an error: ${error}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await printerUpdate(p, 7);
|
||||||
|
errorCheck = true;
|
||||||
|
|
||||||
|
// send log data
|
||||||
|
// fake line
|
||||||
|
printer.end();
|
||||||
|
resolve({
|
||||||
|
success: false,
|
||||||
|
message: "There was an error with the printer.",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await printerUpdate(p, 7);
|
|
||||||
errorCheck = true;
|
|
||||||
|
|
||||||
// send log data
|
|
||||||
// fake line
|
|
||||||
printer.end();
|
|
||||||
resolve({
|
|
||||||
success: false,
|
|
||||||
message: "There was an error with the printer.",
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -230,13 +257,13 @@ export const autoLabelingStats = async (p: any) => {
|
|||||||
|
|
||||||
printer.on("error", async (error) => {
|
printer.on("error", async (error) => {
|
||||||
// just going to say theres an error with the printer
|
// just going to say theres an error with the printer
|
||||||
|
console.log(error);
|
||||||
if (!errorCheck) {
|
if (!errorCheck) {
|
||||||
createLog(
|
createLog(
|
||||||
"error",
|
"error",
|
||||||
"ocp",
|
"ocp",
|
||||||
"ocp",
|
"ocp",
|
||||||
`${p.name} encountered an error: ${error}`
|
`${p.name}, encountered an error: ${error}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ export const dualPrintingProcess = async (lotInfo: any) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// get what was last printed
|
// get what was last printed
|
||||||
const result = await query(printedQuery, "Last Printed Query");
|
const result: any = await query(printedQuery, "Last Printed Query");
|
||||||
lastPrinted = result[0].IdMaschine;
|
lastPrinted = result.data[0].IdMaschine;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
createLog(
|
createLog(
|
||||||
"error",
|
"error",
|
||||||
@@ -51,8 +51,8 @@ export const dualPrintingProcess = async (lotInfo: any) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// get if if running or down
|
// get if if running or down
|
||||||
const first = await query(fisrtLineDT, "First line DT Check");
|
const first: any = await query(fisrtLineDT, "First line DT Check");
|
||||||
firstLine = first[0].LineCheck;
|
firstLine = first.data[0].LineCheck;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
createLog(
|
createLog(
|
||||||
"error",
|
"error",
|
||||||
@@ -63,8 +63,8 @@ export const dualPrintingProcess = async (lotInfo: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const second = await query(secondLineDT, "Second line DT Check");
|
const second: any = await query(secondLineDT, "Second line DT Check");
|
||||||
secondLine = second[0].LineCheck;
|
secondLine = second.data[0].LineCheck;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
createLog(
|
createLog(
|
||||||
"error",
|
"error",
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import { createLog } from "../../logger/logger.js";
|
|||||||
|
|
||||||
export const assignedPrinters = async () => {
|
export const assignedPrinters = async () => {
|
||||||
createLog("debug", "ocp", "ocp", "Lot assignment check");
|
createLog("debug", "ocp", "ocp", "Lot assignment check");
|
||||||
const { data: l, error: lotError } = await tryCatch(getLots());
|
const { data: lot, error: lotError } = await tryCatch(getLots());
|
||||||
|
const l: any = lot;
|
||||||
if (lotError) {
|
if (lotError) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
@@ -43,7 +43,7 @@ export const assignedPrinters = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const printers: any = print.data ?? [];
|
const printers: any = print.data ?? [];
|
||||||
const lots: any = l?.data.length === 0 ? null : l?.data;
|
const lots: any = l?.data.length === 0 ? [] : l?.data;
|
||||||
|
|
||||||
//console.log(lots);
|
//console.log(lots);
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ export const getMac = async (machine: string) => {
|
|||||||
let mac = [];
|
let mac = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mac = await query(updateQuery, "Machine id check");
|
const getMac: any = await query(updateQuery, "Machine id check");
|
||||||
|
|
||||||
|
mac = getMac.data;
|
||||||
// console.log("Machine data", mac); // removed due to swr being activated
|
// console.log("Machine data", mac); // removed due to swr being activated
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
createLog(
|
createLog(
|
||||||
|
|||||||
@@ -42,6 +42,20 @@ export const pausePrinter = async (printerData: any) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
pause.on("end", () => {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!pause.destroyed) {
|
||||||
|
createLog(
|
||||||
|
"info",
|
||||||
|
"printerState",
|
||||||
|
"ocp",
|
||||||
|
`${printerData.name}: was force closed, in pausing trigger`
|
||||||
|
);
|
||||||
|
pause.destroy();
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
|
||||||
resolve({
|
resolve({
|
||||||
success: true,
|
success: true,
|
||||||
message: `${
|
message: `${
|
||||||
|
|||||||
@@ -45,6 +45,20 @@ export const unPausePrinter = async (printerData: any) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
pause.on("end", () => {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!pause.destroyed) {
|
||||||
|
createLog(
|
||||||
|
"info",
|
||||||
|
"printerState",
|
||||||
|
"ocp",
|
||||||
|
`${printerData.name}: was force closed, in unpause menu`
|
||||||
|
);
|
||||||
|
pause.destroy();
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
|
||||||
resolve({
|
resolve({
|
||||||
success: true,
|
success: true,
|
||||||
message: `${
|
message: `${
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ export const addNewPallet = async (data: any, user: string) => {
|
|||||||
if (palletData.length > 0) {
|
if (palletData.length > 0) {
|
||||||
try {
|
try {
|
||||||
// get the pallet info from stock
|
// get the pallet info from stock
|
||||||
const { data: p, error: pe } = await tryCatch(
|
const { data: pa, error: pe } = await tryCatch(
|
||||||
query(updateQuery, "quality request")
|
query(updateQuery, "quality request")
|
||||||
);
|
);
|
||||||
|
const p: any = pa;
|
||||||
if (pe) {
|
if (pe) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
@@ -108,10 +108,10 @@ export const addNewPallet = async (data: any, user: string) => {
|
|||||||
|
|
||||||
// add new pallet
|
// add new pallet
|
||||||
try {
|
try {
|
||||||
const { data: p, error: pe } = await tryCatch(
|
const { data: px, error: pe } = await tryCatch(
|
||||||
query(updateQuery, "quality request")
|
query(updateQuery, "quality request")
|
||||||
);
|
);
|
||||||
|
const p: any = px;
|
||||||
if (p.length === 0) {
|
if (p.length === 0) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
|
|||||||
@@ -53,9 +53,13 @@ export const qualityCycle = async () => {
|
|||||||
"[runningNumber]",
|
"[runningNumber]",
|
||||||
lstQData[i].runningNr
|
lstQData[i].runningNr
|
||||||
);
|
);
|
||||||
let prodData: any = [];
|
|
||||||
|
|
||||||
prodData = await query(qPalletNumber, "Quality update check");
|
const queryData: any = await query(
|
||||||
|
qPalletNumber,
|
||||||
|
"Quality update check"
|
||||||
|
);
|
||||||
|
let prodData: any =
|
||||||
|
queryData?.data.length === 0 ? [] : queryData.data;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
lstQData[i]?.locationAtRequest != prodData[0]?.locationAtRequest
|
lstQData[i]?.locationAtRequest != prodData[0]?.locationAtRequest
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ export async function query(queryToRun: string, name: string) {
|
|||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: `The sql ${dbServer[0].value} is not not connected`,
|
message: `The sql ${dbServer[0].value} is not not connected`,
|
||||||
|
data: [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -178,7 +179,11 @@ export async function query(queryToRun: string, name: string) {
|
|||||||
try {
|
try {
|
||||||
const result = await pool.request().query(query);
|
const result = await pool.request().query(query);
|
||||||
|
|
||||||
return result.recordset;
|
return {
|
||||||
|
success: true,
|
||||||
|
message: `Query results for: ${name}`,
|
||||||
|
data: result.recordset,
|
||||||
|
};
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
if (error.code === "ETIMEOUT") {
|
if (error.code === "ETIMEOUT") {
|
||||||
createLog(
|
createLog(
|
||||||
@@ -189,13 +194,23 @@ export async function query(queryToRun: string, name: string) {
|
|||||||
error
|
error
|
||||||
)}, ${name} did not run due to a timeout.`
|
)}, ${name} did not run due to a timeout.`
|
||||||
);
|
);
|
||||||
throw new Error(`${name} query did not run due to a timeout.`);
|
//throw new Error(`${name} query did not run due to a timeout.`);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: `${name} query did not run due to a timeout.`,
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error.code === "EREQUEST") {
|
if (error.code === "EREQUEST") {
|
||||||
throw new Error(
|
// throw new Error(
|
||||||
`${name} encoutnered an error ${error.originalError.info.message}`
|
// `${name} encoutnered an error ${error.originalError.info.message}`
|
||||||
);
|
// );
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: `${name} encoutnered an error ${error.originalError.info.message}`,
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//console.log(error.originalError.info.message);
|
//console.log(error.originalError.info.message);
|
||||||
|
|||||||
@@ -74,11 +74,23 @@ export const startTCPServer = () => {
|
|||||||
|
|
||||||
socket.on("end", () => {
|
socket.on("end", () => {
|
||||||
createLog("debug", "tcp", "tcp", "Client disconnected");
|
createLog("debug", "tcp", "tcp", "Client disconnected");
|
||||||
|
// just in case we dont fully disconnect
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!socket.destroyed) {
|
||||||
|
socket.destroy();
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
tcpSockets.delete(socket);
|
tcpSockets.delete(socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("error", (err: Error) => {
|
socket.on("error", (err: Error) => {
|
||||||
createLog("info", "tcp", "tcp", `Socket error:", ${err}`);
|
createLog("info", "tcp", "tcp", `Socket error:", ${err}`);
|
||||||
|
// just in case we dont fully disconnect
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!socket.destroyed) {
|
||||||
|
socket.destroy();
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
tcpSockets.delete(socket);
|
tcpSockets.delete(socket);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user