leonardo 2017-03-13 13:49:55 +00:00
parent ed2b6f1e1f
commit 4d2d0c3a04
1 changed files with 18 additions and 16 deletions

View File

@ -155,19 +155,28 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
Constante empresasIntegraAG = constanteService.buscarPorNomeConstante("EMPRESAS_INTEGRACAO_AG"); Constante empresasIntegraAG = constanteService.buscarPorNomeConstante("EMPRESAS_INTEGRACAO_AG");
if (empresasIntegraAG != null && empresasIntegraAG.getValorconstante() != null && empresasIntegraAG.getValorconstante().contains(entidad.getEmpresa().getEmpresaId().toString())) { if (empresasIntegraAG != null && empresasIntegraAG.getValorconstante() != null && empresasIntegraAG.getValorconstante().contains(entidad.getEmpresa().getEmpresaId().toString())) {
log.debug("iniciando integração com AG"); log.debug("iniciando integração com AG");
integrarClienteAG(entidad); integraAG(entidad);
if (!entidad.getIndIntegradoAG()){
throw new IntegracionException(entidad.getMotivoNaoIntegradoAG());
}
integrarFornecedorAG(entidad);
if (!entidad.getIndIntegradoAG()){
throw new IntegracionException(entidad.getMotivoNaoIntegradoAG());
}
log.debug("fim da integração com AG"); log.debug("fim da integração com AG");
} }
return entidad; return entidad;
} }
private void integraAG(PuntoVenta entidad) throws IntegracionException{
String motivoNaoIntegrado = "";
integrarClienteAG(entidad);
if (!entidad.getIndIntegradoAG()){
motivoNaoIntegrado += "Cliente: " + entidad.getMotivoNaoIntegradoAG();
}
integrarFornecedorAG(entidad);
if (!entidad.getIndIntegradoAG()){
motivoNaoIntegrado += "Fornecedor: " + entidad.getMotivoNaoIntegradoAG();
}
if (!motivoNaoIntegrado.isEmpty()){
throw new IntegracionException(entidad.getMotivoNaoIntegradoAG());
}
}
private void integrarFornecedorAG(PuntoVenta entidad) { private void integrarFornecedorAG(PuntoVenta entidad) {
Connection connection = null; Connection connection = null;
@ -417,14 +426,7 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
Constante empresasIntegraAG = constanteService.buscarPorNomeConstante("EMPRESAS_INTEGRACAO_AG"); Constante empresasIntegraAG = constanteService.buscarPorNomeConstante("EMPRESAS_INTEGRACAO_AG");
if (empresasIntegraAG != null && empresasIntegraAG.getValorconstante() != null && empresasIntegraAG.getValorconstante().contains(entidad.getEmpresa().getEmpresaId().toString())) { if (empresasIntegraAG != null && empresasIntegraAG.getValorconstante() != null && empresasIntegraAG.getValorconstante().contains(entidad.getEmpresa().getEmpresaId().toString())) {
log.debug("iniciando integração com AG"); log.debug("iniciando integração com AG");
integrarClienteAG(entidad); integraAG(entidad);
if (!entidad.getIndIntegradoAG()){
throw new IntegracionException(entidad.getMotivoNaoIntegradoAG());
}
integrarFornecedorAG(entidad);
if (!entidad.getIndIntegradoAG()){
throw new IntegracionException(entidad.getMotivoNaoIntegradoAG());
}
log.debug("fim da integração com AG"); log.debug("fim da integração com AG");
} }