// import {Router} from 'express' // import { runQuery } from '../utils/sql/config/sqlConfig.js' // import { ocmeInventory } from '../utils/sql/querys/getOCMEInventory.js' // import { getLanes } from '../utils/sql/querys/getLanes.js' // const router = Router() // router.post('/getLaneData', async (req,res)=>{ // console.log(`Getting lane data`) // let filterdOCMELane // // the body will need to have 1 lane in it. lane: 'B050' // const data = req.body // // add the lane in so we dont crash // if(req.body.lane){ // if(data.laneType === "laneID"){ // // get the mapped lane id // // where alpla_laneID = 30286 // console.log("getting lane by id") // filterdOCMELane = ocmeInventory.replaceAll("where alpla_laneDescription = '[lane]'", `where alpla_laneID = ${data.lane}`) // } else { // console.log("getting lane by name") // filterdOCMELane = ocmeInventory.replaceAll('[lane]', data.lane) // } // // // // get lanes // try { // const laneData = await runQuery(filterdOCMELane, 'Getting current ocme lanes linked') // 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(req.body.laneID){ // // console.log(`Getting the lane data by id`) // // filterdOCMELane = ocmeInventory.replaceAll(`alpla_laneDescription = '[lane]'`, `alpla_laneID = ${data.laneID}`) // // // get lanes // // 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}) // // return // // } // // if everything is missing we send false // res.status(200).json({success: false,message: `Missing either lane name or lane id.`}) // }) // export default router