fixes bug #AL-2093
correção de erro no preenchimento do código de desconto e melhoriasmaster
parent
cd6234bf00
commit
149a361812
12
pom.xml
12
pom.xml
|
@ -1,9 +1,9 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>br.com.rjconsultores</groupId>
|
<groupId>br.com.rjconsultores</groupId>
|
||||||
<artifactId>ModelWeb</artifactId>
|
<artifactId>ModelWeb</artifactId>
|
||||||
<version>1.0.36</version>
|
<version>1.0.37</version>
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
<repository>
|
<repository>
|
||||||
<id>rj-releases</id>
|
<id>rj-releases</id>
|
||||||
|
|
|
@ -75,6 +75,10 @@ import com.rjconsultores.ventaboletos.utilerias.CustomEnum;
|
||||||
@SuppressWarnings({"unchecked"})
|
@SuppressWarnings({"unchecked"})
|
||||||
public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<FechamentoBoleto, Long> implements RemessaCNABBancosDAO{
|
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);
|
private static Logger log = Logger.getLogger(RemessaCNABBancosHibernateDAO.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -85,8 +89,7 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
||||||
public String findBanco(Empresa empresa){
|
public String findBanco(Empresa empresa){
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("SELECT ");
|
sb.append("SELECT DISTINCT fp.BOLETO_BANCO_COD ");
|
||||||
sb.append("DISTINCT fp.BOLETO_BANCO_COD ");
|
|
||||||
sb.append("FROM ");
|
sb.append("FROM ");
|
||||||
sb.append("FECHAMENTO_PARAMGERAL fp ");
|
sb.append("FECHAMENTO_PARAMGERAL fp ");
|
||||||
sb.append("WHERE fp.activo = 1 AND ");
|
sb.append("WHERE fp.activo = 1 AND ");
|
||||||
|
@ -131,11 +134,11 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
||||||
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
||||||
|
|
||||||
Query query = getSession().createSQLQuery(sb.toString());
|
Query query = getSession().createSQLQuery(sb.toString());
|
||||||
query.setInteger("empresaId", empresa.getEmpresaId());
|
query.setInteger(EMPRESA_ID, empresa.getEmpresaId());
|
||||||
|
|
||||||
if(dataDe != null && dataAte != null){
|
if(dataDe != null && dataAte != null){
|
||||||
query.setDate("dataDe", dataDe);
|
query.setDate(DATA_DE, dataDe);
|
||||||
query.setDate("dataAte", dataAte);
|
query.setDate(DATA_ATE, dataAte);
|
||||||
}
|
}
|
||||||
List<Object[]> list = query.list();
|
List<Object[]> list = query.list();
|
||||||
|
|
||||||
|
@ -203,7 +206,7 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
||||||
detalhe.setDataOcorrencia(null);
|
detalhe.setDataOcorrencia(null);
|
||||||
detalhe.setNumeroDoDocumento(StringUtils.right(doc[0], 10));
|
detalhe.setNumeroDoDocumento(StringUtils.right(doc[0], 10));
|
||||||
detalhe.setVencimento((Date) tupla[9]);
|
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.setEmissao((Date) tupla[12]);
|
||||||
detalhe.setPercentualMulta( (BigDecimal) tupla[24] );
|
detalhe.setPercentualMulta( (BigDecimal) tupla[24] );
|
||||||
|
|
||||||
|
@ -226,7 +229,7 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
||||||
|
|
||||||
try{
|
try{
|
||||||
if( tupla[15] != null ) {
|
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 ) {
|
}else if( tupla[23] != null ) {
|
||||||
detalhe.setValorAtraso( calculaValorMora( (BigDecimal) tupla[23], new BigDecimal(tupla[10].toString().replaceAll(",", ".") )) );
|
detalhe.setValorAtraso( calculaValorMora( (BigDecimal) tupla[23], new BigDecimal(tupla[10].toString().replaceAll(",", ".") )) );
|
||||||
}else {
|
}else {
|
||||||
|
@ -238,12 +241,12 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
detalhe.setValorDesconto(new BigDecimal(tupla[16].toString().replaceAll(",", ".")));
|
detalhe.setValorDesconto(new BigDecimal(tupla[16].toString().replace(",", ".")));
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
detalhe.setValorAbatimentoConcedido(new BigDecimal(tupla[17].toString().replaceAll(",", ".")));
|
detalhe.setValorAbatimentoConcedido(new BigDecimal(tupla[17].toString().replace(",", ".")));
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,11 +323,11 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
||||||
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
||||||
|
|
||||||
Query query = getSession().createSQLQuery(sb.toString());
|
Query query = getSession().createSQLQuery(sb.toString());
|
||||||
query.setInteger("empresaId", empresa.getEmpresaId());
|
query.setInteger(EMPRESA_ID, empresa.getEmpresaId());
|
||||||
|
|
||||||
if(dataDe != null && dataAte != null){
|
if(dataDe != null && dataAte != null){
|
||||||
query.setDate("dataDe", dataDe);
|
query.setDate(DATA_DE, dataDe);
|
||||||
query.setDate("dataAte", dataAte);
|
query.setDate(DATA_ATE, dataAte);
|
||||||
}
|
}
|
||||||
List<Object[]> list = query.list();
|
List<Object[]> list = query.list();
|
||||||
|
|
||||||
|
@ -523,11 +526,11 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
||||||
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
||||||
|
|
||||||
Query query = getSession().createSQLQuery(sb.toString());
|
Query query = getSession().createSQLQuery(sb.toString());
|
||||||
query.setInteger("empresaId", empresa.getEmpresaId());
|
query.setInteger(EMPRESA_ID, empresa.getEmpresaId());
|
||||||
|
|
||||||
if(dataDe != null && dataAte != null){
|
if(dataDe != null && dataAte != null){
|
||||||
query.setDate("dataDe", dataDe);
|
query.setDate(DATA_DE, dataDe);
|
||||||
query.setDate("dataAte", dataAte);
|
query.setDate(DATA_ATE, dataAte);
|
||||||
}
|
}
|
||||||
List<Object[]> list = query.list();
|
List<Object[]> list = query.list();
|
||||||
|
|
||||||
|
@ -704,10 +707,10 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
||||||
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
||||||
|
|
||||||
Query query = getSession().createSQLQuery(sb.toString());
|
Query query = getSession().createSQLQuery(sb.toString());
|
||||||
query.setInteger("empresaId", empresa.getEmpresaId());
|
query.setInteger(EMPRESA_ID, empresa.getEmpresaId());
|
||||||
if(dataDe != null && dataAte != null){
|
if(dataDe != null && dataAte != null){
|
||||||
query.setDate("dataDe", dataDe);
|
query.setDate(DATA_DE, dataDe);
|
||||||
query.setDate("dataAte", dataAte);
|
query.setDate(DATA_ATE, dataAte);
|
||||||
}
|
}
|
||||||
List<Object[]> list = query.list();
|
List<Object[]> list = query.list();
|
||||||
|
|
||||||
|
@ -896,10 +899,10 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
||||||
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
||||||
|
|
||||||
Query query = getSession().createSQLQuery(sb.toString());
|
Query query = getSession().createSQLQuery(sb.toString());
|
||||||
query.setInteger("empresaId", empresa.getEmpresaId());
|
query.setInteger(EMPRESA_ID, empresa.getEmpresaId());
|
||||||
if(dataDe != null && dataAte != null){
|
if(dataDe != null && dataAte != null){
|
||||||
query.setDate("dataDe", dataDe);
|
query.setDate(DATA_DE, dataDe);
|
||||||
query.setDate("dataAte", dataAte);
|
query.setDate(DATA_ATE, dataAte);
|
||||||
}
|
}
|
||||||
List<Object[]> list = query.list();
|
List<Object[]> list = query.list();
|
||||||
|
|
||||||
|
@ -994,14 +997,14 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
||||||
titulosBancoBrasil.setIdentDistribuicao(" ");
|
titulosBancoBrasil.setIdentDistribuicao(" ");
|
||||||
titulosBancoBrasil.setNumeroDoDocumento(tupla[0].toString());
|
titulosBancoBrasil.setNumeroDoDocumento(tupla[0].toString());
|
||||||
titulosBancoBrasil.setVencimento((Date) tupla[10]);
|
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.setAgenciaCobradora(null);
|
||||||
titulosBancoBrasil.setDigAgenciaCobradora(null);
|
titulosBancoBrasil.setDigAgenciaCobradora(null);
|
||||||
titulosBancoBrasil.setAceite(AceiteBB.NAO_ACEITE);
|
titulosBancoBrasil.setAceite(AceiteBB.NAO_ACEITE);
|
||||||
titulosBancoBrasil.setEmissao((Date) tupla[13]);
|
titulosBancoBrasil.setEmissao((Date) tupla[13]);
|
||||||
try{
|
try{
|
||||||
titulosBancoBrasil.setCodMora(1);
|
titulosBancoBrasil.setCodMora(1);
|
||||||
titulosBancoBrasil.setJurosDeMora(new BigDecimal(tupla[16].toString().replaceAll(",", ".")));
|
titulosBancoBrasil.setJurosDeMora(new BigDecimal(tupla[16].toString().replace(",", ".")));
|
||||||
titulosBancoBrasil.setDataMora((Date) tupla[10]);
|
titulosBancoBrasil.setDataMora((Date) tupla[10]);
|
||||||
}catch(NullPointerException e){
|
}catch(NullPointerException e){
|
||||||
titulosBancoBrasil.setCodMora(1);
|
titulosBancoBrasil.setCodMora(1);
|
||||||
|
@ -1012,16 +1015,16 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
||||||
try{
|
try{
|
||||||
titulosBancoBrasil.setCodigoDesconto(1);
|
titulosBancoBrasil.setCodigoDesconto(1);
|
||||||
titulosBancoBrasil.setDataDesconto((Date) tupla[10]);
|
titulosBancoBrasil.setDataDesconto((Date) tupla[10]);
|
||||||
titulosBancoBrasil.setDescontoConcedido(new BigDecimal(tupla[17].toString().replaceAll(",", ".")));
|
titulosBancoBrasil.setDescontoConcedido(new BigDecimal(tupla[17].toString().replace(",", ".")));
|
||||||
}catch(NullPointerException e){
|
}catch(NullPointerException e){
|
||||||
titulosBancoBrasil.setCodigoDesconto(1);
|
titulosBancoBrasil.setCodigoDesconto(0);
|
||||||
titulosBancoBrasil.setDataDesconto((Date) tupla[10]);
|
titulosBancoBrasil.setDataDesconto((Date) tupla[10]);
|
||||||
titulosBancoBrasil.setDescontoConcedido(BigDecimal.ZERO);
|
titulosBancoBrasil.setDescontoConcedido(BigDecimal.ZERO);
|
||||||
}
|
}
|
||||||
|
|
||||||
titulosBancoBrasil.setIOF_Devido(BigDecimal.ZERO);
|
titulosBancoBrasil.setIOF_Devido(BigDecimal.ZERO);
|
||||||
try{
|
try{
|
||||||
titulosBancoBrasil.setAbatimentoConcedido(new BigDecimal(tupla[18].toString().replaceAll(",", ".")));
|
titulosBancoBrasil.setAbatimentoConcedido(new BigDecimal(tupla[18].toString().replace(",", ".")));
|
||||||
}catch(NullPointerException e){
|
}catch(NullPointerException e){
|
||||||
titulosBancoBrasil.setAbatimentoConcedido(BigDecimal.ZERO);
|
titulosBancoBrasil.setAbatimentoConcedido(BigDecimal.ZERO);
|
||||||
}
|
}
|
||||||
|
@ -1034,12 +1037,13 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
||||||
|
|
||||||
DetalheObrigatorioDadosPagadorBancoBrasil pagadorBancoBrasil = new DetalheObrigatorioDadosPagadorBancoBrasil();
|
DetalheObrigatorioDadosPagadorBancoBrasil pagadorBancoBrasil = new DetalheObrigatorioDadosPagadorBancoBrasil();
|
||||||
pagadorBancoBrasil.setTipoInscricaoSacado(Integer.parseInt(TipoInscricaoPagador.CNPJ.getId()));
|
pagadorBancoBrasil.setTipoInscricaoSacado(Integer.parseInt(TipoInscricaoPagador.CNPJ.getId()));
|
||||||
pagadorBancoBrasil.setNomeSacado(tupla[21].toString());
|
String ptoVenda = tupla[21].toString();
|
||||||
|
pagadorBancoBrasil.setNomeSacado(ptoVenda.toString());
|
||||||
String cep = "";
|
String cep = "";
|
||||||
try{
|
try{
|
||||||
cep = StringUtils.right("00000000" + tupla[24].toString(), 8);
|
cep = StringUtils.right(ZERO_ESQUERDA + tupla[24].toString(), 8);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
cep = "00000000";
|
cep = ZERO_ESQUERDA;
|
||||||
}
|
}
|
||||||
int cepPrefix = Integer.parseInt(cep.substring(0, 5));
|
int cepPrefix = Integer.parseInt(cep.substring(0, 5));
|
||||||
int cepSufix = Integer.parseInt(cep.substring(5));
|
int cepSufix = Integer.parseInt(cep.substring(5));
|
||||||
|
@ -1050,31 +1054,51 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
||||||
try{
|
try{
|
||||||
pagadorBancoBrasil.setNumeroInscricaoSacado(tupla[20].toString());
|
pagadorBancoBrasil.setNumeroInscricaoSacado(tupla[20].toString());
|
||||||
}catch(Exception e){
|
}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{
|
try{
|
||||||
pagadorBancoBrasil.setLogradouroSacado(tupla[22].toString());
|
pagadorBancoBrasil.setLogradouroSacado(tupla[22].toString());
|
||||||
}catch(Exception e){
|
}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{
|
try{
|
||||||
pagadorBancoBrasil.setBairroSacado(tupla[23].toString());
|
pagadorBancoBrasil.setBairroSacado(tupla[23].toString());
|
||||||
}catch(Exception e){
|
}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{
|
try{
|
||||||
pagadorBancoBrasil.setCidade(tupla[25].toString());
|
pagadorBancoBrasil.setCidade(tupla[25].toString());
|
||||||
}catch(Exception e){
|
}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{
|
try{
|
||||||
pagadorBancoBrasil.setEstado(tupla[26].toString());
|
pagadorBancoBrasil.setEstado(tupla[26].toString());
|
||||||
}catch(Exception e){
|
}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);
|
titulosBancoBrasil.setDetalheObrigatorioDadosPagadorBancoBrasil(pagadorBancoBrasil);
|
||||||
|
@ -1140,10 +1164,10 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
||||||
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
||||||
|
|
||||||
Query query = getSession().createSQLQuery(sb.toString());
|
Query query = getSession().createSQLQuery(sb.toString());
|
||||||
query.setInteger("empresaId", empresa.getEmpresaId());
|
query.setInteger(EMPRESA_ID, empresa.getEmpresaId());
|
||||||
if(dataDe != null && dataAte != null){
|
if(dataDe != null && dataAte != null){
|
||||||
query.setDate("dataDe", dataDe);
|
query.setDate(DATA_DE, dataDe);
|
||||||
query.setDate("dataAte", dataAte);
|
query.setDate(DATA_ATE, dataAte);
|
||||||
}
|
}
|
||||||
List<Object[]> list = query.list();
|
List<Object[]> list = query.list();
|
||||||
|
|
||||||
|
@ -1267,9 +1291,9 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
||||||
pagadorSicoob.setNomeSacado(tupla[21].toString());
|
pagadorSicoob.setNomeSacado(tupla[21].toString());
|
||||||
String cep = "";
|
String cep = "";
|
||||||
try{
|
try{
|
||||||
cep = StringUtils.right("00000000" + tupla[24].toString(), 8);
|
cep = StringUtils.right(ZERO_ESQUERDA + tupla[24].toString(), 8);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
cep = "00000000";
|
cep = ZERO_ESQUERDA;
|
||||||
}
|
}
|
||||||
int cepPrefix = Integer.parseInt(cep.substring(0, 5));
|
int cepPrefix = Integer.parseInt(cep.substring(0, 5));
|
||||||
int cepSufix = Integer.parseInt(cep.substring(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);
|
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
||||||
|
|
||||||
Query query = getSession().createSQLQuery(sb.toString());
|
Query query = getSession().createSQLQuery(sb.toString());
|
||||||
query.setInteger("empresaId", empresa.getEmpresaId());
|
query.setInteger(EMPRESA_ID, empresa.getEmpresaId());
|
||||||
if(dataDe != null && dataAte != null){
|
if(dataDe != null && dataAte != null){
|
||||||
query.setDate("dataDe", dataDe);
|
query.setDate(DATA_DE, dataDe);
|
||||||
query.setDate("dataAte", dataAte);
|
query.setDate(DATA_ATE, dataAte);
|
||||||
}
|
}
|
||||||
List<Object[]> list = query.list();
|
List<Object[]> list = query.list();
|
||||||
|
|
||||||
|
@ -1453,9 +1477,9 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
||||||
|
|
||||||
String cep = "";
|
String cep = "";
|
||||||
try{
|
try{
|
||||||
cep = StringUtils.right("00000000" + tupla[18].toString(), 8);
|
cep = StringUtils.right(ZERO_ESQUERDA + tupla[18].toString(), 8);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
cep = "00000000";
|
cep = ZERO_ESQUERDA;
|
||||||
}
|
}
|
||||||
|
|
||||||
titulosCaixa.setCepSacado(cep);
|
titulosCaixa.setCepSacado(cep);
|
||||||
|
@ -1560,11 +1584,11 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
||||||
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
writeFROMClause(sb, dataDe != null && dataAte != null, reenviar);
|
||||||
|
|
||||||
Query query = getSession().createSQLQuery(sb.toString());
|
Query query = getSession().createSQLQuery(sb.toString());
|
||||||
query.setInteger("empresaId", empresa.getEmpresaId());
|
query.setInteger(EMPRESA_ID, empresa.getEmpresaId());
|
||||||
|
|
||||||
if(dataDe != null && dataAte != null){
|
if(dataDe != null && dataAte != null){
|
||||||
query.setDate("dataDe", dataDe);
|
query.setDate(DATA_DE, dataDe);
|
||||||
query.setDate("dataAte", dataAte);
|
query.setDate(DATA_ATE, dataAte);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Object[]> list = query.list();
|
List<Object[]> list = query.list();
|
||||||
|
@ -1720,7 +1744,7 @@ public class RemessaCNABBancosHibernateDAO extends GenericHibernateDAO<Fechament
|
||||||
.setResultTransformer(new AliasToBeanResultTransformer(FechamentoBoleto.class));
|
.setResultTransformer(new AliasToBeanResultTransformer(FechamentoBoleto.class));
|
||||||
|
|
||||||
query.setString("nossoNumero", nossoNumero);
|
query.setString("nossoNumero", nossoNumero);
|
||||||
query.setInteger("empresaId", empresaId);
|
query.setInteger(EMPRESA_ID, empresaId);
|
||||||
|
|
||||||
FechamentoBoleto retorno = (FechamentoBoleto)query.uniqueResult();
|
FechamentoBoleto retorno = (FechamentoBoleto)query.uniqueResult();
|
||||||
|
|
||||||
|
|
|
@ -1,172 +1,174 @@
|
||||||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.dao.SapDAO;
|
import com.rjconsultores.ventaboletos.dao.SapDAO;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
import com.rjconsultores.ventaboletos.entidad.FechamentoCntcorrente;
|
import com.rjconsultores.ventaboletos.entidad.FechamentoCntcorrente;
|
||||||
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
||||||
import com.rjconsultores.ventaboletos.enums.StatusIntegracaoSap;
|
import com.rjconsultores.ventaboletos.enums.StatusIntegracaoSap;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
import com.rjconsultores.ventaboletos.exception.BusinessRuntimeException;
|
||||||
import com.rjconsultores.ventaboletos.vo.integracao.FechamentoCntCorrenteVO;
|
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||||
|
import com.rjconsultores.ventaboletos.vo.integracao.FechamentoCntCorrenteVO;
|
||||||
@Repository("sapDAO")
|
|
||||||
public class SapHibernateDAO extends GenericHibernateDAO<FechamentoCntcorrente, Long> implements SapDAO {
|
@Repository("sapDAO")
|
||||||
|
public class SapHibernateDAO extends GenericHibernateDAO<FechamentoCntcorrente, Long> implements SapDAO {
|
||||||
@Autowired
|
|
||||||
public SapHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
@Autowired
|
||||||
setSessionFactory(factory);
|
public SapHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||||
}
|
setSessionFactory(factory);
|
||||||
|
}
|
||||||
@Autowired
|
|
||||||
@Qualifier("dataSourceWrite")
|
@Autowired
|
||||||
DataSource scoDs;
|
@Qualifier("dataSourceWrite")
|
||||||
|
DataSource scoDs;
|
||||||
@Override
|
|
||||||
@Transactional
|
@Override
|
||||||
public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, String status) {
|
@Transactional
|
||||||
return obtenerTodosParaRemessa(empresa, dataDe, dataAte, status, null);
|
public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, String status) {
|
||||||
}
|
return obtenerTodosParaRemessa(empresa, dataDe, dataAte, status, null);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
@Transactional
|
@Override
|
||||||
public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, String status, PuntoVenta puntoVenta) {
|
@Transactional
|
||||||
|
public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, String status, PuntoVenta puntoVenta) {
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append(" SELECT ");
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(" fc.fechamentocntcorrente_id, ");
|
sb.append(" SELECT ");
|
||||||
sb.append(" to_char(fc.fecfechamento, 'yyyy-mm-DD'), ");
|
sb.append(" fc.fechamentocntcorrente_id, ");
|
||||||
sb.append(" fc.total, ");
|
sb.append(" to_char(fc.fecfechamento, 'yyyy-mm-DD'), ");
|
||||||
sb.append(" es.cveestado, ");
|
sb.append(" fc.total, ");
|
||||||
sb.append(" pv.numpuntoventa, ");
|
sb.append(" es.cveestado, ");
|
||||||
sb.append(" pv.numdocpuntoventa, ");
|
sb.append(" pv.numpuntoventa, ");
|
||||||
sb.append(" pv.nombpuntoventa, ");
|
sb.append(" pv.numdocpuntoventa, ");
|
||||||
sb.append(" fc.empresa_id, ");
|
sb.append(" pv.nombpuntoventa, ");
|
||||||
sb.append(" emp.nombempresa, ");
|
sb.append(" fc.empresa_id, ");
|
||||||
sb.append(" fc.indintegradosap, ");
|
sb.append(" emp.nombempresa, ");
|
||||||
sb.append(" to_char(fc.fecfechamento, 'yyyy'), ");
|
sb.append(" fc.indintegradosap, ");
|
||||||
sb.append(" to_char(fc.fecfechamento, 'mm'), ");
|
sb.append(" to_char(fc.fecfechamento, 'yyyy'), ");
|
||||||
sb.append(" CASE to_char(fc.fecfechamento, 'D') ");
|
sb.append(" to_char(fc.fecfechamento, 'mm'), ");
|
||||||
sb.append(" WHEN '6' THEN to_char(fc.fecfechamento+3, 'yyyy-mm-DD') ");
|
sb.append(" CASE to_char(fc.fecfechamento, 'D') ");
|
||||||
sb.append(" WHEN '7' THEN to_char(fc.fecfechamento+2, 'yyyy-mm-DD') ");
|
sb.append(" WHEN '6' THEN to_char(fc.fecfechamento+3, 'yyyy-mm-DD') ");
|
||||||
sb.append(" ELSE to_char(fc.fecfechamento+1, 'yyyy-mm-DD') END as feclancamento ");
|
sb.append(" WHEN '7' THEN to_char(fc.fecfechamento+2, 'yyyy-mm-DD') ");
|
||||||
sb.append(" FROM ");
|
sb.append(" ELSE to_char(fc.fecfechamento+1, 'yyyy-mm-DD') END as feclancamento ");
|
||||||
sb.append(" fechamento_cntcorrente fc ");
|
sb.append(" FROM ");
|
||||||
sb.append(" INNER JOIN punto_venta pv ON pv.puntoventa_id = fc.puntoventa_id AND pv.activo = 1 ");
|
sb.append(" fechamento_cntcorrente fc ");
|
||||||
sb.append(" INNER JOIN empresa emp ON emp.empresa_id = fc.empresa_id AND emp.activo = 1 ");
|
sb.append(" INNER JOIN punto_venta pv ON pv.puntoventa_id = fc.puntoventa_id AND pv.activo = 1 ");
|
||||||
sb.append(" INNER JOIN FECHAMENTO_PARAMPTOVTA fp ON fp.PUNTOVENTA_ID = fc.puntoventa_id AND fp.activo =1 ");
|
sb.append(" INNER JOIN empresa emp ON emp.empresa_id = fc.empresa_id AND emp.activo = 1 ");
|
||||||
sb.append(" AND fp.empresa_id = fc.empresa_id AND fp.TIPOPAGAMENTO = 'B'" );
|
sb.append(" INNER JOIN FECHAMENTO_PARAMPTOVTA fp ON fp.PUNTOVENTA_ID = fc.puntoventa_id AND fp.activo =1 ");
|
||||||
sb.append(" LEFT JOIN ciudad ci ON ci.ciudad_id = emp.ciudad_id AND ci.activo = 1 ");
|
sb.append(" AND fp.empresa_id = fc.empresa_id AND fp.TIPOPAGAMENTO = 'B'" );
|
||||||
sb.append(" LEFT JOIN plaza pl ON pl.plaza_id = ci.plaza_id AND pl.activo = 1 ");
|
sb.append(" LEFT JOIN ciudad ci ON ci.ciudad_id = emp.ciudad_id AND ci.activo = 1 ");
|
||||||
sb.append(" LEFT JOIN estado es ON es.estado_id = ci.estado_id AND es.activo = 1 ");
|
sb.append(" LEFT JOIN plaza pl ON pl.plaza_id = ci.plaza_id AND pl.activo = 1 ");
|
||||||
sb.append(" WHERE ");
|
sb.append(" LEFT JOIN estado es ON es.estado_id = ci.estado_id AND es.activo = 1 ");
|
||||||
sb.append(" fc.activo = 1 ");
|
sb.append(" WHERE ");
|
||||||
sb.append(" AND fc.fecfechamento BETWEEN :dataDe AND :dataAte ");
|
sb.append(" fc.activo = 1 ");
|
||||||
|
sb.append(" AND fc.fecfechamento BETWEEN :dataDe AND :dataAte ");
|
||||||
if( empresa != null ) {
|
|
||||||
sb.append(" AND fc.EMPRESA_ID = :empresaId ");
|
if( empresa != null ) {
|
||||||
}
|
sb.append(" AND fc.EMPRESA_ID = :empresaId ");
|
||||||
|
}
|
||||||
if( puntoVenta != null ) {
|
|
||||||
sb.append(" AND pv.puntoventa_id = :puntoVentaId ");
|
if( puntoVenta != null ) {
|
||||||
}
|
sb.append(" AND pv.puntoventa_id = :puntoVentaId ");
|
||||||
|
}
|
||||||
if(status != null && !status.isEmpty()){
|
|
||||||
sb.append(" AND fc.indintegradosap in ("+status+")");
|
if(status != null && !status.isEmpty()){
|
||||||
}
|
sb.append(" AND fc.indintegradosap in ("+status+")");
|
||||||
|
}
|
||||||
sb.append(" ORDER BY ");
|
|
||||||
sb.append(" pv.nombpuntoventa, fc.fecfechamento ");
|
sb.append(" ORDER BY ");
|
||||||
|
sb.append(" pv.nombpuntoventa, fc.fecfechamento ");
|
||||||
Query query = getSession().createSQLQuery(sb.toString());
|
|
||||||
|
Query query = getSession().createSQLQuery(sb.toString());
|
||||||
if( empresa != null ) {
|
|
||||||
query.setInteger("empresaId", empresa.getEmpresaId());
|
if( empresa != null ) {
|
||||||
}
|
query.setInteger("empresaId", empresa.getEmpresaId());
|
||||||
|
}
|
||||||
if( puntoVenta != null ) {
|
|
||||||
query.setInteger("puntoVentaId", puntoVenta.getPuntoventaId());
|
if( puntoVenta != null ) {
|
||||||
}
|
query.setInteger("puntoVentaId", puntoVenta.getPuntoventaId());
|
||||||
|
}
|
||||||
if(dataDe != null && dataAte != null){
|
|
||||||
query.setDate("dataDe", DateUtil.normalizarToFecha(dataDe));
|
if(dataDe != null && dataAte != null){
|
||||||
query.setDate("dataAte", DateUtil.normalizarToFecha(dataAte));
|
query.setDate("dataDe", DateUtil.normalizarToFecha(dataDe));
|
||||||
}
|
query.setDate("dataAte", DateUtil.normalizarToFecha(dataAte));
|
||||||
|
}
|
||||||
query.setMaxResults(100);
|
|
||||||
|
query.setMaxResults(100);
|
||||||
List<Object[]> list = query.list();
|
|
||||||
List<FechamentoCntCorrenteVO> retorno = new ArrayList<FechamentoCntCorrenteVO>();
|
@SuppressWarnings("unchecked")
|
||||||
|
List<Object[]> list = query.list();
|
||||||
for(Object[] tupla : list){
|
List<FechamentoCntCorrenteVO> retorno = new ArrayList<>();
|
||||||
|
|
||||||
FechamentoCntCorrenteVO fcc = new FechamentoCntCorrenteVO();
|
for(Object[] tupla : list){
|
||||||
fcc.setFechamentocntcorrenteId( Long.valueOf(tupla[0].toString()));
|
|
||||||
fcc.setFecfechamento( tupla[1].toString() );
|
FechamentoCntCorrenteVO fcc = new FechamentoCntCorrenteVO();
|
||||||
fcc.setTotal( (BigDecimal)tupla[2] );
|
fcc.setFechamentocntcorrenteId( Long.valueOf(tupla[0].toString()));
|
||||||
fcc.setUfEmpresa(tupla[3].toString());
|
fcc.setFecfechamento( tupla[1].toString() );
|
||||||
fcc.setNumPuntoVenta(tupla[4].toString());
|
fcc.setTotal( (BigDecimal)tupla[2] );
|
||||||
|
fcc.setUfEmpresa(tupla[3].toString());
|
||||||
try {
|
fcc.setNumPuntoVenta(tupla[4].toString());
|
||||||
String cnpj = tupla[5].toString().replaceAll("[^0-9]", "");
|
|
||||||
fcc.setCnpjPuntoVenta(cnpj);
|
try {
|
||||||
}catch (Exception e) {
|
String cnpj = tupla[5].toString().replaceAll("\\D", "");
|
||||||
throw new RuntimeException( "CNPJ fora do padrao no ponto de venda: "+tupla[6] );
|
fcc.setCnpjPuntoVenta(cnpj);
|
||||||
}
|
}catch (Exception e) {
|
||||||
fcc.setNombpuntoventa(tupla[6].toString());
|
throw new BusinessRuntimeException( "CNPJ fora do padrao no ponto de venda: %s ", tupla[6] );
|
||||||
|
}
|
||||||
fcc.setEmpresaId( Integer.valueOf( tupla[7].toString() ));
|
fcc.setNombpuntoventa(tupla[6].toString());
|
||||||
fcc.setNombEmpresa( tupla[8].toString());
|
|
||||||
|
fcc.setEmpresaId( Integer.valueOf( tupla[7].toString() ));
|
||||||
fcc.setIntegradoSap( StatusIntegracaoSap.getStatusIntegracaoSap( tupla[9]==null?0:Integer.valueOf(tupla[9].toString()) ));
|
fcc.setNombEmpresa( tupla[8].toString());
|
||||||
|
|
||||||
fcc.setAnofechamento(tupla[10].toString());
|
fcc.setIntegradoSap( StatusIntegracaoSap.getStatusIntegracaoSap( tupla[9]==null?0:Integer.valueOf(tupla[9].toString()) ));
|
||||||
fcc.setMesfechamento(tupla[11].toString());
|
|
||||||
fcc.setFeclancamento(tupla[12].toString());
|
fcc.setAnofechamento(tupla[10].toString());
|
||||||
|
fcc.setMesfechamento(tupla[11].toString());
|
||||||
//empresa enviada nula apenas no processo automatico
|
fcc.setFeclancamento(tupla[12].toString());
|
||||||
if(empresa == null) {
|
|
||||||
fcc.setEnviar(true);
|
//empresa enviada nula apenas no processo automatico
|
||||||
}
|
if(empresa == null) {
|
||||||
|
fcc.setEnviar(true);
|
||||||
retorno.add(fcc);
|
}
|
||||||
}
|
|
||||||
|
retorno.add(fcc);
|
||||||
return retorno;
|
}
|
||||||
}
|
|
||||||
|
return retorno;
|
||||||
@Override
|
}
|
||||||
@Transactional
|
|
||||||
public synchronized boolean atualizaFechamento(Long fechamentocntcorrenteId, int status) throws Exception {
|
@Override
|
||||||
|
@Transactional
|
||||||
if(fechamentocntcorrenteId == null ) {
|
public synchronized boolean atualizaFechamento(Long fechamentocntcorrenteId, int status) throws Exception {
|
||||||
return false;
|
|
||||||
}
|
if(fechamentocntcorrenteId == null ) {
|
||||||
|
return false;
|
||||||
//é feito update manualmente porque o hibernate utiliza sco_read e nao tem permissao de escrita no banco
|
}
|
||||||
try(Connection con = scoDs.getConnection();
|
|
||||||
Statement stmt = con.createStatement()){
|
//é feito update manualmente porque o hibernate utiliza sco_read e nao tem permissao de escrita no banco
|
||||||
stmt.addBatch("UPDATE FECHAMENTO_CNTCORRENTE SET INDINTEGRADOSAP = "+ status
|
try(Connection con = scoDs.getConnection();
|
||||||
+" WHERE FECHAMENTOCNTCORRENTE_ID = " + fechamentocntcorrenteId);
|
Statement stmt = con.createStatement()){
|
||||||
|
stmt.addBatch("UPDATE FECHAMENTO_CNTCORRENTE SET INDINTEGRADOSAP = "+ status
|
||||||
stmt.executeBatch();
|
+" WHERE FECHAMENTOCNTCORRENTE_ID = " + fechamentocntcorrenteId);
|
||||||
}
|
|
||||||
|
stmt.executeBatch();
|
||||||
return Boolean.TRUE;
|
}
|
||||||
}
|
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -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.FechamentoCntcorrente;
|
||||||
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
||||||
import com.rjconsultores.ventaboletos.enums.StatusIntegracaoSap;
|
import com.rjconsultores.ventaboletos.enums.StatusIntegracaoSap;
|
||||||
|
import com.rjconsultores.ventaboletos.exception.BusinessRuntimeException;
|
||||||
import com.rjconsultores.ventaboletos.rest.IntegracaoSapRest;
|
import com.rjconsultores.ventaboletos.rest.IntegracaoSapRest;
|
||||||
import com.rjconsultores.ventaboletos.service.SapService;
|
import com.rjconsultores.ventaboletos.service.SapService;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||||
|
@ -74,43 +75,39 @@ public class SapServiceImpl implements SapService{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int remessa(List<FechamentoCntCorrenteVO> fechamentos, boolean processoManual) throws Exception {
|
public int remessa(List<FechamentoCntCorrenteVO> fechamentos, boolean processoManual) throws BusinessRuntimeException, Exception {
|
||||||
try {
|
int contador = 0;
|
||||||
int contador = 0;
|
IntegracaoSapRest integracaoSapRest = IntegracaoSapRest.getInstance();
|
||||||
IntegracaoSapRest integracaoSapRest = IntegracaoSapRest.getInstance();
|
String credenciais = buscaConstante(INTEGRACAO_SAP_CREDENCIAL);
|
||||||
String credenciais = buscaConstante(INTEGRACAO_SAP_CREDENCIAL);
|
String url = buscaConstante(INTEGRACAO_SAP_URL);
|
||||||
String url = buscaConstante(INTEGRACAO_SAP_URL);
|
|
||||||
|
|
||||||
for (FechamentoCntCorrenteVO fechamentoCntcorrente : fechamentos) {
|
for (FechamentoCntCorrenteVO fechamentoCntcorrente : fechamentos) {
|
||||||
if( fechamentoCntcorrente.isEnviar()) {
|
if( fechamentoCntcorrente.isEnviar()) {
|
||||||
log.debug("Enviando fechamento:"+ fechamentoCntcorrente.getFechamentocntcorrenteId());
|
log.debug("Enviando fechamento:"+ fechamentoCntcorrente.getFechamentocntcorrenteId());
|
||||||
JSONObject integrado = integracaoSapRest.enviarIntegracaoSap(fechamentoCntcorrente, url, credenciais);
|
JSONObject integrado = integracaoSapRest.enviarIntegracaoSap(fechamentoCntcorrente, url, credenciais);
|
||||||
|
|
||||||
if(integrado == null) {
|
if(integrado == null) {
|
||||||
atualizaFechamento(fechamentoCntcorrente.getFechamentocntcorrenteId(), StatusIntegracaoSap.NAO_ENVIADO.ordinal());
|
atualizaFechamento(fechamentoCntcorrente.getFechamentocntcorrenteId(), StatusIntegracaoSap.NAO_ENVIADO.ordinal());
|
||||||
log.error("Erro no envio/retorno da requisicao para integracao SAP do fechamentoID: "+fechamentoCntcorrente.getFechamentocntcorrenteId());
|
log.error("Erro no envio/retorno da requisicao para integracao SAP do fechamentoID: "+fechamentoCntcorrente.getFechamentocntcorrenteId());
|
||||||
if(processoManual) {
|
tratarProcessoManual(processoManual, "Erro no envio/retorno da requisicao para integracao SAP do fechamentoID: %s", fechamentoCntcorrente);
|
||||||
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());
|
||||||
}else if(integrado.getString("Integration").equals("S")) {
|
contador++;
|
||||||
atualizaFechamento(fechamentoCntcorrente.getFechamentocntcorrenteId(), StatusIntegracaoSap.INTEGRADO.ordinal());
|
}else if(integrado.getString("Integration").equals("E")) {
|
||||||
contador++;
|
atualizaFechamento(fechamentoCntcorrente.getFechamentocntcorrenteId(), StatusIntegracaoSap.RECUSADO.ordinal());
|
||||||
}else if(integrado.getString("Integration").equals("E")) {
|
log.warn("Retorno enviado pelo SAP: \r\n"+integrado.getString("Message"));
|
||||||
atualizaFechamento(fechamentoCntcorrente.getFechamentocntcorrenteId(), StatusIntegracaoSap.RECUSADO.ordinal());
|
tratarProcessoManual(processoManual, "Fechamento: "+fechamentoCntcorrente.getFechamentocntcorrenteId()+"\r\nRetorno enviado pelo SAP: \r\n"+integrado.getString("Message"), fechamentoCntcorrente);
|
||||||
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"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return contador;
|
|
||||||
}catch(RuntimeException re){
|
return contador;
|
||||||
throw re;
|
}
|
||||||
}catch(Exception e){
|
|
||||||
throw e;
|
private void tratarProcessoManual(boolean processoManual, String mensagem, FechamentoCntCorrenteVO fechamentoCntcorrente) {
|
||||||
}
|
if(processoManual) {
|
||||||
|
throw new BusinessRuntimeException( mensagem, fechamentoCntcorrente.getFechamentocntcorrenteId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean atualizaFechamento(Long fechamentocntcorrenteId, int status) throws Exception {
|
private boolean atualizaFechamento(Long fechamentocntcorrenteId, int status) throws Exception {
|
||||||
|
@ -121,7 +118,7 @@ public class SapServiceImpl implements SapService{
|
||||||
Constante constante = constanteDAO.buscarPorNomeConstante(constanteString);
|
Constante constante = constanteDAO.buscarPorNomeConstante(constanteString);
|
||||||
|
|
||||||
if( constante == null || constante.getValorconstante() == null || constante.getValorconstante().isEmpty() ) {
|
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();
|
return constante.getValorconstante();
|
||||||
|
|
|
@ -138,7 +138,7 @@ public class FechamentoCntCorrenteVO {
|
||||||
this.anofechamento = anofechamento;
|
this.anofechamento = anofechamento;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean isEnviar() {
|
public boolean isEnviar() {
|
||||||
return enviar;
|
return enviar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue