edgar 2016-07-08 21:17:22 +00:00
parent b9c722d7b6
commit 64c0c7ed63
1 changed files with 61 additions and 41 deletions

View File

@ -223,6 +223,26 @@ public class TarifaHibernateDAO extends GenericHibernateDAO<Tarifa, Integer> imp
+ "INNER JOIN MARCA marca ON marca.MARCA_ID = tarifa.MARCA_ID " + "INNER JOIN MARCA marca ON marca.MARCA_ID = tarifa.MARCA_ID "
+ "WHERE tarifa.ACTIVO = 1 AND VIGENCIATARIFA_ID = :VIGENCIATARIFAIDORIGEM"); + "WHERE tarifa.ACTIVO = 1 AND VIGENCIATARIFA_ID = :VIGENCIATARIFAIDORIGEM");
if (!excluirTarifasDestino) {
sQuery.append(" AND NOT EXISTS(SELECT"
+ " tDestino.TRAMO_ID,"
+ " tDestino.MARCA_ID,"
+ " tDestino.CLASESERVICIO_ID,"
+ " tDestino.MONEDA_ID,"
+ " tDestino.ORGAOCONCEDENTE_ID,"
+ " tDestino.RUTA_ID"
+ " FROM TARIFA tDestino"
+ " WHERE"
+ " tDestino.TRAMO_ID = tarifa.TRAMO_ID"
+ " AND tDestino.MARCA_ID = tarifa.MARCA_ID"
+ " AND tDestino.CLASESERVICIO_ID = tarifa.CLASESERVICIO_ID"
+ " AND tDestino.MONEDA_ID = tarifa.MONEDA_ID"
+ " AND tDestino.ORGAOCONCEDENTE_ID = tarifa.ORGAOCONCEDENTE_ID"
+ " AND tDestino.RUTA_ID = tarifa.RUTA_ID"
+ " AND tdestino.ACTIVO = 1"
+ " AND VIGENCIATARIFA_ID = :VIGENCIATARIFAIDDESTINO)");
}
if (empresa != null) { if (empresa != null) {
sQuery.append(" AND marca.EMPRESA_ID = :EMPRESA_ID"); sQuery.append(" AND marca.EMPRESA_ID = :EMPRESA_ID");
} }
@ -254,62 +274,62 @@ public class TarifaHibernateDAO extends GenericHibernateDAO<Tarifa, Integer> imp
@Override @Override
public void excluirTodasTarifas(Moneda moneda, Marca marca, ClaseServicio claseServicio, VigenciaTarifa vigenciaTarifa, Parada origem, public void excluirTodasTarifas(Moneda moneda, Marca marca, ClaseServicio claseServicio, VigenciaTarifa vigenciaTarifa, Parada origem,
Parada destino, Categoria categoria, TipoPuntoVenta tipoPuntoVenta, Ruta ruta, Via via){ Parada destino, Categoria categoria, TipoPuntoVenta tipoPuntoVenta, Ruta ruta, Via via) {
StringBuilder hql = new StringBuilder(); StringBuilder hql = new StringBuilder();
hql.append(" update Tarifa set activo = 0 where tarifaId in ("); hql.append(" update Tarifa set activo = 0 where tarifaId in (");
hql.append(" select t.tarifaId from Tarifa t " ); hql.append(" select t.tarifaId from Tarifa t ");
if(categoria == null && tipoPuntoVenta == null){ if (categoria == null && tipoPuntoVenta == null) {
hql.append(" where 0 = 0 "); hql.append(" where 0 = 0 ");
} }
if(categoria != null){ if (categoria != null) {
hql.append(" inner join t.lsTarifaCategoria as tarifascategoria " ); hql.append(" inner join t.lsTarifaCategoria as tarifascategoria ");
hql.append(" where 0 = 0 and tarifascategoria.categoria.categoriaId = " + categoria.getCategoriaId()); hql.append(" where 0 = 0 and tarifascategoria.categoria.categoriaId = " + categoria.getCategoriaId());
} }
if(tipoPuntoVenta != null){ if (tipoPuntoVenta != null) {
hql.append(" inner join t.lsTarifaTipoptovta as tarifastipoptovta " ); hql.append(" inner join t.lsTarifaTipoptovta as tarifastipoptovta ");
if(categoria == null){ if (categoria == null) {
hql.append(" where 0 = 0 and tarifastipoptovta.tipoPuntoVenta.tipoptovtaId = " + tipoPuntoVenta.getTipoptovtaId()); hql.append(" where 0 = 0 and tarifastipoptovta.tipoPuntoVenta.tipoptovtaId = " + tipoPuntoVenta.getTipoptovtaId());
}else{ } else {
hql.append(" and tarifastipoptovta.tipoPuntoVenta.tipoptovtaId = " + tipoPuntoVenta.getTipoptovtaId()); hql.append(" and tarifastipoptovta.tipoPuntoVenta.tipoptovtaId = " + tipoPuntoVenta.getTipoptovtaId());
} }
} }
if(moneda != null){ if (moneda != null) {
hql.append(" and t.moneda.monedaId = " + moneda.getMonedaId()); hql.append(" and t.moneda.monedaId = " + moneda.getMonedaId());
} }
if(marca != null){ if (marca != null) {
hql.append(" and t.marca.marcaId = " + marca.getMarcaId()); hql.append(" and t.marca.marcaId = " + marca.getMarcaId());
} }
if(claseServicio != null){ if (claseServicio != null) {
hql.append(" and t.claseServicio.claseservicioId = " + claseServicio.getClaseservicioId()); hql.append(" and t.claseServicio.claseservicioId = " + claseServicio.getClaseservicioId());
} }
if(vigenciaTarifa != null){ if (vigenciaTarifa != null) {
hql.append(" and t.vigenciaTarifa.vigenciatarifaId = " + vigenciaTarifa.getVigenciatarifaId()); hql.append(" and t.vigenciaTarifa.vigenciatarifaId = " + vigenciaTarifa.getVigenciatarifaId());
} }
if(origem != null){ if (origem != null) {
hql.append(" and t.origen.paradaId = " + origem.getParadaId()); hql.append(" and t.origen.paradaId = " + origem.getParadaId());
} }
if(destino != null){ if (destino != null) {
hql.append(" and t.destino.paradaId = " + destino.getParadaId()); hql.append(" and t.destino.paradaId = " + destino.getParadaId());
} }
if(ruta != null){ if (ruta != null) {
hql.append(" and t.ruta.rutaId = " + ruta.getRutaId()); hql.append(" and t.ruta.rutaId = " + ruta.getRutaId());
} }
if(via != null){ if (via != null) {
hql.append(" and t.via.viaId = " + via.getViaId()); hql.append(" and t.via.viaId = " + via.getViaId());
} }
hql.append(")") ; hql.append(")");
Query sq = getSession().createQuery(hql.toString()); Query sq = getSession().createQuery(hql.toString());
sq.executeUpdate(); sq.executeUpdate();