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