Rev 106 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 106 | espaco | 1 | package br.com.ec.controller.managedbean; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | import java.util.Date; |
||
| 5 | |||
| 6 | import javax.annotation.PostConstruct; |
||
| 7 | import javax.inject.Inject; |
||
| 8 | import javax.inject.Named; |
||
| 9 | |||
| 10 | import org.springframework.context.annotation.Scope; |
||
| 11 | |||
| 195 | espaco | 12 | import br.com.ec.core.consulta.ParametrosConsulta; |
| 13 | import br.com.ec.core.generic.GenericService; |
||
| 14 | import br.com.ec.core.util.DataUtils; |
||
| 106 | espaco | 15 | import br.com.ec.domain.dto.DashboardComprasDTO; |
| 16 | import br.com.ec.domain.model.tipos.TipoPedido; |
||
| 17 | import br.com.ec.domain.model.tipos.TipoSituacaoPedido; |
||
| 18 | import br.com.ec.domain.service.estoqueauditoria.EstoqueAuditoriaService; |
||
| 19 | import br.com.ec.domain.service.pedido.PedidoService; |
||
| 20 | import br.com.ec.domain.service.produto.ProdutoService; |
||
| 195 | espaco | 21 | import br.com.ec.web.generic.AbstractBean; |
| 106 | espaco | 22 | |
| 23 | @Named |
||
| 24 | @Scope("view") |
||
| 25 | public class DashboardComprasBean extends AbstractBean<DashboardComprasDTO> implements Serializable { |
||
| 26 | |||
| 27 | private static final long serialVersionUID = 1L; |
||
| 28 | |||
| 29 | private PedidoService pedidoService; |
||
| 30 | private EstoqueAuditoriaService estoqueAuditoriaService; |
||
| 31 | |||
| 32 | private DashboardComprasDTO acompanhamentoDia; |
||
| 33 | |||
| 34 | @Inject |
||
| 35 | public DashboardComprasBean(PedidoService pedidoService, ProdutoService produtoService, EstoqueAuditoriaService estoqueAuditoriaService) { |
||
| 36 | this.pedidoService = pedidoService; |
||
| 37 | this.estoqueAuditoriaService = estoqueAuditoriaService; |
||
| 38 | } |
||
| 39 | |||
| 40 | @PostConstruct |
||
| 41 | private void iniciarDashboard() { |
||
| 42 | Integer quantidePedidosPendentesAnaliseDeCompras = pedidoService.obterQuantidadePedidosPorSituacao(TipoPedido.RESERVA.getValor(), TipoSituacaoPedido.PENDENTE_ANALISE_COMPRAS.getValor()); |
||
| 43 | Integer quantidadePedidosEmCompras = pedidoService.obterQuantidadePedidosPorSituacao(TipoPedido.RESERVA.getValor(), TipoSituacaoPedido.PEDIDO_EM_COMPRAS.getValor()); |
||
| 44 | |||
| 45 | //INDICADORES |
||
| 46 | setAcompanhamentoDia(new DashboardComprasDTO()); |
||
| 47 | getAcompanhamentoDia().setQuantidadePedidosPendentesAnaliseDeCompras(quantidePedidosPendentesAnaliseDeCompras); |
||
| 48 | getAcompanhamentoDia().setQuantidadePedidosEmCompras(quantidadePedidosEmCompras); |
||
| 49 | getAcompanhamentoDia().setQuantidadeAuditoriasNaoVerificadas(estoqueAuditoriaService.quantidadeAuditoriasNaoVerificadas(null)); |
||
| 50 | |||
| 51 | // ALERTAS |
||
| 52 | Date tresDiasAntes = DataUtils.acrescentarDias(DataUtils.getDataAtual(), -3); |
||
| 53 | Integer pedidosAlertasPendentesAnaliseDeComprasComTresDiasPassados = pedidoService.obterQuantidadePedidosPorSituacaoEePeriodo(TipoPedido.RESERVA.getValor(), TipoSituacaoPedido.PENDENTE_ANALISE_COMPRAS.getValor(), tresDiasAntes, DataUtils.getDataAtual()); |
||
| 54 | |||
| 55 | Date quinzeDiasAntes = DataUtils.acrescentarDias(DataUtils.getDataAtual(), -15); |
||
| 56 | Integer pedidosAlertasEmComprasComQuinzeDiasPassados = pedidoService.obterQuantidadePedidosPorSituacaoEePeriodo(TipoPedido.RESERVA.getValor(), TipoSituacaoPedido.PEDIDO_EM_COMPRAS.getValor(), quinzeDiasAntes, DataUtils.getDataAtual()); |
||
| 57 | |||
| 58 | Date seteDiasPassados = DataUtils.acrescentarDias(DataUtils.getDataAtual(), -7); |
||
| 59 | Integer auditoriasPendentesComSeteDiasPassados = estoqueAuditoriaService.quantidadeAuditoriasNaoVerificadas(seteDiasPassados); |
||
| 60 | |||
| 61 | getAcompanhamentoDia().setQuantidadeAlertaPedidosPendentesAnaliseDeCompras(pedidosAlertasPendentesAnaliseDeComprasComTresDiasPassados); |
||
| 62 | getAcompanhamentoDia().setQuantidadeAlertaPedidosEmCompras(pedidosAlertasEmComprasComQuinzeDiasPassados); |
||
| 63 | getAcompanhamentoDia().setQuantidadeAlertaAuditoriasPendentes(auditoriasPendentesComSeteDiasPassados); |
||
| 64 | } |
||
| 65 | |||
| 66 | @Override |
||
| 67 | public void preCarregamento() { |
||
| 68 | entidade = new DashboardComprasDTO(); |
||
| 69 | parametrosConsulta = new ParametrosConsulta<DashboardComprasDTO>(); |
||
| 70 | parametrosConsulta.setEntidade(entidade); |
||
| 71 | } |
||
| 72 | |||
| 73 | @Override |
||
| 74 | public void limparEntidade() { |
||
| 75 | DashboardComprasDTO consolidado = new DashboardComprasDTO(); |
||
| 76 | setEntidade(consolidado); |
||
| 77 | } |
||
| 78 | |||
| 79 | @Override |
||
| 80 | public GenericService<DashboardComprasDTO> getService() { |
||
| 81 | return null; |
||
| 82 | } |
||
| 83 | |||
| 84 | @Override |
||
| 85 | public DashboardComprasDTO getEntidade() { |
||
| 86 | return entidade; |
||
| 87 | } |
||
| 88 | |||
| 89 | @Override |
||
| 90 | public DashboardComprasDTO getId() { |
||
| 91 | return getEntidade(); |
||
| 92 | } |
||
| 93 | |||
| 94 | public DashboardComprasDTO getAcompanhamentoDia() { |
||
| 95 | return acompanhamentoDia; |
||
| 96 | } |
||
| 97 | public void setAcompanhamentoDia(DashboardComprasDTO consolidadoDia) { |
||
| 98 | this.acompanhamentoDia = consolidadoDia; |
||
| 99 | } |
||
| 100 | |||
| 101 | } |