new apis
This commit is contained in:
parent
f3cbadebd7
commit
11cf57c4d1
@ -52,6 +52,40 @@ export class APPLICATIONNAME_DTO {
|
||||
P_APPLICATIONNAME: string;
|
||||
}
|
||||
|
||||
export class GOODS_PORT_DTO {
|
||||
@ApiProperty({ required: true })
|
||||
@IsString({ message: 'Property P_GOODSPORT must be a string' })
|
||||
@IsDefined({ message: 'Property P_GOODSPORT is required' })
|
||||
P_GOODSPORT: string;
|
||||
}
|
||||
|
||||
export class GOODS_COUNTRY_DTO {
|
||||
@ApiProperty({ required: true })
|
||||
@IsString({ message: 'Property P_GOODSCOUNTRY must be a string' })
|
||||
@IsDefined({ message: 'Property P_GOODSCOUNTRY is required' })
|
||||
P_GOODSCOUNTRY: string;
|
||||
}
|
||||
|
||||
export class REASON_CODE_DTO {
|
||||
@ApiProperty({ required: true })
|
||||
@IsString({ message: 'Property P_REASONCODE must be a string' })
|
||||
@IsDefined({ message: 'Property P_REASONCODE is required' })
|
||||
P_REASONCODE: string;
|
||||
}
|
||||
|
||||
export class EXTENSION_PERIOD_DTO {
|
||||
@ApiProperty({ required: true })
|
||||
@Max(999999999, {
|
||||
message: 'Property P_EXTENSIONPERIOD must not exceed 999999999',
|
||||
})
|
||||
@Min(0, { message: 'Property P_EXTENSIONPERIOD must be at least 0 or more' })
|
||||
@IsInt({ message: 'Property P_EXTENSIONPERIOD allows only whole numbers' })
|
||||
@IsNumber({}, { message: 'Property P_EXTENSIONPERIOD must be a number' })
|
||||
@Transform(({ value }) => Number(value))
|
||||
@IsDefined({ message: 'Property P_EXTENSIONPERIOD is required' })
|
||||
P_EXTENSIONPERIOD: number;
|
||||
}
|
||||
|
||||
export class ORDERTYPE_DTO {
|
||||
@ApiProperty({ required: true })
|
||||
@IsString({ message: 'Property P_ORDERTYPE must be a string' })
|
||||
@ -170,6 +204,52 @@ export class GLTABLE_ROW_DTO {
|
||||
GOODSORIGINCOUNTRY: string;
|
||||
}
|
||||
|
||||
export class GLTABLE_ROW_ADD_DTO {
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@MaxLength(200, { message: 'Property ITEMDESCRIPTION must not exceed 200 characters' })
|
||||
@IsString({ message: 'Property ITEMDESCRIPTION must be a string' })
|
||||
@IsDefined({ message: 'Property ITEMDESCRIPTION is required' })
|
||||
ITEMDESCRIPTION: string;
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@Max(999999999.99, { message: 'Property ITEMVALUE must not exceed 999999999.99' })
|
||||
@Min(0, { message: 'Property ITEMVALUE must be at least 0 or more' })
|
||||
@Transform(({ value }) => Number(value))
|
||||
@IsNumber({ maxDecimalPlaces: 2 }, { message: 'Property ITEMVALUE must be a number' })
|
||||
@IsDefined({ message: 'Property ITEMVALUE is required' })
|
||||
ITEMVALUE: number;
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@Max(99999, { message: 'Property NOOFPIECES must not exceed 99999' })
|
||||
@Min(0, { message: 'Property NOOFPIECES must be at least 0 or more' })
|
||||
@IsInt({ message: 'Property NOOFPIECES allows only whole numbers' })
|
||||
@Transform(({ value }) => Number(value))
|
||||
@IsNumber({}, { message: 'Property NOOFPIECES must be a number' })
|
||||
@IsDefined({ message: 'Property NOOFPIECES is required' })
|
||||
NOOFPIECES: number;
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@Max(99999.9999, { message: 'Property ITEMVALUE must not exceed 999999999.99' })
|
||||
@Min(0, { message: 'Property ITEMVALUE must be at least 0 or more' })
|
||||
@Transform(({ value }) => Number(value))
|
||||
@IsNumber({ maxDecimalPlaces: 2 }, { message: 'Property ITEMVALUE must be a number' })
|
||||
@IsDefined({ message: 'Property ITEMVALUE is required' })
|
||||
ITEMWEIGHT: number;
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@MaxLength(10, { message: 'Property ITEMWEIGHTUOM must not exceed 10 characters' })
|
||||
@IsString({ message: 'Property ITEMWEIGHTUOM must be a string' })
|
||||
@IsDefined({ message: 'Property ITEMWEIGHTUOM is required' })
|
||||
ITEMWEIGHTUOM: string;
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@MaxLength(2, { message: 'Property GOODSORIGINCOUNTRY must not exceed 2 characters' })
|
||||
@IsString({ message: 'Property GOODSORIGINCOUNTRY must be a string' })
|
||||
@IsDefined({ message: 'Property GOODSORIGINCOUNTRY is required' })
|
||||
GOODSORIGINCOUNTRY: string;
|
||||
}
|
||||
|
||||
export class GLTABLE_DTO {
|
||||
@ApiProperty({ required: true, type: () => [GLTABLE_ROW_DTO] })
|
||||
@Type(() => GLTABLE_ROW_DTO)
|
||||
@ -179,7 +259,16 @@ export class GLTABLE_DTO {
|
||||
P_GLTABLE: GLTABLE_ROW_DTO[];
|
||||
}
|
||||
|
||||
export class ITEMNO_DTO{
|
||||
export class GLTABLE_ITEMNO_OPTIONAL_DTO{
|
||||
@ApiProperty({ required: true, type: () => [GLTABLE_ROW_ADD_DTO] })
|
||||
@Type(() => GLTABLE_ROW_ADD_DTO)
|
||||
@ValidateNested({ each: true })
|
||||
@IsArray({ message: 'Property P_GLTABLE allows only array type' })
|
||||
@IsDefined({ message: 'Property P_GLTABLE is required' })
|
||||
P_GLTABLE: GLTABLE_ROW_ADD_DTO[];
|
||||
}
|
||||
|
||||
export class ITEMNO_DTO {
|
||||
@ApiProperty({ required: true })
|
||||
@Max(99999, { message: 'Property ITEMNO must not exceed 99999' })
|
||||
@Min(0, { message: 'Property ITEMNO must be at least 0 or more' })
|
||||
@ -190,7 +279,7 @@ export class ITEMNO_DTO{
|
||||
P_ITEMNO: number;
|
||||
}
|
||||
|
||||
export class SHIPCONTACTID_DTO{
|
||||
export class SHIPCONTACTID_DTO {
|
||||
@ApiProperty({ required: true })
|
||||
@Max(99999, { message: 'Property P_SHIPCONTACTID must not exceed 99999' })
|
||||
@Min(0, { message: 'Property P_SHIPCONTACTID must be at least 0 or more' })
|
||||
|
||||
@ -3,10 +3,10 @@ import { IntersectionType, PartialType } from "@nestjs/swagger";
|
||||
import {
|
||||
APPLICATIONNAME_DTO, AUTHREP_DTO, AUTO_FLAG_DTO, COMMERCIAL_SAMPLE_FLAG_DTO,
|
||||
COUNTRYTABLE_DTO, CUSTCOURIERNO_DTO, DELIVERYMETHOD_DTO, DELIVERYTYPE_DTO,
|
||||
EXIBITIONS_FAIR_FLAG_DTO, FORMOFSECURITY_DTO, GLTABLE_DTO, HEADERID_DTO,
|
||||
EXIBITIONS_FAIR_FLAG_DTO, EXTENSION_PERIOD_DTO, FORMOFSECURITY_DTO, GLTABLE_DTO, GLTABLE_ITEMNO_OPTIONAL_DTO, GOODS_COUNTRY_DTO, GOODS_PORT_DTO, HEADERID_DTO,
|
||||
HORSE_FLAG_DTO, INSPROTECTION_DTO, ITEMNO_DTO, LDIPROTECTION_DTO, ORDERTYPE_DTO, PAYMENTMETHOD_DTO,
|
||||
PRINTGL_DTO,
|
||||
PROF_EQUIPMENT_FLAG_DTO, REFNO_DTO, SHIPADDRID_DTO, SHIPCONTACTID_DTO, SHIPNAME_DTO, SHIPTOTYPE_DTO, USSETS_DTO
|
||||
PROF_EQUIPMENT_FLAG_DTO, REASON_CODE_DTO, REFNO_DTO, SHIPADDRID_DTO, SHIPCONTACTID_DTO, SHIPNAME_DTO, SHIPTOTYPE_DTO, USSETS_DTO
|
||||
} from "./carnet-application-property.dto";
|
||||
|
||||
import { ADDRESS1_DTO, ADDRESS2_DTO, CITY_DTO, COUNTRY_DTO, NOTES_DTO, SPID_DTO, STATE_DTO, USERID_DTO, ZIP_DTO } from "../uscib-managed-sp/sp/sp-property.dto";
|
||||
@ -52,8 +52,18 @@ export class TransmitApplicationtoProcessDTO extends IntersectionType(
|
||||
) { }
|
||||
|
||||
// processing [ PROCESSINGCENTER_PKG ]
|
||||
|
||||
export class CopyCarnetDTO extends (IntersectionType(USERID_DTO, HEADERID_DTO, APPLICATIONNAME_DTO)) { }
|
||||
export class CarnetProcessingCenterDTO extends (IntersectionType(USERID_DTO, HEADERID_DTO)) { }
|
||||
export class GetExtendedSectionDTO extends (IntersectionType(SPID_DTO, HEADERID_DTO)){}
|
||||
export class SaveExtensionApplicationDTO extends(IntersectionType(
|
||||
USERID_DTO,
|
||||
SPID_DTO,
|
||||
HEADERID_DTO,
|
||||
GOODS_PORT_DTO,
|
||||
GOODS_COUNTRY_DTO,
|
||||
REASON_CODE_DTO,
|
||||
EXTENSION_PERIOD_DTO
|
||||
)){}
|
||||
|
||||
export class PrintCarnetDTO extends (IntersectionType(SPID_DTO, HEADERID_DTO, PRINTGL_DTO)) { }
|
||||
export class PrintGLDTO extends (IntersectionType(SPID_DTO, HEADERID_DTO)) { }
|
||||
@ -74,6 +84,10 @@ export class UpdateExpGoodsAuthRepDTO extends IntersectionType(
|
||||
) { }
|
||||
|
||||
export class AddGenerallistItemsDTO extends IntersectionType(
|
||||
HEADERID_DTO, GLTABLE_ITEMNO_OPTIONAL_DTO, USERID_DTO
|
||||
) { }
|
||||
|
||||
export class EditGenerallistItemsDTO extends IntersectionType(
|
||||
HEADERID_DTO, GLTABLE_DTO, USERID_DTO
|
||||
) { }
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BadRequestException, Body, Controller, Delete, Get, Param, Patch, Post, Put, Res, StreamableFile, UseGuards } from '@nestjs/common';
|
||||
import { BadRequestException, Body, Controller, Delete, Get, HttpCode, Param, Patch, Post, Put, Res, StreamableFile, UseGuards } from '@nestjs/common';
|
||||
import { CarnetApplicationService } from './carnet-application.service';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
|
||||
@ -7,7 +7,7 @@ import {
|
||||
AddCountriesDTO,
|
||||
AddGenerallistItemsDTO,
|
||||
CA_UpdateHolderDTO,
|
||||
CarnetProcessingCenterDTO, CreateApplicationDTO, DeleteGenerallistItemsDTO, GetCarnetControlCenterDTO, PrintCarnetDTO, PrintGLDTO, SaveCarnetApplicationDTO, TransmitApplicationtoProcessDTO,
|
||||
CarnetProcessingCenterDTO, CopyCarnetDTO, CreateApplicationDTO, DeleteGenerallistItemsDTO, EditGenerallistItemsDTO, GetCarnetControlCenterDTO, GetExtendedSectionDTO, PrintCarnetDTO, PrintGLDTO, SaveCarnetApplicationDTO, SaveExtensionApplicationDTO, TransmitApplicationtoProcessDTO,
|
||||
UpdateExpGoodsAuthRepDTO,
|
||||
UpdateShippingDetailsDTO
|
||||
} from 'src/dto/property.dto';
|
||||
@ -70,7 +70,7 @@ export class CarnetApplicationController {
|
||||
}
|
||||
|
||||
@Put('EditGenerallistItems')
|
||||
EditGenerallistItems(@Body() body: AddGenerallistItemsDTO) {
|
||||
EditGenerallistItems(@Body() body: EditGenerallistItemsDTO) {
|
||||
return this.carnetApplicationService.EditGenerallistItems(body);
|
||||
}
|
||||
|
||||
@ -106,13 +106,39 @@ export class CarnetApplicationController {
|
||||
VoidCarnet(@Body() body: CarnetProcessingCenterDTO) {
|
||||
return this.carnetApplicationService.VoidCarnet(body);
|
||||
}
|
||||
|
||||
|
||||
@Patch('CopyCarnet')
|
||||
CopyCarnet(@Body() body: CopyCarnetDTO) {
|
||||
return this.carnetApplicationService.CopyCarnet(body);
|
||||
}
|
||||
|
||||
@Patch('DuplicateCarnet')
|
||||
@Roles('ca')
|
||||
DuplicateCarnet(@Body() body: CarnetProcessingCenterDTO) {
|
||||
return this.carnetApplicationService.DuplicateCarnet(body);
|
||||
}
|
||||
|
||||
@Patch('AddlSets')
|
||||
AddlSets(@Body() body: CarnetProcessingCenterDTO) {
|
||||
return this.carnetApplicationService.AddlSets(body);
|
||||
}
|
||||
|
||||
@Patch('ExtendCarnet')
|
||||
ExtendCarnet(@Body() body: CarnetProcessingCenterDTO) {
|
||||
return this.carnetApplicationService.ExtendCarnet(body);
|
||||
}
|
||||
|
||||
@Get('GetExtendedSection/:P_SPID/:P_HEADERID')
|
||||
GetExtendedSection(@Param() body: GetExtendedSectionDTO) {
|
||||
return this.carnetApplicationService.GetExtendedSection(body);
|
||||
}
|
||||
|
||||
@Post('SaveExtensionApplication')
|
||||
@HttpCode(200)
|
||||
SaveExtensionApplication(@Body() body: SaveExtensionApplicationDTO) {
|
||||
return this.carnetApplicationService.SaveExtensionApplication(body);
|
||||
}
|
||||
|
||||
@Patch('CloseCarnet')
|
||||
@Roles('sa')
|
||||
CloseCarnet(@Body() body: CarnetProcessingCenterDTO) {
|
||||
@ -158,7 +184,7 @@ export class CarnetApplicationController {
|
||||
|
||||
// [PRINT_PKG]
|
||||
@Post('PrintCarnet')
|
||||
@Roles('ca', 'sa', 'ua')
|
||||
@HttpCode(200)
|
||||
async PrintCarnet(@Body() body: PrintCarnetDTO, @Res({ passthrough: true }) res: Response) {
|
||||
|
||||
try {
|
||||
@ -203,7 +229,7 @@ export class CarnetApplicationController {
|
||||
}
|
||||
|
||||
@Post('PrintGL')
|
||||
@Roles('ca', 'sa', 'ua')
|
||||
@HttpCode(200)
|
||||
async PrintGL(@Body() body: PrintGLDTO, @Res({ passthrough: true }) res: Response) {
|
||||
try {
|
||||
const { finalArray, carnetData }: any = await this.carnetApplicationService.PrintGL(body);
|
||||
|
||||
@ -16,7 +16,10 @@ import {
|
||||
DeleteGenerallistItemsDTO,
|
||||
PrintCarnetDTO,
|
||||
PrintGLDTO,
|
||||
YON
|
||||
YON,
|
||||
CopyCarnetDTO,
|
||||
GetExtendedSectionDTO,
|
||||
SaveExtensionApplicationDTO
|
||||
} from 'src/dto/property.dto';
|
||||
import { OracleService } from '../oracle.service';
|
||||
import { BadRequestException } from 'src/exceptions/badRequest.exception';
|
||||
@ -327,7 +330,7 @@ export class CarnetApplicationService {
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
|
||||
const GLTABLE_INSTANCE = await this.oracleService.get_GL_TABLE_INSTANCE(body);
|
||||
const GLTABLE_INSTANCE = await this.oracleService.get_GL_TABLE_OPTIONAL_ITEMNO_INSTANCE(body);
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
@ -750,6 +753,50 @@ export class CarnetApplicationService {
|
||||
await closeOracleDbConnection(connection, CarnetApplicationService.name)
|
||||
}
|
||||
}
|
||||
|
||||
async CopyCarnet(body: CopyCarnetDTO) {
|
||||
let connection;
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
PROCESSINGCENTER_PKG.CopyCarnet(
|
||||
:P_USERID, :P_HEADERID, :P_APPLICATIONNAME, :P_CURSOR
|
||||
);
|
||||
END;`,
|
||||
{
|
||||
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
|
||||
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
|
||||
P_APPLICATIONNAME: { val: body.P_APPLICATIONNAME, type: oracledb.DB_TYPE_NVARCHAR },
|
||||
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
|
||||
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
|
||||
await connection.commit();
|
||||
|
||||
const outBinds = result.outBinds;
|
||||
if (!outBinds?.P_CURSOR) {
|
||||
this.logger.error('One or more expected cursors are missing from stored procedure output.');
|
||||
throw new InternalServerException("Incomplete data received from the database.");
|
||||
}
|
||||
|
||||
const fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name);
|
||||
|
||||
if (fres.length > 0 && fres[0].ERRORMESG) {
|
||||
this.logger.warn(fres[0].ERRORMESG);
|
||||
throw new BadRequestException(fres[0].ERRORMESG)
|
||||
}
|
||||
|
||||
return { statusCode: 200, message: "Copied Successfully", ...fres[0] };
|
||||
} catch (error) {
|
||||
handleError(error, CarnetApplicationService.name)
|
||||
} finally {
|
||||
await closeOracleDbConnection(connection, CarnetApplicationService.name)
|
||||
}
|
||||
}
|
||||
async DuplicateCarnet(body: CarnetProcessingCenterDTO) {
|
||||
let connection;
|
||||
try {
|
||||
@ -792,6 +839,181 @@ export class CarnetApplicationService {
|
||||
await closeOracleDbConnection(connection, CarnetApplicationService.name)
|
||||
}
|
||||
}
|
||||
async AddlSets(body: CarnetProcessingCenterDTO) {
|
||||
let connection;
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
PROCESSINGCENTER_PKG.AddlSets(
|
||||
:P_USERID, :P_HEADERID, :P_CURSOR
|
||||
);
|
||||
END;`,
|
||||
{
|
||||
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
|
||||
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
|
||||
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
|
||||
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
|
||||
await connection.commit();
|
||||
|
||||
const outBinds = result.outBinds;
|
||||
if (!outBinds?.P_CURSOR) {
|
||||
this.logger.error('One or more expected cursors are missing from stored procedure output.');
|
||||
throw new InternalServerException("Incomplete data received from the database.");
|
||||
}
|
||||
|
||||
const fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name);
|
||||
|
||||
if (fres.length > 0 && fres[0].ERRORMESG) {
|
||||
this.logger.warn(fres[0].ERRORMESG);
|
||||
throw new BadRequestException(fres[0].ERRORMESG)
|
||||
}
|
||||
|
||||
return { statusCode: 200, message: "Additional sets completed", ...fres[0] };
|
||||
} catch (error) {
|
||||
handleError(error, CarnetApplicationService.name)
|
||||
} finally {
|
||||
await closeOracleDbConnection(connection, CarnetApplicationService.name)
|
||||
}
|
||||
}
|
||||
async ExtendCarnet(body: CarnetProcessingCenterDTO) {
|
||||
let connection;
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
PROCESSINGCENTER_PKG.ExtendCarnet(
|
||||
:P_USERID, :P_HEADERID, :P_CURSOR
|
||||
);
|
||||
END;`,
|
||||
{
|
||||
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
|
||||
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
|
||||
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
|
||||
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
|
||||
await connection.commit();
|
||||
|
||||
const outBinds = result.outBinds;
|
||||
if (!outBinds?.P_CURSOR) {
|
||||
this.logger.error('One or more expected cursors are missing from stored procedure output.');
|
||||
throw new InternalServerException("Incomplete data received from the database.");
|
||||
}
|
||||
|
||||
const fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name);
|
||||
|
||||
if (fres.length > 0 && fres[0].ERRORMESG) {
|
||||
this.logger.warn(fres[0].ERRORMESG);
|
||||
throw new BadRequestException(fres[0].ERRORMESG)
|
||||
}
|
||||
|
||||
return { statusCode: 200, message: "Extended successfully", ...fres[0] };
|
||||
} catch (error) {
|
||||
handleError(error, CarnetApplicationService.name)
|
||||
} finally {
|
||||
await closeOracleDbConnection(connection, CarnetApplicationService.name)
|
||||
}
|
||||
}
|
||||
async GetExtendedSection(body: GetExtendedSectionDTO) {
|
||||
let connection;
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
PROCESSINGCENTER_PKG.GetExtendedSection(
|
||||
:P_SPID, :P_HEADERID, :P_CURSOR
|
||||
);
|
||||
END;`,
|
||||
{
|
||||
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
|
||||
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
|
||||
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
|
||||
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
|
||||
await connection.commit();
|
||||
|
||||
const outBinds = result.outBinds;
|
||||
if (!outBinds?.P_CURSOR) {
|
||||
this.logger.error('One or more expected cursors are missing from stored procedure output.');
|
||||
throw new InternalServerException("Incomplete data received from the database.");
|
||||
}
|
||||
|
||||
const fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name);
|
||||
|
||||
if (fres.length > 0 && fres[0].ERRORMESG) {
|
||||
this.logger.warn(fres[0].ERRORMESG);
|
||||
throw new BadRequestException(fres[0].ERRORMESG)
|
||||
}
|
||||
|
||||
// return { statusCode: 200, message: "Extended successfully", ...fres[0] };
|
||||
return fres;
|
||||
} catch (error) {
|
||||
handleError(error, CarnetApplicationService.name)
|
||||
} finally {
|
||||
await closeOracleDbConnection(connection, CarnetApplicationService.name)
|
||||
}
|
||||
}
|
||||
async SaveExtensionApplication(body: SaveExtensionApplicationDTO) {
|
||||
let connection;
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
PROCESSINGCENTER_PKG.SaveExtensionApplication(
|
||||
:P_USERID, :P_SPID, :P_HEADERID, :P_GOODSPORT, :P_GOODSCOUNTRY, :P_REASONCODE, :P_EXTENSIONPERIOD, :P_CURSOR
|
||||
);
|
||||
END;`,
|
||||
{
|
||||
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
|
||||
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
|
||||
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
|
||||
P_GOODSPORT: { val: body.P_GOODSPORT, type: oracledb.DB_TYPE_NVARCHAR },
|
||||
P_GOODSCOUNTRY: { val: body.P_GOODSCOUNTRY, type: oracledb.DB_TYPE_NVARCHAR },
|
||||
P_REASONCODE: { val: body.P_REASONCODE, type: oracledb.DB_TYPE_NVARCHAR },
|
||||
P_EXTENSIONPERIOD: { val: body.P_EXTENSIONPERIOD, type: oracledb.DB_TYPE_NUMBER },
|
||||
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
|
||||
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
|
||||
await connection.commit();
|
||||
|
||||
const outBinds = result.outBinds;
|
||||
if (!outBinds?.P_CURSOR) {
|
||||
this.logger.error('One or more expected cursors are missing from stored procedure output.');
|
||||
throw new InternalServerException("Incomplete data received from the database.");
|
||||
}
|
||||
|
||||
const fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name);
|
||||
|
||||
if (fres.length > 0 && fres[0].ERRORMESG) {
|
||||
this.logger.warn(fres[0].ERRORMESG);
|
||||
throw new BadRequestException(fres[0].ERRORMESG)
|
||||
}
|
||||
|
||||
return { statusCode: 200, message: "Saved successfully", ...fres[0] };
|
||||
} catch (error) {
|
||||
handleError(error, CarnetApplicationService.name)
|
||||
} finally {
|
||||
await closeOracleDbConnection(connection, CarnetApplicationService.name)
|
||||
}
|
||||
}
|
||||
|
||||
async CloseCarnet(body: CarnetProcessingCenterDTO) {
|
||||
let connection;
|
||||
try {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Injectable, Logger } from "@nestjs/common";
|
||||
import { OracleDBService } from "src/db/db.service";
|
||||
import { CLIENTLOCADDRESSTABLE_ROW_DTO, CONTACTSTABLE_ROW_DTO, COUNTRYTABLE_DTO, COUNTRYTABLE_ROW_DTO, GLTABLE_DTO, GLTABLE_ROW_DTO } from "src/dto/property.dto";
|
||||
import { CLIENTLOCADDRESSTABLE_ROW_DTO, CONTACTSTABLE_ROW_DTO, COUNTRYTABLE_DTO, COUNTRYTABLE_ROW_DTO, GLTABLE_DTO, GLTABLE_ITEMNO_OPTIONAL_DTO, GLTABLE_ROW_ADD_DTO, GLTABLE_ROW_DTO } from "src/dto/property.dto";
|
||||
import { InternalServerException } from "src/exceptions/internalServerError.exception";
|
||||
import { closeOracleDbConnection, handleError } from "src/utils/helper";
|
||||
|
||||
@ -10,6 +10,61 @@ export class OracleService {
|
||||
|
||||
constructor(private readonly oracleDBService: OracleDBService) { }
|
||||
|
||||
async get_GL_TABLE_OPTIONAL_ITEMNO_INSTANCE(finalBody: any) {
|
||||
|
||||
// P_GLTABLE: { val: GLTABLE_INSTANCE, type: 'CARNETSYS.GLTABLE' }
|
||||
// P_GLTABLE: { val: GLTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT }
|
||||
|
||||
let connection;
|
||||
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
|
||||
const GLTABLE = await connection.getDbObjectClass('CARNETSYS.GLTABLE');
|
||||
|
||||
if (typeof GLTABLE !== 'function') {
|
||||
throw new InternalServerException('GLTABLE is not a constructor');
|
||||
}
|
||||
|
||||
async function createGLArrayInstance(
|
||||
ITEMDESCRIPTION, ITEMVALUE, NOOFPIECES,
|
||||
ITEMWEIGHT, ITEMWEIGHTUOM, GOODSORIGINCOUNTRY,
|
||||
) {
|
||||
const result = await connection.execute(
|
||||
`SELECT CARNETSYS.GLARRAY(
|
||||
:ITEMDESCRIPTION, :ITEMVALUE, :NOOFPIECES,
|
||||
:ITEMWEIGHT, :ITEMWEIGHTUOM, :GOODSORIGINCOUNTRY
|
||||
) FROM dual`,
|
||||
{
|
||||
ITEMDESCRIPTION, ITEMVALUE, NOOFPIECES,
|
||||
ITEMWEIGHT, ITEMWEIGHTUOM, GOODSORIGINCOUNTRY,
|
||||
}
|
||||
);
|
||||
return result.rows[0][0];
|
||||
}
|
||||
|
||||
const GLTABLE_ARRAY: GLTABLE_ITEMNO_OPTIONAL_DTO = {
|
||||
P_GLTABLE: await Promise.all(
|
||||
(finalBody.P_GLTABLE ?? []).map(async (x: GLTABLE_ROW_ADD_DTO) => {
|
||||
return await createGLArrayInstance(
|
||||
x.ITEMDESCRIPTION, x.ITEMVALUE, x.NOOFPIECES,
|
||||
x.ITEMWEIGHT, x.ITEMWEIGHTUOM, x.GOODSORIGINCOUNTRY,
|
||||
);
|
||||
})
|
||||
)
|
||||
};
|
||||
|
||||
const GLTABLE_INSTANCE = new GLTABLE(GLTABLE_ARRAY.P_GLTABLE ?? []);
|
||||
|
||||
return GLTABLE_INSTANCE;
|
||||
|
||||
} catch (error) {
|
||||
throw new Error("Error occured completing this process")
|
||||
} finally {
|
||||
await closeOracleDbConnection(connection, OracleService.name)
|
||||
}
|
||||
}
|
||||
|
||||
async get_GL_TABLE_INSTANCE(finalBody: any) {
|
||||
|
||||
// P_GLTABLE: { val: GLTABLE_INSTANCE, type: 'CARNETSYS.GLTABLE' }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user