From 805c691fbcb22053c41a15779608863b1f84fb5c Mon Sep 17 00:00:00 2001 From: leonardo Date: Fri, 30 Dec 2016 14:03:58 +0000 Subject: [PATCH] bug #7788 git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@64349 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../service/impl/PuntoVentaServiceImpl.java | 154 +++++++++--------- 1 file changed, 78 insertions(+), 76 deletions(-) diff --git a/src/com/rjconsultores/ventaboletos/service/impl/PuntoVentaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/PuntoVentaServiceImpl.java index 7dde310cc..9729df983 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/PuntoVentaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/PuntoVentaServiceImpl.java @@ -95,48 +95,49 @@ public class PuntoVentaServiceImpl implements PuntoVentaService { entidad.setActivo(Boolean.TRUE); Exception respEx = null; - if (ApplicationProperties.getInstance().integracionTotvs()) { - try { - - if (entidad.getIndIntegracion() == null || (entidad.getIndIntegracion().equals(TipoRetorno.PENDENTE.getValor()) - || entidad.getIndIntegracion().equals(TipoRetorno.ERRO.getValor()))) { - String resp = integracionTotvs(entidad); - - TipoRetorno retornoTotvs = RetornoTotvs.validaRetornoTotvs(resp); - - switch (retornoTotvs) { - case CONCLUIDA: - entidad.setIndIntegracion(TipoRetorno.CONCLUIDA.getValor()); - break; - - case JA_CADASTRADA: - entidad.setIndIntegracion(TipoRetorno.JA_CADASTRADA.getValor()); - respEx = new IntegracionException(Atributos.MSG_ERRO_JA_CADASTRADO); - break; - - case ERRO: - entidad.setIndIntegracion(TipoRetorno.ERRO.getValor()); - respEx = new IntegracionException(Atributos.MSG_ERRO_GENERICA + resp); - break; - - default: - break; + if (!constanteService.buscarPorNomeConstante("WS_TOTVS_DESATIVA_INTEGRACAO").getValorconstante().equals("1")){ + if (ApplicationProperties.getInstance().integracionTotvs()) { + try { + + if (entidad.getIndIntegracion() == null || (entidad.getIndIntegracion().equals(TipoRetorno.PENDENTE.getValor()) + || entidad.getIndIntegracion().equals(TipoRetorno.ERRO.getValor()))) { + String resp = integracionTotvs(entidad); + + TipoRetorno retornoTotvs = RetornoTotvs.validaRetornoTotvs(resp); + + switch (retornoTotvs) { + case CONCLUIDA: + entidad.setIndIntegracion(TipoRetorno.CONCLUIDA.getValor()); + break; + + case JA_CADASTRADA: + entidad.setIndIntegracion(TipoRetorno.JA_CADASTRADA.getValor()); + respEx = new IntegracionException(Atributos.MSG_ERRO_JA_CADASTRADO); + break; + + case ERRO: + entidad.setIndIntegracion(TipoRetorno.ERRO.getValor()); + respEx = new IntegracionException(Atributos.MSG_ERRO_GENERICA + resp); + break; + + default: + break; + } + } else { + respEx = new IntegracionException(Atributos.MSG_ERRO_NAO_ENVIO); } - } else { - respEx = new IntegracionException(Atributos.MSG_ERRO_NAO_ENVIO); + } catch (ValidacionCampoException ev) { + entidad.setIndIntegracion(TipoRetorno.ERRO.getValor()); + respEx = ev; + + } catch (Exception e) { + entidad.setIndIntegracion(TipoRetorno.ERRO.getValor()); + log.error(Atributos.MSG_ERRO_GENERICA, e); + respEx = new IntegracionException(Atributos.MSG_ERRO_GENERICA + e.getMessage()); } - } catch (ValidacionCampoException ev) { - entidad.setIndIntegracion(TipoRetorno.ERRO.getValor()); - respEx = ev; - - } catch (Exception e) { - entidad.setIndIntegracion(TipoRetorno.ERRO.getValor()); - log.error(Atributos.MSG_ERRO_GENERICA, e); - respEx = new IntegracionException(Atributos.MSG_ERRO_GENERICA + e.getMessage()); + } - } - if (respEx != null) { if (respEx instanceof ValidacionCampoException) { throw (ValidacionCampoException) respEx; @@ -327,47 +328,48 @@ public class PuntoVentaServiceImpl implements PuntoVentaService { Exception respEx = null; - if (ApplicationProperties.getInstance().integracionTotvs()) { - - try { - if (entidad.getIndIntegracion() == null || (entidad.getIndIntegracion().equals(TipoRetorno.PENDENTE.getValor()) - || entidad.getIndIntegracion().equals(TipoRetorno.ERRO.getValor()))) { - String resp = integracionTotvs(entidad); - - TipoRetorno retornoTotvs = RetornoTotvs.validaRetornoTotvs(resp); - - switch (retornoTotvs) { - case CONCLUIDA: - entidad.setIndIntegracion(TipoRetorno.CONCLUIDA.getValor()); - break; - - case JA_CADASTRADA: - entidad.setIndIntegracion(TipoRetorno.JA_CADASTRADA.getValor()); - respEx = new IntegracionException(Atributos.MSG_ERRO_JA_CADASTRADO); - break; - - case ERRO: - entidad.setIndIntegracion(TipoRetorno.ERRO.getValor()); - respEx = new IntegracionException(Atributos.MSG_ERRO_GENERICA + resp); - break; - - default: - break; + if (!constanteService.buscarPorNomeConstante("WS_TOTVS_DESATIVA_INTEGRACAO").getValorconstante().equals("1")){ + if (ApplicationProperties.getInstance().integracionTotvs()) { + + try { + if (entidad.getIndIntegracion() == null || (entidad.getIndIntegracion().equals(TipoRetorno.PENDENTE.getValor()) + || entidad.getIndIntegracion().equals(TipoRetorno.ERRO.getValor()))) { + String resp = integracionTotvs(entidad); + + TipoRetorno retornoTotvs = RetornoTotvs.validaRetornoTotvs(resp); + + switch (retornoTotvs) { + case CONCLUIDA: + entidad.setIndIntegracion(TipoRetorno.CONCLUIDA.getValor()); + break; + + case JA_CADASTRADA: + entidad.setIndIntegracion(TipoRetorno.JA_CADASTRADA.getValor()); + respEx = new IntegracionException(Atributos.MSG_ERRO_JA_CADASTRADO); + break; + + case ERRO: + entidad.setIndIntegracion(TipoRetorno.ERRO.getValor()); + respEx = new IntegracionException(Atributos.MSG_ERRO_GENERICA + resp); + break; + + default: + break; + } + } else { + respEx = new IntegracionException(Atributos.MSG_ERRO_NAO_ENVIO); } - } else { - respEx = new IntegracionException(Atributos.MSG_ERRO_NAO_ENVIO); + } catch (ValidacionCampoException e) { + entidad.setIndIntegracion(TipoRetorno.ERRO.getValor()); + respEx = e; + + } catch (Exception e) { + entidad.setIndIntegracion(TipoRetorno.ERRO.getValor()); + log.error(Atributos.MSG_ERRO_GENERICA, e); + respEx = new IntegracionException(Atributos.MSG_ERRO_GENERICA + e.getMessage()); } - } catch (ValidacionCampoException e) { - entidad.setIndIntegracion(TipoRetorno.ERRO.getValor()); - respEx = e; - - } catch (Exception e) { - entidad.setIndIntegracion(TipoRetorno.ERRO.getValor()); - log.error(Atributos.MSG_ERRO_GENERICA, e); - respEx = new IntegracionException(Atributos.MSG_ERRO_GENERICA + e.getMessage()); } } - entidad = puntoVentaDAO.actualizacion(entidad); log.debug("iniciando integração com AG"); @@ -525,7 +527,7 @@ public class PuntoVentaServiceImpl implements PuntoVentaService { } private String integracionTotvs(PuntoVenta puntoVenta) throws Exception { - if (ApplicationProperties.getInstance().integracionTotvs() && !constanteService.buscarPorNomeConstante("WS_TOTVS_DESATIVA_INTEGRACAO").getValorconstante().equals("1")) { + if (ApplicationProperties.getInstance().integracionTotvs()) { validaCampos(puntoVenta);