feat(logistics): get sscc based on runnning number
returns the sscc based on the running number more for support and testing the endpoints
This commit is contained in:
@@ -20,6 +20,7 @@ import { runHistoricalData } from "./controller/eom/historicalInv.js";
|
|||||||
import intervalChecks from "./route/getActiveLogistics.js";
|
import intervalChecks from "./route/getActiveLogistics.js";
|
||||||
import getActiveLanes from "./route/getActiveLanes.js";
|
import getActiveLanes from "./route/getActiveLanes.js";
|
||||||
import removeAsNonReable from "./route/removeAsNonReusable.js";
|
import removeAsNonReable from "./route/removeAsNonReusable.js";
|
||||||
|
import getSSCC from "./route/getSSCCNumber.js";
|
||||||
|
|
||||||
const app = new OpenAPIHono();
|
const app = new OpenAPIHono();
|
||||||
|
|
||||||
@@ -49,6 +50,7 @@ const routes = [
|
|||||||
|
|
||||||
// logisitcs
|
// logisitcs
|
||||||
removeAsNonReable,
|
removeAsNonReable,
|
||||||
|
getSSCC,
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
// app.route("/server", modules);
|
// app.route("/server", modules);
|
||||||
|
|||||||
76
server/services/logistics/route/getSSCCNumber.ts
Normal file
76
server/services/logistics/route/getSSCCNumber.ts
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||||
|
import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
||||||
|
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||||
|
import { getCycleCountCheck } from "../controller/warehouse/cycleCountChecks/getCycleCountCheck.js";
|
||||||
|
import { getPPOO } from "../controller/warehouse/ppoo/getPPOO.js";
|
||||||
|
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||||
|
import { createSSCC } from "../../../globalUtils/createSSCC.js";
|
||||||
|
|
||||||
|
const app = new OpenAPIHono();
|
||||||
|
|
||||||
|
// const Body = z
|
||||||
|
// .object({
|
||||||
|
// age: z.number().optional().openapi({ example: 90 }),
|
||||||
|
// //email: z.string().optional().openapi({example: "s.smith@example.com"}),
|
||||||
|
// type: z.string().optional().openapi({ example: "fg" }),
|
||||||
|
// })
|
||||||
|
// .openapi("User");
|
||||||
|
app.openapi(
|
||||||
|
createRoute({
|
||||||
|
tags: ["logistics"],
|
||||||
|
summary: "Returns returns sscc based on running number",
|
||||||
|
method: "post",
|
||||||
|
path: "/getsscc",
|
||||||
|
// request: {
|
||||||
|
// body: {
|
||||||
|
// content: {
|
||||||
|
// "application/json": { schema: Body },
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// description:
|
||||||
|
// "Provided a running number and lot number you can consume material.",
|
||||||
|
responses: responses(),
|
||||||
|
}),
|
||||||
|
async (c: any) => {
|
||||||
|
apiHit(c, { endpoint: "/getsscc" });
|
||||||
|
const { data, error: bodyError } = (await tryCatch(
|
||||||
|
c.req.json()
|
||||||
|
)) as any;
|
||||||
|
|
||||||
|
if (bodyError) {
|
||||||
|
return c.json({
|
||||||
|
success: false,
|
||||||
|
message: "Missing critical data.",
|
||||||
|
data: bodyError,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data.runningNr) {
|
||||||
|
return c.json({
|
||||||
|
success: false,
|
||||||
|
message: "Missing critical data.",
|
||||||
|
data: [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data: sscc, error } = await tryCatch(
|
||||||
|
createSSCC(data.runningNr)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return c.json({
|
||||||
|
success: false,
|
||||||
|
message: "Error creating sscc.",
|
||||||
|
data: error,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.json({
|
||||||
|
success: true,
|
||||||
|
message: "SSCC",
|
||||||
|
data: sscc,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
export default app;
|
||||||
Reference in New Issue
Block a user