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-87c2c4800839master
parent
74d3b24464
commit
ff5d4f4cb6
|
@ -10,9 +10,9 @@ import com.rjconsultores.ventaboletos.vo.integracao.FechamentoCntCorrenteVO;
|
|||
|
||||
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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,35 @@
|
|||
package com.rjconsultores.ventaboletos.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public enum StatusIntegracaoSap {
|
||||
INTEGRADO,
|
||||
NAO_INTEGRADO,
|
||||
PENDENTE;
|
||||
INTEGRADO("Integrado"),
|
||||
NAO_ENVIADO("Nao Enviado"),
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@ public interface SapService extends GenericService<FechamentoCntcorrente, Long>
|
|||
|
||||
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;
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.rjconsultores.ventaboletos.entidad.Constante;
|
|||
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.rest.IntegracaoSapRest;
|
||||
import com.rjconsultores.ventaboletos.service.SapService;
|
||||
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_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);
|
||||
|
||||
@Autowired
|
||||
|
@ -65,13 +64,13 @@ public class SapServiceImpl implements SapService{
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, Boolean reenviar) {
|
||||
return sapDAO.obtenerTodosParaRemessa(empresa, dataDe, dataAte, reenviar, null);
|
||||
public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, String status) {
|
||||
return sapDAO.obtenerTodosParaRemessa(empresa, dataDe, dataAte, status, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, Boolean reenviar, PuntoVenta puntoVenta) {
|
||||
return sapDAO.obtenerTodosParaRemessa(empresa, dataDe, dataAte, reenviar, puntoVenta);
|
||||
public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, String status, PuntoVenta puntoVenta) {
|
||||
return sapDAO.obtenerTodosParaRemessa(empresa, dataDe, dataAte, status, puntoVenta);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -87,14 +86,14 @@ public class SapServiceImpl implements SapService{
|
|||
JSONObject integrado = integracaoSapRest.enviarIntegracaoSap(fechamentoCntcorrente, url, credenciais);
|
||||
|
||||
if(integrado == null) {
|
||||
atualizaFechamento(fechamentoCntcorrente.getFechamentocntcorrenteId(), INTEGRACAO_SAP_ERRO);
|
||||
log.error("Erro no envio/retorno da requisicao para integra<EFBFBD><EFBFBD>o SAP do fechamentoID: "+fechamentoCntcorrente.getFechamentocntcorrenteId());
|
||||
throw new RuntimeException("Erro no envio/retorno da requisicao para integração SAP do fechamentoID: "+fechamentoCntcorrente.getFechamentocntcorrenteId());
|
||||
atualizaFechamento(fechamentoCntcorrente.getFechamentocntcorrenteId(), StatusIntegracaoSap.NAO_ENVIADO.ordinal());
|
||||
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 integracao SAP do fechamentoID: "+fechamentoCntcorrente.getFechamentocntcorrenteId());
|
||||
}else if(integrado.getString("Integration").equals("S")) {
|
||||
atualizaFechamento(fechamentoCntcorrente.getFechamentocntcorrenteId(), INTEGRACAO_SAP_OK);
|
||||
atualizaFechamento(fechamentoCntcorrente.getFechamentocntcorrenteId(), StatusIntegracaoSap.INTEGRADO.ordinal());
|
||||
contador++;
|
||||
}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"));
|
||||
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
|
||||
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()) {
|
||||
log.info("IntegracaoSap: Registro a enviar:"+listaPendente.size());
|
||||
|
@ -136,7 +135,7 @@ public class SapServiceImpl implements SapService{
|
|||
throw e;
|
||||
}
|
||||
|
||||
listaPendente = obtenerTodosParaRemessa(null, DateUtil.getYesterdayDate(), new Date(), false);
|
||||
listaPendente = obtenerTodosParaRemessa(null, DateUtil.getYesterdayDate(), new Date(), "2");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.rjconsultores.ventaboletos.vo.integracao;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.rjconsultores.ventaboletos.enums.EnumIntegracaoSap;
|
||||
import com.rjconsultores.ventaboletos.enums.StatusIntegracaoSap;
|
||||
|
||||
public class FechamentoCntCorrenteVO {
|
||||
|
||||
|
@ -23,10 +23,10 @@ public class FechamentoCntCorrenteVO {
|
|||
private Integer empresaId;
|
||||
private String nombEmpresa;
|
||||
private String ufEmpresa;
|
||||
private EnumIntegracaoSap integradoSap;
|
||||
private StatusIntegracaoSap integradoSap;
|
||||
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();
|
||||
this.fechamentocntcorrenteId = fechamentocntcorrenteId;
|
||||
this.fecfechamento = fecfechamento;
|
||||
|
@ -106,11 +106,11 @@ public class FechamentoCntCorrenteVO {
|
|||
this.ufEmpresa = ufEmpresa;
|
||||
}
|
||||
|
||||
public EnumIntegracaoSap getIntegradoSap() {
|
||||
public StatusIntegracaoSap getIntegradoSap() {
|
||||
return integradoSap;
|
||||
}
|
||||
|
||||
public void setIntegradoSap(EnumIntegracaoSap integradoSap) {
|
||||
public void setIntegradoSap(StatusIntegracaoSap integradoSap) {
|
||||
this.integradoSap = integradoSap;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue