From 64c0c7ed63b825834a1b39f806cdcdaa24387a67 Mon Sep 17 00:00:00 2001 From: edgar Date: Fri, 8 Jul 2016 21:17:22 +0000 Subject: [PATCH] fixes bug #7672 git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@57783 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../dao/hibernate/TarifaHibernateDAO.java | 102 +++++++++++------- 1 file changed, 61 insertions(+), 41 deletions(-) diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/TarifaHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/TarifaHibernateDAO.java index 4da39dbc8..ce4b92cb9 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/TarifaHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/TarifaHibernateDAO.java @@ -223,6 +223,26 @@ public class TarifaHibernateDAO extends GenericHibernateDAO imp + "INNER JOIN MARCA marca ON marca.MARCA_ID = tarifa.MARCA_ID " + "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) { sQuery.append(" AND marca.EMPRESA_ID = :EMPRESA_ID"); } @@ -250,69 +270,69 @@ public class TarifaHibernateDAO extends GenericHibernateDAO imp c.add(Restrictions.eq("vigenciaTarifa", vigenciaTarifa)); c.setProjection(Projections.rowCount()); return (HibernateFix.count(c.list()) > 0); - } - + } + @Override - public void excluirTodasTarifas(Moneda moneda, Marca marca, ClaseServicio claseServicio, VigenciaTarifa vigenciaTarifa, Parada origem, - Parada destino, Categoria categoria, TipoPuntoVenta tipoPuntoVenta, Ruta ruta, Via via){ + public void excluirTodasTarifas(Moneda moneda, Marca marca, ClaseServicio claseServicio, VigenciaTarifa vigenciaTarifa, Parada origem, + Parada destino, Categoria categoria, TipoPuntoVenta tipoPuntoVenta, Ruta ruta, Via via) { StringBuilder hql = new StringBuilder(); hql.append(" update Tarifa set activo = 0 where tarifaId in ("); - hql.append(" select t.tarifaId from Tarifa t " ); - - if(categoria == null && tipoPuntoVenta == null){ + hql.append(" select t.tarifaId from Tarifa t "); + + if (categoria == null && tipoPuntoVenta == null) { hql.append(" where 0 = 0 "); } - - if(categoria != null){ - hql.append(" inner join t.lsTarifaCategoria as tarifascategoria " ); + + if (categoria != null) { + hql.append(" inner join t.lsTarifaCategoria as tarifascategoria "); hql.append(" where 0 = 0 and tarifascategoria.categoria.categoriaId = " + categoria.getCategoriaId()); } - - if(tipoPuntoVenta != null){ - hql.append(" inner join t.lsTarifaTipoptovta as tarifastipoptovta " ); - if(categoria == null){ + + if (tipoPuntoVenta != null) { + hql.append(" inner join t.lsTarifaTipoptovta as tarifastipoptovta "); + if (categoria == null) { hql.append(" where 0 = 0 and tarifastipoptovta.tipoPuntoVenta.tipoptovtaId = " + tipoPuntoVenta.getTipoptovtaId()); - }else{ + } else { hql.append(" and tarifastipoptovta.tipoPuntoVenta.tipoptovtaId = " + tipoPuntoVenta.getTipoptovtaId()); - } - } - - if(moneda != null){ + } + } + + if (moneda != null) { hql.append(" and t.moneda.monedaId = " + moneda.getMonedaId()); } - - if(marca != null){ + + if (marca != null) { hql.append(" and t.marca.marcaId = " + marca.getMarcaId()); } - - if(claseServicio != null){ + + if (claseServicio != null) { hql.append(" and t.claseServicio.claseservicioId = " + claseServicio.getClaseservicioId()); } - - if(vigenciaTarifa != null){ + + if (vigenciaTarifa != null) { hql.append(" and t.vigenciaTarifa.vigenciatarifaId = " + vigenciaTarifa.getVigenciatarifaId()); } - - if(origem != null){ + + if (origem != null) { hql.append(" and t.origen.paradaId = " + origem.getParadaId()); } - - if(destino != null){ + + if (destino != null) { hql.append(" and t.destino.paradaId = " + destino.getParadaId()); } - - if(ruta != null){ - hql.append(" and t.ruta.rutaId = " + ruta.getRutaId()); + + if (ruta != null) { + hql.append(" and t.ruta.rutaId = " + ruta.getRutaId()); } - - if(via != null){ + + if (via != null) { hql.append(" and t.via.viaId = " + via.getViaId()); - } - - hql.append(")") ; - - Query sq = getSession().createQuery(hql.toString()); - sq.executeUpdate(); - + } + + hql.append(")"); + + Query sq = getSession().createQuery(hql.toString()); + sq.executeUpdate(); + } }