Rev 568 | 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; |
||
| 582 | blopes | 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; |
||
| 568 | blopes | 18 | import br.com.ec.domain.service.VendaService; |
| 19 | import br.com.ec.web.generic.AbstractBean; |
||
| 20 | |||
| 21 | @Named |
||
| 22 | @Scope("view") |
||
| 582 | blopes | 23 | public class AlertasComprasBean extends AbstractBean<AlertasGeralDTO> implements Serializable { |
| 568 | blopes | 24 | |
| 25 | private static final long serialVersionUID = 1L; |
||
| 26 | |||
| 582 | blopes | 27 | private AlertasService alertasService; |
| 568 | blopes | 28 | private VendaService vendaService; |
| 29 | |||
| 30 | @Inject |
||
| 582 | blopes | 31 | public AlertasComprasBean(AlertasService alertasService, VendaService vendaService) { |
| 32 | this.alertasService = alertasService; |
||
| 568 | blopes | 33 | this.vendaService = vendaService; |
| 34 | } |
||
| 35 | |||
| 36 | @Override |
||
| 582 | blopes | 37 | public GenericService<AlertasGeralDTO> getService() { |
| 568 | blopes | 38 | return null; |
| 39 | } |
||
| 40 | |||
| 41 | @Override |
||
| 582 | blopes | 42 | public AlertasGeralDTO getId() { |
| 568 | blopes | 43 | return null; |
| 44 | } |
||
| 45 | |||
| 46 | @Override |
||
| 47 | public void limparEntidade() { |
||
| 582 | blopes | 48 | setEntidade(new AlertasGeralDTO()); |
| 49 | getEntidade().setQuantidadeDiasVendas(90); |
||
| 50 | getEntidade().setTempoDeEstoqueParaAlerta(30); |
||
| 51 | getEntidade().setAdicionarModelosFavoritosSemVendas(true); |
||
| 52 | getEntidade().setTiposProdutoSelecionados(new ArrayList<TipoProduto>()); |
||
| 568 | blopes | 53 | } |
| 54 | |||
| 55 | @PostConstruct |
||
| 56 | private void iniciarConsolidacoes() { |
||
| 57 | limparEntidade(); |
||
| 582 | blopes | 58 | teste(); |
| 568 | blopes | 59 | } |
| 60 | |||
| 582 | blopes | 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())); |
||
| 568 | blopes | 74 | } |
| 75 | |||
| 76 | |||
| 582 | blopes | 77 | public void teste() { |
| 568 | blopes | 78 | limparEntidade(); |
| 79 | |||
| 80 | |||
| 582 | blopes | 81 | |
| 568 | blopes | 82 | } |
| 83 | |||
| 84 | } |