Go to most recent revision | Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 574 | blopes | 1 | package br.com.ec.domain.service.impl; |
| 2 | |||
| 3 | import java.util.ArrayList; |
||
| 4 | import java.util.List; |
||
| 5 | |||
| 6 | import org.springframework.beans.factory.annotation.Autowired; |
||
| 7 | import org.springframework.stereotype.Service; |
||
| 8 | |||
| 9 | import br.com.ec.core.generic.AbstractService; |
||
| 10 | import br.com.ec.core.generic.GenericRepository; |
||
| 11 | import br.com.ec.core.util.DataUtils; |
||
| 12 | import br.com.ec.core.validador.Validador; |
||
| 13 | import br.com.ec.domain.dto.AnaliseComprasProdutosDTO; |
||
| 14 | import br.com.ec.domain.dto.AnaliseVendaProdutoDTO; |
||
| 15 | import br.com.ec.domain.dto.FornecedorDTO; |
||
| 16 | import br.com.ec.domain.dto.ProdutoDTO; |
||
| 17 | import br.com.ec.domain.model.Compra; |
||
| 18 | import br.com.ec.domain.service.CompraService; |
||
| 19 | import br.com.ec.domain.service.ParcelaService; |
||
| 20 | import br.com.ec.repository.CompraRepository; |
||
| 21 | |||
| 22 | @Service |
||
| 23 | public class CompraServiceImpl extends AbstractService<Compra> implements CompraService { |
||
| 24 | |||
| 25 | private ParcelaService parcelaService; |
||
| 26 | private CompraRepository compraRepository; |
||
| 27 | |||
| 28 | @Autowired |
||
| 29 | public CompraServiceImpl(Validador validador, ParcelaService parcelaService, CompraRepository compraRepository) { |
||
| 30 | super(validador); |
||
| 31 | this.parcelaService = parcelaService; |
||
| 32 | this.compraRepository = compraRepository; |
||
| 33 | } |
||
| 34 | |||
| 35 | @Override |
||
| 36 | protected GenericRepository<Compra> getRepository() { |
||
| 37 | return compraRepository; |
||
| 38 | } |
||
| 39 | |||
| 40 | @Override |
||
| 41 | 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' |
||
| 47 | |||
| 48 | AnaliseComprasProdutosDTO analiseComprasProdutosDTO = new AnaliseComprasProdutosDTO(); |
||
| 49 | |||
| 50 | List<AnaliseVendaProdutoDTO> analisesVendaProdutoDTO = new ArrayList<AnaliseVendaProdutoDTO>(); |
||
| 51 | AnaliseVendaProdutoDTO analiseVendaProdutoDTO = new AnaliseVendaProdutoDTO(); |
||
| 52 | |||
| 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 | |||
| 55 | 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); |
||
| 57 | analiseVendaProdutoDTO.setQuantidadeEstoque(5); |
||
| 58 | analiseVendaProdutoDTO.setQuantidadeVendas(15); |
||
| 59 | analiseVendaProdutoDTO.setDataUltimaCompra(DataUtils.converterStringParaData("2024-03-16")); |
||
| 60 | analiseVendaProdutoDTO.setDataUltimaVenda(DataUtils.converterStringParaData("2024-03-16")); |
||
| 61 | |||
| 62 | // FAZER EXEMPLOS SEM O PEDIDO DE COMPRA |
||
| 63 | // ProdutoPedidoCompraDTO produtoPedidoCompraDTO = new ProdutoPedidoCompraDTO(); |
||
| 64 | analiseVendaProdutoDTO.setProdutoPedidoCompraDTO(null); |
||
| 65 | |||
| 66 | FornecedorDTO fornecedorConsultaDTO = new FornecedorDTO(); |
||
| 67 | analiseVendaProdutoDTO.setFornecedorDTO(fornecedorConsultaDTO); |
||
| 68 | |||
| 69 | analisesVendaProdutoDTO.add(analiseVendaProdutoDTO); |
||
| 70 | |||
| 71 | analiseComprasProdutosDTO.setAnalisesVendaProdutoDTO(analisesVendaProdutoDTO); |
||
| 72 | return analiseComprasProdutosDTO; |
||
| 73 | } |
||
| 74 | |||
| 75 | /* |
||
| 76 | @Override |
||
| 77 | public Compra consultarCompraDaConta(Conta conta) { |
||
| 78 | return compraRepository.consultarCompraDaConta(conta); |
||
| 79 | } |
||
| 80 | |||
| 81 | @Override |
||
| 82 | public void adicionarParcelasNaCompra(Compra compra, List<Parcela> listaParcelas) { |
||
| 83 | parcelaService.cadastrarContaComParcelasNaCompra(compra, listaParcelas); |
||
| 84 | alterar(compra); |
||
| 85 | } |
||
| 86 | |||
| 87 | @Override |
||
| 88 | public void vincularConta(Compra compra, Conta conta) { |
||
| 89 | if (VerificadorUtil.estaNulo(conta)) { |
||
| 90 | throw new NegocioException("CONTA NÃO EXISTE"); |
||
| 91 | } |
||
| 92 | compra.setConta(conta); |
||
| 93 | alterar(compra); |
||
| 94 | } |
||
| 95 | |||
| 96 | @Override |
||
| 97 | public void desvincularConta(Compra compra) { |
||
| 98 | compra.setConta(null); |
||
| 99 | alterar(compra); |
||
| 100 | } |
||
| 101 | |||
| 102 | @Override |
||
| 103 | public void cadastrar(Compra compra) { |
||
| 104 | if (VerificadorUtil.estaNulo(compra.getFornecedor())) { |
||
| 105 | throw new NegocioException("OBRIGATÓRIO INFORMAR O FORNECEDOR"); |
||
| 106 | } |
||
| 107 | super.cadastrar(compra); |
||
| 108 | } |
||
| 109 | */ |
||
| 110 | } |