fix(ocme): cycle count typos

This commit is contained in:
2025-04-01 16:19:25 -05:00
parent 5c642805b1
commit ee3026fa7c
3 changed files with 100 additions and 47 deletions

View File

@@ -41,13 +41,22 @@ export default function OcmeCycleCount() {
setCounting(true); setCounting(true);
toast.success(`Cycle count started`); toast.success(`Cycle count started`);
try { try {
const res = await axios.post("/ocme/api/v1/cyclecount", data, { const res = await axios.post("/ocme/api/v1/cycleCount", data, {
headers: { Authorization: `Bearer ${token}` }, headers: { Authorization: `Bearer ${token}` },
}); });
toast.success(res.data.message);
setData(res.data.data); if (res.data.success) {
setCounting(false); toast.success(res.data.message);
reset(); setData(res.data.data);
setCounting(false);
reset();
}
if (res.data.success) {
toast.success(res.data.message);
setCounting(false);
}
} catch (error) { } catch (error) {
toast.error("There was an error cycle counting"); toast.error("There was an error cycle counting");
setCounting(false); setCounting(false);
@@ -137,7 +146,7 @@ export default function OcmeCycleCount() {
<TableHead>Result</TableHead> <TableHead>Result</TableHead>
</TableRow> </TableRow>
</TableHeader> </TableHeader>
{data.length === 0 ? ( {data?.length === 0 ? (
<TableBody> <TableBody>
{Array(10) {Array(10)
.fill(0) .fill(0)

View File

@@ -1,13 +1,17 @@
import type {User} from "../../../types/users.js"; import type { User } from "../../../types/users.js";
import {alplaStockInv} from "./cycleCount/alplaStockInventory.js"; import { alplaStockInv } from "./cycleCount/alplaStockInventory.js";
import {emptyCount} from "./cycleCount/emptyCycleCount.js"; import { emptyCount } from "./cycleCount/emptyCycleCount.js";
import {fullLaneCount} from "./cycleCount/fullLaneCycleCount.js"; import { fullLaneCount } from "./cycleCount/fullLaneCycleCount.js";
import {ocmeInv} from "./cycleCount/ocmeInventory.js"; import { ocmeInv } from "./cycleCount/ocmeInventory.js";
export const prepareLane = "https://usday1prod.alpla.net/application/public/v1.1/Warehousing/PrepareLaneForInventory"; export const prepareLane =
export const openLane = "https://usday1prod.alpla.net/application/public/v1.0/Warehousing/InventoryOpen"; "https://usday1prod.alpla.net/application/public/v1.1/Warehousing/PrepareLaneForInventory";
export const closeLane = "https://usday1prod.alpla.net/application/public/v1.0/Warehousing/InventoryClose"; export const openLane =
export const releaseLane = "https://usday1prod.alpla.net/application/public/v1.1/Warehousing/ReleaseLaneFromInventory"; "https://usday1prod.alpla.net/application/public/v1.0/Warehousing/InventoryOpen";
export const closeLane =
"https://usday1prod.alpla.net/application/public/v1.0/Warehousing/InventoryClose";
export const releaseLane =
"https://usday1prod.alpla.net/application/public/v1.1/Warehousing/ReleaseLaneFromInventory";
export const scannerID = 500; export const scannerID = 500;
export const cycleCount = async (lane: any, user: User) => { export const cycleCount = async (lane: any, user: User) => {
/** /**
@@ -24,29 +28,39 @@ export const cycleCount = async (lane: any, user: User) => {
// create a new array that has the merge happen. // create a new array that has the merge happen.
const mergeOcmeData = ocme.map((d: any) => { const mergeOcmeData = ocme.map((d: any) => {
// check if its in the ocme array we add it // check if its in the ocme array we add it
const inStock = alplaStock.filter((r: any) => r.runningNumber === d.runningNumber); const inStock = alplaStock.filter(
(r: any) => r.runningNumber === d.runningNumber
);
//console.log(inStock); //console.log(inStock);
if (inStock.length != 0) { if (inStock.length != 0) {
//console.log(`${d.runningNumber} is good`); //console.log(`${d.runningNumber} is good`);
return {...d, ocme: "Yes", stock: "Yes", info: "Good"}; return { ...d, ocme: "Yes", stock: "Yes", info: "Good" };
} else { } else {
//console.log(`${d.runningNumber} is bad`); //console.log(`${d.runningNumber} is bad`);
return {...d, ocme: "Yes", stock: "No", info: "Quality Check Required"}; return {
...d,
ocme: "Yes",
stock: "No",
info: "Validate pallet is ok. ",
};
} }
}); });
const mergeStockData = alplaStock const mergeStockData = alplaStock
.filter((r: any) => !ocme.some((d: any) => d.runningNumber === r.runningNumber)) .filter(
.map((r: any) => { (r: any) =>
return { !ocme.some((d: any) => d.runningNumber === r.runningNumber)
...r, )
ocme_laneLevelID: "", .map((r: any) => {
sscc: "", return {
ocme: "No", ...r,
stock: "Yes", ocme_laneLevelID: "",
info: "Sent to Inv", sscc: "",
}; ocme: "No",
}); stock: "Yes",
info: "Sent to Inv",
};
});
const combineBoth = [...mergeOcmeData, ...mergeStockData]; const combineBoth = [...mergeOcmeData, ...mergeStockData];

View File

@@ -1,10 +1,12 @@
// import {Router} from 'express' // import {Router} from 'express'
// import { runQuery } from '../utils/sql/config/sqlConfig.js' // import { runQuery } from '../utils/sql/config/sqlConfig.js'
// import { ocmeInventory } from '../utils/sql/querys/getOCMEInventory.js' // import { ocmeInventory } from '../utils/sql/querys/getOCMEInventory.js'
// import { getLanes } from '../utils/sql/querys/getLanes.js'
// const router = Router() // const router = Router()
// router.post('/getLaneData', async (req,res)=>{ // router.post('/getLaneData', async (req,res)=>{
// console.log(`Getting lane data`)
// let filterdOCMELane // let filterdOCMELane
// // the body will need to have 1 lane in it. lane: 'B050' // // the body will need to have 1 lane in it. lane: 'B050'
@@ -12,30 +14,58 @@
// // add the lane in so we dont crash // // add the lane in so we dont crash
// if(req.body.lane){ // if(req.body.lane){
// if(data.laneType === "laneID"){ // if(data.laneType === "laneID"){
// get the mapped lane id // // get the mapped lane id
// where alpla_laneID = 30286 // // where alpla_laneID = 30286
// filterdOCMELane = ocmeInventory.replaceAll("where alpla_laneDescription = '[lane]'", `where alpla_laneID = ${data.lane}`) // console.log("getting lane by id")
// filterdOCMELane = ocmeInventory.replaceAll("where alpla_laneDescription = '[lane]'", `where alpla_laneID = ${data.lane}`)
// } else { // } else {
// filterdOCMELane = ocmeInventory.replaceAll('[lane]', data.lane) // console.log("getting lane by name")
// } // filterdOCMELane = ocmeInventory.replaceAll('[lane]', data.lane)
// }
// //
// // get lanes // // get lanes
// const laneData = await runQuery(filterdOCMELane, 'Getting current ocme lanes linked') // try {
// res.status(200).json({success: true,message: `All current lanes from the ocme system.`, totalpallets: laneData.length,data: laneData}) // const laneData = await runQuery(filterdOCMELane, 'Getting current ocme lanes linked')
// return
// let inventory = laneData
// // if we do not have anything then we will send just the name and id so we can at least do the count.
// if(laneData.length === 0){
// console.log(`Sending the name and id over. for an empty count`)
// const lanes = await runQuery(getLanes, 'Getting current ocme lanes linked')
// let filterLane
// if(data.laneType === "laneID"){
// filterLane = lanes.filter(n => n.alpla_laneID.includes(req.body.lane))
// }else {
// filterLane = lanes.filter(n => n.alpla_laneDescription === req.body.lane.toUpperCase())
// }
// inventory = [{alpla_laneDescription: filterLane[0].alpla_laneDescription,alpla_laneID: filterLane[0].alpla_laneID }]
// console.log(filterLane, inventory)
// }
// return res.status(200).json({success: true,message: `All current lanes from the ocme system.`, totalpallets: inventory.length,data: inventory})
// } catch (error) {
// console.log(error)
// return res.status(400).json({success: false,message: `Error getting the lane data`, error})
// }
// } // }
// // if the plant sends the id over lets change the entire where statement. // // if the plant sends the id over lets change the entire where statement.
// if(req.body.laneID){ // // if(req.body.laneID){
// console.log(`Getting the lane data by id`) // // console.log(`Getting the lane data by id`)
// filterdOCMELane = ocmeInventory.replaceAll(`alpla_laneDescription = '[lane]'`, `alpla_laneID = ${data.laneID}`) // // filterdOCMELane = ocmeInventory.replaceAll(`alpla_laneDescription = '[lane]'`, `alpla_laneID = ${data.laneID}`)
// // get lanes // // // get lanes
// const laneData = await runQuery(filterdOCMELane, 'Getting current ocme lanes linked') // // const laneData = await runQuery(filterdOCMELane, 'Getting current ocme lanes linked')
// res.status(200).json({success: true,message: `All current lanes from the ocme system.`, totalpallets: laneData.length,data: laneData}) // // res.status(200).json({success: true,message: `All current lanes from the ocme system.`, totalpallets: laneData.length,data: laneData})
// return // // return
// } // // }
// // if everything is missing we send false // // if everything is missing we send false
// res.status(200).json({success: false,message: `Missing either lane name or lane id.`}) // res.status(200).json({success: false,message: `Missing either lane name or lane id.`})