test(ocme): shipment pallets
This commit is contained in:
@@ -3,9 +3,13 @@ import {OpenAPIHono} from "@hono/zod-openapi";
|
||||
// routes
|
||||
import getInfo from "./route/getInfo.js";
|
||||
import postRunningNr from "./route/postRunningNumber.js";
|
||||
import pickedup from "./route/pickedUp.js";
|
||||
import postsscc from "./route/postSSCC.js";
|
||||
import getShipments from "./route/getShipmentPallets.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
const routes = [getInfo, postRunningNr] as const;
|
||||
const routes = [getInfo, postRunningNr, postsscc, pickedup, getShipments] as const;
|
||||
|
||||
// app.route("/server", modules);
|
||||
const appRoutes = routes.forEach((route) => {
|
||||
|
||||
83
server/services/ocme/route/getShipmentPallets.ts
Normal file
83
server/services/ocme/route/getShipmentPallets.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import {createRoute, OpenAPIHono, z} from "@hono/zod-openapi";
|
||||
import {apiHit} from "../../../globalUtils/apiHits.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
const ShipmentID = z.object({
|
||||
shipmentID: z.string().optional().openapi({example: "14558"}),
|
||||
});
|
||||
|
||||
app.openapi(
|
||||
createRoute({
|
||||
tags: ["ocme"],
|
||||
summary: "Post New running number to be picked up.",
|
||||
method: "post",
|
||||
path: "/getshipmentpallets",
|
||||
request: {
|
||||
body: {
|
||||
content: {
|
||||
"application/json": {schema: ShipmentID},
|
||||
},
|
||||
},
|
||||
},
|
||||
responses: {
|
||||
200: {
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: z.object({
|
||||
success: z.boolean().openapi({example: true}),
|
||||
message: z.string().openapi({example: "Starter"}),
|
||||
// data: z
|
||||
// .array(z.object({sscc: z.string().optional()}))
|
||||
// .optional()
|
||||
// .openapi({example: []}),
|
||||
}),
|
||||
},
|
||||
},
|
||||
description: "Response message",
|
||||
},
|
||||
400: {
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: z.object({
|
||||
success: z.boolean().openapi({example: false}),
|
||||
message: z.string().optional().openapi({example: "Internal Server error"}),
|
||||
data: z.array(z.object({})).optional().openapi({example: []}),
|
||||
}),
|
||||
},
|
||||
},
|
||||
description: "Internal Server Error",
|
||||
},
|
||||
// 401: {
|
||||
// content: {
|
||||
// "application/json": {
|
||||
// schema: z.object({message: z.string().optional().openapi({example: "Unauthenticated"})}),
|
||||
// },
|
||||
// },
|
||||
// description: "Unauthorized",
|
||||
// },
|
||||
// 500: {
|
||||
// content: {
|
||||
// "application/json": {
|
||||
// schema: z.object({message: z.string().optional().openapi({example: "Internal Server error"})}),
|
||||
// },
|
||||
// },
|
||||
// description: "Internal Server Error",
|
||||
// },
|
||||
},
|
||||
}),
|
||||
async (c) => {
|
||||
// make sure we have a vaid user being accessed thats really logged in
|
||||
try {
|
||||
const data = await c.req.json();
|
||||
apiHit(c, {endpoint: "api/ocme/getshipmentpallets", lastBody: data});
|
||||
|
||||
const postPallet = {success: true, message: "Something", data: []};
|
||||
|
||||
return c.json({success: postPallet.success, message: postPallet.message, data: postPallet.data ?? []}, 200);
|
||||
} catch (error) {
|
||||
return c.json({success: false, message: "There was an error getting the shipment data.", data: error}, 400);
|
||||
}
|
||||
}
|
||||
);
|
||||
export default app;
|
||||
16
server/services/sqlServer/querys/ocme/shipmentPallets.ts
Normal file
16
server/services/sqlServer/querys/ocme/shipmentPallets.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export const shipmentPallets = `
|
||||
select TOP([totalPallets]) IdLagerAbteilung as laneId,
|
||||
LagerAbteilungKurzBez as lane,
|
||||
Produktionslos as lotNum,
|
||||
lfdnr as runningNumber,
|
||||
IdAdresse as addressID,
|
||||
BewegungsDatumMax as lastMove, IdArtikelVarianten as article
|
||||
from AlplaPROD_test1.dbo.V_LagerPositionenBarcodes (nolock)
|
||||
where IdArtikelVarianten = [article]
|
||||
and LagerAbteilungKurzBez in ([lanes])
|
||||
and GesperrtAktivSum in (0)
|
||||
order by CASE
|
||||
WHEN BewegungsDatumMax <= DATEADD(DAY, -[fifo], GETDATE()) THEN 0
|
||||
ELSE 1
|
||||
END desc
|
||||
`;
|
||||
Reference in New Issue
Block a user