Alterado end point api/v1/delivery/schedule para mostrar a capacidade e saldo da capacidade com 3 casas decimais e criado peso adicional para mostrar a data de entrega na abertura da venda
This commit is contained in:
@@ -1,47 +1,47 @@
|
||||
/*
|
||||
https://docs.nestjs.com/controllers#controllers
|
||||
*/
|
||||
|
||||
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
|
||||
import { DeliveryOrderModel } from 'src/domain/models/delivery-order.model';
|
||||
import { ImageOrderModel } from 'src/domain/models/image-order.model';
|
||||
import { PaymentModel } from 'src/domain/models/payment.model';
|
||||
import { DeliveryOrderService } from './delivery-order.service';
|
||||
import { ApiExcludeEndpoint } from '@nestjs/swagger';
|
||||
|
||||
@Controller('api/v1/deliveryorder')
|
||||
export class DeliveryOrderController {
|
||||
|
||||
constructor(private readonly deliveryOrderSevive: DeliveryOrderService){}
|
||||
|
||||
@Get('protocolo/:shipmentId/:customerId')
|
||||
@ApiExcludeEndpoint()
|
||||
async getdeliveryByCustomer(@Param("shipmentId") shipmentId: number, @Param("customerId") customerId: number) {
|
||||
return await this.deliveryOrderSevive.getDataDelivery(shipmentId, customerId);
|
||||
}
|
||||
|
||||
@Post('protocolo')
|
||||
@ApiExcludeEndpoint()
|
||||
async createOrReplaceDeliveryByCustomer(@Body() data: DeliveryOrderModel) {
|
||||
return await this.deliveryOrderSevive.createOrReplaceDeliveryOrder(data);
|
||||
}
|
||||
|
||||
@Get('images/:shipmentId/:orderId')
|
||||
@ApiExcludeEndpoint()
|
||||
async getImagesOrder(@Param("shipmentId") shipmentId: number, @Param("orderId") orderId: number) {
|
||||
return await this.deliveryOrderSevive.getImageOrder(shipmentId, orderId);
|
||||
}
|
||||
|
||||
@Post('image')
|
||||
@ApiExcludeEndpoint()
|
||||
async crateImageOrder(@Body() data: ImageOrderModel) {
|
||||
return await this.deliveryOrderSevive.createImageOrder(data);
|
||||
}
|
||||
|
||||
@ApiExcludeEndpoint()
|
||||
@Post('payment')
|
||||
async createPayment(@Body() data: PaymentModel) {
|
||||
return await this.deliveryOrderSevive.createPayment(data);
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
https://docs.nestjs.com/controllers#controllers
|
||||
*/
|
||||
|
||||
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
|
||||
import { DeliveryOrderModel } from 'src/domain/models/delivery-order.model';
|
||||
import { ImageOrderModel } from 'src/domain/models/image-order.model';
|
||||
import { PaymentModel } from 'src/domain/models/payment.model';
|
||||
import { DeliveryOrderService } from './delivery-order.service';
|
||||
import { ApiExcludeEndpoint } from '@nestjs/swagger';
|
||||
|
||||
@Controller('api/v1/deliveryorder')
|
||||
export class DeliveryOrderController {
|
||||
|
||||
constructor(private readonly deliveryOrderSevive: DeliveryOrderService){}
|
||||
|
||||
@Get('protocolo/:shipmentId/:customerId')
|
||||
@ApiExcludeEndpoint()
|
||||
async getdeliveryByCustomer(@Param("shipmentId") shipmentId: number, @Param("customerId") customerId: number) {
|
||||
return await this.deliveryOrderSevive.getDataDelivery(shipmentId, customerId);
|
||||
}
|
||||
|
||||
@Post('protocolo')
|
||||
@ApiExcludeEndpoint()
|
||||
async createOrReplaceDeliveryByCustomer(@Body() data: DeliveryOrderModel) {
|
||||
return await this.deliveryOrderSevive.createOrReplaceDeliveryOrder(data);
|
||||
}
|
||||
|
||||
@Get('images/:shipmentId/:orderId')
|
||||
@ApiExcludeEndpoint()
|
||||
async getImagesOrder(@Param("shipmentId") shipmentId: number, @Param("orderId") orderId: number) {
|
||||
return await this.deliveryOrderSevive.getImageOrder(shipmentId, orderId);
|
||||
}
|
||||
|
||||
@Post('image')
|
||||
@ApiExcludeEndpoint()
|
||||
async crateImageOrder(@Body() data: ImageOrderModel) {
|
||||
return await this.deliveryOrderSevive.createImageOrder(data);
|
||||
}
|
||||
|
||||
@ApiExcludeEndpoint()
|
||||
@Post('payment')
|
||||
async createPayment(@Body() data: PaymentModel) {
|
||||
return await this.deliveryOrderSevive.createPayment(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,227 +1,227 @@
|
||||
/*
|
||||
https://docs.nestjs.com/providers#services
|
||||
*/
|
||||
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Estprotocoloentrega } from 'src/domain/entity/tables/estprotocolo.entity';
|
||||
import { DeliveryOrderModel } from 'src/domain/models/delivery-order.model';
|
||||
import { ImageOrderModel } from 'src/domain/models/image-order.model';
|
||||
import { PaymentModel } from 'src/domain/models/payment.model';
|
||||
import { ResultModel } from 'src/domain/models/result.model';
|
||||
import { getConnection } from 'typeorm';
|
||||
import { Estimagemnota } from '../../domain/entity/tables/estimagemnota.entity';
|
||||
import { Estpagamento } from '../../domain/entity/tables/estpagamento.entity';
|
||||
|
||||
@Injectable()
|
||||
export class DeliveryOrderService {
|
||||
|
||||
async getDataDelivery(shipmentId: number, customerId: number): Promise<any> {
|
||||
const connection = getConnection();
|
||||
const queryRunner = connection.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
try {
|
||||
const result = await queryRunner.manager
|
||||
.getRepository(Estprotocoloentrega)
|
||||
.createQueryBuilder('estprotocoloentrega')
|
||||
.where('numcar = :numcar and codcli = :codcli', { numcar: shipmentId, codcli: customerId})
|
||||
.getOne();
|
||||
|
||||
return result; //new ResultModel(true, 'Registro localizado com sucesso!', result, {});
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return new ResultModel(false,
|
||||
'Erro ao atualizar dados de entrega.',
|
||||
null,
|
||||
error);
|
||||
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
async createOrReplaceDeliveryOrder(data: DeliveryOrderModel): Promise<any> {
|
||||
const connection = getConnection();
|
||||
const queryRunner = connection.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
await queryRunner.startTransaction();
|
||||
console.log(data);
|
||||
try {
|
||||
const updateDelivery = await queryRunner.manager
|
||||
.getRepository(Estprotocoloentrega)
|
||||
.createQueryBuilder('estprotocoloentrega')
|
||||
.where('numcar = :numcar and codcli = :codcli',
|
||||
{ numcar: data.numeroCarregamento, codcli: data.codigoCliente})
|
||||
.getOne();
|
||||
if ( updateDelivery ) {
|
||||
await queryRunner.manager
|
||||
.createQueryBuilder()
|
||||
.update(Estprotocoloentrega)
|
||||
.set({
|
||||
dataEntrega: data.dataEntrega,
|
||||
cpfRecebedor: data.cpfRecebedor,
|
||||
nomeRecebedor: data.nomeRecebedor,
|
||||
urlImagemProtocolo: data.urlImagemProtocolo,
|
||||
latitude: data.latitude,
|
||||
longitude: data.longitude,
|
||||
})
|
||||
.where('numcar = :numcar and codcli = :codcli', { numcar: data.numeroCarregamento, codcli: data.codigoCliente})
|
||||
.execute()
|
||||
} else {
|
||||
await queryRunner.manager
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(Estprotocoloentrega)
|
||||
.values(data)
|
||||
.execute()
|
||||
}
|
||||
|
||||
await queryRunner.commitTransaction();
|
||||
return new ResultModel(true, 'Registro atualizado com sucesso!', data, {});
|
||||
|
||||
} catch (error) {
|
||||
await queryRunner.rollbackTransaction();
|
||||
console.log(error);
|
||||
return new ResultModel(false,
|
||||
'Erro ao atualizar dados de entrega.',
|
||||
null,
|
||||
error);
|
||||
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
async getImageOrder(shipmentId: number, orderId: number): Promise<any> {
|
||||
const connection = getConnection();
|
||||
const queryRunner = connection.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
try {
|
||||
const result = await queryRunner.manager
|
||||
.getRepository(Estimagemnota)
|
||||
.createQueryBuilder('estimagemnota')
|
||||
.select(["numnota as \"numeroNota\"", "numped as \"numeroPedido\", numcar as \"numeroCarregamento\""])
|
||||
.addSelect(["tipo as \"tipo\", data as \"data\", url as \"url\", latitude as \"latitude\", longitude as \"longitude\" "])
|
||||
.where('numcar = :numcar and numped = :numped ', { numcar: shipmentId, numped: orderId})
|
||||
.getRawMany();
|
||||
|
||||
return result;
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return new ResultModel(false,
|
||||
'Erro ao atualizar imagens da nota fiscal.',
|
||||
null,
|
||||
error);
|
||||
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
}
|
||||
}
|
||||
|
||||
async createImageOrder(dataImage: ImageOrderModel): Promise<any> {
|
||||
console.log(dataImage);
|
||||
const connection = getConnection();
|
||||
const queryRunner = connection.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
await queryRunner.startTransaction();
|
||||
try {
|
||||
//const dateDelivery = '2022-04-14T17:52:00';
|
||||
//dataImage.data = dateDelivery;
|
||||
//console.log(dataImage);
|
||||
await queryRunner.manager
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(Estimagemnota)
|
||||
.values(dataImage)
|
||||
.execute()
|
||||
|
||||
await queryRunner.commitTransaction();
|
||||
return new ResultModel(true, 'Imagens incluídas com sucesso!', dataImage, {});
|
||||
|
||||
} catch (error) {
|
||||
await queryRunner.rollbackTransaction();
|
||||
console.log(error);
|
||||
return new ResultModel(false,
|
||||
'Erro ao incluir imagens da nota fiscal.',
|
||||
null,
|
||||
error);
|
||||
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
async createPayment(payment: PaymentModel): Promise<any> {
|
||||
console.log(payment);
|
||||
const connection = getConnection();
|
||||
const queryRunner = connection.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
await queryRunner.startTransaction();
|
||||
try {
|
||||
let cobranca = 'PAGV';
|
||||
switch (payment.formaPagto){
|
||||
case 'credit_card_parcelado':
|
||||
cobranca = 'PAGP';
|
||||
break;
|
||||
case 'debit_card':
|
||||
cobranca = 'PAGD';
|
||||
break;
|
||||
case 'credit_card':
|
||||
cobranca = 'PAGV';
|
||||
break;
|
||||
default:
|
||||
cobranca = 'DH';
|
||||
break;
|
||||
};
|
||||
|
||||
await queryRunner.manager
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(Estpagamento)
|
||||
.values({
|
||||
orderId: payment.orderId,
|
||||
dataPagamento: payment.dataPagamento,
|
||||
codigoAutorizacao: payment.idTransacao,
|
||||
codigoResposta: '00',
|
||||
dataRequisicao: payment.dataPagamento,
|
||||
dataServidor: payment.dataPagamento,
|
||||
estAcquirer: 'pagseguro',
|
||||
idTransacao: payment.codigoAutorizacao,
|
||||
nsu: payment.nsu,
|
||||
parcelas: payment.parcelas,
|
||||
valor: payment.valor / 100,
|
||||
nomeBandeira: 'pagseguro',
|
||||
formaPagto: payment.formaPagto,
|
||||
codigoFuncionario: null,
|
||||
cobranca: cobranca
|
||||
})
|
||||
.execute()
|
||||
|
||||
await queryRunner.commitTransaction();
|
||||
return new ResultModel(true, 'Pagamento incluído com sucesso!', {}, {});
|
||||
|
||||
} catch (error) {
|
||||
await queryRunner.rollbackTransaction();
|
||||
console.log(error);
|
||||
return new ResultModel(false,
|
||||
'Erro ao pagamento para carrgamento / cliente.',
|
||||
null,
|
||||
error);
|
||||
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
https://docs.nestjs.com/providers#services
|
||||
*/
|
||||
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Estprotocoloentrega } from 'src/domain/entity/tables/estprotocolo.entity';
|
||||
import { DeliveryOrderModel } from 'src/domain/models/delivery-order.model';
|
||||
import { ImageOrderModel } from 'src/domain/models/image-order.model';
|
||||
import { PaymentModel } from 'src/domain/models/payment.model';
|
||||
import { ResultModel } from 'src/domain/models/result.model';
|
||||
import { getConnection } from 'typeorm';
|
||||
import { Estimagemnota } from '../../domain/entity/tables/estimagemnota.entity';
|
||||
import { Estpagamento } from '../../domain/entity/tables/estpagamento.entity';
|
||||
|
||||
@Injectable()
|
||||
export class DeliveryOrderService {
|
||||
|
||||
async getDataDelivery(shipmentId: number, customerId: number): Promise<any> {
|
||||
const connection = getConnection();
|
||||
const queryRunner = connection.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
try {
|
||||
const result = await queryRunner.manager
|
||||
.getRepository(Estprotocoloentrega)
|
||||
.createQueryBuilder('estprotocoloentrega')
|
||||
.where('numcar = :numcar and codcli = :codcli', { numcar: shipmentId, codcli: customerId})
|
||||
.getOne();
|
||||
|
||||
return result; //new ResultModel(true, 'Registro localizado com sucesso!', result, {});
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return new ResultModel(false,
|
||||
'Erro ao atualizar dados de entrega.',
|
||||
null,
|
||||
error);
|
||||
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
async createOrReplaceDeliveryOrder(data: DeliveryOrderModel): Promise<any> {
|
||||
const connection = getConnection();
|
||||
const queryRunner = connection.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
await queryRunner.startTransaction();
|
||||
console.log(data);
|
||||
try {
|
||||
const updateDelivery = await queryRunner.manager
|
||||
.getRepository(Estprotocoloentrega)
|
||||
.createQueryBuilder('estprotocoloentrega')
|
||||
.where('numcar = :numcar and codcli = :codcli',
|
||||
{ numcar: data.numeroCarregamento, codcli: data.codigoCliente})
|
||||
.getOne();
|
||||
if ( updateDelivery ) {
|
||||
await queryRunner.manager
|
||||
.createQueryBuilder()
|
||||
.update(Estprotocoloentrega)
|
||||
.set({
|
||||
dataEntrega: data.dataEntrega,
|
||||
cpfRecebedor: data.cpfRecebedor,
|
||||
nomeRecebedor: data.nomeRecebedor,
|
||||
urlImagemProtocolo: data.urlImagemProtocolo,
|
||||
latitude: data.latitude,
|
||||
longitude: data.longitude,
|
||||
})
|
||||
.where('numcar = :numcar and codcli = :codcli', { numcar: data.numeroCarregamento, codcli: data.codigoCliente})
|
||||
.execute()
|
||||
} else {
|
||||
await queryRunner.manager
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(Estprotocoloentrega)
|
||||
.values(data)
|
||||
.execute()
|
||||
}
|
||||
|
||||
await queryRunner.commitTransaction();
|
||||
return new ResultModel(true, 'Registro atualizado com sucesso!', data, {});
|
||||
|
||||
} catch (error) {
|
||||
await queryRunner.rollbackTransaction();
|
||||
console.log(error);
|
||||
return new ResultModel(false,
|
||||
'Erro ao atualizar dados de entrega.',
|
||||
null,
|
||||
error);
|
||||
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
async getImageOrder(shipmentId: number, orderId: number): Promise<any> {
|
||||
const connection = getConnection();
|
||||
const queryRunner = connection.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
try {
|
||||
const result = await queryRunner.manager
|
||||
.getRepository(Estimagemnota)
|
||||
.createQueryBuilder('estimagemnota')
|
||||
.select(["numnota as \"numeroNota\"", "numped as \"numeroPedido\", numcar as \"numeroCarregamento\""])
|
||||
.addSelect(["tipo as \"tipo\", data as \"data\", url as \"url\", latitude as \"latitude\", longitude as \"longitude\" "])
|
||||
.where('numcar = :numcar and numped = :numped ', { numcar: shipmentId, numped: orderId})
|
||||
.getRawMany();
|
||||
|
||||
return result;
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return new ResultModel(false,
|
||||
'Erro ao atualizar imagens da nota fiscal.',
|
||||
null,
|
||||
error);
|
||||
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
}
|
||||
}
|
||||
|
||||
async createImageOrder(dataImage: ImageOrderModel): Promise<any> {
|
||||
console.log(dataImage);
|
||||
const connection = getConnection();
|
||||
const queryRunner = connection.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
await queryRunner.startTransaction();
|
||||
try {
|
||||
//const dateDelivery = '2022-04-14T17:52:00';
|
||||
//dataImage.data = dateDelivery;
|
||||
//console.log(dataImage);
|
||||
await queryRunner.manager
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(Estimagemnota)
|
||||
.values(dataImage)
|
||||
.execute()
|
||||
|
||||
await queryRunner.commitTransaction();
|
||||
return new ResultModel(true, 'Imagens incluídas com sucesso!', dataImage, {});
|
||||
|
||||
} catch (error) {
|
||||
await queryRunner.rollbackTransaction();
|
||||
console.log(error);
|
||||
return new ResultModel(false,
|
||||
'Erro ao incluir imagens da nota fiscal.',
|
||||
null,
|
||||
error);
|
||||
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
async createPayment(payment: PaymentModel): Promise<any> {
|
||||
console.log(payment);
|
||||
const connection = getConnection();
|
||||
const queryRunner = connection.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
await queryRunner.startTransaction();
|
||||
try {
|
||||
let cobranca = 'PAGV';
|
||||
switch (payment.formaPagto){
|
||||
case 'credit_card_parcelado':
|
||||
cobranca = 'PAGP';
|
||||
break;
|
||||
case 'debit_card':
|
||||
cobranca = 'PAGD';
|
||||
break;
|
||||
case 'credit_card':
|
||||
cobranca = 'PAGV';
|
||||
break;
|
||||
default:
|
||||
cobranca = 'DH';
|
||||
break;
|
||||
};
|
||||
|
||||
await queryRunner.manager
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(Estpagamento)
|
||||
.values({
|
||||
orderId: payment.orderId,
|
||||
dataPagamento: payment.dataPagamento,
|
||||
codigoAutorizacao: payment.idTransacao,
|
||||
codigoResposta: '00',
|
||||
dataRequisicao: payment.dataPagamento,
|
||||
dataServidor: payment.dataPagamento,
|
||||
estAcquirer: 'pagseguro',
|
||||
idTransacao: payment.codigoAutorizacao,
|
||||
nsu: payment.nsu,
|
||||
parcelas: payment.parcelas,
|
||||
valor: payment.valor / 100,
|
||||
nomeBandeira: 'pagseguro',
|
||||
formaPagto: payment.formaPagto,
|
||||
codigoFuncionario: null,
|
||||
cobranca: cobranca
|
||||
})
|
||||
.execute()
|
||||
|
||||
await queryRunner.commitTransaction();
|
||||
return new ResultModel(true, 'Pagamento incluído com sucesso!', {}, {});
|
||||
|
||||
} catch (error) {
|
||||
await queryRunner.rollbackTransaction();
|
||||
console.log(error);
|
||||
return new ResultModel(false,
|
||||
'Erro ao pagamento para carrgamento / cliente.',
|
||||
null,
|
||||
error);
|
||||
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -25,5 +25,9 @@ export class ShippingController {
|
||||
return await this.shippingService.GetCollectByCustomer(id);
|
||||
}
|
||||
|
||||
@Get('schedule')
|
||||
async getDeliverySchedule() {
|
||||
return await this.shippingService.getDeliverySchedule();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Connection, getConnection } from 'typeorm';
|
||||
import { ResultModel } from '../../domain/models/result.model';
|
||||
import { Esvretiralojascliente } from '../../domain/entity/views/esventregaslojascliente.entity';
|
||||
import { EsvRetiraLojas } from '../../domain/entity/views/esvretiralojas.entity';
|
||||
import { connectionOptions } from 'src/configs/typeorm.config';
|
||||
|
||||
@Injectable()
|
||||
export class ShippingService {
|
||||
@@ -154,6 +155,62 @@ export class ShippingService {
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
}
|
||||
}
|
||||
|
||||
async getDeliverySchedule() {
|
||||
|
||||
const connection = new Connection(connectionOptions);
|
||||
await connection.connect();
|
||||
const queryRunner = connection.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
|
||||
try {
|
||||
|
||||
const sql = `SELECT PCDIASUTEIS.DATA as "dateDelivery",
|
||||
NVL (PCDIASUTEIS.DIAROTA, 'N') as "delivery",
|
||||
(PARAMFILIAL.OBTERCOMONUMBER ('CAPACIDADE_LOGISTICA', 12)) as "deliverySize",
|
||||
ROUND ( (NVL (VENDAS.TOTPESO, 0) / 1000), 3) as "saleWeigth",
|
||||
ROUND (
|
||||
GREATEST (
|
||||
( ( PARAMFILIAL.OBTERCOMONUMBER ('CAPACIDADE_LOGISTICA',
|
||||
12)
|
||||
* 1000)
|
||||
- NVL (VENDAS.TOTPESO, 0))
|
||||
/ 1000,
|
||||
0),
|
||||
3) as "avaliableDelivery"
|
||||
FROM PCDIASUTEIS,
|
||||
( SELECT PCPEDC.DTENTREGA, SUM (PCPEDC.TOTPESO) TOTPESO
|
||||
FROM PCPEDC
|
||||
WHERE PCPEDC.POSICAO IN ('L', 'M')
|
||||
AND PCPEDC.CONDVENDA = 8
|
||||
AND PCPEDC.CODFILIAL IN (12, 13, 4, 6)
|
||||
AND EXISTS
|
||||
(SELECT TV7.NUMPED
|
||||
FROM PCPEDC TV7
|
||||
WHERE TV7.NUMPED = PCPEDC.NUMPEDENTFUT
|
||||
AND TV7.POSICAO = 'F')
|
||||
AND PCPEDC.DTENTREGA >= TRUNC (SYSDATE) + 3
|
||||
GROUP BY PCPEDC.DTENTREGA) VENDAS
|
||||
WHERE PCDIASUTEIS.CODFILIAL = 12 AND PCDIASUTEIS.DATA BETWEEN TRUNC (SYSDATE) + 3 AND TRUNC(SYSDATE) + 20 --AND NVL(PCDIASUTEIS.DIAROTA,'N') = 'S'
|
||||
AND PCDIASUTEIS.DATA = VENDAS.DTENTREGA(+)
|
||||
ORDER BY PCDIASUTEIS.DATA `;
|
||||
|
||||
const data = await queryRunner.query(sql);
|
||||
|
||||
const sqlDeliveryDate = `SELECT TRUNC(SYSDATE) + esf_calcular_prazo_entrega_programada(TRUNC(SYSDATE),
|
||||
'12',
|
||||
129, '', 0, 500) as "date"
|
||||
FROM DUAL`;
|
||||
const dataDeliveryDate = await queryRunner.query(sqlDeliveryDate);
|
||||
|
||||
const dataComplete = { dateDelivery: dataDeliveryDate[0].date, deliveries: [...data] };
|
||||
|
||||
return dataComplete;
|
||||
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user