fixes bug#0012396
dev: wallace qua: renato git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@86252 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
42d358c3cd
commit
d2c8bb007a
|
@ -4,14 +4,15 @@
|
|||
*/
|
||||
package com.rjconsultores.ventaboletos.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
|
||||
import com.rjconsultores.ventaboletos.entidad.Parada;
|
||||
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||
import com.rjconsultores.ventaboletos.entidad.Tramo;
|
||||
|
||||
import java.util.List;
|
||||
import com.rjconsultores.ventaboletos.vo.ruta.RutaVO;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -52,6 +53,8 @@ public interface RutaDAO extends GenericDAO<Ruta, Integer> {
|
|||
*/
|
||||
public Parada buscarDestino(Ruta ruta);
|
||||
|
||||
public List<RutaVO> buscaRutaPorNumeroSemDadoRepetido(String palavraPesquisaRuta);
|
||||
|
||||
public List<Ruta> buscaRuta(String palavraPesquisaRuta);
|
||||
|
||||
public List<Ruta> buscaRuta(String palavraPesquisaRuta, OrgaoConcedente orgao);
|
||||
|
|
|
@ -9,10 +9,14 @@ import java.util.List;
|
|||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.SQLQuery;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.criterion.Order;
|
||||
import org.hibernate.criterion.Projections;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.hibernate.transform.AliasToBeanResultTransformer;
|
||||
import org.hibernate.type.LongType;
|
||||
import org.hibernate.type.StringType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
@ -25,6 +29,7 @@ import com.rjconsultores.ventaboletos.entidad.Parada;
|
|||
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||
import com.rjconsultores.ventaboletos.entidad.RutaSecuencia;
|
||||
import com.rjconsultores.ventaboletos.entidad.Tramo;
|
||||
import com.rjconsultores.ventaboletos.vo.ruta.RutaVO;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -191,12 +196,12 @@ public class RutaHibernateDAO extends GenericHibernateDAO<Ruta, Integer> impleme
|
|||
@Override
|
||||
public List<Ruta> buscaRuta(String palavraPesquisaRuta, OrgaoConcedente orgao) {
|
||||
StringBuilder hql = new StringBuilder();
|
||||
hql.append(" FROM Ruta ");
|
||||
hql.append(" FROM Ruta r");
|
||||
hql.append(" WHERE (lower(descruta) like :palavraPesquisaRuta ");
|
||||
hql.append(" OR prefixo like :palavraPesquisaRuta ");
|
||||
hql.append(" OR str(numRuta) like :palavraPesquisaRuta) ");
|
||||
hql.append(" OR lower(prefixo) like :palavraPesquisaRuta ");
|
||||
hql.append(" OR lower(str(numRuta)) like :palavraPesquisaRuta) ");
|
||||
if (orgao != null) {
|
||||
hql.append(" AND orgaoConcedente.orgaoConcedenteId = :orgaoId ");
|
||||
hql.append(" AND orgao.orgaoConcedenteId = :orgaoId ");
|
||||
}
|
||||
|
||||
Query sq = getSession().createQuery(hql.toString());
|
||||
|
@ -208,6 +213,32 @@ public class RutaHibernateDAO extends GenericHibernateDAO<Ruta, Integer> impleme
|
|||
return sq.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RutaVO> buscaRutaPorNumeroSemDadoRepetido(String palavraPesquisaRuta) {
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append(" SELECT MAX(R.RUTA_ID) rutaId, ");
|
||||
sql.append(" R.NUMRUTA numRuta, MAX(R.PREFIXO) prefixo, ");
|
||||
sql.append(" MAX(R.DESCRUTA) descruta, ");
|
||||
sql.append(" MAX(ORGAO.DESCORGAO) orgaoConcedente ");
|
||||
sql.append(" FROM RUTA R ");
|
||||
sql.append(" INNER JOIN ORGAO_CONCEDENTE ORGAO ON R.ORGAOCONCEDENTE_ID = ORGAO.ORGAOCONCEDENTE_ID ");
|
||||
sql.append(" WHERE (LOWER(R.DESCRUTA) LIKE :palavraPesquisaRuta ");
|
||||
sql.append(" OR LOWER(R.PREFIXO) LIKE :palavraPesquisaRuta ");
|
||||
sql.append(" OR LOWER(R.NUMRUTA) LIKE :palavraPesquisaRuta) ");
|
||||
sql.append(" GROUP BY R.NUMRUTA ");
|
||||
|
||||
SQLQuery qry = getSession().createSQLQuery(sql.toString())
|
||||
.addScalar("rutaId", LongType.INSTANCE)
|
||||
.addScalar("numRuta", StringType.INSTANCE)
|
||||
.addScalar("prefixo", StringType.INSTANCE)
|
||||
.addScalar("descruta", StringType.INSTANCE)
|
||||
.addScalar("orgaoConcedente", StringType.INSTANCE);
|
||||
qry.setParameter("palavraPesquisaRuta", palavraPesquisaRuta.toLowerCase() + '%');
|
||||
|
||||
qry.setResultTransformer(new AliasToBeanResultTransformer(RutaVO.class));
|
||||
return qry.list();
|
||||
}
|
||||
|
||||
public List<Ruta> buscaRutasFromOrgao(OrgaoConcedente orgao) {
|
||||
StringBuffer hql = new StringBuffer();
|
||||
hql.append("select distinct r FROM Ruta r inner join r.rutaSecuenciaList rSeqList ");
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
*/
|
||||
package com.rjconsultores.ventaboletos.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
|
||||
|
@ -13,8 +15,7 @@ import com.rjconsultores.ventaboletos.entidad.ParadaSecuenciaCombinacaoLinha;
|
|||
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||
import com.rjconsultores.ventaboletos.utilerias.RegistroConDependenciaException;
|
||||
|
||||
import java.util.List;
|
||||
import com.rjconsultores.ventaboletos.vo.ruta.RutaVO;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -83,6 +84,8 @@ public interface RutaService {
|
|||
|
||||
public void generarCombinacion(Ruta ruta) throws BusinessException;
|
||||
|
||||
public List<RutaVO> buscaRutaPorNumeroSemDadoRepetido(String palavraPesquisaRuta);
|
||||
|
||||
public List<Ruta> buscaRuta(String palavraPesquisaRuta);
|
||||
|
||||
public List<Ruta> buscaRuta(String palavraPesquisaRuta, OrgaoConcedente orgao);
|
||||
|
|
|
@ -39,6 +39,7 @@ import com.rjconsultores.ventaboletos.service.RutaService;
|
|||
import com.rjconsultores.ventaboletos.service.TramoService;
|
||||
import com.rjconsultores.ventaboletos.utilerias.RegistroConDependenciaException;
|
||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||
import com.rjconsultores.ventaboletos.vo.ruta.RutaVO;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -496,6 +497,11 @@ public class RutaServiceImpl implements RutaService {
|
|||
return existe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RutaVO> buscaRutaPorNumeroSemDadoRepetido(String palavraPesquisaRuta) {
|
||||
return rutaDAO.buscaRutaPorNumeroSemDadoRepetido(palavraPesquisaRuta);
|
||||
}
|
||||
|
||||
public List<Ruta> buscaRuta(String palavraPesquisaRuta) {
|
||||
return rutaDAO.buscaRuta(palavraPesquisaRuta);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package com.rjconsultores.ventaboletos.vo.ruta;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement
|
||||
public class RutaVO {
|
||||
|
||||
private Long rutaId;
|
||||
private String numRuta;
|
||||
private String prefixo;
|
||||
private String descruta;
|
||||
private String orgaoConcedente;
|
||||
|
||||
public RutaVO() {
|
||||
}
|
||||
|
||||
public RutaVO(Long rutaId, String numRuta, String prefixo, String descruta, String orgaoConcedente) {
|
||||
super();
|
||||
this.rutaId = rutaId;
|
||||
this.numRuta = numRuta;
|
||||
this.prefixo = prefixo;
|
||||
this.descruta = descruta;
|
||||
this.orgaoConcedente = orgaoConcedente;
|
||||
}
|
||||
|
||||
public Long getRutaId() {
|
||||
return rutaId;
|
||||
}
|
||||
|
||||
public void setRutaId(Long rutaId) {
|
||||
this.rutaId = rutaId;
|
||||
}
|
||||
|
||||
public String getNumRuta() {
|
||||
return numRuta;
|
||||
}
|
||||
|
||||
public void setNumRuta(String numRuta) {
|
||||
this.numRuta = numRuta;
|
||||
}
|
||||
|
||||
public String getPrefixo() {
|
||||
return prefixo;
|
||||
}
|
||||
|
||||
public void setPrefixo(String prefixo) {
|
||||
this.prefixo = prefixo;
|
||||
}
|
||||
|
||||
public String getDescruta() {
|
||||
return descruta;
|
||||
}
|
||||
|
||||
public void setDescruta(String descruta) {
|
||||
this.descruta = descruta;
|
||||
}
|
||||
|
||||
public String getOrgaoConcedente() {
|
||||
return orgaoConcedente;
|
||||
}
|
||||
|
||||
public void setOrgaoConcedente(String orgaoConcedente) {
|
||||
this.orgaoConcedente = orgaoConcedente;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue