Rev 422 | Rev 591 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 422 | Rev 428 | ||
|---|---|---|---|
| Line 487... | Line 487... | ||
| 487 | this.alterar(produto); |
487 | this.alterar(produto); |
| 488 | }
|
488 | }
|
| 489 | 489 | ||
| 490 | @Override |
490 | @Override |
| 491 | public void realizarContagem(ProdutoLoja produtoLoja, Integer quantidadeEstoque, String localizacao, Usuario usuario, Boolean indicadorAvaria) { |
491 | public void realizarContagem(ProdutoLoja produtoLoja, Integer quantidadeEstoque, String localizacao, Usuario usuario, Boolean indicadorAvaria) { |
| - | 492 | verificarSeUsuarioLogadoEhVendedorOuSuperior(usuario); |
|
| 492 | if (VerificadorUtil.estaNulo(quantidadeEstoque)) { |
493 | if (VerificadorUtil.estaNulo(quantidadeEstoque)) { |
| 493 | throw new NegocioException("É preciso informar o estoque"); |
494 | throw new NegocioException("É preciso informar o estoque"); |
| 494 | }
|
495 | }
|
| 495 | verificarSeUsuarioLogadoEhVendedorOuSuperior(usuario); |
- | |
| - | 496 | if (quantidadeEstoque > 1000) { |
|
| - | 497 | throw new NegocioException("Estoque informado acima dos padrões. Sem permissão para esta operação!"); |
|
| - | 498 | }
|
|
| - | 499 | ||
| - | 500 | Integer quantidadeEstoqueAnterior = produtoLoja.getQuantidadeEstoque(); |
|
| - | 501 | Integer quantidadeEstoqueNovo = quantidadeEstoque; |
|
| - | 502 | ||
| 496 | produtoLoja.setLocalizacao(localizacao); |
503 | produtoLoja.setLocalizacao(localizacao); |
| - | 504 | produtoLoja.setDataContagemPreparacao(DataUtils.getDataAtual()); |
|
| - | 505 | produtoLoja.setDataContagem(DataUtils.getDataAtual()); |
|
| - | 506 | produtoLoja.setQuantidadeEstoqueContagem(quantidadeEstoqueNovo); |
|
| - | 507 | produtoLoja.setQuantidadeEstoque(quantidadeEstoqueNovo); |
|
| - | 508 | produtoLoja.setUsuarioUltimaContagemPreparacao(usuario); |
|
| - | 509 | produtoLoja.setUsuarioUltimaContagem(usuario); |
|
| - | 510 | produtoLojaService.alterar(produtoLoja); |
|
| - | 511 | if (quantidadeEstoqueAnterior != quantidadeEstoqueNovo) { |
|
| - | 512 | cadastrarAuditoria(usuario, produtoLoja, TipoEstoqueAuditoria.CONTAGEM.getValor(), quantidadeEstoqueAnterior, quantidadeEstoqueNovo, null, "", TipoEstoqueAuditoriaVerificacao.NAO_VERIFICADO.getValor()); |
|
| - | 513 | }
|
|
| - | 514 | if (quantidadeEstoqueNovo > 0) { |
|
| - | 515 | solicitarEntrarEmContatoCasoExistaPedidoParaLojaSolicitante(produtoLoja.getLoja(), usuario, produtoLoja.getProduto()); |
|
| - | 516 | }
|
|
| - | 517 | ||
| - | 518 | // CONTAGEM DUPLA
|
|
| - | 519 | /*
|
|
| 497 | if (VerificadorUtil.naoEstaNulo(produtoLoja.getDataContagemPreparacao())) { |
520 | if (VerificadorUtil.naoEstaNulo(produtoLoja.getDataContagemPreparacao())) {
|
| 498 | // if (diferencaMaiorEmDias(ConstantesSEC.StatusContagem.CONTAGEM_AMARELO_30_DIAS, produtoLoja.getDataContagemPreparacao(), DataUtils.getDataAtual())) {
|
- | |
| - | 521 | if (diferencaMaiorEmDias(ConstantesSEC.StatusContagem.CONTAGEM_AMARELO_30_DIAS, produtoLoja.getDataContagemPreparacao(), DataUtils.getDataAtual())) {
|
|
| 499 | produtoLoja.setDataContagemPreparacao(null); |
522 | produtoLoja.setDataContagemPreparacao(null);
|
| 500 | // }
|
- | |
| - | 523 | }
|
|
| 501 | }
|
524 | }
|
| 502 | if (VerificadorUtil.estaNulo(produtoLoja.getDataContagemPreparacao())) { |
525 | if (VerificadorUtil.estaNulo(produtoLoja.getDataContagemPreparacao())) {
|
| 503 | produtoLoja.setDataContagemPreparacao(DataUtils.getDataAtual()); |
526 | produtoLoja.setDataContagemPreparacao(DataUtils.getDataAtual());
|
| 504 | produtoLoja.setQuantidadeEstoqueContagem(quantidadeEstoque); |
527 | produtoLoja.setQuantidadeEstoqueContagem(quantidadeEstoque);
|
| 505 | produtoLoja.setUsuarioUltimaContagemPreparacao(usuario); |
528 | produtoLoja.setUsuarioUltimaContagemPreparacao(usuario);
|
| 506 | produtoLojaService.alterar(produtoLoja); |
529 | produtoLojaService.alterar(produtoLoja);
|
| - | 530 | // produtoLojaService.realizarContagem(produtoLoja);
|
|
| 507 | } else if (VerificadorUtil.estaNulo(produtoLoja.getDataContagem()) || |
531 | } else if (VerificadorUtil.estaNulo(produtoLoja.getDataContagem()) ||
|
| 508 | produtoLoja.getDataContagem().before(produtoLoja.getDataContagemPreparacao()) || |
532 | produtoLoja.getDataContagem().before(produtoLoja.getDataContagemPreparacao()) ||
|
| 509 | produtoLoja.getIndicadorContagemSolicitada() || |
533 | produtoLoja.getIndicadorContagemSolicitada() ||
|
| 510 | produtoLoja.getUsuarioUltimaContagem().equals(produtoLoja.getUsuarioUltimaContagemPreparacao())) { |
534 | produtoLoja.getUsuarioUltimaContagem().equals(produtoLoja.getUsuarioUltimaContagemPreparacao())) {
|
| 511 | verificarSeUsuarioDePreparacaoDiferente(produtoLoja, usuario); |
535 | verificarSeUsuarioDePreparacaoDiferente(produtoLoja, usuario);
|
| Line 519... | Line 543... | ||
| 519 | produtoLoja.setDataContagem(DataUtils.getDataAtual()); |
543 | produtoLoja.setDataContagem(DataUtils.getDataAtual());
|
| 520 | produtoLoja.setUsuarioUltimaContagem(usuario); |
544 | produtoLoja.setUsuarioUltimaContagem(usuario);
|
| 521 | produtoLoja.setQuantidadeEstoque(quantidadeEstoqueNovo); |
545 | produtoLoja.setQuantidadeEstoque(quantidadeEstoqueNovo);
|
| 522 | produtoLoja.setIndicadorContagemSolicitada(false); |
546 | produtoLoja.setIndicadorContagemSolicitada(false);
|
| 523 | produtoLojaService.alterar(produtoLoja); |
547 | produtoLojaService.alterar(produtoLoja);
|
| - | 548 | // produtoLojaService.realizarContagem(produtoLoja);
|
|
| 524 | if (quantidadeEstoqueAnterior != quantidadeEstoqueNovo) { |
549 | if (quantidadeEstoqueAnterior != quantidadeEstoqueNovo) {
|
| 525 | cadastrarAuditoria(usuario, produtoLoja, TipoEstoqueAuditoria.CONTAGEM.getValor(), quantidadeEstoqueAnterior, quantidadeEstoqueNovo, null, "", TipoEstoqueAuditoriaVerificacao.NAO_VERIFICADO.getValor()); |
550 | cadastrarAuditoria(usuario, produtoLoja, TipoEstoqueAuditoria.CONTAGEM.getValor(), quantidadeEstoqueAnterior, quantidadeEstoqueNovo, null, "", TipoEstoqueAuditoriaVerificacao.NAO_VERIFICADO.getValor());
|
| 526 | }
|
551 | }
|
| 527 | if (quantidadeEstoqueNovo > 0) { |
552 | if (quantidadeEstoqueNovo > 0) {
|
| 528 | solicitarEntrarEmContatoCasoExistaPedidoParaLojaSolicitante(produtoLoja.getLoja(), usuario, produtoLoja.getProduto()); |
553 | solicitarEntrarEmContatoCasoExistaPedidoParaLojaSolicitante(produtoLoja.getLoja(), usuario, produtoLoja.getProduto());
|
| 529 | }
|
554 | }
|
| 530 | }
|
555 | }
|
| 531 | } else { |
556 | } else {
|
| 532 | throw new NegocioException("Contagem indisponível, informe à gestão"); |
557 | throw new NegocioException("Contagem indisponível, informe à gestão");
|
| 533 | }
|
558 | }
|
| - | 559 | */
|
|
| 534 | }
|
560 | }
|
| 535 | 561 | ||
| 536 | private Boolean diferencaMaiorEmDias(Integer quantidadeDias, Date dataAnterior, Date dataPosterior) { |
562 | private Boolean diferencaMaiorEmDias(Integer quantidadeDias, Date dataAnterior, Date dataPosterior) { |
| 537 | Date dataComDias = DataUtils.acrescentarDias(dataAnterior, quantidadeDias); |
563 | Date dataComDias = DataUtils.acrescentarDias(dataAnterior, quantidadeDias); |
| 538 | return dataComDias.before(dataPosterior); |
564 | return dataComDias.before(dataPosterior); |