bug#AL-1726
Modificações dos metodos de integraçao para melhoria junto ao banco de dadosmaster
parent
9ec6f09ad5
commit
0532d002d4
19
pom.xml
19
pom.xml
|
@ -3,7 +3,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>br.com.rjconsultores</groupId>
|
||||
<artifactId>ModelWeb</artifactId>
|
||||
<version>1.0.9</version>
|
||||
<version>1.0.10</version>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
|
@ -133,7 +133,22 @@
|
|||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-jaxrs</artifactId>
|
||||
<version>3.15.3.Final</version>
|
||||
<version>3.14.0.Final</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpcore</artifactId>
|
||||
<version>4.4.14</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.13</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
|
|
@ -3,9 +3,12 @@ package com.rjconsultores.ventaboletos.dao.hibernate;
|
|||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.GenericDAO;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Session;
|
||||
|
@ -21,8 +24,6 @@ import org.hibernate.loader.criteria.CriteriaLoader;
|
|||
import org.hibernate.persister.entity.OuterJoinLoadable;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.GenericDAO;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author gleimar
|
||||
|
@ -158,4 +159,13 @@ public class GenericHibernateDAO<T, ID extends Serializable> extends HibernateDa
|
|||
return info;
|
||||
}
|
||||
|
||||
public static <T> List<T> castList(Class<? extends T> clazz, Collection<?> rawCollection)
|
||||
throws ClassCastException {
|
||||
List<T> result = new ArrayList<T>(rawCollection.size());
|
||||
for (Object o : rawCollection) {
|
||||
result.add(clazz.cast(o));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,15 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.SapDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||
import com.rjconsultores.ventaboletos.entidad.FechamentoCntcorrente;
|
||||
|
@ -15,12 +24,6 @@ import com.rjconsultores.ventaboletos.enums.StatusIntegracaoSap;
|
|||
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||
import com.rjconsultores.ventaboletos.vo.integracao.FechamentoCntCorrenteVO;
|
||||
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository("sapDAO")
|
||||
public class SapHibernateDAO extends GenericHibernateDAO<FechamentoCntcorrente, Long> implements SapDAO {
|
||||
|
||||
|
@ -29,13 +32,18 @@ public class SapHibernateDAO extends GenericHibernateDAO<FechamentoCntcorrente,
|
|||
setSessionFactory(factory);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@Qualifier("dataSourceWrite")
|
||||
DataSource scoDs;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, String status) {
|
||||
return obtenerTodosParaRemessa(empresa, dataDe, dataAte, status, null);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@Transactional
|
||||
public List<FechamentoCntCorrenteVO> obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, String status, PuntoVenta puntoVenta) {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
@ -142,6 +150,7 @@ public class SapHibernateDAO extends GenericHibernateDAO<FechamentoCntcorrente,
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean atualizaFechamento(Long fechamentocntcorrenteId, int status) throws Exception {
|
||||
|
||||
if(fechamentocntcorrenteId == null ) {
|
||||
|
@ -149,17 +158,13 @@ public class SapHibernateDAO extends GenericHibernateDAO<FechamentoCntcorrente,
|
|||
}
|
||||
|
||||
//é feito update manualmente porque o hibernate utiliza sco_read e nao tem permissao de escrita no banco
|
||||
@SuppressWarnings("deprecation")
|
||||
Connection con = getSession().connection();
|
||||
Statement stmt = con.createStatement();
|
||||
con.setAutoCommit(false);
|
||||
|
||||
stmt.addBatch("UPDATE FECHAMENTO_CNTCORRENTE SET INDINTEGRADOSAP = "+ status
|
||||
try(Connection con = scoDs.getConnection();
|
||||
Statement stmt = con.createStatement()){
|
||||
stmt.addBatch("UPDATE FECHAMENTO_CNTCORRENTE SET INDINTEGRADOSAP = "+ status
|
||||
+" WHERE FECHAMENTOCNTCORRENTE_ID = " + fechamentocntcorrenteId);
|
||||
|
||||
stmt.executeBatch();
|
||||
con.commit();
|
||||
stmt.close();
|
||||
stmt.executeBatch();
|
||||
}
|
||||
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.apache.http.client.HttpClient;
|
|||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.codehaus.jettison.json.JSONObject;
|
||||
|
@ -31,7 +31,7 @@ public class IntegracaoSapRest {
|
|||
|
||||
public JSONObject enviarIntegracaoSap( FechamentoCntCorrenteVO fechamento, String url, String credenciais ) {
|
||||
try {
|
||||
HttpClient client = new DefaultHttpClient();
|
||||
HttpClient client = HttpClientBuilder.create().build();
|
||||
HttpUriRequest request = getRequest( url, TipoEnvioRest.POST, credenciais, fechamtoToJson(fechamento));
|
||||
HttpResponse response = client.execute(request);
|
||||
|
||||
|
|
|
@ -83,6 +83,7 @@ public class SapServiceImpl implements SapService{
|
|||
|
||||
for (FechamentoCntCorrenteVO fechamentoCntcorrente : fechamentos) {
|
||||
if( fechamentoCntcorrente.isEnviar()) {
|
||||
log.debug("Enviando fechamento:"+ fechamentoCntcorrente.getFechamentocntcorrenteId());
|
||||
JSONObject integrado = integracaoSapRest.enviarIntegracaoSap(fechamentoCntcorrente, url, credenciais);
|
||||
|
||||
if(integrado == null) {
|
||||
|
|
Loading…
Reference in New Issue