feat(lstv2 move): moved lstv2 into this app to keep them combined and easier to maintain

This commit is contained in:
2025-09-19 22:22:05 -05:00
parent caf2315191
commit e4477402ad
847 changed files with 165801 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
import { runProdApi } from "../../../../globalUtils/runProdApi.js";
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
export const attachSilo = async (data: any) => {
/**
* Detachs a silo
*/
const detachData = {
endpoint: "/public/v1.0/IssueMaterial/AssignSiloToMachine",
data: [
{
laneId: data.laneId,
machineId: data.machineId,
productionLotId: data.productionLotId,
},
],
};
const { data: d, error } = await tryCatch(runProdApi(detachData));
if (error) {
return {
success: false,
message: "Error processing attachingSilo data",
data: error,
};
}
if (!d.success) {
return {
success: false,
message: "Error processing silo attach data",
data: d.message,
};
}
return {
success: true,
message: "silo attach was completed",
data: d.data,
};
};

View File

@@ -0,0 +1,42 @@
import { runProdApi } from "../../../../globalUtils/runProdApi.js";
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
export const detachSilo = async (data: any) => {
/**
* Detachs a silo
*/
const detachData = {
endpoint: "/public/v1.0/IssueMaterial/DetachSiloFromMachine",
data: [
{
laneId: data.laneId,
machineId: data.machineId,
},
],
};
const { data: d, error } = await tryCatch(runProdApi(detachData));
if (error) {
return {
success: false,
message: "Error processing detach data",
data: error,
};
}
if (!d.success) {
return {
success: false,
message: "Error processing detach data",
data: d.message,
};
}
return {
success: true,
message: "Detach was completed",
data: d.data,
};
};

View File

@@ -0,0 +1,63 @@
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
import { createLog } from "../../../logger/logger.js";
import { query } from "../../../sqlServer/prodSqlServer.js";
import {
connectedToMachine,
notconnectedToMachine,
} from "../../../sqlServer/querys/silo/connectionCheck.js";
type Data = {
siloID: string;
connectionType: string;
};
export const siloConnectionType = async (data: Data) => {
/**
* Will return the machines that are attached or detached based on the silo and connection type
*/
if (!data) {
return {
success: false,
message: "Missing mandatory data",
data: [{ error: "Missing siloId or ConnectionType" }],
};
}
// change the silo id to the correct one
let newQuery = "";
if (data.connectionType === "connected") {
newQuery = connectedToMachine.replace("[siloID]", data.siloID);
} else {
newQuery = notconnectedToMachine.replace("[siloID]", data.siloID);
}
/**
* get the silo data
*/
const { data: s, error } = (await tryCatch(
query(newQuery, "Silo connection check")
)) as any;
if (error) {
createLog(
"error",
"lst",
"logistics",
`There was an error getting the silo connection data: ${JSON.stringify(
error
)}`
);
return {
success: false,
message: "There was an error getting the silo connection data.",
data: error,
};
}
return {
success: true,
message: `silo ${data.connectionType} data`,
data: s.data,
};
};