Compare commits

...

7 Commits

7 changed files with 139 additions and 112 deletions

View File

@@ -8,7 +8,7 @@
{ "type": "refactor", "section": "🛠️ Code Refactor" },
{ "type": "perf", "hidden": false, "section": "🚀 Performance" },
{ "type": "test", "section": "📝 Testing Code" },
{ "type": "ci", "hidden": false, "section": "📈 Project changes" },
{ "type": "ci", "hidden": true, "section": "📈 Project changes" },
{ "type": "build", "hidden": true, "section": "📈 Project Builds" }
],
"commitUrlFormat": "https://git.tuffraid.net/cowch/lstV2/commits/{{hash}}",

View File

@@ -35,7 +35,7 @@
}
},
"admConfig": {
"build": 148,
"build": 152,
"oldBuild": "backend-0.1.3.zip"
},
"devDependencies": {

View File

@@ -103,7 +103,7 @@ const updateBuildNumber = (appLock: string) => {
// Auto-commit changes
execSync("git add package.json");
execSync(
`git commit -m "chore(release): bump build number to ${pkgJson.admConfig.build}"`
`git commit -m "ci(release): bump build number to ${pkgJson.admConfig.build}"`
);
} else {
createLog(

View File

@@ -1,3 +1,6 @@
import { db } from "../../../../database/dbclient.js";
import { settings } from "../../../../database/schema/settings.js";
import { tryCatch } from "../../../globalUtils/tryCatch.js";
import type { User } from "../../../types/users.js";
import { alplaStockInv } from "./cycleCount/alplaStockInventory.js";
import { emptyCount } from "./cycleCount/emptyCycleCount.js";

View File

@@ -6,7 +6,6 @@ import { query } from "../../sqlServer/prodSqlServer.js";
import { labelData } from "../../sqlServer/querys/materialHelpers/labelInfo.js";
export const postLabelData = async (data: any) => {
console.log(data);
let newData = data;
if (Array.isArray(data)) {
newData = {

View File

@@ -53,7 +53,10 @@ app.openapi(
.string()
.optional()
.openapi({ example: "Internal Server error" }),
data: z.array(z.object({})).optional().openapi({ example: [] }),
data: z
.array(z.object({}))
.optional()
.openapi({ example: [] }),
}),
},
},
@@ -81,8 +84,11 @@ app.openapi(
// make sure we have a vaid user being accessed thats really logged in
try {
const data = await c.req.json();
apiHit(c, { endpoint: "api/ocme/postRunningNumber", lastBody: data });
const postPallet = await postLabelData(data);
apiHit(c, {
endpoint: "api/ocme/postRunningNumber",
lastBody: data,
});
const postPallet: any = await postLabelData(data);
return c.json(
{
success: postPallet.success,

View File

@@ -9,6 +9,7 @@ import { db } from "../../../database/dbclient.js";
import { settings } from "../../../database/schema/settings.js";
import { eq } from "drizzle-orm";
import { postLabelData } from "../ocme/controller/postRunningNr.js";
import { tryCatch } from "../../globalUtils/tryCatch.js";
let tcpServer: net.Server;
let tcpSockets: Set<net.Socket> = new Set();
@@ -27,8 +28,23 @@ export const startTCPServer = () => {
if (isServerRunning)
return { success: false, message: "Server is already running" };
tcpServer = net.createServer((socket) => {
createLog("info", "tcp", "tcp", "Client connected");
tcpServer = net.createServer(async (socket) => {
createLog("debug", "tcp", "tcp", "Client connected");
const { data: setting, error: settingError } = await tryCatch(
db.select().from(settings)
);
if (settingError) {
return {
success: false,
message: "Error getting settings",
data: [],
};
}
const settingCheck = setting.filter(
(newData) => newData.name === "ocmeService"
);
tcpSockets.add(socket);
socket.on("data", (data: Buffer) => {
@@ -50,11 +66,14 @@ export const startTCPServer = () => {
}
// from the wrapper send the data
const ocmeSetting: any = settingCheck;
if (ocmeSetting[0]?.value === "1") {
postLabelData(parseData);
}
});
socket.on("end", () => {
createLog("info", "tcp", "tcp", "Client disconnected");
createLog("debug", "tcp", "tcp", "Client disconnected");
tcpSockets.delete(socket);
});