Compare commits
10 Commits
0c719dc647
...
082b36ba2b
| Author | SHA1 | Date | |
|---|---|---|---|
| 082b36ba2b | |||
| b9de750668 | |||
| 4e3be2c565 | |||
| 8f828d764a | |||
| 9f68cd2146 | |||
| 3a78f77475 | |||
| 3817c33638 | |||
| ac68a65f5d | |||
| 0c80d3b87d | |||
| e9fd3730d6 |
@@ -0,0 +1,102 @@
|
||||
import { LstCard } from "@/components/extendedUI/LstCard";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { CardContent, CardFooter, CardHeader } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { useForm } from "@tanstack/react-form";
|
||||
import axios from "axios";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
export default function Bookin() {
|
||||
const [bookingIn, setBookingIn] = useState(false);
|
||||
const form = useForm({
|
||||
defaultValues: { runningNr: " " },
|
||||
onSubmit: async ({ value }) => {
|
||||
// Do something with form data
|
||||
setBookingIn(true);
|
||||
|
||||
try {
|
||||
const res = await axios.post("/api/ocp/bookin", {
|
||||
runningNr: parseInt(value.runningNr),
|
||||
});
|
||||
|
||||
if (res.data.success) {
|
||||
toast.success(res.data.message);
|
||||
form.reset();
|
||||
setBookingIn(false);
|
||||
} else {
|
||||
console.log(res.data.data.errors);
|
||||
toast.error(res.data.data.errors[0]?.message);
|
||||
form.reset();
|
||||
setBookingIn(false);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
toast.error(
|
||||
"There was an error booking in pallet please validate you entered the correct info and try again."
|
||||
);
|
||||
setBookingIn(false);
|
||||
}
|
||||
},
|
||||
});
|
||||
return (
|
||||
<LstCard>
|
||||
<CardHeader>
|
||||
<p>Book in a pallet by running number</p>
|
||||
</CardHeader>
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}}
|
||||
>
|
||||
<CardContent>
|
||||
<form.Field
|
||||
name="runningNr"
|
||||
validators={{
|
||||
// We can choose between form-wide and field-specific validators
|
||||
onChange: ({ value }) =>
|
||||
value.length > 2
|
||||
? undefined
|
||||
: "Please enter a valid running number",
|
||||
}}
|
||||
children={(field) => {
|
||||
return (
|
||||
<div className="m-2 min-w-48 max-w-96 p-2">
|
||||
<Label htmlFor="runningNr" className="mb-2">
|
||||
Runnning Number
|
||||
</Label>
|
||||
<Input
|
||||
name={field.name}
|
||||
value={field.state.value}
|
||||
onBlur={field.handleBlur}
|
||||
type="number"
|
||||
onChange={(e) =>
|
||||
field.handleChange(e.target.value)
|
||||
}
|
||||
/>
|
||||
{field.state.meta.errors.length ? (
|
||||
<em>
|
||||
{field.state.meta.errors.join(",")}
|
||||
</em>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</CardContent>
|
||||
<CardFooter>
|
||||
<div className="flex justify-end">
|
||||
<Button
|
||||
onClick={form.handleSubmit}
|
||||
disabled={bookingIn}
|
||||
>
|
||||
Book in
|
||||
</Button>
|
||||
</div>
|
||||
</CardFooter>
|
||||
</form>
|
||||
</LstCard>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import Bookin from "./commands/Bookin";
|
||||
|
||||
export default function HelperPage() {
|
||||
return (
|
||||
<div>
|
||||
<Bookin />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -70,7 +70,7 @@ export default function Lots() {
|
||||
const { settings } = useSettingStore();
|
||||
const server = settings.filter((n) => n.name === "server")[0]?.value || "";
|
||||
|
||||
const roles = ["admin", "manager", "operator"];
|
||||
const roles = ["technician", "admin", "manager", "operator"];
|
||||
const lotdata = data ? data : [];
|
||||
|
||||
if (user && roles.includes(user.role)) {
|
||||
|
||||
@@ -33,6 +33,7 @@ import { Route as ocmeCyclecountIndexImport } from './routes/(ocme)/cyclecount/i
|
||||
import { Route as logisticsSiloAdjustmentsIndexImport } from './routes/(logistics)/siloAdjustments/index'
|
||||
import { Route as logisticsOpenOrdersIndexImport } from './routes/(logistics)/openOrders/index'
|
||||
import { Route as logisticsMaterialHelperIndexImport } from './routes/(logistics)/materialHelper/index'
|
||||
import { Route as logisticsHelperCommandsIndexImport } from './routes/(logistics)/helperCommands/index'
|
||||
import { Route as logisticsDmIndexImport } from './routes/(logistics)/dm/index'
|
||||
import { Route as EomArticleAvImport } from './routes/_eom/article/$av'
|
||||
import { Route as logisticsSiloAdjustmentsHistImport } from './routes/(logistics)/siloAdjustments/$hist'
|
||||
@@ -173,6 +174,13 @@ const logisticsMaterialHelperIndexRoute =
|
||||
getParentRoute: () => rootRoute,
|
||||
} as any)
|
||||
|
||||
const logisticsHelperCommandsIndexRoute =
|
||||
logisticsHelperCommandsIndexImport.update({
|
||||
id: '/(logistics)/helperCommands/',
|
||||
path: '/helperCommands/',
|
||||
getParentRoute: () => rootRoute,
|
||||
} as any)
|
||||
|
||||
const logisticsDmIndexRoute = logisticsDmIndexImport.update({
|
||||
id: '/(logistics)/dm/',
|
||||
path: '/dm/',
|
||||
@@ -364,6 +372,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof logisticsDmIndexImport
|
||||
parentRoute: typeof rootRoute
|
||||
}
|
||||
'/(logistics)/helperCommands/': {
|
||||
id: '/(logistics)/helperCommands/'
|
||||
path: '/helperCommands'
|
||||
fullPath: '/helperCommands'
|
||||
preLoaderRoute: typeof logisticsHelperCommandsIndexImport
|
||||
parentRoute: typeof rootRoute
|
||||
}
|
||||
'/(logistics)/materialHelper/': {
|
||||
id: '/(logistics)/materialHelper/'
|
||||
path: '/materialHelper'
|
||||
@@ -480,6 +495,7 @@ export interface FileRoutesByFullPath {
|
||||
'/siloAdjustments/$hist': typeof logisticsSiloAdjustmentsHistRoute
|
||||
'/article/$av': typeof EomArticleAvRoute
|
||||
'/dm': typeof logisticsDmIndexRoute
|
||||
'/helperCommands': typeof logisticsHelperCommandsIndexRoute
|
||||
'/materialHelper': typeof logisticsMaterialHelperIndexRoute
|
||||
'/openOrders': typeof logisticsOpenOrdersIndexRoute
|
||||
'/siloAdjustments': typeof logisticsSiloAdjustmentsIndexRoute
|
||||
@@ -509,6 +525,7 @@ export interface FileRoutesByTo {
|
||||
'/siloAdjustments/$hist': typeof logisticsSiloAdjustmentsHistRoute
|
||||
'/article/$av': typeof EomArticleAvRoute
|
||||
'/dm': typeof logisticsDmIndexRoute
|
||||
'/helperCommands': typeof logisticsHelperCommandsIndexRoute
|
||||
'/materialHelper': typeof logisticsMaterialHelperIndexRoute
|
||||
'/openOrders': typeof logisticsOpenOrdersIndexRoute
|
||||
'/siloAdjustments': typeof logisticsSiloAdjustmentsIndexRoute
|
||||
@@ -541,6 +558,7 @@ export interface FileRoutesById {
|
||||
'/(logistics)/siloAdjustments/$hist': typeof logisticsSiloAdjustmentsHistRoute
|
||||
'/_eom/article/$av': typeof EomArticleAvRoute
|
||||
'/(logistics)/dm/': typeof logisticsDmIndexRoute
|
||||
'/(logistics)/helperCommands/': typeof logisticsHelperCommandsIndexRoute
|
||||
'/(logistics)/materialHelper/': typeof logisticsMaterialHelperIndexRoute
|
||||
'/(logistics)/openOrders/': typeof logisticsOpenOrdersIndexRoute
|
||||
'/(logistics)/siloAdjustments/': typeof logisticsSiloAdjustmentsIndexRoute
|
||||
@@ -572,6 +590,7 @@ export interface FileRouteTypes {
|
||||
| '/siloAdjustments/$hist'
|
||||
| '/article/$av'
|
||||
| '/dm'
|
||||
| '/helperCommands'
|
||||
| '/materialHelper'
|
||||
| '/openOrders'
|
||||
| '/siloAdjustments'
|
||||
@@ -600,6 +619,7 @@ export interface FileRouteTypes {
|
||||
| '/siloAdjustments/$hist'
|
||||
| '/article/$av'
|
||||
| '/dm'
|
||||
| '/helperCommands'
|
||||
| '/materialHelper'
|
||||
| '/openOrders'
|
||||
| '/siloAdjustments'
|
||||
@@ -630,6 +650,7 @@ export interface FileRouteTypes {
|
||||
| '/(logistics)/siloAdjustments/$hist'
|
||||
| '/_eom/article/$av'
|
||||
| '/(logistics)/dm/'
|
||||
| '/(logistics)/helperCommands/'
|
||||
| '/(logistics)/materialHelper/'
|
||||
| '/(logistics)/openOrders/'
|
||||
| '/(logistics)/siloAdjustments/'
|
||||
@@ -653,6 +674,7 @@ export interface RootRouteChildren {
|
||||
OcpIndexRoute: typeof OcpIndexRoute
|
||||
logisticsSiloAdjustmentsHistRoute: typeof logisticsSiloAdjustmentsHistRoute
|
||||
logisticsDmIndexRoute: typeof logisticsDmIndexRoute
|
||||
logisticsHelperCommandsIndexRoute: typeof logisticsHelperCommandsIndexRoute
|
||||
logisticsMaterialHelperIndexRoute: typeof logisticsMaterialHelperIndexRoute
|
||||
logisticsOpenOrdersIndexRoute: typeof logisticsOpenOrdersIndexRoute
|
||||
logisticsSiloAdjustmentsIndexRoute: typeof logisticsSiloAdjustmentsIndexRoute
|
||||
@@ -675,6 +697,7 @@ const rootRouteChildren: RootRouteChildren = {
|
||||
OcpIndexRoute: OcpIndexRoute,
|
||||
logisticsSiloAdjustmentsHistRoute: logisticsSiloAdjustmentsHistRoute,
|
||||
logisticsDmIndexRoute: logisticsDmIndexRoute,
|
||||
logisticsHelperCommandsIndexRoute: logisticsHelperCommandsIndexRoute,
|
||||
logisticsMaterialHelperIndexRoute: logisticsMaterialHelperIndexRoute,
|
||||
logisticsOpenOrdersIndexRoute: logisticsOpenOrdersIndexRoute,
|
||||
logisticsSiloAdjustmentsIndexRoute: logisticsSiloAdjustmentsIndexRoute,
|
||||
@@ -709,6 +732,7 @@ export const routeTree = rootRoute
|
||||
"/ocp/",
|
||||
"/(logistics)/siloAdjustments/$hist",
|
||||
"/(logistics)/dm/",
|
||||
"/(logistics)/helperCommands/",
|
||||
"/(logistics)/materialHelper/",
|
||||
"/(logistics)/openOrders/",
|
||||
"/(logistics)/siloAdjustments/",
|
||||
@@ -805,6 +829,9 @@ export const routeTree = rootRoute
|
||||
"/(logistics)/dm/": {
|
||||
"filePath": "(logistics)/dm/index.tsx"
|
||||
},
|
||||
"/(logistics)/helperCommands/": {
|
||||
"filePath": "(logistics)/helperCommands/index.tsx"
|
||||
},
|
||||
"/(logistics)/materialHelper/": {
|
||||
"filePath": "(logistics)/materialHelper/index.tsx"
|
||||
},
|
||||
|
||||
28
frontend/src/routes/(logistics)/helperCommands/index.tsx
Normal file
28
frontend/src/routes/(logistics)/helperCommands/index.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import HelperPage from "@/components/logistics/helperCommands/helperPage";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
export const Route = createFileRoute("/(logistics)/helperCommands/")({
|
||||
component: RouteComponent,
|
||||
// beforeLoad: async () => {
|
||||
// const auth = localStorage.getItem("auth_token");
|
||||
// if (!auth) {
|
||||
// throw redirect({
|
||||
// to: "/login",
|
||||
// search: {
|
||||
// // Use the current location to power a redirect after login
|
||||
// // (Do not use `router.state.resolvedLocation` as it can
|
||||
// // potentially lag behind the actual current location)
|
||||
// redirect: location.pathname + location.search,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
});
|
||||
|
||||
function RouteComponent() {
|
||||
return (
|
||||
<div>
|
||||
<HelperPage />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -35,7 +35,7 @@
|
||||
}
|
||||
},
|
||||
"admConfig": {
|
||||
"build": 320,
|
||||
"build": 324,
|
||||
"oldBuild": "backend-0.1.3.zip"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,32 +1,40 @@
|
||||
import {eq} from "drizzle-orm";
|
||||
import {db} from "../../database/dbclient.js";
|
||||
import {settings} from "../../database/schema/settings.js";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { db } from "../../database/dbclient.js";
|
||||
import { settings } from "../../database/schema/settings.js";
|
||||
|
||||
// create the test server stuff
|
||||
const testServers = [
|
||||
{token: "test1", port: 8940},
|
||||
{token: "test2", port: 8941},
|
||||
{token: "test3", port: 8942},
|
||||
{ token: "test1", port: 8940 },
|
||||
{ token: "test2", port: 8941 },
|
||||
{ token: "test3", port: 8942 },
|
||||
];
|
||||
|
||||
export const prodEndpointCreation = async (endpoint: string) => {
|
||||
let url = "";
|
||||
//get the plant token
|
||||
const plantToken = await db.select().from(settings).where(eq(settings.name, "plantToken"));
|
||||
const plantToken = await db
|
||||
.select()
|
||||
.from(settings)
|
||||
.where(eq(settings.name, "plantToken"));
|
||||
|
||||
// check if we are a test server
|
||||
const testServer = testServers.some((server) => server.token === plantToken[0].value);
|
||||
const server = await db.select().from(settings).where(eq(settings.name, "dbServer"));
|
||||
const testServer = testServers.some(
|
||||
(server) => server.token === plantToken[0]?.value
|
||||
);
|
||||
const server = await db
|
||||
.select()
|
||||
.from(settings)
|
||||
.where(eq(settings.name, "dbServer"));
|
||||
|
||||
if (testServer) {
|
||||
//filter out what testserver we are
|
||||
const test = testServers.filter((t) => t.token === plantToken[0].value);
|
||||
// "https://usmcd1vms036.alpla.net:8942/application/public/v1.0/DemandManagement/ORDERS"
|
||||
// "https://usmcd1vms036.alpla.net:8492/application/public/v1.0/DemandManagement/ORDERS"
|
||||
url = `https://${server[0].value}.alpla.net:${test[0].port}/application${endpoint}`;
|
||||
url = `https://${server[0]?.value}.alpla.net:${test[0]?.port}/application${endpoint}`;
|
||||
return url;
|
||||
} else {
|
||||
url = `https://${plantToken[0].value}prod.alpla.net/application${endpoint}`;
|
||||
url = `https://${plantToken[0]?.value}prod.alpla.net/application${endpoint}`;
|
||||
return url;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -9,6 +9,7 @@ import { eq, sql } from "drizzle-orm";
|
||||
export const bookInLabel = async (data: any) => {
|
||||
// update sscc so we can book in
|
||||
const SSCC = data.SSCC.slice(2);
|
||||
|
||||
// api url
|
||||
const url = await prodEndpointCreation(
|
||||
"/public/v1.1/Manufacturing/ProductionControlling/BookIn"
|
||||
@@ -33,7 +34,9 @@ export const bookInLabel = async (data: any) => {
|
||||
"error",
|
||||
"labeling",
|
||||
"ocp",
|
||||
`${data.printer[0].name}, Error:${res.data}`
|
||||
`${
|
||||
data.printer ? data.printer[0].name : "Manual book in"
|
||||
}, Error:${res.data}`
|
||||
);
|
||||
//printerUpdate(data.printer, 7, "Error while booking in.");
|
||||
|
||||
@@ -43,7 +46,6 @@ export const bookInLabel = async (data: any) => {
|
||||
data: res.data,
|
||||
};
|
||||
}
|
||||
|
||||
// update the label.
|
||||
try {
|
||||
const booked = await db
|
||||
@@ -61,7 +63,7 @@ export const bookInLabel = async (data: any) => {
|
||||
"info",
|
||||
"labeling",
|
||||
"ocp",
|
||||
`${booked[0].runningNr} , was just booked in.`
|
||||
`${parseInt(data.SSCC.slice(10, -1))} , was just booked in.`
|
||||
);
|
||||
|
||||
return {
|
||||
@@ -72,24 +74,35 @@ export const bookInLabel = async (data: any) => {
|
||||
data: { SSCC: data.SSCC },
|
||||
};
|
||||
} catch (error) {
|
||||
//console.log(error);
|
||||
createLog(
|
||||
"error",
|
||||
"labeling",
|
||||
"ocp",
|
||||
`Error creating new runningNumber in the DB.`
|
||||
);
|
||||
return {
|
||||
success: true,
|
||||
message: `${parseInt(
|
||||
data.SSCC.slice(10, -1)
|
||||
)}, encoutnered an error posting to the db`,
|
||||
data: error,
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
createLog(
|
||||
"error",
|
||||
"labeling",
|
||||
"ocp",
|
||||
`${data.printer[0].name}, "Error: ${error}`
|
||||
`${
|
||||
data.printer ? data.printer[0].name : "Manual book in"
|
||||
}, "Error: ${error}`
|
||||
);
|
||||
// console.log(error.response.data);
|
||||
return {
|
||||
success: false,
|
||||
message: "There was an error booking in the label.",
|
||||
data: error,
|
||||
data: error.response.data,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -21,6 +21,7 @@ import { printerCycleAutoLabelers } from "./controller/printers/printerCycleAuto
|
||||
import AutostartPrinterCycle from "./routes/printers/autoLabelerStart.js";
|
||||
import AutostopPrinterCycle from "./routes/printers/autoLabelerStop.js";
|
||||
import { deleteLabels } from "../../globalUtils/dbCleanUp/labelCleanUp.js";
|
||||
import bookInLabel from "./routes/labeling/bookIn.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
@@ -38,6 +39,7 @@ const routes = [
|
||||
// labeling
|
||||
getLabels,
|
||||
manualprint,
|
||||
bookInLabel,
|
||||
//dyco
|
||||
dycoCon,
|
||||
dycoClose,
|
||||
|
||||
57
server/services/ocp/routes/labeling/bookIn.ts
Normal file
57
server/services/ocp/routes/labeling/bookIn.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
// 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 { labelingProcess } from "../../controller/labeling/labelProcess.js";
|
||||
import { bookInLabel } from "../../controller/labeling/bookIn.js";
|
||||
import { createSSCC } from "../../../../globalUtils/createSSCC.js";
|
||||
|
||||
const app = new OpenAPIHono({ strict: false });
|
||||
|
||||
app.openapi(
|
||||
createRoute({
|
||||
tags: ["ocp"],
|
||||
summary: "Manual bookin by running Number",
|
||||
method: "post",
|
||||
path: "/bookin",
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c) => {
|
||||
//const hours = c.req.query("hours");
|
||||
const { data: bodyData, error: bodyError } = await tryCatch(
|
||||
c.req.json()
|
||||
);
|
||||
|
||||
if (bodyError) {
|
||||
return c.json({
|
||||
success: false,
|
||||
message: "You are missing data",
|
||||
});
|
||||
}
|
||||
|
||||
// get the sscc number
|
||||
const sscc = await createSSCC(bodyData.runningNr);
|
||||
|
||||
const { data: bookinLabel, error: bookInError } = await tryCatch(
|
||||
bookInLabel({ SSCC: sscc })
|
||||
);
|
||||
|
||||
if (bookInError) {
|
||||
return c.json({
|
||||
success: false,
|
||||
message: "There was an error booking in the label.",
|
||||
data: bookInError,
|
||||
});
|
||||
}
|
||||
|
||||
const newLabel: any = bookinLabel;
|
||||
//console.log(newLabel);
|
||||
|
||||
return c.json({
|
||||
success: newLabel.success,
|
||||
message: newLabel.message,
|
||||
data: newLabel.data,
|
||||
});
|
||||
}
|
||||
);
|
||||
export default app;
|
||||
@@ -336,7 +336,7 @@
|
||||
"idAddress": "10.37.0.26",
|
||||
"greatPlainsPlantCode": "45",
|
||||
"streetAddress": "9 Cermak Blvd",
|
||||
"cityState": "St Peters, MO",
|
||||
"cityState": "St. Peters, MO",
|
||||
"zipcode": "63376",
|
||||
"contactEmail": "Shippingreceivingstpeters@groups.alpla.com",
|
||||
"contactPhone": "6365771018",
|
||||
|
||||
Reference in New Issue
Block a user