git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@30814 d1611594-4594-4d17-8e1d-87c2c4800839
parent
98f4a6c457
commit
19dede32d0
|
@ -69,4 +69,6 @@ public interface CorridaDAO extends GenericDAO<Corrida, Corrida.Id> {
|
||||||
public Long cantCorridaGeneradasHoy();
|
public Long cantCorridaGeneradasHoy();
|
||||||
|
|
||||||
public List<Corrida> buscarGroupCorrridaId(Integer corridaId, Date dateInicio, Date dateFin);
|
public List<Corrida> buscarGroupCorrridaId(Integer corridaId, Date dateInicio, Date dateFin);
|
||||||
|
|
||||||
|
public List<Corrida> buscarGroupCorrridaId(Integer corridaId, Integer origem, Integer destino, Integer ruta, Integer numRuta, Date dateInicio, Date dateFin);
|
||||||
}
|
}
|
|
@ -326,6 +326,70 @@ public class CorridaHibernateDAO extends GenericHibernateDAO<Corrida, Corrida.Id
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Corrida> buscarGroupCorrridaId(Integer corridaId, Integer origem, Integer destino, Integer ruta, Integer numRuta, Date dateInicio, Date dateFin) {
|
||||||
|
StringBuffer sql = new StringBuffer();
|
||||||
|
sql.append(" SELECT c.corrida_id ");
|
||||||
|
sql.append(" FROM corrida c ");
|
||||||
|
if (numRuta != null) {
|
||||||
|
sql.append(" INNER JOIN Ruta r ON r.ruta_id=c.ruta_id ");
|
||||||
|
}
|
||||||
|
sql.append(" WHERE c.feccorrida BETWEEN :dateInicio AND :dateFin ");
|
||||||
|
sql.append(" AND c.corrida_id LIKE :corridaId ");
|
||||||
|
|
||||||
|
if (origem != null) {
|
||||||
|
sql.append(" AND c.ORIGEN_ID=").append(origem);
|
||||||
|
}
|
||||||
|
if (destino != null) {
|
||||||
|
sql.append(" AND c.DESTINO_ID=").append(destino);
|
||||||
|
}
|
||||||
|
if (ruta != null) {
|
||||||
|
sql.append(" AND c.RUTA_ID=").append(ruta);
|
||||||
|
}
|
||||||
|
if (numRuta != null) {
|
||||||
|
sql.append(" AND r.NUMRUTA=").append(numRuta);
|
||||||
|
}
|
||||||
|
|
||||||
|
sql.append(" GROUP BY c.corrida_id ");
|
||||||
|
|
||||||
|
Query sq = getSession().createSQLQuery(sql.toString());
|
||||||
|
|
||||||
|
if (corridaId != null) {
|
||||||
|
sq.setParameter("corridaId", corridaId.toString() + '%');
|
||||||
|
} else {
|
||||||
|
sq.setParameter("corridaId", '%');
|
||||||
|
}
|
||||||
|
|
||||||
|
sq.setParameter("dateInicio", dateInicio);
|
||||||
|
sq.setParameter("dateFin", dateFin);
|
||||||
|
|
||||||
|
List<Object> lsObject = sq.list();
|
||||||
|
|
||||||
|
List<Corrida> lsCorridas = new ArrayList<Corrida>();
|
||||||
|
|
||||||
|
if (lsObject != null && !lsObject.isEmpty()) {
|
||||||
|
|
||||||
|
for (Object object : lsObject) {
|
||||||
|
|
||||||
|
BigDecimal id = (BigDecimal) object;
|
||||||
|
|
||||||
|
StringBuffer hql = new StringBuffer();
|
||||||
|
hql.append(" FROM Corrida ");
|
||||||
|
hql.append(" WHERE id.corridaId = " + id);
|
||||||
|
|
||||||
|
Query squery = getSession().createQuery(hql.toString());
|
||||||
|
squery.setMaxResults(maxResult);
|
||||||
|
|
||||||
|
List<Corrida> lsCorridasAux = squery.list();
|
||||||
|
|
||||||
|
if (lsCorridasAux != null && !lsCorridasAux.isEmpty()) {
|
||||||
|
lsCorridas.add(lsCorridasAux.iterator().next());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return lsCorridas;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Corrida> buscarGroupCorrridaId(Integer corridaId, Date dateInicio, Date dateFin) {
|
public List<Corrida> buscarGroupCorrridaId(Integer corridaId, Date dateInicio, Date dateFin) {
|
||||||
|
|
||||||
StringBuffer sql = new StringBuffer();
|
StringBuffer sql = new StringBuffer();
|
||||||
|
|
|
@ -58,4 +58,6 @@ public interface CorridaService extends GenericService<Corrida, Corrida.Id> {
|
||||||
public Long generarCorridasSelecionadas(List<EsquemaCorrida> lsEsquemaCorrida, Date dataDe, Date dataAte);
|
public Long generarCorridasSelecionadas(List<EsquemaCorrida> lsEsquemaCorrida, Date dataDe, Date dataAte);
|
||||||
|
|
||||||
public List<Corrida> buscarGroupCorrridaId(Integer corridaId, Date dateInicio, Date dateFin);
|
public List<Corrida> buscarGroupCorrridaId(Integer corridaId, Date dateInicio, Date dateFin);
|
||||||
|
|
||||||
|
public List<Corrida> buscarGroupCorrridaId(Integer corridaId, Integer origem, Integer destino, Integer ruta, Integer numRuta, Date dateInicio, Date dateFin);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1002,4 +1002,23 @@ public class CorridaServiceImpl implements CorridaService {
|
||||||
|
|
||||||
return corridaDAO.buscarGroupCorrridaId(corridaId, gCalendarDe.getTime(), gCalendarAte.getTime());
|
return corridaDAO.buscarGroupCorrridaId(corridaId, gCalendarDe.getTime(), gCalendarAte.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Corrida> buscarGroupCorrridaId(Integer corridaId, Integer origem, Integer destino, Integer ruta, Integer numRuta, Date dateInicio, Date dateFin) {
|
||||||
|
GregorianCalendar gCalendarDe = new GregorianCalendar();
|
||||||
|
gCalendarDe.setTime(dateInicio);
|
||||||
|
gCalendarDe.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
gCalendarDe.set(Calendar.MINUTE, 0);
|
||||||
|
gCalendarDe.set(Calendar.SECOND, 0);
|
||||||
|
gCalendarDe.set(Calendar.MILLISECOND, 0);
|
||||||
|
|
||||||
|
GregorianCalendar gCalendarAte = new GregorianCalendar();
|
||||||
|
gCalendarAte.setTime(dateFin);
|
||||||
|
gCalendarAte.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
gCalendarAte.set(Calendar.MINUTE, 0);
|
||||||
|
gCalendarAte.set(Calendar.SECOND, 0);
|
||||||
|
gCalendarAte.set(Calendar.MILLISECOND, 0);
|
||||||
|
|
||||||
|
return corridaDAO.buscarGroupCorrridaId(corridaId, origem, destino, ruta, numRuta, gCalendarDe.getTime(), gCalendarAte.getTime());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue