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