helper scripts
This commit is contained in:
88
scripts/FinanceProcess/consumePalletsToLot copy.mjs
Normal file
88
scripts/FinanceProcess/consumePalletsToLot copy.mjs
Normal file
@@ -0,0 +1,88 @@
|
||||
import net from "net";
|
||||
|
||||
/**
|
||||
* This uses a kinda fake scanner to mimic the scanning process to a server and creates the bol.
|
||||
*/
|
||||
const scannerID = "98@";
|
||||
const scannerCommand = "Alplaprodcmd112"; // to consume all the pallets
|
||||
const lot = "AlplaPRODchg#00000016706"; // to consume to the lot make sure its showing in 2.0 to be able to consume to it
|
||||
|
||||
const labels = [
|
||||
"1000000000000000000000000000000005106656",
|
||||
"1000000000000000000000000000000005106386",
|
||||
"1000000000000000000000000000000005106446",
|
||||
"1000000000000000000000000000000005106326",
|
||||
"1000000000000000000000000000000005105726",
|
||||
"1000000000000000000000000000000005106056",
|
||||
"1000000000000000000000000000000005106256",
|
||||
"1000000000000000000000000000000005105836",
|
||||
"1000000000000000000000000000000005105986",
|
||||
"1000000000000000000000000000000005105506",
|
||||
"1000000000000000000000000000000005106136",
|
||||
"1000000000000000000000000000000005105696",
|
||||
"1000000000000000000000000000000005105426",
|
||||
"1000000000000000000000000000000005105916",
|
||||
"1000000000000000000000000000000005105216",
|
||||
"1000000000000000000000000000000005105416",
|
||||
"1000000000000000000000000000000005105196",
|
||||
"1000000000000000000000000000000005105226",
|
||||
"1000000000000000000000000000000005105816",
|
||||
"1000000000000000000000000000000005110186",
|
||||
"1000000000000000000000000000000005110256",
|
||||
"1000000000000000000000000000000005109926",
|
||||
"1000000000000000000000000000000005110096",
|
||||
"1000000000000000000000000000000005110026",
|
||||
"1000000000000000000000000000000005110036",
|
||||
"1000000000000000000000000000000005109716",
|
||||
"1000000000000000000000000000000005110006",
|
||||
"1000000000000000000000000000000005109446",
|
||||
"1000000000000000000000000000000005109606",
|
||||
"1000000000000000000000000000000005109076",
|
||||
];
|
||||
const STX = "\x02";
|
||||
const ETX = "\x03";
|
||||
|
||||
const scanner = new net.Socket();
|
||||
|
||||
scanner.connect(50000, "10.204.0.26", async () => {
|
||||
console.log("Connected to scanner");
|
||||
|
||||
// change the scanner to the to 112
|
||||
let message = Buffer.from(
|
||||
`${STX}${scannerID}${scannerCommand}${ETX}`,
|
||||
"ascii",
|
||||
);
|
||||
console.log("Sending:", message.toString("ascii"));
|
||||
scanner.write(message);
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000));
|
||||
|
||||
// consume all the pallets in the array
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000));
|
||||
for (let i = 0; i < labels.length; i++) {
|
||||
const l = labels[i];
|
||||
// trigger the lot
|
||||
let message = Buffer.from(`${STX}${scannerID}${lot}${ETX}`, "ascii");
|
||||
console.log("Sending:", message.toString("ascii"));
|
||||
scanner.write(message);
|
||||
|
||||
message = Buffer.from(`${STX}${scannerID}${l}${ETX}`, "ascii");
|
||||
console.log("Sending:", message.toString("ascii"));
|
||||
scanner.write(message);
|
||||
await new Promise((resolve) => setTimeout(resolve, 1200));
|
||||
}
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 1500));
|
||||
scanner.destroy();
|
||||
});
|
||||
|
||||
scanner.on("data", async (data) => {
|
||||
console.log("Response:", data.toString("ascii"));
|
||||
});
|
||||
|
||||
scanner.on("close", () => {
|
||||
console.log("Connection closed");
|
||||
});
|
||||
|
||||
scanner.on("error", (err) => {
|
||||
console.error("Scanner error:", err);
|
||||
});
|
||||
Reference in New Issue
Block a user