updated array to handle

This commit is contained in:
Kallesh B S 2025-03-29 10:28:51 +05:30
parent 76a07a0451
commit 6fc32672f5
2 changed files with 25 additions and 44 deletions

View File

@ -471,13 +471,11 @@ export class HomePageService {
// let res = await connection.execute(`SELECT owner, type_name FROM all_types WHERE type_name IN ('GLARRAY', 'GLTABLE')`)
let GLARRAY = await connection.getDbObjectClass('CARNETSYS.GLARRAY');
// let GLARRAY = await connection.getDbObjectClass('CARNETSYS.GLARRAY');
const GLTABLE = await connection.getDbObjectClass('CARNETSYS.GLTABLE');
const CARNETCOUNTRYARRAY = await connection.getDbObjectClass('CARNETSYS.CARNETCOUNTRYARRAY');
// const CARNETCOUNTRYARRAY = await connection.getDbObjectClass('CARNETSYS.CARNETCOUNTRYARRAY');
const CARNETCOUNTRYTABLE = await connection.getDbObjectClass('CARNETSYS.CARNETCOUNTRYTABLE');
console.log("here ------------ 2");
// Check if GLTABLE is a constructor
if (typeof GLTABLE !== 'function') {
throw new Error('GLTABLE is not a constructor');
@ -487,45 +485,17 @@ export class HomePageService {
throw new Error('CARNETCOUNTRYTABLE is not a constructor');
}
console.log("here ------------ 3");
// console.log(finalBody);
let k = new GLARRAY(1, 'Description for itemno 1', 2500, 20,12,'LBS','US')
// return {k}
const GLTABLE_ARRAY = finalBody.p_gltable ? await Promise.all(finalBody.p_gltable.map(async (x:p_gltableDTO) => {
return await createGLArrayInstance(connection, x.ItemNo, x.ItemDescription, x.ItemValue, x.Noofpieces, x.ItemWeight, x.ItemWeightUOM, x.GoodsOriginCountry);
})) : [];
console.log("here ------------ 4");
const CARNETCOUNTRYTABLE_ARRAY = finalBody.p_countrytable ? await Promise.all(finalBody.p_countrytable.map(async (x) => {
return await createCarnetCountryArrayInstance(connection, x.VisitTransitInd, x.CountryCode, x.NoOfTimesEntLeave);
})) : [];
console.log("CARNETCOUNTRYTABLE_ARRAY : ", CARNETCOUNTRYTABLE_ARRAY[0], CARNETCOUNTRYTABLE_ARRAY[1]);
console.log("here ------------ 5");
// Create an instance of GLTABLE
const GLTABLE_INSTANCE = new GLTABLE(GLTABLE_ARRAY);
const CARNETCOUNTRYTABLE_INSTANCE = new CARNETCOUNTRYTABLE(CARNETCOUNTRYTABLE_ARRAY);
console.log(finalBody);
console.log(GLTABLE_INSTANCE);
console.log(CARNETCOUNTRYTABLE_INSTANCE);
console.log("here ------------ 6");
// return { GLTABLE_INSTANCE, CARNETCOUNTRYTABLE_INSTANCE };
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.SaveCarnetApplication(
@ -679,8 +649,6 @@ export class HomePageService {
);
await connection.commit();
// let fres = await result.outBinds.P_cursor.getRows();
if (result.outBinds && result.outBinds.P_cursor) {
const cursor = result.outBinds.P_cursor;
let rowsBatch;
@ -698,8 +666,6 @@ export class HomePageService {
return rows;
// return fres
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }

View File

@ -56,14 +56,11 @@ export class ManageHoldersService {
throw new Error('No DB Connected')
}
// let res = await connection.execute(`SELECT owner, type_name FROM all_types WHERE type_name IN ('GLARRAY', 'GLTABLE')`)
// let res = await connection.execute(`SELECT owner, type_name FROM all_types WHERE type_name LIKE '%CONTACT%'`);
// return { res:res.rows };
// contactstable
const CONTACTSARRAY = await connection.getDbObjectClass('CARNETSYS.CONTACTSARRAY');
// const CONTACTSARRAY = await connection.getDbObjectClass('CARNETSYS.CONTACTSARRAY');
const CONTACTSTABLE = await connection.getDbObjectClass('CARNETSYS.CONTACTSTABLE');
// Check if GLTABLE is a constructor
@ -71,12 +68,29 @@ export class ManageHoldersService {
throw new Error('CONTACTSTABLE is not a constructor');
}
const CONTACTSTABLE_ARRAY = finalBody.p_contactstable ? finalBody.p_contactstable.map((x: p_contactstableDTO) => {
return new CONTACTSARRAY(x.FirstName, x.LastName, x.MiddleInitial, x.Title, x.EmailAddress, x.PhoneNo, x.MobileNo, x.FaxNo)
}) : [];
async function CREATECONTACTSTABLE_INSTANCE(connection, FirstName, LastName, MiddleInitial, Title, EmailAddress, PhoneNo, MobileNo, FaxNo) {
const result = await connection.execute(
`SELECT CARNETSYS.CONTACTSARRAY(:FirstName, :LastName, :MiddleInitial, :Title, :EmailAddress, :PhoneNo, :MobileNo, :FaxNo) FROM dual`,
{
FirstName,
LastName,
MiddleInitial,
Title,
EmailAddress,
PhoneNo,
MobileNo,
FaxNo
}
);
return result.rows[0][0];
}
const CONTACTSARRAY = finalBody.p_contactstable ? await Promise.all(finalBody.p_contactstable.map(async (x: p_contactstableDTO) => {
return await CREATECONTACTSTABLE_INSTANCE(connection, x.FirstName, x.LastName, x.MiddleInitial, x.Title, x.EmailAddress, x.PhoneNo, x.MobileNo, x.FaxNo);
})) : [];
// Create an instance of GLTABLE
const CONTACTSTABLE_INSTANCE = new CONTACTSTABLE(CONTACTSTABLE_ARRAY);
const CONTACTSTABLE_INSTANCE = new CONTACTSTABLE(CONTACTSARRAY);
const result = await connection.execute(
`BEGIN
@ -184,6 +198,7 @@ export class ManageHoldersService {
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
// let fres = await result.outBinds.P_cursor.getRows();