Rev 568 | Rev 583 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 568 | Rev 582 | ||
|---|---|---|---|
| Line 4... | Line 4... | ||
| 4 | import java.util.ArrayList; |
4 | import java.util.ArrayList; |
| - | 5 | import java.util.Arrays; |
|
| 5 | import java.util.List; |
6 | import java.util.List; |
| 6 | 7 | ||
| 7 | import javax.annotation.PostConstruct; |
8 | import javax.annotation.PostConstruct; |
| 8 | import javax.inject.Inject; |
9 | import javax.inject.Inject; |
| 9 | import javax.inject.Named; |
10 | import javax.inject.Named; |
| 10 | 11 | ||
| 11 | import org.springframework.context.annotation.Scope; |
12 | import org.springframework.context.annotation.Scope; |
| 12 | 13 | ||
| 13 | import br.com.ec.core.generic.GenericService; |
14 | import br.com.ec.core.generic.GenericService; |
| 14 | import br.com.ec.core.util.DataUtils; |
- | |
| 15 | import br.com.ec.domain.dto.AlertasLogisticaComprasDTO; |
- | |
| 16 | import br.com.ec.domain.dto.RankingComprasTransferenciasDTO; |
- | |
| 17 | import br.com.ec.domain.dto.RankingModeloDTO; |
- | |
| 18 | import br.com.ec.domain.dto.consulta.ParametrosConsultaModelosMaisVendidosDTO; |
- | |
| - | 15 | import br.com.ec.domain.dto.AlertasGeralDTO; |
|
| - | 16 | import br.com.ec.domain.model.tipos.TipoProduto; |
|
| - | 17 | import br.com.ec.domain.service.AlertasService; |
|
| 19 | import br.com.ec.domain.service.VendaService; |
18 | import br.com.ec.domain.service.VendaService; |
| 20 | import br.com.ec.web.generic.AbstractBean; |
19 | import br.com.ec.web.generic.AbstractBean; |
| 21 | 20 | ||
| 22 | @Named |
21 | @Named |
| 23 | @Scope("view") |
22 | @Scope("view") |
| 24 | public class AlertasComprasBean extends AbstractBean<AlertasLogisticaComprasDTO> implements Serializable { |
- | |
| - | 23 | public class AlertasComprasBean extends AbstractBean<AlertasGeralDTO> implements Serializable { |
|
| 25 | 24 | ||
| 26 | private static final long serialVersionUID = 1L; |
25 | private static final long serialVersionUID = 1L; |
| 27 | 26 | ||
| 28 | private Boolean adicionarModelosFavoritosSemVendas; |
- | |
| 29 | private Integer quantidadeDiasVendas = 0; |
- | |
| 30 | private Integer quantidadeDiasParaAlerta = 0; |
- | |
| - | 27 | private AlertasService alertasService; |
|
| 31 | private VendaService vendaService; |
28 | private VendaService vendaService; |
| 32 | 29 | ||
| 33 | @Inject |
30 | @Inject |
| 34 | public AlertasComprasBean(VendaService vendaService) { |
- | |
| - | 31 | public AlertasComprasBean(AlertasService alertasService, VendaService vendaService) { |
|
| - | 32 | this.alertasService = alertasService; |
|
| 35 | this.vendaService = vendaService; |
33 | this.vendaService = vendaService; |
| 36 | }
|
34 | }
|
| 37 | 35 | ||
| 38 | @Override |
36 | @Override |
| 39 | public GenericService<AlertasLogisticaComprasDTO> getService() { |
- | |
| - | 37 | public GenericService<AlertasGeralDTO> getService() { |
|
| 40 | return null; |
38 | return null; |
| 41 | }
|
39 | }
|
| 42 | 40 | ||
| 43 | @Override |
41 | @Override |
| 44 | public AlertasLogisticaComprasDTO getId() { |
- | |
| - | 42 | public AlertasGeralDTO getId() { |
|
| 45 | return null; |
43 | return null; |
| 46 | }
|
44 | }
|
| 47 | 45 | ||
| 48 | @Override |
46 | @Override |
| 49 | public void limparEntidade() { |
47 | public void limparEntidade() { |
| 50 | setEntidade(new AlertasLogisticaComprasDTO()); |
- | |
| 51 | setQuantidadeDiasVendas(90); |
- | |
| 52 | setQuantidadeDiasParaAlerta(30); |
- | |
| 53 | setAdicionarModelosFavoritosSemVendas(false); |
- | |
| - | 48 | setEntidade(new AlertasGeralDTO()); |
|
| - | 49 | getEntidade().setQuantidadeDiasVendas(90); |
|
| - | 50 | getEntidade().setTempoDeEstoqueParaAlerta(30); |
|
| - | 51 | getEntidade().setAdicionarModelosFavoritosSemVendas(true); |
|
| - | 52 | getEntidade().setTiposProdutoSelecionados(new ArrayList<TipoProduto>()); |
|
| 54 | }
|
53 | }
|
| 55 | 54 | ||
| 56 | @PostConstruct |
55 | @PostConstruct |
| 57 | private void iniciarConsolidacoes() { |
56 | private void iniciarConsolidacoes() { |
| 58 | limparEntidade(); |
57 | limparEntidade(); |
| - | 58 | teste(); |
|
| 59 | }
|
59 | }
|
| 60 | 60 | ||
| 61 | public Boolean getAdicionarModelosFavoritosSemVendas() { |
- | |
| 62 | return adicionarModelosFavoritosSemVendas; |
- | |
| 63 | }
|
- | |
| 64 | public void setAdicionarModelosFavoritosSemVendas(Boolean adicionarModelosFavoritosSemVendas) { |
- | |
| 65 | this.adicionarModelosFavoritosSemVendas = adicionarModelosFavoritosSemVendas; |
- | |
| - | 61 | public void verificarAlertas() { |
|
| - | 62 | limparEntidade(); |
|
| - | 63 | ||
| - | 64 | // LISTA DE TODOS OS TIPOS, EXCETO CAPAS
|
|
| - | 65 | List<TipoProduto> tiposProduto = new ArrayList<TipoProduto>(); |
|
| - | 66 | tiposProduto.addAll(Arrays.asList(TipoProduto.values())); |
|
| - | 67 | for (TipoProduto tipoProduto : tiposProduto) { |
|
| - | 68 | if (!tipoProduto.getValor().equals(TipoProduto.CAPA.getValor())) { |
|
| - | 69 | getEntidade().getTiposProdutoSelecionados().add(tipoProduto); |
|
| - | 70 | }
|
|
| - | 71 | }
|
|
| - | 72 | ||
| - | 73 | setEntidade(alertasService.consultarAlertasComprasGeral(getEntidade())); |
|
| 66 | }
|
74 | }
|
| 67 | 75 | ||
| 68 | public Integer getQuantidadeDiasVendas() { |
- | |
| 69 | return quantidadeDiasVendas; |
- | |
| 70 | }
|
- | |
| 71 | public void setQuantidadeDiasVendas(Integer quantidadeDiasVendas) { |
- | |
| 72 | this.quantidadeDiasVendas = quantidadeDiasVendas; |
- | |
| 73 | }
|
- | |
| 74 | 76 | ||
| 75 | public Integer getQuantidadeDiasParaAlerta() { |
- | |
| 76 | return quantidadeDiasParaAlerta; |
- | |
| 77 | }
|
- | |
| 78 | public void setQuantidadeDiasParaAlerta(Integer quantidadeDiasParaAlerta) { |
- | |
| 79 | this.quantidadeDiasParaAlerta = quantidadeDiasParaAlerta; |
- | |
| 80 | }
|
- | |
| 81 | - | ||
| 82 | public void verificarAlertas() { |
- | |
| - | 77 | public void teste() { |
|
| 83 | limparEntidade(); |
78 | limparEntidade(); |
| 84 | 79 | ||
| 85 | // CONSULTAR MODELOS MAIS VENDIDOS
|
- | |
| 86 | List<RankingModeloDTO> modelosMaisVendidos = new ArrayList<RankingModeloDTO>(); |
- | |
| 87 | ParametrosConsultaModelosMaisVendidosDTO parametrosConsulta = new ParametrosConsultaModelosMaisVendidosDTO(); |
- | |
| 88 | parametrosConsulta.setDataFinal(DataUtils.getDataAtual()); |
- | |
| 89 | parametrosConsulta.setDataInicial(DataUtils.acrescentarDias(DataUtils.getDataAtual(), quantidadeDiasVendas*-1)); |
- | |
| 90 | modelosMaisVendidos.addAll(vendaService.consultarRankingModelos(parametrosConsulta, adicionarModelosFavoritosSemVendas)); |
- | |
| 91 | 80 | ||
| 92 | List<RankingComprasTransferenciasDTO> rankingComprasTransferencias = new ArrayList<RankingComprasTransferenciasDTO>(); |
- | |
| 93 | rankingComprasTransferencias.addAll(vendaService.consultarRankingComprasTransferencias(getQuantidadeDiasVendas(), getQuantidadeDiasParaAlerta(), modelosMaisVendidos, false)); |
- | |
| 94 | getEntidade().setQuantidadeAlertasModelosPossiveis(modelosMaisVendidos.size()); |
- | |
| 95 | getEntidade().setRankingsComprasTransferenciasDTO(rankingComprasTransferencias); |
- | |
| - | 81 | ||
| 96 | }
|
82 | }
|
| 97 | 83 | ||
| 98 | }
|
84 | }
|