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:
parent
62f4c767dd
commit
0936c239b9
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,15 +10,15 @@ async function bootstrap() {
|
|||
app.use(compression());
|
||||
const options = new DocumentBuilder()
|
||||
.setTitle('API Venda web')
|
||||
.setDescription(`API criada para realsizar todo processo da venda assistida, como criação de oraçamento de venda, pedido de venda
|
||||
cadastro de novos clientes, novos enderessços. A API também fornece dados para o portal de parceiros como a manutenção
|
||||
do cadastro sde parceisros, consulta de venda de movimentação e pagamentos, e fechamento das comissões dos parceiros.`)
|
||||
.setDescription(`API criada para realizar todo processo da venda assistida, como criação de oraçamento de venda, pedido de venda
|
||||
cadastro de novos clientes, novos endereços. A API também fornece dados para o portal de parceiros como a manutenção
|
||||
do cadastro de parceiros, consulta de venda de movimentação e pagamentos, e fechamento das comissões dos parceiros.`)
|
||||
.setVersion("2023.1.2")
|
||||
.addTag("VendaWeb")
|
||||
.addTag("Autenticação")
|
||||
.build();
|
||||
const document = SwaggerModule.createDocument(app, options);
|
||||
SwaggerModule.setup("docs", app, document);
|
||||
await app.listen(3001);
|
||||
await app.listen(3002);
|
||||
}
|
||||
bootstrap();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Injectable, HttpException, HttpStatus } from '@nestjs/common';
|
||||
import { Pcclient } from 'src/domain/entity/tables/pcclient.entity';
|
||||
import { SalesProduct } from 'src/domain/entity/views/esvprodutosvenda.entity';
|
||||
import { Connection, getConnection, QueryRunner } from 'typeorm';
|
||||
import { Connection, getConnection } from 'typeorm';
|
||||
import { Esvsituacaopedido } from '../../domain/entity/views/esvsituacaopedido.entity';
|
||||
import { Stock } from '../../domain/entity/views/esvestoquevenda.entity';
|
||||
import { FilterProduct } from 'src/domain/models/filter-product.model';
|
||||
|
|
|
|||
Loading…
Reference in New Issue