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;