Compare commits

...

26 Commits

Author SHA1 Message Date
a68a3ba640 test(rfid): more rfid work and tested working 2025-04-17 18:42:29 -05:00
af8d53cac1 feat(manual print options): added in block for printing and new log type 2025-04-17 18:42:08 -05:00
5cdca0a41f refactor(cards): messing with the time in the cards 2025-04-17 18:41:40 -05:00
9cb8ca6813 feat(openorders): new open order card and page 2025-04-17 18:41:07 -05:00
d5114ba243 fix(lots errors): fixes to prevent crashes when sql server not connected 2025-04-17 18:40:35 -05:00
e7e35336f8 ci(release): bump build number to 252 2025-04-17 18:33:16 -05:00
fae1f36555 ci(release): bump build number to 251 2025-04-17 09:38:39 -05:00
69031a7f0e ci(release): bump build number to 250 2025-04-17 07:27:28 -05:00
fc621c8ca6 ci(release): bump build number to 249 2025-04-17 07:26:08 -05:00
be1074d142 ci(release): bump build number to 248 2025-04-16 20:54:51 -05:00
365a24ce5f ci(release): bump build number to 247 2025-04-16 19:50:19 -05:00
94f5906299 ci(release): bump build number to 246 2025-04-16 11:14:02 -05:00
35652e3735 ci(release): bump build number to 245 2025-04-16 08:34:56 -05:00
84e0c46be9 ci(release): bump build number to 244 2025-04-15 16:20:04 -05:00
f5fd1c0890 ci(release): bump build number to 243 2025-04-15 16:16:21 -05:00
7dab5f36ec ci(release): bump build number to 242 2025-04-15 16:10:03 -05:00
1b69edfef0 ci(release): bump build number to 241 2025-04-15 14:56:07 -05:00
4c799c70ab ci(release): bump build number to 240 2025-04-15 14:49:18 -05:00
fbd63e6da2 ci(release): bump build number to 239 2025-04-15 14:44:44 -05:00
be31ae2c04 ci(release): bump build number to 238 2025-04-15 14:32:57 -05:00
5f486bf6cd ci(release): bump build number to 237 2025-04-15 12:59:45 -05:00
8cf4e3e31c ci(release): bump build number to 236 2025-04-15 12:52:02 -05:00
558673d8c4 ci(release): bump build number to 235 2025-04-15 09:08:52 -05:00
9add660249 ci(release): bump build number to 234 2025-04-15 07:33:14 -05:00
02912825de ci(release): bump build number to 233 2025-04-15 07:21:35 -05:00
0793c5f7d6 ci(release): bump build number to 232 2025-04-15 07:14:07 -05:00
24 changed files with 707 additions and 221 deletions

View File

@@ -34,6 +34,7 @@ export function AddCards() {
<Cards name={"inv-materials"} rowType={"materials"} />
<Cards name={"inv-packaging"} rowType={"packaging"} />
<Cards name={"inv-waste"} rowType={"waste"} />
<Cards name={"openOrder"} inventory />
</div>
</div>

View File

@@ -1,10 +1,12 @@
import { useCardStore } from "@/lib/store/useCardStore";
import INVCheckCard from "../logistics/warehouse/InventoryCard";
import PPOO from "../logistics/warehouse/PPOOCard";
import OpenOrders from "../logistics/warehouse/openOrders";
const componentsMap: any = {
ppoo: PPOO,
inv: INVCheckCard,
openOrder: OpenOrders,
//QualityRequest,
};
@@ -18,12 +20,19 @@ export default function DashBoard() {
const name = a.name; //.filter((c) => c.i === card.i)[0].i || "name";
const Component = componentsMap[name.split("-")[0]];
return (
<div key={a.name} className="col-span-3">
<Component age={a.age} type={a.rowType} />{" "}
</div>
);
if (name === "openOrder") {
return (
<div key={a.name} className="col-span-6">
<Component age={a.age} type={a.rowType} />
</div>
);
} else {
return (
<div key={a.name} className="col-span-3">
<Component age={a.age} type={a.rowType} />
</div>
);
}
})}
</div>
);

View File

@@ -25,6 +25,9 @@ export default function INVCheckCard(props: any) {
laneData = laneData.filter(
(l: any) => l.rowType === props.type.toUpperCase()
);
// age
laneData = laneData.filter((l: any) => l.DaysSinceLast >= props.age);
}
// const handleCloseCard = () => {

View File

@@ -0,0 +1,33 @@
//import { LstCard } from "@/components/extendedUI/LstCard";
import { getOpenOrders } from "@/utils/querys/logistics/getOpenOrders";
import { openOrderColumns } from "@/utils/tableData/openorders/ooColumns";
import { OpenOrderTable } from "@/utils/tableData/openorders/ooData";
import { useQuery } from "@tanstack/react-query";
//import { CircleX } from "lucide-react";
//import { Suspense } from "react";
//import { toast } from "sonner";
export default function OpenOrders() {
//{ style = {} }
const { data, isError, isLoading } = useQuery(getOpenOrders());
if (isLoading) return <div>Loading openOrder data...</div>;
if (isError) {
return (
<div>
<p>There was an error getting the openorders.</p>
</div>
);
}
let openOrders: any = data;
// const handleCloseCard = () => {
// //removeCard("PPOO");
// toast.success("card removed");
// };
return <OpenOrderTable columns={openOrderColumns} data={openOrders} />;
}

View File

@@ -30,6 +30,7 @@ import { toast } from "sonner";
const printReason = [
{ key: "printerIssue", label: "Printer Related" },
{ key: "missingRfidTag", label: "Missing or incorrect tag" },
{ key: "rfidMissScan", label: "Missed Scan from RFID reader" },
{ key: "strapper", label: "Strapper Error" },
{ key: "manualCheck", label: "20th pallet check" },
{ key: "outOfSync", label: "Labeler Out of Sync" },
@@ -39,6 +40,7 @@ export default function ManualPrintForm() {
const token = localStorage.getItem("auth_token");
const { settings } = useSettingStore();
const [open, setOpen] = useState(false);
const [isSubmitting, setIsSubmitting] = useState(false);
const server = settings.filter((n) => n.name === "server")[0]?.value;
// const serverPort = settings.filter((n) => n.name === "serverPort")[0]?.value;
// const serverUrl = `http://${server}:${serverPort}`;
@@ -57,6 +59,7 @@ export default function ManualPrintForm() {
const handleManualPrintLog = async (logData: any) => {
// toast.success(`A new label was sent to printer: ${lot.PrinterName} for line ${lot.MachineDescription} `);
const logdataUrl = `/api/ocp/manuallabellog`;
setIsSubmitting(true);
axios
.post(logdataUrl, logData, {
headers: { Authorization: `Bearer ${token}` },
@@ -70,16 +73,19 @@ export default function ManualPrintForm() {
}
reset();
setOpen(false);
setIsSubmitting(false);
})
.catch((e) => {
if (e.response.status === 500) {
toast.error(`Internal Server error please try again.`);
setIsSubmitting(false);
return { sucess: false };
}
if (e.response.status === 401) {
//console.log(e.response);
toast.error(`You are not authorized to do this.`);
setIsSubmitting(false);
return { sucess: false };
}
});
@@ -250,7 +256,11 @@ export default function ManualPrintForm() {
>
Close
</Button>
<Button color="primary" type="submit">
<Button
color="primary"
type="submit"
disabled={isSubmitting}
>
Print
</Button>
</div>

View File

@@ -29,6 +29,7 @@ import { Route as AdminNotificationMGTImport } from './routes/_admin/notificatio
import { Route as AdminModulesImport } from './routes/_admin/modules'
import { Route as ocmeCyclecountIndexImport } from './routes/(ocme)/cyclecount/index'
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 EomArticleAvImport } from './routes/_eom/article/$av'
import { Route as logisticsSiloAdjustmentsHistImport } from './routes/(logistics)/siloAdjustments/$hist'
@@ -144,6 +145,12 @@ const logisticsSiloAdjustmentsIndexRoute =
getParentRoute: () => rootRoute,
} as any)
const logisticsOpenOrdersIndexRoute = logisticsOpenOrdersIndexImport.update({
id: '/(logistics)/openOrders/',
path: '/openOrders/',
getParentRoute: () => rootRoute,
} as any)
const logisticsMaterialHelperIndexRoute =
logisticsMaterialHelperIndexImport.update({
id: '/(logistics)/materialHelper/',
@@ -322,6 +329,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof logisticsMaterialHelperIndexImport
parentRoute: typeof rootRoute
}
'/(logistics)/openOrders/': {
id: '/(logistics)/openOrders/'
path: '/openOrders'
fullPath: '/openOrders'
preLoaderRoute: typeof logisticsOpenOrdersIndexImport
parentRoute: typeof rootRoute
}
'/(logistics)/siloAdjustments/': {
id: '/(logistics)/siloAdjustments/'
path: '/siloAdjustments'
@@ -422,6 +436,7 @@ export interface FileRoutesByFullPath {
'/siloAdjustments/$hist': typeof logisticsSiloAdjustmentsHistRoute
'/article/$av': typeof EomArticleAvRoute
'/materialHelper': typeof logisticsMaterialHelperIndexRoute
'/openOrders': typeof logisticsOpenOrdersIndexRoute
'/siloAdjustments': typeof logisticsSiloAdjustmentsIndexRoute
'/cyclecount': typeof ocmeCyclecountIndexRoute
'/siloAdjustments/comment/$comment': typeof logisticsSiloAdjustmentsCommentCommentRoute
@@ -447,6 +462,7 @@ export interface FileRoutesByTo {
'/siloAdjustments/$hist': typeof logisticsSiloAdjustmentsHistRoute
'/article/$av': typeof EomArticleAvRoute
'/materialHelper': typeof logisticsMaterialHelperIndexRoute
'/openOrders': typeof logisticsOpenOrdersIndexRoute
'/siloAdjustments': typeof logisticsSiloAdjustmentsIndexRoute
'/cyclecount': typeof ocmeCyclecountIndexRoute
'/siloAdjustments/comment/$comment': typeof logisticsSiloAdjustmentsCommentCommentRoute
@@ -475,6 +491,7 @@ export interface FileRoutesById {
'/(logistics)/siloAdjustments/$hist': typeof logisticsSiloAdjustmentsHistRoute
'/_eom/article/$av': typeof EomArticleAvRoute
'/(logistics)/materialHelper/': typeof logisticsMaterialHelperIndexRoute
'/(logistics)/openOrders/': typeof logisticsOpenOrdersIndexRoute
'/(logistics)/siloAdjustments/': typeof logisticsSiloAdjustmentsIndexRoute
'/(ocme)/cyclecount/': typeof ocmeCyclecountIndexRoute
'/(logistics)/siloAdjustments/comment/$comment': typeof logisticsSiloAdjustmentsCommentCommentRoute
@@ -502,6 +519,7 @@ export interface FileRouteTypes {
| '/siloAdjustments/$hist'
| '/article/$av'
| '/materialHelper'
| '/openOrders'
| '/siloAdjustments'
| '/cyclecount'
| '/siloAdjustments/comment/$comment'
@@ -526,6 +544,7 @@ export interface FileRouteTypes {
| '/siloAdjustments/$hist'
| '/article/$av'
| '/materialHelper'
| '/openOrders'
| '/siloAdjustments'
| '/cyclecount'
| '/siloAdjustments/comment/$comment'
@@ -552,6 +571,7 @@ export interface FileRouteTypes {
| '/(logistics)/siloAdjustments/$hist'
| '/_eom/article/$av'
| '/(logistics)/materialHelper/'
| '/(logistics)/openOrders/'
| '/(logistics)/siloAdjustments/'
| '/(ocme)/cyclecount/'
| '/(logistics)/siloAdjustments/comment/$comment'
@@ -571,6 +591,7 @@ export interface RootRouteChildren {
OcpIndexRoute: typeof OcpIndexRoute
logisticsSiloAdjustmentsHistRoute: typeof logisticsSiloAdjustmentsHistRoute
logisticsMaterialHelperIndexRoute: typeof logisticsMaterialHelperIndexRoute
logisticsOpenOrdersIndexRoute: typeof logisticsOpenOrdersIndexRoute
logisticsSiloAdjustmentsIndexRoute: typeof logisticsSiloAdjustmentsIndexRoute
ocmeCyclecountIndexRoute: typeof ocmeCyclecountIndexRoute
logisticsSiloAdjustmentsCommentCommentRoute: typeof logisticsSiloAdjustmentsCommentCommentRoute
@@ -589,6 +610,7 @@ const rootRouteChildren: RootRouteChildren = {
OcpIndexRoute: OcpIndexRoute,
logisticsSiloAdjustmentsHistRoute: logisticsSiloAdjustmentsHistRoute,
logisticsMaterialHelperIndexRoute: logisticsMaterialHelperIndexRoute,
logisticsOpenOrdersIndexRoute: logisticsOpenOrdersIndexRoute,
logisticsSiloAdjustmentsIndexRoute: logisticsSiloAdjustmentsIndexRoute,
ocmeCyclecountIndexRoute: ocmeCyclecountIndexRoute,
logisticsSiloAdjustmentsCommentCommentRoute:
@@ -619,6 +641,7 @@ export const routeTree = rootRoute
"/ocp/",
"/(logistics)/siloAdjustments/$hist",
"/(logistics)/materialHelper/",
"/(logistics)/openOrders/",
"/(logistics)/siloAdjustments/",
"/(ocme)/cyclecount/",
"/(logistics)/siloAdjustments/comment/$comment",
@@ -707,6 +730,9 @@ export const routeTree = rootRoute
"/(logistics)/materialHelper/": {
"filePath": "(logistics)/materialHelper/index.tsx"
},
"/(logistics)/openOrders/": {
"filePath": "(logistics)/openOrders/index.tsx"
},
"/(logistics)/siloAdjustments/": {
"filePath": "(logistics)/siloAdjustments/index.tsx"
},

View File

@@ -0,0 +1,14 @@
import OpenOrders from "@/components/logistics/warehouse/openOrders";
import { createFileRoute } from "@tanstack/react-router";
export const Route = createFileRoute("/(logistics)/openOrders/")({
component: RouteComponent,
});
function RouteComponent() {
return (
<div className="m-5 w-11/12 h-9/10">
<OpenOrders />
</div>
);
}

View File

@@ -1,6 +1,17 @@
import { format } from "date-fns";
import { addHours, format } from "date-fns";
export const fixTime = (date: any) => {
const strippedDate = date.replace("Z", ""); // Remove Z
return format(strippedDate, "MM/dd/yyyy hh:mm a");
if (!date) return;
// const strippedDate = date?.replace("Z", ""); // Remove Z
//return format(strippedDate, "MM/dd/yyyy hh:mm a");
const rawDate = new Date(date).toISOString();
const offsetMinutes = new Date().getTimezoneOffset(); // in minutes
const offsetHours =
-offsetMinutes / 60 >= 0 ? offsetMinutes / 60 : -offsetMinutes / 60;
return format(
addHours(rawDate, offsetHours).toISOString(),
"MM/dd/yyyy hh:mm a"
);
};

View File

@@ -0,0 +1,22 @@
import { queryOptions } from "@tanstack/react-query";
import axios from "axios";
export function getOpenOrders() {
return queryOptions({
queryKey: ["getOpenOrders"],
queryFn: () => fetchStockSilo(),
//enabled:
staleTime: 1000,
refetchInterval: 1000 * 60 * 15,
refetchOnWindowFocus: true,
});
}
const fetchStockSilo = async () => {
const { data } = await axios.get(
`/api/datamart/getopenorders?sDay=15&eDay=45`
);
// if we are not localhost ignore the devDir setting.
//const url: string = window.location.host.split(":")[0];
return data.data ?? [];
};

View File

@@ -0,0 +1,61 @@
import { ColumnDef } from "@tanstack/react-table";
import { format } from "date-fns";
// This type is used to define the shape of our data.
// You can use a Zod schema here if you want.
export type Adjustmnets = {
siloAdjust_id: string;
currentStockLevel: string;
newLevel: number;
dateAdjusted: string;
lastDateAdjusted: string;
comment: string;
commentAddedBy: string;
commentDate: string;
add_user: string;
};
export const openOrderColumns: ColumnDef<Adjustmnets>[] = [
{
accessorKey: "Remark",
header: () => <div className="text-left">Carrier/Remark</div>,
cell: ({ row }) => {
const remark: any = row.getValue("Remark");
if (!remark) {
return <p className="text-gray-700/35">No remark</p>;
}
return <p>{remark}</p>;
},
},
{
accessorKey: "DeliveryAddressDescription",
header: "Delivery Address",
},
{
accessorKey: "header",
header: "PO",
},
{
accessorKey: "releaseNumber",
header: "Release #",
},
{
accessorKey: "deliveryDate",
header: "DeliveryDate",
cell: ({ row }) => {
if (row.getValue("deliveryDate")) {
const correctDate = format(
row.getValue("deliveryDate"),
"M/d/yyyy hh:mm"
);
return (
<div className="text-left font-medium">{correctDate}</div>
);
}
},
},
{
accessorKey: "customerItemNumber",
header: "Material #",
},
];

View File

@@ -0,0 +1,251 @@
import {
ColumnDef,
flexRender,
getCoreRowModel,
useReactTable,
getPaginationRowModel,
} from "@tanstack/react-table";
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";
import { Button } from "@/components/ui/button";
import { useState } from "react";
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectLabel,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { ScrollArea } from "@/components/ui/scroll-area";
import { LstCard } from "@/components/extendedUI/LstCard";
import { useLocation } from "@tanstack/react-router";
interface DataTableProps<TData, TValue> {
columns: ColumnDef<TData, TValue>[];
data: TData[];
//style: any;
}
export function OpenOrderTable<TData, TValue>({
columns,
data,
//style,
}: DataTableProps<TData, TValue>) {
const [pagination, setPagination] = useState({
pageIndex: 0, //initial page index
pageSize: 5, //default page size
});
const location = useLocation();
const table = useReactTable({
data,
columns,
getCoreRowModel: getCoreRowModel(),
getPaginationRowModel: getPaginationRowModel(),
onPaginationChange: setPagination,
state: {
//...
pagination,
},
});
//console.log(parseInt(style.height.replace("px", "")) - 50);
return (
<LstCard
className="p-3"
// style={{
// width: `${parseInt(style.width.replace("px", "")) - 50}px`,
// height: `${parseInt(style.height.replace("px", "")) - 150}px`,
// cursor: "move",
// }}
//style={{ overflow: "auto" }}
>
<div>
<div className="flex flex-row justify-between">
<p className="text-center">Open orders </p>
<Select
value={pagination.pageSize.toString()}
onValueChange={(e) =>
setPagination({
...pagination,
pageSize: parseInt(e),
})
}
>
<SelectTrigger className="w-[180px]">
<SelectValue
//id={field.name}
placeholder="Select Page"
/>
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectLabel>Page Size</SelectLabel>
<SelectItem value="5">5</SelectItem>
<SelectItem value="10">10</SelectItem>
<SelectItem value="50">50</SelectItem>
<SelectItem value="100">100</SelectItem>
</SelectGroup>
</SelectContent>
</Select>
</div>
{location.pathname === "/" ? (
<ScrollArea className="h-72 rounded-md border m-2">
<Table
// style={{
// width: `${parseInt(style.width.replace("px", "")) - 50}px`,
// height: `${parseInt(style.height.replace("px", "")) - 200}px`,
// cursor: "move",
// }}
>
<TableHeader>
{table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id}>
{headerGroup.headers.map((header) => {
return (
<TableHead key={header.id}>
{header.isPlaceholder
? null
: flexRender(
header.column
.columnDef
.header,
header.getContext()
)}
</TableHead>
);
})}
</TableRow>
))}
</TableHeader>
<TableBody>
{table.getRowModel().rows?.length ? (
table.getRowModel().rows.map((row) => (
<TableRow
key={row.id}
data-state={
row.getIsSelected() &&
"selected"
}
>
{row
.getVisibleCells()
.map((cell) => (
<TableCell key={cell.id}>
{flexRender(
cell.column
.columnDef.cell,
cell.getContext()
)}
</TableCell>
))}
</TableRow>
))
) : (
<TableRow>
<TableCell
colSpan={columns.length}
className="h-24 text-center"
>
No results.
</TableCell>
</TableRow>
)}
</TableBody>
</Table>
</ScrollArea>
) : (
<ScrollArea className={`h-[725px] rounded-md border m-2`}>
<Table
// style={{
// width: `${parseInt(style.width.replace("px", "")) - 50}px`,
// height: `${parseInt(style.height.replace("px", "")) - 200}px`,
// cursor: "move",
// }}
>
<TableHeader>
{table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id}>
{headerGroup.headers.map((header) => {
return (
<TableHead key={header.id}>
{header.isPlaceholder
? null
: flexRender(
header.column
.columnDef
.header,
header.getContext()
)}
</TableHead>
);
})}
</TableRow>
))}
</TableHeader>
<TableBody>
{table.getRowModel().rows?.length ? (
table.getRowModel().rows.map((row) => (
<TableRow
key={row.id}
data-state={
row.getIsSelected() &&
"selected"
}
>
{row
.getVisibleCells()
.map((cell) => (
<TableCell key={cell.id}>
{flexRender(
cell.column
.columnDef.cell,
cell.getContext()
)}
</TableCell>
))}
</TableRow>
))
) : (
<TableRow>
<TableCell
colSpan={columns.length}
className="h-24 text-center"
>
No results.
</TableCell>
</TableRow>
)}
</TableBody>
</Table>
</ScrollArea>
)}
</div>
<div className="flex items-center justify-end space-x-2">
<Button
variant="outline"
size="sm"
onClick={() => table.previousPage()}
disabled={!table.getCanPreviousPage()}
>
Previous
</Button>
<Button
variant="outline"
size="sm"
onClick={() => table.nextPage()}
disabled={!table.getCanNextPage()}
>
Next
</Button>
</div>
</LstCard>
);
}

View File

@@ -26,7 +26,7 @@ export const columns: ColumnDef<Adjustmnets>[] = [
},
{
accessorKey: "RunningNumber",
header: "Running Number",
header: "Label",
},
{
accessorKey: "ProductionDate",

View File

@@ -33,7 +33,7 @@ export const labelolumns: ColumnDef<Adjustmnets>[] = [
header: "Label Date",
cell: ({ row }) => {
if (row.getValue("upd_date")) {
const correctDate = fixTime(row.getValue("created_at"));
const correctDate = fixTime(row.getValue("upd_date"));
return (
<div className="text-left font-medium">{correctDate}</div>
);

View File

@@ -35,7 +35,7 @@
}
},
"admConfig": {
"build": 231,
"build": 252,
"oldBuild": "backend-0.1.3.zip"
},
"devDependencies": {

View File

@@ -11,18 +11,10 @@ export const getLots = async () => {
return {
success: false,
message: "There was an error getting the lots",
data: lotError,
data: [],
};
}
// if (!lotInfo.data.success) {
// return {
// success: false,
// message: "There was an error getting the lots",
// data: lotInfo.data.message,
// };
// }
return {
success: true,
message: "Current active lots that are technically released.",

View File

@@ -25,7 +25,7 @@ export const updatePrinters = async () => {
})
);
if (prodError) {
if (prodError || prodPrinters?.data.length > 10000) {
//console.log(prodError);
return {
success: false,
@@ -35,7 +35,7 @@ export const updatePrinters = async () => {
}
// do the printer update into our db
const prodPrinterInfo = prodPrinters.data;
const prodPrinterInfo = prodPrinters?.data;
for (let i = 0; i < prodPrinterInfo.length; i++) {
const printerStuff: any = {

View File

@@ -2,7 +2,6 @@
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 });
@@ -15,7 +14,7 @@ app.openapi(
path: "/getlots",
responses: responses(),
}),
async (c) => {
async (c: any) => {
const { data: lotData, error: lotError } = await tryCatch(getLots());
if (lotError) {
@@ -26,9 +25,9 @@ app.openapi(
}
return c.json({
success: lotData.success,
message: lotData.message,
data: lotData.data,
success: lotData?.success,
message: lotData?.message,
data: lotData?.data,
});
}
);

View File

@@ -18,6 +18,20 @@ export const assignedPrinters = async () => {
data: lotError,
};
}
if (l.data.length === 0 && !l.data.sucess) {
createLog(
"error",
"lst",
"ocp",
`There was an error getting the lots: ${l?.message}`
);
return {
success: false,
message: "Error getting lots",
data: [],
};
}
const { data: print, error: printerError } = await tryCatch(getPrinters());
if (printerError) {
@@ -29,17 +43,11 @@ export const assignedPrinters = async () => {
}
const printers: any = print.data ?? [];
const lots: any = l.data.length === 0 ? [] : l.data;
const lots: any = l?.data.length === 0 ? null : l?.data;
if (!lots) {
createLog(
"error",
"lst",
"ocp",
`There was an error getting the lots: ${lots.message}`
);
return;
}
//console.log(lots);
return;
for (let i = 0; i < printers.length; i++) {
// is the printer assinged in alplalabel online?
const assigned = lots?.filter(

View File

@@ -7,7 +7,6 @@ import { eq } from "drizzle-orm";
const authData = btoa("admin:Zebra123!");
let token: string;
let ip: string;
export const readTags = async (reader: string) => {
/**
* Start the read for x seconds then auto stop it
@@ -30,7 +29,7 @@ export const readTags = async (reader: string) => {
ip = readers.find((r) => r.reader === reader)?.readerIP as string;
// start the read
startRead();
startRead(reader, ip);
// start the read
};
@@ -50,7 +49,7 @@ const getReaderToken = async () => {
}
};
const startRead = async () => {
const startRead = async (reader: string, ip: string) => {
await getReaderToken();
try {
const res = await axios.put(
@@ -65,17 +64,17 @@ const startRead = async () => {
if (res.status === 200) {
setTimeout(() => {
stopRead();
}, 2 * 1000);
stopRead(reader, ip);
}, 5 * 1000);
}
// stop after 5 seconds
} catch (error: any) {
if (error.response?.data.code === 3) {
stopRead();
stopRead(reader, ip);
setTimeout(() => {
startRead();
}, 1000);
startRead(reader, ip);
}, 2 * 1000);
}
createLog(
"error",
@@ -86,7 +85,7 @@ const startRead = async () => {
}
};
export const stopRead = async () => {
export const stopRead = async (reader: string, ip: string) => {
await getReaderToken();
try {
const res = await axios.put(
@@ -101,7 +100,7 @@ export const stopRead = async () => {
"error",
"rfid",
"rfid",
`There was an error Stopping the read: ${JSON.stringify(error)}`
`There was an error Stopping the read on ${reader}`
);
}
};

View File

@@ -3,11 +3,32 @@
* Phase 2 we will generate a label to be reprinted at staion 4
*/
import { eq } from "drizzle-orm";
import { db } from "../../../../../database/dbclient.js";
import { rfidReaders } from "../../../../../database/schema/rfidReaders.js";
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
import { createLog } from "../../../logger/logger.js";
import type { TagData } from "../tagData.js";
import { tagStuff } from "../tags/crudTag.js";
export const station3Tags = async (tagData: TagData[]) => {
/**
* Add the new tag to the reader so we know waht was really here
*/
const { error } = await tryCatch(
db
.update(rfidReaders)
.set({ lastTagScanned: tagData[0].tag })
.where(eq(rfidReaders.reader, tagData[0].reader))
);
if (error) {
createLog(
"error",
"rfid",
"rfid",
`${tagData[0].reader} encountered and error addeding ${tagData[0].tag}.`
);
}
createLog(
"info",
"rfid",

View File

@@ -67,18 +67,19 @@ export const wrapperStuff = async (tagData: any) => {
"rfid",
`${tagData[0].tag}, Did not come from a line please check the pallet and manually print the label.`
);
tagStuff(tagData);
monitorChecks();
return {
success: false,
message: `${tagData[0].tag}, Did not come from a line please check the pallet and manually print the label.`,
};
}
if (lines[0].runningNumber) {
if (lines[0]?.runningNumber) {
createLog(
"info",
"rfid",
"rfid",
`Reprint label ${lines[0].runningNumber}`
`Reprint label ${lines[0]?.runningNumber}`
);
} else {
createLog(
@@ -88,7 +89,7 @@ export const wrapperStuff = async (tagData: any) => {
`A new label will be created and linked to this ${tagData[0].tag} tag`
);
const lineNum = parseInt(
checkTag[0]?.lastareaIn.repalceAll("line3", "")
checkTag[0]?.lastareaIn.replace("line3.", "")
);
createLog(
"info",

View File

@@ -58,6 +58,23 @@ const newSubModules = [
active: false,
subSubModule: [],
},
{
name: "Open Orders",
moduleName: "logistics",
description: "Open orders",
link: "/openOrders",
icon: "Truck",
role: [
"viewer",
"technician",
"supervisor",
"manager",
"admin",
"systemAdmin",
],
active: false,
subSubModule: [],
},
// admin module
{

View File

@@ -10,189 +10,196 @@ import { checkHostnamePort } from "../../globalUtils/pingServer.js";
let pool: any;
let connected: boolean = false;
export const initializeProdPool = async () => {
if (!installed) {
createLog(
"info",
"lst",
"sqlProd",
"The server was not installed will reconnect in 5 seconds"
);
setTimeout(() => {
initializeProdPool();
}, 5 * 1000);
if (!installed) {
createLog(
"info",
"lst",
"sqlProd",
"The server was not installed will reconnect in 5 seconds"
);
setTimeout(() => {
initializeProdPool();
}, 5 * 1000);
return { success: false, message: "The server is not installed." };
}
const dbServer = await db
.select()
.from(settings)
.where(eq(settings.name, "dbServer"));
const serverUp = await checkHostnamePort(`${dbServer[0].value}:1433`);
return { success: false, message: "The server is not installed." };
}
const dbServer = await db
.select()
.from(settings)
.where(eq(settings.name, "dbServer"));
const serverUp = await checkHostnamePort(`${dbServer[0].value}:1433`);
if (!serverUp) {
createLog(
"error",
"lst",
"server",
`The sql ${dbServer[0].value} is not reachable`
);
return {
success: false,
message: `The sql ${dbServer[0].value} is not reachable`,
};
}
if (!serverUp) {
createLog(
"error",
"lst",
"server",
`The sql ${dbServer[0].value} is not reachable`
);
return {
success: false,
message: `The sql ${dbServer[0].value} is not reachable`,
data: [],
};
}
// make sure the server is not set to localhost this will prevent some weird issues later but can be localhost on the dev
const serverLoc = await db
.select()
.from(settings)
.where(eq(settings.name, "dbServer"));
if (
serverLoc[0].value === "localhost" &&
process.env.NODE_ENV !== "development"
) {
createLog(
"error",
"lst",
"sqlProd",
"The server is set to localhost, and you are not in development mode."
);
return {
success: false,
message:
"The server is set to localhost, and you are not in development mode.",
};
}
// make sure the server is not set to localhost this will prevent some weird issues later but can be localhost on the dev
const serverLoc = await db
.select()
.from(settings)
.where(eq(settings.name, "dbServer"));
if (
serverLoc[0].value === "localhost" &&
process.env.NODE_ENV !== "development"
) {
createLog(
"error",
"lst",
"sqlProd",
"The server is set to localhost, and you are not in development mode."
);
return {
success: false,
message:
"The server is set to localhost, and you are not in development mode.",
data: [],
};
}
// if you were restarting from the endpoint you get this lovely error
if (connected) {
createLog("error", "lst", "sqlProd", "There is already a connection.");
return { success: false, message: "There is already a connection." };
}
try {
const config = await prodSqlConfig();
pool = await sql.connect(config!);
// if you were restarting from the endpoint you get this lovely error
if (connected) {
createLog("error", "lst", "sqlProd", "There is already a connection.");
return { success: false, message: "There is already a connection." };
}
try {
const config = await prodSqlConfig();
pool = await sql.connect(config!);
createLog(
"info",
"lst",
"sqlProd",
`Connected to ${config?.server}, and looking at ${config?.database}`
);
connected = true;
return {
success: true,
message: "The sql server connection has been closed",
};
} catch (error) {
createLog(
"error",
"lst",
"sqlProd",
`${JSON.stringify(error)}, "There was an error connecting to the pool."`
);
throw new Error("There was an error closing the sql connection");
}
createLog(
"info",
"lst",
"sqlProd",
`Connected to ${config?.server}, and looking at ${config?.database}`
);
connected = true;
return {
success: true,
message: "The sql server connection has been closed",
};
} catch (error) {
createLog(
"error",
"lst",
"sqlProd",
`${JSON.stringify(
error
)}, "There was an error connecting to the pool."`
);
throw new Error("There was an error closing the sql connection");
}
};
export const closePool = async () => {
if (!connected) {
createLog(
"error",
"lst",
"sqlProd",
"There is no connection a connection."
);
return { success: false, message: "There is already a connection." };
}
try {
await pool.close();
createLog("info", "lst", "sqlProd", "Connection pool closed");
connected = false;
return {
success: true,
message: "The sql server connection has been closed",
};
} catch (error) {
createLog(
"error",
"lst",
"sqlProd",
`${JSON.stringify(
error
)}, "There was an error closing the sql connection"`
);
throw new Error("There was an error closing the sql connection");
}
if (!connected) {
createLog(
"error",
"lst",
"sqlProd",
"There is no connection a connection."
);
return { success: false, message: "There is already a connection." };
}
try {
await pool.close();
createLog("info", "lst", "sqlProd", "Connection pool closed");
connected = false;
return {
success: true,
message: "The sql server connection has been closed",
};
} catch (error) {
createLog(
"error",
"lst",
"sqlProd",
`${JSON.stringify(
error
)}, "There was an error closing the sql connection"`
);
throw new Error("There was an error closing the sql connection");
}
};
export async function query(queryToRun: string, name: string) {
/**
* Just an extra catch incase someone tried to run a query while we were not connected to the server or sql server
*/
const dbServer = await db
.select()
.from(settings)
.where(eq(settings.name, "dbServer"));
const serverUp = await checkHostnamePort(`${dbServer[0].value}:1433`);
/**
* Just an extra catch incase someone tried to run a query while we were not connected to the server or sql server
*/
const dbServer = await db
.select()
.from(settings)
.where(eq(settings.name, "dbServer"));
const serverUp = await checkHostnamePort(`${dbServer[0].value}:1433`);
if (!serverUp) {
createLog(
"error",
"lst",
"server",
`The sql ${dbServer[0].value} is not reachable`
);
return {
success: false,
message: `The sql ${dbServer[0].value} is not reachable`,
};
}
if (!connected) {
createLog(
"error",
"lst",
"server",
`The sql ${dbServer[0].value} is not connected`
);
return {
success: false,
message: `The sql ${dbServer[0].value} is not not connected`,
};
}
/**
* We no longer need to send over the plant token change as we do it inside the query function.
*/
const plantToken = await db
.select()
.from(settings)
.where(eq(settings.name, "plantToken"));
const query = queryToRun.replaceAll("test1", plantToken[0].value);
try {
const result = await pool.request().query(query);
return result.recordset;
} catch (error: any) {
if (error.code === "ETIMEOUT") {
createLog(
"error",
"lst",
"sqlProd",
`${JSON.stringify(error)}, ${name} did not run due to a timeout.`
);
throw new Error(`${name} query did not run due to a timeout.`);
if (!serverUp) {
createLog(
"error",
"lst",
"server",
`The sql ${dbServer[0].value} is not reachable`
);
return {
success: false,
message: `The sql ${dbServer[0].value} is not reachable`,
data: [],
};
}
if (error.code === "EREQUEST") {
throw new Error(
`${name} encoutnered an error ${error.originalError.info.message}`
);
if (!connected) {
createLog(
"error",
"lst",
"server",
`The sql ${dbServer[0].value} is not connected`
);
return {
success: false,
message: `The sql ${dbServer[0].value} is not not connected`,
};
}
/**
* We no longer need to send over the plant token change as we do it inside the query function.
*/
const plantToken = await db
.select()
.from(settings)
.where(eq(settings.name, "plantToken"));
const query = queryToRun.replaceAll("test1", plantToken[0].value);
//console.log(error.originalError.info.message);
//EREQUEST
//throw new Error(`${name} encoutnered an error ${error.code}`);
}
try {
const result = await pool.request().query(query);
return result.recordset;
} catch (error: any) {
if (error.code === "ETIMEOUT") {
createLog(
"error",
"lst",
"sqlProd",
`${JSON.stringify(
error
)}, ${name} did not run due to a timeout.`
);
throw new Error(`${name} query did not run due to a timeout.`);
}
if (error.code === "EREQUEST") {
throw new Error(
`${name} encoutnered an error ${error.originalError.info.message}`
);
}
//console.log(error.originalError.info.message);
//EREQUEST
//throw new Error(`${name} encoutnered an error ${error.code}`);
}
}

View File

@@ -13,6 +13,7 @@ IdAdresse AS customerID,
LieferAdressBez as DeliveryAddressDescription,
AbrufLadeDatum AS loadingDate,
AbrufLiefertermin AS deliveryDate
,Remark
--,OrderStatus = 'loading'
--,*
FROM alplaprod_test1.dbo.V_TrackerAuftragsAbrufe (nolock) x