feat(lstv2 move): moved lstv2 into this app to keep them combined and easier to maintain
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { query } from "../../../sqlServer/prodSqlServer.js";
|
||||
import { alplaStock } from "../../../sqlServer/querys/ocme/alplaStockInvByID.js";
|
||||
|
||||
export const alplaStockInv = async (laneID: string) => {
|
||||
/**
|
||||
* We will get the stock data based on the lane id passed over
|
||||
*/
|
||||
|
||||
const stock = alplaStock.replaceAll("[laneID]", `${laneID}`);
|
||||
|
||||
try {
|
||||
const stockData: any = await query(stock, "Stock Data");
|
||||
return stockData.data;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,91 @@
|
||||
import axios from "axios";
|
||||
import {closeLane, openLane, prepareLane, releaseLane, scannerID} from "../cycleCount.js";
|
||||
import {createLog} from "../../../logger/logger.js";
|
||||
import type {User} from "../../../../types/users.js";
|
||||
|
||||
export const emptyCount = async (user: User, lane: string) => {
|
||||
try {
|
||||
const openlane = await axios({
|
||||
method: "POST",
|
||||
url: prepareLane,
|
||||
headers: {
|
||||
Authorization: `Basic ${user.prod}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
data: {
|
||||
scannerId: scannerID,
|
||||
laneId: lane,
|
||||
},
|
||||
});
|
||||
|
||||
createLog("info", user.username!, "ocme-count", openlane.data.message);
|
||||
|
||||
// start the empty inventory process
|
||||
if (openlane.data.result === 0) {
|
||||
try {
|
||||
const open = await axios({
|
||||
method: "POST",
|
||||
url: openLane,
|
||||
headers: {
|
||||
Authorization: `Basic ${user.prod}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
data: {
|
||||
scannerId: scannerID,
|
||||
laneId: lane,
|
||||
},
|
||||
});
|
||||
|
||||
createLog("info", user.username!, "ocme-count", openlane.data.message);
|
||||
|
||||
if (open.data.Result === 0) {
|
||||
//consider the lane empty and close it
|
||||
try {
|
||||
const closelane = await axios({
|
||||
method: "POST",
|
||||
url: closeLane,
|
||||
headers: {
|
||||
Authorization: `Basic ${user.prod}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
data: {
|
||||
scannerId: scannerID,
|
||||
laneId: lane,
|
||||
},
|
||||
});
|
||||
|
||||
createLog("info", user.username!, "ocme-count", openlane.data.message);
|
||||
|
||||
if (closelane.data.Result === 0) {
|
||||
//release the lane
|
||||
//----------------------------------------------------
|
||||
try {
|
||||
const close = await axios({
|
||||
method: "POST",
|
||||
url: releaseLane,
|
||||
headers: {
|
||||
Authorization: `Basic ${user.prod}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
data: {
|
||||
laneId: lane,
|
||||
},
|
||||
});
|
||||
|
||||
createLog("info", user.username!, "ocme-count", close.data.message);
|
||||
} catch (error) {
|
||||
createLog("error", user.username!, "ocme-count", "Releasing the lane");
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
createLog("error", user.username!, "ocme-count", "Closing the lane");
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
createLog("error", user.username!, "ocme-count", "Opening the lane");
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
createLog("error", user.username!, "ocme-count", "Preparing the lane");
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,142 @@
|
||||
// full lane count
|
||||
import axios from "axios";
|
||||
import { delay } from "../../../../globalUtils/delay.js";
|
||||
import { createLog } from "../../../logger/logger.js";
|
||||
import { openLane, prepareLane, scannerID } from "../cycleCount.js";
|
||||
import type { User } from "../../../../types/users.js";
|
||||
import { prodEndpointCreation } from "../../../../globalUtils/createUrl.js";
|
||||
|
||||
let delayTime = 100;
|
||||
|
||||
export const fullLaneCount = async (
|
||||
user: User,
|
||||
lane: string,
|
||||
ocmeLanes: any
|
||||
) => {
|
||||
// prepare the lane.
|
||||
try {
|
||||
const openlane = await axios({
|
||||
method: "POST",
|
||||
url: prepareLane,
|
||||
headers: {
|
||||
Authorization: `Basic ${user.prod}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
data: {
|
||||
scannerId: scannerID,
|
||||
laneId: lane,
|
||||
},
|
||||
});
|
||||
|
||||
createLog("info", user.username!, "ocme-count", openlane.data.message);
|
||||
try {
|
||||
const open = await axios({
|
||||
method: "POST",
|
||||
url: openLane,
|
||||
headers: {
|
||||
Authorization: `Basic ${user.prod}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
data: {
|
||||
scannerId: scannerID,
|
||||
laneId: lane,
|
||||
},
|
||||
});
|
||||
|
||||
createLog("info", user.username!, "ocme-count", open.data.Message);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
// do the inv
|
||||
|
||||
for (let i = 0; i < ocmeLanes.length; i++) {
|
||||
const count = {
|
||||
scannerId: scannerID,
|
||||
sscc: ocmeLanes[i].sscc,
|
||||
};
|
||||
//createLog("cyclecounting", "info", `Processing running: ${ocmeLanes[i].runningNumber}`);
|
||||
await delay(delayTime);
|
||||
|
||||
try {
|
||||
const openLane = await axios({
|
||||
method: "POST",
|
||||
url: await prodEndpointCreation(
|
||||
"/public/v1.0/Warehousing/InventoryCount"
|
||||
),
|
||||
headers: {
|
||||
Authorization: `Basic ${user.prod}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
data: count,
|
||||
});
|
||||
|
||||
createLog(
|
||||
"info",
|
||||
user.username!,
|
||||
"ocme-count",
|
||||
`${openLane.data.Message} on running: ${ocmeLanes[i].runningNumber}`
|
||||
);
|
||||
await delay(delayTime);
|
||||
} catch (error) {
|
||||
createLog("error", user.username!, "ocme-count", `${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
// close the count
|
||||
// close the order
|
||||
try {
|
||||
const openLane = await axios({
|
||||
method: "POST",
|
||||
url: await prodEndpointCreation(
|
||||
"/public/v1.0/Warehousing/InventoryClose"
|
||||
),
|
||||
headers: {
|
||||
Authorization: `Basic ${user.prod}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
data: {
|
||||
scannerId: scannerID,
|
||||
laneId: lane,
|
||||
},
|
||||
});
|
||||
|
||||
createLog("info", user.username!, "ocme-count", openLane.data.Message);
|
||||
|
||||
if (openLane.data.Result === 0) {
|
||||
//release the lane
|
||||
//----------------------------------------------------
|
||||
try {
|
||||
const openLane = await axios({
|
||||
method: "POST",
|
||||
url: await prodEndpointCreation(
|
||||
"/public/v1.1/Warehousing/ReleaseLaneFromInventory"
|
||||
),
|
||||
headers: {
|
||||
Authorization: `Basic ${user.prod}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
data: {
|
||||
laneId: lane,
|
||||
},
|
||||
});
|
||||
|
||||
createLog(
|
||||
"info",
|
||||
user.username!,
|
||||
"ocme-count",
|
||||
openLane.data.message
|
||||
);
|
||||
} catch (error) {
|
||||
createLog("error", user.username!, "ocme-count", `${error}`);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
createLog("error", user.username!, "ocme-count", `${error}`);
|
||||
}
|
||||
|
||||
return { success: true, message: `Lane completed` };
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
import axios from "axios";
|
||||
|
||||
export const ocmeInv = async (data: any) => {
|
||||
try {
|
||||
const res = await axios.post(
|
||||
"http://usday1vms010:3250/api/v1/getlanedata",
|
||||
{ lane: data.lane, laneType: data.laneType },
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Connection: "keep-alive",
|
||||
},
|
||||
}
|
||||
);
|
||||
// console.log(res.data.data);
|
||||
|
||||
return res.data.data;
|
||||
} catch (error: any) {
|
||||
console.log(error.code);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user