diff --git a/frontend/src/components/eom/EomPage.tsx b/frontend/src/components/eom/EomPage.tsx index 144ccb1..8acb92d 100644 --- a/frontend/src/components/eom/EomPage.tsx +++ b/frontend/src/components/eom/EomPage.tsx @@ -1,131 +1,9 @@ -import {useSessionStore} from "@/lib/store/sessionStore"; -import {LstCard} from "../extendedUI/LstCard"; -import {Tabs, TabsContent, TabsList, TabsTrigger} from "../ui/tabs"; -import {useModuleStore} from "@/lib/store/useModuleStore"; -import {Table, TableBody, TableCell, TableHead, TableHeader, TableRow} from "../ui/table"; -import {Skeleton} from "../ui/skeleton"; - -import {Link, useRouter} from "@tanstack/react-router"; -import {Popover, PopoverContent, PopoverTrigger} from "../ui/popover"; -import {Button} from "../ui/button"; -import {cn} from "@/lib/utils"; -import {CalendarIcon} from "lucide-react"; -import {format, startOfMonth} from "date-fns"; -import {Calendar} from "../ui/calendar"; -import {useState} from "react"; -import {toast} from "sonner"; -import KFP from "./KFP"; +import MaterialCheck from "./materialCheck/MaterialCheck"; export default function EomPage() { - const {modules} = useModuleStore(); - const {user} = useSessionStore(); - const router = useRouter(); - const [date, setDate] = useState(); - - if (!user) { - router.navigate({to: "/"}); - } - const eomMod = modules.filter((m) => m.name === "eom"); - // the users current role for eom is? - const role: any = user?.roles.filter((r) => r.module_id === eomMod[0].module_id) || ""; - - const tabs = [ - {key: "kfp", label: "Key Figures", roles: ["admin", "systemAdmin"], content: }, - {key: "fg", label: "Finished Goods", roles: ["admin", "systemAdmin"], content: }, - {key: "mm", label: "Main Material", roles: ["admin", "systemAdmin"], content: }, - {key: "mb", label: "Master Batch", roles: ["admin", "systemAdmin"], content: }, - {key: "ab", label: "Additive", roles: ["admin", "systemAdmin"], content: }, - {key: "pp", label: "Purchased Preforms", roles: ["admin", "systemAdmin"], content: }, - {key: "pre", label: "Preforms", roles: ["admin", "systemAdmin"], content: }, - {key: "pkg", label: "Packaging", roles: ["admin", "systemAdmin"], content: }, - {key: "ui", label: "Undefined Items", roles: ["admin"], content: }, - ]; return (
-
- - - - - - - - -
- -
-
- - - - {tabs.map((tab) => { - if (tab.roles.includes(role[0].role)) - return {tab.label}; - })} - - {tabs.map((tab) => { - if (tab.roles.includes(role[0].role)) - return {tab.content}; - })} - +
); } - -function DummyContent() { - return ( - - - - - Av - Description - Material Type - Waste - Loss / Gain $$ - - - - - {Array(10) - .fill(0) - .map((_, i) => ( - - - - {i} - - - - - - - - - - - - - - - {/* - - */} - - ))} - -
-
- ); -} diff --git a/server/services/eom/eomService.ts b/server/services/eom/eomService.ts index 159f291..2821216 100644 --- a/server/services/eom/eomService.ts +++ b/server/services/eom/eomService.ts @@ -6,17 +6,43 @@ import stats from "./route/stats.js"; import history from "./route/invHistory.js"; import { createJob } from "../notifications/utils/processNotifications.js"; import { historicalInvIMmport } from "./utils/historicalInv.js"; +import { tryCatch } from "../../globalUtils/tryCatch.js"; +import { query } from "../sqlServer/prodSqlServer.js"; +import { shiftChange } from "../sqlServer/querys/misc/shiftChange.js"; +import { createLog } from "../logger/logger.js"; const routes = [stats, history] as const; const appRoutes = routes.forEach((route) => { app.route("/eom", route); }); -// setTimeout(() => { -// historicalInvIMmport(); -// }, 5 * 1000); +setTimeout(async () => { + const { data: shift, error: shiftError } = (await tryCatch( + query(shiftChange, "shift change from material.") + )) as any; + + if (shiftError) { + createLog( + "error", + "eom", + "eom", + "There was an error getting the shift times will use fallback times" + ); + } + + // shift split + const shiftTimeSplit = shift?.data[0]?.shiftChange.split(":"); + + const cronSetup = `${ + shiftTimeSplit.length > 0 ? `${parseInt(shiftTimeSplit[1])}` : "0" + } ${ + shiftTimeSplit.length > 0 ? `${parseInt(shiftTimeSplit[0])}` : "7" + } * * *`; + + //console.log(cronSetup); + createJob("eom_historical_inv", cronSetup, historicalInvIMmport); +}, 5 * 1000); // the time we want to run the hostircal data should be the same time the historical data run on the server // getting this from the shift time -createJob("eom_historical_inv", "0 7 * * *", historicalInvIMmport); export default app;