Rev 583 | Go to most recent revision | 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; |
||
| 583 | blopes | 15 | import br.com.ec.domain.dto.AlertasComprasGeralDTO; |
| 16 | import br.com.ec.domain.dto.AlertasComprasProdutoDTO; |
||
| 582 | blopes | 17 | import br.com.ec.domain.dto.AlertasGeralDTO; |
| 583 | blopes | 18 | import br.com.ec.domain.dto.ProdutoDTO; |
| 582 | blopes | 19 | import br.com.ec.domain.model.tipos.TipoProduto; |
| 20 | import br.com.ec.domain.service.AlertasService; |
||
| 568 | blopes | 21 | import br.com.ec.domain.service.VendaService; |
| 22 | import br.com.ec.web.generic.AbstractBean; |
||
| 23 | |||
| 24 | @Named |
||
| 25 | @Scope("view") |
||
| 582 | blopes | 26 | public class AlertasComprasBean extends AbstractBean<AlertasGeralDTO> implements Serializable { |
| 568 | blopes | 27 | |
| 28 | private static final long serialVersionUID = 1L; |
||
| 29 | |||
| 582 | blopes | 30 | private AlertasService alertasService; |
| 568 | blopes | 31 | private VendaService vendaService; |
| 585 | blopes | 32 | |
| 33 | private Integer tempoDeEstoqueParaAlerta = 30; |
||
| 568 | blopes | 34 | |
| 35 | @Inject |
||
| 582 | blopes | 36 | public AlertasComprasBean(AlertasService alertasService, VendaService vendaService) { |
| 37 | this.alertasService = alertasService; |
||
| 568 | blopes | 38 | this.vendaService = vendaService; |
| 39 | } |
||
| 40 | |||
| 41 | @Override |
||
| 582 | blopes | 42 | public GenericService<AlertasGeralDTO> getService() { |
| 568 | blopes | 43 | return null; |
| 44 | } |
||
| 45 | |||
| 46 | @Override |
||
| 582 | blopes | 47 | public AlertasGeralDTO getId() { |
| 568 | blopes | 48 | return null; |
| 49 | } |
||
| 50 | |||
| 51 | @Override |
||
| 52 | public void limparEntidade() { |
||
| 582 | blopes | 53 | setEntidade(new AlertasGeralDTO()); |
| 54 | getEntidade().setQuantidadeDiasVendas(90); |
||
| 55 | getEntidade().setTempoDeEstoqueParaAlerta(30); |
||
| 56 | getEntidade().setAdicionarModelosFavoritosSemVendas(true); |
||
| 57 | getEntidade().setTiposProdutoSelecionados(new ArrayList<TipoProduto>()); |
||
| 568 | blopes | 58 | } |
| 59 | |||
| 60 | @PostConstruct |
||
| 61 | private void iniciarConsolidacoes() { |
||
| 62 | limparEntidade(); |
||
| 63 | } |
||
| 64 | |||
| 585 | blopes | 65 | public Integer getTempoDeEstoqueParaAlerta() { |
| 66 | return tempoDeEstoqueParaAlerta; |
||
| 67 | } |
||
| 68 | public void setTempoDeEstoqueParaAlerta(Integer tempoDeEstoqueParaAlerta) { |
||
| 69 | this.tempoDeEstoqueParaAlerta = tempoDeEstoqueParaAlerta; |
||
| 70 | } |
||
| 71 | |||
| 582 | blopes | 72 | public void verificarAlertas() { |
| 73 | limparEntidade(); |
||
| 585 | blopes | 74 | getEntidade().setTempoDeEstoqueParaAlerta(getTempoDeEstoqueParaAlerta()); |
| 582 | blopes | 75 | |
| 76 | // LISTA DE TODOS OS TIPOS, EXCETO CAPAS |
||
| 77 | List<TipoProduto> tiposProduto = new ArrayList<TipoProduto>(); |
||
| 78 | tiposProduto.addAll(Arrays.asList(TipoProduto.values())); |
||
| 79 | for (TipoProduto tipoProduto : tiposProduto) { |
||
| 80 | if (!tipoProduto.getValor().equals(TipoProduto.CAPA.getValor())) { |
||
| 81 | getEntidade().getTiposProdutoSelecionados().add(tipoProduto); |
||
| 82 | } |
||
| 83 | } |
||
| 84 | setEntidade(alertasService.consultarAlertasComprasGeral(getEntidade())); |
||
| 568 | blopes | 85 | } |
| 86 | |||
| 87 | } |