diff --git a/README.md b/README.md
index c281894..a902c34 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,7 @@
+# THIS VERSION IS NO LONGER BEING UPDATED PLEASE GO TO THE NEW REPO LINK BELOW
+
+[NEW LST REPO](https://git.tuffraid.net/cowch/lst)
+
# lstV2
Logistics Support Tool V2
diff --git a/frontend/src/routes/__root.tsx b/frontend/src/routes/__root.tsx
index 4005699..40385cf 100644
--- a/frontend/src/routes/__root.tsx
+++ b/frontend/src/routes/__root.tsx
@@ -68,7 +68,7 @@ export const Route = createRootRoute({
{settings.length > 0 && (
LST - Docs
diff --git a/package.json b/package.json
index 3b83deb..9314cca 100644
--- a/package.json
+++ b/package.json
@@ -36,7 +36,7 @@
}
},
"admConfig": {
- "build": 652,
+ "build": 661,
"oldBuild": "backend-0.1.3.zip"
},
"devDependencies": {
diff --git a/server/services/dataMart/controller/psiGetInventory.ts b/server/services/dataMart/controller/psiGetInventory.ts
new file mode 100644
index 0000000..e4a5933
--- /dev/null
+++ b/server/services/dataMart/controller/psiGetInventory.ts
@@ -0,0 +1,63 @@
+import { and, between, inArray, sql } from "drizzle-orm";
+import { db } from "../../../../database/dbclient.js";
+import { invHistoricalData } from "../../../../database/schema/historicalINV.js";
+import { tryCatch } from "../../../globalUtils/tryCatch.js";
+import { createLog } from "../../logger/logger.js";
+
+// type ArticleData = {
+// id: string
+// }
+export const psiGetInventory = async (
+ avs: string,
+ startDate: string,
+ endDate: string
+) => {
+ let articles: any = [];
+
+ if (!avs) {
+ return {
+ success: false,
+ message: `Missing av's please send at least one over`,
+ data: [],
+ };
+ }
+
+ const ids = avs.split(",").map((id) => id.trim());
+
+ const { data, error } = (await tryCatch(
+ db
+ .select()
+ .from(invHistoricalData)
+ .where(
+ and(
+ inArray(invHistoricalData.article, ids),
+ between(invHistoricalData.histDate, startDate, endDate)
+ )
+ )
+ //.limit(100)
+ )) as any;
+
+ if (error) {
+ createLog(
+ "error",
+ "datamart",
+ "datamart",
+ `There was an error getting the planning info: ${JSON.stringify(
+ error
+ )}`
+ );
+ return {
+ success: false,
+ messsage: `There was an error getting the planning info`,
+ data: error,
+ };
+ }
+
+ articles = data;
+ console.log(articles.length);
+ return {
+ success: true,
+ message: "PSI planning Data",
+ data: articles,
+ };
+};
diff --git a/server/services/dataMart/controller/psiGetPlanningData.ts b/server/services/dataMart/controller/psiGetPlanningData.ts
new file mode 100644
index 0000000..dbe8303
--- /dev/null
+++ b/server/services/dataMart/controller/psiGetPlanningData.ts
@@ -0,0 +1,63 @@
+import { tryCatch } from "../../../globalUtils/tryCatch.js";
+import { createLog } from "../../logger/logger.js";
+import { query } from "../../sqlServer/prodSqlServer.js";
+import { planningNumbersByAVDate } from "../../sqlServer/querys/psiReport/planningNumbersByAv.js";
+
+// type ArticleData = {
+// id: string
+// }
+export const psiGetPlanningData = async (
+ avs: string,
+ startDate: string,
+ endDate: string
+) => {
+ let articles: any = [];
+
+ if (!avs) {
+ return {
+ success: false,
+ message: `Missing av's please send at least one over`,
+ data: [],
+ };
+ }
+
+ const { data, error } = (await tryCatch(
+ query(
+ planningNumbersByAVDate
+ .replace("[articles]", avs)
+ .replace("[startDate]", startDate)
+ .replace("[endDate]", endDate),
+ "PSI planning info"
+ )
+ )) as any;
+
+ if (error) {
+ createLog(
+ "error",
+ "datamart",
+ "datamart",
+ `There was an error getting the planning info: ${JSON.stringify(
+ error
+ )}`
+ );
+ return {
+ success: false,
+ messsage: `There was an error getting the planning info`,
+ data: error,
+ };
+ }
+
+ articles = data.data;
+
+ return {
+ success: true,
+ message: "PSI planning Data",
+ data: articles.map((n: any) => {
+ if (n.PalDay) {
+ return { ...n, PalDay: n.PalDay.toFixed(2) };
+ }
+
+ return n;
+ }),
+ };
+};
diff --git a/server/services/dataMart/controller/psiGetProductionData.ts b/server/services/dataMart/controller/psiGetProductionData.ts
new file mode 100644
index 0000000..46f6e9c
--- /dev/null
+++ b/server/services/dataMart/controller/psiGetProductionData.ts
@@ -0,0 +1,63 @@
+import { tryCatch } from "../../../globalUtils/tryCatch.js";
+import { createLog } from "../../logger/logger.js";
+import { query } from "../../sqlServer/prodSqlServer.js";
+import { productionNumbers } from "../../sqlServer/querys/psiReport/prodcuctionNumbers.js";
+
+// type ArticleData = {
+// id: string
+// }
+export const psiGetProductionData = async (
+ avs: string,
+ startDate: string,
+ endDate: string
+) => {
+ let articles: any = [];
+
+ if (!avs) {
+ return {
+ success: false,
+ message: `Missing av's please send at least one over`,
+ data: [],
+ };
+ }
+
+ const { data, error } = (await tryCatch(
+ query(
+ productionNumbers
+ .replace("[articles]", avs)
+ .replace("[startDate]", startDate)
+ .replace("[endDate]", endDate),
+ "PSI production info"
+ )
+ )) as any;
+
+ if (error) {
+ createLog(
+ "error",
+ "datamart",
+ "datamart",
+ `There was an error getting the planning info: ${JSON.stringify(
+ error
+ )}`
+ );
+ return {
+ success: false,
+ messsage: `There was an error getting the planning info`,
+ data: error,
+ };
+ }
+
+ articles = data.data;
+
+ return {
+ success: true,
+ message: "PSI planning Data",
+ data: articles.map((n: any) => {
+ if (n.PalDay) {
+ return { ...n, PalDay: n.PalDay.toFixed(2) };
+ }
+
+ return n;
+ }),
+ };
+};
diff --git a/server/services/dataMart/dataMartService.ts b/server/services/dataMart/dataMartService.ts
index 51ab8c6..ae6d01d 100644
--- a/server/services/dataMart/dataMartService.ts
+++ b/server/services/dataMart/dataMartService.ts
@@ -10,6 +10,9 @@ import addressCorrections from "./route/getCityStateData.js";
import fifoIndex from "./route/getFifoIndex.js";
import financeAudit from "./route/getFinanceAudit.js";
import psiArticleData from "./route/getPsiArticleData.js";
+import psiPlanningData from "./route/getPsiPlanningData.js";
+import psiProductionData from "./route/getPsiProductionData.js";
+import psiInventory from "./route/getPsiinventory.js";
const app = new OpenAPIHono();
@@ -25,6 +28,9 @@ const routes = [
fifoIndex,
financeAudit,
psiArticleData,
+ psiPlanningData,
+ psiProductionData,
+ psiInventory,
] as const;
const appRoutes = routes.forEach((route) => {
diff --git a/server/services/dataMart/route/getPsiPlanningData.ts b/server/services/dataMart/route/getPsiPlanningData.ts
new file mode 100644
index 0000000..d870a59
--- /dev/null
+++ b/server/services/dataMart/route/getPsiPlanningData.ts
@@ -0,0 +1,64 @@
+import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
+import { responses } from "../../../globalUtils/routeDefs/responses.js";
+import { tryCatch } from "../../../globalUtils/tryCatch.js";
+import { apiHit } from "../../../globalUtils/apiHits.js";
+import { psiGetPlanningData } from "../controller/psiGetPlanningData.js";
+
+const app = new OpenAPIHono({ strict: false });
+const Body = z.object({
+ includeRunnningNumbers: z.string().openapi({ example: "x" }),
+});
+app.openapi(
+ createRoute({
+ tags: ["dataMart"],
+ summary: "Returns the psiarticleData.",
+ method: "get",
+ path: "/psiplanningdata",
+ request: {
+ body: {
+ content: {
+ "application/json": { schema: Body },
+ },
+ },
+ },
+ responses: responses(),
+ }),
+ async (c) => {
+ const q: any = c.req.queries();
+
+ // make sure we have a vaid user being accessed thats really logged in
+ apiHit(c, { endpoint: "/psiplanningdata" });
+ //console.log(articles["avs"][0]);
+ const { data, error } = await tryCatch(
+ psiGetPlanningData(
+ q["avs"] ? q["avs"][0] : null,
+ q["startDate"] ? q["startDate"][0] : null,
+ q["endDate"] ? q["endDate"][0] : null
+ )
+ );
+
+ if (error) {
+ console.log(error);
+ return c.json(
+ {
+ success: false,
+ message: "There was an error getting the planning.",
+ data: error,
+ },
+ 400
+ );
+ }
+
+ //console.log(data);
+
+ return c.json(
+ {
+ success: data.success,
+ message: data.message,
+ data: data.data,
+ },
+ data.success ? 200 : 400
+ );
+ }
+);
+export default app;
diff --git a/server/services/dataMart/route/getPsiProductionData.ts b/server/services/dataMart/route/getPsiProductionData.ts
new file mode 100644
index 0000000..a0cf73b
--- /dev/null
+++ b/server/services/dataMart/route/getPsiProductionData.ts
@@ -0,0 +1,64 @@
+import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
+import { responses } from "../../../globalUtils/routeDefs/responses.js";
+import { tryCatch } from "../../../globalUtils/tryCatch.js";
+import { apiHit } from "../../../globalUtils/apiHits.js";
+import { psiGetProductionData } from "../controller/psiGetProductionData.js";
+
+const app = new OpenAPIHono({ strict: false });
+const Body = z.object({
+ includeRunnningNumbers: z.string().openapi({ example: "x" }),
+});
+app.openapi(
+ createRoute({
+ tags: ["dataMart"],
+ summary: "Returns the psiproductiondata.",
+ method: "get",
+ path: "/psiproductiondata",
+ request: {
+ body: {
+ content: {
+ "application/json": { schema: Body },
+ },
+ },
+ },
+ responses: responses(),
+ }),
+ async (c) => {
+ const q: any = c.req.queries();
+
+ // make sure we have a vaid user being accessed thats really logged in
+ apiHit(c, { endpoint: "/psiproductiondata" });
+ //console.log(articles["avs"][0]);
+ const { data, error } = await tryCatch(
+ psiGetProductionData(
+ q["avs"] ? q["avs"][0] : null,
+ q["startDate"] ? q["startDate"][0] : null,
+ q["endDate"] ? q["endDate"][0] : null
+ )
+ );
+
+ if (error) {
+ console.log(error);
+ return c.json(
+ {
+ success: false,
+ message: "There was an error getting the production.",
+ data: error,
+ },
+ 400
+ );
+ }
+
+ //console.log(data);
+
+ return c.json(
+ {
+ success: data.success,
+ message: data.message,
+ data: data.data,
+ },
+ data.success ? 200 : 400
+ );
+ }
+);
+export default app;
diff --git a/server/services/dataMart/route/getPsiinventory.ts b/server/services/dataMart/route/getPsiinventory.ts
new file mode 100644
index 0000000..3b77951
--- /dev/null
+++ b/server/services/dataMart/route/getPsiinventory.ts
@@ -0,0 +1,64 @@
+import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
+import { responses } from "../../../globalUtils/routeDefs/responses.js";
+import { tryCatch } from "../../../globalUtils/tryCatch.js";
+import { apiHit } from "../../../globalUtils/apiHits.js";
+import { psiGetInventory } from "../controller/psiGetInventory.js";
+
+const app = new OpenAPIHono({ strict: false });
+const Body = z.object({
+ includeRunnningNumbers: z.string().openapi({ example: "x" }),
+});
+app.openapi(
+ createRoute({
+ tags: ["dataMart"],
+ summary: "Returns the getPsiinventory.",
+ method: "get",
+ path: "/getpsiinventory",
+ request: {
+ body: {
+ content: {
+ "application/json": { schema: Body },
+ },
+ },
+ },
+ responses: responses(),
+ }),
+ async (c) => {
+ const q: any = c.req.queries();
+
+ // make sure we have a vaid user being accessed thats really logged in
+ apiHit(c, { endpoint: "/getpsiinventory" });
+ //console.log(articles["avs"][0]);
+ const { data, error } = await tryCatch(
+ psiGetInventory(
+ q["avs"] ? q["avs"][0] : null,
+ q["startDate"] ? q["startDate"][0] : null,
+ q["endDate"] ? q["endDate"][0] : null
+ )
+ );
+
+ if (error) {
+ console.log(error);
+ return c.json(
+ {
+ success: false,
+ message: "There was an error getting the production.",
+ data: error,
+ },
+ 400
+ );
+ }
+
+ //console.log(data);
+
+ return c.json(
+ {
+ success: data.success,
+ message: data.message,
+ data: data.data,
+ },
+ data.success ? 200 : 400
+ );
+ }
+);
+export default app;
diff --git a/server/services/eom/utils/removeHistorical.ts b/server/services/eom/utils/removeHistorical.ts
index b7354d9..97d28da 100644
--- a/server/services/eom/utils/removeHistorical.ts
+++ b/server/services/eom/utils/removeHistorical.ts
@@ -27,7 +27,7 @@ export const deleteHistory = async () => {
.where(
lte(
invHistoricalData.histDate,
- sql`(NOW() - INTERVAL '45 day')::date`
+ sql`(NOW() - INTERVAL '365 day')::date`
)
)
);
diff --git a/server/services/ocp/controller/labeling/labelProcess.ts b/server/services/ocp/controller/labeling/labelProcess.ts
index 0b95bc2..427ea03 100644
--- a/server/services/ocp/controller/labeling/labelProcess.ts
+++ b/server/services/ocp/controller/labeling/labelProcess.ts
@@ -289,11 +289,13 @@ export const labelingProcess = async ({
"error",
"labeling",
"ocp",
- `There was an error booking in the label: ${book.data?.errors[0]?.message}`
+ `There was an error booking in the label: ${JSON.stringify(
+ book.data
+ )}`
);
return {
success: false,
- message: `Error Booking in label: ${book.data?.errors[0]?.message}`,
+ message: `Error Booking in label`,
data: book,
};
}
diff --git a/server/services/sqlServer/querys/psiReport/planningNumbersByAv.ts b/server/services/sqlServer/querys/psiReport/planningNumbersByAv.ts
index e3d1570..9a773e9 100644
--- a/server/services/sqlServer/querys/psiReport/planningNumbersByAv.ts
+++ b/server/services/sqlServer/querys/psiReport/planningNumbersByAv.ts
@@ -1,33 +1,34 @@
export const planningNumbersByAVDate = `
use AlplaPROD_test1
-declare @start_date nvarchar(30) = [startDate] --'2025-01-01'
-declare @end_date nvarchar(30) = [endDate] --'2025-08-09'
+declare @start_date nvarchar(30) = '[startDate]' --'2025-01-01'
+declare @end_date nvarchar(30) = '[endDate]' --'2025-08-09'
/*
articles will need to be passed over as well as the date structure we want to see
*/
--- planned lots in planning
-
-select V_ProdLosProduktionJeProdTag_PLANNING.IdArtikelvarianten As Article,
+select x.IdArtikelvarianten As Article,
ProduktionAlias as Description,
standort as MachineId,
MaschinenBezeichnung as MachineName,
--MaschZyklus as PlanningCycleTime,
-V_ProdLosProduktionJeProdTag_PLANNING.IdProdPlanung as LotNumber,
+x.IdProdPlanung as LotNumber,
FORMAT(ProdTag, 'MM/dd/yyyy') as ProductionDay,
-V_ProdLosProduktionJeProdTag_PLANNING.planMenge as TotalPlanned,
+x.planMenge as TotalPlanned,
ProduktionMenge as QTYPerDay,
round(ProduktionMengeVPK, 2) PalDay,
Status as finished
--MaschStdAuslastung as nee
-from dbo.V_ProdLosProduktionJeProdTag_PLANNING (nolock)
+from dbo.V_ProdLosProduktionJeProdTag_PLANNING (nolock) as x
left join
-dbo.V_ProdPlanung (nolock) on
-V_ProdLosProduktionJeProdTag_PLANNING .IdProdPlanung = V_ProdPlanung.IdProdPlanung
+dbo.V_ProdPlanung (nolock) as p on
+x.IdProdPlanung = p.IdProdPlanung
-where V_ProdLosProduktionJeProdTag_PLANNING.IdArtikelvarianten in ([articles]) and ProdTag between @start_date and @end_date --and IdProdPlanung = 18442
+where ProdTag between @start_date and @end_date
+and p.IdArtikelvarianten in ([articles])
+--and V_ProdLosProduktionJeProdTag_PLANNING.IdKunde = 10
+--and IdProdPlanung = 18442
-order by ProdTag
+order by ProdTag desc
`;
diff --git a/server/services/sqlServer/querys/psiReport/prodcuctionNumbers.ts b/server/services/sqlServer/querys/psiReport/prodcuctionNumbers.ts
index be13677..0cebcfa 100644
--- a/server/services/sqlServer/querys/psiReport/prodcuctionNumbers.ts
+++ b/server/services/sqlServer/querys/psiReport/prodcuctionNumbers.ts
@@ -1,8 +1,8 @@
export const productionNumbers = `
use [test1_AlplaPROD2.0_Reporting]
-declare @startDate nvarchar(30) = [startDate] --'2024-12-30'
-declare @endDate nvarchar(30) = [endDate] --'2025-08-09'
+declare @startDate nvarchar(30) = '[startDate]' --'2024-12-30'
+declare @endDate nvarchar(30) = '[endDate]' --'2025-08-09'
select MachineLocation,
ArticleHumanReadableId as article,
diff --git a/server/services/sqlServer/querys/psiReport/psiinventory.ts b/server/services/sqlServer/querys/psiReport/psiinventory.ts
new file mode 100644
index 0000000..9a773e9
--- /dev/null
+++ b/server/services/sqlServer/querys/psiReport/psiinventory.ts
@@ -0,0 +1,34 @@
+export const planningNumbersByAVDate = `
+use AlplaPROD_test1
+declare @start_date nvarchar(30) = '[startDate]' --'2025-01-01'
+declare @end_date nvarchar(30) = '[endDate]' --'2025-08-09'
+/*
+articles will need to be passed over as well as the date structure we want to see
+*/
+
+select x.IdArtikelvarianten As Article,
+ProduktionAlias as Description,
+standort as MachineId,
+MaschinenBezeichnung as MachineName,
+--MaschZyklus as PlanningCycleTime,
+x.IdProdPlanung as LotNumber,
+FORMAT(ProdTag, 'MM/dd/yyyy') as ProductionDay,
+x.planMenge as TotalPlanned,
+ProduktionMenge as QTYPerDay,
+round(ProduktionMengeVPK, 2) PalDay,
+Status as finished
+--MaschStdAuslastung as nee
+
+from dbo.V_ProdLosProduktionJeProdTag_PLANNING (nolock) as x
+
+left join
+dbo.V_ProdPlanung (nolock) as p on
+x.IdProdPlanung = p.IdProdPlanung
+
+where ProdTag between @start_date and @end_date
+and p.IdArtikelvarianten in ([articles])
+--and V_ProdLosProduktionJeProdTag_PLANNING.IdKunde = 10
+--and IdProdPlanung = 18442
+
+order by ProdTag desc
+`;