Rev 585 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 568 | blopes | 1 | package br.com.ec.controller; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | import java.util.ArrayList; |
||
| 582 | blopes | 5 | import java.util.Arrays; |
| 568 | blopes | 6 | import java.util.List; |
| 7 | |||
| 8 | import javax.annotation.PostConstruct; |
||
| 9 | import javax.inject.Inject; |
||
| 10 | import javax.inject.Named; |
||
| 11 | |||
| 12 | import org.springframework.context.annotation.Scope; |
||
| 13 | |||
| 14 | import br.com.ec.core.generic.GenericService; |
||
| 588 | blopes | 15 | import br.com.ec.core.util.DataUtils; |
| 582 | blopes | 16 | import br.com.ec.domain.dto.AlertasGeralDTO; |
| 588 | blopes | 17 | import br.com.ec.domain.dto.AlertasLogisticaComprasDTO; |
| 18 | import br.com.ec.domain.dto.RankingComprasTransferenciasDTO; |
||
| 19 | import br.com.ec.domain.dto.RankingModeloDTO; |
||
| 20 | import br.com.ec.domain.dto.consulta.ParametrosConsultaModelosMaisVendidosDTO; |
||
| 582 | blopes | 21 | import br.com.ec.domain.model.tipos.TipoProduto; |
| 22 | import br.com.ec.domain.service.AlertasService; |
||
| 568 | blopes | 23 | import br.com.ec.domain.service.VendaService; |
| 24 | import br.com.ec.web.generic.AbstractBean; |
||
| 25 | |||
| 26 | @Named |
||
| 27 | @Scope("view") |
||
| 582 | blopes | 28 | public class AlertasComprasBean extends AbstractBean<AlertasGeralDTO> implements Serializable { |
| 568 | blopes | 29 | |
| 30 | private static final long serialVersionUID = 1L; |
||
| 31 | |||
| 582 | blopes | 32 | private AlertasService alertasService; |
| 568 | blopes | 33 | private VendaService vendaService; |
| 585 | blopes | 34 | |
| 35 | private Integer tempoDeEstoqueParaAlerta = 30; |
||
| 568 | blopes | 36 | |
| 37 | @Inject |
||
| 582 | blopes | 38 | public AlertasComprasBean(AlertasService alertasService, VendaService vendaService) { |
| 39 | this.alertasService = alertasService; |
||
| 568 | blopes | 40 | this.vendaService = vendaService; |
| 41 | } |
||
| 42 | |||
| 43 | @Override |
||
| 582 | blopes | 44 | public GenericService<AlertasGeralDTO> getService() { |
| 568 | blopes | 45 | return null; |
| 46 | } |
||
| 47 | |||
| 48 | @Override |
||
| 582 | blopes | 49 | public AlertasGeralDTO getId() { |
| 568 | blopes | 50 | return null; |
| 51 | } |
||
| 52 | |||
| 53 | @Override |
||
| 54 | public void limparEntidade() { |
||
| 582 | blopes | 55 | setEntidade(new AlertasGeralDTO()); |
| 56 | getEntidade().setQuantidadeDiasVendas(90); |
||
| 57 | getEntidade().setTempoDeEstoqueParaAlerta(30); |
||
| 58 | getEntidade().setAdicionarModelosFavoritosSemVendas(true); |
||
| 59 | getEntidade().setTiposProdutoSelecionados(new ArrayList<TipoProduto>()); |
||
| 568 | blopes | 60 | } |
| 61 | |||
| 62 | @PostConstruct |
||
| 63 | private void iniciarConsolidacoes() { |
||
| 64 | limparEntidade(); |
||
| 65 | } |
||
| 66 | |||
| 585 | blopes | 67 | public Integer getTempoDeEstoqueParaAlerta() { |
| 68 | return tempoDeEstoqueParaAlerta; |
||
| 69 | } |
||
| 70 | public void setTempoDeEstoqueParaAlerta(Integer tempoDeEstoqueParaAlerta) { |
||
| 71 | this.tempoDeEstoqueParaAlerta = tempoDeEstoqueParaAlerta; |
||
| 72 | } |
||
| 73 | |||
| 588 | blopes | 74 | public void verificarAlertasCapas() { |
| 75 | limparEntidade(); |
||
| 76 | |||
| 77 | // CONSULTAR MODELOS MAIS VENDIDOS |
||
| 78 | List<RankingModeloDTO> modelosMaisVendidos = new ArrayList<RankingModeloDTO>(); |
||
| 79 | ParametrosConsultaModelosMaisVendidosDTO parametrosConsulta = new ParametrosConsultaModelosMaisVendidosDTO(); |
||
| 80 | parametrosConsulta.setDataFinal(DataUtils.getDataAtual()); |
||
| 81 | parametrosConsulta.setDataInicial(DataUtils.acrescentarDias(DataUtils.getDataAtual(), getEntidade().getQuantidadeDiasVendas()*-1)); |
||
| 82 | modelosMaisVendidos.addAll(vendaService.consultarRankingModelos(parametrosConsulta, getEntidade().getAdicionarModelosFavoritosSemVendas())); |
||
| 83 | |||
| 84 | List<RankingComprasTransferenciasDTO> rankingComprasTransferencias = new ArrayList<RankingComprasTransferenciasDTO>(); |
||
| 85 | rankingComprasTransferencias.addAll(vendaService.consultarRankingComprasTransferencias(getEntidade().getQuantidadeDiasVendas(), |
||
| 86 | getEntidade().getTempoDeEstoqueParaAlerta(), modelosMaisVendidos, false)); |
||
| 87 | |||
| 88 | AlertasLogisticaComprasDTO alertasLogisticaComprasDTO = new AlertasLogisticaComprasDTO(); |
||
| 89 | alertasLogisticaComprasDTO.setQuantidadeAlertasModelosPossiveis(modelosMaisVendidos.size()); |
||
| 90 | alertasLogisticaComprasDTO.setRankingsComprasTransferenciasDTO(rankingComprasTransferencias); |
||
| 91 | getEntidade().setAlertasComprasCapasDTO(alertasLogisticaComprasDTO); |
||
| 92 | } |
||
| 93 | |||
| 582 | blopes | 94 | public void verificarAlertas() { |
| 95 | limparEntidade(); |
||
| 585 | blopes | 96 | getEntidade().setTempoDeEstoqueParaAlerta(getTempoDeEstoqueParaAlerta()); |
| 588 | blopes | 97 | getEntidade().setAlertasComprasDTO(alertasService.consultarAlertasComprasGeral(getEntidade())); |
| 568 | blopes | 98 | } |
| 99 | |||
| 100 | } |