Compare commits
16 Commits
d63138d746
...
36a805c652
| Author | SHA1 | Date | |
|---|---|---|---|
| 36a805c652 | |||
| 460bc3d24a | |||
| ec201fcfb5 | |||
| 914ad46c43 | |||
| b96c546ed3 | |||
| 29b3be41a1 | |||
| 16edf58025 | |||
| 775627f215 | |||
| 4e70fae69b | |||
| 24dd109a21 | |||
| 38b57a00cc | |||
| f8070db95f | |||
| 10e9dc430c | |||
| 6b669ccd9c | |||
| d9a10d98a1 | |||
| e64dc7c013 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": "1",
|
||||
"name": "LogisticsSupportTool_API_DOCS",
|
||||
"name": "lstv2",
|
||||
"type": "collection",
|
||||
"ignore": [
|
||||
"node_modules",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
vars {
|
||||
url: http://localhost:4200
|
||||
url: http://localhost:5500
|
||||
session_cookie:
|
||||
urlv2: http://usbow1vms006:3000
|
||||
jwtV2:
|
||||
|
||||
24
LogisticsSupportTool_API_DOCS/logistics/bookout.bru
Normal file
24
LogisticsSupportTool_API_DOCS/logistics/bookout.bru
Normal file
@@ -0,0 +1,24 @@
|
||||
meta {
|
||||
name: bookout
|
||||
type: http
|
||||
seq: 2
|
||||
}
|
||||
|
||||
post {
|
||||
url: {{url}}/lst/old/api/logistics/bookout
|
||||
body: json
|
||||
auth: none
|
||||
}
|
||||
|
||||
body:json {
|
||||
{
|
||||
|
||||
"runningNr": "1864553",
|
||||
"reason": "30006"
|
||||
}
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
8
LogisticsSupportTool_API_DOCS/logistics/folder.bru
Normal file
8
LogisticsSupportTool_API_DOCS/logistics/folder.bru
Normal file
@@ -0,0 +1,8 @@
|
||||
meta {
|
||||
name: logistics
|
||||
seq: 7
|
||||
}
|
||||
|
||||
auth {
|
||||
mode: inherit
|
||||
}
|
||||
24
LogisticsSupportTool_API_DOCS/logistics/relocate.bru
Normal file
24
LogisticsSupportTool_API_DOCS/logistics/relocate.bru
Normal file
@@ -0,0 +1,24 @@
|
||||
meta {
|
||||
name: relocate
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
post {
|
||||
url: {{url}}/lst/old/api/logistics/relocate
|
||||
body: json
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
body:json {
|
||||
{
|
||||
|
||||
"runningNr": "56121541",
|
||||
"laneID": "30006"
|
||||
}
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
24
LogisticsSupportTool_API_DOCS/logistics/removeAsWaste.bru
Normal file
24
LogisticsSupportTool_API_DOCS/logistics/removeAsWaste.bru
Normal file
@@ -0,0 +1,24 @@
|
||||
meta {
|
||||
name: removeAsWaste
|
||||
type: http
|
||||
seq: 3
|
||||
}
|
||||
|
||||
post {
|
||||
url: {{url}}/lst/old/api/logistics/bookout
|
||||
body: json
|
||||
auth: none
|
||||
}
|
||||
|
||||
body:json {
|
||||
{
|
||||
|
||||
"runningNr": "1865027",
|
||||
"reason": "packer printed premature"
|
||||
}
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
import { text, pgTable, timestamp, uuid, jsonb } from "drizzle-orm/pg-core";
|
||||
import { jsonb, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core";
|
||||
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
export const commandLog = pgTable(
|
||||
"commandLog",
|
||||
{
|
||||
commandLog_id: uuid("commandLog_id").defaultRandom().primaryKey(),
|
||||
commandUsed: text("commandUsed").notNull(),
|
||||
bodySent: jsonb("bodySent").default([]),
|
||||
reasonUsed: text("reasonUsed"),
|
||||
add_at: timestamp("add_Date").defaultNow(),
|
||||
},
|
||||
(table) => [
|
||||
// uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`),
|
||||
// uniqueIndex("role_name").on(table.name),
|
||||
]
|
||||
"commandLog",
|
||||
{
|
||||
commandLog_id: uuid("commandLog_id").defaultRandom().primaryKey(),
|
||||
commandUsed: text("commandUsed").notNull(),
|
||||
bodySent: jsonb("bodySent").default([]),
|
||||
reasonUsed: text("reasonUsed"),
|
||||
addDate: timestamp("add_Date").defaultNow(),
|
||||
},
|
||||
(table) => [
|
||||
// uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`),
|
||||
// uniqueIndex("role_name").on(table.name),
|
||||
],
|
||||
);
|
||||
|
||||
// Schema for inserting a user - can be used to validate API requests
|
||||
|
||||
187
lstV2/server/globalUtils/scannerConnect.ts
Normal file
187
lstV2/server/globalUtils/scannerConnect.ts
Normal file
@@ -0,0 +1,187 @@
|
||||
/**
|
||||
* Using this to make a scanner connection to the server.
|
||||
*/
|
||||
|
||||
import net from "net";
|
||||
|
||||
interface QueuedCommand {
|
||||
command: string;
|
||||
resolve: (value: string) => void;
|
||||
reject: (reason?: any) => void;
|
||||
timeout: NodeJS.Timeout;
|
||||
}
|
||||
|
||||
const STX = "\x02";
|
||||
const ETX = "\x03";
|
||||
|
||||
// const prodIP = process.env.SERVER_IP as string;
|
||||
// const prodPort = parseInt(process.env.SCANNER_PORT || "50000", 10);
|
||||
// const scannerID = `${process.env.SCANNER_ID}@`;
|
||||
//const scannerCommand = "AlplaPRODcmd00000042#000028547"; // top of the picksheet
|
||||
|
||||
export class ScannerClient {
|
||||
private socket = new net.Socket();
|
||||
private connected = false;
|
||||
|
||||
private queue: QueuedCommand[] = [];
|
||||
private processing = false;
|
||||
|
||||
private incomingBuffer = "";
|
||||
|
||||
constructor(
|
||||
private host: string,
|
||||
private port: number,
|
||||
private scannerId: string,
|
||||
) {
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
private initialize() {
|
||||
this.socket.connect(this.port, this.host, () => {
|
||||
console.info("Connected to scanner");
|
||||
this.connected = true;
|
||||
});
|
||||
|
||||
this.socket.on("data", (data) => this.handleData(data));
|
||||
|
||||
this.socket.on("close", () => {
|
||||
console.log("Scanner connection closed");
|
||||
this.connected = false;
|
||||
});
|
||||
|
||||
this.socket.on("error", (err) => {
|
||||
console.error("Scanner error:", err);
|
||||
});
|
||||
}
|
||||
|
||||
// ✅ Public method you use
|
||||
public scan(command: string): Promise<string> {
|
||||
if (!this.connected) {
|
||||
return Promise.reject("Scanner not connected");
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const timeout = setTimeout(() => {
|
||||
this.processing = false;
|
||||
reject("Scanner timeout");
|
||||
this.processQueue();
|
||||
}, 5000); // 5s safety timeout
|
||||
|
||||
this.queue.push({
|
||||
command,
|
||||
resolve,
|
||||
reject,
|
||||
timeout,
|
||||
});
|
||||
|
||||
this.processQueue();
|
||||
});
|
||||
}
|
||||
|
||||
// ✅ Ensures strict FIFO processing
|
||||
private processQueue() {
|
||||
if (this.processing) return;
|
||||
if (this.queue.length === 0) return;
|
||||
|
||||
this.processing = true;
|
||||
|
||||
const current = this.queue[0];
|
||||
const message = Buffer.from(
|
||||
`${STX}${this.scannerId}${current.command}${ETX}`,
|
||||
"ascii",
|
||||
);
|
||||
|
||||
this.socket.write(message);
|
||||
}
|
||||
|
||||
// ✅ Handles full STX/ETX framed responses
|
||||
private handleData(data: Buffer) {
|
||||
console.log(
|
||||
"ASCII:",
|
||||
data
|
||||
.toString("ascii")
|
||||
.replace(/\x00/g, "") // remove null bytes
|
||||
.replace(/\x1B\[[0-9;?]*[A-Za-z]/g, "") // remove ANSI escape codes
|
||||
.trim(),
|
||||
);
|
||||
|
||||
const current = this.queue.shift();
|
||||
if (current) {
|
||||
clearTimeout(current.timeout);
|
||||
current.resolve(data.toString("ascii"));
|
||||
}
|
||||
|
||||
this.processing = false;
|
||||
this.processQueue();
|
||||
}
|
||||
}
|
||||
|
||||
export const scanner = new ScannerClient(
|
||||
process.env.SERVER_IP!,
|
||||
parseInt(process.env.SCANNER_PORT!, 10),
|
||||
`${process.env.SCANNER_ID}@`,
|
||||
);
|
||||
|
||||
// export const connectToScanner = () => {
|
||||
// if (!process.env.SERVER_IP || !process.env.SCANNER_PORT) {
|
||||
// return {
|
||||
// success: false,
|
||||
// message: "Missing ServerIP or ServerPort",
|
||||
// };
|
||||
// }
|
||||
|
||||
// scanner.connect(prodPort, prodIP, () => {
|
||||
// console.log("Connected to scanner");
|
||||
// connected = true;
|
||||
// });
|
||||
// };
|
||||
|
||||
// export const scan = async (command: string) => {
|
||||
// if (!connected) {
|
||||
// return {
|
||||
// success: false,
|
||||
// message: "Scanner is not connected, please contact admin",
|
||||
// };
|
||||
// }
|
||||
// if (inScanCommand) {
|
||||
// bufferCommands.push({ timeStamp: new Date(Date.now()), command: command });
|
||||
// }
|
||||
|
||||
// // we are going to set to scanning
|
||||
// inScanCommand = true;
|
||||
|
||||
// const message = Buffer.from(`${STX}${scannerID}${command}${ETX}`, "ascii");
|
||||
// scanner.write(message);
|
||||
// await new Promise((resolve) => setTimeout(resolve, 750));
|
||||
|
||||
// inScanCommand = false;
|
||||
|
||||
// if (bufferCommands.length > 0) {
|
||||
// await scan(bufferCommands[0].command);
|
||||
// bufferCommands.shift();
|
||||
// }
|
||||
|
||||
// return {
|
||||
// success: true,
|
||||
// message: "Scan completed",
|
||||
// };
|
||||
// };
|
||||
|
||||
// scanner.on("data", async (data) => {
|
||||
// console.log(
|
||||
// "Response:",
|
||||
// data
|
||||
// .toString("ascii")
|
||||
// .replace(/\x00/g, "") // remove null bytes
|
||||
// .replace(/\x1B\[[0-9;?]*[A-Za-z]/g, "") // remove ANSI escape codes
|
||||
// .trim(),
|
||||
// );
|
||||
// });
|
||||
|
||||
// scanner.on("close", () => {
|
||||
// console.log("Connection closed");
|
||||
// });
|
||||
|
||||
// scanner.on("error", (err) => {
|
||||
// console.error("Scanner error:", err);
|
||||
// });
|
||||
@@ -63,10 +63,10 @@ setTimeout(async () => {
|
||||
// the time we want to run the hostircal data should be the same time the historical data run on the server
|
||||
// getting this from the shift time
|
||||
|
||||
if (process.env.NODE_ENV?.trim() !== "production") {
|
||||
setTimeout(() => {
|
||||
historicalInvIMmport();
|
||||
}, 15 * 1000);
|
||||
}
|
||||
//if (process.env.NODE_ENV?.trim() !== "production") {
|
||||
setTimeout(() => {
|
||||
historicalInvIMmport();
|
||||
}, 15 * 1000);
|
||||
//}
|
||||
|
||||
export default app;
|
||||
|
||||
155
lstV2/server/services/logistics/controller/commands/bookout.ts
Normal file
155
lstV2/server/services/logistics/controller/commands/bookout.ts
Normal file
@@ -0,0 +1,155 @@
|
||||
import axios from "axios";
|
||||
import net from "net";
|
||||
import { db } from "../../../../../database/dbclient.js";
|
||||
import { commandLog } from "../../../../../database/schema/commandLog.js";
|
||||
import { createSSCC } from "../../../../globalUtils/createSSCC.js";
|
||||
import { prodEndpointCreation } from "../../../../globalUtils/createUrl.js";
|
||||
import { scanner } from "../../../../globalUtils/scannerConnect.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { createLog } from "../../../logger/logger.js";
|
||||
import { query } from "../../../sqlServer/prodSqlServer.js";
|
||||
import { sqlQuerySelector } from "../../../sqlServer/utils/querySelector.utils.js";
|
||||
|
||||
type Data = {
|
||||
runningNr: number;
|
||||
reason: string;
|
||||
user: string;
|
||||
};
|
||||
export const bookOutPallet = async (data: Data) => {
|
||||
const { runningNr, reason, user } = data;
|
||||
|
||||
if (!reason || reason.length < 4) {
|
||||
return {
|
||||
success: false,
|
||||
status: 400,
|
||||
message: "The reason provided is to short",
|
||||
data: [],
|
||||
};
|
||||
}
|
||||
|
||||
const queryCheck = sqlQuerySelector("inventoryInfo.query");
|
||||
|
||||
if (!queryCheck.success) {
|
||||
return {
|
||||
success: false,
|
||||
status: 400,
|
||||
message: queryCheck.message,
|
||||
data: data,
|
||||
};
|
||||
}
|
||||
const { data: label, error: labelError } = (await tryCatch(
|
||||
query(
|
||||
queryCheck.query!.replace("[runningNr]", `${runningNr}`),
|
||||
"labelQuery",
|
||||
),
|
||||
)) as any;
|
||||
|
||||
if (labelError) {
|
||||
return {
|
||||
success: false,
|
||||
status: 400,
|
||||
message: labelError.message,
|
||||
data: labelError,
|
||||
};
|
||||
}
|
||||
|
||||
// check if we are in ppoo
|
||||
if (label.data.length <= 0) {
|
||||
return {
|
||||
success: false,
|
||||
status: 400,
|
||||
message: `${runningNr} is not currently in ppoo, please move to ppoo before trying to book-out`,
|
||||
data: [],
|
||||
};
|
||||
}
|
||||
|
||||
// check if the label is blocked for coa.
|
||||
if (
|
||||
label.data[0].blockingReason &&
|
||||
!label.data[0].blockingReason?.includes("COA")
|
||||
) {
|
||||
return {
|
||||
success: false,
|
||||
status: 400,
|
||||
message: `${runningNr} is not currently blocked for coa, to get this pallet booked out please take the label to quality to be released then you can book-out.`,
|
||||
data: [],
|
||||
};
|
||||
}
|
||||
|
||||
if (label.data[0].blockingReason) {
|
||||
await scanner.scan("AlplaPRODcmd89");
|
||||
await scanner.scan(`${label.data[0].barcode}`);
|
||||
}
|
||||
|
||||
// create the url to post
|
||||
const url = await prodEndpointCreation(
|
||||
"/public/v1.1/Manufacturing/ProductionControlling/BookOut",
|
||||
);
|
||||
const SSCC = await createSSCC(runningNr);
|
||||
|
||||
const bookOutData = {
|
||||
sscc: SSCC.slice(2),
|
||||
scannerId: "666",
|
||||
};
|
||||
|
||||
try {
|
||||
const results = await axios.post(url, bookOutData, {
|
||||
headers: {
|
||||
"X-API-Key": process.env.TEC_API_KEY || "",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
if (results.data.Errors) {
|
||||
return {
|
||||
success: false,
|
||||
status: 400,
|
||||
message: results.data.Errors.Error.Description,
|
||||
};
|
||||
}
|
||||
|
||||
// if (results.data.Result !== 0) {
|
||||
// console.log("stopping here and closing to soon", results);
|
||||
// return {
|
||||
// success: false,
|
||||
// status: 400,
|
||||
// message: results.data.Message,
|
||||
// };
|
||||
// }
|
||||
|
||||
const { data: commandL, error: ce } = await tryCatch(
|
||||
db.insert(commandLog).values({
|
||||
commandUsed: "book out",
|
||||
bodySent: data,
|
||||
reasonUsed: reason,
|
||||
}),
|
||||
);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: `${runningNr} was booked out`,
|
||||
status: results.status,
|
||||
};
|
||||
} catch (error: any) {
|
||||
console.log(bookOutData);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
status: 400,
|
||||
message: error.response?.data,
|
||||
data: error.response?.data,
|
||||
};
|
||||
}
|
||||
|
||||
// });
|
||||
|
||||
/**
|
||||
* book out the label with
|
||||
* url /public/v1.1/Manufacturing/ProductionControlling/BookOut
|
||||
* {
|
||||
* "sscc": "string",
|
||||
* "scannerId": "string"
|
||||
* }
|
||||
*/
|
||||
//---------------------------------------------------------------------------------------\\
|
||||
};
|
||||
@@ -1,120 +1,50 @@
|
||||
import axios from "axios";
|
||||
import { commandLog } from "../../../../../database/schema/commandLog.js";
|
||||
import { prodEndpointCreation } from "../../../../globalUtils/createUrl.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { lstAuth } from "../../../../index.js";
|
||||
import { createSSCC } from "../../../../globalUtils/createSSCC.js";
|
||||
import { db } from "../../../../../database/dbclient.js";
|
||||
import net from "net";
|
||||
import { commandLog } from "../../../../../database/schema/commandLog.js";
|
||||
import { scanner } from "../../../../globalUtils/scannerConnect.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { query } from "../../../sqlServer/prodSqlServer.js";
|
||||
import { labelInfo } from "../../../sqlServer/querys/warehouse/labelInfo.js";
|
||||
import { settings } from "../../../../../database/schema/settings.js";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { serverData } from "../../../../../database/schema/serverData.js";
|
||||
|
||||
export const removeAsNonReusable = async (data: any) => {
|
||||
// const removalUrl = await prodEndpointCreation(
|
||||
// "/public/v1.0/Warehousing/RemoveAsNonReusableMaterial"
|
||||
// );
|
||||
// get the label info
|
||||
const { data: label, error: labelError } = (await tryCatch(
|
||||
query(labelInfo.replaceAll("[runningNr]", data.runningNr), "Label Info"),
|
||||
)) as any;
|
||||
|
||||
// const sscc = await createSSCC(data.runningNr);
|
||||
if (label.data[0].stockStatus === "notOnStock") {
|
||||
return {
|
||||
success: false,
|
||||
message: `The label: ${data.runningNr} is not currently in stock`,
|
||||
data: [],
|
||||
};
|
||||
}
|
||||
|
||||
// const { data: remove, error } = await tryCatch(
|
||||
// axios.post(
|
||||
// removalUrl,
|
||||
// { scannerId: "500", sscc: sscc.slice(2) },
|
||||
// {
|
||||
// headers: { Authorization: `Basic ${lstAuth}` },
|
||||
// }
|
||||
// )
|
||||
// );
|
||||
if (label.data[0].blockingReason) {
|
||||
return {
|
||||
success: false,
|
||||
status: 400,
|
||||
message: `${data.runningNr} is currently blocked, to get this pallet removed please take the label to quality to be released then you can remove.`,
|
||||
data: [],
|
||||
};
|
||||
}
|
||||
|
||||
// use a scanner tcp connection to trigger this process
|
||||
const STX = "\x02";
|
||||
const ETX = "\x03";
|
||||
const scanner = new net.Socket();
|
||||
let stage = 0;
|
||||
// get the label info
|
||||
const { data: label, error: labelError } = (await tryCatch(
|
||||
query(labelInfo.replaceAll("[runningNr]", data.runningNr), "Label Info")
|
||||
)) as any;
|
||||
await scanner.scan("AlplaPRODcmd23");
|
||||
await scanner.scan(`${label.data[0].barcode}`);
|
||||
|
||||
if (label.data[0].stockStatus === "notOnStock") {
|
||||
return {
|
||||
success: false,
|
||||
message: `The label: ${data.runningNr} is not currently in stock`,
|
||||
data: [],
|
||||
};
|
||||
}
|
||||
let reason = data.reason || "";
|
||||
delete data.reason;
|
||||
|
||||
// get the server ip based on the token.
|
||||
const setting = await db.select().from(settings);
|
||||
const { data: commandL, error: ce } = await tryCatch(
|
||||
db.insert(commandLog).values({
|
||||
commandUsed: "removeAsNonReusable",
|
||||
bodySent: data,
|
||||
reasonUsed: reason,
|
||||
}),
|
||||
);
|
||||
|
||||
const plantInfo = await db.select().from(serverData);
|
||||
const plantToken = setting.filter((n: any) => n.name === "plantToken");
|
||||
const scannerID = setting.filter((n: any) => n.name === "scannerID");
|
||||
const scannerPort = setting.filter((n: any) => n.name === "scannerPort");
|
||||
const plantData = plantInfo.filter(
|
||||
(p: any) => p.plantToken === plantToken[0].value
|
||||
);
|
||||
|
||||
scanner.connect(
|
||||
parseInt(scannerPort[0].value),
|
||||
plantData[0].idAddress!,
|
||||
async () => {
|
||||
// need to get the ip from the server data and scanner port
|
||||
//console.log(`connected to scanner`);
|
||||
scanner.write(`${STX}${scannerID[0].value}@AlplaPRODcmd23${ETX}`);
|
||||
}
|
||||
);
|
||||
scanner.on("data", (data) => {
|
||||
const response = data.toString();
|
||||
//console.log("Received:", response.trimStart());
|
||||
if (stage === 0) {
|
||||
stage = 1;
|
||||
scanner.write(
|
||||
`${STX}${scannerID[0].value}@${label.data[0].Barcode}${ETX}`
|
||||
);
|
||||
} else if (stage === 1) {
|
||||
scanner.end();
|
||||
}
|
||||
});
|
||||
scanner.on("close", () => {
|
||||
//console.log("Connection closed");
|
||||
scanner.destroy();
|
||||
});
|
||||
scanner.on("error", (err) => {
|
||||
//console.error("Scanner error:", err);
|
||||
scanner.destroy();
|
||||
return {
|
||||
success: false,
|
||||
message: `The label: ${data.runningNr} encountering an error while being removed, please try again`,
|
||||
data: [],
|
||||
};
|
||||
});
|
||||
|
||||
// if (error) {
|
||||
// //console.log(error);
|
||||
// return {
|
||||
// success: false,
|
||||
// message: `There was an error removing ${data.runningNr}`,
|
||||
// data: [],
|
||||
// };
|
||||
// }
|
||||
|
||||
let reason = data.reason || "";
|
||||
delete data.reason;
|
||||
|
||||
const { data: commandL, error: ce } = await tryCatch(
|
||||
db.insert(commandLog).values({
|
||||
commandUsed: "removeAsNonReusable",
|
||||
bodySent: data,
|
||||
reasonUsed: reason,
|
||||
})
|
||||
);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: `The label: ${data.runningNr}, was removed`,
|
||||
data: [],
|
||||
};
|
||||
return {
|
||||
success: true,
|
||||
message: `The label: ${data.runningNr}, was removed`,
|
||||
data: [],
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { OpenAPIHono } from "@hono/zod-openapi";
|
||||
|
||||
import { migrateAdjustments } from "./controller/siloAdjustments/migrateAdjustments.js";
|
||||
import { getLanesToCycleCount } from "./controller/warehouse/cycleCountChecks/cyclecountCheck.js";
|
||||
import attachSilo from "./route/attachSilo.js";
|
||||
import bookOutPallet from "./route/bookout.js";
|
||||
import comsumeMaterial from "./route/consumeMaterial.js";
|
||||
import detachSilo from "./route/detachSilo.js";
|
||||
import postBulkOrders from "./route/dm/bulkOrdersIn.js";
|
||||
@@ -56,6 +58,7 @@ const routes = [
|
||||
// logisitcs
|
||||
removeAsNonReable,
|
||||
getSSCC,
|
||||
bookOutPallet,
|
||||
] as const;
|
||||
|
||||
// app.route("/server", modules);
|
||||
|
||||
87
lstV2/server/services/logistics/route/bookout.ts
Normal file
87
lstV2/server/services/logistics/route/bookout.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||
import { verify } from "hono/jwt";
|
||||
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||
//import { authMiddleware } from "../../auth/middleware/authMiddleware.js";
|
||||
import { bookOutPallet } from "../controller/commands/bookout.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
const responseSchema = z.object({
|
||||
success: z.boolean().optional().openapi({ example: true }),
|
||||
message: z.string().optional().openapi({ example: "user access" }),
|
||||
});
|
||||
|
||||
app.openapi(
|
||||
createRoute({
|
||||
tags: ["logistics"],
|
||||
summary: "Consumes material based on its running number",
|
||||
method: "post",
|
||||
path: "/bookout",
|
||||
//middleware: authMiddleware,
|
||||
description:
|
||||
"Provided a running number and lot number you can consume material.",
|
||||
responses: {
|
||||
200: {
|
||||
content: { "application/json": { schema: responseSchema } },
|
||||
description: "stopped",
|
||||
},
|
||||
400: {
|
||||
content: { "application/json": { schema: responseSchema } },
|
||||
description: "Failed to stop",
|
||||
},
|
||||
401: {
|
||||
content: { "application/json": { schema: responseSchema } },
|
||||
description: "Failed to stop",
|
||||
},
|
||||
},
|
||||
}),
|
||||
async (c) => {
|
||||
const { data, error } = await tryCatch(c.req.json());
|
||||
|
||||
if (error) {
|
||||
return c.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Missing data please try again",
|
||||
error,
|
||||
},
|
||||
400,
|
||||
);
|
||||
}
|
||||
apiHit(c, { endpoint: "/bookout", lastBody: data });
|
||||
//const authHeader = c.req.header("Authorization");
|
||||
//const token = authHeader?.split("Bearer ")[1] || "";
|
||||
|
||||
//const payload = await verify(token, process.env.JWT_SECRET!);
|
||||
try {
|
||||
//return apiReturn(c, true, access?.message, access?.data, 200);
|
||||
|
||||
//const pointData = { ...data, user: payload.user };
|
||||
|
||||
const bookout = await bookOutPallet(data);
|
||||
|
||||
console.log("from booout:", bookout);
|
||||
return c.json(
|
||||
{
|
||||
success: bookout?.success,
|
||||
message: bookout?.message,
|
||||
data: bookout.data,
|
||||
},
|
||||
200,
|
||||
);
|
||||
} catch (error) {
|
||||
console.log("from error:", error);
|
||||
//return apiReturn(c, false, "Error in setting the user access", error, 400);
|
||||
return c.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Missing data please try again",
|
||||
error,
|
||||
},
|
||||
400,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
export default app;
|
||||
@@ -1,112 +1,112 @@
|
||||
import { isBefore } from "date-fns";
|
||||
import { db } from "../../../../../database/dbclient.js";
|
||||
import { fifoIndex } from "../../../../../database/schema/fifoIndex.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { query } from "../../../sqlServer/prodSqlServer.js";
|
||||
import { currentInv } from "../../../sqlServer/querys/notifications/fifoIndex/currentInv.js";
|
||||
import { shippedPallets } from "../../../sqlServer/querys/notifications/fifoIndex/shippedPallets.js";
|
||||
import { db } from "../../../../../database/dbclient.js";
|
||||
import { fifoIndex } from "../../../../../database/schema/fifoIndex.js";
|
||||
|
||||
export default async function fifoIndexCheck() {
|
||||
/**
|
||||
* getting the shipped pallets
|
||||
*/
|
||||
const { data: shipped, error: eShipped } = await tryCatch(
|
||||
query(shippedPallets, "notify shipped pallets")
|
||||
);
|
||||
/**
|
||||
* getting the shipped pallets
|
||||
*/
|
||||
const { data: shipped, error: eShipped } = await tryCatch(
|
||||
query(shippedPallets, "notify shipped pallets"),
|
||||
);
|
||||
|
||||
const { data: currentStuff, error: eCurrentInv } = await tryCatch(
|
||||
query(currentInv, "notify shipped pallets")
|
||||
);
|
||||
const { data: currentStuff, error: eCurrentInv } = await tryCatch(
|
||||
query(currentInv, "notify shipped pallets"),
|
||||
);
|
||||
|
||||
// console.log(shipped?.data[2]);
|
||||
// console.log(currentStuff?.data[2]);
|
||||
// console.log(shipped?.data[2]);
|
||||
// console.log(currentStuff?.data[2]);
|
||||
|
||||
/**
|
||||
* We want to check if the each shippened pallet is out of fifo
|
||||
*/
|
||||
const check = shipped?.data.map((n: any) => {
|
||||
/**
|
||||
* Returns all data so we know if we are in or out.
|
||||
*/
|
||||
//check if there are pallets older than the current one we are mapped on.
|
||||
const fifoCheck = currentStuff?.data.filter(
|
||||
(i: any) => isBefore(i.prodDate, n.prodDate) && i.av === n.av
|
||||
);
|
||||
//console.log(fifoCheck.length);
|
||||
if (fifoCheck.length > 0) {
|
||||
// console.log("Out of fifo", {
|
||||
// av: n.av,
|
||||
// rn: n.runningNr,
|
||||
// fRn: fifoCheck[0].runningNr,
|
||||
// dates: [fifoCheck[0].prodDate, n.prodDate],
|
||||
// });
|
||||
}
|
||||
/**
|
||||
* We want to check if the each shippened pallet is out of fifo
|
||||
*/
|
||||
const check: any = shipped?.data.map((n: any) => {
|
||||
/**
|
||||
* Returns all data so we know if we are in or out.
|
||||
*/
|
||||
//check if there are pallets older than the current one we are mapped on.
|
||||
const fifoCheck = currentStuff?.data.filter(
|
||||
(i: any) => isBefore(i.prodDate, n.prodDate) && i.av === n.av,
|
||||
) as any;
|
||||
//console.log(fifoCheck.length);
|
||||
if (fifoCheck.length > 0) {
|
||||
// console.log("Out of fifo", {
|
||||
// av: n.av,
|
||||
// rn: n.runningNr,
|
||||
// fRn: fifoCheck[0].runningNr,
|
||||
// dates: [fifoCheck[0].prodDate, n.prodDate],
|
||||
// });
|
||||
}
|
||||
|
||||
return {
|
||||
...n,
|
||||
// currentInv: fifoCheck[0],
|
||||
fifoFollowed: fifoCheck.length === 0 ? true : false,
|
||||
};
|
||||
});
|
||||
return {
|
||||
...n,
|
||||
// currentInv: fifoCheck[0],
|
||||
fifoFollowed: fifoCheck.length === 0 ? true : false,
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* lets see just the av that is our or in
|
||||
*/
|
||||
/**
|
||||
* lets see just the av that is our or in
|
||||
*/
|
||||
|
||||
const avCheck = (check: any) => {
|
||||
/**
|
||||
* This will only return the data based on out of fifo.
|
||||
*/
|
||||
// check how many times each av showed up
|
||||
const avCounts = check.reduce((a: any, c: any) => {
|
||||
if (c.fifoFollowed === false) {
|
||||
const avValue = c.av;
|
||||
a[avValue] = (a[avValue] || 0) + 1;
|
||||
}
|
||||
return a;
|
||||
}, {});
|
||||
const avCheck = (check: any) => {
|
||||
/**
|
||||
* This will only return the data based on out of fifo.
|
||||
*/
|
||||
// check how many times each av showed up
|
||||
const avCounts = check.reduce((a: any, c: any) => {
|
||||
if (c.fifoFollowed === false) {
|
||||
const avValue = c.av;
|
||||
a[avValue] = (a[avValue] || 0) + 1;
|
||||
}
|
||||
return a;
|
||||
}, {});
|
||||
|
||||
// transform them back to an avCount Object
|
||||
const result = Object.keys(avCounts).map((av) => ({
|
||||
av: parseInt(av, 10),
|
||||
count: avCounts[av],
|
||||
}));
|
||||
// transform them back to an avCount Object
|
||||
const result = Object.keys(avCounts).map((av) => ({
|
||||
av: parseInt(av, 10),
|
||||
count: avCounts[av],
|
||||
}));
|
||||
|
||||
return result;
|
||||
};
|
||||
return result;
|
||||
};
|
||||
|
||||
const outOfFifo: any = avCheck(check);
|
||||
const totalOut = outOfFifo.reduce((sum: any, c: any) => {
|
||||
return sum + c.count;
|
||||
}, 0);
|
||||
const outOfFifo: any = avCheck(check);
|
||||
const totalOut = outOfFifo.reduce((sum: any, c: any) => {
|
||||
return sum + c.count;
|
||||
}, 0);
|
||||
|
||||
/**
|
||||
* add the data to the db
|
||||
*/
|
||||
for (let i = 0; i < check.length; i++) {
|
||||
const { data: dbInsert, error: dbE } = await tryCatch(
|
||||
db
|
||||
.insert(fifoIndex)
|
||||
.values({
|
||||
lot: check[i].lot,
|
||||
av: check[i].av,
|
||||
runningNr: check[i].runningNr,
|
||||
prodDate: check[i].prodDate,
|
||||
fifoFollowed: check[i].fifoFollowed,
|
||||
add_Date: check[i].add_Date,
|
||||
})
|
||||
.onConflictDoNothing()
|
||||
);
|
||||
}
|
||||
/**
|
||||
* add the data to the db
|
||||
*/
|
||||
for (let i = 0; i < check!.length; i++) {
|
||||
const { data: dbInsert, error: dbE } = await tryCatch(
|
||||
db
|
||||
.insert(fifoIndex)
|
||||
.values({
|
||||
lot: check[i].lot,
|
||||
av: check[i].av,
|
||||
runningNr: check[i].runningNr,
|
||||
prodDate: check[i].prodDate,
|
||||
fifoFollowed: check[i].fifoFollowed,
|
||||
add_Date: check[i].add_Date,
|
||||
})
|
||||
.onConflictDoNothing(),
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Fifo index data",
|
||||
data: {
|
||||
palletsOut: check,
|
||||
totalShipped: shipped?.data.length,
|
||||
inFifo: shipped?.data.length - totalOut,
|
||||
outOfFifoData: outOfFifo,
|
||||
},
|
||||
};
|
||||
return {
|
||||
success: true,
|
||||
message: "Fifo index data",
|
||||
data: {
|
||||
palletsOut: check,
|
||||
totalShipped: shipped?.data.length,
|
||||
inFifo: shipped!.data.length - totalOut,
|
||||
outOfFifoData: outOfFifo,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ export default async function tooManyErrors(notifyData: any) {
|
||||
} ${errorLogData.length > 1 ? "errors" : "error"} in the last ${notifyData.checkInterval} min`,
|
||||
template: "tooManyErrors",
|
||||
context: {
|
||||
data: errorLogData,
|
||||
data: errorLogData.slice(0, 100),
|
||||
count: notifyData.notifiySettings.errorCount,
|
||||
time: notifyData.checkInterval,
|
||||
},
|
||||
|
||||
@@ -94,7 +94,7 @@ export const sendEmail = async (data: any): Promise<any> => {
|
||||
} as SMTPTransport.Options);
|
||||
|
||||
// update the from email
|
||||
fromEmail = `noreply@alpla.com`;
|
||||
fromEmail = `donotreply@alpla.com`;
|
||||
}
|
||||
|
||||
// creating the handlbar options
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
import { createPlcMonitor } from "./plcController.js";
|
||||
|
||||
export const zechettiConnect = () => {
|
||||
const config: any = {
|
||||
controllers: [
|
||||
{
|
||||
id: "Zecchetti_1",
|
||||
ip: "192.168.193.97",
|
||||
slot: 0,
|
||||
rpi: 250,
|
||||
printerId: 22, // grabbed from 2.0
|
||||
tags: ["N7[0]"],
|
||||
},
|
||||
{
|
||||
id: "Zecchetti_2",
|
||||
ip: "192.168.193.111",
|
||||
slot: 0,
|
||||
rpi: 100,
|
||||
printerId: 23,
|
||||
tags: ["N8[0]"],
|
||||
},
|
||||
],
|
||||
};
|
||||
const config: any = {
|
||||
controllers: [
|
||||
{
|
||||
id: "Zecchetti_1",
|
||||
ip: "192.168.193.97",
|
||||
slot: 0,
|
||||
rpi: 250,
|
||||
printerId: 22, // grabbed from 2.0
|
||||
tags: ["N7[0]"],
|
||||
},
|
||||
// {
|
||||
// id: "Zecchetti_2",
|
||||
// ip: "192.168.193.111",
|
||||
// slot: 0,
|
||||
// rpi: 100,
|
||||
// printerId: 23,
|
||||
// tags: ["N8[0]"],
|
||||
// },
|
||||
],
|
||||
};
|
||||
|
||||
const monitor = createPlcMonitor(config);
|
||||
const monitor = createPlcMonitor(config);
|
||||
|
||||
// Start
|
||||
monitor.start();
|
||||
// Start
|
||||
monitor.start();
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ import { createLog } from "../logger/logger.js";
|
||||
import { serverSettings } from "../server/controller/settings/getSettings.js";
|
||||
import { prodSqlConfig } from "./utils/prodServerConfig.js";
|
||||
|
||||
let pool: any;
|
||||
let pool: sql.ConnectionPool;
|
||||
let connected: boolean = false;
|
||||
export const initializeProdPool = async () => {
|
||||
if (!installed) {
|
||||
@@ -34,7 +34,9 @@ export const initializeProdPool = async () => {
|
||||
(n: any) => n.name === "dbServer",
|
||||
) as any;
|
||||
|
||||
const serverUp = await checkHostnamePort(`${dbServer[0].value}:1433`);
|
||||
const serverUp = await checkHostnamePort(
|
||||
`${process.env.NODE_ENV !== "development" ? "localhost" : dbServer[0].value}:1433`,
|
||||
);
|
||||
|
||||
if (!serverUp) {
|
||||
createLog(
|
||||
@@ -88,7 +90,8 @@ export const initializeProdPool = async () => {
|
||||
}
|
||||
try {
|
||||
const config = await prodSqlConfig();
|
||||
pool = await sql.connect(config!);
|
||||
pool = new sql.ConnectionPool(config!);
|
||||
await pool.connect();
|
||||
|
||||
createLog(
|
||||
"info",
|
||||
@@ -164,7 +167,9 @@ export async function query(queryToRun: string, name: string) {
|
||||
const dbServer = serverSettings.filter(
|
||||
(n: any) => n.name === "dbServer",
|
||||
) as any;
|
||||
const serverUp = await checkHostnamePort(`${dbServer[0].value}:1433`);
|
||||
const serverUp = await checkHostnamePort(
|
||||
`${process.env.NODE_ENV !== "development" ? "localhost" : dbServer[0].value}:1433`,
|
||||
);
|
||||
|
||||
if (!serverUp) {
|
||||
createLog(
|
||||
|
||||
@@ -61,7 +61,8 @@ V_Artikel.ArtikelvariantenTypBez= 'LDPE' or
|
||||
V_Artikel.ArtikelvariantenTypBez= 'PP' or
|
||||
V_Artikel.ArtikelvariantenTypBez= 'HDPE' or
|
||||
V_Artikel.ArtikelvariantenTypBez= 'PET' or
|
||||
V_Artikel.ArtikelvariantenTypBez= 'PET-P'
|
||||
V_Artikel.ArtikelvariantenTypBez= 'PET-P' or
|
||||
V_Artikel.ArtikelvariantenTypBez= 'PET-G'
|
||||
THEN 'MM'
|
||||
WHEN
|
||||
V_Artikel.ArtikelvariantenTypBez='HDPE-Waste' or
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
This query will return a single running number as long as its in stock.
|
||||
|
||||
To get all data comment out the lfdnr in the where statmen
|
||||
*/
|
||||
use AlplaPROD_test1
|
||||
|
||||
DECLARE @runningNumber nvarchar(max) = '[runningNr]' -- when saving in lst should be '[runningNr]'
|
||||
|
||||
select x.idartikelVarianten as av,
|
||||
ArtikelVariantenAlias as alias,
|
||||
x.Lfdnr as runningNumber,
|
||||
round(sum(EinlagerungsMengeVPKSum),0) as totalPallets,
|
||||
sum(EinlagerungsMengeSum) as totalPalletQTY,
|
||||
round(sum(VerfuegbareMengeVPKSum),0) as avaliblePallets,
|
||||
sum(VerfuegbareMengeSum) as avaliablePalletQTY,
|
||||
sum(case when c.Description LIKE '%COA%' then GesperrteMengeVPKSum else 0 end) as coaPallets,
|
||||
sum(case when c.Description LIKE '%COA%' then GesperrteMengeSum else 0 end) as coaQTY,
|
||||
sum(case when c.Description NOT LIKE '%COA%' or x.IdMainDefect = -1 then GesperrteMengeVPKSum else 0 end) as heldPallets,
|
||||
sum(case when c.Description NOT LIKE '%COA%' or x.IdMainDefect = -1 then GesperrteMengeSum else 0 end) as heldQTY
|
||||
,IdProdPlanung as lot
|
||||
,IdAdressen as addressID,
|
||||
x.AdressBez as addressDescription
|
||||
,x.IdLagerAbteilung as locationId
|
||||
,x.lagerabteilungkurzbez as location
|
||||
,lot.machine
|
||||
,produktionsdatummin as productionDate
|
||||
,'728'
|
||||
+ RIGHT(CAST(YEAR(produktionsdatummin) AS varchar(4)), 1)
|
||||
+ CAST(DATEDIFF(DAY, DATEFROMPARTS(YEAR(produktionsdatummin), 1, 1), produktionsdatummin) + 1 AS varchar(3))
|
||||
+ CAST(lot.machine AS varchar(10)) as batch
|
||||
,c.Description as blockingReason
|
||||
,x.Barcode as barcode
|
||||
--,*
|
||||
from dbo.[V_LagerPositionenBarcodes] (nolock) x
|
||||
|
||||
left join
|
||||
dbo.T_EtikettenGedruckt as l(nolock) on
|
||||
x.Lfdnr = l.Lfdnr AND l.Lfdnr > 1
|
||||
|
||||
left join
|
||||
|
||||
(SELECT *
|
||||
FROM [dbo].[T_BlockingDefects] where Active = 1) as c
|
||||
on x.IdMainDefect = c.IdBlockingDefect
|
||||
|
||||
/*
|
||||
get lot and machine info
|
||||
*/
|
||||
left join
|
||||
(select location as machine,
|
||||
runningnumber as lot
|
||||
,planstart
|
||||
,planend
|
||||
from [test1_AlplaPROD2.0_Read].[productionScheduling].[ProductionLot] (nolock) x
|
||||
|
||||
left join
|
||||
[test1_AlplaPROD2.0_Read].[masterData].[Machine] (nolock) m on
|
||||
m.id = x.machineid) as lot on
|
||||
lot.lot = IdProdPlanung
|
||||
/*
|
||||
The data below will be controlled by the user in excel by default everything will be passed over
|
||||
IdAdressen = 3
|
||||
*/
|
||||
where IdArtikelTyp = 1
|
||||
and x.IdWarenlager in (1) -- the pallet must be in ppoo
|
||||
and x.Lfdnr = @runningNumber -- comment this out when you want to get everything
|
||||
|
||||
group by x.idartikelVarianten, ArtikelVariantenAlias, c.Description, IdAdressen,
|
||||
x.AdressBez , x.Lfdnr,
|
||||
IdProdPlanung
|
||||
,x.IdLagerAbteilung
|
||||
,x.lagerabteilungkurzbez
|
||||
,lot.machine
|
||||
,produktionsdatummin
|
||||
,x.Barcode
|
||||
|
||||
order by x.IdArtikelVarianten
|
||||
@@ -29,7 +29,7 @@ left join
|
||||
alplaprod_test1.dbo.V_LagerPositionenBarcodes (nolock) as l on
|
||||
ext.RunningNumber = l.Lfdnr
|
||||
|
||||
WHERE ext.SsccEanRunningNumber IN (@runningNumber) and
|
||||
WHERE ext.RunningNumber IN (@runningNumber) and
|
||||
ext.RunningNumber NOT IN (
|
||||
SELECT RunningNumber FROM [test1_AlplaPROD2.0_Read].[labelling].[InternalLabel] WHERE RunningNumber IN (@runningNumber)
|
||||
)
|
||||
|
||||
@@ -4,48 +4,47 @@ import { createLog } from "../../logger/logger.js";
|
||||
import { serverSettings } from "../../server/controller/settings/getSettings.js";
|
||||
|
||||
export const prodSqlConfig = async () => {
|
||||
try {
|
||||
//const serverSetting = await db.select().from(settings);
|
||||
const serverSetting = serverSettings as any;
|
||||
// create dummy type data
|
||||
const server = serverSetting.filter((s: any) => s.name === "dbServer");
|
||||
const plantToken = serverSetting.filter(
|
||||
(s: any) => s.name === "plantToken"
|
||||
);
|
||||
const dbUser = serverSetting.filter((s: any) => s.name === "dbUser");
|
||||
// if erroring out double check the password was actually encoded before saving
|
||||
const dbPassword = serverSetting.filter(
|
||||
(s: any) => s.name === "dbPass"
|
||||
);
|
||||
try {
|
||||
//const serverSetting = await db.select().from(settings);
|
||||
const serverSetting = serverSettings as any;
|
||||
// create dummy type data
|
||||
const server = serverSetting.filter((s: any) => s.name === "dbServer");
|
||||
const plantToken = serverSetting.filter(
|
||||
(s: any) => s.name === "plantToken",
|
||||
);
|
||||
const dbUser = serverSetting.filter((s: any) => s.name === "dbUser");
|
||||
// if erroring out double check the password was actually encoded before saving
|
||||
const dbPassword = serverSetting.filter((s: any) => s.name === "dbPass");
|
||||
|
||||
const sqlConfig = {
|
||||
server: server[0].value,
|
||||
database: `AlplaPROD_${plantToken[0].value}_cus`,
|
||||
user: dbUser[0].value,
|
||||
password: atob(dbPassword[0].value),
|
||||
options: {
|
||||
encrypt: true,
|
||||
trustServerCertificate: true,
|
||||
},
|
||||
requestTimeout: 90000, // in milliseconds
|
||||
pool: {
|
||||
max: 20, // Maximum number of connections in the pool
|
||||
min: 0, // Minimum number of connections in the pool
|
||||
idleTimeoutMillis: 10000, // How long a connection is allowed to be idle before being released
|
||||
reapIntervalMillis: 1000, // how often to check for idle resourses to destory
|
||||
acquireTimeoutMillis: 100000, // How long until a complete timeout happens
|
||||
},
|
||||
};
|
||||
const sqlConfig = {
|
||||
server:
|
||||
process.env.NODE_ENV !== "development" ? "localhost" : server[0].value,
|
||||
database: `AlplaPROD_${plantToken[0].value}_cus`,
|
||||
user: dbUser[0].value,
|
||||
password: atob(dbPassword[0].value),
|
||||
options: {
|
||||
encrypt: true,
|
||||
trustServerCertificate: true,
|
||||
},
|
||||
requestTimeout: 90000, // in milliseconds
|
||||
pool: {
|
||||
max: 20, // Maximum number of connections in the pool
|
||||
min: 0, // Minimum number of connections in the pool
|
||||
idleTimeoutMillis: 10000, // How long a connection is allowed to be idle before being released
|
||||
reapIntervalMillis: 1000, // how often to check for idle resourses to destory
|
||||
acquireTimeoutMillis: 100000, // How long until a complete timeout happens
|
||||
},
|
||||
};
|
||||
|
||||
return sqlConfig;
|
||||
} catch (error) {
|
||||
createLog(
|
||||
"info",
|
||||
"lst",
|
||||
"sqlProd",
|
||||
`${JSON.stringify(
|
||||
error
|
||||
)} "There was an error getting/setting up the config for the prod sql server."`
|
||||
);
|
||||
}
|
||||
return sqlConfig;
|
||||
} catch (error) {
|
||||
createLog(
|
||||
"info",
|
||||
"lst",
|
||||
"sqlProd",
|
||||
`${JSON.stringify(
|
||||
error,
|
||||
)} "There was an error getting/setting up the config for the prod sql server."`,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
21
lstV2/server/services/sqlServer/utils/querySelector.utils.ts
Normal file
21
lstV2/server/services/sqlServer/utils/querySelector.utils.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { readFileSync } from "fs";
|
||||
|
||||
export const sqlQuerySelector = (name: string) => {
|
||||
try {
|
||||
const queryFile = readFileSync(
|
||||
new URL(`../querys/${name}.sql`, import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
query: queryFile,
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
message:
|
||||
"Error getting the query file, please make sure you have the correct name.",
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -3,53 +3,72 @@ 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 prodIP = "10.204.0.26";
|
||||
const prodPort = 50000;
|
||||
const scannerID = "98@";
|
||||
const scannerCommand = "AlplaPRODcmd00000042#000047909"; // top of the picksheet
|
||||
const scannerCommand = "AlplaPRODcmd00000042#000028547"; // 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",
|
||||
"1000000000000000000000000000000005566030",
|
||||
"1000000000000000000000000000000005544896",
|
||||
"1000000000000000000000000000000005544906",
|
||||
"1000000000000000000000000000000005544916",
|
||||
"1000000000000000000000000000000005544926",
|
||||
"1000000000000000000000000000000005544936",
|
||||
"1000000000000000000000000000000005544946",
|
||||
"1000000000000000000000000000000005544956",
|
||||
"1000000000000000000000000000000005544966",
|
||||
"1000000000000000000000000000000005544976",
|
||||
"1000000000000000000000000000000005544986",
|
||||
"1000000000000000000000000000000005544996",
|
||||
"1000000000000000000000000000000005545006",
|
||||
"1000000000000000000000000000000005545016",
|
||||
"1000000000000000000000000000000005545026",
|
||||
"1000000000000000000000000000000005545036",
|
||||
"1000000000000000000000000000000005545046",
|
||||
"1000000000000000000000000000000005545056",
|
||||
"1000000000000000000000000000000005545066",
|
||||
"1000000000000000000000000000000005545076",
|
||||
"1000000000000000000000000000000005545086",
|
||||
"1000000000000000000000000000000005545096",
|
||||
"1000000000000000000000000000000005545106",
|
||||
"1000000000000000000000000000000005545116",
|
||||
"1000000000000000000000000000000005545126",
|
||||
"1000000000000000000000000000000005545136",
|
||||
"1000000000000000000000000000000005545146",
|
||||
"1000000000000000000000000000000005545156",
|
||||
"1000000000000000000000000000000005545166",
|
||||
"1000000000000000000000000000000005545176",
|
||||
"1000000000000000000000000000000005545186",
|
||||
"1000000000000000000000000000000005544580",
|
||||
"1000000000000000000000000000000005544590",
|
||||
"1000000000000000000000000000000005544600",
|
||||
"1000000000000000000000000000000005544610",
|
||||
"1000000000000000000000000000000005544640",
|
||||
"1000000000000000000000000000000005544650",
|
||||
"1000000000000000000000000000000005544660",
|
||||
"1000000000000000000000000000000005544670",
|
||||
"1000000000000000000000000000000005544680",
|
||||
"1000000000000000000000000000000005544690",
|
||||
"1000000000000000000000000000000005544700",
|
||||
"1000000000000000000000000000000005544710",
|
||||
"1000000000000000000000000000000005544720",
|
||||
"1000000000000000000000000000000005544730",
|
||||
"1000000000000000000000000000000005544740",
|
||||
"1000000000000000000000000000000005544750",
|
||||
"1000000000000000000000000000000005544760",
|
||||
"1000000000000000000000000000000005544770",
|
||||
"1000000000000000000000000000000005544780",
|
||||
"1000000000000000000000000000000005544790",
|
||||
"1000000000000000000000000000000005544800",
|
||||
"1000000000000000000000000000000005544810",
|
||||
"1000000000000000000000000000000005544820",
|
||||
"1000000000000000000000000000000005544830",
|
||||
"1000000000000000000000000000000005544840",
|
||||
"1000000000000000000000000000000005544850",
|
||||
"1000000000000000000000000000000005544860",
|
||||
"1000000000000000000000000000000005544870",
|
||||
];
|
||||
const STX = "\x02";
|
||||
const ETX = "\x03";
|
||||
|
||||
Reference in New Issue
Block a user