Compare commits
54 Commits
dev
...
3b5e82fdc1
| Author | SHA1 | Date | |
|---|---|---|---|
| 3b5e82fdc1 | |||
| f9cd3fb881 | |||
| 51267f5202 | |||
| ceaa25f31e | |||
| 416254353c | |||
| 7f946c095b | |||
| c2aa69ab0a | |||
| 250988800e | |||
| cacfd6d2e0 | |||
| 8d2721b0c2 | |||
| 36cdc7b4bf | |||
| 4d4d6fc7a4 | |||
| 030f9f9aac | |||
| 9e9a56cbb1 | |||
| b01980e1c5 | |||
| fe0c500dcf | |||
| 8a040d15db | |||
| f90066c090 | |||
| 04eb2e3e14 | |||
| 90fb0d364d | |||
| e6e1cecce3 | |||
| 73aa95a693 | |||
| b9f19095cb | |||
| dcb56d4274 | |||
| bc1821132e | |||
| 2551d6c907 | |||
| adf0880659 | |||
| 5149de3199 | |||
| c71b514d9a | |||
| 9254e52808 | |||
| b8c028a6c1 | |||
| 529e922485 | |||
| 5201012235 | |||
| abe53b8f5d | |||
| 836f3e294b | |||
| 96abef762b | |||
| 2c227f9428 | |||
| 46647687dc | |||
| cb01ef1af1 | |||
| b3b5fcec65 | |||
| 3a4dc47a36 | |||
| 63177b523e | |||
| e1cad027d2 | |||
| c1cc355f4f | |||
| 5ed67f3fc0 | |||
| 57e82d2360 | |||
| 9395ec6cd4 | |||
| 0475bb30f9 | |||
| 6843368c36 | |||
| 335ea2deca | |||
| 96814c1115 | |||
| 6dd9ed848b | |||
| 0c5fc1dfb0 | |||
| 5886bea85d |
50
.vscode/settings.json
vendored
50
.vscode/settings.json
vendored
@@ -1,26 +1,28 @@
|
|||||||
{
|
{
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
|
"workbench.colorTheme": "Default Dark+",
|
||||||
"editor.formatOnSave": true,
|
"prettier.tabWidth": 4,
|
||||||
"[javascript]": {
|
"terminal.integrated.env.windows": {},
|
||||||
"editor.formatOnSave": true
|
"editor.formatOnSave": true,
|
||||||
},
|
"[javascript]": {
|
||||||
"[javascriptreact]": {
|
"editor.formatOnSave": true
|
||||||
"editor.formatOnSave": true
|
},
|
||||||
},
|
"[javascriptreact]": {
|
||||||
"[typescript]": {
|
"editor.formatOnSave": true
|
||||||
"editor.formatOnSave": true
|
},
|
||||||
},
|
"[typescript]": {
|
||||||
"[typescriptreact]": {
|
"editor.formatOnSave": true
|
||||||
"editor.formatOnSave": true
|
},
|
||||||
},
|
"[typescriptreact]": {
|
||||||
"[json]": {
|
"editor.formatOnSave": true
|
||||||
"editor.formatOnSave": true
|
},
|
||||||
},
|
"[json]": {
|
||||||
"[graphql]": {
|
"editor.formatOnSave": true
|
||||||
"editor.formatOnSave": true
|
},
|
||||||
},
|
"[graphql]": {
|
||||||
"[handlebars]": {
|
"editor.formatOnSave": true
|
||||||
"editor.formatOnSave": true
|
},
|
||||||
}
|
"[handlebars]": {
|
||||||
|
"editor.formatOnSave": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
database/migrations/0026_daily_the_twelve.sql
Normal file
17
database/migrations/0026_daily_the_twelve.sql
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
CREATE TABLE "printers" (
|
||||||
|
"printer_id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"humanReadableId" text,
|
||||||
|
"name" text NOT NULL,
|
||||||
|
"ipAddress" text,
|
||||||
|
"port" numeric NOT NULL,
|
||||||
|
"status" text,
|
||||||
|
"statusText" text NOT NULL,
|
||||||
|
"lastTimePrinted" text,
|
||||||
|
"assigned" boolean DEFAULT false NOT NULL,
|
||||||
|
"remark" text,
|
||||||
|
"monitorState" boolean DEFAULT false NOT NULL,
|
||||||
|
"add_Date" timestamp DEFAULT now(),
|
||||||
|
"upd_date" timestamp DEFAULT now()
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE UNIQUE INDEX "humanReadableId" ON "printers" USING btree ("name");
|
||||||
3
database/migrations/0027_needy_sleepwalker.sql
Normal file
3
database/migrations/0027_needy_sleepwalker.sql
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
ALTER TABLE "printers" ALTER COLUMN "statusText" DROP NOT NULL;--> statement-breakpoint
|
||||||
|
ALTER TABLE "printers" ALTER COLUMN "assigned" DROP NOT NULL;--> statement-breakpoint
|
||||||
|
ALTER TABLE "printers" ALTER COLUMN "monitorState" DROP NOT NULL;
|
||||||
1
database/migrations/0028_fast_wong.sql
Normal file
1
database/migrations/0028_fast_wong.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE "printers" ALTER COLUMN "port" DROP NOT NULL;
|
||||||
2
database/migrations/0029_giant_blue_blade.sql
Normal file
2
database/migrations/0029_giant_blue_blade.sql
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
DROP INDEX "humanReadableId";--> statement-breakpoint
|
||||||
|
CREATE UNIQUE INDEX "humanReadableId" ON "printers" USING btree ("humanReadableId");
|
||||||
4
database/migrations/0030_conscious_cable.sql
Normal file
4
database/migrations/0030_conscious_cable.sql
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
CREATE TABLE "prodlabels" (
|
||||||
|
"label_id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"runningNr" integer NOT NULL
|
||||||
|
);
|
||||||
7
database/migrations/0031_loud_alex_power.sql
Normal file
7
database/migrations/0031_loud_alex_power.sql
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
ALTER TABLE "prodlabels" ADD COLUMN "printerID" integer;--> statement-breakpoint
|
||||||
|
ALTER TABLE "prodlabels" ADD COLUMN "printerName" text;--> statement-breakpoint
|
||||||
|
ALTER TABLE "prodlabels" ADD COLUMN "line" integer;--> statement-breakpoint
|
||||||
|
ALTER TABLE "prodlabels" ADD COLUMN "status" text;--> statement-breakpoint
|
||||||
|
ALTER TABLE "prodlabels" ADD COLUMN "add_date" timestamp;--> statement-breakpoint
|
||||||
|
ALTER TABLE "prodlabels" ADD COLUMN "upd_date" timestamp;--> statement-breakpoint
|
||||||
|
CREATE UNIQUE INDEX "runningNr" ON "prodlabels" USING btree ("runningNr");
|
||||||
1168
database/migrations/meta/0026_snapshot.json
Normal file
1168
database/migrations/meta/0026_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
1168
database/migrations/meta/0027_snapshot.json
Normal file
1168
database/migrations/meta/0027_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
1168
database/migrations/meta/0028_snapshot.json
Normal file
1168
database/migrations/meta/0028_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
1168
database/migrations/meta/0029_snapshot.json
Normal file
1168
database/migrations/meta/0029_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
1194
database/migrations/meta/0030_snapshot.json
Normal file
1194
database/migrations/meta/0030_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
1246
database/migrations/meta/0031_snapshot.json
Normal file
1246
database/migrations/meta/0031_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -183,6 +183,48 @@
|
|||||||
"when": 1742655504936,
|
"when": 1742655504936,
|
||||||
"tag": "0025_amusing_sugar_man",
|
"tag": "0025_amusing_sugar_man",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 26,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1742914066219,
|
||||||
|
"tag": "0026_daily_the_twelve",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 27,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1742917145140,
|
||||||
|
"tag": "0027_needy_sleepwalker",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 28,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1742917676211,
|
||||||
|
"tag": "0028_fast_wong",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 29,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1742917978318,
|
||||||
|
"tag": "0029_giant_blue_blade",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 30,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1742938986653,
|
||||||
|
"tag": "0030_conscious_cable",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 31,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1742939306614,
|
||||||
|
"tag": "0031_loud_alex_power",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
42
database/schema/printers.ts
Normal file
42
database/schema/printers.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import {
|
||||||
|
text,
|
||||||
|
pgTable,
|
||||||
|
numeric,
|
||||||
|
index,
|
||||||
|
timestamp,
|
||||||
|
boolean,
|
||||||
|
uuid,
|
||||||
|
uniqueIndex,
|
||||||
|
} from "drizzle-orm/pg-core";
|
||||||
|
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
|
||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
export const printers = pgTable(
|
||||||
|
"printers",
|
||||||
|
{
|
||||||
|
printer_id: uuid("printer_id").defaultRandom().primaryKey(),
|
||||||
|
humanReadableId: text("humanReadableId"),
|
||||||
|
name: text("name").notNull(),
|
||||||
|
ipAddress: text("ipAddress"),
|
||||||
|
port: numeric("port"),
|
||||||
|
status: text("status"),
|
||||||
|
statusText: text("statusText"),
|
||||||
|
lastTimePrinted: text("lastTimePrinted"),
|
||||||
|
assigned: boolean("assigned").default(false),
|
||||||
|
remark: text("remark"),
|
||||||
|
monitorState: boolean("monitorState").default(false),
|
||||||
|
add_Date: timestamp("add_Date").defaultNow(),
|
||||||
|
upd_date: timestamp("upd_date").defaultNow(),
|
||||||
|
},
|
||||||
|
(table) => [
|
||||||
|
//uniqueIndex("emailUniqueIndex").on(sql`lower(${table.email})`),
|
||||||
|
uniqueIndex("humanReadableId").on(table.humanReadableId),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
// Schema for inserting a user - can be used to validate API requests
|
||||||
|
// export const insertRolesSchema = createInsertSchema(roles, {
|
||||||
|
// name: z.string().min(3, {message: "Role name must be more than 3 letters"}),
|
||||||
|
// });
|
||||||
|
// Schema for selecting a Expenses - can be used to validate API responses
|
||||||
|
export const selectRolesSchema = createSelectSchema(printers);
|
||||||
29
database/schema/prodLabels.ts
Normal file
29
database/schema/prodLabels.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import {
|
||||||
|
integer,
|
||||||
|
pgTable,
|
||||||
|
uuid,
|
||||||
|
uniqueIndex,
|
||||||
|
text,
|
||||||
|
timestamp,
|
||||||
|
} from "drizzle-orm/pg-core";
|
||||||
|
import { createSelectSchema } from "drizzle-zod";
|
||||||
|
|
||||||
|
export const prodlabels = pgTable(
|
||||||
|
"prodlabels",
|
||||||
|
{
|
||||||
|
label_id: uuid("label_id").defaultRandom().primaryKey(),
|
||||||
|
printerID: integer("printerID"),
|
||||||
|
printerName: text("printerName"),
|
||||||
|
line: integer("line"),
|
||||||
|
runningNr: integer("runningNr").notNull(),
|
||||||
|
status: text("status"),
|
||||||
|
add_date: timestamp("add_date"),
|
||||||
|
upd_date: timestamp("upd_date"),
|
||||||
|
},
|
||||||
|
(table) => [
|
||||||
|
//uniqueIndex("emailUniqueIndex").on(sql`lower(${table.email})`),
|
||||||
|
uniqueIndex("runningNr").on(table.runningNr),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
export const prodlabelsSchema = createSelectSchema(prodlabels);
|
||||||
32
frontend/package-lock.json
generated
32
frontend/package-lock.json
generated
@@ -16,6 +16,7 @@
|
|||||||
"@radix-ui/react-dropdown-menu": "^2.1.6",
|
"@radix-ui/react-dropdown-menu": "^2.1.6",
|
||||||
"@radix-ui/react-label": "^2.1.2",
|
"@radix-ui/react-label": "^2.1.2",
|
||||||
"@radix-ui/react-popover": "^1.1.6",
|
"@radix-ui/react-popover": "^1.1.6",
|
||||||
|
"@radix-ui/react-scroll-area": "^1.2.3",
|
||||||
"@radix-ui/react-select": "^2.1.6",
|
"@radix-ui/react-select": "^2.1.6",
|
||||||
"@radix-ui/react-separator": "^1.1.2",
|
"@radix-ui/react-separator": "^1.1.2",
|
||||||
"@radix-ui/react-slot": "^1.1.2",
|
"@radix-ui/react-slot": "^1.1.2",
|
||||||
@@ -1740,6 +1741,37 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@radix-ui/react-scroll-area": {
|
||||||
|
"version": "1.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-scroll-area/-/react-scroll-area-1.2.3.tgz",
|
||||||
|
"integrity": "sha512-l7+NNBfBYYJa9tNqVcP2AGvxdE3lmE6kFTBXdvHgUaZuy+4wGCL1Cl2AfaR7RKyimj7lZURGLwFO59k4eBnDJQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@radix-ui/number": "1.1.0",
|
||||||
|
"@radix-ui/primitive": "1.1.1",
|
||||||
|
"@radix-ui/react-compose-refs": "1.1.1",
|
||||||
|
"@radix-ui/react-context": "1.1.1",
|
||||||
|
"@radix-ui/react-direction": "1.1.0",
|
||||||
|
"@radix-ui/react-presence": "1.1.2",
|
||||||
|
"@radix-ui/react-primitive": "2.0.2",
|
||||||
|
"@radix-ui/react-use-callback-ref": "1.1.0",
|
||||||
|
"@radix-ui/react-use-layout-effect": "1.1.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/react": "*",
|
||||||
|
"@types/react-dom": "*",
|
||||||
|
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
||||||
|
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/react": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@types/react-dom": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@radix-ui/react-select": {
|
"node_modules/@radix-ui/react-select": {
|
||||||
"version": "2.1.6",
|
"version": "2.1.6",
|
||||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-select/-/react-select-2.1.6.tgz",
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-select/-/react-select-2.1.6.tgz",
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
"@radix-ui/react-dropdown-menu": "^2.1.6",
|
"@radix-ui/react-dropdown-menu": "^2.1.6",
|
||||||
"@radix-ui/react-label": "^2.1.2",
|
"@radix-ui/react-label": "^2.1.2",
|
||||||
"@radix-ui/react-popover": "^1.1.6",
|
"@radix-ui/react-popover": "^1.1.6",
|
||||||
|
"@radix-ui/react-scroll-area": "^1.2.3",
|
||||||
"@radix-ui/react-select": "^2.1.6",
|
"@radix-ui/react-select": "^2.1.6",
|
||||||
"@radix-ui/react-separator": "^1.1.2",
|
"@radix-ui/react-separator": "^1.1.2",
|
||||||
"@radix-ui/react-slot": "^1.1.2",
|
"@radix-ui/react-slot": "^1.1.2",
|
||||||
|
|||||||
131
frontend/src/components/ocme/WrapperCard.tsx
Normal file
131
frontend/src/components/ocme/WrapperCard.tsx
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
import axios from "axios";
|
||||||
|
import { LstCard } from "../extendedUI/LstCard";
|
||||||
|
import { Button } from "../ui/button";
|
||||||
|
import { ScrollArea } from "../ui/scroll-area";
|
||||||
|
import { Skeleton } from "../ui/skeleton";
|
||||||
|
import {
|
||||||
|
Table,
|
||||||
|
TableBody,
|
||||||
|
TableCell,
|
||||||
|
TableHead,
|
||||||
|
TableHeader,
|
||||||
|
TableRow,
|
||||||
|
} from "../ui/table";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
|
||||||
|
const currentPallets = [
|
||||||
|
{ key: "line", label: "Line" },
|
||||||
|
{ key: "runningNr", label: "Running #" },
|
||||||
|
{ key: "upd_date", label: "Date Scanned" },
|
||||||
|
{ key: "waitingfor", label: "Waiting For" },
|
||||||
|
{ key: "clear", label: "Clear" },
|
||||||
|
];
|
||||||
|
|
||||||
|
const currentTags = [
|
||||||
|
{ key: "line", label: "Line" },
|
||||||
|
{ key: "printerName", label: "Printer" },
|
||||||
|
{ key: "runningNr", label: "Running #" },
|
||||||
|
{ key: "upd_date", label: "Label date" },
|
||||||
|
{ key: "status", label: "Label Status" },
|
||||||
|
];
|
||||||
|
export default function WrapperManualTrigger() {
|
||||||
|
const cameraTrigger = async () => {
|
||||||
|
try {
|
||||||
|
const res = await axios.get("/ocme/api/v1/manualCameraTrigger");
|
||||||
|
|
||||||
|
if (res.data.success) {
|
||||||
|
toast.success(res.data.message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!res.data.success) {
|
||||||
|
toast.error(res.data.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
//stoast.success(error.data.message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<LstCard className="m-2 p-2">
|
||||||
|
<ScrollArea className="max-h-[200px]">
|
||||||
|
<span>Wrapper Pallet Info</span>
|
||||||
|
|
||||||
|
<Table>
|
||||||
|
<TableHeader>
|
||||||
|
<TableRow>
|
||||||
|
{currentPallets.map((l) => (
|
||||||
|
<TableHead key={l.key}>{l.label}</TableHead>
|
||||||
|
))}
|
||||||
|
</TableRow>
|
||||||
|
</TableHeader>
|
||||||
|
<TableBody>
|
||||||
|
{Array(3)
|
||||||
|
.fill(0)
|
||||||
|
.map((_, 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>
|
||||||
|
</Table>
|
||||||
|
</ScrollArea>
|
||||||
|
<ScrollArea className="max-h-[200px]">
|
||||||
|
<Table>
|
||||||
|
<TableHeader>
|
||||||
|
<TableRow>
|
||||||
|
{currentTags.map((l) => (
|
||||||
|
<TableHead key={l.key}>{l.label}</TableHead>
|
||||||
|
))}
|
||||||
|
</TableRow>
|
||||||
|
</TableHeader>
|
||||||
|
<TableBody>
|
||||||
|
{Array(3)
|
||||||
|
.fill(0)
|
||||||
|
.map((_, 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>
|
||||||
|
</Table>
|
||||||
|
</ScrollArea>
|
||||||
|
<div>
|
||||||
|
<hr />
|
||||||
|
<p className="text-center mb-3">Manual Triggers</p>
|
||||||
|
<div className="flex flex-row justify-between">
|
||||||
|
<Button onClick={cameraTrigger}>Camera</Button>
|
||||||
|
<Button>Rfid</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</LstCard>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,14 +1,27 @@
|
|||||||
import {toast} from "sonner";
|
import { toast } from "sonner";
|
||||||
import {LstCard} from "../extendedUI/LstCard";
|
import { LstCard } from "../extendedUI/LstCard";
|
||||||
import {Button} from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
import {Input} from "../ui/input";
|
import { Input } from "../ui/input";
|
||||||
import {Table, TableBody, TableCell, TableHead, TableHeader, TableRow} from "../ui/table";
|
import {
|
||||||
import {Skeleton} from "../ui/skeleton";
|
Table,
|
||||||
|
TableBody,
|
||||||
|
TableCell,
|
||||||
|
TableHead,
|
||||||
|
TableHeader,
|
||||||
|
TableRow,
|
||||||
|
} from "../ui/table";
|
||||||
|
import { Skeleton } from "../ui/skeleton";
|
||||||
//import CycleCountLog from "./CycleCountLog";
|
//import CycleCountLog from "./CycleCountLog";
|
||||||
import {Select, SelectContent, SelectItem, SelectTrigger, SelectValue} from "../ui/select";
|
import {
|
||||||
import {Controller, useForm} from "react-hook-form";
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from "../ui/select";
|
||||||
|
import { Controller, useForm } from "react-hook-form";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import {useState} from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
export default function OcmeCycleCount() {
|
export default function OcmeCycleCount() {
|
||||||
const token = localStorage.getItem("auth_token");
|
const token = localStorage.getItem("auth_token");
|
||||||
@@ -18,7 +31,7 @@ export default function OcmeCycleCount() {
|
|||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
//watch,
|
//watch,
|
||||||
formState: {errors},
|
formState: { errors },
|
||||||
reset,
|
reset,
|
||||||
control,
|
control,
|
||||||
} = useForm();
|
} = useForm();
|
||||||
@@ -29,7 +42,7 @@ export default function OcmeCycleCount() {
|
|||||||
toast.success(`Cycle count started`);
|
toast.success(`Cycle count started`);
|
||||||
try {
|
try {
|
||||||
const res = await axios.post("/ocme/api/v1/cyclecount", data, {
|
const res = await axios.post("/ocme/api/v1/cyclecount", data, {
|
||||||
headers: {Authorization: `Bearer ${token}`},
|
headers: { Authorization: `Bearer ${token}` },
|
||||||
});
|
});
|
||||||
toast.success(res.data.message);
|
toast.success(res.data.message);
|
||||||
setData(res.data.data);
|
setData(res.data.data);
|
||||||
@@ -45,20 +58,25 @@ export default function OcmeCycleCount() {
|
|||||||
<div className="flex flex-row w-screen">
|
<div className="flex flex-row w-screen">
|
||||||
<div className="m-2 w-5/6">
|
<div className="m-2 w-5/6">
|
||||||
<LstCard>
|
<LstCard>
|
||||||
<p className="ml-2">Please enter the name or laneID you want to cycle count.</p>
|
<p className="ml-2">
|
||||||
|
Please enter the name or laneID you want to cycle count.
|
||||||
|
</p>
|
||||||
<div>
|
<div>
|
||||||
<form onSubmit={handleSubmit(onSubmit)}>
|
<form onSubmit={handleSubmit(onSubmit)}>
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<div className="m-2 flex flex-row">
|
<div className="m-2 flex flex-row">
|
||||||
<Input
|
<Input
|
||||||
placeholder="enter lane: L064"
|
placeholder="enter lane: L064"
|
||||||
className={errors.lane ? "border-red-500" : ""}
|
className={
|
||||||
|
errors.lane ? "border-red-500" : ""
|
||||||
|
}
|
||||||
aria-invalid={!!errors.lane}
|
aria-invalid={!!errors.lane}
|
||||||
{...register("lane", {
|
{...register("lane", {
|
||||||
required: true,
|
required: true,
|
||||||
minLength: {
|
minLength: {
|
||||||
value: 3,
|
value: 3,
|
||||||
message: "The lane is too short!",
|
message:
|
||||||
|
"The lane is too short!",
|
||||||
},
|
},
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
@@ -68,25 +86,39 @@ export default function OcmeCycleCount() {
|
|||||||
name="laneType"
|
name="laneType"
|
||||||
defaultValue={""}
|
defaultValue={""}
|
||||||
render={({
|
render={({
|
||||||
field: {onChange},
|
field: { onChange },
|
||||||
fieldState: {},
|
fieldState: {},
|
||||||
//formState,
|
//formState,
|
||||||
}) => (
|
}) => (
|
||||||
<Select onValueChange={onChange}>
|
<Select
|
||||||
|
onValueChange={onChange}
|
||||||
|
>
|
||||||
<SelectTrigger className="w-[180px]">
|
<SelectTrigger className="w-[180px]">
|
||||||
<SelectValue placeholder="Select name or id" />
|
<SelectValue placeholder="Select name or id" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="name">Name</SelectItem>
|
<SelectItem value="name">
|
||||||
<SelectItem value="laneId">Lane ID</SelectItem>
|
Name
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value="laneId">
|
||||||
|
Lane ID
|
||||||
|
</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Button className="m-2" type="submit" disabled={counting}>
|
<Button
|
||||||
{counting ? <span>Counting...</span> : <span>CycleCount</span>}
|
className="m-2"
|
||||||
|
type="submit"
|
||||||
|
disabled={counting}
|
||||||
|
>
|
||||||
|
{counting ? (
|
||||||
|
<span>Counting...</span>
|
||||||
|
) : (
|
||||||
|
<span>CycleCount</span>
|
||||||
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@@ -108,41 +140,43 @@ export default function OcmeCycleCount() {
|
|||||||
{data.length === 0 ? (
|
{data.length === 0 ? (
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{Array(10)
|
{Array(10)
|
||||||
.fill(0)
|
.fill(0)
|
||||||
.map((_, i) => (
|
.map((_, i) => (
|
||||||
<TableRow key={i}>
|
<TableRow key={i}>
|
||||||
<TableCell className="font-medium">
|
<TableCell className="font-medium">
|
||||||
<Skeleton className="h-4" />
|
<Skeleton className="h-4" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Skeleton className="h-4" />
|
<Skeleton className="h-4" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Skeleton className="h-4" />
|
<Skeleton className="h-4" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Skeleton className="h-4" />
|
<Skeleton className="h-4" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Skeleton className="h-4" />
|
<Skeleton className="h-4" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Skeleton className="h-4" />
|
<Skeleton className="h-4" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Skeleton className="h-4" />
|
<Skeleton className="h-4" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Skeleton className="h-4" />
|
<Skeleton className="h-4" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
))}
|
))}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{data.map((i: any) => {
|
{data.map((i: any) => {
|
||||||
let classname = ``;
|
let classname = ``;
|
||||||
if (i.info === "Quality Check Required") {
|
if (
|
||||||
|
i.info === "Quality Check Required"
|
||||||
|
) {
|
||||||
classname = `bg-red-500`;
|
classname = `bg-red-500`;
|
||||||
}
|
}
|
||||||
if (i.info === "Sent to Inv") {
|
if (i.info === "Sent to Inv") {
|
||||||
@@ -150,24 +184,46 @@ export default function OcmeCycleCount() {
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<TableRow key={i.runningNumber}>
|
<TableRow key={i.runningNumber}>
|
||||||
<TableCell className={`font-medium ${classname}`}>
|
<TableCell
|
||||||
|
className={`font-medium ${classname}`}
|
||||||
|
>
|
||||||
{i.alpla_laneID}
|
{i.alpla_laneID}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className={`font-medium ${classname}`}>
|
<TableCell
|
||||||
|
className={`font-medium ${classname}`}
|
||||||
|
>
|
||||||
{i.alpla_laneDescription}
|
{i.alpla_laneDescription}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className={`font-medium ${classname}`}>
|
<TableCell
|
||||||
|
className={`font-medium ${classname}`}
|
||||||
|
>
|
||||||
{i.Article}
|
{i.Article}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className={`font-medium ${classname}`}>
|
<TableCell
|
||||||
|
className={`font-medium ${classname}`}
|
||||||
|
>
|
||||||
{i.alpla_laneDescription}
|
{i.alpla_laneDescription}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className={`font-medium ${classname}`}>
|
<TableCell
|
||||||
|
className={`font-medium ${classname}`}
|
||||||
|
>
|
||||||
{i.runningNumber}
|
{i.runningNumber}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className={`font-medium ${classname}`}>{i.ocme}</TableCell>
|
<TableCell
|
||||||
<TableCell className={`font-medium ${classname}`}>{i.stock}</TableCell>
|
className={`font-medium ${classname}`}
|
||||||
<TableCell className={`font-medium ${classname}`}>{i.info}</TableCell>
|
>
|
||||||
|
{i.ocme}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell
|
||||||
|
className={`font-medium ${classname}`}
|
||||||
|
>
|
||||||
|
{i.stock}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell
|
||||||
|
className={`font-medium ${classname}`}
|
||||||
|
>
|
||||||
|
{i.info}
|
||||||
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -1,23 +1,30 @@
|
|||||||
import {LstCard} from "@/components/extendedUI/LstCard";
|
import { LstCard } from "@/components/extendedUI/LstCard";
|
||||||
|
|
||||||
import {Skeleton} from "@/components/ui/skeleton";
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
import {Table, TableBody, TableCell, TableHead, TableHeader, TableRow} from "@/components/ui/table";
|
import {
|
||||||
|
Table,
|
||||||
|
TableBody,
|
||||||
|
TableCell,
|
||||||
|
TableHead,
|
||||||
|
TableHeader,
|
||||||
|
TableRow,
|
||||||
|
} from "@/components/ui/table";
|
||||||
// import {useSessionStore} from "@/lib/store/sessionStore";
|
// import {useSessionStore} from "@/lib/store/sessionStore";
|
||||||
// import {useSettingStore} from "@/lib/store/useSettings";
|
// import {useSettingStore} from "@/lib/store/useSettings";
|
||||||
import {useQuery} from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import {getlabels} from "@/utils/querys/production/labels";
|
import { getlabels } from "@/utils/querys/production/labels";
|
||||||
import {format} from "date-fns";
|
import { format } from "date-fns";
|
||||||
|
|
||||||
const labelLogs = [
|
const labelLogs = [
|
||||||
{key: "line", label: "Line"},
|
{ key: "line", label: "Line" },
|
||||||
{key: "printerName", label: "Printer"},
|
{ key: "printerName", label: "Printer" },
|
||||||
{key: "runningNr", label: "Running #"},
|
{ key: "runningNr", label: "Running #" },
|
||||||
{key: "upd_date", label: "Label date"},
|
{ key: "upd_date", label: "Label date" },
|
||||||
{key: "status", label: "Label Status"},
|
{ key: "status", label: "Label Status" },
|
||||||
//{key: "reprint", label: "Reprint"}, // removing the reprint button for now until repritning is working as intended
|
//{key: "reprint", label: "Reprint"}, // removing the reprint button for now until repritning is working as intended
|
||||||
];
|
];
|
||||||
export default function LabelLog() {
|
export default function LabelLog() {
|
||||||
const {data, isError, isLoading} = useQuery(getlabels("4"));
|
const { data, isError, isLoading } = useQuery(getlabels("4"));
|
||||||
//const {user} = useSessionStore();
|
//const {user} = useSessionStore();
|
||||||
//const {settings} = useSettingStore();
|
//const {settings} = useSettingStore();
|
||||||
//const server = settings.filter((n) => n.name === "server")[0]?.value || "";
|
//const server = settings.filter((n) => n.name === "server")[0]?.value || "";
|
||||||
@@ -40,26 +47,26 @@ export default function LabelLog() {
|
|||||||
|
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{Array(7)
|
{Array(7)
|
||||||
.fill(0)
|
.fill(0)
|
||||||
.map((_, i) => (
|
.map((_, i) => (
|
||||||
<TableRow key={i}>
|
<TableRow key={i}>
|
||||||
<TableCell className="font-medium">
|
<TableCell className="font-medium">
|
||||||
<Skeleton className="h-4" />
|
<Skeleton className="h-4" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Skeleton className="h-4" />
|
<Skeleton className="h-4" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Skeleton className="h-4" />
|
<Skeleton className="h-4" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Skeleton className="h-4" />
|
<Skeleton className="h-4" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Skeleton className="h-4" />
|
<Skeleton className="h-4" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
))}
|
))}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
</LstCard>
|
</LstCard>
|
||||||
@@ -82,39 +89,47 @@ export default function LabelLog() {
|
|||||||
<>
|
<>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{Array(7)
|
{Array(7)
|
||||||
.fill(0)
|
.fill(0)
|
||||||
.map((_, i) => (
|
.map((_, i) => (
|
||||||
<TableRow key={i}>
|
<TableRow key={i}>
|
||||||
<TableCell className="font-medium">
|
<TableCell className="font-medium">
|
||||||
<Skeleton className="h-4" />
|
<Skeleton className="h-4" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Skeleton className="h-4" />
|
<Skeleton className="h-4" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Skeleton className="h-4" />
|
<Skeleton className="h-4" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Skeleton className="h-4" />
|
<Skeleton className="h-4" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Skeleton className="h-4" />
|
<Skeleton className="h-4" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
))}
|
))}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{data?.map((label: any) => (
|
{data?.map((label: any) => (
|
||||||
<TableRow key={label.runningNr}>
|
<TableRow key={label.runningNr}>
|
||||||
<TableCell className="font-medium">{label.line}</TableCell>
|
<TableCell className="font-medium">
|
||||||
<TableCell className="font-medium">{label.printerName}</TableCell>
|
{label.line}
|
||||||
<TableCell className="font-medium">{label.runningNr}</TableCell>
|
</TableCell>
|
||||||
|
<TableCell className="font-medium">
|
||||||
|
{label.printerName}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell className="font-medium">
|
||||||
|
{label.runningNr}
|
||||||
|
</TableCell>
|
||||||
<TableCell className="font-medium">
|
<TableCell className="font-medium">
|
||||||
{format(label.upd_date, "M/d/yyyy hh:mm")}
|
{format(label.upd_date, "M/d/yyyy hh:mm")}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className="font-medium">{label.status}</TableCell>
|
<TableCell className="font-medium">
|
||||||
|
{label.status}
|
||||||
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
))}
|
))}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
|
|||||||
@@ -1,14 +1,22 @@
|
|||||||
import {LstCard} from "@/components/extendedUI/LstCard";
|
import { LstCard } from "@/components/extendedUI/LstCard";
|
||||||
|
|
||||||
import {Skeleton} from "@/components/ui/skeleton";
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
import {Table, TableBody, TableCell, TableHead, TableHeader, TableRow} from "@/components/ui/table";
|
import {
|
||||||
import {useSessionStore} from "@/lib/store/sessionStore";
|
Table,
|
||||||
import {useSettingStore} from "@/lib/store/useSettings";
|
TableBody,
|
||||||
import {LotType} from "@/types/lots";
|
TableCell,
|
||||||
import {getlots} from "@/utils/querys/production/lots";
|
TableHead,
|
||||||
import {useQuery} from "@tanstack/react-query";
|
TableHeader,
|
||||||
|
TableRow,
|
||||||
|
} from "@/components/ui/table";
|
||||||
|
import { useSessionStore } from "@/lib/store/sessionStore";
|
||||||
|
import { useSettingStore } from "@/lib/store/useSettings";
|
||||||
|
import { LotType } from "@/types/lots";
|
||||||
|
import { getlots } from "@/utils/querys/production/lots";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import ManualPrint from "./ManualPrinting/ManualPrint";
|
import ManualPrint from "./ManualPrinting/ManualPrint";
|
||||||
import ManualPrintForm from "./ManualPrinting/ManualPrintForm";
|
import ManualPrintForm from "./ManualPrinting/ManualPrintForm";
|
||||||
|
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||||
|
|
||||||
let lotColumns = [
|
let lotColumns = [
|
||||||
{
|
{
|
||||||
@@ -57,12 +65,12 @@ let lotColumns = [
|
|||||||
// },
|
// },
|
||||||
];
|
];
|
||||||
export default function Lots() {
|
export default function Lots() {
|
||||||
const {data, isError, isLoading} = useQuery(getlots());
|
const { data, isError, isLoading } = useQuery(getlots());
|
||||||
const {user} = useSessionStore();
|
const { user } = useSessionStore();
|
||||||
const {settings} = useSettingStore();
|
const { settings } = useSettingStore();
|
||||||
const server = settings.filter((n) => n.name === "server")[0]?.value || "";
|
const server = settings.filter((n) => n.name === "server")[0]?.value || "";
|
||||||
|
|
||||||
console.log(server);
|
console.log(data);
|
||||||
|
|
||||||
const roles = ["admin", "manager", "operator"];
|
const roles = ["admin", "manager", "operator"];
|
||||||
|
|
||||||
@@ -83,140 +91,167 @@ export default function Lots() {
|
|||||||
if (isError) {
|
if (isError) {
|
||||||
return (
|
return (
|
||||||
<div className="m-2 p-2 min-h-2/5">
|
<div className="m-2 p-2 min-h-2/5">
|
||||||
<LstCard>
|
<ScrollArea className="max-h-1/2 rounded-md border p-4">
|
||||||
<p className="text-center">Current Assigned lots</p>
|
<LstCard>
|
||||||
<Table>
|
<p className="text-center">Current Assigned lots</p>
|
||||||
<TableHeader>
|
<Table>
|
||||||
<TableRow>
|
<TableHeader>
|
||||||
{lotColumns.map((l) => (
|
<TableRow>
|
||||||
<TableHead key={l.key}>{l.label}</TableHead>
|
{lotColumns.map((l) => (
|
||||||
))}
|
<TableHead key={l.key}>
|
||||||
</TableRow>
|
{l.label}
|
||||||
</TableHeader>
|
</TableHead>
|
||||||
|
))}
|
||||||
<TableBody>
|
|
||||||
{Array(10)
|
|
||||||
.fill(0)
|
|
||||||
.map((_, 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>
|
|
||||||
<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>
|
</TableRow>
|
||||||
))}
|
</TableHeader>
|
||||||
</TableBody>
|
|
||||||
</Table>
|
<TableBody>
|
||||||
</LstCard>
|
{Array(10)
|
||||||
|
.fill(0)
|
||||||
|
.map((_, 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>
|
||||||
|
<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>
|
||||||
|
</Table>
|
||||||
|
</LstCard>
|
||||||
|
</ScrollArea>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LstCard className="m-2 p-2 min-h-2/5">
|
<LstCard className="m-2 p-2 min-h-2/5">
|
||||||
<p className="text-center">Current Assigned lots</p>
|
<ScrollArea className="h-[400px]">
|
||||||
<Table>
|
<p className="text-center">Current Assigned lots</p>
|
||||||
<TableHeader>
|
<Table>
|
||||||
<TableRow>
|
<TableHeader>
|
||||||
{lotColumns.map((l) => (
|
<TableRow>
|
||||||
<TableHead key={l.key}>{l.label}</TableHead>
|
{lotColumns.map((l) => (
|
||||||
))}
|
<TableHead key={l.key}>{l.label}</TableHead>
|
||||||
</TableRow>
|
))}
|
||||||
</TableHeader>
|
</TableRow>
|
||||||
{isLoading ? (
|
</TableHeader>
|
||||||
<>
|
{isLoading ? (
|
||||||
|
<>
|
||||||
|
<TableBody>
|
||||||
|
{Array(10)
|
||||||
|
.fill(0)
|
||||||
|
.map((_, 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>
|
||||||
|
<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>
|
<TableBody>
|
||||||
{Array(10)
|
{data?.map((lot: LotType) => (
|
||||||
.fill(0)
|
<TableRow key={lot.LabelOnlineID}>
|
||||||
.map((_, i) => (
|
|
||||||
<TableRow key={i}>
|
|
||||||
<TableCell className="font-medium">
|
<TableCell className="font-medium">
|
||||||
<Skeleton className="h-4" />
|
{lot.MachineLocation}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell className="font-medium">
|
||||||
<Skeleton className="h-4" />
|
{lot.AV}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell className="font-medium">
|
||||||
<Skeleton className="h-4" />
|
{lot.Alias}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell className="font-medium">
|
||||||
<Skeleton className="h-4" />
|
{lot.LOT}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell className="font-medium">
|
||||||
<Skeleton className="h-4" />
|
{lot.ProlinkLot}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell className="font-medium">
|
||||||
<Skeleton className="h-4" />
|
{lot.PlannedQTY}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell className="font-medium">
|
||||||
<Skeleton className="h-4" />
|
{lot.Produced}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell className="font-medium">
|
||||||
<Skeleton className="h-4" />
|
{lot.Remaining}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell className="font-medium">
|
||||||
<Skeleton className="h-4" />
|
{lot.overPrinting}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
{user && roles.includes(user.role) && (
|
||||||
|
<>
|
||||||
|
{server === "usday1vms006" ||
|
||||||
|
server === "localhost" ? (
|
||||||
|
<>
|
||||||
|
<TableCell className="flex justify-center">
|
||||||
|
<ManualPrintForm
|
||||||
|
lot={lot}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<TableCell className="flex justify-center">
|
||||||
|
<ManualPrint lot={lot} />
|
||||||
|
</TableCell>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</TableRow>
|
</TableRow>
|
||||||
))}
|
))}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</>
|
)}
|
||||||
) : (
|
</Table>
|
||||||
<TableBody>
|
</ScrollArea>
|
||||||
{data?.map((lot: LotType) => (
|
|
||||||
<TableRow key={lot.LabelOnlineID}>
|
|
||||||
<TableCell className="font-medium">{lot.MachineLocation}</TableCell>
|
|
||||||
<TableCell className="font-medium">{lot.AV}</TableCell>
|
|
||||||
<TableCell className="font-medium">{lot.Alias}</TableCell>
|
|
||||||
<TableCell className="font-medium">{lot.LOT}</TableCell>
|
|
||||||
<TableCell className="font-medium">{lot.ProlinkLot}</TableCell>
|
|
||||||
<TableCell className="font-medium">{lot.PlannedQTY}</TableCell>
|
|
||||||
<TableCell className="font-medium">{lot.Produced}</TableCell>
|
|
||||||
<TableCell className="font-medium">{lot.Remaining}</TableCell>
|
|
||||||
<TableCell className="font-medium">{lot.overPrinting}</TableCell>
|
|
||||||
{user && roles.includes(user.role) && (
|
|
||||||
<>
|
|
||||||
{server === "usday1vms006" || server === "localhost" ? (
|
|
||||||
<>
|
|
||||||
<TableCell className="flex justify-center">
|
|
||||||
<ManualPrintForm lot={lot} />
|
|
||||||
</TableCell>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<TableCell className="flex justify-center">
|
|
||||||
<ManualPrint lot={lot} />
|
|
||||||
</TableCell>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</TableRow>
|
|
||||||
))}
|
|
||||||
</TableBody>
|
|
||||||
)}
|
|
||||||
</Table>
|
|
||||||
</LstCard>
|
</LstCard>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
|
import WrapperManualTrigger from "@/components/ocme/WrapperCard";
|
||||||
import LabelLog from "./LabelLog";
|
import LabelLog from "./LabelLog";
|
||||||
import Lots from "./Lots";
|
import Lots from "./Lots";
|
||||||
import OcpLogs from "./OcpLogs";
|
import OcpLogs from "./OcpLogs";
|
||||||
import PrinterStatus from "./PrinterStatus";
|
import PrinterStatus from "./PrinterStatus";
|
||||||
|
import { useSettingStore } from "@/lib/store/useSettings";
|
||||||
|
|
||||||
export default function OCPPage() {
|
export default function OCPPage() {
|
||||||
|
const { settings } = useSettingStore();
|
||||||
|
|
||||||
|
const server = settings.filter((n) => n.plantToken === "usday1");
|
||||||
return (
|
return (
|
||||||
<div className="h-dvh w-full overflow-hidden">
|
<div className="h-dvh w-full overflow-hidden">
|
||||||
<div className="flex flex-wrap gap-2">
|
<div className="flex flex-wrap gap-2">
|
||||||
@@ -21,8 +26,15 @@ export default function OCPPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-1/6">
|
<div className="w-1/6 flex flex-col">
|
||||||
<PrinterStatus />
|
{server && (
|
||||||
|
<div>
|
||||||
|
<WrapperManualTrigger />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div>
|
||||||
|
<PrinterStatus />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
import {LstCard} from "@/components/extendedUI/LstCard";
|
import { LstCard } from "@/components/extendedUI/LstCard";
|
||||||
import {Skeleton} from "@/components/ui/skeleton";
|
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||||
import {Table, TableBody, TableCell, TableHead, TableHeader, TableRow} from "@/components/ui/table";
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
|
import {
|
||||||
|
Table,
|
||||||
|
TableBody,
|
||||||
|
TableCell,
|
||||||
|
TableHead,
|
||||||
|
TableHeader,
|
||||||
|
TableRow,
|
||||||
|
} from "@/components/ui/table";
|
||||||
|
|
||||||
let printerCols = [
|
let printerCols = [
|
||||||
{
|
{
|
||||||
@@ -19,34 +27,37 @@ let printerCols = [
|
|||||||
export default function PrinterStatus() {
|
export default function PrinterStatus() {
|
||||||
return (
|
return (
|
||||||
<LstCard className="m-2 p-2">
|
<LstCard className="m-2 p-2">
|
||||||
<p className="text-center">Printer Status</p>
|
<ScrollArea className="max-h-[300px]">
|
||||||
<Table>
|
<p className="text-center">Printer Status</p>
|
||||||
<TableHeader>
|
|
||||||
<TableRow>
|
|
||||||
{printerCols.map((l) => (
|
|
||||||
<TableHead key={l.key}>{l.label}</TableHead>
|
|
||||||
))}
|
|
||||||
</TableRow>
|
|
||||||
</TableHeader>
|
|
||||||
|
|
||||||
<TableBody>
|
<Table>
|
||||||
{Array(10)
|
<TableHeader>
|
||||||
.fill(0)
|
<TableRow>
|
||||||
.map((_, i) => (
|
{printerCols.map((l) => (
|
||||||
<TableRow key={i}>
|
<TableHead key={l.key}>{l.label}</TableHead>
|
||||||
<TableCell className="font-medium">
|
))}
|
||||||
<Skeleton className="h-4" />
|
|
||||||
</TableCell>
|
|
||||||
<TableCell>
|
|
||||||
<Skeleton className="h-4" />
|
|
||||||
</TableCell>
|
|
||||||
<TableCell>
|
|
||||||
<Skeleton className="h-4" />
|
|
||||||
</TableCell>
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
))}
|
</TableHeader>
|
||||||
</TableBody>
|
|
||||||
</Table>
|
<TableBody>
|
||||||
|
{Array(5)
|
||||||
|
.fill(0)
|
||||||
|
.map((_, 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>
|
||||||
|
</TableRow>
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</ScrollArea>
|
||||||
</LstCard>
|
</LstCard>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
56
frontend/src/components/ui/scroll-area.tsx
Normal file
56
frontend/src/components/ui/scroll-area.tsx
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
function ScrollArea({
|
||||||
|
className,
|
||||||
|
children,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof ScrollAreaPrimitive.Root>) {
|
||||||
|
return (
|
||||||
|
<ScrollAreaPrimitive.Root
|
||||||
|
data-slot="scroll-area"
|
||||||
|
className={cn("relative", className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<ScrollAreaPrimitive.Viewport
|
||||||
|
data-slot="scroll-area-viewport"
|
||||||
|
className="ring-ring/10 dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] focus-visible:ring-4 focus-visible:outline-1"
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</ScrollAreaPrimitive.Viewport>
|
||||||
|
<ScrollBar />
|
||||||
|
<ScrollAreaPrimitive.Corner />
|
||||||
|
</ScrollAreaPrimitive.Root>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function ScrollBar({
|
||||||
|
className,
|
||||||
|
orientation = "vertical",
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>) {
|
||||||
|
return (
|
||||||
|
<ScrollAreaPrimitive.ScrollAreaScrollbar
|
||||||
|
data-slot="scroll-area-scrollbar"
|
||||||
|
orientation={orientation}
|
||||||
|
className={cn(
|
||||||
|
"flex touch-none p-px transition-colors select-none",
|
||||||
|
orientation === "vertical" &&
|
||||||
|
"h-full w-2.5 border-l border-l-transparent",
|
||||||
|
orientation === "horizontal" &&
|
||||||
|
"h-2.5 flex-col border-t border-t-transparent",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<ScrollAreaPrimitive.ScrollAreaThumb
|
||||||
|
data-slot="scroll-area-thumb"
|
||||||
|
className="bg-border relative flex-1 rounded-full"
|
||||||
|
/>
|
||||||
|
</ScrollAreaPrimitive.ScrollAreaScrollbar>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { ScrollArea, ScrollBar }
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import {queryOptions} from "@tanstack/react-query";
|
import { queryOptions } from "@tanstack/react-query";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
export function getlabels(hours: string) {
|
export function getlabels(hours: string) {
|
||||||
@@ -13,7 +13,7 @@ export function getlabels(hours: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const fetchSettings = async (hours: string) => {
|
const fetchSettings = async (hours: string) => {
|
||||||
const {data} = await axios.get(`/api/v1/ocp/labels?hours=${hours}`);
|
const { data } = await axios.get(`/api/ocp/getlabels?hours=${hours}`);
|
||||||
// if we are not localhost ignore the devDir setting.
|
// if we are not localhost ignore the devDir setting.
|
||||||
//const url: string = window.location.host.split(":")[0];
|
//const url: string = window.location.host.split(":")[0];
|
||||||
return data.data ?? [];
|
return data.data ?? [];
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {queryOptions} from "@tanstack/react-query";
|
import { queryOptions } from "@tanstack/react-query";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
export function getlots() {
|
export function getlots() {
|
||||||
@@ -13,7 +13,7 @@ export function getlots() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const fetchSettings = async () => {
|
const fetchSettings = async () => {
|
||||||
const {data} = await axios.get("/api/v1/ocp/lots");
|
const { data } = await axios.get("/api/ocp/getlots");
|
||||||
// if we are not localhost ignore the devDir setting.
|
// if we are not localhost ignore the devDir setting.
|
||||||
//const url: string = window.location.host.split(":")[0];
|
//const url: string = window.location.host.split(":")[0];
|
||||||
let lotData = data.data;
|
let lotData = data.data;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
"deploy": "standard-version --conventional-commits && npm run prodBuild",
|
"deploy": "standard-version --conventional-commits && npm run prodBuild",
|
||||||
"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",
|
||||||
"prodBuild": "npm run v1Build && powershell -ExecutionPolicy Bypass -File server/scripts/build.ps1 -dir \"C:\\Users\\matthes01\\Documents\\lstv2\" && npm run zipServer",
|
"prodBuild": "npm run v1Build && powershell -ExecutionPolicy Bypass -File server/scripts/build.ps1 -dir \"C:\\Users\\matthes01\\Documents\\lstv2-dev\" && npm run zipServer",
|
||||||
"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"
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admConfig": {
|
"admConfig": {
|
||||||
"build": 50,
|
"build": 84,
|
||||||
"oldBuild": "backend-0.1.3.zip"
|
"oldBuild": "backend-0.1.3.zip"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
143
server/index.ts
143
server/index.ts
@@ -1,12 +1,12 @@
|
|||||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
||||||
import { serve } from "@hono/node-server";
|
import { serve } from "@hono/node-server";
|
||||||
import { OpenAPIHono } from "@hono/zod-openapi";
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
||||||
import { proxy } from "hono/proxy";
|
|
||||||
import { serveStatic } from "@hono/node-server/serve-static";
|
import { serveStatic } from "@hono/node-server/serve-static";
|
||||||
import { logger } from "hono/logger";
|
import { logger } from "hono/logger";
|
||||||
import { cors } from "hono/cors";
|
import { cors } from "hono/cors";
|
||||||
import { createLog } from "./services/logger/logger.js";
|
import { createLog } from "./services/logger/logger.js";
|
||||||
import { WebSocketServer } from "ws";
|
|
||||||
// custom routes
|
// custom routes
|
||||||
import scalar from "./services/general/route/scalar.js";
|
import scalar from "./services/general/route/scalar.js";
|
||||||
import system from "./services/server/systemServer.js";
|
import system from "./services/server/systemServer.js";
|
||||||
@@ -31,64 +31,67 @@ export const lstAuth = btoa(`${username}:${password}`);
|
|||||||
// checking to make sure we have the settings intialized
|
// checking to make sure we have the settings intialized
|
||||||
const serverIntialized = await db.select({ count: count() }).from(settings);
|
const serverIntialized = await db.select({ count: count() }).from(settings);
|
||||||
export const installed =
|
export const installed =
|
||||||
serverIntialized[0].count === 0 && process.env.NODE_ENV !== "development"
|
serverIntialized[0].count === 0 && process.env.NODE_ENV !== "development"
|
||||||
? false
|
? false
|
||||||
: true;
|
: true;
|
||||||
createLog("info", "LST", "server", `Server is installed: ${installed}`);
|
createLog("info", "LST", "server", `Server is installed: ${installed}`);
|
||||||
|
|
||||||
const app = new OpenAPIHono({ strict: false });
|
const app = new OpenAPIHono({ strict: false });
|
||||||
|
|
||||||
// middle ware
|
// middle ware
|
||||||
app.use("*", logger());
|
if (process.env.NODE_ENV === "development") {
|
||||||
|
app.use("*", logger());
|
||||||
|
}
|
||||||
|
|
||||||
app.use(
|
app.use(
|
||||||
"*",
|
"*",
|
||||||
cors({
|
cors({
|
||||||
origin: "*", // Allow all origins
|
origin: "*", // Allow all origins
|
||||||
allowHeaders: ["Content-Type", "Authorization", "X-Requested-With"],
|
allowHeaders: ["Content-Type", "Authorization", "X-Requested-With"],
|
||||||
allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"],
|
allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"],
|
||||||
//exposeHeaders: ["Content-Length", "X-Kuma-Revision"],
|
//exposeHeaders: ["Content-Length", "X-Kuma-Revision"],
|
||||||
credentials: true, // Allow credentials if needed
|
credentials: true, // Allow credentials if needed
|
||||||
maxAge: 600,
|
maxAge: 600,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
// Middleware to normalize route case
|
// Middleware to normalize route case
|
||||||
app.use("*", async (c, next) => {
|
// app.use("*", async (c, next) => {
|
||||||
const lowercasedUrl = c.req.url.toLowerCase();
|
// // const lowercasedUrl = c.req.url.toLowerCase();
|
||||||
//console.log("Incoming Request:", c.req.url, c.req.method);
|
// console.log("Incoming Request:", c.req.url, c.req.method);
|
||||||
// If the URL is already lowercase, continue as usual
|
// // // If the URL is already lowercase, continue as usual
|
||||||
if (c.req.url === lowercasedUrl) {
|
// // if (c.req.url === lowercasedUrl) {
|
||||||
return next();
|
// await next();
|
||||||
}
|
// // }
|
||||||
|
|
||||||
// Otherwise, re-route internally
|
// // // Otherwise, re-route internally
|
||||||
return c.redirect(lowercasedUrl, 308); // 308 preserves the HTTP method
|
// // return c.redirect(lowercasedUrl, 308); // 308 preserves the HTTP method
|
||||||
});
|
// });
|
||||||
|
|
||||||
app.doc("/api/ref", {
|
app.doc("/api/ref", {
|
||||||
openapi: "3.0.0",
|
openapi: "3.0.0",
|
||||||
info: {
|
info: {
|
||||||
version: "2.0.0",
|
version: "2.0.0",
|
||||||
title: "LST API",
|
title: "LST API",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
scalar,
|
scalar,
|
||||||
auth,
|
auth,
|
||||||
// apiHits,
|
// apiHits,
|
||||||
system,
|
system,
|
||||||
tcpServer,
|
tcpServer,
|
||||||
sqlService,
|
sqlService,
|
||||||
logistics,
|
logistics,
|
||||||
rfid,
|
rfid,
|
||||||
printers,
|
printers,
|
||||||
loggerService,
|
loggerService,
|
||||||
ocpService,
|
ocpService,
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
const appRoutes = routes.forEach((route) => {
|
const appRoutes = routes.forEach((route) => {
|
||||||
app.route("/api/", route);
|
app.route("/api/", route);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.route("/ocme/", ocme);
|
app.route("/ocme/", ocme);
|
||||||
@@ -129,48 +132,48 @@ app.use("*", serveStatic({ path: "./frontend/dist/index.html" }));
|
|||||||
|
|
||||||
// Handle app exit signals
|
// Handle app exit signals
|
||||||
process.on("SIGINT", async () => {
|
process.on("SIGINT", async () => {
|
||||||
console.log("\nGracefully shutting down...");
|
console.log("\nGracefully shutting down...");
|
||||||
//await closePool();
|
//await closePool();
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on("SIGTERM", async () => {
|
process.on("SIGTERM", async () => {
|
||||||
console.log("Received termination signal, closing database...");
|
console.log("Received termination signal, closing database...");
|
||||||
//await closePool();
|
//await closePool();
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on("uncaughtException", async (err) => {
|
process.on("uncaughtException", async (err) => {
|
||||||
console.log("Uncaught Exception:", err);
|
console.log("Uncaught Exception:", err);
|
||||||
//await closePool();
|
//await closePool();
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on("beforeExit", async () => {
|
process.on("beforeExit", async () => {
|
||||||
console.log("Process is about to exit...");
|
console.log("Process is about to exit...");
|
||||||
//await closePool();
|
//await closePool();
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
const port =
|
const port =
|
||||||
process.env.NODE_ENV === "development"
|
process.env.NODE_ENV === "development"
|
||||||
? process.env.VITE_SERVER_PORT
|
? process.env.VITE_SERVER_PORT
|
||||||
: process.env.PROD_PORT;
|
: process.env.PROD_PORT;
|
||||||
|
|
||||||
serve(
|
serve(
|
||||||
{
|
{
|
||||||
fetch: app.fetch,
|
fetch: app.fetch,
|
||||||
port: Number(port),
|
port: Number(port),
|
||||||
hostname: "0.0.0.0",
|
hostname: "0.0.0.0",
|
||||||
},
|
},
|
||||||
(info) => {
|
(info) => {
|
||||||
createLog(
|
createLog(
|
||||||
"info",
|
"info",
|
||||||
"LST",
|
"LST",
|
||||||
"server",
|
"server",
|
||||||
`Server is running on http://${info.address}:${info.port}`
|
`Server is running on http://${info.address}:${info.port}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
export type AppRoutes = typeof appRoutes;
|
export type AppRoutes = typeof appRoutes;
|
||||||
|
|||||||
@@ -415,10 +415,10 @@ try {
|
|||||||
Start-Service -DisplayName $serviceLstV2
|
Start-Service -DisplayName $serviceLstV2
|
||||||
Start-Sleep -Seconds 1
|
Start-Sleep -Seconds 1
|
||||||
Write-Host "$($server) finished updating"
|
Write-Host "$($server) finished updating"
|
||||||
if($token -eq "usday1"){
|
# if($token -eq "usday1"){
|
||||||
Write-Host "Starting $($serviceOcme)"
|
# Write-Host "Starting $($serviceOcme)"
|
||||||
Start-Service -DisplayName $serviceOcme
|
# Start-Service -DisplayName $serviceOcme
|
||||||
}
|
# }
|
||||||
|
|
||||||
}
|
}
|
||||||
Invoke-Command -ComputerName $server -ScriptBlock $plantFunness -ArgumentList $server, $token, $location, $buildZip, $buildLoc, $obslst, $obsBuild -Credential $credentials
|
Invoke-Command -ComputerName $server -ScriptBlock $plantFunness -ArgumentList $server, $token, $location, $buildZip, $buildLoc, $obslst, $obsBuild -Credential $credentials
|
||||||
@@ -1,21 +1,24 @@
|
|||||||
import {spawn} from "child_process";
|
import { spawn } from "child_process";
|
||||||
import {getAppInfo} from "../globalUtils/appInfo.js";
|
import { getAppInfo } from "../globalUtils/appInfo.js";
|
||||||
import {db} from "../../database/dbclient.js";
|
import { db } from "../../database/dbclient.js";
|
||||||
import {serverData} from "../../database/schema/serverData.js";
|
import { serverData } from "../../database/schema/serverData.js";
|
||||||
import {eq, sql} from "drizzle-orm";
|
import { eq, sql } from "drizzle-orm";
|
||||||
import {createLog} from "../services/logger/logger.js";
|
import { createLog } from "../services/logger/logger.js";
|
||||||
|
|
||||||
type UpdateServerResponse = {
|
type UpdateServerResponse = {
|
||||||
success: boolean;
|
success: boolean;
|
||||||
message: string;
|
message: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateServer = async (devApp: string, server: string | null): Promise<UpdateServerResponse> => {
|
export const updateServer = async (
|
||||||
|
devApp: string,
|
||||||
|
server: string | null
|
||||||
|
): Promise<UpdateServerResponse> => {
|
||||||
const app = await getAppInfo(devApp);
|
const app = await getAppInfo(devApp);
|
||||||
const serverInfo = await db
|
const serverInfo = await db
|
||||||
.select()
|
.select()
|
||||||
.from(serverData)
|
.from(serverData)
|
||||||
.where(eq(serverData.plantToken, server?.toLowerCase() ?? ""));
|
.where(eq(serverData.plantToken, server?.toLowerCase() ?? ""));
|
||||||
|
|
||||||
if (serverInfo.length === 0) {
|
if (serverInfo.length === 0) {
|
||||||
createLog(
|
createLog(
|
||||||
@@ -26,7 +29,8 @@ export const updateServer = async (devApp: string, server: string | null): Promi
|
|||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "Looks like you are missing the plant token or have entered an incorrect one please try again.",
|
message:
|
||||||
|
"Looks like you are missing the plant token or have entered an incorrect one please try again.",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,9 +81,9 @@ export const updateServer = async (devApp: string, server: string | null): Promi
|
|||||||
const process = spawn("powershell", args);
|
const process = spawn("powershell", args);
|
||||||
// change the server to upgradeing
|
// change the server to upgradeing
|
||||||
await db
|
await db
|
||||||
.update(serverData)
|
.update(serverData)
|
||||||
.set({isUpgrading: true})
|
.set({ isUpgrading: true })
|
||||||
.where(eq(serverData.plantToken, server?.toLowerCase() ?? ""));
|
.where(eq(serverData.plantToken, server?.toLowerCase() ?? ""));
|
||||||
//let stdout = "";
|
//let stdout = "";
|
||||||
//let stderr = "";
|
//let stderr = "";
|
||||||
|
|
||||||
@@ -108,9 +112,14 @@ export const updateServer = async (devApp: string, server: string | null): Promi
|
|||||||
//update the last build.
|
//update the last build.
|
||||||
try {
|
try {
|
||||||
await db
|
await db
|
||||||
.update(serverData)
|
.update(serverData)
|
||||||
.set({lastUpdated: sql`NOW()`, isUpgrading: false})
|
.set({ lastUpdated: sql`NOW()`, isUpgrading: false })
|
||||||
.where(eq(serverData.plantToken, server?.toLowerCase() ?? ""));
|
.where(
|
||||||
|
eq(
|
||||||
|
serverData.plantToken,
|
||||||
|
server?.toLowerCase() ?? ""
|
||||||
|
)
|
||||||
|
);
|
||||||
createLog(
|
createLog(
|
||||||
"info",
|
"info",
|
||||||
"lst",
|
"lst",
|
||||||
@@ -156,17 +165,35 @@ export const updateServer = async (devApp: string, server: string | null): Promi
|
|||||||
export async function processAllServers(devApp: string) {
|
export async function processAllServers(devApp: string) {
|
||||||
const servers = await db.select().from(serverData);
|
const servers = await db.select().from(serverData);
|
||||||
|
|
||||||
createLog("info", "lst", "serverUpdater", `Running the update on all servers`);
|
createLog(
|
||||||
|
"info",
|
||||||
|
"lst",
|
||||||
|
"serverUpdater",
|
||||||
|
`Running the update on all servers`
|
||||||
|
);
|
||||||
let count = 1;
|
let count = 1;
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
try {
|
try {
|
||||||
const updateToServer = await updateServer(devApp, server.plantToken);
|
const updateToServer = await updateServer(
|
||||||
createLog("info", "lst", "serverUpdater", `${server.sName} was updated.`);
|
devApp,
|
||||||
|
server.plantToken
|
||||||
|
);
|
||||||
|
createLog(
|
||||||
|
"info",
|
||||||
|
"lst",
|
||||||
|
"serverUpdater",
|
||||||
|
`${server.sName} was updated.`
|
||||||
|
);
|
||||||
count = count + 1;
|
count = count + 1;
|
||||||
|
|
||||||
//return {success: true, message: `${server.sName} was updated.`, data: updateToServer};
|
//return {success: true, message: `${server.sName} was updated.`, data: updateToServer};
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
createLog("info", "lst", "serverUpdater", `Error updating ${server.sName}: ${error.message}`);
|
createLog(
|
||||||
|
"info",
|
||||||
|
"lst",
|
||||||
|
"serverUpdater",
|
||||||
|
`Error updating ${server.sName}: ${error.message}`
|
||||||
|
);
|
||||||
//return {success: false, message: `Error updating ${server.sName}: ${error.message}`};
|
//return {success: false, message: `Error updating ${server.sName}: ${error.message}`};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ const updateBuildNumber = (appLock: string) => {
|
|||||||
// Auto-commit changes
|
// Auto-commit changes
|
||||||
execSync("git add package.json");
|
execSync("git add package.json");
|
||||||
execSync(
|
execSync(
|
||||||
`git commit -m "build: bump build number to ${pkgJson.admConfig.build}"`
|
`git commit -m "chore(release): bump build number to ${pkgJson.admConfig.build}"`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
createLog(
|
createLog(
|
||||||
|
|||||||
@@ -3,9 +3,14 @@ import axios from "axios";
|
|||||||
export const ocmeInv = async (data: any) => {
|
export const ocmeInv = async (data: any) => {
|
||||||
try {
|
try {
|
||||||
const res = await axios.post(
|
const res = await axios.post(
|
||||||
"http://usday1vms010:3250/api/v1/getLaneData",
|
"http://usday1vms010:3250/api/v1/getlanedata",
|
||||||
{lane: data.lane, laneType: data.laneType},
|
{ lane: data.lane, laneType: data.laneType },
|
||||||
{headers: {"Content-Type": "application/json", Connection: "keep-alive"}}
|
{
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Connection: "keep-alive",
|
||||||
|
},
|
||||||
|
}
|
||||||
);
|
);
|
||||||
// console.log(res.data.data);
|
// console.log(res.data.data);
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +1,39 @@
|
|||||||
import {db} from "../../../../database/dbclient.js";
|
import { db } from "../../../../database/dbclient.js";
|
||||||
import {ocmeData} from "../../../../database/schema/ocme.js";
|
import { ocmeData } from "../../../../database/schema/ocme.js";
|
||||||
import {differenceInMinutes} from "date-fns";
|
import { differenceInMinutes } from "date-fns";
|
||||||
import {createLog} from "../../logger/logger.js";
|
import { createLog } from "../../logger/logger.js";
|
||||||
import {eq} from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
|
|
||||||
export const getInfo = async () => {
|
export const getInfo = async () => {
|
||||||
let ocmeInfo: any = [];
|
let ocmeInfo: any = [];
|
||||||
try {
|
try {
|
||||||
ocmeInfo = await db.select().from(ocmeData).where(eq(ocmeData.pickedUp, false));
|
ocmeInfo = await db
|
||||||
|
.select()
|
||||||
|
.from(ocmeData)
|
||||||
|
.where(eq(ocmeData.pickedUp, false));
|
||||||
|
|
||||||
// add in the time difference
|
// add in the time difference
|
||||||
ocmeInfo = ocmeInfo.map((o: any) => {
|
ocmeInfo = ocmeInfo.map((o: any) => {
|
||||||
const now = new Date(Date.now());
|
const now = new Date(Date.now());
|
||||||
const diff = differenceInMinutes(now, o.add_Date!);
|
//const strippedDate = o.add_Date.replace("Z", "");
|
||||||
return {...o, waitingFor: diff};
|
const diff = differenceInMinutes(now, o.add_Date);
|
||||||
});
|
return { ...o, waitingFor: diff };
|
||||||
createLog("info", "ocme", "ocme", `There are ${ocmeInfo.length} pallet(s) to be picked up.`);
|
});
|
||||||
} catch (error) {
|
createLog(
|
||||||
createLog("error", "ocme", "ocme", "There was an error trying to retrive the ocmeInfo.");
|
"info",
|
||||||
throw Error("There was an error trying to retrive the.");
|
"ocme",
|
||||||
}
|
"ocme",
|
||||||
|
`There are ${ocmeInfo.length} pallet(s) to be picked up.`
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
createLog(
|
||||||
|
"error",
|
||||||
|
"ocme",
|
||||||
|
"ocme",
|
||||||
|
"There was an error trying to retrive the ocmeInfo."
|
||||||
|
);
|
||||||
|
throw Error("There was an error trying to retrive the.");
|
||||||
|
}
|
||||||
|
|
||||||
return ocmeInfo;
|
return ocmeInfo;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,43 +1,76 @@
|
|||||||
import {db} from "../../../../database/dbclient.js";
|
import { db } from "../../../../database/dbclient.js";
|
||||||
import {ocmeData} from "../../../../database/schema/ocme.js";
|
import { ocmeData } from "../../../../database/schema/ocme.js";
|
||||||
import {createSSCC} from "../../../globalUtils/createSSCC.js";
|
import { createSSCC } from "../../../globalUtils/createSSCC.js";
|
||||||
import {createLog} from "../../logger/logger.js";
|
import { createLog } from "../../logger/logger.js";
|
||||||
import {query} from "../../sqlServer/prodSqlServer.js";
|
import { query } from "../../sqlServer/prodSqlServer.js";
|
||||||
import {labelData} from "../../sqlServer/querys/materialHelpers/labelInfo.js";
|
import { labelData } from "../../sqlServer/querys/materialHelpers/labelInfo.js";
|
||||||
|
|
||||||
export const postLabelData = async (data: any) => {
|
export const postLabelData = async (data: any) => {
|
||||||
// if we have sscc we will do everything here and ignore the rn even it its sent over
|
console.log(data);
|
||||||
if (data.sscc && !data.runningNr) {
|
let newData = data;
|
||||||
data.runningNr = data.sscc.slice(10, -1);
|
if (Array.isArray(data)) {
|
||||||
|
newData = {
|
||||||
|
sscc: data[1],
|
||||||
|
areaFrom: data[0],
|
||||||
|
completed: true,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data.sscc && !data.runningNr) {
|
if (newData.sscc && !newData.runningNr) {
|
||||||
// data.runningNr = data.sscc.slice(10, -1);
|
newData.runningNr = newData.sscc.slice(10, -1);
|
||||||
return {success: false, message: "Missing data please try again", data: []};
|
}
|
||||||
|
if (!newData.sscc && !newData.runningNr) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Missing data please try again",
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let label;
|
let label;
|
||||||
const filterQuery = labelData.replaceAll("[rn]", data.runningNr);
|
const filterQuery = labelData.replaceAll("[rn]", newData.runningNr);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
label = await query(filterQuery, "Label data");
|
label = await query(filterQuery, "Label data");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
createLog("error", "ocme", "ocme", "There was an error getting the labelData");
|
createLog(
|
||||||
|
"error",
|
||||||
|
"ocme",
|
||||||
|
"ocme",
|
||||||
|
"There was an error getting the labelData"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const newPost = {
|
const newPost = {
|
||||||
sscc: data.sscc ? data.sscc : await createSSCC(data.runningNr),
|
sscc: newData.sscc ? newData.sscc : await createSSCC(newData.runningNr),
|
||||||
runningNr: data.runningNr,
|
runningNr: newData.runningNr,
|
||||||
completed: data.completed,
|
completed: newData.completed ? newData.completed : true,
|
||||||
lineNum: label[0].machineLocation,
|
lineNum: label[0]?.machineLocation,
|
||||||
areaFrom: data.areaFrom,
|
areaFrom: newData.areaFrom,
|
||||||
pickedUp: false,
|
pickedUp: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const enterNewData = await db.insert(ocmeData).values(newPost).returning({sscc: ocmeData.sscc});
|
const enterNewData = await db
|
||||||
return {success: true, message: "Data was posted to ocme info", data: enterNewData};
|
.insert(ocmeData)
|
||||||
|
.values(newPost)
|
||||||
|
.returning({
|
||||||
|
sscc: ocmeData.sscc,
|
||||||
|
runningNr: ocmeData.runningNr,
|
||||||
|
areaFrom: ocmeData.areaFrom,
|
||||||
|
lineNum: ocmeData.lineNum,
|
||||||
|
completed: ocmeData.completed,
|
||||||
|
pickedUp: ocmeData.pickedUp,
|
||||||
|
});
|
||||||
|
|
||||||
|
//console.log(enterNewData);
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "Data was posted to ocme info",
|
||||||
|
data: enterNewData,
|
||||||
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
//console.log(error);
|
||||||
return {success: false, message: "Data was posted to ocme info", data: newPost};
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Data was posted to ocme info",
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
56
server/services/ocme/controller/triggerCamera.ts
Normal file
56
server/services/ocme/controller/triggerCamera.ts
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
import net from "net";
|
||||||
|
import { db } from "../../../../database/dbclient.js";
|
||||||
|
import { settings } from "../../../../database/schema/settings.js";
|
||||||
|
import { eq } from "drizzle-orm";
|
||||||
|
import { createLog } from "../../logger/logger.js";
|
||||||
|
|
||||||
|
export const triggerScanner = async () => {
|
||||||
|
const camera = new net.Socket();
|
||||||
|
let setting = await db
|
||||||
|
.select()
|
||||||
|
.from(settings)
|
||||||
|
.where(eq(settings.name, "zebraScanners"));
|
||||||
|
if (setting.length === 0) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Looks like the setting is missing.",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const scannerData = JSON.parse(setting[0]?.value);
|
||||||
|
let data = scannerData.filter((n: any) => n.name === "wrapper1");
|
||||||
|
|
||||||
|
if (data.length === 0) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Looks like the scanner is missing.",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
let port = data[0]?.port;
|
||||||
|
|
||||||
|
createLog(
|
||||||
|
"info",
|
||||||
|
"wrapperScanner",
|
||||||
|
"ocme",
|
||||||
|
`End of line Camera was triggered`
|
||||||
|
);
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
camera.connect(port, data[0].ip, async () => {
|
||||||
|
createLog("info", "wrapperScanner", "ocme", `Triggered`);
|
||||||
|
camera.write("TRIGGER", "utf8");
|
||||||
|
camera.end();
|
||||||
|
resolve({ success: true, message: "Camera was triggered." });
|
||||||
|
});
|
||||||
|
|
||||||
|
camera.on("error", (error) => {
|
||||||
|
createLog("error", "wrapperScanner", "ocme", `${error}`);
|
||||||
|
resolve({
|
||||||
|
success: false,
|
||||||
|
message: `There was an error triggering the camera: ${JSON.stringify(
|
||||||
|
error
|
||||||
|
)}`,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
resolve({ success: true, message: "Camera was triggered." });
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import {OpenAPIHono} from "@hono/zod-openapi";
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
||||||
|
|
||||||
// routes
|
// routes
|
||||||
import getInfo from "./route/getInfo.js";
|
import getInfo from "./route/getInfo.js";
|
||||||
@@ -7,35 +7,52 @@ import pickedup from "./route/pickedUp.js";
|
|||||||
import postsscc from "./route/postSSCC.js";
|
import postsscc from "./route/postSSCC.js";
|
||||||
import getShipments from "./route/getShipmentPallets.js";
|
import getShipments from "./route/getShipmentPallets.js";
|
||||||
import cycleCount from "./route/cycleCount.js";
|
import cycleCount from "./route/cycleCount.js";
|
||||||
import {serve} from "@hono/node-server";
|
import { serve } from "@hono/node-server";
|
||||||
import {createLog} from "../logger/logger.js";
|
import { createLog } from "../logger/logger.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 manualTrigger from "./route/triggerCamera.js";
|
||||||
|
|
||||||
const app = new OpenAPIHono();
|
const app = new OpenAPIHono();
|
||||||
const port = process.env.OCME_PORT;
|
const port = process.env.OCME_PORT;
|
||||||
const routes = [getInfo, postRunningNr, postsscc, pickedup, getShipments, cycleCount] as const;
|
const routes = [
|
||||||
|
getInfo,
|
||||||
|
postRunningNr,
|
||||||
|
postsscc,
|
||||||
|
pickedup,
|
||||||
|
getShipments,
|
||||||
|
cycleCount,
|
||||||
|
manualTrigger,
|
||||||
|
] as const;
|
||||||
const setting = await db.select().from(settings);
|
const setting = await db.select().from(settings);
|
||||||
|
|
||||||
const isActive = setting.filter((n) => n.name === "ocmeService");
|
const isActive = setting.filter((n) => n.name === "ocmeService");
|
||||||
const appRoutes = routes.forEach((route) => {
|
const appRoutes = routes.forEach((route) => {
|
||||||
app.route("/api/v1", route);
|
app.route("/api/v1", route);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.all("/api/v1/*", (c) => {
|
app.all("/api/v1/*", (c) => {
|
||||||
return c.json({success: false, message: "you have encounted an ocme route that dose not exist."});
|
return c.json({
|
||||||
|
success: false,
|
||||||
|
message: "you have encounted an ocme route that dose not exist.",
|
||||||
|
});
|
||||||
});
|
});
|
||||||
if (port && isActive[0]?.value === "1") {
|
if (port && isActive[0]?.value === "1") {
|
||||||
serve(
|
serve(
|
||||||
{
|
{
|
||||||
fetch: app.fetch,
|
fetch: app.fetch,
|
||||||
port: Number(port),
|
port: Number(port),
|
||||||
hostname: "0.0.0.0",
|
hostname: "0.0.0.0",
|
||||||
},
|
},
|
||||||
(info) => {
|
(info) => {
|
||||||
createLog("info", "LST", "server", `Ocme section is listening on http://${info.address}:${info.port}`);
|
createLog(
|
||||||
}
|
"info",
|
||||||
);
|
"LST",
|
||||||
|
"server",
|
||||||
|
`Ocme section is listening on http://${info.address}:${info.port}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default app;
|
export default app;
|
||||||
|
|||||||
@@ -1,60 +1,71 @@
|
|||||||
import {createRoute, OpenAPIHono, z} from "@hono/zod-openapi";
|
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||||
|
|
||||||
import {apiHit} from "../../../globalUtils/apiHits.js";
|
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||||
import {responses} from "../../../globalUtils/routeDefs/responses.js";
|
import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
||||||
import {authMiddleware} from "../../auth/middleware/authMiddleware.js";
|
import { authMiddleware } from "../../auth/middleware/authMiddleware.js";
|
||||||
import {cycleCount} from "../controller/cycleCount.js";
|
import { cycleCount } from "../controller/cycleCount.js";
|
||||||
import type {User} from "../../../types/users.js";
|
import type { User } from "../../../types/users.js";
|
||||||
import {verify} from "hono/jwt";
|
import { verify } from "hono/jwt";
|
||||||
|
|
||||||
const app = new OpenAPIHono({strict: false});
|
const app = new OpenAPIHono({ strict: false });
|
||||||
|
|
||||||
const AddSetting = z.object({
|
const AddSetting = z.object({
|
||||||
lane: z.string().openapi({example: "L064"}),
|
lane: z.string().openapi({ example: "L064" }),
|
||||||
});
|
});
|
||||||
|
|
||||||
app.openapi(
|
app.openapi(
|
||||||
createRoute({
|
createRoute({
|
||||||
tags: ["ocme"],
|
tags: ["ocme"],
|
||||||
summary: "Cycle counts a lane based on the lane Alias",
|
summary: "Cycle counts a lane based on the lane Alias",
|
||||||
method: "post",
|
method: "post",
|
||||||
path: "/cyclecount",
|
path: "/cycleCount",
|
||||||
middleware: authMiddleware,
|
middleware: authMiddleware,
|
||||||
request: {
|
request: {
|
||||||
body: {
|
body: {
|
||||||
content: {
|
content: {
|
||||||
"application/json": {schema: AddSetting},
|
"application/json": { schema: AddSetting },
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
responses: responses(),
|
},
|
||||||
}),
|
},
|
||||||
async (c) => {
|
responses: responses(),
|
||||||
apiHit(c, {endpoint: "api/auth/register"});
|
}),
|
||||||
// make sure we have a vaid user being accessed thats really logged in
|
async (c) => {
|
||||||
const body = await c.req.json();
|
apiHit(c, { endpoint: "api/auth/register" });
|
||||||
|
// make sure we have a vaid user being accessed thats really logged in
|
||||||
|
const body = await c.req.json();
|
||||||
|
|
||||||
const authHeader = c.req.header("Authorization");
|
const authHeader = c.req.header("Authorization");
|
||||||
|
|
||||||
const token = authHeader?.split("Bearer ")[1] || "";
|
const token = authHeader?.split("Bearer ")[1] || "";
|
||||||
let user: User;
|
let user: User;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const payload = await verify(token, process.env.JWT_SECRET!);
|
const payload = await verify(token, process.env.JWT_SECRET!);
|
||||||
user = payload.user as User;
|
user = payload.user as User;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return c.json({message: "Unauthorized"}, 401);
|
return c.json({ message: "Unauthorized" }, 401);
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const cycleData = await cycleCount(body, user);
|
|
||||||
return c.json({success: true, message: `${body.lane} was just cycle counted.`, data: cycleData}, 200);
|
|
||||||
} catch (error) {
|
|
||||||
return c.json(
|
|
||||||
{success: false, message: `There was an error cycle counting ${body.lane}`, data: error},
|
|
||||||
400
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const cycleData = await cycleCount(body, user);
|
||||||
|
return c.json(
|
||||||
|
{
|
||||||
|
success: true,
|
||||||
|
message: `${body.lane} was just cycle counted.`,
|
||||||
|
data: cycleData,
|
||||||
|
},
|
||||||
|
200
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
return c.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: `There was an error cycle counting ${body.lane}`,
|
||||||
|
data: error,
|
||||||
|
},
|
||||||
|
400
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
);
|
);
|
||||||
export default app;
|
export default app;
|
||||||
|
|||||||
@@ -1,80 +1,36 @@
|
|||||||
import {createRoute, OpenAPIHono, z} from "@hono/zod-openapi";
|
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||||
import {getInfo} from "../controller/getInfo.js";
|
import { getInfo } from "../controller/getInfo.js";
|
||||||
import {apiHit} from "../../../globalUtils/apiHits.js";
|
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||||
|
import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
||||||
|
|
||||||
const app = new OpenAPIHono({strict: false});
|
const app = new OpenAPIHono({ strict: false });
|
||||||
|
|
||||||
const AddSetting = z.object({
|
|
||||||
name: z.string().openapi({example: "server"}),
|
|
||||||
value: z.string().openapi({example: "localhost"}),
|
|
||||||
description: z.string().openapi({example: "The server we are going to connect to"}),
|
|
||||||
roles: z.string().openapi({example: "admin"}),
|
|
||||||
module: z.string().openapi({example: "production"}),
|
|
||||||
});
|
|
||||||
|
|
||||||
app.openapi(
|
app.openapi(
|
||||||
createRoute({
|
createRoute({
|
||||||
tags: ["ocme"],
|
tags: ["ocme"],
|
||||||
summary: "Get all current info",
|
summary: "Get all current info",
|
||||||
method: "get",
|
method: "get",
|
||||||
path: "/getinfo",
|
path: "/getInfo",
|
||||||
request: {
|
|
||||||
body: {
|
responses: responses(),
|
||||||
content: {
|
|
||||||
"application/json": {schema: AddSetting},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
responses: {
|
|
||||||
200: {
|
|
||||||
content: {
|
|
||||||
"application/json": {
|
|
||||||
schema: z.object({
|
|
||||||
success: z.boolean().openapi({example: true}),
|
|
||||||
message: z.string().openapi({example: "Starter"}),
|
|
||||||
data: z.array(z.object({})).optional().openapi({example: []}),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
description: "Response message",
|
|
||||||
},
|
|
||||||
400: {
|
|
||||||
content: {
|
|
||||||
"application/json": {
|
|
||||||
schema: z.object({
|
|
||||||
success: z.boolean().openapi({example: false}),
|
|
||||||
message: z.string().optional().openapi({example: "Internal Server error"}),
|
|
||||||
data: z.array(z.object({})).optional().openapi({example: []}),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
description: "Internal Server Error",
|
|
||||||
},
|
|
||||||
// 401: {
|
|
||||||
// content: {
|
|
||||||
// "application/json": {
|
|
||||||
// schema: z.object({message: z.string().optional().openapi({example: "Unauthenticated"})}),
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// description: "Unauthorized",
|
|
||||||
// },
|
|
||||||
// 500: {
|
|
||||||
// content: {
|
|
||||||
// "application/json": {
|
|
||||||
// schema: z.object({message: z.string().optional().openapi({example: "Internal Server error"})}),
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// description: "Internal Server Error",
|
|
||||||
// },
|
|
||||||
},
|
|
||||||
}),
|
}),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
// make sure we have a vaid user being accessed thats really logged in
|
// make sure we have a vaid user being accessed thats really logged in
|
||||||
apiHit(c, {endpoint: "api/auth/register"});
|
apiHit(c, { endpoint: "api/auth/register" });
|
||||||
try {
|
try {
|
||||||
return c.json({success: true, message: "Ocme Info", data: await getInfo()}, 200);
|
return c.json(
|
||||||
|
{ success: true, message: "Ocme Info", data: await getInfo() },
|
||||||
|
200
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return c.json({success: false, message: "There was an error getting ocmeInfo data", data: error}, 400);
|
return c.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "There was an error getting ocmeInfo data",
|
||||||
|
data: error,
|
||||||
|
},
|
||||||
|
400
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,94 +1,114 @@
|
|||||||
import {createRoute, OpenAPIHono, z} from "@hono/zod-openapi";
|
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||||
import {apiHit} from "../../../globalUtils/apiHits.js";
|
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||||
import {getShipmentPallets} from "../controller/getShipmentPallets.js";
|
import { getShipmentPallets } from "../controller/getShipmentPallets.js";
|
||||||
|
|
||||||
const app = new OpenAPIHono();
|
const app = new OpenAPIHono();
|
||||||
|
|
||||||
const ShipmentID = z.object({
|
const ShipmentID = z.object({
|
||||||
shipmentID: z.string().optional().openapi({example: "14558"}),
|
shipmentID: z.string().optional().openapi({ example: "14558" }),
|
||||||
});
|
});
|
||||||
|
|
||||||
app.openapi(
|
app.openapi(
|
||||||
createRoute({
|
createRoute({
|
||||||
tags: ["ocme"],
|
tags: ["ocme"],
|
||||||
summary: "Post New running number to be picked up.",
|
summary: "Post New running number to be picked up.",
|
||||||
method: "post",
|
method: "post",
|
||||||
path: "/getshipmentpallets",
|
path: "/GetShipmentPallets",
|
||||||
request: {
|
request: {
|
||||||
body: {
|
body: {
|
||||||
content: {
|
content: {
|
||||||
"application/json": {schema: ShipmentID},
|
"application/json": { schema: ShipmentID },
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
responses: {
|
},
|
||||||
200: {
|
},
|
||||||
content: {
|
responses: {
|
||||||
"application/json": {
|
200: {
|
||||||
schema: z.object({
|
content: {
|
||||||
success: z.boolean().openapi({example: true}),
|
"application/json": {
|
||||||
message: z.string().openapi({example: "Starter"}),
|
schema: z.object({
|
||||||
// data: z
|
success: z.boolean().openapi({ example: true }),
|
||||||
// .array(z.object({sscc: z.string().optional()}))
|
message: z.string().openapi({ example: "Starter" }),
|
||||||
// .optional()
|
// data: z
|
||||||
// .openapi({example: []}),
|
// .array(z.object({sscc: z.string().optional()}))
|
||||||
}),
|
// .optional()
|
||||||
},
|
// .openapi({example: []}),
|
||||||
},
|
}),
|
||||||
description: "Response message",
|
},
|
||||||
},
|
|
||||||
400: {
|
|
||||||
content: {
|
|
||||||
"application/json": {
|
|
||||||
schema: z.object({
|
|
||||||
success: z.boolean().openapi({example: false}),
|
|
||||||
message: z.string().optional().openapi({example: "Internal Server error"}),
|
|
||||||
data: z.array(z.object({})).optional().openapi({example: []}),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
description: "Internal Server Error",
|
|
||||||
},
|
|
||||||
// 401: {
|
|
||||||
// content: {
|
|
||||||
// "application/json": {
|
|
||||||
// schema: z.object({message: z.string().optional().openapi({example: "Unauthenticated"})}),
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// description: "Unauthorized",
|
|
||||||
// },
|
|
||||||
// 500: {
|
|
||||||
// content: {
|
|
||||||
// "application/json": {
|
|
||||||
// schema: z.object({message: z.string().optional().openapi({example: "Internal Server error"})}),
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// description: "Internal Server Error",
|
|
||||||
// },
|
|
||||||
},
|
},
|
||||||
}),
|
description: "Response message",
|
||||||
async (c) => {
|
},
|
||||||
// make sure we have a vaid user being accessed thats really logged in
|
400: {
|
||||||
try {
|
content: {
|
||||||
const data = await c.req.json();
|
"application/json": {
|
||||||
apiHit(c, {endpoint: "api/ocme/getshipmentpallets", lastBody: data});
|
schema: z.object({
|
||||||
|
success: z.boolean().openapi({ example: false }),
|
||||||
|
message: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.openapi({ example: "Internal Server error" }),
|
||||||
|
data: z.array(z.object({})).optional().openapi({ example: [] }),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: "Internal Server Error",
|
||||||
|
},
|
||||||
|
// 401: {
|
||||||
|
// content: {
|
||||||
|
// "application/json": {
|
||||||
|
// schema: z.object({message: z.string().optional().openapi({example: "Unauthenticated"})}),
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// description: "Unauthorized",
|
||||||
|
// },
|
||||||
|
// 500: {
|
||||||
|
// content: {
|
||||||
|
// "application/json": {
|
||||||
|
// schema: z.object({message: z.string().optional().openapi({example: "Internal Server error"})}),
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// description: "Internal Server Error",
|
||||||
|
// },
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
async (c) => {
|
||||||
|
// make sure we have a vaid user being accessed thats really logged in
|
||||||
|
try {
|
||||||
|
const data = await c.req.json();
|
||||||
|
apiHit(c, { endpoint: "api/ocme/getshipmentpallets", lastBody: data });
|
||||||
|
|
||||||
if (!data.shipmentID) {
|
console.log;
|
||||||
return c.json(
|
|
||||||
{success: false, message: "You are missing the shipment id please try again.", data: []},
|
|
||||||
400
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const shiptmentData = await getShipmentPallets(data.shipmentID);
|
if (!data.shipmentID) {
|
||||||
|
return c.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "You are missing the shipment id please try again.",
|
||||||
|
data: [],
|
||||||
|
},
|
||||||
|
400
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return c.json(
|
const shiptmentData = await getShipmentPallets(data.shipmentID);
|
||||||
{success: shiptmentData.success, message: shiptmentData.message, data: shiptmentData.data ?? []},
|
|
||||||
200
|
return c.json(
|
||||||
);
|
{
|
||||||
} catch (error) {
|
success: shiptmentData.success,
|
||||||
return c.json({success: false, message: "There was an error getting the shipment data.", data: error}, 400);
|
message: shiptmentData.message,
|
||||||
}
|
data: shiptmentData.data ?? [],
|
||||||
|
},
|
||||||
|
200
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
return c.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "There was an error getting the shipment data.",
|
||||||
|
data: error,
|
||||||
|
},
|
||||||
|
400
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
);
|
);
|
||||||
export default app;
|
export default app;
|
||||||
|
|||||||
@@ -1,89 +1,114 @@
|
|||||||
import {createRoute, OpenAPIHono, z} from "@hono/zod-openapi";
|
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||||
import {postLabelData} from "../controller/postRunningNr.js";
|
import { postLabelData } from "../controller/postRunningNr.js";
|
||||||
import {apiHit} from "../../../globalUtils/apiHits.js";
|
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||||
import {pickedup} from "../controller/pickedup.js";
|
import { pickedup } from "../controller/pickedup.js";
|
||||||
|
|
||||||
const app = new OpenAPIHono();
|
const app = new OpenAPIHono();
|
||||||
|
|
||||||
const PostRunningNr = z.object({
|
const PostRunningNr = z.object({
|
||||||
sscc: z.string().optional().openapi({example: "00090103830005710997"}),
|
sscc: z.string().optional().openapi({ example: "00090103830005710997" }),
|
||||||
runningNr: z.string().optional().openapi({example: "localhost"}),
|
runningNr: z.string().optional().openapi({ example: "localhost" }),
|
||||||
areaFrom: z.string().optional().openapi({example: "The server we are going to connect to"}),
|
areaFrom: z
|
||||||
completed: z.boolean().optional().openapi({example: true}),
|
.string()
|
||||||
all: z.boolean().optional().openapi({example: false}),
|
.optional()
|
||||||
|
.openapi({ example: "The server we are going to connect to" }),
|
||||||
|
completed: z.boolean().optional().openapi({ example: true }),
|
||||||
|
all: z.boolean().optional().openapi({ example: false }),
|
||||||
});
|
});
|
||||||
|
|
||||||
app.openapi(
|
app.openapi(
|
||||||
createRoute({
|
createRoute({
|
||||||
tags: ["ocme"],
|
tags: ["ocme"],
|
||||||
summary: "Picks up a pallet in the system.",
|
summary: "Picks up a pallet in the system.",
|
||||||
method: "patch",
|
method: "patch",
|
||||||
description:
|
description:
|
||||||
"removes the pallet(s) from showing as needed to be picked up, we clear everything related to the pallet number to reduce the risk of a mix, passing `all` will just clear everything that is pending.",
|
"removes the pallet(s) from showing as needed to be picked up, we clear everything related to the pallet number to reduce the risk of a mix, passing `all` will just clear everything that is pending.",
|
||||||
path: "/pickedup",
|
path: "/pickedUp",
|
||||||
request: {
|
request: {
|
||||||
body: {
|
body: {
|
||||||
content: {
|
content: {
|
||||||
"application/json": {schema: PostRunningNr},
|
"application/json": { schema: PostRunningNr },
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
responses: {
|
},
|
||||||
200: {
|
},
|
||||||
content: {
|
responses: {
|
||||||
"application/json": {
|
200: {
|
||||||
schema: z.object({
|
content: {
|
||||||
success: z.boolean().openapi({example: true}),
|
"application/json": {
|
||||||
message: z.string().openapi({example: "Starter"}),
|
schema: z.object({
|
||||||
// data: z
|
success: z.boolean().openapi({ example: true }),
|
||||||
// .array(z.object({sscc: z.string().optional()}))
|
message: z.string().openapi({ example: "Starter" }),
|
||||||
// .optional()
|
// data: z
|
||||||
// .openapi({example: []}),
|
// .array(z.object({sscc: z.string().optional()}))
|
||||||
}),
|
// .optional()
|
||||||
},
|
// .openapi({example: []}),
|
||||||
},
|
}),
|
||||||
description: "Response message",
|
},
|
||||||
},
|
|
||||||
400: {
|
|
||||||
content: {
|
|
||||||
"application/json": {
|
|
||||||
schema: z.object({
|
|
||||||
success: z.boolean().openapi({example: false}),
|
|
||||||
message: z.string().optional().openapi({example: "Internal Server error"}),
|
|
||||||
data: z.array(z.object({})).optional().openapi({example: []}),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
description: "Internal Server Error",
|
|
||||||
},
|
|
||||||
// 401: {
|
|
||||||
// content: {
|
|
||||||
// "application/json": {
|
|
||||||
// schema: z.object({message: z.string().optional().openapi({example: "Unauthenticated"})}),
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// description: "Unauthorized",
|
|
||||||
// },
|
|
||||||
500: {
|
|
||||||
content: {
|
|
||||||
"application/json": {
|
|
||||||
schema: z.object({message: z.string().optional().openapi({example: "Internal Server error"})}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
description: "Internal Server Error",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}),
|
description: "Response message",
|
||||||
async (c) => {
|
},
|
||||||
// make sure we have a vaid user being accessed thats really logged in
|
400: {
|
||||||
try {
|
content: {
|
||||||
const data = await c.req.json();
|
"application/json": {
|
||||||
apiHit(c, {endpoint: "api/ocme/pickedup", lastBody: data});
|
schema: z.object({
|
||||||
const postPallet = await pickedup(data);
|
success: z.boolean().openapi({ example: false }),
|
||||||
return c.json({success: postPallet.success, message: postPallet.message, data: postPallet.data}, 200);
|
message: z
|
||||||
} catch (error) {
|
.string()
|
||||||
return c.json({success: false, message: "There was an error getting ocmeInfo data", data: error}, 400);
|
.optional()
|
||||||
}
|
.openapi({ example: "Internal Server error" }),
|
||||||
|
data: z.array(z.object({})).optional().openapi({ example: [] }),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: "Internal Server Error",
|
||||||
|
},
|
||||||
|
// 401: {
|
||||||
|
// content: {
|
||||||
|
// "application/json": {
|
||||||
|
// schema: z.object({message: z.string().optional().openapi({example: "Unauthenticated"})}),
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// description: "Unauthorized",
|
||||||
|
// },
|
||||||
|
500: {
|
||||||
|
content: {
|
||||||
|
"application/json": {
|
||||||
|
schema: z.object({
|
||||||
|
message: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.openapi({ example: "Internal Server error" }),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: "Internal Server Error",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
async (c) => {
|
||||||
|
// make sure we have a vaid user being accessed thats really logged in
|
||||||
|
try {
|
||||||
|
const data = await c.req.json();
|
||||||
|
apiHit(c, { endpoint: "api/ocme/pickedup", lastBody: data });
|
||||||
|
const postPallet = await pickedup(data);
|
||||||
|
return c.json(
|
||||||
|
{
|
||||||
|
success: postPallet.success,
|
||||||
|
message: postPallet.message,
|
||||||
|
data: postPallet.data,
|
||||||
|
},
|
||||||
|
200
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
return c.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "There was an error getting ocmeInfo data",
|
||||||
|
data: error,
|
||||||
|
},
|
||||||
|
400
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
);
|
);
|
||||||
export default app;
|
export default app;
|
||||||
|
|||||||
@@ -1,86 +1,106 @@
|
|||||||
import {createRoute, OpenAPIHono, z} from "@hono/zod-openapi";
|
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||||
import {getInfo} from "../controller/getInfo.js";
|
import { getInfo } from "../controller/getInfo.js";
|
||||||
import {postLabelData} from "../controller/postRunningNr.js";
|
import { postLabelData } from "../controller/postRunningNr.js";
|
||||||
import {apiHit} from "../../../globalUtils/apiHits.js";
|
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||||
|
|
||||||
const app = new OpenAPIHono();
|
const app = new OpenAPIHono();
|
||||||
|
|
||||||
const PostRunningNr = z.object({
|
const PostRunningNr = z.object({
|
||||||
sscc: z.string().optional().openapi({example: "00090103830005710997"}),
|
sscc: z.string().optional().openapi({ example: "00090103830005710997" }),
|
||||||
runningNr: z.string().optional().openapi({example: "localhost"}),
|
runningNr: z.string().optional().openapi({ example: "localhost" }),
|
||||||
areaFrom: z.string().optional().openapi({example: "The server we are going to connect to"}),
|
areaFrom: z
|
||||||
completed: z.boolean().optional().openapi({example: true}),
|
.string()
|
||||||
|
.optional()
|
||||||
|
.openapi({ example: "The server we are going to connect to" }),
|
||||||
|
completed: z.boolean().optional().openapi({ example: true }),
|
||||||
});
|
});
|
||||||
|
|
||||||
app.openapi(
|
app.openapi(
|
||||||
createRoute({
|
createRoute({
|
||||||
tags: ["ocme"],
|
tags: ["ocme"],
|
||||||
summary: "Post New running number to be picked up.",
|
summary: "Post New running number to be picked up.",
|
||||||
method: "post",
|
method: "post",
|
||||||
path: "/postrunningnumber",
|
path: "/postRunningNumber",
|
||||||
request: {
|
request: {
|
||||||
body: {
|
body: {
|
||||||
content: {
|
content: {
|
||||||
"application/json": {schema: PostRunningNr},
|
"application/json": { schema: PostRunningNr },
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
responses: {
|
},
|
||||||
200: {
|
},
|
||||||
content: {
|
responses: {
|
||||||
"application/json": {
|
200: {
|
||||||
schema: z.object({
|
content: {
|
||||||
success: z.boolean().openapi({example: true}),
|
"application/json": {
|
||||||
message: z.string().openapi({example: "Starter"}),
|
schema: z.object({
|
||||||
// data: z
|
success: z.boolean().openapi({ example: true }),
|
||||||
// .array(z.object({sscc: z.string().optional()}))
|
message: z.string().openapi({ example: "Starter" }),
|
||||||
// .optional()
|
// data: z
|
||||||
// .openapi({example: []}),
|
// .array(z.object({sscc: z.string().optional()}))
|
||||||
}),
|
// .optional()
|
||||||
},
|
// .openapi({example: []}),
|
||||||
},
|
}),
|
||||||
description: "Response message",
|
},
|
||||||
},
|
|
||||||
400: {
|
|
||||||
content: {
|
|
||||||
"application/json": {
|
|
||||||
schema: z.object({
|
|
||||||
success: z.boolean().openapi({example: false}),
|
|
||||||
message: z.string().optional().openapi({example: "Internal Server error"}),
|
|
||||||
data: z.array(z.object({})).optional().openapi({example: []}),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
description: "Internal Server Error",
|
|
||||||
},
|
|
||||||
// 401: {
|
|
||||||
// content: {
|
|
||||||
// "application/json": {
|
|
||||||
// schema: z.object({message: z.string().optional().openapi({example: "Unauthenticated"})}),
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// description: "Unauthorized",
|
|
||||||
// },
|
|
||||||
// 500: {
|
|
||||||
// content: {
|
|
||||||
// "application/json": {
|
|
||||||
// schema: z.object({message: z.string().optional().openapi({example: "Internal Server error"})}),
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// description: "Internal Server Error",
|
|
||||||
// },
|
|
||||||
},
|
},
|
||||||
}),
|
description: "Response message",
|
||||||
async (c) => {
|
},
|
||||||
// make sure we have a vaid user being accessed thats really logged in
|
400: {
|
||||||
try {
|
content: {
|
||||||
const data = await c.req.json();
|
"application/json": {
|
||||||
apiHit(c, {endpoint: "api/ocme/postRunningNumber", lastBody: data});
|
schema: z.object({
|
||||||
const postPallet = await postLabelData(data);
|
success: z.boolean().openapi({ example: false }),
|
||||||
return c.json({success: postPallet.success, message: postPallet.message, data: postPallet.data ?? []}, 200);
|
message: z
|
||||||
} catch (error) {
|
.string()
|
||||||
return c.json({success: false, message: "There was an error getting ocmeInfo data", data: error}, 400);
|
.optional()
|
||||||
}
|
.openapi({ example: "Internal Server error" }),
|
||||||
|
data: z.array(z.object({})).optional().openapi({ example: [] }),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: "Internal Server Error",
|
||||||
|
},
|
||||||
|
// 401: {
|
||||||
|
// content: {
|
||||||
|
// "application/json": {
|
||||||
|
// schema: z.object({message: z.string().optional().openapi({example: "Unauthenticated"})}),
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// description: "Unauthorized",
|
||||||
|
// },
|
||||||
|
// 500: {
|
||||||
|
// content: {
|
||||||
|
// "application/json": {
|
||||||
|
// schema: z.object({message: z.string().optional().openapi({example: "Internal Server error"})}),
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// description: "Internal Server Error",
|
||||||
|
// },
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
async (c) => {
|
||||||
|
// make sure we have a vaid user being accessed thats really logged in
|
||||||
|
try {
|
||||||
|
const data = await c.req.json();
|
||||||
|
apiHit(c, { endpoint: "api/ocme/postRunningNumber", lastBody: data });
|
||||||
|
const postPallet = await postLabelData(data);
|
||||||
|
return c.json(
|
||||||
|
{
|
||||||
|
success: postPallet.success,
|
||||||
|
message: postPallet.message,
|
||||||
|
data: postPallet.data ?? [],
|
||||||
|
},
|
||||||
|
200
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
return c.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "There was an error getting ocmeInfo data",
|
||||||
|
data: error,
|
||||||
|
},
|
||||||
|
400
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
);
|
);
|
||||||
export default app;
|
export default app;
|
||||||
|
|||||||
@@ -1,86 +1,106 @@
|
|||||||
import {createRoute, OpenAPIHono, z} from "@hono/zod-openapi";
|
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||||
import {getInfo} from "../controller/getInfo.js";
|
import { getInfo } from "../controller/getInfo.js";
|
||||||
import {postLabelData} from "../controller/postRunningNr.js";
|
import { postLabelData } from "../controller/postRunningNr.js";
|
||||||
import {apiHit} from "../../../globalUtils/apiHits.js";
|
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||||
|
|
||||||
const app = new OpenAPIHono();
|
const app = new OpenAPIHono();
|
||||||
|
|
||||||
const PostRunningNr = z.object({
|
const PostRunningNr = z.object({
|
||||||
sscc: z.string().optional().openapi({example: "00090103830005710997"}),
|
sscc: z.string().optional().openapi({ example: "00090103830005710997" }),
|
||||||
runningNr: z.string().optional().openapi({example: "localhost"}),
|
runningNr: z.string().optional().openapi({ example: "localhost" }),
|
||||||
areaFrom: z.string().optional().openapi({example: "The server we are going to connect to"}),
|
areaFrom: z
|
||||||
completed: z.boolean().optional().openapi({example: true}),
|
.string()
|
||||||
|
.optional()
|
||||||
|
.openapi({ example: "The server we are going to connect to" }),
|
||||||
|
completed: z.boolean().optional().openapi({ example: true }),
|
||||||
});
|
});
|
||||||
|
|
||||||
app.openapi(
|
app.openapi(
|
||||||
createRoute({
|
createRoute({
|
||||||
tags: ["ocme"],
|
tags: ["ocme"],
|
||||||
summary: "Post New running number to be picked up.",
|
summary: "Post New running number to be picked up.",
|
||||||
method: "post",
|
method: "post",
|
||||||
path: "/postsscc",
|
path: "/postSSCC",
|
||||||
request: {
|
request: {
|
||||||
body: {
|
body: {
|
||||||
content: {
|
content: {
|
||||||
"application/json": {schema: PostRunningNr},
|
"application/json": { schema: PostRunningNr },
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
responses: {
|
},
|
||||||
200: {
|
},
|
||||||
content: {
|
responses: {
|
||||||
"application/json": {
|
200: {
|
||||||
schema: z.object({
|
content: {
|
||||||
success: z.boolean().openapi({example: true}),
|
"application/json": {
|
||||||
message: z.string().openapi({example: "Starter"}),
|
schema: z.object({
|
||||||
// data: z
|
success: z.boolean().openapi({ example: true }),
|
||||||
// .array(z.object({sscc: z.string().optional()}))
|
message: z.string().openapi({ example: "Starter" }),
|
||||||
// .optional()
|
// data: z
|
||||||
// .openapi({example: []}),
|
// .array(z.object({sscc: z.string().optional()}))
|
||||||
}),
|
// .optional()
|
||||||
},
|
// .openapi({example: []}),
|
||||||
},
|
}),
|
||||||
description: "Response message",
|
},
|
||||||
},
|
|
||||||
400: {
|
|
||||||
content: {
|
|
||||||
"application/json": {
|
|
||||||
schema: z.object({
|
|
||||||
success: z.boolean().openapi({example: false}),
|
|
||||||
message: z.string().optional().openapi({example: "Internal Server error"}),
|
|
||||||
data: z.array(z.object({})).optional().openapi({example: []}),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
description: "Internal Server Error",
|
|
||||||
},
|
|
||||||
// 401: {
|
|
||||||
// content: {
|
|
||||||
// "application/json": {
|
|
||||||
// schema: z.object({message: z.string().optional().openapi({example: "Unauthenticated"})}),
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// description: "Unauthorized",
|
|
||||||
// },
|
|
||||||
// 500: {
|
|
||||||
// content: {
|
|
||||||
// "application/json": {
|
|
||||||
// schema: z.object({message: z.string().optional().openapi({example: "Internal Server error"})}),
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// description: "Internal Server Error",
|
|
||||||
// },
|
|
||||||
},
|
},
|
||||||
}),
|
description: "Response message",
|
||||||
async (c) => {
|
},
|
||||||
// make sure we have a vaid user being accessed thats really logged in
|
400: {
|
||||||
try {
|
content: {
|
||||||
const data = await c.req.json();
|
"application/json": {
|
||||||
apiHit(c, {endpoint: "api/ocme/postRunningNumber", lastBody: data});
|
schema: z.object({
|
||||||
const postPallet = await postLabelData(data);
|
success: z.boolean().openapi({ example: false }),
|
||||||
return c.json({success: postPallet.success, message: postPallet.message, data: postPallet.data ?? []}, 200);
|
message: z
|
||||||
} catch (error) {
|
.string()
|
||||||
return c.json({success: false, message: "There was an error getting ocmeInfo data", data: error}, 400);
|
.optional()
|
||||||
}
|
.openapi({ example: "Internal Server error" }),
|
||||||
|
data: z.array(z.object({})).optional().openapi({ example: [] }),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: "Internal Server Error",
|
||||||
|
},
|
||||||
|
// 401: {
|
||||||
|
// content: {
|
||||||
|
// "application/json": {
|
||||||
|
// schema: z.object({message: z.string().optional().openapi({example: "Unauthenticated"})}),
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// description: "Unauthorized",
|
||||||
|
// },
|
||||||
|
// 500: {
|
||||||
|
// content: {
|
||||||
|
// "application/json": {
|
||||||
|
// schema: z.object({message: z.string().optional().openapi({example: "Internal Server error"})}),
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// description: "Internal Server Error",
|
||||||
|
// },
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
async (c) => {
|
||||||
|
// make sure we have a vaid user being accessed thats really logged in
|
||||||
|
try {
|
||||||
|
const data = await c.req.json();
|
||||||
|
apiHit(c, { endpoint: "api/ocme/postRunningNumber", lastBody: data });
|
||||||
|
const postPallet = await postLabelData(data);
|
||||||
|
return c.json(
|
||||||
|
{
|
||||||
|
success: postPallet.success,
|
||||||
|
message: postPallet.message,
|
||||||
|
data: postPallet.data ?? [],
|
||||||
|
},
|
||||||
|
200
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
return c.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "There was an error getting ocmeInfo data",
|
||||||
|
data: error,
|
||||||
|
},
|
||||||
|
400
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
);
|
);
|
||||||
export default app;
|
export default app;
|
||||||
|
|||||||
28
server/services/ocme/route/triggerCamera.ts
Normal file
28
server/services/ocme/route/triggerCamera.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||||
|
import { getInfo } from "../controller/getInfo.js";
|
||||||
|
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||||
|
import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
||||||
|
import { triggerScanner } from "../controller/triggerCamera.js";
|
||||||
|
|
||||||
|
const app = new OpenAPIHono({ strict: false });
|
||||||
|
|
||||||
|
app.openapi(
|
||||||
|
createRoute({
|
||||||
|
tags: ["ocme"],
|
||||||
|
summary: "Triggers the camera at the end of the dyco.",
|
||||||
|
method: "get",
|
||||||
|
path: "/manualCameraTrigger",
|
||||||
|
responses: responses(),
|
||||||
|
}),
|
||||||
|
async (c) => {
|
||||||
|
// make sure we have a vaid user being accessed thats really logged in
|
||||||
|
apiHit(c, { endpoint: "api/auth/register" });
|
||||||
|
const manualTrigger: any = await triggerScanner();
|
||||||
|
console.log(manualTrigger);
|
||||||
|
return c.json({
|
||||||
|
success: manualTrigger.success,
|
||||||
|
message: manualTrigger.message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
export default app;
|
||||||
32
server/services/ocp/controller/labeling/getLabels.ts
Normal file
32
server/services/ocp/controller/labeling/getLabels.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import { desc, lte, sql } from "drizzle-orm";
|
||||||
|
import { db } from "../../../../../database/dbclient.js";
|
||||||
|
import { prodlabels } from "../../../../../database/schema/prodLabels.js";
|
||||||
|
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||||
|
export const getLabels = async (hours: string) => {
|
||||||
|
const { data: labelInfo, error: labelError } = await tryCatch(
|
||||||
|
db
|
||||||
|
.select()
|
||||||
|
.from(prodlabels)
|
||||||
|
.where(
|
||||||
|
lte(
|
||||||
|
prodlabels.upd_date,
|
||||||
|
sql.raw(`NOW() - INTERVAL '${hours} hours'`)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.orderBy(desc(prodlabels.upd_date))
|
||||||
|
);
|
||||||
|
|
||||||
|
if (labelError) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "There was an error getting the labels",
|
||||||
|
data: labelError,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "Current labels order by upd_Date.",
|
||||||
|
data: labelInfo,
|
||||||
|
};
|
||||||
|
};
|
||||||
23
server/services/ocp/controller/lots/lots.ts
Normal file
23
server/services/ocp/controller/lots/lots.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||||
|
import { query } from "../../../sqlServer/prodSqlServer.js";
|
||||||
|
import { lotQuery } from "../../../sqlServer/querys/ocp/lots.js";
|
||||||
|
|
||||||
|
export const getLots = async () => {
|
||||||
|
const { data: lotInfo, error: lotError } = await tryCatch(
|
||||||
|
query(lotQuery, "Alplalabel online lots")
|
||||||
|
);
|
||||||
|
|
||||||
|
if (lotError) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "There was an error getting the lots",
|
||||||
|
data: lotError,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "Current active lots that are technically released.",
|
||||||
|
data: lotInfo,
|
||||||
|
};
|
||||||
|
};
|
||||||
68
server/services/ocp/controller/lots/prolinkCheck.ts
Normal file
68
server/services/ocp/controller/lots/prolinkCheck.ts
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
import { db } from "../../../../../database/dbclient.js";
|
||||||
|
import { settings } from "../../../../../database/schema/settings.js";
|
||||||
|
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||||
|
import { createLog } from "../../../logger/logger.js";
|
||||||
|
import { query } from "../../../sqlServer/prodSqlServer.js";
|
||||||
|
import { prolinkQuery } from "../../../sqlServer/querys/ocp/prolinkCheck.js";
|
||||||
|
|
||||||
|
// check the if the lot matches
|
||||||
|
export const prolinkCheck = async (lot: any) => {
|
||||||
|
const { data, error: settingError } = await tryCatch(
|
||||||
|
db.select().from(settings)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (settingError) {
|
||||||
|
createLog(
|
||||||
|
"error",
|
||||||
|
"ocp",
|
||||||
|
"ocp",
|
||||||
|
`There was an error getting the settings.`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const settingData: any = data;
|
||||||
|
const plantToken = settingData.filter(
|
||||||
|
(s: any) => s.name === "plantToken"
|
||||||
|
)[0].value;
|
||||||
|
const prolinkCheck = settingData.filter(
|
||||||
|
(s: any) => s.name === "prolinkCheck"
|
||||||
|
)[0].value;
|
||||||
|
|
||||||
|
// if we want to ignore prolink check it will be disabled and then just return a pass as true
|
||||||
|
if (prolinkCheck === "0") {
|
||||||
|
createLog(
|
||||||
|
"info",
|
||||||
|
"ocp",
|
||||||
|
"ocp",
|
||||||
|
`Prolink Check is disabled skipping check.`
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// run the query
|
||||||
|
try {
|
||||||
|
const prolink = await query(prolinkQuery, "Prolink Checks");
|
||||||
|
|
||||||
|
//console.log(lot);
|
||||||
|
// filter out the lot
|
||||||
|
const filterdLot = prolink.filter(
|
||||||
|
(p: any) => p.AlplaLabelOnline === lot
|
||||||
|
);
|
||||||
|
|
||||||
|
//console.log(filterdLot);
|
||||||
|
if (filterdLot[0].LotCheck === "Good") {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
createLog(
|
||||||
|
"error",
|
||||||
|
"ocp",
|
||||||
|
"ocp",
|
||||||
|
`Error from running the Prolink Check query: ${err}`
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,20 +1,44 @@
|
|||||||
import {db} from "../../../../database/dbclient.js";
|
import { db } from "../../../../database/dbclient.js";
|
||||||
import {manualPrinting} from "../../../../database/schema/ocpManualPrint.js";
|
import { manualPrinting } from "../../../../database/schema/ocpManualPrint.js";
|
||||||
|
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||||
|
|
||||||
export const manualPrint = async (data: any) => {
|
export const manualPrint = async (manualPrint: any) => {
|
||||||
/**
|
/**
|
||||||
* add the reason we did a manual print.
|
* add the reason we did a manual print.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const manualPrintData = {
|
const manualPrintData = {
|
||||||
line: data.line,
|
line: manualPrint.line,
|
||||||
printReason: data.printReason,
|
printReason: manualPrint.printReason,
|
||||||
initials: data.initials,
|
initials: manualPrint.initials,
|
||||||
additionalComments: data?.additionalComments,
|
additionalComments: manualPrint?.additionalComments,
|
||||||
add_user: "lst",
|
add_user: "lst",
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
const { data, error } = await tryCatch(
|
||||||
const manualPrint = await db.insert(manualPrinting).values(manualPrintData);
|
db
|
||||||
} catch (error) {}
|
.insert(manualPrinting)
|
||||||
|
.values(manualPrintData)
|
||||||
|
.returning({
|
||||||
|
line: manualPrinting.line,
|
||||||
|
printReason: manualPrinting.printReason,
|
||||||
|
initials: manualPrinting.initials,
|
||||||
|
additionalComments: manualPrinting?.additionalComments,
|
||||||
|
add_user: manualPrinting.add_user,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "There was an error posting the manualPrintData",
|
||||||
|
data: error,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "There was an error posting the manualPrintData",
|
||||||
|
data,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
21
server/services/ocp/controller/printers/getPrinters.ts
Normal file
21
server/services/ocp/controller/printers/getPrinters.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { db } from "../../../../../database/dbclient.js";
|
||||||
|
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||||
|
import { printers } from "../../../../../database/schema/printers.js";
|
||||||
|
|
||||||
|
export const getPrinters = async () => {
|
||||||
|
const currentTime = new Date(Date.now());
|
||||||
|
|
||||||
|
const { data: printerData, error: printerError } = await tryCatch(
|
||||||
|
db.select().from(printers)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (printerError) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "there was an error getting the printers",
|
||||||
|
data: printerError,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return { success: true, message: "Printers", data: printerData };
|
||||||
|
};
|
||||||
84
server/services/ocp/controller/printers/updatePrinters.ts
Normal file
84
server/services/ocp/controller/printers/updatePrinters.ts
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
import { printers } from "../../../../../database/schema/printers.js";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
import { sql } from "drizzle-orm";
|
||||||
|
import { prodEndpointCreation } from "../../../../globalUtils/createUrl.js";
|
||||||
|
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||||
|
import { lstAuth } from "../../../../index.js";
|
||||||
|
import { db } from "../../../../../database/dbclient.js";
|
||||||
|
import { createLog } from "../../../logger/logger.js";
|
||||||
|
|
||||||
|
export const updatePrinters = async () => {
|
||||||
|
const currentTime = new Date(Date.now());
|
||||||
|
|
||||||
|
// get the printers from prod
|
||||||
|
let url = await prodEndpointCreation(
|
||||||
|
"/public/v1.0/Administration/Printers"
|
||||||
|
);
|
||||||
|
|
||||||
|
const { data: prodPrinters, error: prodError } = await tryCatch(
|
||||||
|
axios.get(url, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Basic ${lstAuth}`,
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
if (prodError) {
|
||||||
|
console.log(prodError);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "there was an error getting the printers.",
|
||||||
|
data: prodError,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// do the printer update into our db
|
||||||
|
const prodPrinterInfo = prodPrinters.data;
|
||||||
|
|
||||||
|
for (let i = 0; i < prodPrinterInfo.length; i++) {
|
||||||
|
const printerStuff: any = {
|
||||||
|
humanReadableId: prodPrinterInfo[i].humanReadableId,
|
||||||
|
name: prodPrinterInfo[i].name,
|
||||||
|
ipAddress: prodPrinterInfo[i].ipAddress,
|
||||||
|
port: prodPrinterInfo[i].port,
|
||||||
|
remark: prodPrinterInfo[i].remark,
|
||||||
|
};
|
||||||
|
const { data, error } = await tryCatch(
|
||||||
|
db
|
||||||
|
.insert(printers)
|
||||||
|
.values(printerStuff)
|
||||||
|
.onConflictDoUpdate({
|
||||||
|
target: printers.humanReadableId,
|
||||||
|
set: {
|
||||||
|
//humanReadableId: prodPrinterInfo[i].humanReadableId,
|
||||||
|
name: prodPrinterInfo[i].name,
|
||||||
|
ipAddress: prodPrinterInfo[i].ipAddress,
|
||||||
|
port: prodPrinterInfo[i].port,
|
||||||
|
remark: prodPrinterInfo[i].remark,
|
||||||
|
upd_date: sql`NOW()`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
createLog(
|
||||||
|
"error",
|
||||||
|
"lst",
|
||||||
|
"ocp",
|
||||||
|
`${
|
||||||
|
prodPrinterInfo[i].name
|
||||||
|
} encoutered and error adding/updating ${JSON.stringify(error)}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
createLog(
|
||||||
|
"info",
|
||||||
|
"lst",
|
||||||
|
"ocp",
|
||||||
|
`${prodPrinterInfo[i].name} were just added/updated.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return { success: true, message: "Printers were just added or updated." };
|
||||||
|
};
|
||||||
@@ -1,14 +1,27 @@
|
|||||||
import {OpenAPIHono} from "@hono/zod-openapi";
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
||||||
|
|
||||||
// routes
|
// routes
|
||||||
import manualLabelLog from "./routes/manualPrintLog.js";
|
import manualLabelLog from "./routes/manualPrintLog.js";
|
||||||
|
import getPrinters from "./routes/printers/getPritners.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 updateprinters from "./routes/printers/updatePrinters.js";
|
||||||
|
import { updatePrinters } from "./controller/printers/updatePrinters.js";
|
||||||
|
import getLots from "./routes/lots/getLots.js";
|
||||||
|
import getLabels from "./routes/labeling/getLabels.js";
|
||||||
|
|
||||||
const app = new OpenAPIHono();
|
const app = new OpenAPIHono();
|
||||||
|
|
||||||
const routes = [manualLabelLog] as const;
|
const routes = [
|
||||||
|
manualLabelLog,
|
||||||
|
//printer
|
||||||
|
getPrinters,
|
||||||
|
updateprinters,
|
||||||
|
// lots
|
||||||
|
getLots,
|
||||||
|
// labeling
|
||||||
|
getLabels,
|
||||||
|
] as const;
|
||||||
const setting = await db.select().from(settings);
|
const setting = await db.select().from(settings);
|
||||||
|
|
||||||
const appRoutes = routes.forEach((route) => {
|
const appRoutes = routes.forEach((route) => {
|
||||||
@@ -16,7 +29,15 @@ const appRoutes = routes.forEach((route) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.all("/ocp/*", (c) => {
|
app.all("/ocp/*", (c) => {
|
||||||
return c.json({success: false, message: "You have encounters a ocp route that dose not exist."});
|
return c.json({
|
||||||
|
success: false,
|
||||||
|
message: "You have encounters a ocp route that dose not exist.",
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// run the printer update on restart just to keep everything good
|
||||||
|
setTimeout(() => {
|
||||||
|
updatePrinters();
|
||||||
|
}, 3 * 1000);
|
||||||
|
|
||||||
export default app;
|
export default app;
|
||||||
|
|||||||
37
server/services/ocp/routes/labeling/getLabels.ts
Normal file
37
server/services/ocp/routes/labeling/getLabels.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
// an external way to creating logs
|
||||||
|
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||||
|
import { responses } from "../../../../globalUtils/routeDefs/responses.js";
|
||||||
|
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||||
|
import { getLabels } from "../../controller/labeling/getLabels.js";
|
||||||
|
|
||||||
|
const app = new OpenAPIHono({ strict: false });
|
||||||
|
|
||||||
|
app.openapi(
|
||||||
|
createRoute({
|
||||||
|
tags: ["ocp"],
|
||||||
|
summary: "Returns current active lots that are tech released",
|
||||||
|
method: "get",
|
||||||
|
path: "/getlabels",
|
||||||
|
responses: responses(),
|
||||||
|
}),
|
||||||
|
async (c) => {
|
||||||
|
const hours = c.req.query("hours");
|
||||||
|
const { data: labelData, error: labelError } = await tryCatch(
|
||||||
|
getLabels(hours ?? "2")
|
||||||
|
);
|
||||||
|
|
||||||
|
if (labelError) {
|
||||||
|
return c.json({
|
||||||
|
success: false,
|
||||||
|
message: "There was an error getting the printers",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.json({
|
||||||
|
success: labelData.success,
|
||||||
|
message: labelData.message,
|
||||||
|
data: labelData.data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
export default app;
|
||||||
35
server/services/ocp/routes/lots/getLots.ts
Normal file
35
server/services/ocp/routes/lots/getLots.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
// an external way to creating logs
|
||||||
|
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||||
|
import { responses } from "../../../../globalUtils/routeDefs/responses.js";
|
||||||
|
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||||
|
import { getPrinters } from "../../controller/printers/getPrinters.js";
|
||||||
|
import { getLots } from "../../controller/lots/lots.js";
|
||||||
|
|
||||||
|
const app = new OpenAPIHono({ strict: false });
|
||||||
|
|
||||||
|
app.openapi(
|
||||||
|
createRoute({
|
||||||
|
tags: ["ocp"],
|
||||||
|
summary: "Returns current active lots that are tech released",
|
||||||
|
method: "get",
|
||||||
|
path: "/getlots",
|
||||||
|
responses: responses(),
|
||||||
|
}),
|
||||||
|
async (c) => {
|
||||||
|
const { data: lotData, error: lotError } = await tryCatch(getLots());
|
||||||
|
|
||||||
|
if (lotError) {
|
||||||
|
return c.json({
|
||||||
|
success: false,
|
||||||
|
message: "There was an error getting the printers",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.json({
|
||||||
|
success: lotData.success,
|
||||||
|
message: lotData.message,
|
||||||
|
data: lotData.data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
export default app;
|
||||||
@@ -1,18 +1,21 @@
|
|||||||
// an external way to creating logs
|
// an external way to creating logs
|
||||||
import {createRoute, OpenAPIHono, z} from "@hono/zod-openapi";
|
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||||
import {apiHit} from "../../../globalUtils/apiHits.js";
|
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||||
import {responses} from "../../../globalUtils/routeDefs/responses.js";
|
import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
||||||
import type {User} from "../../../types/users.js";
|
import type { User } from "../../../types/users.js";
|
||||||
import {verify} from "hono/jwt";
|
import { verify } from "hono/jwt";
|
||||||
import {manualPrint} from "../controller/manualLabelLog.js";
|
import { manualPrint } from "../controller/manualLabelLog.js";
|
||||||
import {authMiddleware} from "../../auth/middleware/authMiddleware.js";
|
import { authMiddleware } from "../../auth/middleware/authMiddleware.js";
|
||||||
|
|
||||||
const app = new OpenAPIHono({strict: false});
|
const app = new OpenAPIHono({ strict: false });
|
||||||
const CreateLog = z.object({
|
const CreateLog = z.object({
|
||||||
line: z.string().openapi({example: "info"}),
|
line: z.string().openapi({ example: "info" }),
|
||||||
initials: z.string().openapi({example: "server"}),
|
initials: z.string().openapi({ example: "server" }),
|
||||||
printReason: z.string().openapi({example: "This is a new log posted"}),
|
printReason: z.string().openapi({ example: "This is a new log posted" }),
|
||||||
additionalComments: z.string().optional().openapi({example: "Some reason why we did this."}),
|
additionalComments: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.openapi({ example: "Some reason why we did this." }),
|
||||||
});
|
});
|
||||||
|
|
||||||
app.openapi(
|
app.openapi(
|
||||||
@@ -24,32 +27,33 @@ app.openapi(
|
|||||||
//middleware: authMiddleware,
|
//middleware: authMiddleware,
|
||||||
//description: "This might be a temp soltuin during the transtion between versions",
|
//description: "This might be a temp soltuin during the transtion between versions",
|
||||||
request: {
|
request: {
|
||||||
body: {content: {"application/json": {schema: CreateLog}}},
|
body: { content: { "application/json": { schema: CreateLog } } },
|
||||||
},
|
},
|
||||||
responses: responses(),
|
responses: responses(),
|
||||||
}),
|
}),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const body = await c.req.json();
|
const body = await c.req.json();
|
||||||
apiHit(c, {endpoint: `api/logger/logs/id`});
|
apiHit(c, { endpoint: `api/logger/logs/id` });
|
||||||
// const authHeader = c.req.header("Authorization");
|
|
||||||
|
|
||||||
// const token = authHeader?.split("Bearer ")[1] || "";
|
|
||||||
// let user: User;
|
|
||||||
|
|
||||||
// try {
|
|
||||||
// const payload = await verify(token, process.env.JWT_SECRET!);
|
|
||||||
// user = payload.user as User;
|
|
||||||
// } catch (error) {
|
|
||||||
// console.log(error);
|
|
||||||
// return c.json({message: "Unauthorized"}, 401);
|
|
||||||
// }
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//const data = {...body, add_user: user.username};
|
//const data = {...body, add_user: user.username};
|
||||||
await manualPrint(body);
|
const printLog: any = await manualPrint(body);
|
||||||
return c.json({success: true, message: "Manual Print was added.", data: []}, 200);
|
return c.json(
|
||||||
|
{
|
||||||
|
success: printLog.success,
|
||||||
|
message: printLog.message,
|
||||||
|
data: printLog.data ?? [],
|
||||||
|
},
|
||||||
|
200
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return c.json({success: false, message: "There was an error clearing the log.", data: error}, 400);
|
return c.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "There was an error clearing the log.",
|
||||||
|
data: error,
|
||||||
|
},
|
||||||
|
400
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
50
server/services/ocp/routes/printers/getPritners.ts
Normal file
50
server/services/ocp/routes/printers/getPritners.ts
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
// an external way to creating logs
|
||||||
|
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||||
|
import { responses } from "../../../../globalUtils/routeDefs/responses.js";
|
||||||
|
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||||
|
import { getPrinters } from "../../controller/printers/getPrinters.js";
|
||||||
|
|
||||||
|
const app = new OpenAPIHono({ strict: false });
|
||||||
|
const CreateLog = z.object({
|
||||||
|
line: z.string().openapi({ example: "info" }),
|
||||||
|
initials: z.string().openapi({ example: "server" }),
|
||||||
|
printReason: z.string().openapi({ example: "This is a new log posted" }),
|
||||||
|
additionalComments: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.openapi({ example: "Some reason why we did this." }),
|
||||||
|
});
|
||||||
|
|
||||||
|
app.openapi(
|
||||||
|
createRoute({
|
||||||
|
tags: ["ocp"],
|
||||||
|
summary: "Prints a label.",
|
||||||
|
method: "get",
|
||||||
|
path: "/getprinters",
|
||||||
|
//middleware: authMiddleware,
|
||||||
|
//description: "This might be a temp soltuin during the transtion between versions",
|
||||||
|
request: {
|
||||||
|
body: { content: { "application/json": { schema: CreateLog } } },
|
||||||
|
},
|
||||||
|
responses: responses(),
|
||||||
|
}),
|
||||||
|
async (c) => {
|
||||||
|
const { data: printData, error: printError } = await tryCatch(
|
||||||
|
getPrinters()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (printError) {
|
||||||
|
return c.json({
|
||||||
|
success: false,
|
||||||
|
message: "There was an error getting the printers",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.json({
|
||||||
|
success: printData.success,
|
||||||
|
message: printData.message,
|
||||||
|
data: printData.data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
export default app;
|
||||||
50
server/services/ocp/routes/printers/updatePrinters.ts
Normal file
50
server/services/ocp/routes/printers/updatePrinters.ts
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
// an external way to creating logs
|
||||||
|
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||||
|
import { responses } from "../../../../globalUtils/routeDefs/responses.js";
|
||||||
|
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||||
|
import { updatePrinters } from "../../controller/printers/updatePrinters.js";
|
||||||
|
|
||||||
|
const app = new OpenAPIHono({ strict: false });
|
||||||
|
const CreateLog = z.object({
|
||||||
|
line: z.string().openapi({ example: "info" }),
|
||||||
|
initials: z.string().openapi({ example: "server" }),
|
||||||
|
printReason: z.string().openapi({ example: "This is a new log posted" }),
|
||||||
|
additionalComments: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.openapi({ example: "Some reason why we did this." }),
|
||||||
|
});
|
||||||
|
|
||||||
|
app.openapi(
|
||||||
|
createRoute({
|
||||||
|
tags: ["ocp"],
|
||||||
|
summary: "Prints a label.",
|
||||||
|
method: "get",
|
||||||
|
path: "/updateprinters",
|
||||||
|
//middleware: authMiddleware,
|
||||||
|
//description: "This might be a temp soltuin during the transtion between versions",
|
||||||
|
request: {
|
||||||
|
body: { content: { "application/json": { schema: CreateLog } } },
|
||||||
|
},
|
||||||
|
responses: responses(),
|
||||||
|
}),
|
||||||
|
async (c) => {
|
||||||
|
const { data: printData, error: printError } = await tryCatch(
|
||||||
|
updatePrinters()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (printError) {
|
||||||
|
return c.json({
|
||||||
|
success: false,
|
||||||
|
message: "There was an error getting the printers",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.json({
|
||||||
|
success: printData.success,
|
||||||
|
message: printData.message,
|
||||||
|
data: printData.data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
export default app;
|
||||||
@@ -3,44 +3,64 @@
|
|||||||
* Phase 2 we will just reprint the tag that was generated at the line
|
* Phase 2 we will just reprint the tag that was generated at the line
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {createLog} from "../../../logger/logger.js";
|
import { createLog } from "../../../logger/logger.js";
|
||||||
import type {TagData} from "../tagData.js";
|
import type { TagData } from "../tagData.js";
|
||||||
import {tagStuff} from "../tags/crudTag.js";
|
import { tagStuff } from "../tags/crudTag.js";
|
||||||
|
|
||||||
export const wrapperStuff = async (tagData: TagData[]) => {
|
export const wrapperStuff = async (tagData: TagData[]) => {
|
||||||
if (tagData.length != 1) {
|
if (tagData.length != 1) {
|
||||||
createLog(
|
createLog(
|
||||||
"error",
|
"error",
|
||||||
"rfid",
|
"rfid",
|
||||||
"rfid",
|
"rfid",
|
||||||
`There are ${tagData.length} tags and this ${tagData[0].reader} only allows 1 tag to create a label.`
|
`There are ${tagData.length} tags and this ${tagData[0].reader} only allows 1 tag to create a label.`
|
||||||
);
|
);
|
||||||
tagStuff(tagData);
|
tagStuff(tagData);
|
||||||
} else {
|
} else {
|
||||||
const tagdata = await tagStuff(tagData);
|
const tagdata = await tagStuff(tagData);
|
||||||
|
if (!tagData) {
|
||||||
/**
|
createLog("error", "rfid", "rfid", `No tagData was grabbed.`);
|
||||||
* we want to make sure this pallet came from a line as its last spot if not we need to have a manual check.
|
|
||||||
*/
|
|
||||||
const station3 = tagdata.some((n: any) => n.lastareaIn.includes("line3"));
|
|
||||||
|
|
||||||
if (!station3) {
|
|
||||||
createLog(
|
|
||||||
"error",
|
|
||||||
"rfid",
|
|
||||||
"rfid",
|
|
||||||
`${tagdata.tag}, Did not come from a line please check the pallet and manually print the label.`
|
|
||||||
);
|
|
||||||
|
|
||||||
// when we manually run again we want to make sure we read from the 3rd antenna this way we do not get the wrong info.
|
|
||||||
// more testing will need to be done on this.
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if a running number exists
|
|
||||||
if (station3.runningNumber) {
|
|
||||||
createLog("info", "rfid", "rfid", `Reprint label ${station3.runningNumber}`);
|
|
||||||
} else {
|
|
||||||
createLog("info", "rfid", "rfid", `A new labels will be created and linked to this ${tagdata.tag} tag`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* we want to make sure this pallet came from a line as its last spot if not we need to have a manual check.
|
||||||
|
*/
|
||||||
|
if (
|
||||||
|
!Array.isArray(tagdata) &&
|
||||||
|
tagdata?.some((n: any) => n.lastareaIn.includes("line3"))
|
||||||
|
) {
|
||||||
|
createLog("error", "rfid", "rfid", `Data passed over is not an array.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const station3 = tagdata; //?.some((n: any) => n.lastareaIn.includes("line3"));
|
||||||
|
|
||||||
|
if (!station3) {
|
||||||
|
createLog(
|
||||||
|
"error",
|
||||||
|
"rfid",
|
||||||
|
"rfid",
|
||||||
|
`${tagdata[0].tag}, Did not come from a line please check the pallet and manually print the label.`
|
||||||
|
);
|
||||||
|
|
||||||
|
// when we manually run again we want to make sure we read from the 3rd antenna this way we do not get the wrong info.
|
||||||
|
// more testing will need to be done on this.
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if a running number exists
|
||||||
|
if (station3.runningNumber) {
|
||||||
|
createLog(
|
||||||
|
"info",
|
||||||
|
"rfid",
|
||||||
|
"rfid",
|
||||||
|
`Reprint label ${station3.runningNumber}`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
createLog(
|
||||||
|
"info",
|
||||||
|
"rfid",
|
||||||
|
"rfid",
|
||||||
|
`A new labels will be created and linked to this ${tagdata.tag} tag`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
55
server/services/sqlServer/querys/ocp/lots.ts
Normal file
55
server/services/sqlServer/querys/ocp/lots.ts
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
export const lotQuery = `
|
||||||
|
select IdMaschinen_ProdPlanung as LabelOnlineID,
|
||||||
|
IdMaschine as machineID,
|
||||||
|
MaschinenStandort as MachineLocation,
|
||||||
|
MaschinenBez as MachineDescription,
|
||||||
|
IdProdPlanung as LOT,
|
||||||
|
prolink.lot as ProlinkLot,
|
||||||
|
IdArtikelvarianten as AV,
|
||||||
|
ArtikelVariantenBez as Alias,
|
||||||
|
convert(varchar, add_date, 20) as Add_Date,
|
||||||
|
Add_user,
|
||||||
|
idEtikettenDrucker as printerID,
|
||||||
|
b.name as PrinterName,
|
||||||
|
CAST(TotalPlannedLoadingUnits as float) as PlannedQTY,
|
||||||
|
CAST(TotalProducedLoadingUnits as float) as Produced,
|
||||||
|
ROUND(CAST(TotalPlannedLoadingUnits as float) - CAST(TotalProducedLoadingUnits as float),2) as Remaining,
|
||||||
|
case
|
||||||
|
-- checks if someone changed the criteria to something else to trigger the over run
|
||||||
|
when x.ProzentReserveAnzahlPaletten > 0 then 'yes'
|
||||||
|
|
||||||
|
-- if the lot has a decimal in it to allow over running with no intervention
|
||||||
|
when CAST(TotalPlannedLoadingUnits as float) - floor(CAST(TotalPlannedLoadingUnits as float)) > 0 then 'yes'
|
||||||
|
else 'no' end as overPrinting,
|
||||||
|
CustomerHumanReadableId as CustomerId,
|
||||||
|
CustomerName as CustomerName,
|
||||||
|
idMaschine as MachineID,
|
||||||
|
prolink.lastProlinkUpdate as lastProlinkUpdate,
|
||||||
|
IdEtikettenLayoutPalette as palletLabel,
|
||||||
|
AnzahlKopienPalette as pallerCopies,
|
||||||
|
IdEtikettenLayoutKarton as cartonLabel,
|
||||||
|
AnzahlKopienKarton as cartonCopies,
|
||||||
|
IsTechnicallyReleased
|
||||||
|
--*
|
||||||
|
from AlplaPROD_test1.dbo.V_Maschinen_ProdPlanungen x (nolock)
|
||||||
|
join
|
||||||
|
[test1_AlplaPROD2.0_Read].[productionControlling].[ProducedLot] on
|
||||||
|
x.IdProdPlanung =
|
||||||
|
[test1_AlplaPROD2.0_Read].[productionControlling].[ProducedLot].ProductionLotHumanReadableId
|
||||||
|
left join
|
||||||
|
[test1_AlplaPROD2.0_Read].masterData.Printer as b on
|
||||||
|
x.IdEtikettenDrucker = b.HumanReadableId
|
||||||
|
-- adding in prolink lot
|
||||||
|
left join
|
||||||
|
(SELECT * from (SELECT IdMaschine as prolinkMachineId,
|
||||||
|
Produktionslos as lot,
|
||||||
|
Upd_Date as lastProlinkUpdate,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY IdMaschine ORDER BY Upd_Date DESC) RN_Prolink
|
||||||
|
FROM AlplaPROD_test1.dbo.T_HistoryProduktionsdaten (nolock)
|
||||||
|
WHERE Upd_Date BETWEEN DATEADD(DD, - 300, getdate()) AND DATEADD(DD, 1, getdate())) p
|
||||||
|
WHERE RN_Prolink = 1
|
||||||
|
) as prolink on
|
||||||
|
x.idMaschine = prolink.prolinkMachineId
|
||||||
|
|
||||||
|
where IsTechnicallyReleased = 1
|
||||||
|
`;
|
||||||
25
server/services/sqlServer/querys/ocp/prolinkCheck.ts
Normal file
25
server/services/sqlServer/querys/ocp/prolinkCheck.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
export const prolinkQuery = `
|
||||||
|
select * from (
|
||||||
|
select *
|
||||||
|
From(select
|
||||||
|
V_Maschinen_ProdPlanungen.MaschinenStandort as Machine,
|
||||||
|
V_Maschinen_ProdPlanungen.IdProdPlanung as AlplaLabelOnline,
|
||||||
|
prolink.lot Prolink,
|
||||||
|
case when AlplaPROD_test1.dbo.V_Maschinen_ProdPlanungen.IdProdPlanung <> prolink.lot
|
||||||
|
Then 'IncorrectLot'
|
||||||
|
Else 'Good' end as LotCheck
|
||||||
|
from AlplaPROD_test1.dbo.V_Maschinen_ProdPlanungen (nolock)
|
||||||
|
left join
|
||||||
|
(
|
||||||
|
SELECT *
|
||||||
|
FROM (SELECT IdMaschine,
|
||||||
|
Produktionslos as lot,
|
||||||
|
Startzeit as StartTime,
|
||||||
|
Upd_Date,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY IdMaschine ORDER BY Upd_Date DESC) RN_Prolink
|
||||||
|
FROM AlplaPROD_test1.dbo.T_HistoryProduktionsdaten (nolock)
|
||||||
|
WHERE Upd_Date BETWEEN DATEADD(DD, - 10, getdate()) AND DATEADD(DD, 1, getdate())) a
|
||||||
|
WHERE RN_Prolink = 1
|
||||||
|
) as prolink on AlplaPROD_test1.dbo.V_Maschinen_ProdPlanungen.IdMaschine=prolink.IdMaschine) a
|
||||||
|
) a
|
||||||
|
`;
|
||||||
@@ -1,23 +1,28 @@
|
|||||||
import net from "net";
|
import net from "net";
|
||||||
import {OpenAPIHono} from "@hono/zod-openapi";
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
||||||
import {createLog} from "../logger/logger.js";
|
import { createLog } from "../logger/logger.js";
|
||||||
|
|
||||||
import startTCP from "./route/startServer.js";
|
import startTCP from "./route/startServer.js";
|
||||||
import stopTCP from "./route/stopServer.js";
|
import stopTCP from "./route/stopServer.js";
|
||||||
import restartTCP from "./route/restartServer.js";
|
import restartTCP from "./route/restartServer.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 {eq} from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
|
import { postLabelData } from "../ocme/controller/postRunningNr.js";
|
||||||
|
|
||||||
let tcpServer: net.Server;
|
let tcpServer: net.Server;
|
||||||
let tcpSockets: Set<net.Socket> = new Set();
|
let tcpSockets: Set<net.Socket> = new Set();
|
||||||
let isServerRunning = false;
|
let isServerRunning = false;
|
||||||
|
|
||||||
const tcpPort = await db.select().from(settings).where(eq(settings.name, "tcpPort"));
|
const tcpPort = await db
|
||||||
|
.select()
|
||||||
|
.from(settings)
|
||||||
|
.where(eq(settings.name, "tcpPort"));
|
||||||
const app = new OpenAPIHono();
|
const app = new OpenAPIHono();
|
||||||
|
|
||||||
export const startTCPServer = () => {
|
export const startTCPServer = () => {
|
||||||
if (isServerRunning) return {success: false, message: "Server is already running"};
|
if (isServerRunning)
|
||||||
|
return { success: false, message: "Server is already running" };
|
||||||
|
|
||||||
tcpServer = net.createServer((socket) => {
|
tcpServer = net.createServer((socket) => {
|
||||||
console.log("Client connected");
|
console.log("Client connected");
|
||||||
@@ -25,7 +30,19 @@ export const startTCPServer = () => {
|
|||||||
tcpSockets.add(socket);
|
tcpSockets.add(socket);
|
||||||
socket.on("data", (data: Buffer) => {
|
socket.on("data", (data: Buffer) => {
|
||||||
console.log("Received:", data.toString());
|
console.log("Received:", data.toString());
|
||||||
socket.write("Message received");
|
const parseData = data.toString("utf-8").trimEnd().split(" ");
|
||||||
|
// hb from the scanners
|
||||||
|
if (parseData[0] === "HB") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// alert from the printers
|
||||||
|
if (parseData[0] === "ALERT:" || parseData[0] === "ALERT") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// from the wrapper send the data
|
||||||
|
postLabelData(parseData);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("end", () => {
|
socket.on("end", () => {
|
||||||
@@ -40,16 +57,22 @@ export const startTCPServer = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
tcpServer.listen(tcpPort[0]?.value ?? 2222, () => {
|
tcpServer.listen(tcpPort[0]?.value ?? 2222, () => {
|
||||||
createLog("info", "lst", "tcp", `TCP Server listening on port ${tcpPort[0]?.value ?? 2222}`);
|
createLog(
|
||||||
|
"info",
|
||||||
|
"lst",
|
||||||
|
"tcp",
|
||||||
|
`TCP Server listening on port ${tcpPort[0]?.value ?? 2222}`
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
isServerRunning = true;
|
isServerRunning = true;
|
||||||
return {success: true, message: "TCP Server started"};
|
return { success: true, message: "TCP Server started" };
|
||||||
};
|
};
|
||||||
|
|
||||||
// Function to stop the TCP server
|
// Function to stop the TCP server
|
||||||
export const stopTCPServer = () => {
|
export const stopTCPServer = () => {
|
||||||
if (!isServerRunning) return {success: false, message: "Server is not running"};
|
if (!isServerRunning)
|
||||||
|
return { success: false, message: "Server is not running" };
|
||||||
for (const socket of tcpSockets) {
|
for (const socket of tcpSockets) {
|
||||||
socket.destroy();
|
socket.destroy();
|
||||||
}
|
}
|
||||||
@@ -58,7 +81,7 @@ export const stopTCPServer = () => {
|
|||||||
console.log("TCP Server stopped");
|
console.log("TCP Server stopped");
|
||||||
});
|
});
|
||||||
isServerRunning = false;
|
isServerRunning = false;
|
||||||
return {success: true, message: "TCP Server stopped"};
|
return { success: true, message: "TCP Server stopped" };
|
||||||
};
|
};
|
||||||
|
|
||||||
app.route("/tcpserver/start", startTCP);
|
app.route("/tcpserver/start", startTCP);
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ESNext",
|
"target": "ESNext",
|
||||||
"module": "NodeNext",
|
"module": "NodeNext",
|
||||||
"moduleResolution": "nodenext",
|
"moduleResolution": "nodenext",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"verbatimModuleSyntax": true,
|
"verbatimModuleSyntax": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"types": ["node"],
|
"types": ["node"],
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"jsxImportSource": "hono/jsx",
|
"jsxImportSource": "hono/jsx",
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"removeComments": true,
|
"removeComments": true,
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"resolveJsonModule": true
|
"resolveJsonModule": true
|
||||||
},
|
},
|
||||||
"include": ["server", "scripts/**/*.ts"],
|
"include": ["server", "scripts/**/*.ts"],
|
||||||
"exclude": ["node_modules", "frontend", "dist", "testFiles"]
|
"exclude": ["node_modules", "frontend", "dist", "testFiles"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user