fixes bug#al-1693

dev: Celio
qua:

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@115137 d1611594-4594-4d17-8e1d-87c2c4800839
master
fabio 2022-11-03 15:02:52 +00:00
parent 74d3b24464
commit ff5d4f4cb6
6 changed files with 52 additions and 61 deletions

View File

@ -10,9 +10,9 @@ import com.rjconsultores.ventaboletos.vo.integracao.FechamentoCntCorrenteVO;
public interface SapDAO extends GenericDAO<FechamentoCntcorrente, Long> { public interface SapDAO extends GenericDAO<FechamentoCntcorrente, Long> {
public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, Boolean reenviar); public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, String status);
public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, Boolean reenviar, PuntoVenta puntoVenta); public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, String status, PuntoVenta puntoVenta);
public boolean atualizaFechamento(Long fechamentocntcorrenteId, int status) throws Exception; public boolean atualizaFechamento(Long fechamentocntcorrenteId, int status) throws Exception;

View File

@ -1,36 +0,0 @@
package com.rjconsultores.ventaboletos.enums;
import java.util.Arrays;
import java.util.List;
public enum EnumIntegracaoSap {
INTEGRADO("Integrado"),
NAO_ENVIADO("Nao Enviado"),
ERRO("Recusado SAP");
private String descricao;
private EnumIntegracaoSap(String descricao) {
this.descricao = descricao;
}
@Override
public String toString() {
return descricao;
}
public static List<EnumIntegracaoSap> list() {
return Arrays.asList(values());
}
public static EnumIntegracaoSap getEnumIntegracaoSap(Integer tValor) {
for (EnumIntegracaoSap valor : EnumIntegracaoSap.values()) {
if (tValor.equals(valor.ordinal())) {
return valor;
}
}
return null;
}
}

View File

@ -1,7 +1,35 @@
package com.rjconsultores.ventaboletos.enums; package com.rjconsultores.ventaboletos.enums;
import java.util.Arrays;
import java.util.List;
public enum StatusIntegracaoSap { public enum StatusIntegracaoSap {
INTEGRADO, INTEGRADO("Integrado"),
NAO_INTEGRADO, NAO_ENVIADO("Nao Enviado"),
PENDENTE; PENDENTE("Pendente"),
RECUSADO("Recusado SAP");
private String descricao;
private StatusIntegracaoSap(String descricao) {
this.descricao = descricao;
}
@Override
public String toString() {
return descricao;
}
public static List<StatusIntegracaoSap> list() {
return Arrays.asList(values());
}
public static StatusIntegracaoSap getStatusIntegracaoSap(Integer tValor) {
for (StatusIntegracaoSap valor : StatusIntegracaoSap.values()) {
if (tValor.equals(valor.ordinal())) {
return valor;
}
}
return null;
}
} }

View File

@ -12,9 +12,9 @@ public interface SapService extends GenericService<FechamentoCntcorrente, Long>
public int remessa(List<FechamentoCntCorrenteVO> fechamentos) throws Exception ; public int remessa(List<FechamentoCntCorrenteVO> fechamentos) throws Exception ;
public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, Boolean reenviar); public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, String status);
public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, Boolean reenviar, PuntoVenta puntoVenta); public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, String status, PuntoVenta puntoVenta);
public void integracaoSapAutomatica() throws Exception; public void integracaoSapAutomatica() throws Exception;

View File

@ -15,6 +15,7 @@ import com.rjconsultores.ventaboletos.entidad.Constante;
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.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;
@ -25,8 +26,6 @@ public class SapServiceImpl implements SapService{
private static final String INTEGRACAO_SAP_URL = "INTEGRACAO_SAP_URL"; private static final String INTEGRACAO_SAP_URL = "INTEGRACAO_SAP_URL";
private static final String INTEGRACAO_SAP_CREDENCIAL = "INTEGRACAO_SAP_CREDENCIAL"; private static final String INTEGRACAO_SAP_CREDENCIAL = "INTEGRACAO_SAP_CREDENCIAL";
private static final int INTEGRACAO_SAP_OK = 1;
private static final int INTEGRACAO_SAP_ERRO = 2;
private static Logger log = Logger.getLogger(SapServiceImpl.class); private static Logger log = Logger.getLogger(SapServiceImpl.class);
@Autowired @Autowired
@ -65,13 +64,13 @@ public class SapServiceImpl implements SapService{
} }
@Override @Override
public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, Boolean reenviar) { public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, String status) {
return sapDAO.obtenerTodosParaRemessa(empresa, dataDe, dataAte, reenviar, null); return sapDAO.obtenerTodosParaRemessa(empresa, dataDe, dataAte, status, null);
} }
@Override @Override
public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, Boolean reenviar, PuntoVenta puntoVenta) { public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, String status, PuntoVenta puntoVenta) {
return sapDAO.obtenerTodosParaRemessa(empresa, dataDe, dataAte, reenviar, puntoVenta); return sapDAO.obtenerTodosParaRemessa(empresa, dataDe, dataAte, status, puntoVenta);
} }
@Override @Override
@ -87,14 +86,14 @@ public class SapServiceImpl implements SapService{
JSONObject integrado = integracaoSapRest.enviarIntegracaoSap(fechamentoCntcorrente, url, credenciais); JSONObject integrado = integracaoSapRest.enviarIntegracaoSap(fechamentoCntcorrente, url, credenciais);
if(integrado == null) { if(integrado == null) {
atualizaFechamento(fechamentoCntcorrente.getFechamentocntcorrenteId(), INTEGRACAO_SAP_ERRO); atualizaFechamento(fechamentoCntcorrente.getFechamentocntcorrenteId(), StatusIntegracaoSap.NAO_ENVIADO.ordinal());
log.error("Erro no envio/retorno da requisicao para integra<EFBFBD><EFBFBD>o SAP do fechamentoID: "+fechamentoCntcorrente.getFechamentocntcorrenteId()); log.error("Erro no envio/retorno da requisicao para integracao SAP do fechamentoID: "+fechamentoCntcorrente.getFechamentocntcorrenteId());
throw new RuntimeException("Erro no envio/retorno da requisicao para integração SAP do fechamentoID: "+fechamentoCntcorrente.getFechamentocntcorrenteId()); throw new RuntimeException("Erro no envio/retorno da requisicao para integracao SAP do fechamentoID: "+fechamentoCntcorrente.getFechamentocntcorrenteId());
}else if(integrado.getString("Integration").equals("S")) { }else if(integrado.getString("Integration").equals("S")) {
atualizaFechamento(fechamentoCntcorrente.getFechamentocntcorrenteId(), INTEGRACAO_SAP_OK); atualizaFechamento(fechamentoCntcorrente.getFechamentocntcorrenteId(), StatusIntegracaoSap.INTEGRADO.ordinal());
contador++; contador++;
}else if(integrado.getString("Integration").equals("E")) { }else if(integrado.getString("Integration").equals("E")) {
atualizaFechamento(fechamentoCntcorrente.getFechamentocntcorrenteId(), INTEGRACAO_SAP_ERRO); atualizaFechamento(fechamentoCntcorrente.getFechamentocntcorrenteId(), StatusIntegracaoSap.RECUSADO.ordinal());
log.warn("Retorno enviado pelo SAP: \r\n"+integrado.getString("Message")); log.warn("Retorno enviado pelo SAP: \r\n"+integrado.getString("Message"));
throw new RuntimeException("Fechamento: "+fechamentoCntcorrente.getFechamentocntcorrenteId()+"\r\nRetorno enviado pelo SAP: \r\n"+integrado.getString("Message")); throw new RuntimeException("Fechamento: "+fechamentoCntcorrente.getFechamentocntcorrenteId()+"\r\nRetorno enviado pelo SAP: \r\n"+integrado.getString("Message"));
} }
@ -125,7 +124,7 @@ public class SapServiceImpl implements SapService{
@Override @Override
public void integracaoSapAutomatica() throws Exception { public void integracaoSapAutomatica() throws Exception {
List<FechamentoCntCorrenteVO> listaPendente = obtenerTodosParaRemessa(null, DateUtil.getYesterdayDate(), new Date(), false); List<FechamentoCntCorrenteVO> listaPendente = obtenerTodosParaRemessa(null, DateUtil.getYesterdayDate(), new Date(), "2");
while(!listaPendente.isEmpty()) { while(!listaPendente.isEmpty()) {
log.info("IntegracaoSap: Registro a enviar:"+listaPendente.size()); log.info("IntegracaoSap: Registro a enviar:"+listaPendente.size());
@ -136,7 +135,7 @@ public class SapServiceImpl implements SapService{
throw e; throw e;
} }
listaPendente = obtenerTodosParaRemessa(null, DateUtil.getYesterdayDate(), new Date(), false); listaPendente = obtenerTodosParaRemessa(null, DateUtil.getYesterdayDate(), new Date(), "2");
} }
} }

View File

@ -2,7 +2,7 @@ package com.rjconsultores.ventaboletos.vo.integracao;
import java.math.BigDecimal; import java.math.BigDecimal;
import com.rjconsultores.ventaboletos.enums.EnumIntegracaoSap; import com.rjconsultores.ventaboletos.enums.StatusIntegracaoSap;
public class FechamentoCntCorrenteVO { public class FechamentoCntCorrenteVO {
@ -23,10 +23,10 @@ public class FechamentoCntCorrenteVO {
private Integer empresaId; private Integer empresaId;
private String nombEmpresa; private String nombEmpresa;
private String ufEmpresa; private String ufEmpresa;
private EnumIntegracaoSap integradoSap; private StatusIntegracaoSap integradoSap;
private boolean enviar; private boolean enviar;
public FechamentoCntCorrenteVO(Long fechamentocntcorrenteId, String fecfechamento, String feclancamento, String anofechamento, String mesfechamento, BigDecimal total, String nombpuntoventa, String cnpjPuntoVenta, Integer empresaId, String nombEmpresa, String ufEmpresa, EnumIntegracaoSap integradoSap) { public FechamentoCntCorrenteVO(Long fechamentocntcorrenteId, String fecfechamento, String feclancamento, String anofechamento, String mesfechamento, BigDecimal total, String nombpuntoventa, String cnpjPuntoVenta, Integer empresaId, String nombEmpresa, String ufEmpresa, StatusIntegracaoSap integradoSap) {
super(); super();
this.fechamentocntcorrenteId = fechamentocntcorrenteId; this.fechamentocntcorrenteId = fechamentocntcorrenteId;
this.fecfechamento = fecfechamento; this.fecfechamento = fecfechamento;
@ -106,11 +106,11 @@ public class FechamentoCntCorrenteVO {
this.ufEmpresa = ufEmpresa; this.ufEmpresa = ufEmpresa;
} }
public EnumIntegracaoSap getIntegradoSap() { public StatusIntegracaoSap getIntegradoSap() {
return integradoSap; return integradoSap;
} }
public void setIntegradoSap(EnumIntegracaoSap integradoSap) { public void setIntegradoSap(StatusIntegracaoSap integradoSap) {
this.integradoSap = integradoSap; this.integradoSap = integradoSap;
} }