fixes bug#15030
dev:lucas qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@95901 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
1308f68e30
commit
8bb0d1c5cd
|
@ -49,6 +49,9 @@ public class Constantes {
|
|||
|
||||
public static Short TURNO_AUTOMATICO = new Short("99");
|
||||
|
||||
public static final String IMAGEM_EMPRESA = "EMPRESA_BACKGROUND";
|
||||
public static final String IMAGEM_EMPRESA_GENERICA = "EMPRESA_BACKGROUND_GENERICA";
|
||||
|
||||
public static List<Integer> ORGAOS_CONCEDENTES_CALCULO_ARTESP = new ArrayList<Integer>(Arrays.asList(new Integer[]{21, 30})) ;
|
||||
/*
|
||||
3 ANTT
|
||||
|
@ -101,4 +104,10 @@ public class Constantes {
|
|||
public static final String ESTACAO_EMBARCADA = "ESTACAO_EMBARCADA";
|
||||
|
||||
public static final Integer CATEGORIA_NORMAL = 1;
|
||||
|
||||
public static final String BPE_AMBIENTE = "BPE_AMBIENTE";
|
||||
|
||||
public static final String BPE_URL = "BPE_URL";
|
||||
|
||||
public static final String BPE_URL_CONTIG = "BPE_URL_CONTIG_";
|
||||
}
|
||||
|
|
|
@ -16,4 +16,6 @@ public interface ConstanteDAO extends GenericDAO<Constante, Integer> {
|
|||
public Constante buscarPorNomeConstante(String nomeConstante);
|
||||
|
||||
public List<Constante> buscar(String nombconstante);
|
||||
|
||||
public List<Constante> buscarPorNomeConstanteLike(String nombconstante);
|
||||
}
|
||||
|
|
|
@ -56,4 +56,13 @@ public class ConstanteHibernateDAO extends GenericHibernateDAO<Constante, Intege
|
|||
|
||||
return c.list();
|
||||
}
|
||||
|
||||
public List<Constante> buscarPorNomeConstanteLike(String nombconstante) {
|
||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||
|
||||
c.add(Restrictions.ilike("nombconstante", "%" + nombconstante + "%"));
|
||||
|
||||
return c.list();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,9 +48,9 @@ public class ContingenciaClienteRest {
|
|||
return instance;
|
||||
}
|
||||
|
||||
public Integer consultar(String uf, String ambiente, String cnpj) {
|
||||
public Integer consultar(String bpeURL, String uf, String ambiente, String cnpj) {
|
||||
try {
|
||||
return verificarStatus(getURI(PATH_CONSULTA_STATUS, uf, ambiente, cnpj), ETipoEnvio.GET);
|
||||
return verificarStatus(getURI(bpeURL, PATH_CONSULTA_STATUS, uf, ambiente, cnpj), ETipoEnvio.GET);
|
||||
} catch (IOException e) {
|
||||
log.error(e);
|
||||
} catch (JSONException e) {
|
||||
|
@ -61,9 +61,9 @@ public class ContingenciaClienteRest {
|
|||
return null;
|
||||
}
|
||||
|
||||
public Integer definir(String uf, String ambiente, String cnpj, Integer idStatus) {
|
||||
public Integer definir(String bpeURL,String uf, String ambiente, String cnpj, Integer idStatus) {
|
||||
try {
|
||||
return verificarStatus(getURI(PATH_DEFINIR_STATUS, uf, ambiente, cnpj, idStatus), ETipoEnvio.POST);
|
||||
return verificarStatus(getURI(bpeURL, PATH_DEFINIR_STATUS, uf, ambiente, cnpj, idStatus), ETipoEnvio.POST);
|
||||
} catch (IOException e) {
|
||||
log.error(e);
|
||||
} catch (JSONException e) {
|
||||
|
@ -116,9 +116,9 @@ public class ContingenciaClienteRest {
|
|||
return "Basic " + new String(Base64.encodeBase64(CREDENCIAIS.getBytes()));
|
||||
}
|
||||
|
||||
private String getURI(String path, String uf, String ambiente, String cnpj) {
|
||||
private String getURI(String bpeURL, String path, String uf, String ambiente, String cnpj) {
|
||||
StringBuilder uri = new StringBuilder();
|
||||
uri.append(buscarConstanteURL());
|
||||
uri.append(bpeURL);
|
||||
uri.append(path);
|
||||
uri.append("?uf=").append(uf);
|
||||
uri.append("&ambiente=").append(ambiente);
|
||||
|
@ -127,9 +127,9 @@ public class ContingenciaClienteRest {
|
|||
return uri.toString();
|
||||
}
|
||||
|
||||
private String getURI(String path, String uf, String ambiente, String cnpj, Integer idStatus) {
|
||||
private String getURI(String bpeURL, String path, String uf, String ambiente, String cnpj, Integer idStatus) {
|
||||
StringBuilder uri = new StringBuilder();
|
||||
uri.append(getURI(path, uf, ambiente, cnpj));
|
||||
uri.append(getURI(bpeURL, path, uf, ambiente, cnpj));
|
||||
uri.append("&tpEmis=").append(idStatus);
|
||||
|
||||
return uri.toString();
|
||||
|
|
|
@ -21,4 +21,6 @@ public interface ConstanteService extends GenericService<Constante, Integer> {
|
|||
String buscarURLPainelBPe();
|
||||
|
||||
String buscarNomeConstanteURLPainelBPe();
|
||||
|
||||
public List<Constante> buscarPorNomeConstanteLike(String nomeConstante);
|
||||
}
|
||||
|
|
|
@ -116,4 +116,10 @@ public class ConstanteServiceImpl implements ConstanteService {
|
|||
|
||||
return constante.getValorconstante().equalsIgnoreCase("true");
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
|
||||
public List<Constante> buscarPorNomeConstanteLike(String nombconstante) {
|
||||
return constanteDAO.buscarPorNomeConstanteLike(nombconstante);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,12 +5,15 @@ import java.util.List;
|
|||
|
||||
import javax.mail.SendFailedException;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.rjconsultores.ventaboletos.constantes.Constantes;
|
||||
import com.rjconsultores.ventaboletos.dao.LogHistoricoContingenciaDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.Constante;
|
||||
import com.rjconsultores.ventaboletos.entidad.EmpresaEmail;
|
||||
import com.rjconsultores.ventaboletos.entidad.EmpresaEmailConfig;
|
||||
import com.rjconsultores.ventaboletos.entidad.LogHistoricoContingencia;
|
||||
|
@ -18,6 +21,7 @@ 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.service.ConstanteService;
|
||||
import com.rjconsultores.ventaboletos.service.ContingenciaService;
|
||||
import com.rjconsultores.ventaboletos.service.EmpresaEmailConfigService;
|
||||
import com.rjconsultores.ventaboletos.service.EmpresaEmailService;
|
||||
|
@ -44,6 +48,9 @@ public class ContingenciaServiceImpl implements ContingenciaService {
|
|||
@Autowired
|
||||
private EmpresaEmailConfigService empresaEmailConfigService;
|
||||
|
||||
@Autowired
|
||||
private ConstanteService constanteService;
|
||||
|
||||
public List<LogHistoricoContingencia> buscarHistorico(Integer empresaID, Integer estadoID) {
|
||||
return histContingenciaDAO.buscarHistorico(empresaID, estadoID);
|
||||
}
|
||||
|
@ -84,9 +91,25 @@ public class ContingenciaServiceImpl implements ContingenciaService {
|
|||
}
|
||||
|
||||
private void definirStatusContingencia(LogHistoricoContingencia historicoCont) {
|
||||
ContingenciaClienteRest.getInstance().definir(historicoCont.getEstado().getCveestado(),
|
||||
|
||||
List<Constante> constantesContig = constanteService.buscarPorNomeConstanteLike(Constantes.BPE_URL_CONTIG);
|
||||
if (CollectionUtils.isEmpty(constantesContig)) {
|
||||
Constante constanteBPeURL = constanteService.buscarPorNomeConstante(Constantes.BPE_URL);
|
||||
constantesContig.add(constanteBPeURL);
|
||||
}
|
||||
|
||||
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()));
|
||||
} catch (Exception e) {
|
||||
log.error("", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private EStatusContingencia getStatusContingencia(LogHistoricoContingencia historicoCont) {
|
||||
|
|
Loading…
Reference in New Issue