feat(eom): all endpoints created for the eom template to run in all plants
This commit is contained in:
@@ -1,7 +1,11 @@
|
|||||||
|
import { eq } from "drizzle-orm";
|
||||||
|
import { db } from "../../../../database/dbclient.js";
|
||||||
|
import { settings } from "../../../../database/schema/settings.js";
|
||||||
|
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||||
import { query } from "../../sqlServer/prodSqlServer.js";
|
import { query } from "../../sqlServer/prodSqlServer.js";
|
||||||
import { activeArticle } from "../../sqlServer/querys/dataMart/article.js";
|
import { activeArticle } from "../../sqlServer/querys/dataMart/article.js";
|
||||||
|
|
||||||
export const getActiveAv = async () => {
|
export const getActiveAv = async (includePlantToken: boolean = false) => {
|
||||||
let articles: any = [];
|
let articles: any = [];
|
||||||
try {
|
try {
|
||||||
const res = await query(activeArticle, "Get active articles");
|
const res = await query(activeArticle, "Get active articles");
|
||||||
@@ -10,5 +14,20 @@ export const getActiveAv = async () => {
|
|||||||
articles = error;
|
articles = error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return articles;
|
if (includePlantToken) {
|
||||||
|
const { data, error } = (await tryCatch(
|
||||||
|
db.select().from(settings).where(eq(settings.name, "plantToken"))
|
||||||
|
)) as any;
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
console.log("Error getting articles");
|
||||||
|
return articles;
|
||||||
|
}
|
||||||
|
|
||||||
|
return articles.map((n: any) => {
|
||||||
|
return { plantToken: data[0].value, ...n };
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return articles;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ import {
|
|||||||
totalInvRn,
|
totalInvRn,
|
||||||
} from "../../sqlServer/querys/dataMart/totalINV.js";
|
} from "../../sqlServer/querys/dataMart/totalINV.js";
|
||||||
|
|
||||||
export const getINV = async (rn: boolean) => {
|
export const getINV = async (
|
||||||
|
rn: boolean,
|
||||||
|
includePlantToken: boolean = false
|
||||||
|
) => {
|
||||||
let inventory: any = [];
|
let inventory: any = [];
|
||||||
|
|
||||||
let updatedQuery = totalInvNoRn;
|
let updatedQuery = totalInvNoRn;
|
||||||
|
|||||||
@@ -22,13 +22,17 @@ app.openapi(
|
|||||||
async (c) => {
|
async (c) => {
|
||||||
//const body = await c.req.json();
|
//const body = await c.req.json();
|
||||||
// make sure we have a vaid user being accessed thats really logged in
|
// make sure we have a vaid user being accessed thats really logged in
|
||||||
|
const includePlantToken: any = c.req.queries();
|
||||||
|
|
||||||
apiHit(c, { endpoint: "/getarticles" });
|
apiHit(c, { endpoint: "/getarticles" });
|
||||||
try {
|
try {
|
||||||
return c.json(
|
return c.json(
|
||||||
{
|
{
|
||||||
success: true,
|
success: true,
|
||||||
message: "Current active Articles",
|
message: "Current active Articles",
|
||||||
data: await getActiveAv(),
|
data: await getActiveAv(
|
||||||
|
includePlantToken["includePlantToken"] ? true : false
|
||||||
|
),
|
||||||
},
|
},
|
||||||
200
|
200
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,8 +3,12 @@ import { db } from "../../../../database/dbclient.js";
|
|||||||
import { invHistoricalData } from "../../../../database/schema/historicalINV.js";
|
import { invHistoricalData } from "../../../../database/schema/historicalINV.js";
|
||||||
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
|
import { settings } from "../../../../database/schema/settings.js";
|
||||||
|
|
||||||
export const historicalInvByDate = async (date: string) => {
|
export const historicalInvByDate = async (
|
||||||
|
date: string,
|
||||||
|
includePlantToken: boolean = false
|
||||||
|
) => {
|
||||||
const histDate = new Date(date);
|
const histDate = new Date(date);
|
||||||
|
|
||||||
const { data, error } = (await tryCatch(
|
const { data, error } = (await tryCatch(
|
||||||
@@ -24,9 +28,28 @@ export const historicalInvByDate = async (date: string) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
if (includePlantToken) {
|
||||||
success: true,
|
const { data: s, error: se } = (await tryCatch(
|
||||||
message: `Historical inventory for ${date}`,
|
db.select().from(settings).where(eq(settings.name, "plantToken"))
|
||||||
data: data,
|
)) as any;
|
||||||
};
|
|
||||||
|
if (se) {
|
||||||
|
console.log("Error getting articles");
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: `Historical inventory for ${date}`,
|
||||||
|
data: data.map((n: any) => {
|
||||||
|
return { plantToken: s[0].value, ...n };
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: `Historical inventory for ${date}`,
|
||||||
|
data: data,
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,8 +2,11 @@ import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
|||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import { query } from "../../sqlServer/prodSqlServer.js";
|
import { query } from "../../sqlServer/prodSqlServer.js";
|
||||||
import { lastPurchasePrice } from "../../sqlServer/querys/eom/lstPurchasePrice.js";
|
import { lastPurchasePrice } from "../../sqlServer/querys/eom/lstPurchasePrice.js";
|
||||||
|
import { db } from "../../../../database/dbclient.js";
|
||||||
|
import { settings } from "../../../../database/schema/settings.js";
|
||||||
|
import { eq } from "drizzle-orm";
|
||||||
|
|
||||||
export const lastPurchase = async () => {
|
export const lastPurchase = async (includePlantToken: boolean = false) => {
|
||||||
const { data, error } = (await tryCatch(
|
const { data, error } = (await tryCatch(
|
||||||
query(lastPurchasePrice, "Last purchase price")
|
query(lastPurchasePrice, "Last purchase price")
|
||||||
)) as any;
|
)) as any;
|
||||||
@@ -16,9 +19,28 @@ export const lastPurchase = async () => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
if (includePlantToken) {
|
||||||
success: true,
|
const { data: s, error: se } = (await tryCatch(
|
||||||
message: `Last purchase price for all av in the last 5 years`,
|
db.select().from(settings).where(eq(settings.name, "plantToken"))
|
||||||
data: data.data,
|
)) as any;
|
||||||
};
|
|
||||||
|
if (se) {
|
||||||
|
console.log("Error getting articles");
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: `Last purchase price for all av in the last 5 years`,
|
||||||
|
data: data.data.map((n: any) => {
|
||||||
|
return { plantToken: s[0].value, ...n };
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: `Last purchase price for all av in the last 5 years`,
|
||||||
|
data: data.data,
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
|
import { eq } from "drizzle-orm";
|
||||||
|
import { db } from "../../../../database/dbclient.js";
|
||||||
|
import { settings } from "../../../../database/schema/settings.js";
|
||||||
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||||
import { query } from "../../sqlServer/prodSqlServer.js";
|
import { query } from "../../sqlServer/prodSqlServer.js";
|
||||||
import { lastSalesPriceCheck } from "../../sqlServer/querys/eom/lastSalesprice.js";
|
import { lastSalesPriceCheck } from "../../sqlServer/querys/eom/lastSalesprice.js";
|
||||||
|
import { format } from "date-fns-tz";
|
||||||
|
|
||||||
export const lastSales = async (date: string) => {
|
export const lastSales = async (
|
||||||
|
date: string,
|
||||||
|
includePlantToken: boolean = false
|
||||||
|
) => {
|
||||||
const { data, error } = (await tryCatch(
|
const { data, error } = (await tryCatch(
|
||||||
query(lastSalesPriceCheck.replace("[date]", date), "Last sales price")
|
query(lastSalesPriceCheck.replace("[date]", date), "Last sales price")
|
||||||
)) as any;
|
)) as any;
|
||||||
@@ -15,9 +22,34 @@ export const lastSales = async (date: string) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
if (includePlantToken) {
|
||||||
success: true,
|
const { data: s, error: se } = (await tryCatch(
|
||||||
message: `Last sales price for all av in the last 5 years`,
|
db.select().from(settings).where(eq(settings.name, "plantToken"))
|
||||||
data: data.data,
|
)) as any;
|
||||||
};
|
|
||||||
|
if (se) {
|
||||||
|
console.log("Error getting articles");
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: `Historical inventory for ${date}`,
|
||||||
|
data: data.data.map((n: any) => {
|
||||||
|
return {
|
||||||
|
plantToken: s[0].value,
|
||||||
|
...n,
|
||||||
|
validDate: format(n.validDate, "M/d/yyyy"),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: `Last sales price for all av in the last 5 years`,
|
||||||
|
data: data.data.map((n: any) => {
|
||||||
|
return { ...n, validDate: format(n.validDate, "M/d/yyyy") };
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
import { eq } from "drizzle-orm";
|
||||||
|
import { db } from "../../../../database/dbclient.js";
|
||||||
|
import { settings } from "../../../../database/schema/settings.js";
|
||||||
|
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||||
|
import { query } from "../../sqlServer/prodSqlServer.js";
|
||||||
|
import { lastSalesPriceCheck } from "../../sqlServer/querys/eom/lastSalesprice.js";
|
||||||
|
import { consumptionCheck } from "../../sqlServer/querys/eom/consumptionCheck.js";
|
||||||
|
import { format } from "date-fns-tz";
|
||||||
|
|
||||||
|
type Consumption = {
|
||||||
|
startDate: string;
|
||||||
|
endDate: string;
|
||||||
|
includePlantToken: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getProductionConsumption = async (consumption: Consumption) => {
|
||||||
|
const { data, error } = (await tryCatch(
|
||||||
|
query(
|
||||||
|
consumptionCheck
|
||||||
|
.replace("[startDate]", consumption.startDate)
|
||||||
|
.replace("[endDate]", consumption.endDate),
|
||||||
|
"Last sales price"
|
||||||
|
)
|
||||||
|
)) as any;
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Error getting the last sales price",
|
||||||
|
data: error,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (consumption.includePlantToken) {
|
||||||
|
const { data: s, error: se } = (await tryCatch(
|
||||||
|
db.select().from(settings).where(eq(settings.name, "plantToken"))
|
||||||
|
)) as any;
|
||||||
|
|
||||||
|
if (se) {
|
||||||
|
console.log("Error getting articles");
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: `consumption data`,
|
||||||
|
data: data.data.map((n: any) => {
|
||||||
|
return {
|
||||||
|
plantToken: s[0].value,
|
||||||
|
...n,
|
||||||
|
Prod_Date: format(n.Prod_Date, "M/d/yyyy"),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: `consumption data`,
|
||||||
|
data: data.data.map((n: any) => {
|
||||||
|
return {
|
||||||
|
...n,
|
||||||
|
Prod_Date: format(n.Prod_Date, "M/d/yyyy"),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
66
lstV2/server/services/eom/controller/getPurchased.ts
Normal file
66
lstV2/server/services/eom/controller/getPurchased.ts
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
import { eq } from "drizzle-orm";
|
||||||
|
import { db } from "../../../../database/dbclient.js";
|
||||||
|
import { settings } from "../../../../database/schema/settings.js";
|
||||||
|
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||||
|
import { query } from "../../sqlServer/prodSqlServer.js";
|
||||||
|
import { format } from "date-fns-tz";
|
||||||
|
import { purchased } from "../../sqlServer/querys/eom/purchased.js";
|
||||||
|
|
||||||
|
type Consumption = {
|
||||||
|
startDate: string;
|
||||||
|
endDate: string;
|
||||||
|
includePlantToken: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getPurchased = async (consumption: Consumption) => {
|
||||||
|
const { data, error } = (await tryCatch(
|
||||||
|
query(
|
||||||
|
purchased
|
||||||
|
.replace("[startDate]", consumption.startDate)
|
||||||
|
.replace("[endDate]", consumption.endDate),
|
||||||
|
"Last sales price"
|
||||||
|
)
|
||||||
|
)) as any;
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Error getting the last sales price",
|
||||||
|
data: error,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (consumption.includePlantToken) {
|
||||||
|
const { data: s, error: se } = (await tryCatch(
|
||||||
|
db.select().from(settings).where(eq(settings.name, "plantToken"))
|
||||||
|
)) as any;
|
||||||
|
|
||||||
|
if (se) {
|
||||||
|
console.log("Error getting articles");
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: `consumption data`,
|
||||||
|
data: data.data.map((n: any) => {
|
||||||
|
return {
|
||||||
|
plantToken: s[0].value,
|
||||||
|
...n,
|
||||||
|
Received_Date: format(n.Received_Date, "M/d/yyyy"),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: `consumption data`,
|
||||||
|
data: data.data.map((n: any) => {
|
||||||
|
return {
|
||||||
|
...n,
|
||||||
|
Received_Date: format(n.Received_Date, "M/d/yyyy"),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
68
lstV2/server/services/eom/controller/getSoldItems.ts
Normal file
68
lstV2/server/services/eom/controller/getSoldItems.ts
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
import { eq } from "drizzle-orm";
|
||||||
|
import { db } from "../../../../database/dbclient.js";
|
||||||
|
import { settings } from "../../../../database/schema/settings.js";
|
||||||
|
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||||
|
import { query } from "../../sqlServer/prodSqlServer.js";
|
||||||
|
|
||||||
|
import { format } from "date-fns-tz";
|
||||||
|
|
||||||
|
import { soldOutItems } from "../../sqlServer/querys/eom/soldOut.js";
|
||||||
|
|
||||||
|
type Consumption = {
|
||||||
|
startDate: string;
|
||||||
|
endDate: string;
|
||||||
|
includePlantToken: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getSoldItems = async (consumption: Consumption) => {
|
||||||
|
const { data, error } = (await tryCatch(
|
||||||
|
query(
|
||||||
|
soldOutItems
|
||||||
|
.replace("[startDate]", consumption.startDate)
|
||||||
|
.replace("[endDate]", consumption.endDate),
|
||||||
|
"Last sales price"
|
||||||
|
)
|
||||||
|
)) as any;
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Error getting the last sales price",
|
||||||
|
data: error,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (consumption.includePlantToken) {
|
||||||
|
const { data: s, error: se } = (await tryCatch(
|
||||||
|
db.select().from(settings).where(eq(settings.name, "plantToken"))
|
||||||
|
)) as any;
|
||||||
|
|
||||||
|
if (se) {
|
||||||
|
console.log("Error getting articles");
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: `consumption data`,
|
||||||
|
data: data.data.map((n: any) => {
|
||||||
|
return {
|
||||||
|
plantToken: s[0].value,
|
||||||
|
...n,
|
||||||
|
DeliveryDate: format(n.DeliveryDate, "M/d/yyyy"),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: `consumption data`,
|
||||||
|
data: data.data.map((n: any) => {
|
||||||
|
return {
|
||||||
|
...n,
|
||||||
|
DeliveryDate: format(n.DeliveryDate, "M/d/yyyy"),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
68
lstV2/server/services/eom/controller/getregrind.ts
Normal file
68
lstV2/server/services/eom/controller/getregrind.ts
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
import { eq } from "drizzle-orm";
|
||||||
|
import { db } from "../../../../database/dbclient.js";
|
||||||
|
import { settings } from "../../../../database/schema/settings.js";
|
||||||
|
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||||
|
import { query } from "../../sqlServer/prodSqlServer.js";
|
||||||
|
import { lastSalesPriceCheck } from "../../sqlServer/querys/eom/lastSalesprice.js";
|
||||||
|
import { consumptionCheck } from "../../sqlServer/querys/eom/consumptionCheck.js";
|
||||||
|
import { format } from "date-fns-tz";
|
||||||
|
import { regrindCheck } from "../../sqlServer/querys/eom/regrind.js";
|
||||||
|
|
||||||
|
type Consumption = {
|
||||||
|
startDate: string;
|
||||||
|
endDate: string;
|
||||||
|
includePlantToken: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getRegrind = async (consumption: Consumption) => {
|
||||||
|
const { data, error } = (await tryCatch(
|
||||||
|
query(
|
||||||
|
regrindCheck
|
||||||
|
.replace("[startDate]", consumption.startDate)
|
||||||
|
.replace("[endDate]", consumption.endDate),
|
||||||
|
"Last sales price"
|
||||||
|
)
|
||||||
|
)) as any;
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Error getting the last sales price",
|
||||||
|
data: error,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (consumption.includePlantToken) {
|
||||||
|
const { data: s, error: se } = (await tryCatch(
|
||||||
|
db.select().from(settings).where(eq(settings.name, "plantToken"))
|
||||||
|
)) as any;
|
||||||
|
|
||||||
|
if (se) {
|
||||||
|
console.log("Error getting articles");
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: `consumption data`,
|
||||||
|
data: data.data.map((n: any) => {
|
||||||
|
return {
|
||||||
|
plantToken: s[0].value,
|
||||||
|
...n,
|
||||||
|
Buchungsdatum: format(n.Buchungsdatum, "M/d/yyyy"),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: `consumption data`,
|
||||||
|
data: data.data.map((n: any) => {
|
||||||
|
return {
|
||||||
|
...n,
|
||||||
|
Buchungsdatum: format(n.Buchungsdatum, "M/d/yyyy"),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -12,8 +12,23 @@ import { shiftChange } from "../sqlServer/querys/misc/shiftChange.js";
|
|||||||
import { createLog } from "../logger/logger.js";
|
import { createLog } from "../logger/logger.js";
|
||||||
import lastPurch from "./route/getLastPurchPrice.js";
|
import lastPurch from "./route/getLastPurchPrice.js";
|
||||||
import lastSales from "./route/getLastSalesPrice.js";
|
import lastSales from "./route/getLastSalesPrice.js";
|
||||||
|
import gpData from "./route/getGpData.js";
|
||||||
|
import consumptionData from "./route/getProductionConsumption.js";
|
||||||
|
import regrind from "./route/getregrind.js";
|
||||||
|
import soldItems from "./route/getSoldItems.js";
|
||||||
|
import purchased from "./route/getPurchased.js";
|
||||||
|
|
||||||
const routes = [stats, history, lastPurch, lastSales] as const;
|
const routes = [
|
||||||
|
stats,
|
||||||
|
history,
|
||||||
|
lastPurch,
|
||||||
|
lastSales,
|
||||||
|
gpData,
|
||||||
|
consumptionData,
|
||||||
|
regrind,
|
||||||
|
soldItems,
|
||||||
|
purchased,
|
||||||
|
] as const;
|
||||||
|
|
||||||
const appRoutes = routes.forEach((route) => {
|
const appRoutes = routes.forEach((route) => {
|
||||||
app.route("/eom", route);
|
app.route("/eom", route);
|
||||||
|
|||||||
51
lstV2/server/services/eom/route/getGpData.ts
Normal file
51
lstV2/server/services/eom/route/getGpData.ts
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||||
|
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||||
|
import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
||||||
|
|
||||||
|
import { runGPQuery } from "../../sqlServer/gpSqlServer.js";
|
||||||
|
|
||||||
|
const app = new OpenAPIHono({ strict: false });
|
||||||
|
const EomStat = z.object({
|
||||||
|
plant: z.string().openapi({ example: "Salt Lake City" }),
|
||||||
|
userRan: z.string().openapi({ example: "smith034" }),
|
||||||
|
eomSheetVersion: z.string().openapi({ example: "0.0.223" }),
|
||||||
|
});
|
||||||
|
|
||||||
|
app.openapi(
|
||||||
|
createRoute({
|
||||||
|
tags: ["eom"],
|
||||||
|
summary: "Gets History Data by date.",
|
||||||
|
method: "get",
|
||||||
|
path: "/gpData",
|
||||||
|
responses: responses(),
|
||||||
|
}),
|
||||||
|
async (c) => {
|
||||||
|
//const body = await c.req.json();
|
||||||
|
// make sure we have a vaid user being accessed thats really logged in
|
||||||
|
const q: any = c.req.queries();
|
||||||
|
|
||||||
|
apiHit(c, { endpoint: "/gpData" });
|
||||||
|
try {
|
||||||
|
const res = await runGPQuery({
|
||||||
|
startDate: q["startDate"] ? q["startDate"][0] : "",
|
||||||
|
endDate: q["endDate"] ? q["endDate"][0] : "",
|
||||||
|
gpCode: q["gpCode"] ? q["gpCode"] : "",
|
||||||
|
});
|
||||||
|
|
||||||
|
return c.json(
|
||||||
|
{ success: res.success, message: res.message, data: res.data },
|
||||||
|
200
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
return c.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "There was an error getting gp data.",
|
||||||
|
data: error,
|
||||||
|
},
|
||||||
|
400
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
export default app;
|
||||||
@@ -17,10 +17,12 @@ app.openapi(
|
|||||||
async (c) => {
|
async (c) => {
|
||||||
//const body = await c.req.json();
|
//const body = await c.req.json();
|
||||||
// make sure we have a vaid user being accessed thats really logged in
|
// make sure we have a vaid user being accessed thats really logged in
|
||||||
|
const q: any = c.req.queries();
|
||||||
apiHit(c, { endpoint: "/lastpurchprice" });
|
apiHit(c, { endpoint: "/lastpurchprice" });
|
||||||
try {
|
try {
|
||||||
const res = await lastPurchase();
|
const res = await lastPurchase(
|
||||||
|
q["includePlantToken"] ? true : false
|
||||||
|
);
|
||||||
|
|
||||||
return c.json(
|
return c.json(
|
||||||
{ success: res.success, message: res.message, data: res.data },
|
{ success: res.success, message: res.message, data: res.data },
|
||||||
|
|||||||
@@ -17,12 +17,14 @@ app.openapi(
|
|||||||
}),
|
}),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
//const body = await c.req.json();
|
//const body = await c.req.json();
|
||||||
const month: string = c.req.query("month") ?? "";
|
|
||||||
// make sure we have a vaid user being accessed thats really logged in
|
// make sure we have a vaid user being accessed thats really logged in
|
||||||
|
const q: any = c.req.queries();
|
||||||
apiHit(c, { endpoint: "/lastsalesprice" });
|
apiHit(c, { endpoint: "/lastsalesprice" });
|
||||||
try {
|
try {
|
||||||
const res = await lastSales(month);
|
const res = await lastSales(
|
||||||
|
q["month"] ? q["month"][0] : null,
|
||||||
|
q["includePlantToken"] ? true : false
|
||||||
|
);
|
||||||
|
|
||||||
return c.json(
|
return c.json(
|
||||||
{ success: res.success, message: res.message, data: res.data },
|
{ success: res.success, message: res.message, data: res.data },
|
||||||
|
|||||||
52
lstV2/server/services/eom/route/getProductionConsumption.ts
Normal file
52
lstV2/server/services/eom/route/getProductionConsumption.ts
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||||
|
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||||
|
import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
||||||
|
|
||||||
|
import { runGPQuery } from "../../sqlServer/gpSqlServer.js";
|
||||||
|
import { getProductionConsumption } from "../controller/getProductionConsumption.js";
|
||||||
|
|
||||||
|
const app = new OpenAPIHono({ strict: false });
|
||||||
|
const EomStat = z.object({
|
||||||
|
plant: z.string().openapi({ example: "Salt Lake City" }),
|
||||||
|
userRan: z.string().openapi({ example: "smith034" }),
|
||||||
|
eomSheetVersion: z.string().openapi({ example: "0.0.223" }),
|
||||||
|
});
|
||||||
|
|
||||||
|
app.openapi(
|
||||||
|
createRoute({
|
||||||
|
tags: ["eom"],
|
||||||
|
summary: "Gets History Data by date.",
|
||||||
|
method: "get",
|
||||||
|
path: "/productionconsumption",
|
||||||
|
responses: responses(),
|
||||||
|
}),
|
||||||
|
async (c) => {
|
||||||
|
//const body = await c.req.json();
|
||||||
|
// make sure we have a vaid user being accessed thats really logged in
|
||||||
|
const q: any = c.req.queries();
|
||||||
|
|
||||||
|
apiHit(c, { endpoint: "/gpData" });
|
||||||
|
try {
|
||||||
|
const res = await getProductionConsumption({
|
||||||
|
startDate: q["startDate"] ? q["startDate"][0] : "",
|
||||||
|
endDate: q["endDate"] ? q["endDate"][0] : "",
|
||||||
|
includePlantToken: q["includePlantToken"] ? true : false,
|
||||||
|
});
|
||||||
|
|
||||||
|
return c.json(
|
||||||
|
{ success: res.success, message: res.message, data: res.data },
|
||||||
|
200
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
return c.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "There was an error getting gp data.",
|
||||||
|
data: error,
|
||||||
|
},
|
||||||
|
400
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
export default app;
|
||||||
50
lstV2/server/services/eom/route/getPurchased.ts
Normal file
50
lstV2/server/services/eom/route/getPurchased.ts
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||||
|
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||||
|
import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
||||||
|
import { getPurchased } from "../controller/getPurchased.js";
|
||||||
|
|
||||||
|
const app = new OpenAPIHono({ strict: false });
|
||||||
|
const EomStat = z.object({
|
||||||
|
plant: z.string().openapi({ example: "Salt Lake City" }),
|
||||||
|
userRan: z.string().openapi({ example: "smith034" }),
|
||||||
|
eomSheetVersion: z.string().openapi({ example: "0.0.223" }),
|
||||||
|
});
|
||||||
|
|
||||||
|
app.openapi(
|
||||||
|
createRoute({
|
||||||
|
tags: ["eom"],
|
||||||
|
summary: "Gets History Data by date.",
|
||||||
|
method: "get",
|
||||||
|
path: "/purchased",
|
||||||
|
responses: responses(),
|
||||||
|
}),
|
||||||
|
async (c) => {
|
||||||
|
//const body = await c.req.json();
|
||||||
|
// make sure we have a vaid user being accessed thats really logged in
|
||||||
|
const q: any = c.req.queries();
|
||||||
|
|
||||||
|
apiHit(c, { endpoint: "/regrind" });
|
||||||
|
try {
|
||||||
|
const res = await getPurchased({
|
||||||
|
startDate: q["startDate"] ? q["startDate"][0] : "",
|
||||||
|
endDate: q["endDate"] ? q["endDate"][0] : "",
|
||||||
|
includePlantToken: q["includePlantToken"] ? true : false,
|
||||||
|
});
|
||||||
|
|
||||||
|
return c.json(
|
||||||
|
{ success: res.success, message: res.message, data: res.data },
|
||||||
|
200
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
return c.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "There was an error getting gp data.",
|
||||||
|
data: error,
|
||||||
|
},
|
||||||
|
400
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
export default app;
|
||||||
54
lstV2/server/services/eom/route/getSoldItems.ts
Normal file
54
lstV2/server/services/eom/route/getSoldItems.ts
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||||
|
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||||
|
import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
||||||
|
|
||||||
|
import { runGPQuery } from "../../sqlServer/gpSqlServer.js";
|
||||||
|
import { getProductionConsumption } from "../controller/getProductionConsumption.js";
|
||||||
|
import { getRegrind } from "../controller/getregrind.js";
|
||||||
|
import { getSoldItems } from "../controller/getSoldItems.js";
|
||||||
|
|
||||||
|
const app = new OpenAPIHono({ strict: false });
|
||||||
|
const EomStat = z.object({
|
||||||
|
plant: z.string().openapi({ example: "Salt Lake City" }),
|
||||||
|
userRan: z.string().openapi({ example: "smith034" }),
|
||||||
|
eomSheetVersion: z.string().openapi({ example: "0.0.223" }),
|
||||||
|
});
|
||||||
|
|
||||||
|
app.openapi(
|
||||||
|
createRoute({
|
||||||
|
tags: ["eom"],
|
||||||
|
summary: "Gets History Data by date.",
|
||||||
|
method: "get",
|
||||||
|
path: "/solditems",
|
||||||
|
responses: responses(),
|
||||||
|
}),
|
||||||
|
async (c) => {
|
||||||
|
//const body = await c.req.json();
|
||||||
|
// make sure we have a vaid user being accessed thats really logged in
|
||||||
|
const q: any = c.req.queries();
|
||||||
|
|
||||||
|
apiHit(c, { endpoint: "/regrind" });
|
||||||
|
try {
|
||||||
|
const res = await getSoldItems({
|
||||||
|
startDate: q["startDate"] ? q["startDate"][0] : "",
|
||||||
|
endDate: q["endDate"] ? q["endDate"][0] : "",
|
||||||
|
includePlantToken: q["includePlantToken"] ? true : false,
|
||||||
|
});
|
||||||
|
|
||||||
|
return c.json(
|
||||||
|
{ success: res.success, message: res.message, data: res.data },
|
||||||
|
200
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
return c.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "There was an error getting gp data.",
|
||||||
|
data: error,
|
||||||
|
},
|
||||||
|
400
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
export default app;
|
||||||
53
lstV2/server/services/eom/route/getregrind.ts
Normal file
53
lstV2/server/services/eom/route/getregrind.ts
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||||
|
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||||
|
import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
||||||
|
|
||||||
|
import { runGPQuery } from "../../sqlServer/gpSqlServer.js";
|
||||||
|
import { getProductionConsumption } from "../controller/getProductionConsumption.js";
|
||||||
|
import { getRegrind } from "../controller/getregrind.js";
|
||||||
|
|
||||||
|
const app = new OpenAPIHono({ strict: false });
|
||||||
|
const EomStat = z.object({
|
||||||
|
plant: z.string().openapi({ example: "Salt Lake City" }),
|
||||||
|
userRan: z.string().openapi({ example: "smith034" }),
|
||||||
|
eomSheetVersion: z.string().openapi({ example: "0.0.223" }),
|
||||||
|
});
|
||||||
|
|
||||||
|
app.openapi(
|
||||||
|
createRoute({
|
||||||
|
tags: ["eom"],
|
||||||
|
summary: "Gets History Data by date.",
|
||||||
|
method: "get",
|
||||||
|
path: "/regrind",
|
||||||
|
responses: responses(),
|
||||||
|
}),
|
||||||
|
async (c) => {
|
||||||
|
//const body = await c.req.json();
|
||||||
|
// make sure we have a vaid user being accessed thats really logged in
|
||||||
|
const q: any = c.req.queries();
|
||||||
|
|
||||||
|
apiHit(c, { endpoint: "/regrind" });
|
||||||
|
try {
|
||||||
|
const res = await getRegrind({
|
||||||
|
startDate: q["startDate"] ? q["startDate"][0] : "",
|
||||||
|
endDate: q["endDate"] ? q["endDate"][0] : "",
|
||||||
|
includePlantToken: q["includePlantToken"] ? true : false,
|
||||||
|
});
|
||||||
|
|
||||||
|
return c.json(
|
||||||
|
{ success: res.success, message: res.message, data: res.data },
|
||||||
|
200
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
return c.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "There was an error getting gp data.",
|
||||||
|
data: error,
|
||||||
|
},
|
||||||
|
400
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
export default app;
|
||||||
@@ -21,11 +21,14 @@ app.openapi(
|
|||||||
async (c) => {
|
async (c) => {
|
||||||
//const body = await c.req.json();
|
//const body = await c.req.json();
|
||||||
// make sure we have a vaid user being accessed thats really logged in
|
// make sure we have a vaid user being accessed thats really logged in
|
||||||
const month: string = c.req.query("month") ?? "";
|
const q: any = c.req.queries();
|
||||||
|
|
||||||
apiHit(c, { endpoint: "/histinv" });
|
apiHit(c, { endpoint: "/histinv" });
|
||||||
try {
|
try {
|
||||||
const res = await historicalInvByDate(month);
|
const res = await historicalInvByDate(
|
||||||
|
q["month"] ? q["month"][0] : null,
|
||||||
|
q["includePlantToken"] ? true : false
|
||||||
|
);
|
||||||
|
|
||||||
return c.json(
|
return c.json(
|
||||||
{ success: res.success, message: res.message, data: res.data },
|
{ success: res.success, message: res.message, data: res.data },
|
||||||
|
|||||||
@@ -85,16 +85,16 @@ export const labelingProcess = async ({
|
|||||||
(l: any) => l.MachineID === macId[0]?.HumanReadableId
|
(l: any) => l.MachineID === macId[0]?.HumanReadableId
|
||||||
);
|
);
|
||||||
|
|
||||||
if (filteredLot.length === 0) {
|
if (!filteredLot || filteredLot.length === 0) {
|
||||||
createLog(
|
createLog(
|
||||||
"error",
|
"error",
|
||||||
"labeling",
|
"labeling",
|
||||||
"ocp",
|
"ocp",
|
||||||
`There is not a lot assigned to ${line}.`
|
`There is not a lot assigned to ${zechette.line}.`
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: `There is not a lot assigned to ${line}.`,
|
message: `There is not a lot assigned to ${zechette.line}.`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
104
lstV2/server/services/sqlServer/gpSqlServer.ts
Normal file
104
lstV2/server/services/sqlServer/gpSqlServer.ts
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
import sql from "mssql";
|
||||||
|
import { tryCatch } from "../../globalUtils/tryCatch.js";
|
||||||
|
import { db } from "../../../database/dbclient.js";
|
||||||
|
import { settings } from "../../../database/schema/settings.js";
|
||||||
|
import { eq } from "drizzle-orm";
|
||||||
|
import { format } from "date-fns-tz";
|
||||||
|
|
||||||
|
const username = "gpviewer";
|
||||||
|
const password = "gp$$ViewOnly!";
|
||||||
|
|
||||||
|
const sqlGPConfig = {
|
||||||
|
server: "USMCD1VMS011",
|
||||||
|
database: `ALPLA`,
|
||||||
|
user: username,
|
||||||
|
password: password,
|
||||||
|
options: {
|
||||||
|
encrypt: true,
|
||||||
|
trustServerCertificate: true,
|
||||||
|
},
|
||||||
|
requestTimeout: 90000,
|
||||||
|
};
|
||||||
|
|
||||||
|
type GPCheck = {
|
||||||
|
startDate: string;
|
||||||
|
endDate: string;
|
||||||
|
gpCode: string;
|
||||||
|
};
|
||||||
|
export const runGPQuery = async (gpCheck: GPCheck) => {
|
||||||
|
let pool2: sql.ConnectionPool | null = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Create a brand-new pool, not touching the "global" one
|
||||||
|
pool2 = new sql.ConnectionPool(sqlGPConfig);
|
||||||
|
await pool2.connect();
|
||||||
|
|
||||||
|
const query = `
|
||||||
|
select * from (
|
||||||
|
select
|
||||||
|
case when x.POPRCTNM is null then p.POPRCTNM else p.POPRCTNM end as RCT_Num,
|
||||||
|
PONUMBER PO,
|
||||||
|
p.VENDORID Supplier,
|
||||||
|
ITEMNMBR Item,
|
||||||
|
QTYSHPPD shipped,
|
||||||
|
UOFM Type,
|
||||||
|
TRXLOCTN Location,
|
||||||
|
case when CONVERT(DATE, x.receiptdate) is null then convert(date, p.DATERECD) else CONVERT(DATE, x.receiptdate) end as Date_Recived
|
||||||
|
from ALPLA.dbo.pop10500 (nolock) as p
|
||||||
|
left join
|
||||||
|
ALPLA.dbo.POP10300 as x on p.POPRCTNM = x.POPRCTNM
|
||||||
|
WHERE TRXLOCTN LIKE '[gpCode]%' and p.POPTYPE = 1) a
|
||||||
|
where Date_Recived BETWEEN '[startDate]' AND '[endDate]'
|
||||||
|
`;
|
||||||
|
|
||||||
|
const { data: s, error: se } = (await tryCatch(
|
||||||
|
db.select().from(settings).where(eq(settings.name, "plantToken"))
|
||||||
|
)) as any;
|
||||||
|
|
||||||
|
if (se) {
|
||||||
|
console.log("Error getting articles");
|
||||||
|
return se;
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await pool2
|
||||||
|
.request()
|
||||||
|
|
||||||
|
.query(
|
||||||
|
query
|
||||||
|
.replace("[startDate]", gpCheck.startDate)
|
||||||
|
.replace("[endDate]", gpCheck.endDate)
|
||||||
|
.replace("[gpCode]", gpCheck.gpCode)
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "GP data",
|
||||||
|
data: result.recordset.map((n: any) => {
|
||||||
|
return {
|
||||||
|
plantToken: s[0].value,
|
||||||
|
...n,
|
||||||
|
RCT_Num: n.RCT_Num.trim(),
|
||||||
|
PO: n.PO.trim(),
|
||||||
|
Supplier: n.Supplier.trim(),
|
||||||
|
Item: n.Item.trim(),
|
||||||
|
article:
|
||||||
|
n.Item.split("-").length > 1
|
||||||
|
? n.Item.split("-")[1].trim()
|
||||||
|
: "No article",
|
||||||
|
Type: n.Type.trim(),
|
||||||
|
Location: n.Location.trim(),
|
||||||
|
Date_Recived: format(n.Date_Recived, "M/d/yyyy"),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Error Getting GP data",
|
||||||
|
data: error,
|
||||||
|
};
|
||||||
|
} finally {
|
||||||
|
if (pool2) await pool2.close(); // Always close the pool
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
export const consumptionCheck = `
|
||||||
|
SELECT IdArtikelvarianten AS AV,
|
||||||
|
Menge AS Quantity,
|
||||||
|
CONVERT(DATE, BuchDatum) AS Prod_Date
|
||||||
|
FROM alplaprod_test1.dbo.T_LBW (nolock)
|
||||||
|
WHERE BuchDatum BETWEEN '[startDate]' AND '[endDate]' ORDER BY BuchDatum DESC
|
||||||
|
`;
|
||||||
42
lstV2/server/services/sqlServer/querys/eom/purchased.ts
Normal file
42
lstV2/server/services/sqlServer/querys/eom/purchased.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
export const purchased = `
|
||||||
|
use AlplaPROD_test1
|
||||||
|
|
||||||
|
declare @start_date nvarchar(30) = '[startDate] '
|
||||||
|
declare @end_date nvarchar(30) = '[endDate] '
|
||||||
|
|
||||||
|
select T_Wareneingaenge.IdBestellung AS Purchase_order,
|
||||||
|
T_Adressen.IdAdressen,
|
||||||
|
T_Adressen.Bezeichnung,
|
||||||
|
T_Wareneingaenge.IdArtikelVarianten AS AV,
|
||||||
|
V_Artikel.Alias,
|
||||||
|
x.Bemerkung AS Remark,
|
||||||
|
T_Wareneingaenge.Bemerkung AS Purchase_Remark,
|
||||||
|
x.Add_User,
|
||||||
|
CONVERT(DATE, x.Add_Date) AS Received_Date,
|
||||||
|
x.IdWareneingangPlanung,
|
||||||
|
T_Wareneingaenge.SollMenge As Ordered_QTY,
|
||||||
|
x.EntladeMenge As Received_QTY,
|
||||||
|
case when T_Adressen.Bezeichnung LIKE '%Alpla%' Then 'AlplaPlant' Else 'Supplier' End AS
|
||||||
|
Supplier,
|
||||||
|
x.Typ as incoming_goods_type
|
||||||
|
from dbo.T_WareneingangPlanungen (nolock) as x
|
||||||
|
|
||||||
|
join
|
||||||
|
|
||||||
|
dbo.T_Wareneingaenge (nolock) on
|
||||||
|
x.IdWareneingang=
|
||||||
|
dbo.T_Wareneingaenge.IdWareneingang
|
||||||
|
join
|
||||||
|
dbo.V_Artikel (nolock) on
|
||||||
|
dbo.T_Wareneingaenge.IdArtikelVarianten=
|
||||||
|
dbo.V_Artikel.IdArtikelvarianten
|
||||||
|
|
||||||
|
join
|
||||||
|
dbo.T_Adressen (nolock) on dbo.T_Wareneingaenge.IdLieferantAdresse =
|
||||||
|
dbo.T_Adressen.IdAdressen
|
||||||
|
|
||||||
|
where x.add_date between @start_date + (select top(1) CONVERT(char(8), StartDate, 108) as startTime from [test1_AlplaPROD2.0_Read].masterData.ShiftDefinition (nolock) where TeamNumber = 1)
|
||||||
|
AND @end_date + (select top(1) CONVERT(char(8), StartDate, 108) as startTime from [test1_AlplaPROD2.0_Read].masterData.ShiftDefinition (nolock) where TeamNumber = 1)
|
||||||
|
|
||||||
|
order by x.add_date desc
|
||||||
|
`;
|
||||||
15
lstV2/server/services/sqlServer/querys/eom/regrind.ts
Normal file
15
lstV2/server/services/sqlServer/querys/eom/regrind.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
export const regrindCheck = `
|
||||||
|
select IdArtikelVarianten,
|
||||||
|
ArtikelVariantenAlias,
|
||||||
|
IdRezeptur,
|
||||||
|
Menge,
|
||||||
|
IdBuchungsGrund,
|
||||||
|
Buchungsdatum,
|
||||||
|
ProduktionsLos,
|
||||||
|
IdReinheit,
|
||||||
|
ReinheitBez, HerkunftBez
|
||||||
|
from alplaprod_test1.[dbo].[V_AbfallLagerBuchungen] (nolock)
|
||||||
|
where Buchungsdatum between '[startDate] ' + (select top(1) CONVERT(char(8), StartDate, 108) as startTime from [test1_AlplaPROD2.0_Read].masterData.ShiftDefinition (nolock) where TeamNumber = 1)
|
||||||
|
and '[endDate] ' + (select top(1) CONVERT(char(8), StartDate, 108) as startTime from [test1_AlplaPROD2.0_Read].masterData.ShiftDefinition (nolock) where TeamNumber = 1)
|
||||||
|
and IdBuchungsGrund in (140, 240) and BuchungsTyp = 1
|
||||||
|
`;
|
||||||
17
lstV2/server/services/sqlServer/querys/eom/soldOut.ts
Normal file
17
lstV2/server/services/sqlServer/querys/eom/soldOut.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
export const soldOutItems = `
|
||||||
|
|
||||||
|
select IdArtikelVarianten AS AV,
|
||||||
|
ArtikelVariantenAlias AS AVDescription,
|
||||||
|
convert(date,AbrufLadeDatum,23) As DeliveryDate,
|
||||||
|
idlieferadresse AS DeliveryAddress,
|
||||||
|
LieferAdressBez,
|
||||||
|
AuftragsNummer AS PO_Number,
|
||||||
|
IdAuftragsPosition AS LineITEM,
|
||||||
|
IdAuftragsAbruf AS ReleaseNumber,
|
||||||
|
AbrufMengeVPK AS PalletsRequested,
|
||||||
|
AbrufMenge AS PiecesRequested,
|
||||||
|
GelieferteMengeVPK AS DeliveredPallets,
|
||||||
|
GelieferteMenge AS DeliveredQTY,
|
||||||
|
case when LieferAdressBez Like '%alpla%' Then 'AlplaPlant' ELSE 'Customer' End as CustomerType
|
||||||
|
from alplaprod_test1.dbo.V_TrackerAuftragsAbrufe (nolock)
|
||||||
|
where AbrufLadeDatum between '[startDate]' and '[endDate]'`;
|
||||||
Reference in New Issue
Block a user