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);
Exception respEx = null;
try {
if (entidad.getIndIntegracion() == TipoRetorno.PENDENTE.getValor()
|| entidad.getIndIntegracion() == 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 (ApplicationProperties.getInstance().integracionTotvs()) {
try {
if (entidad.getIndIntegracion() == TipoRetorno.PENDENTE.getValor()
|| entidad.getIndIntegracion() == 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());
}
entidad = puntoVentaDAO.suscribir(entidad);
if (respEx != null) {
@ -131,44 +132,48 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.TRUE);
Exception respEx = null;
try {
if (entidad.getIndIntegracion() == TipoRetorno.PENDENTE.getValor()
|| entidad.getIndIntegracion() == 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 (ApplicationProperties.getInstance().integracionTotvs()) {
try {
if (entidad.getIndIntegracion() == TipoRetorno.PENDENTE.getValor()
|| entidad.getIndIntegracion() == 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);