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) {
case CONCLUIDA: switch (retornoTotvs) {
entidad.setIndIntegracion(TipoRetorno.CONCLUIDA.getValor()); case CONCLUIDA:
break; entidad.setIndIntegracion(TipoRetorno.CONCLUIDA.getValor());
break;
case JA_CADASTRADA:
entidad.setIndIntegracion(TipoRetorno.JA_CADASTRADA.getValor()); case JA_CADASTRADA:
respEx = new IntegracionException(Atributos.MSG_ERRO_JA_CADASTRADO); entidad.setIndIntegracion(TipoRetorno.JA_CADASTRADA.getValor());
break; respEx = new IntegracionException(Atributos.MSG_ERRO_JA_CADASTRADO);
break;
case ERRO:
entidad.setIndIntegracion(TipoRetorno.ERRO.getValor()); case ERRO:
respEx = new IntegracionException(Atributos.MSG_ERRO_GENERICA + resp); entidad.setIndIntegracion(TipoRetorno.ERRO.getValor());
break; respEx = new IntegracionException(Atributos.MSG_ERRO_GENERICA + resp);
break;
default:
break; default:
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) {
@ -131,44 +132,48 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime()); entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.TRUE); entidad.setActivo(Boolean.TRUE);
Exception respEx = null; Exception respEx = null;
try {
if (entidad.getIndIntegracion() == TipoRetorno.PENDENTE.getValor() if (ApplicationProperties.getInstance().integracionTotvs()) {
|| entidad.getIndIntegracion() == TipoRetorno.ERRO.getValor()) {
String resp = integracionTotvs(entidad); try {
if (entidad.getIndIntegracion() == TipoRetorno.PENDENTE.getValor()
TipoRetorno retornoTotvs = RetornoTotvs.validaRetornoTotvs(resp); || entidad.getIndIntegracion() == TipoRetorno.ERRO.getValor()) {
String resp = integracionTotvs(entidad);
switch (retornoTotvs) {
case CONCLUIDA: TipoRetorno retornoTotvs = RetornoTotvs.validaRetornoTotvs(resp);
entidad.setIndIntegracion(TipoRetorno.CONCLUIDA.getValor());
break; switch (retornoTotvs) {
case CONCLUIDA:
case JA_CADASTRADA: entidad.setIndIntegracion(TipoRetorno.CONCLUIDA.getValor());
entidad.setIndIntegracion(TipoRetorno.JA_CADASTRADA.getValor()); break;
respEx = new IntegracionException(Atributos.MSG_ERRO_JA_CADASTRADO);
break; case JA_CADASTRADA:
entidad.setIndIntegracion(TipoRetorno.JA_CADASTRADA.getValor());
case ERRO: respEx = new IntegracionException(Atributos.MSG_ERRO_JA_CADASTRADO);
entidad.setIndIntegracion(TipoRetorno.ERRO.getValor()); break;
respEx = new IntegracionException(Atributos.MSG_ERRO_GENERICA + resp);
break; case ERRO:
entidad.setIndIntegracion(TipoRetorno.ERRO.getValor());
default: respEx = new IntegracionException(Atributos.MSG_ERRO_GENERICA + resp);
break; 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 (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); entidad = puntoVentaDAO.actualizacion(entidad);