bug#0000 Erro ao setar contigencia
dev:lucas qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@98163 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
5b7acd4c03
commit
746db464e7
|
@ -1,8 +1,12 @@
|
|||
package com.rjconsultores.ventaboletos.rest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
|
@ -17,6 +21,8 @@ import org.codehaus.jettison.json.JSONException;
|
|||
import org.codehaus.jettison.json.JSONObject;
|
||||
import org.zkoss.zkplus.spring.SpringUtil;
|
||||
|
||||
import com.rjconsultores.ventaboletos.constantes.Constantes;
|
||||
import com.rjconsultores.ventaboletos.entidad.Constante;
|
||||
import com.rjconsultores.ventaboletos.service.ConstanteService;
|
||||
/**
|
||||
* @author vjcor
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package com.rjconsultores.ventaboletos.service.impl;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.mail.SendFailedException;
|
||||
|
||||
|
@ -21,11 +23,13 @@ import com.rjconsultores.ventaboletos.enums.EAmbienteContingencia;
|
|||
import com.rjconsultores.ventaboletos.enums.EStatusContingencia;
|
||||
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||
import com.rjconsultores.ventaboletos.rest.ContingenciaClienteRest;
|
||||
import com.rjconsultores.ventaboletos.rest.ContingenciaClienteRest.ETipoEnvio;
|
||||
import com.rjconsultores.ventaboletos.service.ConstanteService;
|
||||
import com.rjconsultores.ventaboletos.service.ContingenciaService;
|
||||
import com.rjconsultores.ventaboletos.service.EmpresaEmailConfigService;
|
||||
import com.rjconsultores.ventaboletos.service.EmpresaEmailService;
|
||||
import com.rjconsultores.ventaboletos.utilerias.SendMail;
|
||||
import com.rjconsultores.ventaboletos.utilerias.StringHelper;
|
||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||
|
||||
/**
|
||||
|
@ -73,7 +77,11 @@ public class ContingenciaServiceImpl implements ContingenciaService {
|
|||
}
|
||||
|
||||
try {
|
||||
definirStatusContingencia(historicoCont);
|
||||
Integer retorno = definirStatusContingencia(historicoCont);
|
||||
|
||||
if (retorno == null) {
|
||||
throw new BusinessException(" entre em contato com o administrador do sistema.");
|
||||
}
|
||||
|
||||
if (EStatusContingencia.CONTINGENCIA.equals(getStatusContingencia(historicoCont))) {
|
||||
enviaEmail(historicoCont);
|
||||
|
@ -90,7 +98,9 @@ public class ContingenciaServiceImpl implements ContingenciaService {
|
|||
return histContingenciaDAO.suscribir(historicoCont);
|
||||
}
|
||||
|
||||
private void definirStatusContingencia(LogHistoricoContingencia historicoCont) {
|
||||
private Integer definirStatusContingencia(LogHistoricoContingencia historicoCont) {
|
||||
|
||||
Integer statusEnviado = Integer.valueOf(historicoCont.getStatus());
|
||||
|
||||
List<Constante> constantesContig = constanteService.buscarPorNomeConstanteLike(Constantes.BPE_URL_CONTIG);
|
||||
if (CollectionUtils.isEmpty(constantesContig)) {
|
||||
|
@ -98,18 +108,44 @@ public class ContingenciaServiceImpl implements ContingenciaService {
|
|||
constantesContig.add(constanteBPeURL);
|
||||
}
|
||||
|
||||
HashMap<Constante, Integer> retornos = new HashMap<Constante, Integer>();
|
||||
|
||||
for (Constante constante : constantesContig) {
|
||||
|
||||
try {
|
||||
String bpeURL = constante.getValorconstante();
|
||||
ContingenciaClienteRest.getInstance().definir(bpeURL, historicoCont.getEstado().getCveestado(),
|
||||
historicoCont.getAmbiente().toString(), historicoCont.getEmpresa().getCnpj(),
|
||||
Integer.valueOf(historicoCont.getStatus()));
|
||||
String url = constante.getValorconstante();
|
||||
Integer retorno = ContingenciaClienteRest.getInstance().consultar(url, historicoCont.getEstado().getCveestado(), historicoCont.getAmbiente().toString(), StringHelper.retornaSomenteNumeros(historicoCont.getEmpresa().getCnpj()));
|
||||
retornos.put(constante, retorno);
|
||||
} catch (Exception e) {
|
||||
log.error("", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (Entry<Constante, Integer> entry : retornos.entrySet()) {
|
||||
if (entry.getValue() == null || (entry.getValue() != null && entry.getValue().equals(statusEnviado))) {
|
||||
log.info("O Servidor:" + entry.getKey().getValorconstante() + "enviou: " + statusEnviado + " recebeu " + entry.getValue());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
for (Constante constante : constantesContig) {
|
||||
|
||||
try {
|
||||
String bpeURL = constante.getValorconstante();
|
||||
|
||||
Integer retorno = ContingenciaClienteRest.getInstance().definir(bpeURL, historicoCont.getEstado().getCveestado(),
|
||||
historicoCont.getAmbiente().toString(), StringHelper.retornaSomenteNumeros(historicoCont.getEmpresa().getCnpj()),
|
||||
Integer.valueOf(historicoCont.getStatus()));
|
||||
|
||||
log.info("Servidor:" + bpeURL + " status:" + retorno);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("", e);
|
||||
}
|
||||
}
|
||||
|
||||
return statusEnviado;
|
||||
|
||||
}
|
||||
|
||||
private EStatusContingencia getStatusContingencia(LogHistoricoContingencia historicoCont) {
|
||||
|
|
Loading…
Reference in New Issue