Compare commits
19 Commits
136bf9820d
...
292eb324c5
| Author | SHA1 | Date | |
|---|---|---|---|
| 292eb324c5 | |||
| 51e6864868 | |||
| 0caf8094de | |||
| 92c8fc2554 | |||
| ed777437eb | |||
| 353960bd26 | |||
| 6156a1a5bb | |||
| 826c44c996 | |||
| aadf255e34 | |||
| 60690d2df4 | |||
| c31dc523e7 | |||
| caec533279 | |||
| 146832b569 | |||
| 0207e15f38 | |||
| 2701f18eec | |||
| 091305ea9f | |||
| b8e904b7c9 | |||
| 990e0a9aa4 | |||
| f9fa5defa3 |
7
database/migrations/0066_nosy_dark_beast.sql
Normal file
7
database/migrations/0066_nosy_dark_beast.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE "commandLog" (
|
||||
"commandLog_id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"commandUsed" text NOT NULL,
|
||||
"bodySent" jsonb DEFAULT '[]'::jsonb,
|
||||
"reasonUsed" text,
|
||||
"add_Date" timestamp DEFAULT now()
|
||||
);
|
||||
2159
database/migrations/meta/0066_snapshot.json
Normal file
2159
database/migrations/meta/0066_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -463,6 +463,13 @@
|
||||
"when": 1749492130639,
|
||||
"tag": "0065_nappy_talos",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 66,
|
||||
"version": "7",
|
||||
"when": 1749671243377,
|
||||
"tag": "0066_nosy_dark_beast",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
25
database/schema/commandLog.ts
Normal file
25
database/schema/commandLog.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { text, pgTable, timestamp, uuid, jsonb } from "drizzle-orm/pg-core";
|
||||
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
export const commandLog = pgTable(
|
||||
"commandLog",
|
||||
{
|
||||
commandLog_id: uuid("commandLog_id").defaultRandom().primaryKey(),
|
||||
commandUsed: text("commandUsed").notNull(),
|
||||
bodySent: jsonb("bodySent").default([]),
|
||||
reasonUsed: text("reasonUsed"),
|
||||
add_at: timestamp("add_Date").defaultNow(),
|
||||
},
|
||||
(table) => [
|
||||
// uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`),
|
||||
// uniqueIndex("role_name").on(table.name),
|
||||
]
|
||||
);
|
||||
|
||||
// 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(commandLog);
|
||||
@@ -2,15 +2,15 @@ import { LstCard } from "@/components/extendedUI/LstCard";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectGroup,
|
||||
SelectItem,
|
||||
SelectLabel,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
// import {
|
||||
// Select,
|
||||
// SelectContent,
|
||||
// SelectGroup,
|
||||
// SelectItem,
|
||||
// SelectLabel,
|
||||
// SelectTrigger,
|
||||
// SelectValue,
|
||||
// } from "@/components/ui/select";
|
||||
|
||||
import { DebugButton } from "@/utils/formStuff/debugButton";
|
||||
import { userFormOptions } from "@/utils/formStuff/options/userformOptions";
|
||||
@@ -142,7 +142,7 @@ export default function UserCard(data: any) {
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<form.Field
|
||||
{/* <form.Field
|
||||
name="role"
|
||||
//listeners={{onChange: ({value})=>{}}}
|
||||
children={(field) => {
|
||||
@@ -184,7 +184,7 @@ export default function UserCard(data: any) {
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
/> */}
|
||||
<form.Field
|
||||
name="password"
|
||||
validators={{
|
||||
|
||||
@@ -9,6 +9,7 @@ import { useState } from "react";
|
||||
import Barcode from "react-barcode";
|
||||
import { BarcodePDFExport } from "./BarcodeExport";
|
||||
import { BulkBarcodePDFExport } from "./BulkExport";
|
||||
import CommonCommands from "./CommonCommands";
|
||||
|
||||
export default function BGPage() {
|
||||
const { data, isError, isLoading } = useQuery(getLanes());
|
||||
@@ -53,13 +54,15 @@ export default function BGPage() {
|
||||
|
||||
return (
|
||||
<div className="flex flex-row m-2">
|
||||
<div className="flex flex-row">
|
||||
<div className="m-2">
|
||||
<LstCard>
|
||||
<CardHeader>Warehouse Barcodes</CardHeader>
|
||||
<CardContent>
|
||||
{warehouseArray.map((i: any) => {
|
||||
const lanes = data?.filter(
|
||||
(wid: any) => wid.warehouseId === i.warehouseId
|
||||
(wid: any) =>
|
||||
wid.warehouseId === i.warehouseId
|
||||
);
|
||||
return (
|
||||
<div className="m-2" key={i.warehouseId}>
|
||||
@@ -73,16 +76,22 @@ export default function BGPage() {
|
||||
return (
|
||||
<div key={l.laneId}>
|
||||
<Checkbox
|
||||
id={l.laneId}
|
||||
id={
|
||||
l.laneId
|
||||
}
|
||||
// checked={checked.includes(
|
||||
// l
|
||||
// )}
|
||||
onCheckedChange={() =>
|
||||
changeBox(l)
|
||||
changeBox(
|
||||
l
|
||||
)
|
||||
}
|
||||
/>
|
||||
<label
|
||||
id={l.laneId}
|
||||
id={
|
||||
l.laneId
|
||||
}
|
||||
className="ml-2"
|
||||
>
|
||||
{
|
||||
@@ -137,7 +146,9 @@ export default function BGPage() {
|
||||
<div className="flex justify-end">
|
||||
{checked.length > 1 && (
|
||||
<div>
|
||||
<BulkBarcodePDFExport data={checked} />
|
||||
<BulkBarcodePDFExport
|
||||
data={checked}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -146,5 +157,9 @@ export default function BGPage() {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="m-2">
|
||||
<CommonCommands />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
import { LstCard } from "@/components/extendedUI/LstCard";
|
||||
import { CardContent, CardFooter, CardHeader } from "@/components/ui/card";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { useState } from "react";
|
||||
import Barcode from "react-barcode";
|
||||
import { BarcodePDFExport } from "./BarcodeExport";
|
||||
import { BulkBarcodePDFExport } from "./BulkExport";
|
||||
|
||||
const commoncmd = [{ name: "Relocate", commandId: 33 }];
|
||||
export default function CommonCommands() {
|
||||
const [checked, setChecked] = useState([]);
|
||||
|
||||
// handle the onchange
|
||||
const changeBox = (d: any) => {
|
||||
setChecked((prev: any) => {
|
||||
if (prev.includes(d)) {
|
||||
return prev.filter((name: any) => name !== d);
|
||||
} else {
|
||||
return [...prev, d];
|
||||
}
|
||||
});
|
||||
};
|
||||
return (
|
||||
<div>
|
||||
<div>
|
||||
<LstCard>
|
||||
<CardHeader>Common Barcodes</CardHeader>
|
||||
<CardContent>
|
||||
{commoncmd.map((i: any) => {
|
||||
return (
|
||||
<div className="flex flex-row">
|
||||
<div>
|
||||
<Checkbox
|
||||
id={i.commandId}
|
||||
// checked={checked.includes(
|
||||
// l
|
||||
// )}
|
||||
onCheckedChange={() => changeBox(i)}
|
||||
/>
|
||||
<label
|
||||
id={i.commandId}
|
||||
className="ml-2"
|
||||
>
|
||||
{i.name}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</CardContent>
|
||||
</LstCard>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{checked.length > 0 && (
|
||||
<div className="m-2">
|
||||
<LstCard>
|
||||
<CardHeader>Current selected Barcodes</CardHeader>
|
||||
<CardContent>
|
||||
{checked.map((c: any) => {
|
||||
return (
|
||||
<div
|
||||
className="flex justify-center"
|
||||
key={`${c.name}`}
|
||||
>
|
||||
<div>
|
||||
<Barcode
|
||||
value={`AlplaPRODcmd${c.commandId}`}
|
||||
width={2}
|
||||
height={50}
|
||||
displayValue={false}
|
||||
/>
|
||||
<p className="flex justify-center">
|
||||
Bacrode: {c.name}
|
||||
</p>
|
||||
</div>
|
||||
<div className="ml-2 mt-4">
|
||||
<BarcodePDFExport
|
||||
barcodeValue={`AlplaPRODcmd${c.commandId}`}
|
||||
data={c}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</CardContent>
|
||||
<CardFooter>
|
||||
<div className="flex justify-end">
|
||||
{checked.length > 1 && (
|
||||
<div>
|
||||
<BulkBarcodePDFExport
|
||||
data={checked}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</CardFooter>
|
||||
</LstCard>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { LstCard } from "@/components/extendedUI/LstCard";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { CardContent, CardFooter, CardHeader } from "@/components/ui/card";
|
||||
import { CardContent, CardHeader } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { useForm } from "@tanstack/react-form";
|
||||
@@ -63,7 +63,7 @@ export default function Bookin() {
|
||||
}}
|
||||
children={(field) => {
|
||||
return (
|
||||
<div className="m-2 min-w-48 max-w-96 p-2">
|
||||
<div className="">
|
||||
<Label htmlFor="runningNr" className="mb-2">
|
||||
Runnning Number
|
||||
</Label>
|
||||
@@ -85,9 +85,7 @@ export default function Bookin() {
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</CardContent>
|
||||
<CardFooter>
|
||||
<div className="flex justify-end">
|
||||
<div className="flex mt-2 justify-end">
|
||||
<Button
|
||||
onClick={form.handleSubmit}
|
||||
disabled={bookingIn}
|
||||
@@ -95,7 +93,7 @@ export default function Bookin() {
|
||||
Book in
|
||||
</Button>
|
||||
</div>
|
||||
</CardFooter>
|
||||
</CardContent>
|
||||
</form>
|
||||
</LstCard>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
import { LstCard } from "@/components/extendedUI/LstCard";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { CardContent, CardHeader } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { useForm } from "@tanstack/react-form";
|
||||
import axios from "axios";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
export default function RemoveAsNonReusable() {
|
||||
const [stockOut, setStockOut] = useState(false);
|
||||
const form = useForm({
|
||||
defaultValues: { runningNr: " ", reason: " " },
|
||||
onSubmit: async ({ value }) => {
|
||||
// Do something with form data
|
||||
setStockOut(true);
|
||||
|
||||
//console.log(value);
|
||||
|
||||
try {
|
||||
const res = await axios.post(
|
||||
"/api/logistics/removeasreusable",
|
||||
|
||||
value // this is basically the data field
|
||||
);
|
||||
|
||||
if (res.data.success) {
|
||||
toast.success(res.data.message);
|
||||
form.reset();
|
||||
setStockOut(false);
|
||||
} else {
|
||||
console.log(res.data);
|
||||
toast.error(res.data?.message);
|
||||
form.reset();
|
||||
setStockOut(false);
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.log(error);
|
||||
toast.error(error.message);
|
||||
setStockOut(false);
|
||||
}
|
||||
},
|
||||
});
|
||||
return (
|
||||
<LstCard>
|
||||
<CardHeader>
|
||||
<p>Remove a pallet as non reusable</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="w-96">
|
||||
<Label htmlFor="runningNr" className="mb-2">
|
||||
Runnning Number
|
||||
</Label>
|
||||
<Input
|
||||
name={field.name}
|
||||
value={field.state.value}
|
||||
onBlur={field.handleBlur}
|
||||
required
|
||||
type="number"
|
||||
onChange={(e) =>
|
||||
field.handleChange(e.target.value)
|
||||
}
|
||||
/>
|
||||
{field.state.meta.errors.length ? (
|
||||
<em>
|
||||
{field.state.meta.errors.join(",")}
|
||||
</em>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<form.Field
|
||||
name="reason"
|
||||
validators={{
|
||||
// We can choose between form-wide and field-specific validators
|
||||
onChange: ({ value }) =>
|
||||
value.length > 10
|
||||
? undefined
|
||||
: "Please enter a valid reason on why you needed to remove this pallet",
|
||||
}}
|
||||
children={(field) => {
|
||||
return (
|
||||
<div className="">
|
||||
<Label htmlFor="reason" className="mb-2">
|
||||
Reason for removing
|
||||
</Label>
|
||||
<Textarea
|
||||
name={field.name}
|
||||
value={field.state.value}
|
||||
onBlur={field.handleBlur}
|
||||
//type="number"
|
||||
onChange={(e) =>
|
||||
field.handleChange(e.target.value)
|
||||
}
|
||||
/>
|
||||
{field.state.meta.errors.length ? (
|
||||
<div className="text-pretty max-w-96">
|
||||
<em>
|
||||
{field.state.meta.errors.join(
|
||||
","
|
||||
)}
|
||||
</em>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<div className="flex mt-2 justify-end">
|
||||
<Button onClick={form.handleSubmit} disabled={stockOut}>
|
||||
Remove
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</form>
|
||||
</LstCard>
|
||||
);
|
||||
}
|
||||
@@ -1,9 +1,16 @@
|
||||
import Bookin from "./commands/Bookin";
|
||||
import RemoveAsNonReusable from "./commands/RemoveAsNonReusable";
|
||||
|
||||
export default function HelperPage() {
|
||||
return (
|
||||
<div>
|
||||
<div className="flex flex-wrap m-2 justify-center">
|
||||
<div className="m-1">
|
||||
<Bookin />
|
||||
</div>
|
||||
|
||||
<div className="m-1">
|
||||
<RemoveAsNonReusable />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ import { useQuery } from "@tanstack/react-query";
|
||||
import ManualPrint from "./ManualPrinting/ManualPrint";
|
||||
import ManualPrintForm from "./ManualPrinting/ManualPrintForm";
|
||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import { useGetUserRoles } from "@/lib/store/useGetRoles";
|
||||
import { useModuleStore } from "@/lib/store/useModuleStore";
|
||||
|
||||
let lotColumns = [
|
||||
{
|
||||
@@ -68,12 +70,21 @@ export default function Lots() {
|
||||
const { data, isError, isLoading } = useQuery(getlots());
|
||||
const { user } = useSessionStore();
|
||||
const { settings } = useSettingStore();
|
||||
const { userRoles } = useGetUserRoles();
|
||||
const { modules } = useModuleStore();
|
||||
|
||||
const server = settings.filter((n) => n.name === "server")[0]?.value || "";
|
||||
|
||||
const roles = ["technician", "admin", "manager", "operator"];
|
||||
const roles = ["systemAdmin", "technician", "admin", "manager", "operator"];
|
||||
const lotdata = data ? data : [];
|
||||
|
||||
if (user && roles.includes(user.role)) {
|
||||
const module = modules.filter((n) => n.name === "logistics");
|
||||
|
||||
const accessRoles = userRoles.filter(
|
||||
(n) => n.module_id === module[0]?.module_id
|
||||
) as any;
|
||||
|
||||
if (user && roles.includes(accessRoles[0]?.role)) {
|
||||
//width = 1280;
|
||||
const checkCol = lotColumns.some((l) => l.key === "printLabel");
|
||||
if (!checkCol) {
|
||||
@@ -230,7 +241,8 @@ export default function Lots() {
|
||||
<TableCell className="font-medium">
|
||||
{lot.overPrinting}
|
||||
</TableCell>
|
||||
{user && roles.includes(user.role) && (
|
||||
{user &&
|
||||
roles.includes(accessRoles[0].role) && (
|
||||
<>
|
||||
{server === "usday1vms006" ||
|
||||
server === "localhost" ? (
|
||||
@@ -241,7 +253,9 @@ export default function Lots() {
|
||||
</>
|
||||
) : (
|
||||
<TableCell className="flex justify-center">
|
||||
<ManualPrint lot={lot} />
|
||||
<ManualPrint
|
||||
lot={lot}
|
||||
/>
|
||||
</TableCell>
|
||||
)}
|
||||
</>
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
}
|
||||
},
|
||||
"admConfig": {
|
||||
"build": 389,
|
||||
"build": 399,
|
||||
"oldBuild": "backend-0.1.3.zip"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
import axios from "axios";
|
||||
import { commandLog } from "../../../../../database/schema/commandLog.js";
|
||||
import { prodEndpointCreation } from "../../../../globalUtils/createUrl.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { lstAuth } from "../../../../index.js";
|
||||
import { createSSCC } from "../../../../globalUtils/createSSCC.js";
|
||||
import { db } from "../../../../../database/dbclient.js";
|
||||
import net from "net";
|
||||
import { query } from "../../../sqlServer/prodSqlServer.js";
|
||||
import { labelInfo } from "../../../sqlServer/querys/warehouse/labelInfo.js";
|
||||
import { settings } from "../../../../../database/schema/settings.js";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { serverData } from "../../../../../database/schema/serverData.js";
|
||||
export const removeAsNonReusable = async (data: any) => {
|
||||
// const removalUrl = await prodEndpointCreation(
|
||||
// "/public/v1.0/Warehousing/RemoveAsNonReusableMaterial"
|
||||
// );
|
||||
|
||||
// const sscc = await createSSCC(data.runningNr);
|
||||
|
||||
// const { data: remove, error } = await tryCatch(
|
||||
// axios.post(
|
||||
// removalUrl,
|
||||
// { scannerId: "500", sscc: sscc.slice(2) },
|
||||
// {
|
||||
// headers: { Authorization: `Basic ${lstAuth}` },
|
||||
// }
|
||||
// )
|
||||
// );
|
||||
|
||||
// use a scanner tcp connection to trigger this process
|
||||
const STX = "\x02";
|
||||
const ETX = "\x03";
|
||||
const scanner = new net.Socket();
|
||||
let stage = 0;
|
||||
// get the label info
|
||||
const { data: label, error: labelError } = (await tryCatch(
|
||||
query(labelInfo.replaceAll("[runningNr]", data.runningNr), "Label Info")
|
||||
)) as any;
|
||||
|
||||
if (label.data[0].stockStatus === "notOnStock") {
|
||||
return {
|
||||
success: false,
|
||||
message: `The label: ${data.runningNr} is not currently in stock`,
|
||||
data: [],
|
||||
};
|
||||
}
|
||||
|
||||
// get the server ip based on the token.
|
||||
const setting = await db.select().from(settings);
|
||||
|
||||
const plantInfo = await db.select().from(serverData);
|
||||
const plantToken = setting.filter((n: any) => n.name === "plantToken");
|
||||
const scannerID = setting.filter((n: any) => n.name === "scannerID");
|
||||
const scannerPort = setting.filter((n: any) => n.name === "scannerPort");
|
||||
const plantData = plantInfo.filter(
|
||||
(p: any) => p.plantToken === plantToken[0].value
|
||||
);
|
||||
|
||||
scanner.connect(
|
||||
parseInt(scannerPort[0].value),
|
||||
plantData[0].idAddress!,
|
||||
async () => {
|
||||
// need to get the ip from the server data and scanner port
|
||||
//console.log(`connected to scanner`);
|
||||
scanner.write(`${STX}${scannerID[0].value}@AlplaPRODcmd23${ETX}`);
|
||||
}
|
||||
);
|
||||
scanner.on("data", (data) => {
|
||||
const response = data.toString();
|
||||
//console.log("Received:", response.trimStart());
|
||||
if (stage === 0) {
|
||||
stage = 1;
|
||||
scanner.write(
|
||||
`${STX}${scannerID[0].value}${label.data[0].Barcode}${ETX}`
|
||||
);
|
||||
} else if (stage === 1) {
|
||||
scanner.end();
|
||||
}
|
||||
});
|
||||
scanner.on("close", () => {
|
||||
//console.log("Connection closed");
|
||||
scanner.destroy();
|
||||
});
|
||||
scanner.on("error", (err) => {
|
||||
//console.error("Scanner error:", err);
|
||||
scanner.destroy();
|
||||
return {
|
||||
success: false,
|
||||
message: `The label: ${data.runningNr} encountering an error while being removed, please try again`,
|
||||
data: [],
|
||||
};
|
||||
});
|
||||
|
||||
// if (error) {
|
||||
// //console.log(error);
|
||||
// return {
|
||||
// success: false,
|
||||
// message: `There was an error removing ${data.runningNr}`,
|
||||
// data: [],
|
||||
// };
|
||||
// }
|
||||
|
||||
let reason = data.reason || "";
|
||||
delete data.reason;
|
||||
|
||||
const { data: commandL, error: ce } = await tryCatch(
|
||||
db.insert(commandLog).values({
|
||||
commandUsed: "removeAsNonReusable",
|
||||
bodySent: data,
|
||||
reasonUsed: reason,
|
||||
})
|
||||
);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: `The label: ${data.runningNr}, was removed`,
|
||||
data: [],
|
||||
};
|
||||
};
|
||||
@@ -117,7 +117,9 @@ export const pNgForecast = async (data: any, user: any) => {
|
||||
const activeAV = article.filter(
|
||||
(c: any) =>
|
||||
c?.CustomerArticleNumber ===
|
||||
nForecast[i]?.customerArticleNo.toString()
|
||||
nForecast[i]?.customerArticleNo.toString() &&
|
||||
// validate it works via the default address
|
||||
c?.IdAdresse === parseInt(pNg[0].value)
|
||||
);
|
||||
|
||||
if (activeAV.length > 0) {
|
||||
|
||||
@@ -5,6 +5,9 @@ import { query } from "../../../sqlServer/prodSqlServer.js";
|
||||
import { createLog } from "../../../logger/logger.js";
|
||||
|
||||
import { prodEndpointCreation } from "../../../../globalUtils/createUrl.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { db } from "../../../../../database/dbclient.js";
|
||||
import { commandLog } from "../../../../../database/schema/commandLog.js";
|
||||
|
||||
type Data = {
|
||||
runningNr: string;
|
||||
@@ -34,7 +37,7 @@ export const consumeMaterial = async (data: Data, prod: any) => {
|
||||
if (barcode.length === 0) {
|
||||
return {
|
||||
success: false,
|
||||
message: "The running number you've is not in stock.",
|
||||
message: "The running number you've entered not on stock.",
|
||||
};
|
||||
//throw Error("The provided runningNr is not in stock");
|
||||
}
|
||||
@@ -56,6 +59,12 @@ export const consumeMaterial = async (data: Data, prod: any) => {
|
||||
},
|
||||
});
|
||||
//console.log(results);
|
||||
const { data: commandL, error: ce } = await tryCatch(
|
||||
db.insert(commandLog).values({
|
||||
commandUsed: "consumeMaterial",
|
||||
bodySent: data,
|
||||
})
|
||||
);
|
||||
return {
|
||||
success: true,
|
||||
message: "Material was consumed",
|
||||
|
||||
@@ -5,6 +5,8 @@ import { query } from "../../../sqlServer/prodSqlServer.js";
|
||||
import { createLog } from "../../../logger/logger.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { prodEndpointCreation } from "../../../../globalUtils/createUrl.js";
|
||||
import { db } from "../../../../../database/dbclient.js";
|
||||
import { commandLog } from "../../../../../database/schema/commandLog.js";
|
||||
type Data = {
|
||||
runningNr: string;
|
||||
laneName: string;
|
||||
@@ -86,6 +88,12 @@ export const returnMaterial = async (data: Data, prod: any) => {
|
||||
},
|
||||
});
|
||||
//console.log(results);
|
||||
const { data: commandL, error: ce } = await tryCatch(
|
||||
db.insert(commandLog).values({
|
||||
commandUsed: "returnMaterial",
|
||||
bodySent: data,
|
||||
})
|
||||
);
|
||||
return {
|
||||
success: true,
|
||||
message: "Material was returned",
|
||||
|
||||
@@ -19,6 +19,7 @@ import outbound from "./route/getOutbound.js";
|
||||
import { runHistoricalData } from "./controller/eom/historicalInv.js";
|
||||
import intervalChecks from "./route/getActiveLogistics.js";
|
||||
import getActiveLanes from "./route/getActiveLanes.js";
|
||||
import removeAsNonReable from "./route/removeAsNonReusable.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
@@ -45,6 +46,9 @@ const routes = [
|
||||
// outbound deliveries
|
||||
outbound,
|
||||
intervalChecks,
|
||||
|
||||
// logisitcs
|
||||
removeAsNonReable,
|
||||
] as const;
|
||||
|
||||
// app.route("/server", modules);
|
||||
|
||||
62
server/services/logistics/route/removeAsNonReusable.ts
Normal file
62
server/services/logistics/route/removeAsNonReusable.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||
import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
||||
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||
import { removeAsNonReusable } from "../controller/commands/removeAsNonReusable.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
// const Body = z
|
||||
// .object({
|
||||
// age: z.number().optional().openapi({ example: 90 }),
|
||||
// //email: z.string().optional().openapi({example: "s.smith@example.com"}),
|
||||
// type: z.string().optional().openapi({ example: "fg" }),
|
||||
// })
|
||||
// .openapi("User");
|
||||
app.openapi(
|
||||
createRoute({
|
||||
tags: ["logistics"],
|
||||
summary:
|
||||
"Remove a pallet similar to stock out from the system with a reason",
|
||||
method: "post",
|
||||
path: "/removeasreusable",
|
||||
// request: {
|
||||
// body: {
|
||||
// content: {
|
||||
// "application/json": { schema: Body },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// description:
|
||||
// "Provided a running number and lot number you can consume material.",
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c: any) => {
|
||||
apiHit(c, { endpoint: "/removeasreusable" });
|
||||
const { data: body, error: be } = await tryCatch(c.req.json());
|
||||
|
||||
if (be) {
|
||||
return {
|
||||
success: false,
|
||||
message: "Missing data",
|
||||
data: [],
|
||||
};
|
||||
}
|
||||
const { data, error } = await tryCatch(removeAsNonReusable(body));
|
||||
|
||||
if (error) {
|
||||
return c.json({
|
||||
success: false,
|
||||
message: "Error getting lane data.",
|
||||
data: error,
|
||||
});
|
||||
}
|
||||
|
||||
return c.json({
|
||||
success: data.success,
|
||||
message: data.message,
|
||||
data: data.data,
|
||||
});
|
||||
}
|
||||
);
|
||||
export default app;
|
||||
@@ -6,6 +6,8 @@ import { labelingProcess } from "../../controller/labeling/labelProcess.js";
|
||||
import { bookInLabel } from "../../controller/labeling/bookIn.js";
|
||||
import { createSSCC } from "../../../../globalUtils/createSSCC.js";
|
||||
import { apiHit } from "../../../../globalUtils/apiHits.js";
|
||||
import { db } from "../../../../../database/dbclient.js";
|
||||
import { commandLog } from "../../../../../database/schema/commandLog.js";
|
||||
|
||||
const app = new OpenAPIHono({ strict: false });
|
||||
|
||||
@@ -49,6 +51,13 @@ app.openapi(
|
||||
const newLabel: any = bookinLabel;
|
||||
//console.log(newLabel);
|
||||
|
||||
const { data: commandL, error: ce } = await tryCatch(
|
||||
db.insert(commandLog).values({
|
||||
commandUsed: "bookin",
|
||||
bodySent: bodyData,
|
||||
})
|
||||
);
|
||||
|
||||
return c.json({
|
||||
success: newLabel.success,
|
||||
message: newLabel.message,
|
||||
|
||||
@@ -15,6 +15,7 @@ const newProdRoles: any = [
|
||||
roles: ["Manufacturing\\IssueMaterial\\MaterialHandler"],
|
||||
rolesLegacy: [3],
|
||||
},
|
||||
// production
|
||||
{
|
||||
name: "prodsupervisor",
|
||||
description:
|
||||
@@ -26,6 +27,38 @@ const newProdRoles: any = [
|
||||
],
|
||||
rolesLegacy: [3, 11, 41, 48, 49],
|
||||
},
|
||||
// quality
|
||||
{
|
||||
name: "qualityTechB",
|
||||
description:
|
||||
"Quality tech with blocking, planning, stock warehouse leader, waste, quality waste.",
|
||||
roles: ["Quality\\Blocking\\ProcessAdmin"],
|
||||
rolesLegacy: [3, 14, 45],
|
||||
},
|
||||
// logistics
|
||||
|
||||
// plant manager
|
||||
{
|
||||
name: "plantManager",
|
||||
description:
|
||||
"Quality tech with blocking, planning, stock warehouse leader, waste, quality waste.",
|
||||
roles: [
|
||||
"Quality\\ComplaintHandling\\ProcessAdmin",
|
||||
"Manufacturing\\ProductionControlling\\ProcessAdmin",
|
||||
"MasterData\\Manufacturing\\ProcessAdmin",
|
||||
"Quality\\Blocking\\ProcessAdmin",
|
||||
"Logistics\\InboundDeliveries\\ApiConsumer",
|
||||
"MasterData\\Logistics\\ProcessAdmin",
|
||||
"DemandManagement\\Order\\ProcessAdmin",
|
||||
"Manufacturing\\IssueMaterial\\ProcessAdmin",
|
||||
"Logistics\\Warehousing\\ProcessAdmin",
|
||||
"Logistics\\OutboundDeliveries\\ProcessAdmin",
|
||||
"DemandManagement\\Forecast\\ProcessAdmin",
|
||||
"Manufacturing\\ProductionLabelling\\ProcessAdmin",
|
||||
],
|
||||
rolesLegacy: [4, 55, 145, 95, 45, 105, 65, 15, 125],
|
||||
},
|
||||
// regional
|
||||
];
|
||||
export const prodRoles = async () => {
|
||||
// get the roles
|
||||
|
||||
@@ -213,14 +213,14 @@
|
||||
"streetAddress": "3320 Fort Shawnee Industrial Dr",
|
||||
"cityState": "Lima, OH",
|
||||
"zipcode": "45806",
|
||||
"contactEmail": "blake.matthes@alpla.com",
|
||||
"contactPhone": "6366970253",
|
||||
"contactEmail": "shippingreceivinglima@groups.alpla.com",
|
||||
"contactPhone": "",
|
||||
"customerTiAcc": "ALPL01LIMAINT",
|
||||
"lstServerPort": "3000",
|
||||
"active": true,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "E:\\LST\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"shippingHours": "[{\"early\": \"07:00\", \"late\": \"11:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{ "specialInstructions": "" }]
|
||||
},
|
||||
|
||||
@@ -222,6 +222,20 @@ const newSettings = [
|
||||
serviceBelowsTo: "dm",
|
||||
roleToChange: "admin",
|
||||
},
|
||||
{
|
||||
name: "scannerID",
|
||||
value: `500`,
|
||||
description: "What scanner id will we be using for the app",
|
||||
serviceBelowsTo: "logistics",
|
||||
roleToChange: "admin",
|
||||
},
|
||||
{
|
||||
name: "scannerPort",
|
||||
value: `50002`,
|
||||
description: "What port instance will we be using?",
|
||||
serviceBelowsTo: "logistics",
|
||||
roleToChange: "admin",
|
||||
},
|
||||
// temp settings can be deleted at a later date once that code is removed
|
||||
{
|
||||
name: "siloAdjMigrations",
|
||||
|
||||
20
server/services/sqlServer/querys/warehouse/labelInfo.ts
Normal file
20
server/services/sqlServer/querys/warehouse/labelInfo.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
export const labelInfo = `
|
||||
select top(500) e.Barcode,
|
||||
e.IdArtikelvarianten as av,
|
||||
e.lfdnr as rn,
|
||||
IdEtikettenLayout as labelLayout,
|
||||
AnzStkJePalette,
|
||||
Sonstiges_9,AnzStkJeKarton
|
||||
,case when EinlagerungsMengeSum IS NULL then 'notOnStock' else 'onStock' end as stockStatus
|
||||
,EinlagerungsMengeSum
|
||||
--,*
|
||||
from [AlplaPROD_test1].dbo.[T_EtikettenGedruckt] e (nolock)
|
||||
|
||||
left join
|
||||
[AlplaPROD_test1].dbo.V_LagerPositionenBarcodes as l on
|
||||
e.LfdNr = l.Lfdnr
|
||||
|
||||
where e.LfdNr in ([runningNr])
|
||||
|
||||
order by add_date desc
|
||||
`;
|
||||
Reference in New Issue
Block a user