fixes bug#23499
dev: Valdevir qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@109594 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
76264dfe05
commit
1e2e496867
|
@ -12,5 +12,5 @@ public interface SapDAO extends GenericDAO<FechamentoCntcorrente, Long> {
|
|||
public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, Boolean reenviar);
|
||||
|
||||
public boolean atualizaFechamento(Long fechamentocntcorrenteId) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -16,6 +16,7 @@ import org.springframework.stereotype.Repository;
|
|||
import com.rjconsultores.ventaboletos.dao.SapDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||
import com.rjconsultores.ventaboletos.entidad.FechamentoCntcorrente;
|
||||
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||
import com.rjconsultores.ventaboletos.vo.integracao.FechamentoCntCorrenteVO;
|
||||
|
||||
@Repository("sapDAO")
|
||||
|
@ -57,21 +58,27 @@ public class SapHibernateDAO extends GenericHibernateDAO<FechamentoCntcorrente,
|
|||
sb.append(" WHERE ");
|
||||
sb.append(" fc.activo = 1 ");
|
||||
sb.append(" AND fc.fecfechamento BETWEEN :dataDe AND :dataAte ");
|
||||
sb.append(" AND fc.EMPRESA_ID = :empresaId ");
|
||||
|
||||
if(!reenviar){
|
||||
sb.append(" AND ( fc.indintegradosap IS NULL OR fc.indintegradosap = 0) ");
|
||||
if( empresa != null ) {
|
||||
sb.append(" AND fc.EMPRESA_ID = :empresaId ");
|
||||
}
|
||||
|
||||
if(!reenviar){
|
||||
sb.append(" AND ( fc.indintegradosap IS NULL OR fc.indintegradosap <> 1) ");
|
||||
}
|
||||
|
||||
sb.append(" ORDER BY ");
|
||||
sb.append(" pv.nombpuntoventa, fc.fecfechamento ");
|
||||
|
||||
Query query = getSession().createSQLQuery(sb.toString());
|
||||
query.setInteger("empresaId", empresa.getEmpresaId());
|
||||
|
||||
if(dataDe != null && dataAte != null){
|
||||
query.setDate("dataDe", dataDe);
|
||||
query.setDate("dataAte", dataAte);
|
||||
if( empresa != null ) {
|
||||
query.setInteger("empresaId", empresa.getEmpresaId());
|
||||
}
|
||||
|
||||
if(dataDe != null && dataAte != null){
|
||||
query.setDate("dataDe", DateUtil.normalizarToFecha(dataDe));
|
||||
query.setDate("dataAte", DateUtil.normalizarToFecha(dataAte));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -104,6 +111,11 @@ public class SapHibernateDAO extends GenericHibernateDAO<FechamentoCntcorrente,
|
|||
fcc.setMesfechamento(tupla[11].toString());
|
||||
fcc.setFeclancamento(tupla[12].toString());
|
||||
|
||||
//empresa enviada nula apenas no processo automatico
|
||||
if(empresa == null) {
|
||||
fcc.setEnviar(true);
|
||||
}
|
||||
|
||||
retorno.add(fcc);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@ import java.util.Date;
|
|||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
@ -15,11 +17,11 @@ import javax.persistence.Table;
|
|||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import com.rjconsultores.ventaboletos.enums.StatusIntegracaoSap;
|
||||
|
||||
@Entity
|
||||
@Table(name = "FECHAMENTO_CNTCORRENTE")
|
||||
public class FechamentoCntcorrente {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@SequenceGenerator(name = "FECHAMENTO_CNTCORRENTE_SEQ", sequenceName = "FECHAMENTO_CNTCORRENTE_SEQ", allocationSize = 1)
|
||||
@Id
|
||||
|
@ -67,7 +69,8 @@ public class FechamentoCntcorrente {
|
|||
private Boolean indemailenviado;
|
||||
|
||||
@Column(name = "INDINTEGRADOSAP")
|
||||
private Boolean integradoSap;
|
||||
@Enumerated(EnumType.ORDINAL)
|
||||
private StatusIntegracaoSap integradoSap;
|
||||
|
||||
public Long getFechamentocntcorrenteId() {
|
||||
return fechamentocntcorrenteId;
|
||||
|
@ -165,11 +168,11 @@ public class FechamentoCntcorrente {
|
|||
this.indemailenviado = indemailenviado;
|
||||
}
|
||||
|
||||
public Boolean getIntegradoSap() {
|
||||
public StatusIntegracaoSap getIntegradoSap() {
|
||||
return integradoSap;
|
||||
}
|
||||
|
||||
public void setIntegradoSap(Boolean integradoSap) {
|
||||
public void setIntegradoSap(StatusIntegracaoSap integradoSap) {
|
||||
this.integradoSap = integradoSap;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package com.rjconsultores.ventaboletos.enums;
|
||||
|
||||
public enum StatusIntegracaoSap {
|
||||
INTEGRADO,
|
||||
NAO_INTEGRADO,
|
||||
PENDENTE;
|
||||
}
|
|
@ -30,7 +30,7 @@ public class IntegracaoSapRest {
|
|||
}
|
||||
|
||||
public JSONObject enviarIntegracaoSap( FechamentoCntCorrenteVO fechamento, String url, String credenciais ) {
|
||||
try {
|
||||
try {
|
||||
HttpClient client = new DefaultHttpClient();
|
||||
HttpUriRequest request = getRequest( url, TipoEnvioRest.POST, credenciais, fechamtoToJson(fechamento));
|
||||
HttpResponse response = client.execute(request);
|
||||
|
|
|
@ -12,5 +12,7 @@ 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 void integracaoSapAutomatica() throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -108,4 +108,13 @@ public class SapServiceImpl implements SapService{
|
|||
return constante.getValorconstante();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void integracaoSapAutomatica() throws Exception {
|
||||
List<FechamentoCntCorrenteVO> listaPendente = obtenerTodosParaRemessa(null, new Date(), new Date(), false);
|
||||
|
||||
if(!listaPendente.isEmpty()) {
|
||||
remessa(listaPendente);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue