feat(ocmeserver): the server was just migrated so it can be upgraded to lstv2
This commit is contained in:
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