Rev 117 | 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; |
||
| 116 | espaco | 4 | import java.util.ArrayList; |
| 106 | espaco | 5 | import java.util.List; |
| 6 | |||
| 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.LojaDTO; |
||
| 13 | import br.com.ec.domain.model.AberturaLoja; |
||
| 14 | import br.com.ec.domain.model.Loja; |
||
| 15 | import br.com.ec.domain.model.Pessoa; |
||
| 16 | import br.com.ec.domain.model.Venda; |
||
| 17 | import br.com.ec.domain.model.VendaVivo; |
||
| 159 | espaco | 18 | import br.com.ec.domain.model.Vigencia; |
| 106 | espaco | 19 | import br.com.ec.domain.model.tipos.TipoEmitirNotaFiscal; |
| 20 | import br.com.ec.domain.service.aberturaloja.AberturaLojaService; |
||
| 21 | import br.com.ec.domain.service.loja.LojaService; |
||
| 22 | import br.com.ec.domain.service.produto.ProdutoService; |
||
| 23 | import br.com.ec.domain.service.transferencia.TransferenciaService; |
||
| 24 | import br.com.ec.domain.service.venda.VendaService; |
||
| 25 | import br.com.ec.domain.service.vendavivo.VendaVivoService; |
||
| 26 | import br.com.ec.domain.shared.ConstantesSEC; |
||
| 27 | import br.edu.cesmac.core.generic.GenericService; |
||
| 28 | import br.edu.cesmac.core.util.DataUtils; |
||
| 29 | import br.edu.cesmac.core.util.VerificadorUtil; |
||
| 30 | import br.edu.cesmac.web.exception.VerificadorLancamentoException; |
||
| 31 | import br.edu.cesmac.web.exception.VerificadorLancamentoException.CommandBean; |
||
| 32 | import br.edu.cesmac.web.generic.AbstractBean; |
||
| 33 | import br.edu.cesmac.web.message.LancadorMensagem; |
||
| 34 | |||
| 35 | @Named |
||
| 36 | @Scope("view") |
||
| 37 | public class LojaBean extends AbstractBean<Loja> implements Serializable { |
||
| 38 | |||
| 39 | private static final long serialVersionUID = 1L; |
||
| 40 | |||
| 41 | private LojaService lojaService; |
||
| 42 | private VendaService vendaService; |
||
| 43 | private VendaVivoService vendaVivoService; |
||
| 44 | private ProdutoService produtoService; |
||
| 45 | private AberturaLojaService aberturaLojaService; |
||
| 46 | private TransferenciaService transferenciaService; |
||
| 47 | |||
| 48 | private Loja lojaSelecionada; |
||
| 49 | private String senhaUsuarioParaAbertura; |
||
| 159 | espaco | 50 | private List<Loja> centrosDeCustos; |
| 106 | espaco | 51 | private List<Loja> listaLojasAtivas; |
| 52 | private List<Loja> listaLojasAtivasEspacoCase; |
||
| 53 | private List<Loja> listaLojas; |
||
| 54 | private List<Loja> listaLojasComDetalhes; |
||
| 55 | private List<LojaDTO> listaLojasDTOAtivas; |
||
| 56 | |||
| 57 | private Integer quantidadeNotificacoes; |
||
| 58 | private Integer quantidadeNotificacoesContagem; |
||
| 59 | private Integer quantidadeNotificacoesRetirarDoSite; |
||
| 60 | private Integer quantidadeTransferenciasParaReceberAbertas; |
||
| 61 | |||
| 116 | espaco | 62 | private Integer quantidadeVendas; |
| 106 | espaco | 63 | |
| 116 | espaco | 64 | private Boolean consultarComCasaDasCapas = false; |
| 65 | |||
| 106 | espaco | 66 | @Inject |
| 67 | public LojaBean(LojaService lojaService, VendaService vendaService, VendaVivoService vendaVivoService, |
||
| 68 | ProdutoService produtoService, AberturaLojaService aberturaLojaService, TransferenciaService transferenciaService) { |
||
| 69 | this.lojaService = lojaService; |
||
| 70 | this.vendaService = vendaService; |
||
| 71 | this.vendaVivoService = vendaVivoService; |
||
| 72 | this.produtoService = produtoService; |
||
| 73 | this.aberturaLojaService = aberturaLojaService; |
||
| 74 | this.transferenciaService = transferenciaService; |
||
| 75 | } |
||
| 76 | |||
| 77 | @Override |
||
| 78 | public void limparEntidade() { |
||
| 79 | setEntidade(new Loja()); |
||
| 80 | } |
||
| 81 | |||
| 82 | @Override |
||
| 83 | public GenericService<Loja> getService() { |
||
| 84 | return lojaService; |
||
| 85 | } |
||
| 86 | |||
| 87 | @Override |
||
| 88 | public Loja getEntidade() { |
||
| 89 | return entidade; |
||
| 90 | } |
||
| 91 | |||
| 92 | @Override |
||
| 93 | public Loja getId() { |
||
| 94 | return getEntidade(); |
||
| 95 | } |
||
| 96 | |||
| 97 | public Loja getLojaSelecionada() { |
||
| 98 | if (VerificadorUtil.estaNulo(lojaSelecionada)) { |
||
| 99 | if (VerificadorUtil.naoEstaNulo(getParametro("sequencialLoja"))) { |
||
| 100 | Loja loja = new Loja(); |
||
| 101 | loja.setSequencial(new Long(getParametro("sequencialLoja").toString())); |
||
| 102 | lojaSelecionada = lojaService.consultarPorId(loja); |
||
| 103 | } |
||
| 104 | } |
||
| 105 | return lojaSelecionada; |
||
| 106 | } |
||
| 107 | public void setLojaSelecionada(Loja lojaSelecionada) { |
||
| 108 | this.lojaSelecionada = lojaSelecionada; |
||
| 109 | } |
||
| 110 | |||
| 111 | public String getSenhaUsuarioParaAbertura() { |
||
| 112 | return senhaUsuarioParaAbertura; |
||
| 113 | } |
||
| 114 | public void setSenhaUsuarioParaAbertura(String senhaUsuarioParaAbertura) { |
||
| 115 | this.senhaUsuarioParaAbertura = senhaUsuarioParaAbertura; |
||
| 116 | } |
||
| 117 | |||
| 159 | espaco | 118 | public List<Loja> getCentrosDeCustos() { |
| 119 | if (VerificadorUtil.estaNuloOuVazio(centrosDeCustos)) { |
||
| 120 | List<Loja> lojasAtivas = new ArrayList<Loja>(); |
||
| 121 | lojasAtivas.add(new Loja(new Long(-1), "SEM CENTRO DE CUSTOS")); |
||
| 122 | lojasAtivas.addAll(getListaLojasAtivas()); |
||
| 123 | setCentrosDeCustos(lojasAtivas); |
||
| 124 | } |
||
| 125 | return centrosDeCustos; |
||
| 126 | } |
||
| 127 | public void setCentrosDeCustos(List<Loja> centrosDeCustos) { |
||
| 128 | this.centrosDeCustos = centrosDeCustos; |
||
| 129 | } |
||
| 130 | |||
| 106 | espaco | 131 | public List<Loja> getListaLojasAtivas() { |
| 132 | if (VerificadorUtil.estaNulo(listaLojasAtivas)) { |
||
| 133 | setListaLojasAtivas(lojaService.listarLojasAtivas()); |
||
| 134 | } |
||
| 135 | return listaLojasAtivas; |
||
| 136 | } |
||
| 137 | public void setListaLojasAtivas(List<Loja> listaLojasAtivas) { |
||
| 138 | this.listaLojasAtivas = listaLojasAtivas; |
||
| 139 | } |
||
| 140 | |||
| 141 | public List<Loja> getListaLojasAtivasEspacoCase() { |
||
| 142 | if (VerificadorUtil.estaNulo(listaLojasAtivasEspacoCase)) { |
||
| 143 | setListaLojasAtivasEspacoCase(lojaService.listarLojasAtivasEspacoCase()); |
||
| 144 | } |
||
| 145 | return listaLojasAtivasEspacoCase; |
||
| 146 | } |
||
| 147 | public void setListaLojasAtivasEspacoCase(List<Loja> listaLojasAtivasEspacoCase) { |
||
| 148 | this.listaLojasAtivasEspacoCase = listaLojasAtivasEspacoCase; |
||
| 149 | } |
||
| 116 | espaco | 150 | public List<Loja> listaLojasAtivasEspacoCase(Boolean comCasaDasCapas) { |
| 151 | Loja lojaCasaDasCapas = new Loja(ConstantesSEC.SEQUENCIAL_CASA_DAS_CAPAS_17); |
||
| 152 | if (comCasaDasCapas) { |
||
| 153 | if (!getListaLojasAtivasEspacoCase().contains(lojaCasaDasCapas)) { |
||
| 154 | setListaLojasAtivasEspacoCase(lojaService.listarLojasAtivasEspacoCaseEeCasaDasCapas()); |
||
| 155 | } |
||
| 156 | } else { |
||
| 157 | getListaLojasAtivasEspacoCase().remove(lojaCasaDasCapas); |
||
| 158 | } |
||
| 159 | return getListaLojasAtivasEspacoCase(); |
||
| 160 | } |
||
| 106 | espaco | 161 | |
| 162 | public List<Loja> getListaLojas() { |
||
| 163 | if (VerificadorUtil.estaNulo(listaLojas)) { |
||
| 164 | setListaLojas(lojaService.consultarTodos(new Loja())); |
||
| 165 | } |
||
| 166 | return listaLojas; |
||
| 167 | } |
||
| 168 | public void setListaLojas(List<Loja> listaLojas) { |
||
| 169 | this.listaLojas = listaLojas; |
||
| 170 | } |
||
| 171 | |||
| 172 | public List<Loja> getListaLojasComDetalhes() { |
||
| 173 | if (VerificadorUtil.estaNulo(listaLojasComDetalhes)) { |
||
| 174 | setListaLojasComDetalhes(lojaService.listarLojasComDetalhe()); |
||
| 175 | } |
||
| 176 | return listaLojasComDetalhes; |
||
| 177 | } |
||
| 178 | public void setListaLojasComDetalhes(List<Loja> listaLojasComDetalhes) { |
||
| 179 | this.listaLojasComDetalhes = listaLojasComDetalhes; |
||
| 180 | } |
||
| 181 | |||
| 182 | public List<LojaDTO> getListaLojasDTOAtivas() { |
||
| 183 | if (VerificadorUtil.estaNulo(listaLojasDTOAtivas)) { |
||
| 184 | setListaLojasDTOAtivas(lojaService.listarLojasDTOAtivas()); |
||
| 185 | } |
||
| 186 | return listaLojasDTOAtivas; |
||
| 187 | } |
||
| 188 | public void setListaLojasDTOAtivas(List<LojaDTO> listaLojasDTOAtivas) { |
||
| 189 | this.listaLojasDTOAtivas = listaLojasDTOAtivas; |
||
| 190 | } |
||
| 191 | |||
| 192 | public Integer getQuantidadeNotificacoes() { |
||
| 193 | if (VerificadorUtil.naoEstaNulo(getLojaSelecionada())) { |
||
| 194 | if (VerificadorUtil.estaNulo(quantidadeNotificacoes)) { |
||
| 195 | setQuantidadeNotificacoes(quantidadeNotificacoes()); |
||
| 196 | } |
||
| 197 | } |
||
| 198 | return quantidadeNotificacoes; |
||
| 199 | } |
||
| 200 | public void setQuantidadeNotificacoes(Integer quantidadeNotificacoes) { |
||
| 201 | this.quantidadeNotificacoes = quantidadeNotificacoes; |
||
| 202 | } |
||
| 203 | |||
| 204 | public Integer getQuantidadeNotificacoesContagem() { |
||
| 205 | if (VerificadorUtil.naoEstaNulo(getLojaSelecionada())) { |
||
| 206 | if (VerificadorUtil.estaNulo(quantidadeNotificacoesContagem)) { |
||
| 207 | setQuantidadeNotificacoesContagem(quantidadeNotificacoesContagem(getLojaSelecionada())); |
||
| 208 | } |
||
| 209 | } |
||
| 210 | return quantidadeNotificacoesContagem; |
||
| 211 | } |
||
| 212 | public void setQuantidadeNotificacoesContagem(Integer quantidadeNotificacoesContagem) { |
||
| 213 | this.quantidadeNotificacoesContagem = quantidadeNotificacoesContagem; |
||
| 214 | } |
||
| 215 | |||
| 216 | public Integer getQuantidadeNotificacoesRetirarDoSite() { |
||
| 217 | if (VerificadorUtil.naoEstaNulo(getLojaSelecionada())) { |
||
| 218 | if (VerificadorUtil.estaNulo(quantidadeNotificacoesRetirarDoSite)) { |
||
| 219 | setQuantidadeNotificacoesRetirarDoSite(quantidadeNotificacoesRetirarDoSite(getLojaSelecionada())); |
||
| 220 | } |
||
| 221 | } |
||
| 222 | return quantidadeNotificacoesRetirarDoSite; |
||
| 223 | } |
||
| 224 | public void setQuantidadeNotificacoesRetirarDoSite(Integer quantidadeNotificacoesRetirarDoSite) { |
||
| 225 | this.quantidadeNotificacoesRetirarDoSite = quantidadeNotificacoesRetirarDoSite; |
||
| 226 | } |
||
| 227 | |||
| 228 | public Integer getQuantidadeTransferenciasParaReceberAbertas() { |
||
| 229 | if (VerificadorUtil.naoEstaNulo(getLojaSelecionada())) { |
||
| 230 | if (VerificadorUtil.estaNulo(quantidadeTransferenciasParaReceberAbertas)) { |
||
| 231 | setQuantidadeTransferenciasParaReceberAbertas(quantidadeTransferenciasAbertasParaReceber(getLojaSelecionada())); |
||
| 232 | } |
||
| 233 | } |
||
| 234 | return quantidadeTransferenciasParaReceberAbertas; |
||
| 235 | } |
||
| 236 | public void setQuantidadeTransferenciasParaReceberAbertas(Integer quantidadeTransferenciasParaReceberAbertas) { |
||
| 237 | this.quantidadeTransferenciasParaReceberAbertas = quantidadeTransferenciasParaReceberAbertas; |
||
| 238 | } |
||
| 239 | |||
| 240 | /***************************************************************/ |
||
| 241 | |||
| 242 | public TipoEmitirNotaFiscal[] getTiposEmitirNotaFiscal() { |
||
| 243 | return TipoEmitirNotaFiscal.values(); |
||
| 244 | } |
||
| 245 | |||
| 246 | public boolean lojaEstaAberta(Loja loja) { |
||
| 247 | return VerificadorUtil.naoEstaNulo(aberturaLojaService.consultarAberturaLoja(DataUtils.getDataAtual(), loja)); |
||
| 248 | } |
||
| 249 | |||
| 250 | public AberturaLoja consultarAberturaLoja(Long sequencialLoja) { |
||
| 251 | return aberturaLojaService.consultarAberturaLoja(DataUtils.getDataAtual(), new Loja(sequencialLoja)); |
||
| 252 | } |
||
| 253 | |||
| 254 | public void abrirLoja() { |
||
| 255 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 256 | public void execute() { |
||
| 257 | aberturaLojaService.abrirLoja(getSenhaUsuarioParaAbertura(), getLojaSelecionada()); |
||
| 258 | LancadorMensagem.lancarSucessoRedirecionandoTela("ABERTURA DE LOJA REALIZADA COM SUCESSO!", "/sistema/loja.xhtml?sequencialLoja=" + getLojaSelecionada().getSequencial()); |
||
| 259 | } |
||
| 260 | }); |
||
| 261 | } |
||
| 262 | |||
| 263 | public Integer getQuantidadeVendas() { |
||
| 264 | return quantidadeVendas; |
||
| 265 | } |
||
| 266 | public void setQuantidadeVendas(Integer quantidadeVendas) { |
||
| 267 | this.quantidadeVendas = quantidadeVendas; |
||
| 268 | } |
||
| 269 | public Integer quantidadeVendas(Loja loja) { |
||
| 270 | if (VerificadorUtil.estaNulo(getQuantidadeVendas())) { |
||
| 271 | Venda venda = new Venda(); |
||
| 272 | venda.setLoja(loja); |
||
| 273 | setQuantidadeVendas(vendaService.obterQuantidadeDeVendasPorLojaEePeriodo(venda, DataUtils.getDataAtual(), DataUtils.getDataAtual())); |
||
| 274 | } |
||
| 275 | return getQuantidadeVendas(); |
||
| 276 | } |
||
| 277 | |||
| 116 | espaco | 278 | public Boolean getConsultarComCasaDasCapas() { |
| 279 | return consultarComCasaDasCapas; |
||
| 280 | } |
||
| 281 | public void setConsultarComCasaDasCapas(Boolean consultarComCasaDasCapas) { |
||
| 282 | this.consultarComCasaDasCapas = consultarComCasaDasCapas; |
||
| 283 | } |
||
| 284 | |||
| 106 | espaco | 285 | public Integer quantidadeVendasVivo(Loja loja) { |
| 286 | VendaVivo venda = new VendaVivo(); |
||
| 287 | venda.setLoja(loja); |
||
| 288 | return vendaVivoService.obterQuantidadeDeVendasPorLojaEePeriodo(venda, DataUtils.getDataAtual(), DataUtils.getDataAtual()); |
||
| 289 | } |
||
| 290 | |||
| 291 | public Integer quantidadeNotificacoes(Loja loja) { |
||
| 292 | Integer notificacoes = 0; |
||
| 293 | if (VerificadorUtil.naoEstaNulo(loja)) { |
||
| 294 | if (quantidadeNotificacoesContagem(loja) > 0) {notificacoes++;} |
||
| 295 | } |
||
| 296 | return notificacoes; |
||
| 297 | } |
||
| 298 | |||
| 299 | public Integer quantidadeNotificacoes(Integer quantidadeNotificacoesContagem) { |
||
| 300 | Integer notificacoes = 0; |
||
| 301 | if (VerificadorUtil.naoEstaNulo(quantidadeNotificacoesContagem)) { |
||
| 302 | if (quantidadeNotificacoesContagem > 0) {notificacoes++;} |
||
| 303 | } |
||
| 304 | return notificacoes; |
||
| 305 | } |
||
| 306 | |||
| 307 | public Integer quantidadeNotificacoes() { |
||
| 308 | Integer notificacoes = 0; |
||
| 309 | if (VerificadorUtil.naoEstaNulo(getQuantidadeNotificacoesContagem())) { |
||
| 310 | if (getQuantidadeNotificacoesContagem() > 0) {notificacoes++;} |
||
| 311 | } |
||
| 312 | return notificacoes; |
||
| 313 | } |
||
| 314 | |||
| 315 | public Integer quantidadeNotificacoesContagem(Loja loja) { |
||
| 316 | return produtoService.quantidadeParaContagem(loja); |
||
| 317 | } |
||
| 318 | |||
| 319 | public Integer quantidadeNotificacoesRetirarDoSite(Loja loja) { |
||
| 320 | return produtoService.quantidadeProdutosParaRetirarDoOnline(loja); |
||
| 321 | } |
||
| 322 | |||
| 323 | public Integer quantidadeTransferenciasAbertasParaReceber(Loja loja) { |
||
| 324 | return transferenciaService.obterQuantidadeDeTransferenciasParaReceberAbertas(loja, null, null); |
||
| 325 | } |
||
| 326 | |||
| 327 | public void selecionarPessoaJuridica(final Pessoa pessoa) { |
||
| 328 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 329 | public void execute() { |
||
| 330 | getEntidade().setPessoaJuridica(pessoa); |
||
| 331 | adicionandoParametroArgsConfirmandoAcao(true); |
||
| 332 | } |
||
| 333 | }); |
||
| 334 | } |
||
| 335 | |||
| 336 | public void retirarPessoaJuridica() { |
||
| 337 | getEntidade().setPessoaJuridica(null); |
||
| 338 | } |
||
| 339 | |||
| 340 | /***************************************************************/ |
||
| 341 | |||
| 342 | public Long getSequencialQuiosqueExtra() { |
||
| 343 | return ConstantesSEC.SEQUENCIAL_QUIOSQUE_EXTRA_2; |
||
| 344 | } |
||
| 345 | |||
| 346 | public Long getSequencialLojaVivo() { |
||
| 347 | return ConstantesSEC.SEQUENCIAL_LOJA_VIVO_4; |
||
| 348 | } |
||
| 349 | |||
| 350 | public Long getSequencialMatrizEstoque() { |
||
| 351 | return ConstantesSEC.SEQUENCIAL_MATRIZ_ESTOQUE_9; |
||
| 352 | } |
||
| 353 | |||
| 354 | public Long getSequencialLojaFarmacia() { |
||
| 355 | return ConstantesSEC.SEQUENCIAL_LOJA_FARMACIA_7; |
||
| 356 | } |
||
| 357 | |||
| 358 | public Long getSequencialRestaurante() { |
||
| 359 | return ConstantesSEC.SEQUENCIAL_RESTAURANTE_16; |
||
| 360 | } |
||
| 361 | |||
| 362 | public Long getSequencialCasaDasCapas() { |
||
| 363 | return ConstantesSEC.SEQUENCIAL_CASA_DAS_CAPAS_17; |
||
| 364 | } |
||
| 365 | |||
| 366 | } |