feat(scanner): added in lanechecks
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
|
import { runProdApi } from "../utils/prodEndpoint.utils.js";
|
||||||
import { db } from "../db/db.controller.js";
|
|
||||||
import { scanLog } from "../db/schema/scanlog.schema.js";
|
|
||||||
import { apiReturn } from "../utils/returnHelper.utils.js";
|
import { apiReturn } from "../utils/returnHelper.utils.js";
|
||||||
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
@@ -9,27 +7,26 @@ const router = Router();
|
|||||||
router.post("/", async (req, res) => {
|
router.post("/", async (req, res) => {
|
||||||
const body = req.body;
|
const body = req.body;
|
||||||
|
|
||||||
const newLog = await db
|
const lane = body.lane.split("#");
|
||||||
.insert(scanLog)
|
|
||||||
.values({
|
console.log(lane[2]);
|
||||||
scannerId: body.scannerId,
|
const laneData = await runProdApi({
|
||||||
message: body.message,
|
method: "post",
|
||||||
prompt: body.prompt,
|
endpoint: "/public/v1.1/Warehousing/GetWarehouseUnits",
|
||||||
commandDescription: body.commandDescription,
|
data: [
|
||||||
status: body.status,
|
{
|
||||||
lines: body.lines,
|
laneIds: [lane[2]],
|
||||||
user: body.user,
|
},
|
||||||
runningNumber: body.runningNumber,
|
],
|
||||||
})
|
});
|
||||||
.returning();
|
|
||||||
|
|
||||||
return apiReturn(res, {
|
return apiReturn(res, {
|
||||||
success: true,
|
success: true,
|
||||||
level: "info",
|
level: "info",
|
||||||
module: "mobile",
|
module: "mobile",
|
||||||
subModule: "scan logs",
|
subModule: "lane check",
|
||||||
message: `New log from ${body.scannerId}`,
|
message: `all data for lane Id: ${lane}`,
|
||||||
data: newLog,
|
data: laneData?.data ?? [],
|
||||||
status: 200,
|
status: 200,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { Express } from "express";
|
import type { Express } from "express";
|
||||||
import downloads from "./donwloadApps.route.js";
|
import downloads from "./donwloadApps.route.js";
|
||||||
|
import lanes from "./laneCheck.js";
|
||||||
import authPin from "./mobileAuth.route.js";
|
import authPin from "./mobileAuth.route.js";
|
||||||
import newPin from "./mobilePin.route.js";
|
import newPin from "./mobilePin.route.js";
|
||||||
import logs from "./scanLogs.route.js";
|
import logs from "./scanLogs.route.js";
|
||||||
@@ -12,6 +13,7 @@ export const setupMobileRoutes = (baseUrl: string, app: Express) => {
|
|||||||
app.use(`${baseUrl}/api/mobile/logs`, logs);
|
app.use(`${baseUrl}/api/mobile/logs`, logs);
|
||||||
app.use(`${baseUrl}/api/mobile/auth`, authPin);
|
app.use(`${baseUrl}/api/mobile/auth`, authPin);
|
||||||
app.use(`${baseUrl}/api/mobile/pin`, newPin);
|
app.use(`${baseUrl}/api/mobile/pin`, newPin);
|
||||||
|
app.use(`${baseUrl}/api/mobile/laneCheck`, lanes);
|
||||||
|
|
||||||
// all other system should be under /api/system/*
|
// all other system should be under /api/system/*
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
"foregroundImage": "./assets/adaptive-icon-white.png",
|
"foregroundImage": "./assets/adaptive-icon-white.png",
|
||||||
"backgroundColor": "#ffffff"
|
"backgroundColor": "#ffffff"
|
||||||
},
|
},
|
||||||
"versionCode": 30,
|
"versionCode": 31,
|
||||||
"minSupportedVersionCode": 26,
|
"minSupportedVersionCode": 26,
|
||||||
"predictiveBackGestureEnabled": false,
|
"predictiveBackGestureEnabled": false,
|
||||||
"package": "net.alpla.lst.mobile"
|
"package": "net.alpla.lst.mobile"
|
||||||
|
|||||||
5496
lstMobile/package-lock.json
generated
5496
lstMobile/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,7 @@
|
|||||||
"ios": "expo run:ios",
|
"ios": "expo run:ios",
|
||||||
"web": "expo start --web",
|
"web": "expo start --web",
|
||||||
"lint": "expo lint",
|
"lint": "expo lint",
|
||||||
"build:apk:clean": "expo prebuild --clean && cd android && gradlew.bat clean && gradlew.bat assembleRelease && npm run copy:apk",
|
"build:apk:clean": "expo prebuild --clean && cd android && gradlew.bat assembleRelease && npm run copy:apk",
|
||||||
"build:apk": "expo prebuild && cd android && gradlew.bat assembleRelease && npm run copy:apk",
|
"build:apk": "expo prebuild && cd android && gradlew.bat assembleRelease && npm run copy:apk",
|
||||||
"build:mobile": "cd scripts && node runBuild.ts",
|
"build:mobile": "cd scripts && node runBuild.ts",
|
||||||
"build:mobile:bump": "cd scripts && node runBuild.ts --bump",
|
"build:mobile:bump": "cd scripts && node runBuild.ts --bump",
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
"@react-navigation/bottom-tabs": "^7.15.5",
|
"@react-navigation/bottom-tabs": "^7.15.5",
|
||||||
"@react-navigation/elements": "^2.9.10",
|
"@react-navigation/elements": "^2.9.10",
|
||||||
"@react-navigation/native": "^7.1.33",
|
"@react-navigation/native": "^7.1.33",
|
||||||
|
"@rn-primitives/dialog": "^1.4.0",
|
||||||
"@rn-primitives/portal": "^1.4.0",
|
"@rn-primitives/portal": "^1.4.0",
|
||||||
"@rn-primitives/separator": "^1.4.0",
|
"@rn-primitives/separator": "^1.4.0",
|
||||||
"@rn-primitives/slot": "^1.4.0",
|
"@rn-primitives/slot": "^1.4.0",
|
||||||
@@ -56,10 +57,11 @@
|
|||||||
"react-dom": "19.2.0",
|
"react-dom": "19.2.0",
|
||||||
"react-native": "0.83.4",
|
"react-native": "0.83.4",
|
||||||
"react-native-gesture-handler": "~2.30.0",
|
"react-native-gesture-handler": "~2.30.0",
|
||||||
"react-native-reanimated": "^4.2.1",
|
"react-native-reanimated": "4.2.1",
|
||||||
"react-native-safe-area-context": "~5.6.2",
|
"react-native-safe-area-context": "~5.6.2",
|
||||||
"react-native-screens": "~4.23.0",
|
"react-native-screens": "~4.23.0",
|
||||||
"react-native-tcp-socket": "^6.4.1",
|
"react-native-tcp-socket": "^6.4.1",
|
||||||
|
"react-native-toast-message": "^2.3.3",
|
||||||
"react-native-web": "~0.21.0",
|
"react-native-web": "~0.21.0",
|
||||||
"react-native-worklets": "0.7.2",
|
"react-native-worklets": "0.7.2",
|
||||||
"socket.io-client": "^4.8.3",
|
"socket.io-client": "^4.8.3",
|
||||||
|
|||||||
@@ -1,37 +1,210 @@
|
|||||||
import React, { useCallback, useEffect } from "react";
|
import axios from "axios";
|
||||||
import { Text, View } from "react-native";
|
import { format } from "date-fns-tz";
|
||||||
|
import { useFocusEffect } from "expo-router";
|
||||||
|
import type React from "react";
|
||||||
|
import { useCallback, useEffect, useState } from "react";
|
||||||
|
import { ScrollView, Text, View } from "react-native";
|
||||||
|
import { SafeAreaView } from "react-native-safe-area-context";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
import { GlobalFooter } from "../../components/UpdateFooter";
|
||||||
import { Button } from "../../components/ui/button";
|
import { Button } from "../../components/ui/button";
|
||||||
|
import { Card, CardContent, CardHeader } from "../../components/ui/card";
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
DialogTrigger,
|
||||||
|
} from "../../components/ui/dialog";
|
||||||
|
import { useAppStore } from "../../hooks/useAppStore";
|
||||||
|
import { scannerFeedback } from "../../lib/feedbackScan";
|
||||||
import { type ZebraScanResult, zebraScanner } from "../../lib/ZebraScanner";
|
import { type ZebraScanResult, zebraScanner } from "../../lib/ZebraScanner";
|
||||||
|
|
||||||
|
const InfoRow = ({
|
||||||
|
label,
|
||||||
|
value,
|
||||||
|
}: {
|
||||||
|
label: string;
|
||||||
|
value: React.ReactNode;
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<View className="flex-row justify-between gap-4 py-2 border-b border-gray-200">
|
||||||
|
<Text className="text-sm text-gray-500">{label}</Text>
|
||||||
|
<Text className="text-sm font-medium text-gray-900 text-right flex-1">
|
||||||
|
{value}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default function LaneCheck() {
|
export default function LaneCheck() {
|
||||||
const handleScan = useCallback(async (scan: ZebraScanResult) => {
|
const [units, setUnits] = useState<any>(null);
|
||||||
console.log(scan);
|
const serverIp = useAppStore((s) => s.serverIp);
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
const handleScan = useCallback(
|
||||||
zebraScanner.ensureProfile();
|
async (scan: ZebraScanResult) => {
|
||||||
zebraScanner.startListening();
|
setUnits(null);
|
||||||
|
await scannerFeedback({
|
||||||
|
type: "scan",
|
||||||
|
sound: true,
|
||||||
|
vibrate: true,
|
||||||
|
led: true,
|
||||||
|
});
|
||||||
|
if (!scan.data.startsWith("loc")) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Scan error",
|
||||||
|
text2: "The last scan was not a lane please try again",
|
||||||
|
});
|
||||||
|
|
||||||
const sub = zebraScanner.addScanListener((scan) => {
|
return;
|
||||||
//console.log("SCAN:", scan);
|
}
|
||||||
handleScan(scan);
|
try {
|
||||||
});
|
const res = await axios.post(
|
||||||
|
`http://${serverIp.trim()}:3000/lst/api/mobile/lanecheck`,
|
||||||
|
{
|
||||||
|
lane: scan.data,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timeout: 5000,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (res.status === 200) {
|
||||||
|
setUnits(res.data);
|
||||||
|
Toast.show({
|
||||||
|
type: "info",
|
||||||
|
text1: "Lane Data",
|
||||||
|
text2: "All Loading Units from this lane will be listed below",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Lane Data",
|
||||||
|
text2: "Error getting lane data please try again",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[serverIp.trim],
|
||||||
|
);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
zebraScanner.startListening();
|
||||||
|
|
||||||
|
const sub = zebraScanner.addScanListener((scan) => {
|
||||||
|
//console.log("SCAN:", scan);
|
||||||
|
handleScan(scan);
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
sub.remove();
|
||||||
|
zebraScanner.stopListening();
|
||||||
|
//setUnits(null);
|
||||||
|
};
|
||||||
|
}, [handleScan]),
|
||||||
|
);
|
||||||
|
|
||||||
return () => {
|
|
||||||
sub.remove();
|
|
||||||
zebraScanner.stopListening();
|
|
||||||
};
|
|
||||||
}, [handleScan]);
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
flex: 1,
|
|
||||||
//justifyContent: "center",
|
//justifyContent: "center",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
marginTop: 50,
|
marginTop: 50,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Text>LaneChecks</Text>
|
{units ? (
|
||||||
|
// <SafeAreaView className={`flex-1 w-full items-center`}>
|
||||||
|
// <ScrollView className="w-full flex-1">
|
||||||
|
// <View className="flex items-center gap-2 w-full">
|
||||||
|
// {units.data?.map((i: any, index: any) => (
|
||||||
|
// <View key={`${i.runningNumber}-${index}`}>
|
||||||
|
// <Text>example</Text>
|
||||||
|
// </View>
|
||||||
|
// ))}
|
||||||
|
// </View>
|
||||||
|
// </ScrollView>
|
||||||
|
// </SafeAreaView>
|
||||||
|
<SafeAreaView className={`w-full items-center`}>
|
||||||
|
<View style={{ padding: 2 }}>
|
||||||
|
<Text>There Are {units.data.length} units in this lane</Text>
|
||||||
|
</View>
|
||||||
|
<ScrollView className="w-full" style={{ marginBottom: 20 }}>
|
||||||
|
<View>
|
||||||
|
{units.data.map((i, index) => (
|
||||||
|
<View
|
||||||
|
key={`${i.runningNumber}-${index}`}
|
||||||
|
style={{
|
||||||
|
justifyContent: "center",
|
||||||
|
margin: 2,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Dialog>
|
||||||
|
<DialogTrigger>
|
||||||
|
<Card
|
||||||
|
className="w-full"
|
||||||
|
style={{
|
||||||
|
borderColor:
|
||||||
|
i.state === "QualityBlocked" ? "red" : undefined,
|
||||||
|
borderWidth: 4,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CardContent>
|
||||||
|
<Text>
|
||||||
|
{i.articleId} - {i.articleName}
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<Text>
|
||||||
|
Running Number: {i.runningNumber ?? "Non barcoded"}
|
||||||
|
</Text>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</DialogTrigger>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>
|
||||||
|
Details for Article {i.articleId}, Rn:
|
||||||
|
{i.runningNumber ?? "Non barcoded"}{" "}
|
||||||
|
</DialogTitle>
|
||||||
|
<DialogDescription>
|
||||||
|
<InfoRow
|
||||||
|
label="Production Date"
|
||||||
|
value={format(i.productionDate, "MM/dd/yyyy HH:mm")}
|
||||||
|
/>
|
||||||
|
<InfoRow label="Quantity" value={i.quantity} />
|
||||||
|
{i.state === "QualityBlocked" && (
|
||||||
|
<InfoRow
|
||||||
|
label="Defect"
|
||||||
|
value={i.mainDefectGroupDescription}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{i.state === "QualityBlocked" && (
|
||||||
|
<InfoRow
|
||||||
|
label="Description"
|
||||||
|
value={i.mainDefectDescription}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
</View>
|
||||||
|
))}
|
||||||
|
</View>
|
||||||
|
</ScrollView>
|
||||||
|
</SafeAreaView>
|
||||||
|
) : (
|
||||||
|
<View className="mt-50">
|
||||||
|
<Text className="text-2xl text-center">
|
||||||
|
Please scan a lane to see all Units that are in the lane.
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
<View>
|
||||||
|
<GlobalFooter />
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,16 @@ import { PortalHost } from "@rn-primitives/portal";
|
|||||||
import { Stack } from "expo-router";
|
import { Stack } from "expo-router";
|
||||||
import { StatusBar } from "expo-status-bar";
|
import { StatusBar } from "expo-status-bar";
|
||||||
import "../../global.css";
|
import "../../global.css";
|
||||||
|
import { useEffect } from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
import useDeviceLock from "../hooks/useDeviceCheck";
|
import useDeviceLock from "../hooks/useDeviceCheck";
|
||||||
|
import { zebraScanner } from "../lib/ZebraScanner";
|
||||||
|
|
||||||
export default function RootLayout() {
|
export default function RootLayout() {
|
||||||
useDeviceLock();
|
useDeviceLock();
|
||||||
|
useEffect(() => {
|
||||||
|
zebraScanner.ensureProfile();
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -18,6 +24,7 @@ export default function RootLayout() {
|
|||||||
<Stack.Screen name="(tabs)" />
|
<Stack.Screen name="(tabs)" />
|
||||||
</Stack>
|
</Stack>
|
||||||
<PortalHost />
|
<PortalHost />
|
||||||
|
<Toast />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,4 +37,7 @@ export const zebraScanner = {
|
|||||||
): EmitterSubscription {
|
): EmitterSubscription {
|
||||||
return scannerEmitter.addListener("barcodeScanned", callback);
|
return scannerEmitter.addListener("barcodeScanned", callback);
|
||||||
},
|
},
|
||||||
|
disableScannerInput() {
|
||||||
|
ZebraScanner.disableScannerInput();
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user