Compare commits

..

6 Commits

21 changed files with 565 additions and 80 deletions

View File

@@ -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 # lstV2
Logistics Support Tool V2 Logistics Support Tool V2

View File

@@ -1,26 +1,30 @@
import {LstCard} from "@/components/extendedUI/LstCard"; import { LstCard } from "@/components/extendedUI/LstCard";
import {Button} from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import {CardHeader} from "@/components/ui/card"; import { CardHeader } from "@/components/ui/card";
import {Input} from "@/components/ui/input"; import { Input } from "@/components/ui/input";
import {Label} from "@/components/ui/label"; import { Label } from "@/components/ui/label";
import {useSessionStore} from "@/lib/store/sessionStore";
import axios from "axios";
import {useState} from "react";
import {useForm} from "react-hook-form"; import axios from "axios";
import {toast} from "sonner"; import { useState } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
export default function ConsumeMaterial() { export default function ConsumeMaterial() {
const {register: register1, handleSubmit: handleSubmit1, reset} = useForm(); const {
register: register1,
handleSubmit: handleSubmit1,
reset,
} = useForm();
const [submitting, setSubmitting] = useState(false); const [submitting, setSubmitting] = useState(false);
const {token} = useSessionStore();
const handleConsume = async (data: any) => { const handleConsume = async (data: any) => {
setSubmitting(true); setSubmitting(true);
try { try {
const result = await axios.post(`/api/logistics/consume`, data, { // const result = await axios.post(`/api/logistics/consume`, data, {
headers: {Authorization: `Bearer ${token}`}, // headers: {Authorization: `Bearer ${token}`},
}); // });
const result = await axios.post(`/api/logistics/consume`, data);
if (result.data.success) { if (result.data.success) {
toast.success(result.data.message); toast.success(result.data.message);
setSubmitting(false); setSubmitting(false);
@@ -33,12 +37,14 @@ export default function ConsumeMaterial() {
toast.error(result.data.message); toast.error(result.data.message);
} }
} catch (error: any) { } catch (error: any) {
//console.log(error); console.log(error);
setSubmitting(false); setSubmitting(false);
if (error.status === 401) { if (error.status === 401) {
toast.error("Unauthorized to do this task."); toast.error("Unauthorized to do this task.");
} else { } else {
toast.error("Unexpected error if this continues please constact an admin."); toast.error(
"Unexpected error if this continues please constact an admin."
);
} }
} }
}; };
@@ -53,7 +59,9 @@ export default function ConsumeMaterial() {
<LstCard> <LstCard>
<form onSubmit={handleSubmit1(handleConsume)}> <form onSubmit={handleSubmit1(handleConsume)}>
<div className="m-2"> <div className="m-2">
<Label htmlFor="runningNr">Enter unit running number</Label> <Label htmlFor="runningNr">
Enter unit running number
</Label>
<Input <Input
className="mt-2" className="mt-2"
//defaultValue="634" //defaultValue="634"
@@ -62,7 +70,9 @@ export default function ConsumeMaterial() {
/> />
</div> </div>
<div className="m-2"> <div className="m-2">
<Label htmlFor="lotNum">Enter lot number</Label> <Label htmlFor="lotNum">
Enter lot number
</Label>
<Input <Input
className="mt-2" className="mt-2"
//defaultValue="634" //defaultValue="634"
@@ -71,7 +81,12 @@ export default function ConsumeMaterial() {
/> />
</div> </div>
<Button className="m-2" color="primary" type="submit" disabled={submitting}> <Button
className="m-2"
color="primary"
type="submit"
disabled={submitting}
>
Consume materal Consume materal
</Button> </Button>
</form> </form>
@@ -81,12 +96,19 @@ export default function ConsumeMaterial() {
<LstCard> <LstCard>
<div className="w-96 p-1"> <div className="w-96 p-1">
<ol> <ol>
<li>1. Enter the running number of the material you would like to consume</li> <li>
<li>2. Enter the lot number you will be consuming to</li> 1. Enter the running number of the
material you would like to consume
</li>
<li>
2. Enter the lot number you will be
consuming to
</li>
<li>3. Press consume material</li> <li>3. Press consume material</li>
</ol> </ol>
<p className="text-pretty w-96"> <p className="text-pretty w-96">
*This process is only for barcoded material, if it is set to auto consume you will *This process is only for barcoded material,
if it is set to auto consume you will
encounter and error. encounter and error.
</p> </p>
</div> </div>

View File

@@ -14,13 +14,16 @@ import {
TooltipContent, TooltipContent,
TooltipTrigger, TooltipTrigger,
} from "@/components/ui/tooltip"; } from "@/components/ui/tooltip";
import { useSettingStore } from "@/lib/store/useSettings";
export default function TransferToNextLot() { export default function TransferToNextLot() {
const [gaylordFilled, setGaylordFilled] = useState([0]); const [gaylordFilled, setGaylordFilled] = useState([0]);
const [actualAmount, setActualAmount] = useState(0); const [actualAmount, setActualAmount] = useState(0);
const [tab, setTab] = useState("esitmate"); const [tab, setTab] = useState("esitmate");
const [typeSwitch, setTypeSwitch] = useState(false); const [typeSwitch, setTypeSwitch] = useState(false);
const { settings } = useSettingStore();
const server = settings.filter((n: any) => n.name === "dbServer");
const form = useAppForm({ const form = useAppForm({
defaultValues: { defaultValues: {
runningNumber: "", runningNumber: "",
@@ -111,7 +114,7 @@ export default function TransferToNextLot() {
} }
> >
<p className="text-center"> <p className="text-center">
Almost full Almost full - 95%
</p> </p>
</button> </button>
<button <button
@@ -129,7 +132,7 @@ export default function TransferToNextLot() {
} }
> >
<p className="text-center"> <p className="text-center">
About 75% full About full - 75%
</p> </p>
</button> </button>
<button <button
@@ -145,7 +148,7 @@ export default function TransferToNextLot() {
} }
> >
<p className="text-center"> <p className="text-center">
Half full Half full - 50%
</p> </p>
</button> </button>
<button <button
@@ -163,7 +166,7 @@ export default function TransferToNextLot() {
} }
> >
<p className="text-center"> <p className="text-center">
Almost empty Almost empty - 25%
</p> </p>
</button> </button>
</div> </div>
@@ -218,7 +221,7 @@ export default function TransferToNextLot() {
name="runningNumber" name="runningNumber"
children={(field) => ( children={(field) => (
<field.InputField <field.InputField
label="Runnung Number" label="Running Number"
inputType="number" inputType="number"
required={true} required={true}
/> />
@@ -398,6 +401,19 @@ export default function TransferToNextLot() {
process, this process will just get process, this process will just get
the gaylord to the next lot. the gaylord to the next lot.
</p> </p>
<br />
{settings.length > 0 && (
<p>
For more in depth instructions
please{" "}
<a
href={`https://${server[0].value}.alpla.net/lst/d/docs/ocp/ocp#tranfer-partial-estimated-quantity-to-the-next-lot`}
target="_blank"
>
<em>CLICK HERE</em>
</a>
</p>
)}
</div> </div>
) : ( ) : (
<div> <div>
@@ -437,6 +453,19 @@ export default function TransferToNextLot() {
process, this process will just get process, this process will just get
the gaylord to the next lot. the gaylord to the next lot.
</p> </p>
<br />
{settings.length > 0 && (
<p>
For more in depth instructions
please{" "}
<a
href={`https://${server[0].value}.alpla.net/lst/d/docs/ocp/ocp#tranfer-partial-estimated-quantity-to-the-next-lot`}
target="_blank"
>
<em>CLICK HERE</em>
</a>
</p>
)}
</div> </div>
)} )}
</LstCard> </LstCard>

View File

@@ -243,7 +243,8 @@ export default function ManualPrintForm() {
<Textarea <Textarea
//label="Comments" //label="Comments"
placeholder="add more info as needed." placeholder="add more info as needed."
{...register("additionalComments")} {...(register("additionalComments"),
{ required: true, minLength: 10 })}
/> />
</div> </div>

View File

@@ -28,6 +28,7 @@ import { useLogout } from "@/hooks/useLogout";
import ExportInventoryData from "@/components/logistics/warehouse/ExportInventoryData"; import ExportInventoryData from "@/components/logistics/warehouse/ExportInventoryData";
import { AddCards } from "@/components/dashboard/AddCards"; import { AddCards } from "@/components/dashboard/AddCards";
import DMButtons from "@/components/logistics/dm/DMButtons"; import DMButtons from "@/components/logistics/dm/DMButtons";
import { useSettingStore } from "@/lib/store/useSettings";
//import { AddCards } from "@/components/dashboard/AddCards"; //import { AddCards } from "@/components/dashboard/AddCards";
// same as the layout // same as the layout
@@ -38,6 +39,9 @@ export const Route = createRootRoute({
const { user } = useSessionStore(); const { user } = useSessionStore();
const logout = useLogout(); const logout = useLogout();
const location = useLocation(); const location = useLocation();
const { settings } = useSettingStore();
const server = settings.filter((n: any) => n.name === "dbServer");
return ( return (
<div className="overflow-hidden"> <div className="overflow-hidden">
@@ -61,6 +65,17 @@ export const Route = createRootRoute({
<div className="m-1"> <div className="m-1">
<ModeToggle /> <ModeToggle />
</div> </div>
<div className="mr-1 ml-1">
{settings.length > 0 && (
<a
href={`https://${server[0].value}.alpla.net/lst/d`}
target="_blank"
>
LST - Docs
</a>
)}
</div>
{session ? ( {session ? (
<div className="m-1"> <div className="m-1">
<DropdownMenu> <DropdownMenu>

View File

@@ -36,7 +36,7 @@
} }
}, },
"admConfig": { "admConfig": {
"build": 652, "build": 661,
"oldBuild": "backend-0.1.3.zip" "oldBuild": "backend-0.1.3.zip"
}, },
"devDependencies": { "devDependencies": {

View File

@@ -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,
};
};

View File

@@ -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;
}),
};
};

View File

@@ -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;
}),
};
};

View File

@@ -10,6 +10,9 @@ import addressCorrections from "./route/getCityStateData.js";
import fifoIndex from "./route/getFifoIndex.js"; import fifoIndex from "./route/getFifoIndex.js";
import financeAudit from "./route/getFinanceAudit.js"; import financeAudit from "./route/getFinanceAudit.js";
import psiArticleData from "./route/getPsiArticleData.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(); const app = new OpenAPIHono();
@@ -25,6 +28,9 @@ const routes = [
fifoIndex, fifoIndex,
financeAudit, financeAudit,
psiArticleData, psiArticleData,
psiPlanningData,
psiProductionData,
psiInventory,
] as const; ] as const;
const appRoutes = routes.forEach((route) => { const appRoutes = routes.forEach((route) => {

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -27,7 +27,7 @@ export const deleteHistory = async () => {
.where( .where(
lte( lte(
invHistoricalData.histDate, invHistoricalData.histDate,
sql`(NOW() - INTERVAL '45 day')::date` sql`(NOW() - INTERVAL '365 day')::date`
) )
) )
); );

View File

@@ -13,7 +13,7 @@ type Data = {
runningNr: string; runningNr: string;
lotNum: number; lotNum: number;
}; };
export const consumeMaterial = async (data: Data, prod: any) => { export const consumeMaterial = async (data: Data) => {
const { runningNr, lotNum } = data; const { runningNr, lotNum } = data;
// replace the rn // replace the rn
@@ -28,12 +28,7 @@ export const consumeMaterial = async (data: Data, prod: any) => {
barcode = r?.data; barcode = r?.data;
} catch (error) { } catch (error) {
console.log(error); console.log(error);
createLog( createLog("error", "", "logistics", `Error getting barcode: ${error}`);
"error",
prod.user.username,
"logistics",
`Error getting barcode: ${error}`
);
} }
if (barcode.length === 0) { if (barcode.length === 0) {

View File

@@ -51,33 +51,29 @@ app.openapi(
); );
} }
apiHit(c, { endpoint: "/consume", lastBody: data }); apiHit(c, { endpoint: "/consume", lastBody: data });
const authHeader = c.req.header("Authorization"); //const authHeader = c.req.header("Authorization");
const token = authHeader?.split("Bearer ")[1] || ""; //const token = authHeader?.split("Bearer ")[1] || "";
//const payload = await verify(token, process.env.JWT_SECRET!);
try { try {
const payload = await verify(token, process.env.JWT_SECRET!); //return apiReturn(c, true, access?.message, access?.data, 200);
try {
//return apiReturn(c, true, access?.message, access?.data, 200);
const consume = await consumeMaterial(data, payload); const consume = await consumeMaterial(data);
return c.json( return c.json(
{ success: consume?.success, message: consume?.message }, { success: consume?.success, message: consume?.message },
200 200
); );
} catch (error) {
//console.log(error);
//return apiReturn(c, false, "Error in setting the user access", error, 400);
return c.json(
{
success: false,
message: "Missing data please try again",
error,
},
400
);
}
} catch (error) { } catch (error) {
return c.json({ success: false, message: "Unauthorized" }, 401); //console.log(error);
//return apiReturn(c, false, "Error in setting the user access", error, 400);
return c.json(
{
success: false,
message: "Missing data please try again",
error,
},
400
);
} }
} }
); );

View File

@@ -289,11 +289,13 @@ export const labelingProcess = async ({
"error", "error",
"labeling", "labeling",
"ocp", "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 { return {
success: false, success: false,
message: `Error Booking in label: ${book.data?.errors[0]?.message}`, message: `Error Booking in label`,
data: book, data: book,
}; };
} }

View File

@@ -52,7 +52,7 @@ MaterialHumanReadableId
,x.EffectiveConsumption as consumption -- this is how much was consummed via cmd 112 ,x.EffectiveConsumption as consumption -- this is how much was consummed via cmd 112
,x.TotalDemand as totalDemand -- the total demand needed to finish the lot out ,x.TotalDemand as totalDemand -- the total demand needed to finish the lot out
,case when cp.Pieces >= 0.001 then (lot.TotalProducedQuantity+1) * cp.Pieces else ,case when cp.Pieces >= 0.001 then (lot.TotalProducedLoadingUnits+1) * cp.Pieces else
(a.Weight *((case when cp.Percentage is null then 80 else cp.Percentage end) / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end totalNeeded (a.Weight *((case when cp.Percentage is null then 80 else cp.Percentage end) / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end totalNeeded
,case when IsMainMaterial = 1 then ,case when IsMainMaterial = 1 then
@@ -134,8 +134,7 @@ group by IdArtikelVarianten,ArtikelVariantenBez
) as l on ) as l on
l.IdArtikelVarianten = MaterialHumanReadableId l.IdArtikelVarianten = MaterialHumanReadableId
where lot.ProductionLotHumanReadableId = @lot and where lot.ProductionLotHumanReadableId = @lot and MaterialDescription not like '%nopal%'
MaterialDescription NOT LIKE '%nopal%'
and MaterialDescription NOT LIKE '%bb%' and MaterialDescription NOT LIKE '%bb%'
and MaterialDescription NOT LIKE '%mcg%' and MaterialDescription NOT LIKE '%mcg%'
`; `;

View File

@@ -1,33 +1,34 @@
export const planningNumbersByAVDate = ` export const planningNumbersByAVDate = `
use AlplaPROD_test1 use AlplaPROD_test1
declare @start_date nvarchar(30) = [startDate] --'2025-01-01' declare @start_date nvarchar(30) = '[startDate]' --'2025-01-01'
declare @end_date nvarchar(30) = [endDate] --'2025-08-09' 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 articles will need to be passed over as well as the date structure we want to see
*/ */
-- planned lots in planning select x.IdArtikelvarianten As Article,
select V_ProdLosProduktionJeProdTag_PLANNING.IdArtikelvarianten As Article,
ProduktionAlias as Description, ProduktionAlias as Description,
standort as MachineId, standort as MachineId,
MaschinenBezeichnung as MachineName, MaschinenBezeichnung as MachineName,
--MaschZyklus as PlanningCycleTime, --MaschZyklus as PlanningCycleTime,
V_ProdLosProduktionJeProdTag_PLANNING.IdProdPlanung as LotNumber, x.IdProdPlanung as LotNumber,
FORMAT(ProdTag, 'MM/dd/yyyy') as ProductionDay, FORMAT(ProdTag, 'MM/dd/yyyy') as ProductionDay,
V_ProdLosProduktionJeProdTag_PLANNING.planMenge as TotalPlanned, x.planMenge as TotalPlanned,
ProduktionMenge as QTYPerDay, ProduktionMenge as QTYPerDay,
round(ProduktionMengeVPK, 2) PalDay, round(ProduktionMengeVPK, 2) PalDay,
Status as finished Status as finished
--MaschStdAuslastung as nee --MaschStdAuslastung as nee
from dbo.V_ProdLosProduktionJeProdTag_PLANNING (nolock) from dbo.V_ProdLosProduktionJeProdTag_PLANNING (nolock) as x
left join left join
dbo.V_ProdPlanung (nolock) on dbo.V_ProdPlanung (nolock) as p on
V_ProdLosProduktionJeProdTag_PLANNING .IdProdPlanung = V_ProdPlanung.IdProdPlanung 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
`; `;

View File

@@ -1,8 +1,8 @@
export const productionNumbers = ` export const productionNumbers = `
use [test1_AlplaPROD2.0_Reporting] use [test1_AlplaPROD2.0_Reporting]
declare @startDate nvarchar(30) = [startDate] --'2024-12-30' declare @startDate nvarchar(30) = '[startDate]' --'2024-12-30'
declare @endDate nvarchar(30) = [endDate] --'2025-08-09' declare @endDate nvarchar(30) = '[endDate]' --'2025-08-09'
select MachineLocation, select MachineLocation,
ArticleHumanReadableId as article, ArticleHumanReadableId as article,

View File

@@ -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
`;