Rev 574 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 574 | Rev 575 | ||
|---|---|---|---|
| Line 4... | Line 4... | ||
| 4 | import java.util.List; |
4 | import java.util.List; |
| 5 | 5 | ||
| 6 | import org.springframework.beans.factory.annotation.Autowired; |
6 | import org.springframework.beans.factory.annotation.Autowired; |
| 7 | import org.springframework.stereotype.Service; |
7 | import org.springframework.stereotype.Service; |
| 8 | 8 | ||
| - | 9 | import br.com.ec.core.exception.NegocioException; |
|
| 9 | import br.com.ec.core.generic.AbstractService; |
10 | import br.com.ec.core.generic.AbstractService; |
| 10 | import br.com.ec.core.generic.GenericRepository; |
11 | import br.com.ec.core.generic.GenericRepository; |
| 11 | import br.com.ec.core.util.DataUtils; |
12 | import br.com.ec.core.util.DataUtils; |
| - | 13 | import br.com.ec.core.util.VerificadorUtil; |
|
| 12 | import br.com.ec.core.validador.Validador; |
14 | import br.com.ec.core.validador.Validador; |
| 13 | import br.com.ec.domain.dto.AnaliseComprasProdutosDTO; |
15 | import br.com.ec.domain.dto.AnaliseComprasProdutosDTO; |
| 14 | import br.com.ec.domain.dto.AnaliseVendaProdutoDTO; |
16 | import br.com.ec.domain.dto.AnaliseVendaProdutoDTO; |
| 15 | import br.com.ec.domain.dto.FornecedorDTO; |
17 | import br.com.ec.domain.dto.FornecedorDTO; |
| 16 | import br.com.ec.domain.dto.ProdutoDTO; |
18 | import br.com.ec.domain.dto.ProdutoDTO; |
| 17 | import br.com.ec.domain.model.Compra; |
19 | import br.com.ec.domain.model.Compra; |
| 18 | import br.com.ec.domain.service.CompraService; |
20 | import br.com.ec.domain.service.CompraService; |
| 19 | import br.com.ec.domain.service.ParcelaService; |
21 | import br.com.ec.domain.service.ParcelaService; |
| - | 22 | import br.com.ec.domain.service.ProdutoService; |
|
| 20 | import br.com.ec.repository.CompraRepository; |
23 | import br.com.ec.repository.CompraRepository; |
| 21 | 24 | ||
| 22 | @Service |
25 | @Service |
| 23 | public class CompraServiceImpl extends AbstractService<Compra> implements CompraService { |
26 | public class CompraServiceImpl extends AbstractService<Compra> implements CompraService { |
| 24 | 27 | ||
| 25 | private ParcelaService parcelaService; |
28 | private ParcelaService parcelaService; |
| - | 29 | private ProdutoService produtoService; |
|
| 26 | private CompraRepository compraRepository; |
30 | private CompraRepository compraRepository; |
| 27 | 31 | ||
| 28 | @Autowired |
32 | @Autowired |
| 29 | public CompraServiceImpl(Validador validador, ParcelaService parcelaService, CompraRepository compraRepository) { |
- | |
| - | 33 | public CompraServiceImpl(Validador validador, ParcelaService parcelaService, ProdutoService produtoService, |
|
| - | 34 | CompraRepository compraRepository) { |
|
| 30 | super(validador); |
35 | super(validador); |
| 31 | this.parcelaService = parcelaService; |
36 | this.parcelaService = parcelaService; |
| - | 37 | this.produtoService = produtoService; |
|
| 32 | this.compraRepository = compraRepository; |
38 | this.compraRepository = compraRepository; |
| 33 | }
|
39 | }
|
| 34 | 40 | ||
| 35 | @Override |
41 | @Override |
| 36 | protected GenericRepository<Compra> getRepository() { |
42 | protected GenericRepository<Compra> getRepository() { |
| 37 | return compraRepository; |
43 | return compraRepository; |
| 38 | }
|
44 | }
|
| 39 | 45 | ||
| 40 | @Override |
46 | @Override |
| 41 | public AnaliseComprasProdutosDTO gerarComprasAutomaticamente(FornecedorDTO fornecedorDTO) { |
47 | public AnaliseComprasProdutosDTO gerarComprasAutomaticamente(FornecedorDTO fornecedorDTO) { |
| 42 | // VERIFICAR PRODUTOS:
|
- | |
| 43 | // VENDAS À PARTIR DE 2023
|
- | |
| 44 | // VERIFICAR ÚLTIMA DATA DE COMPRA DO PRODUTO
|
- | |
| 45 | // VERIFICAR A QUANTIDADE DE PRODUTOS VENDIDOS POR MÊS EM 3 MESES OU ATÉ A DATA DA ÚLTIMA VENDA, A QUE FOR MENOR;
|
- | |
| 46 | // LISTAR PRODUTOS COM UM TEMPO DE ESTOQUE INFERIOR À 15 DIAS, SEM INFORMAÇÃO DE PEDIDOS DE 'NÃO COMPRAR' OU 'SOLICITADO'
|
- | |
| - | 48 | if (VerificadorUtil.estaNulo(fornecedorDTO)) { |
|
| - | 49 | throw new NegocioException("INFORME O FORNECEDOR"); |
|
| - | 50 | }
|
|
| 47 | 51 | ||
| 48 | AnaliseComprasProdutosDTO analiseComprasProdutosDTO = new AnaliseComprasProdutosDTO(); |
52 | AnaliseComprasProdutosDTO analiseComprasProdutosDTO = new AnaliseComprasProdutosDTO(); |
| 49 | 53 | ||
| 50 | List<AnaliseVendaProdutoDTO> analisesVendaProdutoDTO = new ArrayList<AnaliseVendaProdutoDTO>(); |
54 | List<AnaliseVendaProdutoDTO> analisesVendaProdutoDTO = new ArrayList<AnaliseVendaProdutoDTO>(); |
| 51 | AnaliseVendaProdutoDTO analiseVendaProdutoDTO = new AnaliseVendaProdutoDTO(); |
- | |
| 52 | 55 | ||
| 53 | // 6 3 0 3 09/03/2022 2024-03-16 12:18:54.193-03 XINXIN CAPAS 35479 32132 KIT CARREGADOR VEICULAR CABO DE DADOS MICRO USB V8 3.4A 1M HREBOS HS-98 18.00 60.00 true 1 K U false BR true false 12 40.00 false false
|
- | |
| 54 | - | ||
| - | 56 | // CONSULTAR TODOS OS PRODUTOS DO FORNECEDOR INFORMADO
|
|
| - | 57 | // LISTAR PRODUTOS SEM PEDIDOS DE 'NÃO COMPRAR'
|
|
| - | 58 | List<ProdutoDTO> produtosParaAnalise = produtoService.consultarProdutosDoFornecedor(fornecedorDTO.getSequencial()); |
|
| - | 59 | ||
| - | 60 | for (ProdutoDTO produtoDTO : produtosParaAnalise) { |
|
| - | 61 | AnaliseVendaProdutoDTO analiseVendaProdutoDTO = new AnaliseVendaProdutoDTO(); |
|
| - | 62 | analiseVendaProdutoDTO.setProdutoDTO(produtoDTO); |
|
| - | 63 | ||
| - | 64 | // VERIFICAR ÚLTIMA DATA DE COMPRA DO PRODUTO
|
|
| - | 65 | // VERIFICAR QUANTIDADE DE VENDAS REALIZADAS EM 3 MESES, APÓS A ÚLTIMA DATA DE COMPRA
|
|
| - | 66 | // VERIFICAR A QUANTIDADE DE PRODUTOS VENDIDOS POR MÊS EM 3 MESES OU ATÉ A DATA DA ÚLTIMA VENDA, A QUE FOR MENOR;
|
|
| - | 67 | analiseVendaProdutoDTO.setQuantidadeEstoque(5); |
|
| - | 68 | analiseVendaProdutoDTO.setQuantidadeVendas(15); |
|
| - | 69 | analiseVendaProdutoDTO.setQuantidadeDiasParaComprar(90); |
|
| - | 70 | analiseVendaProdutoDTO.setQuantidadeVendasAposCompra(20); |
|
| - | 71 | analiseVendaProdutoDTO.setDataUltimaCompra(DataUtils.converterStringParaData("16/03/2024")); |
|
| - | 72 | analiseVendaProdutoDTO.setDataUltimaVenda(DataUtils.converterStringParaData("16/03/2024")); |
|
| - | 73 | ||
| - | 74 | analisesVendaProdutoDTO.add(analiseVendaProdutoDTO); |
|
| - | 75 | }
|
|
| - | 76 | ||
| - | 77 | analiseComprasProdutosDTO.setAnalisesVendaProdutoDTO(analisesVendaProdutoDTO); |
|
| - | 78 | // SUGERIR A COMPRA DE PRODUTOS POR 90 DIAS, COM UM TEMPO DE ESTOQUE INFERIOR À 15 DIAS
|
|
| - | 79 | ||
| - | 80 | /*
|
|
| 55 | ProdutoDTO produtoDTO = new ProdutoDTO(new Long(35479), "032132", "KIT CARREGADOR VEICULAR CABO DE DADOS MICRO USB V8 3.4A 1M HREBOS HS-98"); |
81 | ProdutoDTO produtoDTO = new ProdutoDTO(new Long(35479), "032132", "KIT CARREGADOR VEICULAR CABO DE DADOS MICRO USB V8 3.4A 1M HREBOS HS-98");
|
| 56 | analiseVendaProdutoDTO.setProdutoDTO(produtoDTO); |
82 | analiseVendaProdutoDTO.setProdutoDTO(produtoDTO);
|
| 57 | analiseVendaProdutoDTO.setQuantidadeEstoque(5); |
83 | analiseVendaProdutoDTO.setQuantidadeEstoque(5);
|
| 58 | analiseVendaProdutoDTO.setQuantidadeVendas(15); |
84 | analiseVendaProdutoDTO.setQuantidadeVendas(15);
|
| 59 | analiseVendaProdutoDTO.setDataUltimaCompra(DataUtils.converterStringParaData("2024-03-16")); |
- | |
| 60 | analiseVendaProdutoDTO.setDataUltimaVenda(DataUtils.converterStringParaData("2024-03-16")); |
- | |
| - | 85 | analiseVendaProdutoDTO.setQuantidadeDiasParaComprar(90);
|
|
| - | 86 | analiseVendaProdutoDTO.setQuantidadeVendasAposCompra(20);
|
|
| - | 87 | analiseVendaProdutoDTO.setDataUltimaCompra(DataUtils.converterStringParaData("16/03/2024"));
|
|
| - | 88 | analiseVendaProdutoDTO.setDataUltimaVenda(DataUtils.converterStringParaData("16/03/2024"));
|
|
| 61 | 89 |
|
|
| 62 | // FAZER EXEMPLOS SEM O PEDIDO DE COMPRA
|
90 | // FAZER EXEMPLOS SEM O PEDIDO DE COMPRA
|
| 63 | // ProdutoPedidoCompraDTO produtoPedidoCompraDTO = new ProdutoPedidoCompraDTO();
|
91 | // ProdutoPedidoCompraDTO produtoPedidoCompraDTO = new ProdutoPedidoCompraDTO();
|
| 64 | analiseVendaProdutoDTO.setProdutoPedidoCompraDTO(null); |
92 | analiseVendaProdutoDTO.setProdutoPedidoCompraDTO(null);
|
| 65 | 93 |
|
|
| Line 67... | Line 95... | ||
| 67 | analiseVendaProdutoDTO.setFornecedorDTO(fornecedorConsultaDTO); |
95 | analiseVendaProdutoDTO.setFornecedorDTO(fornecedorConsultaDTO);
|
| 68 | 96 |
|
|
| 69 | analisesVendaProdutoDTO.add(analiseVendaProdutoDTO); |
97 | analisesVendaProdutoDTO.add(analiseVendaProdutoDTO);
|
| 70 | 98 |
|
|
| 71 | analiseComprasProdutosDTO.setAnalisesVendaProdutoDTO(analisesVendaProdutoDTO); |
99 | analiseComprasProdutosDTO.setAnalisesVendaProdutoDTO(analisesVendaProdutoDTO);
|
| - | 100 | */
|
|
| 72 | return analiseComprasProdutosDTO; |
101 | return analiseComprasProdutosDTO; |
| 73 | }
|
102 | }
|
| 74 | 103 | ||
| 75 | /*
|
104 | /*
|
| 76 | @Override
|
105 | @Override
|