helper scripts
This commit is contained in:
99
scripts/FinanceProcess/createBol.mjs
Normal file
99
scripts/FinanceProcess/createBol.mjs
Normal file
@@ -0,0 +1,99 @@
|
||||
import net from "net";
|
||||
|
||||
/**
|
||||
* This uses a kinda fake scanner to mimic the scanning process to a server and creates the bol.
|
||||
*/
|
||||
const prodIP = "10.44.0.26";
|
||||
const prodPort = 50001;
|
||||
const scannerID = "98@";
|
||||
const scannerCommand = "AlplaPRODcmd00000042#000047909"; // top of the picksheet
|
||||
const scannerCommand2 = ""; // bottom of the pick sheet
|
||||
|
||||
const labels = [
|
||||
"1000000000000000000000000000000006544320",
|
||||
"1000000000000000000000000000000006544280",
|
||||
"1000000000000000000000000000000006544410",
|
||||
"1000000000000000000000000000000006544490",
|
||||
"1000000000000000000000000000000006544450",
|
||||
"1000000000000000000000000000000006544520",
|
||||
"1000000000000000000000000000000006544590",
|
||||
"1000000000000000000000000000000006544560",
|
||||
"1000000000000000000000000000000006544860",
|
||||
"1000000000000000000000000000000006544830",
|
||||
"1000000000000000000000000000000006544930",
|
||||
"1000000000000000000000000000000006544890",
|
||||
"1000000000000000000000000000000006545100",
|
||||
"1000000000000000000000000000000006545060",
|
||||
"1000000000000000000000000000000006545270",
|
||||
"1000000000000000000000000000000006545220",
|
||||
"1000000000000000000000000000000006544990",
|
||||
"1000000000000000000000000000000006545040",
|
||||
"1000000000000000000000000000000006545520",
|
||||
"1000000000000000000000000000000006545490",
|
||||
"1000000000000000000000000000000006545450",
|
||||
"1000000000000000000000000000000006545560",
|
||||
"1000000000000000000000000000000006545760",
|
||||
"1000000000000000000000000000000006545640",
|
||||
"1000000000000000000000000000000006545690",
|
||||
"1000000000000000000000000000000006545620",
|
||||
"1000000000000000000000000000000006546450",
|
||||
"1000000000000000000000000000000006546500",
|
||||
"1000000000000000000000000000000006545940",
|
||||
"1000000000000000000000000000000006545900",
|
||||
"1000000000000000000000000000000006545850",
|
||||
"1000000000000000000000000000000006545820",
|
||||
"1000000000000000000000000000000006546530",
|
||||
"1000000000000000000000000000000006545330",
|
||||
"1000000000000000000000000000000006546090",
|
||||
"1000000000000000000000000000000006546220",
|
||||
"1000000000000000000000000000000006546120",
|
||||
"1000000000000000000000000000000006546140",
|
||||
"1000000000000000000000000000000006546260",
|
||||
"1000000000000000000000000000000006546310",
|
||||
];
|
||||
const STX = "\x02";
|
||||
const ETX = "\x03";
|
||||
|
||||
const scanner = new net.Socket();
|
||||
|
||||
scanner.connect(prodPort, prodIP, async () => {
|
||||
console.log("Connected to scanner");
|
||||
|
||||
const message = Buffer.from(
|
||||
`${STX}${scannerID}${scannerCommand}${ETX}`,
|
||||
"ascii",
|
||||
);
|
||||
console.log("Sending:", message.toString("ascii"));
|
||||
scanner.write(message);
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000));
|
||||
|
||||
for (let i = 0; i < labels.length; i++) {
|
||||
const l = labels[i];
|
||||
|
||||
const message = Buffer.from(`${STX}${scannerID}${l}${ETX}`, "ascii");
|
||||
console.log("Sending:", message.toString("ascii"));
|
||||
scanner.write(message);
|
||||
await new Promise((resolve) => setTimeout(resolve, 1200));
|
||||
}
|
||||
|
||||
// //close the incoming
|
||||
// await new Promise(resolve => setTimeout(resolve, 1500));
|
||||
// const message2 = Buffer.from(`${STX}${scannerID}${scannerCommand2}${ETX}`, "ascii");
|
||||
// console.log("Sending:", message2.toString("ascii"));
|
||||
// scanner.write(message2);
|
||||
|
||||
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