feat(ocp): add lots with scroll view was added
This commit is contained in:
23
server/services/ocp/controller/lots/lots.ts
Normal file
23
server/services/ocp/controller/lots/lots.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { query } from "../../../sqlServer/prodSqlServer.js";
|
||||
import { lotQuery } from "../../../sqlServer/querys/ocp/lots.js";
|
||||
|
||||
export const getLots = async () => {
|
||||
const { data: lotInfo, error: lotError } = await tryCatch(
|
||||
query(lotQuery, "Alplalabel online lots")
|
||||
);
|
||||
|
||||
if (lotError) {
|
||||
return {
|
||||
success: false,
|
||||
message: "There was an error getting the lots",
|
||||
data: lotError,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Current active lots that are technically released.",
|
||||
data: lotInfo,
|
||||
};
|
||||
};
|
||||
@@ -6,7 +6,8 @@ import getPrinters from "./routes/printers/getPritners.js";
|
||||
import { db } from "../../../database/dbclient.js";
|
||||
import { settings } from "../../../database/schema/settings.js";
|
||||
import updateprinters from "./routes/printers/updatePrinters.js";
|
||||
import { updatePrinters } from "./controller/updatePrinters.js";
|
||||
import { updatePrinters } from "./controller/printers/updatePrinters.js";
|
||||
import getLots from "./routes/lots/getLots.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
@@ -15,6 +16,8 @@ const routes = [
|
||||
//printer
|
||||
getPrinters,
|
||||
updateprinters,
|
||||
// lots
|
||||
getLots,
|
||||
] as const;
|
||||
const setting = await db.select().from(settings);
|
||||
|
||||
|
||||
35
server/services/ocp/routes/lots/getLots.ts
Normal file
35
server/services/ocp/routes/lots/getLots.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
// an external way to creating logs
|
||||
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||
import { responses } from "../../../../globalUtils/routeDefs/responses.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { getPrinters } from "../../controller/printers/getPrinters.js";
|
||||
import { getLots } from "../../controller/lots/lots.js";
|
||||
|
||||
const app = new OpenAPIHono({ strict: false });
|
||||
|
||||
app.openapi(
|
||||
createRoute({
|
||||
tags: ["ocp"],
|
||||
summary: "Returns current active lots that are tech released",
|
||||
method: "get",
|
||||
path: "/getlots",
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c) => {
|
||||
const { data: lotData, error: lotError } = await tryCatch(getLots());
|
||||
|
||||
if (lotError) {
|
||||
return c.json({
|
||||
success: false,
|
||||
message: "There was an error getting the printers",
|
||||
});
|
||||
}
|
||||
|
||||
return c.json({
|
||||
success: lotData.success,
|
||||
message: lotData.message,
|
||||
data: lotData.data,
|
||||
});
|
||||
}
|
||||
);
|
||||
export default app;
|
||||
55
server/services/sqlServer/querys/ocp/lots.ts
Normal file
55
server/services/sqlServer/querys/ocp/lots.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
export const lotQuery = `
|
||||
select IdMaschinen_ProdPlanung as LabelOnlineID,
|
||||
IdMaschine as machineID,
|
||||
MaschinenStandort as MachineLocation,
|
||||
MaschinenBez as MachineDescription,
|
||||
IdProdPlanung as LOT,
|
||||
prolink.lot as ProlinkLot,
|
||||
IdArtikelvarianten as AV,
|
||||
ArtikelVariantenBez as Alias,
|
||||
convert(varchar, add_date, 20) as Add_Date,
|
||||
Add_user,
|
||||
idEtikettenDrucker as printerID,
|
||||
b.name as PrinterName,
|
||||
CAST(TotalPlannedLoadingUnits as float) as PlannedQTY,
|
||||
CAST(TotalProducedLoadingUnits as float) as Produced,
|
||||
ROUND(CAST(TotalPlannedLoadingUnits as float) - CAST(TotalProducedLoadingUnits as float),2) as Remaining,
|
||||
case
|
||||
-- checks if someone changed the criteria to something else to trigger the over run
|
||||
when x.ProzentReserveAnzahlPaletten > 0 then 'yes'
|
||||
|
||||
-- if the lot has a decimal in it to allow over running with no intervention
|
||||
when CAST(TotalPlannedLoadingUnits as float) - floor(CAST(TotalPlannedLoadingUnits as float)) > 0 then 'yes'
|
||||
else 'no' end as overPrinting,
|
||||
CustomerHumanReadableId as CustomerId,
|
||||
CustomerName as CustomerName,
|
||||
idMaschine as MachineID,
|
||||
prolink.lastProlinkUpdate as lastProlinkUpdate,
|
||||
IdEtikettenLayoutPalette as palletLabel,
|
||||
AnzahlKopienPalette as pallerCopies,
|
||||
IdEtikettenLayoutKarton as cartonLabel,
|
||||
AnzahlKopienKarton as cartonCopies,
|
||||
IsTechnicallyReleased
|
||||
--*
|
||||
from AlplaPROD_test1.dbo.V_Maschinen_ProdPlanungen x (nolock)
|
||||
join
|
||||
[test1_AlplaPROD2.0_Read].[productionControlling].[ProducedLot] on
|
||||
x.IdProdPlanung =
|
||||
[test1_AlplaPROD2.0_Read].[productionControlling].[ProducedLot].ProductionLotHumanReadableId
|
||||
left join
|
||||
[test1_AlplaPROD2.0_Read].masterData.Printer as b on
|
||||
x.IdEtikettenDrucker = b.HumanReadableId
|
||||
-- adding in prolink lot
|
||||
left join
|
||||
(SELECT * from (SELECT IdMaschine as prolinkMachineId,
|
||||
Produktionslos as lot,
|
||||
Upd_Date as lastProlinkUpdate,
|
||||
ROW_NUMBER() OVER (PARTITION BY IdMaschine ORDER BY Upd_Date DESC) RN_Prolink
|
||||
FROM AlplaPROD_test1.dbo.T_HistoryProduktionsdaten (nolock)
|
||||
WHERE Upd_Date BETWEEN DATEADD(DD, - 300, getdate()) AND DATEADD(DD, 1, getdate())) p
|
||||
WHERE RN_Prolink = 1
|
||||
) as prolink on
|
||||
x.idMaschine = prolink.prolinkMachineId
|
||||
|
||||
where IsTechnicallyReleased = 1
|
||||
`;
|
||||
Reference in New Issue
Block a user