From c6480c741d3a883d18f69fd3e25da104a0ba932d Mon Sep 17 00:00:00 2001 From: frederico Date: Mon, 14 Mar 2016 19:05:07 +0000 Subject: [PATCH] =?UTF-8?q?#7212=20-=20desenvolvimento=20parcial=20Modific?= =?UTF-8?q?a=C3=A7=C3=A3o=20Massiva=20Alias,=20exporta=C3=A7=C3=A3o=20ok,?= =?UTF-8?q?=20importa=C3=A7=C3=A3o=20em=20desenvolvimento?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@53855 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../ventaboletos/dao/AliasServicoDAO.java | 11 ++++++ .../hibernate/AliasServicoHibernateDAO.java | 37 +++++++++++++++++++ .../service/AliasServicoService.java | 4 ++ .../service/impl/AliasServicoServiceImpl.java | 7 ++++ .../service/impl/CorridaServiceImpl.java | 2 +- 5 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/com/rjconsultores/ventaboletos/dao/AliasServicoDAO.java b/src/com/rjconsultores/ventaboletos/dao/AliasServicoDAO.java index 07ef56c68..d27141c92 100644 --- a/src/com/rjconsultores/ventaboletos/dao/AliasServicoDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/AliasServicoDAO.java @@ -3,6 +3,8 @@ package com.rjconsultores.ventaboletos.dao; import java.util.List; import com.rjconsultores.ventaboletos.entidad.AliasServico; +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.Ruta; public interface AliasServicoDAO extends GenericDAO{ @@ -26,4 +28,13 @@ public interface AliasServicoDAO extends GenericDAO{ */ public List buscar(Integer origenId,Integer destinoId,Integer rutaId,Integer corridaId); + + /** + * Realiza a busca com os filtro informados. + * @param linas + * @param empresas + * @return + */ + public List buscarPorLinhaEmpresa(List linhas, List empresas); + } diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/AliasServicoHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/AliasServicoHibernateDAO.java index 46a661073..576792d79 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/AliasServicoHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/AliasServicoHibernateDAO.java @@ -3,6 +3,7 @@ package com.rjconsultores.ventaboletos.dao.hibernate; import java.util.List; import org.hibernate.Criteria; +import org.hibernate.Query; import org.hibernate.SessionFactory; import org.hibernate.criterion.Restrictions; import org.springframework.beans.factory.annotation.Autowired; @@ -11,6 +12,8 @@ import org.springframework.stereotype.Repository; import com.rjconsultores.ventaboletos.dao.AliasServicoDAO; import com.rjconsultores.ventaboletos.entidad.AliasServico; +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.Ruta; @Repository("aliasServicoDAO") public class AliasServicoHibernateDAO extends GenericHibernateDAO @@ -45,4 +48,38 @@ public class AliasServicoHibernateDAO extends GenericHibernateDAO buscarPorLinhaEmpresa(List linhas, List empresas) { + + StringBuilder hql = new StringBuilder(); + hql.append("SELECT DISTINCT alias "); + hql.append("FROM AliasServico alias "); + hql.append("INNER JOIN alias.ruta.lsRutaEmpresa as re "); + hql.append(" WHERE (1 = 1) "); + + if (!linhas.isEmpty()) { + hql.append(" AND alias.ruta.rutaId IN ("); + for (Ruta r : linhas) { + hql.append(r.getRutaId() + ","); + } + hql.deleteCharAt(hql.length() - 1); + hql.append(")"); + } + + if (!empresas.isEmpty()) { + hql.append(" AND re.empresa.empresaId IN ("); + for (Empresa e : empresas) { + hql.append(e.getEmpresaId() + ","); + } + hql.deleteCharAt(hql.length() - 1); + hql.append(")"); + } + + Query query = getSession().createQuery(hql.toString()); + + return query.list(); + } + } diff --git a/src/com/rjconsultores/ventaboletos/service/AliasServicoService.java b/src/com/rjconsultores/ventaboletos/service/AliasServicoService.java index 2cefabeff..8b3c04c6b 100644 --- a/src/com/rjconsultores/ventaboletos/service/AliasServicoService.java +++ b/src/com/rjconsultores/ventaboletos/service/AliasServicoService.java @@ -3,6 +3,8 @@ package com.rjconsultores.ventaboletos.service; import java.util.List; import com.rjconsultores.ventaboletos.entidad.AliasServico; +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.Ruta; import com.rjconsultores.ventaboletos.exception.BusinessException; public interface AliasServicoService{ @@ -14,4 +16,6 @@ public interface AliasServicoService{ public AliasServico suscribirActualizar(AliasServico entidad) throws BusinessException; public void borrar(AliasServico entidad); + + public List buscarPorLinhaEmpresa(List linhas, List empresas); } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/AliasServicoServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/AliasServicoServiceImpl.java index fd397af20..fd819ebce 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/AliasServicoServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/AliasServicoServiceImpl.java @@ -12,6 +12,8 @@ import org.springframework.transaction.annotation.Transactional; import com.rjconsultores.ventaboletos.dao.AliasServicoDAO; import com.rjconsultores.ventaboletos.entidad.AliasServico; +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.Ruta; import com.rjconsultores.ventaboletos.exception.BusinessException; import com.rjconsultores.ventaboletos.service.AliasServicoService; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; @@ -78,4 +80,9 @@ public class AliasServicoServiceImpl implements AliasServicoService { aliasServicoDAO.actualizacion(entidad); } + + @Override + public List buscarPorLinhaEmpresa(List linhas, List empresas) { + return aliasServicoDAO.buscarPorLinhaEmpresa(linhas, empresas); + } } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/CorridaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/CorridaServiceImpl.java index b0a61a075..5db549d9d 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/CorridaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/CorridaServiceImpl.java @@ -728,7 +728,7 @@ public class CorridaServiceImpl implements CorridaService { tiempoOrigen += estadoOrigen.getTiempoHorVerano(); } } - + //21688 Estado estadoDestino = esquemaTramo.getTramo().getDestino().getCiudad().getEstado(); int tiempoDestino = 0;