From c777395b0350f60bd457c3164ed1ae478249df3a Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 14 Nov 2025 11:49:57 -0600 Subject: [PATCH] feat(quality): priority ranking added --- frontend/src/lib/tableStuff/TableNoExpand.tsx | 2 +- frontend/src/routeTree.gen.ts | 21 + .../old/-components/dashboard/AddCards.tsx | 1 + .../old/-components/dashboard/Dashboard.tsx | 17 +- .../old/-components/layout/lst-sidebar.tsx | 4 +- .../layout/side-components/quality.tsx | 58 +- .../old/-utils/querys/quality/getPallets.tsx | 20 + .../quality/-components/QualityRequest.tsx | 331 +++ .../old/quality/-components/RequestPallet.tsx | 161 ++ .../old/quality/-components/WarehouseCard.tsx | 121 + .../src/routes/_old/old/quality/index.tsx | 44 + .../migrations/0076_stiff_champions.sql | 1 + .../migrations/meta/0076_snapshot.json | 2278 +++++++++++++++++ lstV2/database/migrations/meta/_journal.json | 7 + lstV2/database/schema/qualityRequest.ts | 73 +- .../quality/controller/addNewPallet.ts | 62 +- .../quality/controller/getRequests.ts | 35 +- .../quality/controller/qualityCycle.ts | 4 +- 18 files changed, 3137 insertions(+), 103 deletions(-) create mode 100644 frontend/src/routes/_old/old/-utils/querys/quality/getPallets.tsx create mode 100644 frontend/src/routes/_old/old/quality/-components/QualityRequest.tsx create mode 100644 frontend/src/routes/_old/old/quality/-components/RequestPallet.tsx create mode 100644 frontend/src/routes/_old/old/quality/-components/WarehouseCard.tsx create mode 100644 frontend/src/routes/_old/old/quality/index.tsx create mode 100644 lstV2/database/migrations/0076_stiff_champions.sql create mode 100644 lstV2/database/migrations/meta/0076_snapshot.json diff --git a/frontend/src/lib/tableStuff/TableNoExpand.tsx b/frontend/src/lib/tableStuff/TableNoExpand.tsx index 52ae23a..93def2e 100644 --- a/frontend/src/lib/tableStuff/TableNoExpand.tsx +++ b/frontend/src/lib/tableStuff/TableNoExpand.tsx @@ -40,7 +40,7 @@ export default function TableNoExpand({ }); return (
-
+
{table.getHeaderGroups().map((headerGroup) => ( diff --git a/frontend/src/routeTree.gen.ts b/frontend/src/routeTree.gen.ts index 76949d3..ddbe9ec 100644 --- a/frontend/src/routeTree.gen.ts +++ b/frontend/src/routeTree.gen.ts @@ -21,6 +21,7 @@ import { Route as AppAdminLayoutRouteRouteImport } from './routes/_app/_adminLay import { Route as OldOldIndexRouteImport } from './routes/_old/old/index' import { Route as AppauthLoginRouteImport } from './routes/_app/(auth)/login' import { Route as OldOldRfidIndexRouteImport } from './routes/_old/old/rfid/index' +import { Route as OldOldQualityIndexRouteImport } from './routes/_old/old/quality/index' import { Route as OldOldOcpIndexRouteImport } from './routes/_old/old/ocp/index' import { Route as MobileMobileLayoutMIndexRouteImport } from './routes/_mobile/_mobileLayout/m/index' import { Route as AppForkliftsForkliftsIndexRouteImport } from './routes/_app/_forklifts/forklifts/index' @@ -107,6 +108,11 @@ const OldOldRfidIndexRoute = OldOldRfidIndexRouteImport.update({ path: '/rfid/', getParentRoute: () => OldOldRouteRoute, } as any) +const OldOldQualityIndexRoute = OldOldQualityIndexRouteImport.update({ + id: '/quality/', + path: '/quality/', + getParentRoute: () => OldOldRouteRoute, +} as any) const OldOldOcpIndexRoute = OldOldOcpIndexRouteImport.update({ id: '/ocp/', path: '/ocp/', @@ -303,6 +309,7 @@ export interface FileRoutesByFullPath { '/forklifts': typeof AppForkliftsForkliftsIndexRoute '/m': typeof MobileMobileLayoutMIndexRoute '/old/ocp': typeof OldOldOcpIndexRoute + '/old/quality': typeof OldOldQualityIndexRoute '/old/rfid': typeof OldOldRfidIndexRoute '/admin/modules': typeof AppAdminLayoutAdminSystemModulesRoute '/admin/settings': typeof AppAdminLayoutAdminSystemSettingsRoute @@ -339,6 +346,7 @@ export interface FileRoutesByTo { '/forklifts': typeof AppForkliftsForkliftsIndexRoute '/m': typeof MobileMobileLayoutMIndexRoute '/old/ocp': typeof OldOldOcpIndexRoute + '/old/quality': typeof OldOldQualityIndexRoute '/old/rfid': typeof OldOldRfidIndexRoute '/admin/modules': typeof AppAdminLayoutAdminSystemModulesRoute '/admin/settings': typeof AppAdminLayoutAdminSystemSettingsRoute @@ -383,6 +391,7 @@ export interface FileRoutesById { '/_app/_forklifts/forklifts/': typeof AppForkliftsForkliftsIndexRoute '/_mobile/_mobileLayout/m/': typeof MobileMobileLayoutMIndexRoute '/_old/old/ocp/': typeof OldOldOcpIndexRoute + '/_old/old/quality/': typeof OldOldQualityIndexRoute '/_old/old/rfid/': typeof OldOldRfidIndexRoute '/_app/_adminLayout/admin/_system/modules': typeof AppAdminLayoutAdminSystemModulesRoute '/_app/_adminLayout/admin/_system/settings': typeof AppAdminLayoutAdminSystemSettingsRoute @@ -422,6 +431,7 @@ export interface FileRouteTypes { | '/forklifts' | '/m' | '/old/ocp' + | '/old/quality' | '/old/rfid' | '/admin/modules' | '/admin/settings' @@ -458,6 +468,7 @@ export interface FileRouteTypes { | '/forklifts' | '/m' | '/old/ocp' + | '/old/quality' | '/old/rfid' | '/admin/modules' | '/admin/settings' @@ -501,6 +512,7 @@ export interface FileRouteTypes { | '/_app/_forklifts/forklifts/' | '/_mobile/_mobileLayout/m/' | '/_old/old/ocp/' + | '/_old/old/quality/' | '/_old/old/rfid/' | '/_app/_adminLayout/admin/_system/modules' | '/_app/_adminLayout/admin/_system/settings' @@ -602,6 +614,13 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof OldOldRfidIndexRouteImport parentRoute: typeof OldOldRouteRoute } + '/_old/old/quality/': { + id: '/_old/old/quality/' + path: '/quality' + fullPath: '/old/quality' + preLoaderRoute: typeof OldOldQualityIndexRouteImport + parentRoute: typeof OldOldRouteRoute + } '/_old/old/ocp/': { id: '/_old/old/ocp/' path: '/ocp' @@ -949,6 +968,7 @@ const MobileMobileLayoutRouteRouteWithChildren = interface OldOldRouteRouteChildren { OldOldIndexRoute: typeof OldOldIndexRoute OldOldOcpIndexRoute: typeof OldOldOcpIndexRoute + OldOldQualityIndexRoute: typeof OldOldQualityIndexRoute OldOldRfidIndexRoute: typeof OldOldRfidIndexRoute OldOldlogisticsSiloAdjustmentsHistRoute: typeof OldOldlogisticsSiloAdjustmentsHistRoute OldOldlogisticsBarcodegenIndexRoute: typeof OldOldlogisticsBarcodegenIndexRoute @@ -964,6 +984,7 @@ interface OldOldRouteRouteChildren { const OldOldRouteRouteChildren: OldOldRouteRouteChildren = { OldOldIndexRoute: OldOldIndexRoute, OldOldOcpIndexRoute: OldOldOcpIndexRoute, + OldOldQualityIndexRoute: OldOldQualityIndexRoute, OldOldRfidIndexRoute: OldOldRfidIndexRoute, OldOldlogisticsSiloAdjustmentsHistRoute: OldOldlogisticsSiloAdjustmentsHistRoute, diff --git a/frontend/src/routes/_old/old/-components/dashboard/AddCards.tsx b/frontend/src/routes/_old/old/-components/dashboard/AddCards.tsx index 2acd5be..476bc55 100644 --- a/frontend/src/routes/_old/old/-components/dashboard/AddCards.tsx +++ b/frontend/src/routes/_old/old/-components/dashboard/AddCards.tsx @@ -29,6 +29,7 @@ export function AddCards() { +
diff --git a/frontend/src/routes/_old/old/-components/dashboard/Dashboard.tsx b/frontend/src/routes/_old/old/-components/dashboard/Dashboard.tsx index 9e86bd9..8b10196 100644 --- a/frontend/src/routes/_old/old/-components/dashboard/Dashboard.tsx +++ b/frontend/src/routes/_old/old/-components/dashboard/Dashboard.tsx @@ -1,4 +1,5 @@ import { useCardStore } from "../../-lib/store/useCardStore"; +import Quality from "../../quality/-components/WarehouseCard"; import INVCheckCard from "../logistics/warehouse/InventoryCard"; import OpenOrders from "../logistics/warehouse/openOrders"; import PPOO from "../logistics/warehouse/PPOOCard"; @@ -7,6 +8,7 @@ const componentsMap: any = { ppoo: PPOO, inv: INVCheckCard, openOrder: OpenOrders, + qualityCard: Quality, //QualityRequest, }; @@ -26,14 +28,21 @@ export default function DashBoard() {
); - } else { - //console.log(name.split("-")[0], a); + } + + if (name === "qualityCard") { return ( -
- +
+
); } + //console.log(name.split("-")[0], a); + return ( +
+ +
+ ); })}
); diff --git a/frontend/src/routes/_old/old/-components/layout/lst-sidebar.tsx b/frontend/src/routes/_old/old/-components/layout/lst-sidebar.tsx index dc890e0..8be6139 100644 --- a/frontend/src/routes/_old/old/-components/layout/lst-sidebar.tsx +++ b/frontend/src/routes/_old/old/-components/layout/lst-sidebar.tsx @@ -17,6 +17,7 @@ import { AdminSideBar } from "./side-components/admin"; import { Header } from "./side-components/header"; import { LogisticsSideBar } from "./side-components/logistics"; import { ProductionSideBar } from "./side-components/production"; +import { QualitySideBar } from "./side-components/quality"; export function AppSidebar() { const { session } = useAuth(); @@ -31,11 +32,12 @@ export function AppSidebar() { {/* userAccess("logistics", ["systemAdmin", "admin","manager","viewer"]) */} + {userAccess(null, ["systemAdmin"]) && ( <> {/* - */} + */} )} diff --git a/frontend/src/routes/_old/old/-components/layout/side-components/quality.tsx b/frontend/src/routes/_old/old/-components/layout/side-components/quality.tsx index 9adfbeb..67ed0ac 100644 --- a/frontend/src/routes/_old/old/-components/layout/side-components/quality.tsx +++ b/frontend/src/routes/_old/old/-components/layout/side-components/quality.tsx @@ -1,4 +1,6 @@ -import { Printer } from "lucide-react"; +import { Cat, Printer } from "lucide-react"; +import type { UserRoles } from "@/lib/authClient"; +import type { User } from "@/types"; import { SidebarGroup, SidebarGroupContent, @@ -7,31 +9,49 @@ import { SidebarMenuButton, SidebarMenuItem, } from "../../../../../../components/ui/sidebar"; +import { useModuleStore } from "../../../-lib/store/useModuleStore"; +import { hasPageAccess } from "../../../-utils/userAccess"; -const items = [ - { - title: "Qaulity Request", - url: "#", - icon: Printer, - }, -]; +const iconMap: any = { + Printer: Printer, + Cat: Cat, +}; + +export function QualitySideBar({ + user, + userRoles, +}: { + user: User | null; + userRoles: UserRoles[] | null; +}) { + const { modules } = useModuleStore(); + + const items = modules?.filter((m) => m.category === "quality" && m.active); + const userUpdate = { ...user, roles: userRoles }; -export function QualitySideBar() { return ( Quality - {items.map((item) => ( - - - - - {item.title} - - - - ))} + {items.map((item) => { + if (!item.active) return; + const Icon = iconMap[item.icon === "" ? "Cat" : item.icon]; + return ( + + <> + {hasPageAccess(userUpdate as any, item.roles, item.name) && ( + + + + {item.name} + + + )} + + + ); + })} diff --git a/frontend/src/routes/_old/old/-utils/querys/quality/getPallets.tsx b/frontend/src/routes/_old/old/-utils/querys/quality/getPallets.tsx new file mode 100644 index 0000000..9568146 --- /dev/null +++ b/frontend/src/routes/_old/old/-utils/querys/quality/getPallets.tsx @@ -0,0 +1,20 @@ +import { queryOptions } from "@tanstack/react-query"; +import axios from "axios"; + +export function getPallets() { + return queryOptions({ + queryKey: ["getPallets"], + queryFn: () => fetch(), + //enabled: + staleTime: 1000, + refetchInterval: 60 * 1000, + refetchOnWindowFocus: true, + }); +} + +const fetch = async () => { + const { data } = await axios.get(`/lst/old/api/quality/getrequest`); + // if we are not localhost ignore the devDir setting. + //const url: string = window.location.host.split(":")[0]; + return data.data ?? []; +}; diff --git a/frontend/src/routes/_old/old/quality/-components/QualityRequest.tsx b/frontend/src/routes/_old/old/quality/-components/QualityRequest.tsx new file mode 100644 index 0000000..fce8f34 --- /dev/null +++ b/frontend/src/routes/_old/old/quality/-components/QualityRequest.tsx @@ -0,0 +1,331 @@ +import { useQuery } from "@tanstack/react-query"; +import { useNavigate, useRouterState } from "@tanstack/react-router"; +import { createColumnHelper } from "@tanstack/react-table"; +import axios from "axios"; +import { ArrowDown, ArrowUp } from "lucide-react"; +import { useState } from "react"; +import { toast } from "sonner"; +import { Button } from "@/components/ui/button"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; +import { useAuth, userAccess } from "@/lib/authClient"; +import TableNoExpand from "@/lib/tableStuff/TableNoExpand"; +import { getPallets } from "../../-utils/querys/quality/getPallets"; + +type Pallets = { + request_id: string; + article: string; + description: string; + runningNr: string; + lotNr: string; + warehouseAtRequest: string; + locationAtRequest: string; + warehouseMovedTo: string; + locationMovedTo: string; + durationToMove: null; + qualityDurationToInspect: number; + returnDurationToInspect: number; + locationDropOff: string; + palletStatus: number; + palletStatusText: string; + palletRequest: number; + priority: number; + add_date: Date; + add_user: string; + upd_date: Date; + upd_user: string; +}; + +export default function QualityRequest() { + const { data, isLoading, refetch } = useQuery(getPallets()); + const columnHelper = createColumnHelper(); + const { session } = useAuth(); + const navigate = useNavigate(); + const router = useRouterState(); + const currentPath = router.location.href; + + const palletCompleted = async (e: any) => { + if (!session || !session.user) { + toast.error("You are allowed to do this unless you are logged in"); + navigate({ to: "/login", search: { redirect: currentPath } }); + return; + } + const data = { + username: session?.user.username, + runningNr: Number(e.original.runningNr), + palletStatusText: "return", + }; + try { + const res = await axios.post("/lst/old/api/quality/newrequest", data); + + //console.log(res.data); + + if (res.data.success) { + toast.success(res.data.message); + refetch(); + } + + if (!res.data.success) { + toast.error(res.data.message); + } + } catch (error) { + console.log(error); + toast.error("Encountered and error please try again"); + } + }; + + const columns = [ + columnHelper.accessor("article", { + header: ({ column }) => { + return ( + + ); + }, + }), + columnHelper.accessor("description", { + header: ({ column }) => { + return ( + + ); + }, + }), + columnHelper.accessor("runningNr", { + header: ({ column }) => { + return ( + + ); + }, + }), + columnHelper.accessor("lotNr", { + header: ({ column }) => { + return ( + + ); + }, + }), + columnHelper.accessor("locationAtRequest", { + header: ({ column }) => { + return ( + + ); + }, + }), + columnHelper.accessor("locationDropOff", { + header: ({ column }) => { + return ( + + ); + }, + cell: ({ getValue }) => { + return ( + <> + {getValue() ? getValue() : "missing dropoff location"} + + ); + }, + }), + columnHelper.accessor("palletStatusText", { + header: ({ column }) => { + return ( + + ); + }, + }), + columnHelper.accessor("palletRequest", { + header: ({ column }) => { + return ( + + ); + }, + cell: ({ row }) => { + // if pending + const okToCompleteStats = [2, 4, 5]; + return ( + <> + {okToCompleteStats.includes(row.original.palletStatus) ? ( + + ) : ( + Pending to be completed + )} + + ); + }, + }), + ]; + + let adminColumns: any = []; + if (userAccess("quality", ["systemAdmin", "admin", "supervisor"])) { + adminColumns = [ + ...columns, + columnHelper.accessor("priority", { + header: ({ column }) => { + return ( + + ); + }, + cell: ({ row, getValue }) => { + // if pending + + const [p, setP] = useState(`${getValue()}`); + console.log(getValue()); + return ( + <> + + + ); + }, + }), + ]; + } + if (isLoading) { + return
Loading user data
; + } + return ; +} diff --git a/frontend/src/routes/_old/old/quality/-components/RequestPallet.tsx b/frontend/src/routes/_old/old/quality/-components/RequestPallet.tsx new file mode 100644 index 0000000..c0c8f3d --- /dev/null +++ b/frontend/src/routes/_old/old/quality/-components/RequestPallet.tsx @@ -0,0 +1,161 @@ +import { useQuery } from "@tanstack/react-query"; +import { useNavigate, useRouterState } from "@tanstack/react-router"; +import axios from "axios"; +import { toast } from "sonner"; +import { Button } from "@/components/ui/button"; +import { + Dialog, + DialogClose, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog"; +import { useAuth } from "@/lib/authClient"; +import { useAppForm } from "@/lib/formStuff"; +import { getPallets } from "../../-utils/querys/quality/getPallets"; + +const areaSelection = [ + { value: "rework", label: "Rework" }, + { value: "holdArea", label: "Hold Area" }, + { value: "inspectionArea", label: "Inspection Area" }, +]; +export default function RequestPallet() { + const { session } = useAuth(); + const navigate = useNavigate(); + const router = useRouterState(); + const { refetch } = useQuery(getPallets()); + const currentPath = router.location.href; + const form = useAppForm({ + defaultValues: { + username: "", + runningNr: 0, + moveTo: "", + }, + onSubmit: async ({ value }) => { + if (!session || !session.user) { + toast.error("You are allowed to do this unless you are logged in"); + navigate({ to: "/login", search: { redirect: currentPath } }); + return; + } + if (value.runningNr === 0) { + return toast.error( + "You did not change the running number, please add a valid running number", + ); + } + const postData = { + runningNr: Number(value.runningNr), + moveTo: value.moveTo, + username: session?.user.username, + }; + + console.log(postData); + try { + const res = await axios.post( + "/lst/old/api/quality/newrequest", + postData, + ); + + console.log(res.data); + + if (res.data.success) { + toast.success(res.data.message); + form.reset(); + refetch(); + } + + if (!res.data.success) { + toast.error(res.data.message); + } + } catch (error) { + console.log(error); + toast.error("Encountered and error please try again"); + } + }, + }); + return ( + + + + + + + + Request a pallet for the warehouse to retrieve{" "} + + + This form is used to request a pallet to be brought up to be + inspected, reworked, placed on hold, or please fill out and the + warehouse will see and bring to the designated location. Once + finished click done or cancel. + + +
+
{ + e.preventDefault(); + form.handleSubmit(); + }} + > +
+ ( + + )} + /> +
+
+ { + // onValueChange(value); + // }, + // }} + children={(field) => ( + + )} + /> +
+
+ + + + + + + + + +
+ +
+
+
+ ); +} diff --git a/frontend/src/routes/_old/old/quality/-components/WarehouseCard.tsx b/frontend/src/routes/_old/old/quality/-components/WarehouseCard.tsx new file mode 100644 index 0000000..de50de0 --- /dev/null +++ b/frontend/src/routes/_old/old/quality/-components/WarehouseCard.tsx @@ -0,0 +1,121 @@ +//import { LstCard } from "@/components/extendedUI/LstCard"; + +import { useQuery } from "@tanstack/react-query"; +import { createColumnHelper } from "@tanstack/react-table"; +import { ArrowDown, ArrowUp } from "lucide-react"; +import { Button } from "@/components/ui/button"; +import { CardHeader } from "@/components/ui/card"; +import TableNoExpand from "@/lib/tableStuff/TableNoExpand"; +import { LstCard } from "../../-components/extendedUi/LstCard"; +import { getPallets } from "../../-utils/querys/quality/getPallets"; + +//import { CircleX } from "lucide-react"; +//import { Suspense } from "react"; +//import { toast } from "sonner"; + +type Pallets = { + article: string; + runningNr: string; + warehouseAtRequest: string; + locationAtRequest: string; + locationDropOff: string; +}; + +export default function PPOO() { + //{ style = {} } + const { data, isError, isLoading } = useQuery(getPallets()); + const columnHelper = createColumnHelper(); + + if (isLoading) return
Loading pallet data...
; + if (isError) { + return ( +
+

There was an error getting the pallets.

+
+ ); + } + const monitoring = [1, 4, 6, 7]; + const filteredData = data.filter((n: any) => + monitoring.includes(n.palletStatus), + ); + + const columns = [ + columnHelper.accessor("article", { + header: ({ column }) => { + return ( + + ); + }, + }), + columnHelper.accessor("runningNr", { + header: ({ column }) => { + return ( + + ); + }, + }), + columnHelper.accessor("locationAtRequest", { + header: ({ column }) => { + return ( + + ); + }, + }), + columnHelper.accessor("locationDropOff", { + header: ({ column }) => { + return ( + + ); + }, + }), + ]; + + return ( + + + Quality Request Card Total Pallets {filteredData.length} + + + + ); +} diff --git a/frontend/src/routes/_old/old/quality/index.tsx b/frontend/src/routes/_old/old/quality/index.tsx new file mode 100644 index 0000000..cafa3d7 --- /dev/null +++ b/frontend/src/routes/_old/old/quality/index.tsx @@ -0,0 +1,44 @@ +import { createFileRoute, redirect } from "@tanstack/react-router"; +import { checkUserAccess } from "@/lib/authClient"; +import QualityRequest from "./-components/QualityRequest"; +import RequestPallet from "./-components/RequestPallet"; + +export const Route = createFileRoute("/_old/old/quality/")({ + component: RouteComponent, + beforeLoad: async () => { + const auth = await checkUserAccess({ + allowedRoles: [ + "systemAdmin", + "technician", + "admin", + "manager", + "supervisor", + ], + moduleName: "quality", // optional + }); + + 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 ( +
+
+ +
+ + +
+ ); +} diff --git a/lstV2/database/migrations/0076_stiff_champions.sql b/lstV2/database/migrations/0076_stiff_champions.sql new file mode 100644 index 0000000..a5633a1 --- /dev/null +++ b/lstV2/database/migrations/0076_stiff_champions.sql @@ -0,0 +1 @@ +ALTER TABLE "qualityRequest" ADD COLUMN "priority" integer DEFAULT 4; \ No newline at end of file diff --git a/lstV2/database/migrations/meta/0076_snapshot.json b/lstV2/database/migrations/meta/0076_snapshot.json new file mode 100644 index 0000000..a2b46e2 --- /dev/null +++ b/lstV2/database/migrations/meta/0076_snapshot.json @@ -0,0 +1,2278 @@ +{ + "id": "3d27a1ce-85ec-4e83-96c4-f167f1e57c04", + "prevId": "8eb9c4aa-af07-4a9c-b660-d91a17fb0f46", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.apiHits": { + "name": "apiHits", + "schema": "", + "columns": { + "apiHit_id": { + "name": "apiHit_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastBody": { + "name": "lastBody", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "stats": { + "name": "stats", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 1 + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "endpoint": { + "name": "endpoint", + "columns": [ + { + "expression": "endpoint", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "ip", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.commandLog": { + "name": "commandLog", + "schema": "", + "columns": { + "commandLog_id": { + "name": "commandLog_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "commandUsed": { + "name": "commandUsed", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bodySent": { + "name": "bodySent", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "reasonUsed": { + "name": "reasonUsed", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.fifoIndex": { + "name": "fifoIndex", + "schema": "", + "columns": { + "fifoIndex_id": { + "name": "fifoIndex_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "lot": { + "name": "lot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "av": { + "name": "av", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "runningNr": { + "name": "runningNr", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "prodDate": { + "name": "prodDate", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "fifoFollowed": { + "name": "fifoFollowed", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "fifo_runningNr": { + "name": "fifo_runningNr", + "columns": [ + { + "expression": "runningNr", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.invHistoricalData": { + "name": "invHistoricalData", + "schema": "", + "columns": { + "inv_id": { + "name": "inv_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "histDate": { + "name": "histDate", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "plantToken": { + "name": "plantToken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "article": { + "name": "article", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "articleDescription": { + "name": "articleDescription", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "materialType": { + "name": "materialType", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "total_QTY": { + "name": "total_QTY", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "avaliable_QTY": { + "name": "avaliable_QTY", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "coa_QTY": { + "name": "coa_QTY", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "held_QTY": { + "name": "held_QTY", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lot_number": { + "name": "lot_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "consignment": { + "name": "consignment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "upd_user": { + "name": "upd_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'lst'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.logs": { + "name": "logs", + "schema": "", + "columns": { + "log_id": { + "name": "log_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "level": { + "name": "level", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'LST_Serivce'" + }, + "service": { + "name": "service", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'system'" + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "checked": { + "name": "checked", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.modules": { + "name": "modules", + "schema": "", + "columns": { + "module_id": { + "name": "module_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "roles": { + "name": "roles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[\"view\",\"systemAdmin\"]'::jsonb" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "module_name": { + "name": "module_name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notifications": { + "name": "notifications", + "schema": "", + "columns": { + "notify_id": { + "name": "notify_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "checkInterval": { + "name": "checkInterval", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'1'" + }, + "timeType": { + "name": "timeType", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'hour'" + }, + "emails": { + "name": "emails", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "lastRan": { + "name": "lastRan", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "notifiySettings": { + "name": "notifiySettings", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + } + }, + "indexes": { + "notify_name": { + "name": "notify_name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ocmeData": { + "name": "ocmeData", + "schema": "", + "columns": { + "ocme_id": { + "name": "ocme_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "sscc": { + "name": "sscc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runningNr": { + "name": "runningNr", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "completed": { + "name": "completed", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "lineNum": { + "name": "lineNum", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "pickedUp": { + "name": "pickedUp", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "areaFrom": { + "name": "areaFrom", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "ocme_runningNr": { + "name": "ocme_runningNr", + "columns": [ + { + "expression": "runningNr", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ocmeCycleCounts": { + "name": "ocmeCycleCounts", + "schema": "", + "columns": { + "ocme_id": { + "name": "ocme_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "laneId": { + "name": "laneId", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "warehouseName": { + "name": "warehouseName", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "laneName": { + "name": "laneName", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "good": { + "name": "good", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "cycleCount": { + "name": "cycleCount", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.manualPrinting": { + "name": "manualPrinting", + "schema": "", + "columns": { + "print_id": { + "name": "print_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "line": { + "name": "line", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "printReason": { + "name": "printReason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "initials": { + "name": "initials", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "additionalComments": { + "name": "additionalComments", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "add_user": { + "name": "add_user", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.printerData": { + "name": "printerData", + "schema": "", + "columns": { + "printer_id": { + "name": "printer_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "humanReadableId": { + "name": "humanReadableId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ipAddress": { + "name": "ipAddress", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "port": { + "name": "port", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "statusText": { + "name": "statusText", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastTimePrinted": { + "name": "lastTimePrinted", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "assigned": { + "name": "assigned", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "remark": { + "name": "remark", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "printDelay": { + "name": "printDelay", + "type": "numeric", + "primaryKey": false, + "notNull": false, + "default": "'90'" + }, + "monitorState": { + "name": "monitorState", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "processes": { + "name": "processes", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "print_delay_override": { + "name": "print_delay_override", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "humanReadableId": { + "name": "humanReadableId", + "columns": [ + { + "expression": "humanReadableId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.prodlabels": { + "name": "prodlabels", + "schema": "", + "columns": { + "label_id": { + "name": "label_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "printerID": { + "name": "printerID", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "printerName": { + "name": "printerName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "line": { + "name": "line", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "runningNr": { + "name": "runningNr", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "add_user": { + "name": "add_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'lst'" + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "runningNr": { + "name": "runningNr", + "columns": [ + { + "expression": "runningNr", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.prodPermissions": { + "name": "prodPermissions", + "schema": "", + "columns": { + "prodPerm_id": { + "name": "prodPerm_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "roles": { + "name": "roles", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "rolesLegacy": { + "name": "rolesLegacy", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "prodPermName": { + "name": "prodPermName", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.qualityRequest": { + "name": "qualityRequest", + "schema": "", + "columns": { + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "article": { + "name": "article", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runningNr": { + "name": "runningNr", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lotNr": { + "name": "lotNr", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "warehouseAtRequest": { + "name": "warehouseAtRequest", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "locationAtRequest": { + "name": "locationAtRequest", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "warehouseMovedTo": { + "name": "warehouseMovedTo", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "locationMovedTo": { + "name": "locationMovedTo", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "durationToMove": { + "name": "durationToMove", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "qualityDurationToInspect": { + "name": "qualityDurationToInspect", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "returnDurationToInspect": { + "name": "returnDurationToInspect", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "locationDropOff": { + "name": "locationDropOff", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "palletStatus": { + "name": "palletStatus", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "palletStatusText": { + "name": "palletStatusText", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "palletRequest": { + "name": "palletRequest", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "priority": { + "name": "priority", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 4 + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "add_user": { + "name": "add_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'LST'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_user": { + "name": "upd_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'LST'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.labelRatio": { + "name": "labelRatio", + "schema": "", + "columns": { + " ratio_id": { + "name": " ratio_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'labels'" + }, + "autoLabel": { + "name": "autoLabel", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "manualLabel": { + "name": "manualLabel", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "lastReset": { + "name": "lastReset", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "labelname": { + "name": "labelname", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.rfidReaders": { + "name": "rfidReaders", + "schema": "", + "columns": { + "rfidReader_id": { + "name": "rfidReader_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "reader": { + "name": "reader", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "readerIP": { + "name": "readerIP", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastHeartBeat": { + "name": "lastHeartBeat", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "lastTrigger": { + "name": "lastTrigger", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "lastTiggerGood": { + "name": "lastTiggerGood", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "lastTagScanned": { + "name": "lastTagScanned", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "goodReads": { + "name": "goodReads", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "badReads": { + "name": "badReads", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + } + }, + "indexes": { + "reader": { + "name": "reader", + "columns": [ + { + "expression": "reader", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.rfidTags": { + "name": "rfidTags", + "schema": "", + "columns": { + "rfidTag_id": { + "name": "rfidTag_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tagHex": { + "name": "tagHex", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag": { + "name": "tag", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastRead": { + "name": "lastRead", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "counts": { + "name": "counts", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "lastareaIn": { + "name": "lastareaIn", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "runningNumber": { + "name": "runningNumber", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "antenna": { + "name": "antenna", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "tagStrength": { + "name": "tagStrength", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "tagHex": { + "name": "tagHex", + "columns": [ + { + "expression": "tagHex", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.roles": { + "name": "roles", + "schema": "", + "columns": { + "role_id": { + "name": "role_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "role_name": { + "name": "role_name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.serverData": { + "name": "serverData", + "schema": "", + "columns": { + "server_id": { + "name": "server_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "sName": { + "name": "sName", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "serverDNS": { + "name": "serverDNS", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "plantToken": { + "name": "plantToken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "idAddress": { + "name": "idAddress", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "greatPlainsPlantCode": { + "name": "greatPlainsPlantCode", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "streetAddress": { + "name": "streetAddress", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cityState": { + "name": "cityState", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "zipcode": { + "name": "zipcode", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "contactEmail": { + "name": "contactEmail", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contactPhone": { + "name": "contactPhone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "customerTiAcc": { + "name": "customerTiAcc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lstServerPort": { + "name": "lstServerPort", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "serverLoc": { + "name": "serverLoc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "oldVersion": { + "name": "oldVersion", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastUpdated": { + "name": "lastUpdated", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "shippingHours": { + "name": "shippingHours", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'[{\"early\": \"06:30\", \"late\": \"23:00\"}]'" + }, + "tiPostTime": { + "name": "tiPostTime", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'[{\"from\": \"24\", \"to\": \"24\"}]'" + }, + "otherSettings": { + "name": "otherSettings", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[{\"specialInstructions\":\"something for ti\",\"active\":false}]'::jsonb" + }, + "isUpgrading": { + "name": "isUpgrading", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + } + }, + "indexes": { + "plantToken": { + "name": "plantToken", + "columns": [ + { + "expression": "plantToken", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.settings": { + "name": "settings", + "schema": "", + "columns": { + "role_id": { + "name": "role_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "moduleName": { + "name": "moduleName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "roles": { + "name": "roles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[\"systemAdmin\"]'::jsonb" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "name": { + "name": "name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.siloAdjustments": { + "name": "siloAdjustments", + "schema": "", + "columns": { + "siloAdjust_id": { + "name": "siloAdjust_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "level": { + "name": "level", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "locationID": { + "name": "locationID", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "currentStockLevel": { + "name": "currentStockLevel", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "newLevel": { + "name": "newLevel", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "''" + }, + "dateAdjusted": { + "name": "dateAdjusted", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "lastDateAdjusted": { + "name": "lastDateAdjusted", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "commentAddedBy": { + "name": "commentAddedBy", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "commentDate": { + "name": "commentDate", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "commentKey": { + "name": "commentKey", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "add_user": { + "name": "add_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'LST_Serivce'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.subModules": { + "name": "subModules", + "schema": "", + "columns": { + "submodule_id": { + "name": "submodule_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "moduleName": { + "name": "moduleName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "link": { + "name": "link", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "roles": { + "name": "roles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[\"systemAdmin\"]'::jsonb" + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "subSubModule": { + "name": "subSubModule", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "subModule_name": { + "name": "subModule_name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.userRoles": { + "name": "userRoles", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role_id": { + "name": "role_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "module_id": { + "name": "module_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "user_module_unique": { + "name": "user_module_unique", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "module_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "userRoles_user_id_users_user_id_fk": { + "name": "userRoles_user_id_users_user_id_fk", + "tableFrom": "userRoles", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "user_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "userRoles_role_id_roles_role_id_fk": { + "name": "userRoles_role_id_roles_role_id_fk", + "tableFrom": "userRoles", + "tableTo": "roles", + "columnsFrom": [ + "role_id" + ], + "columnsTo": [ + "role_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "userRoles_module_id_modules_module_id_fk": { + "name": "userRoles_module_id_modules_module_id_fk", + "tableFrom": "userRoles", + "tableTo": "modules", + "columnsFrom": [ + "module_id" + ], + "columnsTo": [ + "module_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "passwordToken": { + "name": "passwordToken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "passwordTokenExpires": { + "name": "passwordTokenExpires", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "pingcode": { + "name": "pingcode", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'user'" + }, + "lastLogin": { + "name": "lastLogin", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "username": { + "name": "username", + "columns": [ + { + "expression": "username", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/lstV2/database/migrations/meta/_journal.json b/lstV2/database/migrations/meta/_journal.json index a1bc08c..9ebeb7f 100644 --- a/lstV2/database/migrations/meta/_journal.json +++ b/lstV2/database/migrations/meta/_journal.json @@ -533,6 +533,13 @@ "when": 1762983466464, "tag": "0075_tan_unicorn", "breakpoints": true + }, + { + "idx": 76, + "version": "7", + "when": 1763134709763, + "tag": "0076_stiff_champions", + "breakpoints": true } ] } \ No newline at end of file diff --git a/lstV2/database/schema/qualityRequest.ts b/lstV2/database/schema/qualityRequest.ts index 8554a88..edb391c 100644 --- a/lstV2/database/schema/qualityRequest.ts +++ b/lstV2/database/schema/qualityRequest.ts @@ -1,45 +1,46 @@ import { - text, - pgTable, - numeric, - index, - timestamp, - boolean, - uuid, - uniqueIndex, - integer, + boolean, + index, + integer, + numeric, + pgTable, + text, + timestamp, + uniqueIndex, + uuid, } from "drizzle-orm/pg-core"; import { createInsertSchema, createSelectSchema } from "drizzle-zod"; import { z } from "zod"; export const qualityRequest = pgTable( - "qualityRequest", - { - request_id: uuid("request_id").defaultRandom().primaryKey(), - article: numeric("article"), - description: text("description"), - runningNr: text("runningNr"), - lotNr: numeric("lotNr"), - warehouseAtRequest: text("warehouseAtRequest"), - locationAtRequest: text("locationAtRequest"), - warehouseMovedTo: text("warehouseMovedTo"), - locationMovedTo: text("locationMovedTo"), - durationToMove: integer("durationToMove"), - qualityDurationToInspect: integer("qualityDurationToInspect"), - returnDurationToInspect: integer("returnDurationToInspect"), - locationDropOff: text("locationDropOff"), - palletStatus: integer("palletStatus"), - palletStatusText: text("palletStatusText"), - palletRequest: integer("palletRequest"), - add_date: timestamp("add_date").defaultNow(), - add_user: text("add_user").default("LST"), - upd_date: timestamp("upd_date").defaultNow(), - upd_user: text("upd_user").default("LST"), - }, - (table) => [ - // uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`), - // uniqueIndex("role_name").on(table.name), - ] + "qualityRequest", + { + request_id: uuid("request_id").defaultRandom().primaryKey(), + article: numeric("article"), + description: text("description"), + runningNr: text("runningNr"), + lotNr: numeric("lotNr"), + warehouseAtRequest: text("warehouseAtRequest"), + locationAtRequest: text("locationAtRequest"), + warehouseMovedTo: text("warehouseMovedTo"), + locationMovedTo: text("locationMovedTo"), + durationToMove: integer("durationToMove"), + qualityDurationToInspect: integer("qualityDurationToInspect"), + returnDurationToInspect: integer("returnDurationToInspect"), + locationDropOff: text("locationDropOff"), + palletStatus: integer("palletStatus"), + palletStatusText: text("palletStatusText"), + palletRequest: integer("palletRequest"), + priority: integer("priority").default(4), // 1,2,3,4 + add_date: timestamp("add_date").defaultNow(), + add_user: text("add_user").default("LST"), + upd_date: timestamp("upd_date").defaultNow(), + upd_user: text("upd_user").default("LST"), + }, + (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 diff --git a/lstV2/server/services/quality/controller/addNewPallet.ts b/lstV2/server/services/quality/controller/addNewPallet.ts index 3f4b3e9..25cd38d 100644 --- a/lstV2/server/services/quality/controller/addNewPallet.ts +++ b/lstV2/server/services/quality/controller/addNewPallet.ts @@ -1,5 +1,6 @@ import { differenceInMinutes } from "date-fns"; import { eq, sql } from "drizzle-orm"; +import { priority } from "st-ethernet-ip/dist/enip/cip/connection-manager/index.js"; import { db } from "../../../../database/dbclient.js"; import { qualityRequest } from "../../../../database/schema/qualityRequest.js"; import { timeZoneFix } from "../../../globalUtils/timeZoneFix.js"; @@ -39,11 +40,13 @@ export const addNewPallet = async (data: any) => { const palletData: any = c; // if the pallet exist then tell the user to check on it const pStatus = [1, 4, 6]; - if (palletData && pStatus.includes(palletData[0]?.palletStatus)) { - return { - success: false, - message: `Running number ${data.runningNr} is already pending or reactivated please follow up with the warehouse team on status to be moved.`, - }; + if (!data.priority) { + if (palletData && pStatus.includes(palletData[0]?.palletStatus)) { + return { + success: false, + message: `Running number ${data.runningNr} is already pending or reactivated please follow up with the warehouse team on status to be moved.`, + }; + } } // update the existing pallet if already in the system @@ -61,25 +64,36 @@ export const addNewPallet = async (data: any) => { data: pe, }; } - const pData = { - warehouseAtRequest: p[0].warehouseAtRequest, - locationAtRequest: p[0].locationAtRequest, - warehouseMovedTo: null, - locationMovedTo: null, - palletStatus: data.palletStatusText === "return" ? 6 : 4, - //durationToMove: 0, - palletStatusText: - data.palletStatusText === "return" ? "return" : "reactivated", - qualityDurationToInspect: - data.palletStatusText === "return" - ? differenceInMinutes(new Date(Date.now()), p[0].lastMove) - : 0, - locationDropOff: - data.palletStatusText === "return" ? "Return to warhouse" : "", - palletRequest: palletData[0].palletStatus + 1, - upd_user: data.user, - upd_date: sql`NOW()`, - }; + + let pData = {}; + + if (data.priority) { + pData = { + priority: data.priority, + upd_user: data.user, + upd_date: sql`NOW()`, + }; + } else { + pData = { + warehouseAtRequest: p[0].warehouseAtRequest, + locationAtRequest: p[0].locationAtRequest, + warehouseMovedTo: null, + locationMovedTo: null, + palletStatus: data.palletStatusText === "return" ? 6 : 4, + //durationToMove: 0, + palletStatusText: + data.palletStatusText === "return" ? "return" : "reactivated", + qualityDurationToInspect: + data.palletStatusText === "return" + ? differenceInMinutes(new Date(Date.now()), p[0].lastMove) + : 0, + locationDropOff: + data.palletStatusText === "return" ? "Return to warhouse" : "", + palletRequest: palletData[0].palletStatus + 1, + upd_user: data.user, + upd_date: sql`NOW()`, + }; + } const { data: u, error } = await tryCatch( db diff --git a/lstV2/server/services/quality/controller/getRequests.ts b/lstV2/server/services/quality/controller/getRequests.ts index fc98af1..4023731 100644 --- a/lstV2/server/services/quality/controller/getRequests.ts +++ b/lstV2/server/services/quality/controller/getRequests.ts @@ -1,25 +1,28 @@ -import { desc } from "drizzle-orm"; +import { asc, desc } from "drizzle-orm"; import { db } from "../../../../database/dbclient.js"; import { qualityRequest } from "../../../../database/schema/qualityRequest.js"; import { tryCatch } from "../../../globalUtils/tryCatch.js"; import qualityBlockingMonitor from "../../notifications/controller/notifications/qualityBlocking.js"; export const getRequest = async () => { - const { data, error } = await tryCatch( - db.select().from(qualityRequest).orderBy(desc(qualityRequest.add_date)) - ); + const { data, error } = await tryCatch( + db + .select() + .from(qualityRequest) + .orderBy(asc(qualityRequest.priority), asc(qualityRequest.add_date)), + ); - if (error) { - return { - success: false, - message: "There was an error getting the quality request", - data: error, - }; - } + if (error) { + return { + success: false, + message: "There was an error getting the quality request", + data: error, + }; + } - return { - success: true, - message: "Quality request pallets.", - data, - }; + return { + success: true, + message: "Quality request pallets.", + data, + }; }; diff --git a/lstV2/server/services/quality/controller/qualityCycle.ts b/lstV2/server/services/quality/controller/qualityCycle.ts index bf3e319..071d9fd 100644 --- a/lstV2/server/services/quality/controller/qualityCycle.ts +++ b/lstV2/server/services/quality/controller/qualityCycle.ts @@ -105,7 +105,7 @@ export const qualityCycle = async () => { ); } else { createLog( - "info", + "debug", "lst", "quality", `Pallet ${ @@ -119,7 +119,7 @@ export const qualityCycle = async () => { } await delay(150); } else { - createLog("info", "lst", "quality", "nothing to update"); + //createLog("info", "lst", "quality", "nothing to update"); } }, 5 * 60 * 1000,