Compare commits
6 Commits
5013228384
...
2b5e77993b
| Author | SHA1 | Date | |
|---|---|---|---|
| 2b5e77993b | |||
| 6efaffbb17 | |||
| 90ddbca2e7 | |||
| 7a9ea16f48 | |||
| 420826de9b | |||
| dc2d3718fa |
@@ -207,7 +207,7 @@ export default function TransferToNextLot() {
|
|||||||
<span>"EOM Transfer"</span>
|
<span>"EOM Transfer"</span>
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<TooltipTrigger>
|
<TooltipTrigger>
|
||||||
<Info className="h-[16px] w-[16px]" />
|
<Info className="h-4 w-4" />
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
<TooltipContent>
|
<TooltipContent>
|
||||||
<p>
|
<p>
|
||||||
@@ -223,7 +223,7 @@ export default function TransferToNextLot() {
|
|||||||
<span>"Lot Transfer"</span>
|
<span>"Lot Transfer"</span>
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<TooltipTrigger>
|
<TooltipTrigger>
|
||||||
<Info className="h-[16px] w-[16px]" />
|
<Info className="h-4 w-4" />
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
<TooltipContent>
|
<TooltipContent>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
export const abbottForecast = async () => {};
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
|
import { addDays } from "date-fns";
|
||||||
|
import XLSX from "xlsx";
|
||||||
import { db } from "../../../../../../../database/dbclient.js";
|
import { db } from "../../../../../../../database/dbclient.js";
|
||||||
import { settings } from "../../../../../../../database/schema/settings.js";
|
import { settings } from "../../../../../../../database/schema/settings.js";
|
||||||
import { tryCatch } from "../../../../../../globalUtils/tryCatch.js";
|
import { tryCatch } from "../../../../../../globalUtils/tryCatch.js";
|
||||||
import XLSX from "xlsx";
|
import { createLog } from "../../../../../logger/logger.js";
|
||||||
import { postForecast } from "../postForecast.js";
|
import { sendEmail } from "../../../../../notifications/controller/sendMail.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";
|
||||||
import { addDays } from "date-fns";
|
import { excelDateStuff } from "../../../../utils/excelDateStuff.js";
|
||||||
import { sendEmail } from "../../../../../notifications/controller/sendMail.js";
|
import { postForecast } from "../postForecast.js";
|
||||||
import { createLog } from "../../../../../logger/logger.js";
|
|
||||||
|
|
||||||
export const energizerForecast = async (data: any, user: any) => {
|
export const energizerForecast = async (data: any, user: any) => {
|
||||||
/**
|
/**
|
||||||
@@ -55,23 +56,29 @@ export const energizerForecast = async (data: any, user: any) => {
|
|||||||
for (let j = 1; j < row.length; j++) {
|
for (let j = 1; j < row.length; j++) {
|
||||||
const qty = row[j];
|
const qty = row[j];
|
||||||
|
|
||||||
if (qty && qty !== 0) {
|
if (qty && qty > 0) {
|
||||||
const requirementDate = rows[0][j]; // first row is dates
|
const requirementDate = rows[0][j]; // first row is dates
|
||||||
|
const date = isNaN(requirementDate)
|
||||||
|
? new Date(requirementDate)
|
||||||
|
: excelDateStuff(requirementDate);
|
||||||
|
|
||||||
|
console.log(isNaN(requirementDate), requirementDate, date);
|
||||||
posting.push({
|
posting.push({
|
||||||
customerArticleNo: material,
|
customerArticleNo: material,
|
||||||
quantity: qty,
|
quantity: qty,
|
||||||
requirementDate: new Date(requirementDate),
|
requirementDate: date,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//console.log(posting);
|
||||||
|
|
||||||
// the predefined data that will never change
|
// the predefined data that will never change
|
||||||
const predefinedObject = {
|
const predefinedObject = {
|
||||||
receivingPlantId: plantToken[0].value,
|
receivingPlantId: plantToken[0].value,
|
||||||
documentName: `ForecastFromLST-${new Date(Date.now()).toLocaleString(
|
documentName: `ForecastFromLST-${new Date(Date.now()).toLocaleString(
|
||||||
"en-US"
|
"en-US",
|
||||||
)}`,
|
)}`,
|
||||||
sender: user.username || "lst-system",
|
sender: user.username || "lst-system",
|
||||||
customerId: customerId,
|
customerId: customerId,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import XLSX from "xlsx";
|
import XLSX from "xlsx";
|
||||||
import { tryCatch } from "../../../../../../globalUtils/tryCatch.js";
|
|
||||||
import { db } from "../../../../../../../database/dbclient.js";
|
import { db } from "../../../../../../../database/dbclient.js";
|
||||||
import { settings } from "../../../../../../../database/schema/settings.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 { invoiceAddress } from "../../../../../sqlServer/querys/dm/invoiceAddress.js";
|
||||||
import { orderState } from "../../../../../sqlServer/querys/dm/orderState.js";
|
import { orderState } from "../../../../../sqlServer/querys/dm/orderState.js";
|
||||||
import { excelDateStuff } from "../../../../utils/excelDateStuff.js";
|
import { excelDateStuff } from "../../../../utils/excelDateStuff.js";
|
||||||
import { invoiceAddress } from "../../../../../sqlServer/querys/dm/invoiceAddress.js";
|
|
||||||
import { postOrders } from "../postOrders.js";
|
import { postOrders } from "../postOrders.js";
|
||||||
|
|
||||||
export const energizerOrders = async (data: any, user: any) => {
|
export const energizerOrders = async (data: any, user: any) => {
|
||||||
@@ -25,7 +25,7 @@ export const energizerOrders = async (data: any, user: any) => {
|
|||||||
|
|
||||||
// order state
|
// order state
|
||||||
const { data: o, error: oe } = await tryCatch(
|
const { data: o, error: oe } = await tryCatch(
|
||||||
query(orderState, "Gets the next 500 orders that have not been started")
|
query(orderState, "Gets the next 500 orders that have not been started"),
|
||||||
);
|
);
|
||||||
|
|
||||||
const openOrders: any = o?.data;
|
const openOrders: any = o?.data;
|
||||||
@@ -40,7 +40,7 @@ export const energizerOrders = async (data: any, user: any) => {
|
|||||||
|
|
||||||
// order state
|
// order state
|
||||||
const { data: invoice, error: ie } = await tryCatch(
|
const { data: invoice, error: ie } = await tryCatch(
|
||||||
query(invoiceAddress, "Gets invoices addresses")
|
query(invoiceAddress, "Gets invoices addresses"),
|
||||||
);
|
);
|
||||||
const i: any = invoice?.data;
|
const i: any = invoice?.data;
|
||||||
|
|
||||||
@@ -83,11 +83,11 @@ export const energizerOrders = async (data: any, user: any) => {
|
|||||||
const predefinedObject = {
|
const predefinedObject = {
|
||||||
receivingPlantId: plantToken[0].value,
|
receivingPlantId: plantToken[0].value,
|
||||||
documentName: `OrdersFromLST-${new Date(Date.now()).toLocaleString(
|
documentName: `OrdersFromLST-${new Date(Date.now()).toLocaleString(
|
||||||
"en-US"
|
"en-US",
|
||||||
)}`,
|
)}`,
|
||||||
sender: user.username || "lst-system",
|
sender: user.username || "lst-system",
|
||||||
externalRefNo: `OrdersFromLST-${new Date(Date.now()).toLocaleString(
|
externalRefNo: `OrdersFromLST-${new Date(Date.now()).toLocaleString(
|
||||||
"en-US"
|
"en-US",
|
||||||
)}`,
|
)}`,
|
||||||
orders: [],
|
orders: [],
|
||||||
};
|
};
|
||||||
@@ -97,8 +97,8 @@ export const energizerOrders = async (data: any, user: any) => {
|
|||||||
// filter out the orders that have already been started just to reduce the risk of errors.
|
// filter out the orders that have already been started just to reduce the risk of errors.
|
||||||
newOrders.filter((oo: any) =>
|
newOrders.filter((oo: any) =>
|
||||||
openOrders.some(
|
openOrders.some(
|
||||||
(o: any) => o.CustomerOrderNumber === oo.CustomerOrderNumber
|
(o: any) => o.CustomerOrderNumber === oo.CustomerOrderNumber,
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// filter out the blanks
|
// filter out the blanks
|
||||||
@@ -119,7 +119,7 @@ export const energizerOrders = async (data: any, user: any) => {
|
|||||||
// // map everything out for each order
|
// // map everything out for each order
|
||||||
const nOrder = newOrders.map((o: any) => {
|
const nOrder = newOrders.map((o: any) => {
|
||||||
const invoice = i.filter(
|
const invoice = i.filter(
|
||||||
(i: any) => i.deliveryAddress === parseInt(o.CUSTOMERID)
|
(i: any) => i.deliveryAddress === parseInt(o.CUSTOMERID),
|
||||||
);
|
);
|
||||||
if (!invoice) {
|
if (!invoice) {
|
||||||
return;
|
return;
|
||||||
@@ -137,7 +137,7 @@ export const energizerOrders = async (data: any, user: any) => {
|
|||||||
deliveryDate: o.DELDATE, //excelDateStuff(o.DELDATE),
|
deliveryDate: o.DELDATE, //excelDateStuff(o.DELDATE),
|
||||||
customerLineItemNo: o.ReleaseNo, // this is how it is currently sent over from abbott
|
customerLineItemNo: o.ReleaseNo, // this is how it is currently sent over from abbott
|
||||||
customerReleaseNo: o.ReleaseNo, // same as above
|
customerReleaseNo: o.ReleaseNo, // same as above
|
||||||
remark: o.remark === "" ? null : o.remark,
|
remark: o.COMMENTS === "" ? null : o.COMMENTS,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export const printerDelayByLot = async (lot: any) => {
|
|||||||
})
|
})
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
eq(printerData.humanReadableId, lot[i].printerID),
|
eq(printerData.humanReadableId, lot[i]?.printerID),
|
||||||
eq(printerData.printDelayOverride, false),
|
eq(printerData.printDelayOverride, false),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -46,9 +46,17 @@ app.openapi(
|
|||||||
return c.json({ success: false, message: "missing data" }, 400);
|
return c.json({ success: false, message: "missing data" }, 400);
|
||||||
}
|
}
|
||||||
//console.log(`Tag: ${Buffer.from(body.idHex, "hex").toString("utf-8")}, ${body[key].data.idHex}`);
|
//console.log(`Tag: ${Buffer.from(body.idHex, "hex").toString("utf-8")}, ${body[key].data.idHex}`);
|
||||||
|
createLog(
|
||||||
|
"info",
|
||||||
|
"rfid-tag",
|
||||||
|
"rfid",
|
||||||
|
`Tag Data from ${reader}: ${JSON.stringify(body)}`,
|
||||||
|
);
|
||||||
|
|
||||||
for (let i = 0; i < body.length; i++) {
|
for (let i = 0; i < body.length; i++) {
|
||||||
const tag = Buffer.from(body[i].data.idHex, "hex").toString("utf-8");
|
const tag = Buffer.from(body[i].data.idHex, "hex")
|
||||||
|
.toString("utf-8")
|
||||||
|
.replace("\x00\x00", "");
|
||||||
// console.log(
|
// console.log(
|
||||||
// "Raw value:",
|
// "Raw value:",
|
||||||
// body[i].data.peakRssi,
|
// body[i].data.peakRssi,
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
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
|
|
||||||
`;
|
|
||||||
Reference in New Issue
Block a user