Rev 258 | 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.ArrayList; |
||
| 5 | import java.util.Date; |
||
| 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 | |||
| 195 | espaco | 14 | import br.com.ec.core.consulta.ParametrosConsulta; |
| 15 | import br.com.ec.core.generic.GenericService; |
||
| 16 | import br.com.ec.core.util.DataUtils; |
||
| 106 | espaco | 17 | import br.com.ec.domain.dto.DashboardLogisticaDTO; |
| 18 | import br.com.ec.domain.dto.LojaDTO; |
||
| 19 | import br.com.ec.domain.model.Loja; |
||
| 20 | import br.com.ec.domain.model.Perfil; |
||
| 21 | import br.com.ec.domain.model.tipos.TipoProduto; |
||
| 22 | import br.com.ec.domain.service.loja.LojaService; |
||
| 23 | import br.com.ec.domain.service.pendencia.PendenciaService; |
||
| 24 | import br.com.ec.domain.service.produto.ProdutoService; |
||
| 25 | import br.com.ec.domain.service.produtodaloja.ProdutoLojaService; |
||
| 26 | import br.com.ec.domain.service.transferencia.TransferenciaService; |
||
| 27 | import br.com.ec.domain.shared.ConstantesSEC; |
||
| 195 | espaco | 28 | import br.com.ec.web.generic.AbstractBean; |
| 106 | espaco | 29 | |
| 30 | @Named |
||
| 31 | @Scope("view") |
||
| 32 | public class DashboardLogisticaBean extends AbstractBean<DashboardLogisticaDTO> implements Serializable { |
||
| 33 | |||
| 34 | private static final long serialVersionUID = 1L; |
||
| 35 | |||
| 36 | private LojaService lojaService; |
||
| 37 | private ProdutoLojaService produtoLojaService; |
||
| 38 | private ProdutoService produtoService; |
||
| 39 | private PendenciaService pendenciaService; |
||
| 40 | private TransferenciaService transferenciaService; |
||
| 41 | |||
| 42 | private List<DashboardLogisticaDTO> acompanhamentos; |
||
| 43 | |||
| 44 | @Inject |
||
| 45 | public DashboardLogisticaBean(LojaService lojaService, ProdutoLojaService produtoLojaService, ProdutoService produtoService, |
||
| 46 | PendenciaService pendenciaService, TransferenciaService transferenciaService) { |
||
| 47 | this.lojaService = lojaService; |
||
| 48 | this.produtoLojaService = produtoLojaService; |
||
| 49 | this.produtoService = produtoService; |
||
| 50 | this.pendenciaService = pendenciaService; |
||
| 51 | this.transferenciaService = transferenciaService; |
||
| 52 | } |
||
| 53 | |||
| 54 | @PostConstruct |
||
| 55 | private void iniciarDashboard() { |
||
| 56 | List<DashboardLogisticaDTO> acompanhamentos = new ArrayList<DashboardLogisticaDTO>(); |
||
| 124 | espaco | 57 | List<Loja> lojas = lojaService.listarLojasAtivasEspacoCaseEeCasaDasCapas(); |
| 106 | espaco | 58 | for (Loja loja : lojas) { |
| 59 | DashboardLogisticaDTO acompanhamento = new DashboardLogisticaDTO(); |
||
| 60 | LojaDTO lojaDTO = new LojaDTO(); |
||
| 61 | lojaDTO.setSequencial(loja.getSequencial()); |
||
| 62 | lojaDTO.setDescricao(loja.getDescricao()); |
||
| 63 | lojaDTO.setLimitadorProdutos(loja.getLimitadorProdutos()); |
||
| 64 | |||
| 65 | acompanhamento.setLojaDTO(lojaDTO); |
||
| 66 | acompanhamento.setQuantidadeEstoqueTotal(produtoLojaService.consultarEstoqueTipoProdutoEeLoja(TipoProduto.CAPA.getValor(), loja.getSequencial())); |
||
| 305 | espaco | 67 | acompanhamento.setQuantidadePendencias(pendenciaService.obterQuantidadePendenciasNaoFinalizadasPorLojaPerfilEePeriodo(loja, new Perfil(ConstantesSEC.PERFIL_LOJISTICA_4), null, null)); |
| 106 | espaco | 68 | acompanhamento.setQuantidadeTransferenciasParaReceberAbertas(transferenciaService.obterQuantidadeDeTransferenciasParaReceberAbertas(loja, null, null)); |
| 69 | acompanhamento.setQuantidadeContagensAbertas(produtoService.quantidadeParaContagem(loja)); |
||
| 70 | acompanhamento.setQuantidadeContagensRealizadas(produtoLojaService.obterQuantidadeDeContagens(loja, DataUtils.getDataAtual(), DataUtils.getDataAtual())); |
||
| 71 | |||
| 72 | Date cincoDiasAntes = DataUtils.acrescentarDias(DataUtils.getDataAtual(), -5); |
||
| 73 | acompanhamento.setQuantidadeAlertaTransferenciasAbertasPorMaiorPeriodo(transferenciaService.obterQuantidadeDeTransferenciasParaReceberAbertas(loja, null, cincoDiasAntes)); |
||
| 74 | |||
| 75 | Date seteDiasAntes = DataUtils.acrescentarDias(DataUtils.getDataAtual(), -7); |
||
| 305 | espaco | 76 | acompanhamento.setQuantidadeAlertaPendenciasAbertasPorMaiorPeriodo(pendenciaService.obterQuantidadePendenciasNaoFinalizadasPorLojaPerfilEePeriodo(loja, new Perfil(ConstantesSEC.PERFIL_LOJISTICA_4), null, seteDiasAntes)); |
| 258 | espaco | 77 | if (!loja.getSequencial().equals(ConstantesSEC.SEQUENCIAL_CASA_DAS_CAPAS_17)) { |
| 78 | acompanhamento.setQuantidadeAlertaModelosNaoFavoritos(produtoLojaService.obterQuantidadeEstoqueModelosNaoFavoritos(TipoProduto.CAPA.getValor(), loja.getSequencial())); |
||
| 79 | } else { |
||
| 80 | acompanhamento.setQuantidadeAlertaModelosNaoFavoritos(0); |
||
| 81 | } |
||
| 106 | espaco | 82 | |
| 83 | acompanhamentos.add(acompanhamento); |
||
| 84 | } |
||
| 85 | setAcompanhamentos(acompanhamentos); |
||
| 86 | } |
||
| 87 | |||
| 88 | @Override |
||
| 89 | public void preCarregamento() { |
||
| 90 | entidade = new DashboardLogisticaDTO(); |
||
| 91 | parametrosConsulta = new ParametrosConsulta<DashboardLogisticaDTO>(); |
||
| 92 | parametrosConsulta.setEntidade(entidade); |
||
| 93 | } |
||
| 94 | |||
| 95 | @Override |
||
| 96 | public void limparEntidade() { |
||
| 97 | DashboardLogisticaDTO consolidado = new DashboardLogisticaDTO(); |
||
| 98 | setEntidade(consolidado); |
||
| 99 | } |
||
| 100 | |||
| 101 | @Override |
||
| 102 | public GenericService<DashboardLogisticaDTO> getService() { |
||
| 103 | return null; |
||
| 104 | } |
||
| 105 | |||
| 106 | @Override |
||
| 107 | public DashboardLogisticaDTO getEntidade() { |
||
| 108 | return entidade; |
||
| 109 | } |
||
| 110 | |||
| 111 | @Override |
||
| 112 | public DashboardLogisticaDTO getId() { |
||
| 113 | return getEntidade(); |
||
| 114 | } |
||
| 115 | |||
| 116 | public List<DashboardLogisticaDTO> getAcompanhamentos() { |
||
| 117 | return acompanhamentos; |
||
| 118 | } |
||
| 119 | public void setAcompanhamentos(List<DashboardLogisticaDTO> acompanhamentos) { |
||
| 120 | this.acompanhamentos = acompanhamentos; |
||
| 121 | } |
||
| 122 | |||
| 123 | } |