Compare commits
6 Commits
43ca16dc80
...
8fb06c71d3
| Author | SHA1 | Date | |
|---|---|---|---|
| 8fb06c71d3 | |||
| e258aaead9 | |||
| 491de26a0b | |||
| f1979f0fc9 | |||
| f4433f4192 | |||
| bff0e77766 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,6 +8,7 @@ builds
|
|||||||
nssm.exe
|
nssm.exe
|
||||||
backend-0.1.2-217.zip
|
backend-0.1.2-217.zip
|
||||||
backend-0.1.2-218.zip
|
backend-0.1.2-218.zip
|
||||||
|
backend-0.1.2.zip
|
||||||
postgresql-17.2-3-windows-x64.exe
|
postgresql-17.2-3-windows-x64.exe
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,16 @@ const fetchSession = async () => {
|
|||||||
});
|
});
|
||||||
// console.log(res);
|
// console.log(res);
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
|
localStorage.removeItem("auth_token");
|
||||||
|
// remove these for a while if no session just until fully to 2.0 and clearly no one has ran lstv1 in a long time
|
||||||
|
localStorage.removeItem("ally-supports-cache");
|
||||||
|
localStorage.removeItem("auth-storage");
|
||||||
|
localStorage.removeItem("nextauth.message");
|
||||||
|
localStorage.removeItem("prod");
|
||||||
|
localStorage.removeItem("cards");
|
||||||
|
localStorage.removeItem("rememberMe");
|
||||||
|
localStorage.removeItem("username");
|
||||||
|
|
||||||
throw new Error("Session not found");
|
throw new Error("Session not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
46
package-lock.json
generated
46
package-lock.json
generated
@@ -23,11 +23,11 @@
|
|||||||
"drizzle-kit": "^0.30.4",
|
"drizzle-kit": "^0.30.4",
|
||||||
"drizzle-orm": "^0.39.3",
|
"drizzle-orm": "^0.39.3",
|
||||||
"drizzle-zod": "^0.7.0",
|
"drizzle-zod": "^0.7.0",
|
||||||
|
"fast-xml-parser": "^5.0.9",
|
||||||
"jsonwebtoken": "^9.0.2",
|
"jsonwebtoken": "^9.0.2",
|
||||||
"mssql": "^11.0.1",
|
"mssql": "^11.0.1",
|
||||||
"nodemailer": "^6.10.0",
|
"nodemailer": "^6.10.0",
|
||||||
"nodemailer-express-handlebars": "^7.0.0",
|
"nodemailer-express-handlebars": "^7.0.0",
|
||||||
"npm-check-updates": "^17.1.15",
|
|
||||||
"pg": "^8.13.3",
|
"pg": "^8.13.3",
|
||||||
"pino": "^9.6.0",
|
"pino": "^9.6.0",
|
||||||
"pino-abstract-transport": "^2.0.0",
|
"pino-abstract-transport": "^2.0.0",
|
||||||
@@ -5360,6 +5360,24 @@
|
|||||||
],
|
],
|
||||||
"license": "BSD-3-Clause"
|
"license": "BSD-3-Clause"
|
||||||
},
|
},
|
||||||
|
"node_modules/fast-xml-parser": {
|
||||||
|
"version": "5.0.9",
|
||||||
|
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.0.9.tgz",
|
||||||
|
"integrity": "sha512-2mBwCiuW3ycKQQ6SOesSB8WeF+fIGb6I/GG5vU5/XEptwFFhp9PE8b9O7fbs2dpq9fXn4ULR3UsfydNUCntf5A==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/NaturalIntelligence"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"strnum": "^2.0.5"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"fxparser": "src/cli/cli.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/fdir": {
|
"node_modules/fdir": {
|
||||||
"version": "6.4.3",
|
"version": "6.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.3.tgz",
|
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.3.tgz",
|
||||||
@@ -8784,20 +8802,6 @@
|
|||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/npm-check-updates": {
|
|
||||||
"version": "17.1.15",
|
|
||||||
"resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-17.1.15.tgz",
|
|
||||||
"integrity": "sha512-miATvKu5rjec/1wxc5TGDjpsucgtCHwRVZorZpDkS6NzdWXfnUWlN4abZddWb7XSijAuBNzzYglIdTm9SbgMVg==",
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"bin": {
|
|
||||||
"ncu": "build/cli.js",
|
|
||||||
"npm-check-updates": "build/cli.js"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": "^18.18.0 || >=20.0.0",
|
|
||||||
"npm": ">=8.12.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/npm-run-path": {
|
"node_modules/npm-run-path": {
|
||||||
"version": "4.0.1",
|
"version": "4.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz",
|
||||||
@@ -10645,6 +10649,18 @@
|
|||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/strnum": {
|
||||||
|
"version": "2.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/strnum/-/strnum-2.0.5.tgz",
|
||||||
|
"integrity": "sha512-YAT3K/sgpCUxhxNMrrdhtod3jckkpYwH6JAuwmUdXZsmzH1wUyzTMrrK2wYCEEqlKwrWDd35NeuUkbBy/1iK+Q==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/NaturalIntelligence"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/style-mod": {
|
"node_modules/style-mod": {
|
||||||
"version": "4.1.2",
|
"version": "4.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.2.tgz",
|
||||||
|
|||||||
@@ -18,7 +18,8 @@
|
|||||||
"db:dev": "npm run build && npm run db:generate && npm run db:migrate",
|
"db:dev": "npm run build && npm run db:generate && npm run db:migrate",
|
||||||
"deploy": "standard-version --conventional-commits && npm run prodBuild",
|
"deploy": "standard-version --conventional-commits && npm run prodBuild",
|
||||||
"zipServer": "dotenvx run -f .env -- tsx server/scripts/zipUpBuild.ts \"C:\\Users\\matthes01\\Documents\\lstv2\"",
|
"zipServer": "dotenvx run -f .env -- tsx server/scripts/zipUpBuild.ts \"C:\\Users\\matthes01\\Documents\\lstv2\"",
|
||||||
"prodBuild": "powershell -ExecutionPolicy Bypass -File server/scripts/build.ps1 -dir \"C:\\Users\\matthes01\\Documents\\lstv2\" && npm run zipServer",
|
"v1Build": "cd C:\\Users\\matthes01\\Documents\\logisticsSupportTool && npm run oldBuilder",
|
||||||
|
"prodBuild": "npm run v1Build && powershell -ExecutionPolicy Bypass -File server/scripts/build.ps1 -dir \"C:\\Users\\matthes01\\Documents\\lstv2\" && npm run zipServer",
|
||||||
"commit": "cz",
|
"commit": "cz",
|
||||||
"prodinstall": "npm i --omit=dev && npm run db:migrate",
|
"prodinstall": "npm i --omit=dev && npm run db:migrate",
|
||||||
"checkupdates": "npm-check-updates"
|
"checkupdates": "npm-check-updates"
|
||||||
@@ -39,6 +40,7 @@
|
|||||||
"drizzle-kit": "^0.30.4",
|
"drizzle-kit": "^0.30.4",
|
||||||
"drizzle-orm": "^0.39.3",
|
"drizzle-orm": "^0.39.3",
|
||||||
"drizzle-zod": "^0.7.0",
|
"drizzle-zod": "^0.7.0",
|
||||||
|
"fast-xml-parser": "^5.0.9",
|
||||||
"jsonwebtoken": "^9.0.2",
|
"jsonwebtoken": "^9.0.2",
|
||||||
"mssql": "^11.0.1",
|
"mssql": "^11.0.1",
|
||||||
"nodemailer": "^6.10.0",
|
"nodemailer": "^6.10.0",
|
||||||
@@ -71,7 +73,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admConfig": {
|
"admConfig": {
|
||||||
"build": 22,
|
"build": 26,
|
||||||
"oldBuild": "backend-0.1.2-218.zip"
|
"oldBuild": "backend-0.1.2.zip"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
78
server/services/ocmeServer/laneUpdate/configureLanes.ts
Normal file
78
server/services/ocmeServer/laneUpdate/configureLanes.ts
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
// import {runQuery} from "../utils/sql/config/sqlConfig.js";
|
||||||
|
// /**
|
||||||
|
// * 1. Copy the Setup.xml to the desktop.
|
||||||
|
// * 2. run the createJson script.
|
||||||
|
// * 3. get the alplaprod lanes with this query select IdLagerAbteilung as id,Bezeichnung as name from [dbo].[V_LagerAbteilungen] where IdWarenLager not in (6,5) and aktiv = 1
|
||||||
|
// * 4. convert this to a json
|
||||||
|
// *
|
||||||
|
// * in the ocme data we want grab the section in each section called "clsParkingRow" this is inside the RowList. thenjust copy the array into the lanes.
|
||||||
|
// *
|
||||||
|
// */
|
||||||
|
// export const lanes = [];
|
||||||
|
|
||||||
|
// export const prodNames = [];
|
||||||
|
// const combinedInfo = [];
|
||||||
|
// const updatedLanesWithNames = lanes.map((l) => {
|
||||||
|
// //filter the prodnames out
|
||||||
|
// if (l.CustomerKey === "") {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// const names = prodNames.filter((v) => v.id === l.CustomerKey);
|
||||||
|
|
||||||
|
// if (names) {
|
||||||
|
// //console.log({...l, laneName: names[0]?.name});
|
||||||
|
// combinedInfo.push({...l, laneName: names[0]?.name});
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // get the skey from ocme
|
||||||
|
// const matcheverything = async () => {
|
||||||
|
// const query = `select SKEY as ocme_laneLevelID, id_row, id_park from [Agv_AlplaDayton].[dbo].[Park] where id_park in (4,3)`;
|
||||||
|
|
||||||
|
// const ocmeData = await runQuery(query, "lanes");
|
||||||
|
|
||||||
|
// //console.log(ocmeData)
|
||||||
|
|
||||||
|
// const ocmeToSend = [];
|
||||||
|
// const correctOcmeData = ocmeData.map((o) => {
|
||||||
|
// // filter out the prod lanes
|
||||||
|
// const prodInfo = combinedInfo.filter((f) => f.Id === o.id_row && f.ParkId === o.id_park);
|
||||||
|
|
||||||
|
// if (prodInfo.length === 0) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// if (prodInfo) {
|
||||||
|
// ocmeToSend.push({...o, laneName: prodInfo[0].laneName, laneId: prodInfo[0].CustomerKey});
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
// function delay(ms) {
|
||||||
|
// return new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //console.log(ocmeToSend)
|
||||||
|
// for (let i = 0; i < ocmeToSend.length; i++) {
|
||||||
|
// let updateQuery = `
|
||||||
|
// MERGE INTO [Alpla_Lst].[dbo].[lanes] AS target
|
||||||
|
// USING (SELECT '${ocmeToSend[i].ocme_laneLevelID}' AS ocme_laneLevelID, ${ocmeToSend[i].laneId} AS alpla_laneID, '${ocmeToSend[i].laneName}' AS alpla_laneDescription, getdate() as upd_date) AS source
|
||||||
|
// ON target.ocme_laneLevelID LIKE source.ocme_laneLevelID
|
||||||
|
// WHEN MATCHED THEN
|
||||||
|
// UPDATE SET target.alpla_laneID = source.alpla_laneID,
|
||||||
|
// target.alpla_laneDescription = source.alpla_laneDescription,
|
||||||
|
// target.upd_date = source.upd_date
|
||||||
|
// WHEN NOT MATCHED BY TARGET THEN
|
||||||
|
// INSERT (ocme_laneLevelID, alpla_laneID, alpla_laneDescription, upd_date)
|
||||||
|
// VALUES (source.ocme_laneLevelID, source.alpla_laneID, source.alpla_laneDescription, source.upd_date);
|
||||||
|
// `;
|
||||||
|
|
||||||
|
// const queryRan = await runQuery(updateQuery, "running");
|
||||||
|
// console.log(
|
||||||
|
// `${ocmeToSend[i].ocme_laneLevelID} just updated in park ${ocmeToSend[i].id_park}, remaining to update ${
|
||||||
|
// ocmeToSend.length - i
|
||||||
|
// }`
|
||||||
|
// );
|
||||||
|
// await delay(150);
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
|
// matcheverything();
|
||||||
55
server/services/ocmeServer/laneUpdate/createJson.ts
Normal file
55
server/services/ocmeServer/laneUpdate/createJson.ts
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
// import fs from "fs";
|
||||||
|
// import {XMLParser} from "fast-xml-parser";
|
||||||
|
// //const xmlData = fs.readFileSync('C:\\Users\\adm_matthes01\\Desktop\\Setup.xml', 'utf8');
|
||||||
|
|
||||||
|
// // Read the XML file as a string
|
||||||
|
// const xmlData = fs.readFileSync("C:\\Users\\adm_matthes01\\Desktop\\Setup.xml", "utf8");
|
||||||
|
|
||||||
|
// // Create a parser instance with options
|
||||||
|
// const parser = new XMLParser({
|
||||||
|
// ignoreAttributes: false, // Keep attributes in JSON
|
||||||
|
// attributeNamePrefix: "@_", // Prefix for attributes
|
||||||
|
// allowBooleanAttributes: true,
|
||||||
|
// trimValues: true,
|
||||||
|
// parseTagValue: true,
|
||||||
|
// parseAttributeValue: true,
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // Parse the XML into a JSON object
|
||||||
|
// const jsonObj = parser.parse(xmlData);
|
||||||
|
|
||||||
|
// // Convert JSON object to a formatted string
|
||||||
|
// const jsonString = JSON.stringify(jsonObj.clsAGVManagerProject.ParkingList, null, 2);
|
||||||
|
|
||||||
|
// // Write the JSON to a file
|
||||||
|
// fs.writeFileSync("large.json", jsonString, "utf8");
|
||||||
|
|
||||||
|
// console.log("JSON saved to large.json");
|
||||||
|
|
||||||
|
// fs.readFile("large.json", "utf8", (err, data) => {
|
||||||
|
// if (err) {
|
||||||
|
// console.error(err);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// const json = JSON.parse(data);
|
||||||
|
// //console.log(JSON.stringify(json[0].RowList, null, 2));
|
||||||
|
|
||||||
|
// const rowUpates = [];
|
||||||
|
// const updates = json.clsParking.map((i) => {
|
||||||
|
// // i.RowList.clsParkingRow.map(r =>{
|
||||||
|
// // rowUpates.push({id: r.Id, CustomerKey: r.CustomerKey})
|
||||||
|
// // })
|
||||||
|
// //console.log({id: i.Id,name: i. Name, lanes: i.RowList.clsParkingRow })
|
||||||
|
// rowUpates.push({id: i.Id, name: i.Name, lanes: i.RowList.clsParkingRow});
|
||||||
|
// });
|
||||||
|
// //console.log(Object.keys(json.clsAGVManagerProject.PalletCardConfigList. ParkingList.clsParking));
|
||||||
|
|
||||||
|
// //console.log(rowUpates)
|
||||||
|
// for (var i = 0; i <= 1; i++) {
|
||||||
|
// const laneID = {ID_ROW: rowUpates[i].lanes};
|
||||||
|
|
||||||
|
// if (laneID) {
|
||||||
|
// console.log(laneID.Id);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// });
|
||||||
18
server/services/ocmeServer/ocmeServerService.ts
Normal file
18
server/services/ocmeServer/ocmeServerService.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
// import express from 'express'
|
||||||
|
// import cors from "cors";
|
||||||
|
|
||||||
|
// import getLanes from './route/getLanes.js'
|
||||||
|
// import getLaneData from './route/getLaneData.js'
|
||||||
|
// const port = 3250
|
||||||
|
|
||||||
|
// const app = express()
|
||||||
|
|
||||||
|
// app.use(express.json());
|
||||||
|
// app.use(cors({origin: true, credentials: true}));
|
||||||
|
|
||||||
|
// app.use('/api/v1', getLanes)
|
||||||
|
// app.use('/api/v1', getLaneData)
|
||||||
|
|
||||||
|
// app.listen(port, ()=>{
|
||||||
|
// console.log(`Listing on port: ${port}`)
|
||||||
|
// })
|
||||||
38
server/services/ocmeServer/routes/getLaneData.ts
Normal file
38
server/services/ocmeServer/routes/getLaneData.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
// import {Router} from 'express'
|
||||||
|
// import { runQuery } from '../utils/sql/config/sqlConfig.js'
|
||||||
|
// import { ocmeInventory } from '../utils/sql/querys/getOCMEInventory.js'
|
||||||
|
|
||||||
|
// const router = Router()
|
||||||
|
|
||||||
|
// router.post('/getLaneData', async (req,res)=>{
|
||||||
|
|
||||||
|
// 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){
|
||||||
|
// filterdOCMELane = ocmeInventory.replaceAll('[lane]', data.lane)
|
||||||
|
// // 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 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
|
||||||
15
server/services/ocmeServer/routes/getLanes.ts
Normal file
15
server/services/ocmeServer/routes/getLanes.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
// import {Router} from 'express'
|
||||||
|
// import { runQuery } from '../utils/sql/config/sqlConfig.js'
|
||||||
|
// import { getLanes } from '../utils/sql/querys/getLanes.js'
|
||||||
|
|
||||||
|
// const router = Router()
|
||||||
|
|
||||||
|
// router.get('/getLanes', async (req,res)=>{
|
||||||
|
// // get lanes
|
||||||
|
// const lanes = await runQuery(getLanes, 'Getting current ocme lanes linked')
|
||||||
|
|
||||||
|
// const laneDescriptions = lanes.map(item => item.alpla_laneDescription);
|
||||||
|
// res.status(200).json({success: true,message: `All current lanes from the ocme system.`, totalLanes: lanes.length,data: laneDescriptions})
|
||||||
|
// })
|
||||||
|
|
||||||
|
// export default router
|
||||||
24
server/services/sqlServer/querys/ocme/getOcmeInventory.ts
Normal file
24
server/services/sqlServer/querys/ocme/getOcmeInventory.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
export const ocmeInventory = `
|
||||||
|
SELECT [ocme_laneLevelID]
|
||||||
|
,[alpla_laneID]
|
||||||
|
,[alpla_laneDescription]
|
||||||
|
,bob.SKU as Article
|
||||||
|
,bob.description
|
||||||
|
,bob.sscc
|
||||||
|
,bob.runningNumber
|
||||||
|
FROM [Alpla_Lst].[dbo].[lanes] (nolock) a
|
||||||
|
|
||||||
|
left JOIN
|
||||||
|
(Select p.SKEY,
|
||||||
|
x.y.value('(value)[1]', 'varchar(max)') AS sscc,
|
||||||
|
b.y.value('(value)[1]', 'varchar(max)') AS runningNumber,
|
||||||
|
k.l.value('(value)[1]', 'varchar(max)') AS SKU,
|
||||||
|
d.l.value('(value)[1]', 'varchar(max)') AS description
|
||||||
|
from Agv_AlplaDayton.dbo.Park p (nolock)
|
||||||
|
outer apply p.pallet_card.nodes('/*:ArrayOfClsPalletCard/*:clsPalletCard/*:PalletCardConfig/*:palletCardFieldList/*:clsPalletCardField[Name="SSCC"]') as x(y)
|
||||||
|
outer apply p.pallet_card.nodes('/*:ArrayOfClsPalletCard/*:clsPalletCard/*:PalletCardConfig/*:palletCardFieldList/*:clsPalletCardField[Name="RUNNING_NUMBER"]') as b(y)
|
||||||
|
outer apply p.pallet_card.nodes('/*:ArrayOfClsPalletCard/*:clsPalletCard/*:PalletCardConfig/*:palletCardFieldList/*:clsPalletCardField[Name= "SKU" ]') as k(l)
|
||||||
|
outer apply p.pallet_card.nodes('/*:ArrayOfClsPalletCard/*:clsPalletCard/*:PalletCardConfig/*:palletCardFieldList/*:clsPalletCardField[Name= "DESCRIPTION" ]') as d(l)) as bob
|
||||||
|
on a.ocme_laneLevelID = bob.SKEY
|
||||||
|
where alpla_laneDescription = '[lane]' and runningNumber > 1
|
||||||
|
`;
|
||||||
6
server/services/sqlServer/querys/ocme/getOcmeLanes.ts
Normal file
6
server/services/sqlServer/querys/ocme/getOcmeLanes.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export const getLanes = `
|
||||||
|
select DISTINCT alpla_laneDescription
|
||||||
|
from Alpla_Lst.dbo.lanes (nolock)
|
||||||
|
where alpla_laneDescription is not null
|
||||||
|
order by alpla_laneDescription desc
|
||||||
|
`;
|
||||||
48
server/services/sqlServer/utils/ocmeServerConfig.ts
Normal file
48
server/services/sqlServer/utils/ocmeServerConfig.ts
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import sql from "mssql";
|
||||||
|
|
||||||
|
// hardcoding everything to make sure it all works as intended
|
||||||
|
const server = "usday1vms010";
|
||||||
|
const dbUser = "ocme";
|
||||||
|
const dbPassword = "Democrat-Humongous";
|
||||||
|
|
||||||
|
export const sqlConfig_ocme = {
|
||||||
|
server: server,
|
||||||
|
database: `Alpla_lst`,
|
||||||
|
user: dbUser,
|
||||||
|
password: dbPassword,
|
||||||
|
options: {
|
||||||
|
encrypt: true,
|
||||||
|
trustServerCertificate: true,
|
||||||
|
},
|
||||||
|
requestTimeout: 90000, // in milliseconds
|
||||||
|
// ocmePool: {
|
||||||
|
// 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
|
||||||
|
// },
|
||||||
|
};
|
||||||
|
|
||||||
|
export async function runQuery(queryToRun: string, name: string) {
|
||||||
|
let connection;
|
||||||
|
try {
|
||||||
|
// Establish a direct connection to the different server
|
||||||
|
connection = await sql.connect(sqlConfig_ocme);
|
||||||
|
|
||||||
|
// Execute the query
|
||||||
|
const result = await connection.request().query(queryToRun);
|
||||||
|
console.log(`${name} query ran successfully on different server`);
|
||||||
|
|
||||||
|
return result.recordset;
|
||||||
|
} catch (err) {
|
||||||
|
console.log(`Error running ${name} query on different server: ${err}`);
|
||||||
|
|
||||||
|
return [];
|
||||||
|
} finally {
|
||||||
|
// Close the direct connection
|
||||||
|
if (connection) {
|
||||||
|
await connection.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user