gleimar 2015-04-30 23:52:17 +00:00
parent 76a85c8a28
commit a8e0007c29
1 changed files with 75 additions and 70 deletions

View File

@ -75,44 +75,45 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
entidad.setActivo(Boolean.TRUE); entidad.setActivo(Boolean.TRUE);
Exception respEx = null; Exception respEx = null;
try { if (ApplicationProperties.getInstance().integracionTotvs()) {
if (entidad.getIndIntegracion() == TipoRetorno.PENDENTE.getValor() try {
|| entidad.getIndIntegracion() == TipoRetorno.ERRO.getValor()) { if (entidad.getIndIntegracion() == TipoRetorno.PENDENTE.getValor()
String resp = integracionTotvs(entidad); || entidad.getIndIntegracion() == TipoRetorno.ERRO.getValor()) {
String resp = integracionTotvs(entidad);
TipoRetorno retornoTotvs = RetornoTotvs.validaRetornoTotvs(resp); TipoRetorno retornoTotvs = RetornoTotvs.validaRetornoTotvs(resp);
switch (retornoTotvs) { switch (retornoTotvs) {
case CONCLUIDA: case CONCLUIDA:
entidad.setIndIntegracion(TipoRetorno.CONCLUIDA.getValor()); entidad.setIndIntegracion(TipoRetorno.CONCLUIDA.getValor());
break; break;
case JA_CADASTRADA: case JA_CADASTRADA:
entidad.setIndIntegracion(TipoRetorno.JA_CADASTRADA.getValor()); entidad.setIndIntegracion(TipoRetorno.JA_CADASTRADA.getValor());
respEx = new IntegracionException(Atributos.MSG_ERRO_JA_CADASTRADO); respEx = new IntegracionException(Atributos.MSG_ERRO_JA_CADASTRADO);
break; break;
case ERRO: case ERRO:
entidad.setIndIntegracion(TipoRetorno.ERRO.getValor()); entidad.setIndIntegracion(TipoRetorno.ERRO.getValor());
respEx = new IntegracionException(Atributos.MSG_ERRO_GENERICA + resp); respEx = new IntegracionException(Atributos.MSG_ERRO_GENERICA + resp);
break; break;
default: default:
break; break;
}
} else {
respEx = new IntegracionException(Atributos.MSG_ERRO_NAO_ENVIO);
} }
} else { } catch (ValidacionCampoException ev) {
respEx = new IntegracionException(Atributos.MSG_ERRO_NAO_ENVIO); 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());
} }
entidad = puntoVentaDAO.suscribir(entidad); entidad = puntoVentaDAO.suscribir(entidad);
if (respEx != null) { if (respEx != null) {
@ -133,42 +134,46 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
entidad.setActivo(Boolean.TRUE); entidad.setActivo(Boolean.TRUE);
Exception respEx = null; Exception respEx = null;
try {
if (entidad.getIndIntegracion() == TipoRetorno.PENDENTE.getValor()
|| entidad.getIndIntegracion() == TipoRetorno.ERRO.getValor()) {
String resp = integracionTotvs(entidad);
TipoRetorno retornoTotvs = RetornoTotvs.validaRetornoTotvs(resp); if (ApplicationProperties.getInstance().integracionTotvs()) {
switch (retornoTotvs) { try {
case CONCLUIDA: if (entidad.getIndIntegracion() == TipoRetorno.PENDENTE.getValor()
entidad.setIndIntegracion(TipoRetorno.CONCLUIDA.getValor()); || entidad.getIndIntegracion() == TipoRetorno.ERRO.getValor()) {
break; String resp = integracionTotvs(entidad);
case JA_CADASTRADA: TipoRetorno retornoTotvs = RetornoTotvs.validaRetornoTotvs(resp);
entidad.setIndIntegracion(TipoRetorno.JA_CADASTRADA.getValor());
respEx = new IntegracionException(Atributos.MSG_ERRO_JA_CADASTRADO);
break;
case ERRO: switch (retornoTotvs) {
entidad.setIndIntegracion(TipoRetorno.ERRO.getValor()); case CONCLUIDA:
respEx = new IntegracionException(Atributos.MSG_ERRO_GENERICA + resp); entidad.setIndIntegracion(TipoRetorno.CONCLUIDA.getValor());
break; break;
default: case JA_CADASTRADA:
break; 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 { } catch (ValidacionCampoException e) {
respEx = new IntegracionException(Atributos.MSG_ERRO_NAO_ENVIO); entidad.setIndIntegracion(TipoRetorno.ERRO.getValor());
} respEx = e;
} catch (ValidacionCampoException e) {
entidad.setIndIntegracion(TipoRetorno.ERRO.getValor());
respEx = e;
} catch (Exception e) { } catch (Exception e) {
entidad.setIndIntegracion(TipoRetorno.ERRO.getValor()); entidad.setIndIntegracion(TipoRetorno.ERRO.getValor());
log.error(Atributos.MSG_ERRO_GENERICA, e); log.error(Atributos.MSG_ERRO_GENERICA, e);
respEx = new IntegracionException(Atributos.MSG_ERRO_GENERICA + e.getMessage()); respEx = new IntegracionException(Atributos.MSG_ERRO_GENERICA + e.getMessage());
}
} }
entidad = puntoVentaDAO.actualizacion(entidad); entidad = puntoVentaDAO.actualizacion(entidad);