From 150628a5fbf38f8a4af23b7682bcecfed92f2547 Mon Sep 17 00:00:00 2001 From: leonardo Date: Fri, 20 Dec 2013 14:35:54 +0000 Subject: [PATCH] =?UTF-8?q?0004575:=20Estoque=20de=20Passagens=20na=20troc?= =?UTF-8?q?a=20de=20ag=C3=AAncia.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@32801 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../ventaboletos/dao/EstacionDAO.java | 2 ++ .../dao/hibernate/EstacionHibernateDAO.java | 18 ++++++++++++++++++ .../service/impl/EstacionServiceImpl.java | 8 ++++++++ 3 files changed, 28 insertions(+) diff --git a/src/com/rjconsultores/ventaboletos/dao/EstacionDAO.java b/src/com/rjconsultores/ventaboletos/dao/EstacionDAO.java index fca70766a..0108ca7ba 100644 --- a/src/com/rjconsultores/ventaboletos/dao/EstacionDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/EstacionDAO.java @@ -33,4 +33,6 @@ public interface EstacionDAO extends GenericDAO { public List buscarEstaciones(PuntoVenta puntoVenta); public List buscarPuntosVentaEstacionPorUsuario(Usuario usuario); + + public Boolean temEstoque(PuntoVenta puntoVenta, Estacion estacion); } diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/EstacionHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/EstacionHibernateDAO.java index 50df5a082..04e28247b 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/EstacionHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/EstacionHibernateDAO.java @@ -6,9 +6,11 @@ package com.rjconsultores.ventaboletos.dao.hibernate; import com.rjconsultores.ventaboletos.entidad.Usuario; +import java.math.BigDecimal; import java.util.List; import org.hibernate.Criteria; +import org.hibernate.SQLQuery; import org.hibernate.SessionFactory; import org.hibernate.criterion.DetachedCriteria; import org.hibernate.criterion.Order; @@ -94,5 +96,21 @@ public List buscarEstaciones(PuntoVenta puntoVenta) { return buscaPuntoVentasUsuario.list(); } + + public Boolean temEstoque(PuntoVenta puntoVenta, Estacion estacion){ + StringBuilder qryStr = new StringBuilder(); + qryStr.append("Select count(*) from ABASTO_BOLETO B, DET_ABASTO_BOLETO D "); + qryStr.append("where d.abastoboleto_id = b.abastoboleto_id and (d.statusfirma = 0 "); + qryStr.append("or d.statusfirma = 1) and d.activo = 1 and b.activo = 1 and "); + qryStr.append("b.puntoventa_id = :puntoventa_id and b.estacion_id = :estacion_id"); + + SQLQuery query = getSession().createSQLQuery(qryStr.toString()); + query.setParameter("puntoventa_id", puntoVenta.getPuntoventaId()); + query.setParameter("estacion_id", estacion.getEstacionId()); + + List list = query.list(); + BigDecimal result = list.get(0); + return (result.intValue() > 0); + } } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/EstacionServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/EstacionServiceImpl.java index 8a19b7a9e..5317b769d 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/EstacionServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/EstacionServiceImpl.java @@ -46,6 +46,14 @@ public class EstacionServiceImpl implements EstacionService { @Transactional(rollbackFor = BusinessException.class) public Estacion suscribirActualizar(Estacion estacion) throws BusinessException { + if (!ApplicationProperties.getInstance().generarRotinaFolios()){ + Estacion estacionPuntoVentaAnterior = estacionDAO.obtenerID(estacion.getEstacionId()); + if (!estacionPuntoVentaAnterior.getPuntoVenta().equals(estacion.getPuntoVenta())){ + if (estacionDAO.temEstoque(estacionPuntoVentaAnterior.getPuntoVenta(), estacion)){ + throw new BusinessException("estacionServiceImpl.msg.hayStock"); + } + } + } Boolean esMacDuplicado = Boolean.FALSE; List lsEstacionMac = estacionDAO.buscar(estacion.getDescmac()); if (!lsEstacionMac.isEmpty()) {