feat(eom): all endpoints created for the eom template to run in all plants
This commit is contained in:
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) => {
|
||||
//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: "/lastpurchprice" });
|
||||
try {
|
||||
const res = await lastPurchase();
|
||||
const res = await lastPurchase(
|
||||
q["includePlantToken"] ? true : false
|
||||
);
|
||||
|
||||
return c.json(
|
||||
{ success: res.success, message: res.message, data: res.data },
|
||||
|
||||
@@ -17,12 +17,14 @@ app.openapi(
|
||||
}),
|
||||
async (c) => {
|
||||
//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
|
||||
|
||||
const q: any = c.req.queries();
|
||||
apiHit(c, { endpoint: "/lastsalesprice" });
|
||||
try {
|
||||
const res = await lastSales(month);
|
||||
const res = await lastSales(
|
||||
q["month"] ? q["month"][0] : null,
|
||||
q["includePlantToken"] ? true : false
|
||||
);
|
||||
|
||||
return c.json(
|
||||
{ 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) => {
|
||||
//const body = await c.req.json();
|
||||
// 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" });
|
||||
try {
|
||||
const res = await historicalInvByDate(month);
|
||||
const res = await historicalInvByDate(
|
||||
q["month"] ? q["month"][0] : null,
|
||||
q["includePlantToken"] ? true : false
|
||||
);
|
||||
|
||||
return c.json(
|
||||
{ success: res.success, message: res.message, data: res.data },
|
||||
|
||||
Reference in New Issue
Block a user