fixes bug #AL-2093
correção de erro no preenchimento do código de desconto e melhoriasmaster
parent
cd6234bf00
commit
149a361812
2
pom.xml
2
pom.xml
|
@ -3,7 +3,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>br.com.rjconsultores</groupId>
|
||||
<artifactId>ModelWeb</artifactId>
|
||||
<version>1.0.36</version>
|
||||
<version>1.0.37</version>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>rj-releases</id>
|
||||
|
|
|
@ -75,6 +75,10 @@ import com.rjconsultores.ventaboletos.utilerias.CustomEnum;
|
|||
@SuppressWarnings({"unchecked"})
|
||||
public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<FechamentoBoleto, Long> implements RemessaCNABBancosDAO{
|
||||
|
||||
private static final String DATA_ATE = "dataAte";
|
||||
private static final String DATA_DE = "dataDe";
|
||||
private static final String EMPRESA_ID = "empresaId";
|
||||
private static final String ZERO_ESQUERDA = "00000000";
|
||||
private static Logger log = Logger.getLogger(RemessaCNABBancosHibernateDAO.class);
|
||||
|
||||
@Autowired
|
||||
|
@ -85,8 +89,7 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
|||
public String findBanco(Empresa empresa){
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("SELECT ");
|
||||
sb.append("DISTINCT fp.BOLETO_BANCO_COD ");
|
||||
sb.append("SELECT DISTINCT fp.BOLETO_BANCO_COD ");
|
||||
sb.append("FROM ");
|
||||
sb.append("FECHAMENTO_PARAMGERAL fp ");
|
||||
sb.append("WHERE fp.activo = 1 AND ");
|
||||
|
@ -131,11 +134,11 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
|||
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
||||
|
||||
Query query = getSession().createSQLQuery(sb.toString());
|
||||
query.setInteger("empresaId", empresa.getEmpresaId());
|
||||
query.setInteger(EMPRESA_ID, empresa.getEmpresaId());
|
||||
|
||||
if(dataDe != null && dataAte != null){
|
||||
query.setDate("dataDe", dataDe);
|
||||
query.setDate("dataAte", dataAte);
|
||||
query.setDate(DATA_DE, dataDe);
|
||||
query.setDate(DATA_ATE, dataAte);
|
||||
}
|
||||
List<Object[]> list = query.list();
|
||||
|
||||
|
@ -203,7 +206,7 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
|||
detalhe.setDataOcorrencia(null);
|
||||
detalhe.setNumeroDoDocumento(StringUtils.right(doc[0], 10));
|
||||
detalhe.setVencimento((Date) tupla[9]);
|
||||
detalhe.setValor(new BigDecimal(tupla[10].toString().replaceAll(",", ".")));
|
||||
detalhe.setValor(new BigDecimal(tupla[10].toString().replace(",", ".")));
|
||||
detalhe.setEmissao((Date) tupla[12]);
|
||||
detalhe.setPercentualMulta( (BigDecimal) tupla[24] );
|
||||
|
||||
|
@ -226,7 +229,7 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
|||
|
||||
try{
|
||||
if( tupla[15] != null ) {
|
||||
detalhe.setValorAtraso(new BigDecimal(tupla[15].toString().replaceAll(",", ".")));
|
||||
detalhe.setValorAtraso(new BigDecimal(tupla[15].toString().replace(",", ".")));
|
||||
}else if( tupla[23] != null ) {
|
||||
detalhe.setValorAtraso( calculaValorMora( (BigDecimal) tupla[23], new BigDecimal(tupla[10].toString().replaceAll(",", ".") )) );
|
||||
}else {
|
||||
|
@ -238,12 +241,12 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
|||
}
|
||||
|
||||
try{
|
||||
detalhe.setValorDesconto(new BigDecimal(tupla[16].toString().replaceAll(",", ".")));
|
||||
detalhe.setValorDesconto(new BigDecimal(tupla[16].toString().replace(",", ".")));
|
||||
}catch(Exception e){
|
||||
}
|
||||
|
||||
try{
|
||||
detalhe.setValorAbatimentoConcedido(new BigDecimal(tupla[17].toString().replaceAll(",", ".")));
|
||||
detalhe.setValorAbatimentoConcedido(new BigDecimal(tupla[17].toString().replace(",", ".")));
|
||||
}catch(Exception e){
|
||||
}
|
||||
|
||||
|
@ -320,11 +323,11 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
|||
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
||||
|
||||
Query query = getSession().createSQLQuery(sb.toString());
|
||||
query.setInteger("empresaId", empresa.getEmpresaId());
|
||||
query.setInteger(EMPRESA_ID, empresa.getEmpresaId());
|
||||
|
||||
if(dataDe != null && dataAte != null){
|
||||
query.setDate("dataDe", dataDe);
|
||||
query.setDate("dataAte", dataAte);
|
||||
query.setDate(DATA_DE, dataDe);
|
||||
query.setDate(DATA_ATE, dataAte);
|
||||
}
|
||||
List<Object[]> list = query.list();
|
||||
|
||||
|
@ -523,11 +526,11 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
|||
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
||||
|
||||
Query query = getSession().createSQLQuery(sb.toString());
|
||||
query.setInteger("empresaId", empresa.getEmpresaId());
|
||||
query.setInteger(EMPRESA_ID, empresa.getEmpresaId());
|
||||
|
||||
if(dataDe != null && dataAte != null){
|
||||
query.setDate("dataDe", dataDe);
|
||||
query.setDate("dataAte", dataAte);
|
||||
query.setDate(DATA_DE, dataDe);
|
||||
query.setDate(DATA_ATE, dataAte);
|
||||
}
|
||||
List<Object[]> list = query.list();
|
||||
|
||||
|
@ -704,10 +707,10 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
|||
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
||||
|
||||
Query query = getSession().createSQLQuery(sb.toString());
|
||||
query.setInteger("empresaId", empresa.getEmpresaId());
|
||||
query.setInteger(EMPRESA_ID, empresa.getEmpresaId());
|
||||
if(dataDe != null && dataAte != null){
|
||||
query.setDate("dataDe", dataDe);
|
||||
query.setDate("dataAte", dataAte);
|
||||
query.setDate(DATA_DE, dataDe);
|
||||
query.setDate(DATA_ATE, dataAte);
|
||||
}
|
||||
List<Object[]> list = query.list();
|
||||
|
||||
|
@ -896,10 +899,10 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
|||
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
||||
|
||||
Query query = getSession().createSQLQuery(sb.toString());
|
||||
query.setInteger("empresaId", empresa.getEmpresaId());
|
||||
query.setInteger(EMPRESA_ID, empresa.getEmpresaId());
|
||||
if(dataDe != null && dataAte != null){
|
||||
query.setDate("dataDe", dataDe);
|
||||
query.setDate("dataAte", dataAte);
|
||||
query.setDate(DATA_DE, dataDe);
|
||||
query.setDate(DATA_ATE, dataAte);
|
||||
}
|
||||
List<Object[]> list = query.list();
|
||||
|
||||
|
@ -994,14 +997,14 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
|||
titulosBancoBrasil.setIdentDistribuicao(" ");
|
||||
titulosBancoBrasil.setNumeroDoDocumento(tupla[0].toString());
|
||||
titulosBancoBrasil.setVencimento((Date) tupla[10]);
|
||||
titulosBancoBrasil.setValor(new BigDecimal(tupla[11].toString().replaceAll(",", ".")));
|
||||
titulosBancoBrasil.setValor(new BigDecimal(tupla[11].toString().replace(",", ".")));
|
||||
titulosBancoBrasil.setAgenciaCobradora(null);
|
||||
titulosBancoBrasil.setDigAgenciaCobradora(null);
|
||||
titulosBancoBrasil.setAceite(AceiteBB.NAO_ACEITE);
|
||||
titulosBancoBrasil.setEmissao((Date) tupla[13]);
|
||||
try{
|
||||
titulosBancoBrasil.setCodMora(1);
|
||||
titulosBancoBrasil.setJurosDeMora(new BigDecimal(tupla[16].toString().replaceAll(",", ".")));
|
||||
titulosBancoBrasil.setJurosDeMora(new BigDecimal(tupla[16].toString().replace(",", ".")));
|
||||
titulosBancoBrasil.setDataMora((Date) tupla[10]);
|
||||
}catch(NullPointerException e){
|
||||
titulosBancoBrasil.setCodMora(1);
|
||||
|
@ -1012,16 +1015,16 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
|||
try{
|
||||
titulosBancoBrasil.setCodigoDesconto(1);
|
||||
titulosBancoBrasil.setDataDesconto((Date) tupla[10]);
|
||||
titulosBancoBrasil.setDescontoConcedido(new BigDecimal(tupla[17].toString().replaceAll(",", ".")));
|
||||
titulosBancoBrasil.setDescontoConcedido(new BigDecimal(tupla[17].toString().replace(",", ".")));
|
||||
}catch(NullPointerException e){
|
||||
titulosBancoBrasil.setCodigoDesconto(1);
|
||||
titulosBancoBrasil.setCodigoDesconto(0);
|
||||
titulosBancoBrasil.setDataDesconto((Date) tupla[10]);
|
||||
titulosBancoBrasil.setDescontoConcedido(BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
titulosBancoBrasil.setIOF_Devido(BigDecimal.ZERO);
|
||||
try{
|
||||
titulosBancoBrasil.setAbatimentoConcedido(new BigDecimal(tupla[18].toString().replaceAll(",", ".")));
|
||||
titulosBancoBrasil.setAbatimentoConcedido(new BigDecimal(tupla[18].toString().replace(",", ".")));
|
||||
}catch(NullPointerException e){
|
||||
titulosBancoBrasil.setAbatimentoConcedido(BigDecimal.ZERO);
|
||||
}
|
||||
|
@ -1034,12 +1037,13 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
|||
|
||||
DetalheObrigatorioDadosPagadorBancoBrasil pagadorBancoBrasil = new DetalheObrigatorioDadosPagadorBancoBrasil();
|
||||
pagadorBancoBrasil.setTipoInscricaoSacado(Integer.parseInt(TipoInscricaoPagador.CNPJ.getId()));
|
||||
pagadorBancoBrasil.setNomeSacado(tupla[21].toString());
|
||||
String ptoVenda = tupla[21].toString();
|
||||
pagadorBancoBrasil.setNomeSacado(ptoVenda.toString());
|
||||
String cep = "";
|
||||
try{
|
||||
cep = StringUtils.right("00000000" + tupla[24].toString(), 8);
|
||||
cep = StringUtils.right(ZERO_ESQUERDA + tupla[24].toString(), 8);
|
||||
}catch(Exception e){
|
||||
cep = "00000000";
|
||||
cep = ZERO_ESQUERDA;
|
||||
}
|
||||
int cepPrefix = Integer.parseInt(cep.substring(0, 5));
|
||||
int cepSufix = Integer.parseInt(cep.substring(5));
|
||||
|
@ -1050,31 +1054,51 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
|||
try{
|
||||
pagadorBancoBrasil.setNumeroInscricaoSacado(tupla[20].toString());
|
||||
}catch(Exception e){
|
||||
throw new ValidacaoRemessaException("O CNPJ do ponto de venda "+tupla[21]+" está fora do padrão, favor corrigir");
|
||||
throw new ValidacaoRemessaException(
|
||||
String.format(
|
||||
"O CNPJ do ponto de venda %s está fora do padrão, favor corrigir",
|
||||
ptoVenda)
|
||||
);
|
||||
}
|
||||
|
||||
try{
|
||||
pagadorBancoBrasil.setLogradouroSacado(tupla[22].toString());
|
||||
}catch(Exception e){
|
||||
throw new ValidacaoRemessaException("O Logradouro do ponto de venda "+tupla[21]+" está fora do padrão, favor corrigir");
|
||||
throw new ValidacaoRemessaException(
|
||||
String.format(
|
||||
"O Logradouro do ponto de venda %s está fora do padrão, favor corrigir",
|
||||
ptoVenda)
|
||||
);
|
||||
}
|
||||
|
||||
try{
|
||||
pagadorBancoBrasil.setBairroSacado(tupla[23].toString());
|
||||
}catch(Exception e){
|
||||
throw new ValidacaoRemessaException("O Bairro do ponto de venda "+tupla[21]+" está fora do padrão, favor corrigir");
|
||||
throw new ValidacaoRemessaException(
|
||||
String.format(
|
||||
"O Bairro do ponto de venda %s está fora do padrão, favor corrigir",
|
||||
ptoVenda)
|
||||
);
|
||||
}
|
||||
|
||||
try{
|
||||
pagadorBancoBrasil.setCidade(tupla[25].toString());
|
||||
}catch(Exception e){
|
||||
throw new ValidacaoRemessaException("A cidade do ponto de venda "+tupla[21]+" está fora do padrão, favor corrigir");
|
||||
throw new ValidacaoRemessaException(
|
||||
String.format(
|
||||
"A cidade do ponto de venda %s está fora do padrão, favor corrigir",
|
||||
ptoVenda)
|
||||
);
|
||||
}
|
||||
|
||||
try{
|
||||
pagadorBancoBrasil.setEstado(tupla[26].toString());
|
||||
}catch(Exception e){
|
||||
throw new ValidacaoRemessaException("O Estado do ponto de venda "+tupla[21]+" está fora do padrão, favor corrigir");
|
||||
throw new ValidacaoRemessaException(
|
||||
String.format(
|
||||
"O Estado do ponto de venda %s está fora do padrão, favor corrigir",
|
||||
ptoVenda)
|
||||
);
|
||||
}
|
||||
|
||||
titulosBancoBrasil.setDetalheObrigatorioDadosPagadorBancoBrasil(pagadorBancoBrasil);
|
||||
|
@ -1140,10 +1164,10 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
|||
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
||||
|
||||
Query query = getSession().createSQLQuery(sb.toString());
|
||||
query.setInteger("empresaId", empresa.getEmpresaId());
|
||||
query.setInteger(EMPRESA_ID, empresa.getEmpresaId());
|
||||
if(dataDe != null && dataAte != null){
|
||||
query.setDate("dataDe", dataDe);
|
||||
query.setDate("dataAte", dataAte);
|
||||
query.setDate(DATA_DE, dataDe);
|
||||
query.setDate(DATA_ATE, dataAte);
|
||||
}
|
||||
List<Object[]> list = query.list();
|
||||
|
||||
|
@ -1267,9 +1291,9 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
|||
pagadorSicoob.setNomeSacado(tupla[21].toString());
|
||||
String cep = "";
|
||||
try{
|
||||
cep = StringUtils.right("00000000" + tupla[24].toString(), 8);
|
||||
cep = StringUtils.right(ZERO_ESQUERDA + tupla[24].toString(), 8);
|
||||
}catch(Exception e){
|
||||
cep = "00000000";
|
||||
cep = ZERO_ESQUERDA;
|
||||
}
|
||||
int cepPrefix = Integer.parseInt(cep.substring(0, 5));
|
||||
int cepSufix = Integer.parseInt(cep.substring(5));
|
||||
|
@ -1365,10 +1389,10 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
|||
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
||||
|
||||
Query query = getSession().createSQLQuery(sb.toString());
|
||||
query.setInteger("empresaId", empresa.getEmpresaId());
|
||||
query.setInteger(EMPRESA_ID, empresa.getEmpresaId());
|
||||
if(dataDe != null && dataAte != null){
|
||||
query.setDate("dataDe", dataDe);
|
||||
query.setDate("dataAte", dataAte);
|
||||
query.setDate(DATA_DE, dataDe);
|
||||
query.setDate(DATA_ATE, dataAte);
|
||||
}
|
||||
List<Object[]> list = query.list();
|
||||
|
||||
|
@ -1453,9 +1477,9 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
|||
|
||||
String cep = "";
|
||||
try{
|
||||
cep = StringUtils.right("00000000" + tupla[18].toString(), 8);
|
||||
cep = StringUtils.right(ZERO_ESQUERDA + tupla[18].toString(), 8);
|
||||
}catch(Exception e){
|
||||
cep = "00000000";
|
||||
cep = ZERO_ESQUERDA;
|
||||
}
|
||||
|
||||
titulosCaixa.setCepSacado(cep);
|
||||
|
@ -1560,11 +1584,11 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
|||
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
||||
|
||||
Query query = getSession().createSQLQuery(sb.toString());
|
||||
query.setInteger("empresaId", empresa.getEmpresaId());
|
||||
query.setInteger(EMPRESA_ID, empresa.getEmpresaId());
|
||||
|
||||
if(dataDe != null && dataAte != null){
|
||||
query.setDate("dataDe", dataDe);
|
||||
query.setDate("dataAte", dataAte);
|
||||
query.setDate(DATA_DE, dataDe);
|
||||
query.setDate(DATA_ATE, dataAte);
|
||||
}
|
||||
|
||||
List<Object[]> list = query.list();
|
||||
|
@ -1720,7 +1744,7 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
|||
.setResultTransformer(new AliasToBeanResultTransformer(FechamentoBoleto.class));
|
||||
|
||||
query.setString("nossoNumero", nossoNumero);
|
||||
query.setInteger("empresaId", empresaId);
|
||||
query.setInteger(EMPRESA_ID, empresaId);
|
||||
|
||||
FechamentoBoleto retorno = (FechamentoBoleto)query.uniqueResult();
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import com.rjconsultores.ventaboletos.entidad.Empresa;
|
|||
import com.rjconsultores.ventaboletos.entidad.FechamentoCntcorrente;
|
||||
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
||||
import com.rjconsultores.ventaboletos.enums.StatusIntegracaoSap;
|
||||
import com.rjconsultores.ventaboletos.exception.BusinessRuntimeException;
|
||||
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||
import com.rjconsultores.ventaboletos.vo.integracao.FechamentoCntCorrenteVO;
|
||||
|
||||
|
@ -109,8 +110,9 @@ public class SapHibernateDAO extends GenericHibernateDAO<FechamentoCntcorrente,
|
|||
|
||||
query.setMaxResults(100);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Object[]> list = query.list();
|
||||
List<FechamentoCntCorrenteVO> retorno = new ArrayList<FechamentoCntCorrenteVO>();
|
||||
List<FechamentoCntCorrenteVO> retorno = new ArrayList<>();
|
||||
|
||||
for(Object[] tupla : list){
|
||||
|
||||
|
@ -122,10 +124,10 @@ public class SapHibernateDAO extends GenericHibernateDAO<FechamentoCntcorrente,
|
|||
fcc.setNumPuntoVenta(tupla[4].toString());
|
||||
|
||||
try {
|
||||
String cnpj = tupla[5].toString().replaceAll("[^0-9]", "");
|
||||
String cnpj = tupla[5].toString().replaceAll("\\D", "");
|
||||
fcc.setCnpjPuntoVenta(cnpj);
|
||||
}catch (Exception e) {
|
||||
throw new RuntimeException( "CNPJ fora do padrao no ponto de venda: "+tupla[6] );
|
||||
throw new BusinessRuntimeException( "CNPJ fora do padrao no ponto de venda: %s ", tupla[6] );
|
||||
}
|
||||
fcc.setNombpuntoventa(tupla[6].toString());
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package com.rjconsultores.ventaboletos.exception;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import org.zkoss.util.resource.Labels;
|
||||
|
||||
public class BusinessRuntimeException extends RuntimeException {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
*
|
||||
* @param message
|
||||
* - La clave del archivo de traducción
|
||||
*/
|
||||
public BusinessRuntimeException(String message) {
|
||||
super(Labels.getLabel(message) == null ? message :Labels.getLabel(message));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param message- La clave del archivo de traducción
|
||||
* @param oMsg - Los parametros de la mensage
|
||||
*/
|
||||
public BusinessRuntimeException(String message,Object oMsg) {
|
||||
super(new MessageFormat(Labels.getLabel(message)).format(oMsg));
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ import com.rjconsultores.ventaboletos.entidad.Empresa;
|
|||
import com.rjconsultores.ventaboletos.entidad.FechamentoCntcorrente;
|
||||
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
||||
import com.rjconsultores.ventaboletos.enums.StatusIntegracaoSap;
|
||||
import com.rjconsultores.ventaboletos.exception.BusinessRuntimeException;
|
||||
import com.rjconsultores.ventaboletos.rest.IntegracaoSapRest;
|
||||
import com.rjconsultores.ventaboletos.service.SapService;
|
||||
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||
|
@ -74,42 +75,38 @@ public class SapServiceImpl implements SapService{
|
|||
}
|
||||
|
||||
@Override
|
||||
public int remessa(List<FechamentoCntCorrenteVO> fechamentos, boolean processoManual) throws Exception {
|
||||
try {
|
||||
int contador = 0;
|
||||
IntegracaoSapRest integracaoSapRest = IntegracaoSapRest.getInstance();
|
||||
String credenciais = buscaConstante(INTEGRACAO_SAP_CREDENCIAL);
|
||||
String url = buscaConstante(INTEGRACAO_SAP_URL);
|
||||
public int remessa(List<FechamentoCntCorrenteVO> fechamentos, boolean processoManual) throws BusinessRuntimeException, Exception {
|
||||
int contador = 0;
|
||||
IntegracaoSapRest integracaoSapRest = IntegracaoSapRest.getInstance();
|
||||
String credenciais = buscaConstante(INTEGRACAO_SAP_CREDENCIAL);
|
||||
String url = buscaConstante(INTEGRACAO_SAP_URL);
|
||||
|
||||
for (FechamentoCntCorrenteVO fechamentoCntcorrente : fechamentos) {
|
||||
if( fechamentoCntcorrente.isEnviar()) {
|
||||
log.debug("Enviando fechamento:"+ fechamentoCntcorrente.getFechamentocntcorrenteId());
|
||||
JSONObject integrado = integracaoSapRest.enviarIntegracaoSap(fechamentoCntcorrente, url, credenciais);
|
||||
for (FechamentoCntCorrenteVO fechamentoCntcorrente : fechamentos) {
|
||||
if( fechamentoCntcorrente.isEnviar()) {
|
||||
log.debug("Enviando fechamento:"+ fechamentoCntcorrente.getFechamentocntcorrenteId());
|
||||
JSONObject integrado = integracaoSapRest.enviarIntegracaoSap(fechamentoCntcorrente, url, credenciais);
|
||||
|
||||
if(integrado == null) {
|
||||
atualizaFechamento(fechamentoCntcorrente.getFechamentocntcorrenteId(), StatusIntegracaoSap.NAO_ENVIADO.ordinal());
|
||||
log.error("Erro no envio/retorno da requisicao para integracao SAP do fechamentoID: "+fechamentoCntcorrente.getFechamentocntcorrenteId());
|
||||
if(processoManual) {
|
||||
throw new RuntimeException("Erro no envio/retorno da requisicao para integracao SAP do fechamentoID: "+fechamentoCntcorrente.getFechamentocntcorrenteId());
|
||||
}
|
||||
}else if(integrado.getString("Integration").equals("S")) {
|
||||
atualizaFechamento(fechamentoCntcorrente.getFechamentocntcorrenteId(), StatusIntegracaoSap.INTEGRADO.ordinal());
|
||||
contador++;
|
||||
}else if(integrado.getString("Integration").equals("E")) {
|
||||
atualizaFechamento(fechamentoCntcorrente.getFechamentocntcorrenteId(), StatusIntegracaoSap.RECUSADO.ordinal());
|
||||
log.warn("Retorno enviado pelo SAP: \r\n"+integrado.getString("Message"));
|
||||
if(processoManual) {
|
||||
throw new RuntimeException("Fechamento: "+fechamentoCntcorrente.getFechamentocntcorrenteId()+"\r\nRetorno enviado pelo SAP: \r\n"+integrado.getString("Message"));
|
||||
}
|
||||
}
|
||||
if(integrado == null) {
|
||||
atualizaFechamento(fechamentoCntcorrente.getFechamentocntcorrenteId(), StatusIntegracaoSap.NAO_ENVIADO.ordinal());
|
||||
log.error("Erro no envio/retorno da requisicao para integracao SAP do fechamentoID: "+fechamentoCntcorrente.getFechamentocntcorrenteId());
|
||||
tratarProcessoManual(processoManual, "Erro no envio/retorno da requisicao para integracao SAP do fechamentoID: %s", fechamentoCntcorrente);
|
||||
}else if(integrado.getString("Integration").equals("S")) {
|
||||
atualizaFechamento(fechamentoCntcorrente.getFechamentocntcorrenteId(), StatusIntegracaoSap.INTEGRADO.ordinal());
|
||||
contador++;
|
||||
}else if(integrado.getString("Integration").equals("E")) {
|
||||
atualizaFechamento(fechamentoCntcorrente.getFechamentocntcorrenteId(), StatusIntegracaoSap.RECUSADO.ordinal());
|
||||
log.warn("Retorno enviado pelo SAP: \r\n"+integrado.getString("Message"));
|
||||
tratarProcessoManual(processoManual, "Fechamento: "+fechamentoCntcorrente.getFechamentocntcorrenteId()+"\r\nRetorno enviado pelo SAP: \r\n"+integrado.getString("Message"), fechamentoCntcorrente);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return contador;
|
||||
}catch(RuntimeException re){
|
||||
throw re;
|
||||
}catch(Exception e){
|
||||
throw e;
|
||||
return contador;
|
||||
}
|
||||
|
||||
private void tratarProcessoManual(boolean processoManual, String mensagem, FechamentoCntCorrenteVO fechamentoCntcorrente) {
|
||||
if(processoManual) {
|
||||
throw new BusinessRuntimeException( mensagem, fechamentoCntcorrente.getFechamentocntcorrenteId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +118,7 @@ public class SapServiceImpl implements SapService{
|
|||
Constante constante = constanteDAO.buscarPorNomeConstante(constanteString);
|
||||
|
||||
if( constante == null || constante.getValorconstante() == null || constante.getValorconstante().isEmpty() ) {
|
||||
throw new RuntimeException("Constante "+constanteString+" n<>o cadastrada");
|
||||
throw new BusinessRuntimeException("Constante %s não cadastrada", constanteString);
|
||||
}
|
||||
|
||||
return constante.getValorconstante();
|
||||
|
|
|
@ -138,7 +138,7 @@ public class FechamentoCntCorrenteVO {
|
|||
this.anofechamento = anofechamento;
|
||||
}
|
||||
|
||||
public Boolean isEnviar() {
|
||||
public boolean isEnviar() {
|
||||
return enviar;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue