leonardo 2016-12-30 14:03:58 +00:00
parent 9a30194926
commit 805c691fbc
1 changed files with 78 additions and 76 deletions

View File

@ -95,48 +95,49 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
entidad.setActivo(Boolean.TRUE); entidad.setActivo(Boolean.TRUE);
Exception respEx = null; Exception respEx = null;
if (ApplicationProperties.getInstance().integracionTotvs()) { if (!constanteService.buscarPorNomeConstante("WS_TOTVS_DESATIVA_INTEGRACAO").getValorconstante().equals("1")){
try { if (ApplicationProperties.getInstance().integracionTotvs()) {
try {
if (entidad.getIndIntegracion() == null || (entidad.getIndIntegracion().equals(TipoRetorno.PENDENTE.getValor()) if (entidad.getIndIntegracion() == null || (entidad.getIndIntegracion().equals(TipoRetorno.PENDENTE.getValor())
|| entidad.getIndIntegracion().equals(TipoRetorno.ERRO.getValor()))) { || entidad.getIndIntegracion().equals(TipoRetorno.ERRO.getValor()))) {
String resp = integracionTotvs(entidad); 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());
} }
} }
if (respEx != null) { if (respEx != null) {
if (respEx instanceof ValidacionCampoException) { if (respEx instanceof ValidacionCampoException) {
throw (ValidacionCampoException) respEx; throw (ValidacionCampoException) respEx;
@ -327,47 +328,48 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
Exception respEx = null; Exception respEx = null;
if (ApplicationProperties.getInstance().integracionTotvs()) { if (!constanteService.buscarPorNomeConstante("WS_TOTVS_DESATIVA_INTEGRACAO").getValorconstante().equals("1")){
if (ApplicationProperties.getInstance().integracionTotvs()) {
try { try {
if (entidad.getIndIntegracion() == null || (entidad.getIndIntegracion().equals(TipoRetorno.PENDENTE.getValor()) if (entidad.getIndIntegracion() == null || (entidad.getIndIntegracion().equals(TipoRetorno.PENDENTE.getValor())
|| entidad.getIndIntegracion().equals(TipoRetorno.ERRO.getValor()))) { || entidad.getIndIntegracion().equals(TipoRetorno.ERRO.getValor()))) {
String resp = integracionTotvs(entidad); 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 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);
log.debug("iniciando integração com AG"); log.debug("iniciando integração com AG");
@ -525,7 +527,7 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
} }
private String integracionTotvs(PuntoVenta puntoVenta) throws Exception { 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); validaCampos(puntoVenta);