Mantis: 0004070 e 0004071

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@27798 d1611594-4594-4d17-8e1d-87c2c4800839
master
rodrigo 2013-06-14 19:37:36 +00:00
parent 7202e44ee5
commit 00768ad6bb
5 changed files with 175 additions and 144 deletions

View File

@ -9,14 +9,18 @@ import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
import java.util.List; import java.util.List;
/** /**
* *
* @author Administrador * @author Administrador
*/ */
public interface PuntoVentaDAO extends GenericDAO<PuntoVenta, Integer> { public interface PuntoVentaDAO extends GenericDAO<PuntoVenta, Integer> {
public List<PuntoVenta> buscaLike(String strEstacion); public List<PuntoVenta> buscaLike(String strEstacion);
public List<PuntoVenta> busca(String nomPuntoVenta, String numPuntoVenta); public List<PuntoVenta> busca(String nomPuntoVenta, String numPuntoVenta);
public List<PuntoVenta> buscaPuntoVenta(String numPuntoVenta);
public List<PuntoVenta> buscaPuntoVentaParada(Parada parada); public List<PuntoVenta> buscaPuntoVenta(String numPuntoVenta);
public List<PuntoVenta> buscaPuntoVentaParada(Parada parada);
public List<PuntoVenta> buscarPuntoVentaSubordinados(PuntoVenta puntoVenta);
} }

View File

@ -18,60 +18,69 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
/** /**
* *
* @author Administrador * @author Administrador
*/ */
@Repository("puntoVentaDAO") @Repository("puntoVentaDAO")
public class PuntoVentaHibernateDAO extends GenericHibernateDAO<PuntoVenta, Integer> public class PuntoVentaHibernateDAO extends GenericHibernateDAO<PuntoVenta, Integer>
implements PuntoVentaDAO { implements PuntoVentaDAO {
@Autowired @Autowired
public PuntoVentaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { public PuntoVentaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
setSessionFactory(factory); setSessionFactory(factory);
} }
@Override @Override
public List<PuntoVenta> obtenerTodos() { public List<PuntoVenta> obtenerTodos() {
Criteria c = getSession().createCriteria(getPersistentClass()); Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE)); c.add(Restrictions.eq("activo", Boolean.TRUE));
c.addOrder(Order.asc("nombpuntoventa")); c.addOrder(Order.asc("nombpuntoventa"));
return c.list(); return c.list();
} }
public List<PuntoVenta> buscaLike(String strEstacion) { public List<PuntoVenta> buscaLike(String strEstacion) {
Criteria c = getSession().createCriteria(getPersistentClass()); Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE)); c.add(Restrictions.eq("activo", Boolean.TRUE));
c.add(Restrictions.like("nombpuntoventa", strEstacion, MatchMode.START)); c.add(Restrictions.like("nombpuntoventa", strEstacion, MatchMode.START));
return c.list(); return c.list();
} }
public List<PuntoVenta> busca(String nomPuntoVenta, String numPuntoVenta) { public List<PuntoVenta> busca(String nomPuntoVenta, String numPuntoVenta) {
Criteria c = getSession().createCriteria(getPersistentClass()); Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE)); c.add(Restrictions.eq("activo", Boolean.TRUE));
c.add(Restrictions.eq("nombpuntoventa", nomPuntoVenta)); c.add(Restrictions.eq("nombpuntoventa", nomPuntoVenta));
c.add(Restrictions.eq("numPuntoVenta", numPuntoVenta)); c.add(Restrictions.eq("numPuntoVenta", numPuntoVenta));
return c.list(); return c.list();
} }
public List<PuntoVenta> buscaPuntoVenta(String numPuntoVenta) {
Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE));
c.add(Restrictions.eq("numPuntoVenta", numPuntoVenta));
return c.list(); public List<PuntoVenta> buscaPuntoVenta(String numPuntoVenta) {
} Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE));
public List<PuntoVenta> buscaPuntoVentaParada(Parada parada){ c.add(Restrictions.eq("numPuntoVenta", numPuntoVenta));
Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE)); return c.list();
c.add(Restrictions.eq("parada", parada)); }
return c.list(); public List<PuntoVenta> buscaPuntoVentaParada(Parada parada) {
} Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE));
c.add(Restrictions.eq("parada", parada));
return c.list();
}
@Override
public List<PuntoVenta> buscarPuntoVentaSubordinados(PuntoVenta puntoVenta) {
Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE));
c.add(Restrictions.eq("puntoVentaPadre", puntoVenta));
return c.list();
}
} }

View File

@ -132,6 +132,9 @@ public class PuntoVenta implements Serializable {
private Boolean indValidaStock; private Boolean indValidaStock;
@Column(name = "TIEMPOCANCELACION") @Column(name = "TIEMPOCANCELACION")
private Integer tiempoCancelacion; private Integer tiempoCancelacion;
@OneToOne
@JoinColumn(name = "PUNTOVENTAPADRE_ID")
private PuntoVenta puntoVentaPadre;
public PtovtaComissao getComissaoId() { public PtovtaComissao getComissaoId() {
return comissaoId; return comissaoId;
@ -585,4 +588,12 @@ public class PuntoVenta implements Serializable {
public void setTiempoCancelacion(Integer tiempoCancelacion) { public void setTiempoCancelacion(Integer tiempoCancelacion) {
this.tiempoCancelacion = tiempoCancelacion; this.tiempoCancelacion = tiempoCancelacion;
} }
public PuntoVenta getPuntoVentaPadre() {
return puntoVentaPadre;
}
public void setPuntoVentaPadre(PuntoVenta puntoVentaPadre) {
this.puntoVentaPadre = puntoVentaPadre;
}
} }

View File

@ -9,14 +9,18 @@ import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
import java.util.List; import java.util.List;
/** /**
* *
* @author Administrador * @author Administrador
*/ */
public interface PuntoVentaService extends GenericService<PuntoVenta, Integer> { public interface PuntoVentaService extends GenericService<PuntoVenta, Integer> {
public List<PuntoVenta> buscaLike(String strEstacion); public List<PuntoVenta> buscaLike(String strEstacion);
public List<PuntoVenta> buscar(String nomPuntoVenta, String numPuntoVenta); public List<PuntoVenta> buscar(String nomPuntoVenta, String numPuntoVenta);
public List<PuntoVenta> buscaPuntoVenta(String numPuntoVenta);
public List<PuntoVenta> buscaPuntoVentaParada(Parada paradaId); public List<PuntoVenta> buscaPuntoVenta(String numPuntoVenta);
public List<PuntoVenta> buscaPuntoVentaParada(Parada paradaId);
public List<PuntoVenta> buscarPuntoVentaSubordinados(PuntoVenta puntoVenta);
} }

View File

@ -4,121 +4,124 @@
*/ */
package com.rjconsultores.ventaboletos.service.impl; package com.rjconsultores.ventaboletos.service.impl;
import com.rjconsultores.ventaboletos.dao.PuntoVentaDAO;
import com.rjconsultores.ventaboletos.entidad.FormaPagoDet;
import com.rjconsultores.ventaboletos.entidad.Parada;
import com.rjconsultores.ventaboletos.entidad.PtovtaEmpresa;
import com.rjconsultores.ventaboletos.entidad.PtovtaEstoque;
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
import com.rjconsultores.ventaboletos.service.PtovtaEmpresaService;
import com.rjconsultores.ventaboletos.service.PuntoVentaService;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.rjconsultores.ventaboletos.dao.PuntoVentaDAO;
import com.rjconsultores.ventaboletos.entidad.FormaPagoDet;
import com.rjconsultores.ventaboletos.entidad.Parada;
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
import com.rjconsultores.ventaboletos.service.PuntoVentaService;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
/** /**
* *
* @author Administrador * @author Administrador
*/ */
@Service("puntoVentaService") @Service("puntoVentaService")
public class PuntoVentaServiceImpl implements PuntoVentaService { public class PuntoVentaServiceImpl implements PuntoVentaService {
@Autowired @Autowired
private PuntoVentaDAO puntoVentaDAO; private PuntoVentaDAO puntoVentaDAO;
@Autowired
private PtovtaEmpresaService ptoVtaService;
public List<PuntoVenta> obtenerTodos() { public List<PuntoVenta> obtenerTodos() {
return puntoVentaDAO.obtenerTodos(); return puntoVentaDAO.obtenerTodos();
} }
public PuntoVenta obtenerID(Integer id) { public PuntoVenta obtenerID(Integer id) {
return puntoVentaDAO.obtenerID(id); return puntoVentaDAO.obtenerID(id);
} }
@Transactional @Transactional
public PuntoVenta suscribir(PuntoVenta entidad) { public PuntoVenta suscribir(PuntoVenta entidad) {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime()); entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.TRUE); entidad.setActivo(Boolean.TRUE);
return puntoVentaDAO.suscribir(entidad); return puntoVentaDAO.suscribir(entidad);
} }
@Transactional @Transactional
public PuntoVenta actualizacion(PuntoVenta entidad) { public PuntoVenta actualizacion(PuntoVenta entidad) {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime()); entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.TRUE); entidad.setActivo(Boolean.TRUE);
return puntoVentaDAO.actualizacion(entidad); return puntoVentaDAO.actualizacion(entidad);
} }
@Transactional @Transactional
public void borrar(PuntoVenta entidad) { public void borrar(PuntoVenta entidad) {
for (FormaPagoDet forma : entidad.getLsFormaPagoDet()) { for (FormaPagoDet forma : entidad.getLsFormaPagoDet()) {
forma.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); forma.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
forma.setFecmodif(Calendar.getInstance().getTime()); forma.setFecmodif(Calendar.getInstance().getTime());
forma.setActivo(Boolean.FALSE); forma.setActivo(Boolean.FALSE);
} }
// for (PtovtaEstoque forma : entidad.getPtovtaEstoqueList()) {
// forma.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
// forma.setFecmodif(Calendar.getInstance().getTime());
// forma.setActivo(Boolean.FALSE);
// }
if(entidad.getAgenciaId() != null){
entidad.getAgenciaId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.getAgenciaId().setFecmodif(Calendar.getInstance().getTime());
entidad.getAgenciaId().setActivo(Boolean.FALSE);
}
if(entidad.getComissaoId() != null){
entidad.getComissaoId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.getComissaoId().setFecmodif(Calendar.getInstance().getTime());
entidad.getComissaoId().setActivo(Boolean.FALSE);
}
if(entidad.getDiversosId() != null){
entidad.getDiversosId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.getDiversosId().setFecmodif(Calendar.getInstance().getTime());
entidad.getDiversosId().setActivo(Boolean.FALSE);
}
if(entidad.getTitularId() != null){
entidad.getTitularId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.getTitularId().setFecmodif(Calendar.getInstance().getTime());
entidad.getTitularId().setActivo(Boolean.FALSE);
}
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); // for (PtovtaEstoque forma : entidad.getPtovtaEstoqueList()) {
entidad.setFecmodif(Calendar.getInstance().getTime()); // forma.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setActivo(Boolean.FALSE); // forma.setFecmodif(Calendar.getInstance().getTime());
// forma.setActivo(Boolean.FALSE);
// }
puntoVentaDAO.actualizacion(entidad); if (entidad.getAgenciaId() != null) {
}
public List<PuntoVenta> buscaLike(String strEstacion) { entidad.getAgenciaId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
return puntoVentaDAO.buscaLike(strEstacion); entidad.getAgenciaId().setFecmodif(Calendar.getInstance().getTime());
} entidad.getAgenciaId().setActivo(Boolean.FALSE);
public List<PuntoVenta> buscar(String nomPuntoVenta, String numPuntoVenta) { }
return puntoVentaDAO.busca(nomPuntoVenta, numPuntoVenta);
} if (entidad.getComissaoId() != null) {
entidad.getComissaoId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
public List<PuntoVenta> buscaPuntoVenta(String numPuntoVenta) { entidad.getComissaoId().setFecmodif(Calendar.getInstance().getTime());
return puntoVentaDAO.buscaPuntoVenta(numPuntoVenta); entidad.getComissaoId().setActivo(Boolean.FALSE);
} }
public List<PuntoVenta> buscaPuntoVentaParada(Parada paradaId) { if (entidad.getDiversosId() != null) {
return puntoVentaDAO.buscaPuntoVentaParada(paradaId); entidad.getDiversosId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
} entidad.getDiversosId().setFecmodif(Calendar.getInstance().getTime());
entidad.getDiversosId().setActivo(Boolean.FALSE);
}
if (entidad.getTitularId() != null) {
entidad.getTitularId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.getTitularId().setFecmodif(Calendar.getInstance().getTime());
entidad.getTitularId().setActivo(Boolean.FALSE);
}
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.FALSE);
puntoVentaDAO.actualizacion(entidad);
}
public List<PuntoVenta> buscaLike(String strEstacion) {
return puntoVentaDAO.buscaLike(strEstacion);
}
public List<PuntoVenta> buscar(String nomPuntoVenta, String numPuntoVenta) {
return puntoVentaDAO.busca(nomPuntoVenta, numPuntoVenta);
}
public List<PuntoVenta> buscaPuntoVenta(String numPuntoVenta) {
return puntoVentaDAO.buscaPuntoVenta(numPuntoVenta);
}
public List<PuntoVenta> buscaPuntoVentaParada(Parada paradaId) {
return puntoVentaDAO.buscaPuntoVentaParada(paradaId);
}
@Override
public List<PuntoVenta> buscarPuntoVentaSubordinados(PuntoVenta puntoVenta) {
List<PuntoVenta> lsPuntoVentaSubordinados = puntoVentaDAO.buscarPuntoVentaSubordinados(puntoVenta);
return lsPuntoVentaSubordinados;
}
} }