diff --git a/src/com/rjconsultores/ventaboletos/dao/EmpresaDAO.java b/src/com/rjconsultores/ventaboletos/dao/EmpresaDAO.java index d0ac417f4..12b304db4 100644 --- a/src/com/rjconsultores/ventaboletos/dao/EmpresaDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/EmpresaDAO.java @@ -7,6 +7,8 @@ package com.rjconsultores.ventaboletos.dao; import java.util.List; import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.Estado; +import com.rjconsultores.ventaboletos.entidad.PuntoVenta; /** * @@ -23,4 +25,6 @@ public interface EmpresaDAO extends GenericDAO { public List buscar(String nombempresa, Boolean indExterna, Short indTipo); public List obtenerIndTipo2(); + + public List buscarNotInPuntoVtaComissao(PuntoVenta puntoVenta); } diff --git a/src/com/rjconsultores/ventaboletos/dao/GrupoRutaDAO.java b/src/com/rjconsultores/ventaboletos/dao/GrupoRutaDAO.java new file mode 100644 index 000000000..6449cc76e --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/GrupoRutaDAO.java @@ -0,0 +1,19 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.dao; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.GrupoRuta; + +/** + * + * @author Bruno H. G. Gouvêa + * + */ +public interface GrupoRutaDAO extends GenericDAO { + + public List buscarPorNome(String descgrupo); +} diff --git a/src/com/rjconsultores/ventaboletos/dao/PtovtaComissaoDAO.java b/src/com/rjconsultores/ventaboletos/dao/PtovtaComissaoDAO.java index 2f9ef65ce..2402172dd 100644 --- a/src/com/rjconsultores/ventaboletos/dao/PtovtaComissaoDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/PtovtaComissaoDAO.java @@ -3,6 +3,7 @@ package com.rjconsultores.ventaboletos.dao; import java.util.List; import com.rjconsultores.ventaboletos.entidad.PtovtaComissao; +import com.rjconsultores.ventaboletos.entidad.PuntoVenta; @@ -10,5 +11,6 @@ public interface PtovtaComissaoDAO extends GenericDAO { public List buscar(int id); + public List buscarByPuntaVenta(PuntoVenta puntaVenta); } diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaHibernateDAO.java index d5f3b949d..f98bfae7e 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaHibernateDAO.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import java.util.List; import org.hibernate.Criteria; +import org.hibernate.Query; import org.hibernate.SessionFactory; import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; @@ -17,6 +18,8 @@ import org.springframework.stereotype.Repository; import com.rjconsultores.ventaboletos.dao.EmpresaDAO; import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.Estado; +import com.rjconsultores.ventaboletos.entidad.PuntoVenta; /** * @@ -100,4 +103,28 @@ public class EmpresaHibernateDAO extends GenericHibernateDAO return c.list(); } + + + public List buscarNotInPuntoVtaComissao(PuntoVenta puntoVenta){ + StringBuilder sb = new StringBuilder(); + + sb.append(" select em "); + sb.append(" from Empresa em "); + sb.append(" where em.activo = 1 "); + sb.append(" and em.empresaId not in ( "); + sb.append(" select pc.empresaId.empresaId from PtovtaComissao pc "); + sb.append(" where pc.activo = 1 and pc.puntoventaId.puntoventaId = :puntoventaId "); + sb.append(" )"); + sb.append(" order by em.nombempresa"); + + + Query query = getSession().createQuery(sb.toString()); + query.setParameter("puntoventaId", puntoVenta.getPuntoventaId()); + + List lsEmpresa = query.list(); + + + return lsEmpresa; + + } } diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/GrupoRutaHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/GrupoRutaHibernateDAO.java new file mode 100644 index 000000000..0253763d2 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/GrupoRutaHibernateDAO.java @@ -0,0 +1,42 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.dao.hibernate; + +import java.util.List; + +import com.rjconsultores.ventaboletos.dao.GrupoRutaDAO; +import com.rjconsultores.ventaboletos.entidad.ClaseServicio; +import com.rjconsultores.ventaboletos.entidad.GrupoRuta; + +import org.hibernate.Criteria; +import org.hibernate.SessionFactory; +import org.hibernate.criterion.Restrictions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Repository; + +/** + * + * @author Bruno H. G. Gouvêa + * + */ +@Repository("grupoRutaDAO") +public class GrupoRutaHibernateDAO extends GenericHibernateDAO + implements GrupoRutaDAO { + + @Autowired + public GrupoRutaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + public List buscarPorNome(String descgrupo) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.eq("descgrupo", descgrupo)); + + return c.list(); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/PtovtaComissaoHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/PtovtaComissaoHibernateDAO.java index aea3f6780..56faf7913 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/PtovtaComissaoHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/PtovtaComissaoHibernateDAO.java @@ -12,7 +12,10 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; import com.rjconsultores.ventaboletos.dao.PtovtaComissaoDAO; +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.EmpresaImposto; import com.rjconsultores.ventaboletos.entidad.PtovtaComissao; +import com.rjconsultores.ventaboletos.entidad.PuntoVenta; @Repository("ptovtaComissaoDAO") @@ -42,6 +45,16 @@ public class PtovtaComissaoHibernateDAO extends GenericHibernateDAO buscarByPuntaVenta(PuntoVenta puntaVenta) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.eq("puntoventaId", puntaVenta)); + + c.addOrder(Order.asc("empresaId")); + + return c.list(); + } } diff --git a/src/com/rjconsultores/ventaboletos/entidad/GrupoRuta.java b/src/com/rjconsultores/ventaboletos/entidad/GrupoRuta.java new file mode 100644 index 000000000..2fcff53fb --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/GrupoRuta.java @@ -0,0 +1,134 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.entidad; + +import java.io.Serializable; +import java.util.Date; +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.SequenceGenerator; + +/** + * + * @author Bruno H. G. Gouvêa + * + */ +@Entity +@SequenceGenerator(name = "GRUPO_RUTA_SEQ", sequenceName = "GRUPO_RUTA_SEQ", allocationSize = 1) +@Table(name = "GRUPO_RUTA") +public class GrupoRuta implements Serializable { + + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "GRUPO_RUTA_SEQ") + @Column(name = "GRUPORUTA_ID") + private Integer grupoRutaId; + @Column(name = "DESCGRUPO") + private String descgrupo; + @Column(name = "ACTIVO") + private Boolean activo; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + + + public GrupoRuta() { + } + + public Boolean getActivo() { + return activo; + } + + public void setActivo(Boolean activo) { + this.activo = activo; + } + + public Date getFecmodif() { + return fecmodif; + } + + public void setFecmodif(Date fecmodif) { + this.fecmodif = fecmodif; + } + + public Integer getUsuarioId() { + return usuarioId; + } + + public void setUsuarioId(Integer usuarioId) { + this.usuarioId = usuarioId; + } + + /** + * @return the grupoRutaId + */ + public Integer getGrupoRutaId() { + return grupoRutaId; + } + + /** + * @param grupoRutaId + * the grupoRutaId to set + */ + public void setGrupoRutaId(Integer grupoRutaId) { + this.grupoRutaId = grupoRutaId; + } + + + + /** + * @return the descGrupo + */ + public String getDescGrupo() { + return descgrupo; + } + + /** + * @param descGrupo the descGrupo to set + */ + public void setDescGrupo(String descgrupo) { + this.descgrupo = descgrupo; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final GrupoRuta other = (GrupoRuta) obj; + if (!this.getGrupoRutaId().equals(other.getGrupoRutaId())) { + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 59 * hash + (this.getGrupoRutaId() != null ? this.getGrupoRutaId().hashCode() : 0); + return hash; + } + + @Override + public String toString() { + return "com.rjconsultores.ventaboletos.entidad.CategoriaClase[grupoRutaId=" + grupoRutaId + "]"; + } +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/PtovtaComissao.java b/src/com/rjconsultores/ventaboletos/entidad/PtovtaComissao.java index 564ffa845..f96d32bac 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/PtovtaComissao.java +++ b/src/com/rjconsultores/ventaboletos/entidad/PtovtaComissao.java @@ -124,6 +124,10 @@ public class PtovtaComissao implements Serializable { @JoinColumn(name = "PUNTOVENTA_ID", referencedColumnName = "PUNTOVENTA_ID") @ManyToOne private PuntoVenta puntoventaId; + + @JoinColumn(name = "EMPRESA_ID", referencedColumnName = "EMPRESA_ID") + @ManyToOne + private Empresa empresaId; public PtovtaComissao() { } @@ -429,7 +433,21 @@ public class PtovtaComissao implements Serializable { // - @Override + /** + * @return the empresaId + */ + public Empresa getEmpresaId() { + return empresaId; + } + + /** + * @param empresaId the empresaId to set + */ + public void setEmpresaId(Empresa empresaId) { + this.empresaId = empresaId; + } + + @Override public int hashCode() { int hash = 0; hash += (ptovtaComissaoId != null ? ptovtaComissaoId.hashCode() : 0); diff --git a/src/com/rjconsultores/ventaboletos/entidad/Ruta.java b/src/com/rjconsultores/ventaboletos/entidad/Ruta.java index 7f21d45e8..24ca531b7 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/Ruta.java +++ b/src/com/rjconsultores/ventaboletos/entidad/Ruta.java @@ -53,6 +53,9 @@ public class Ruta implements Serializable { @JoinColumn(name = "CLASESERVICIO_ID", referencedColumnName = "CLASESERVICIO_ID") @ManyToOne private ClaseServicio claseServicio; + @JoinColumn(name = "GRUPORUTA_ID", referencedColumnName = "GRUPORUTA_ID") + @ManyToOne + private GrupoRuta grupoRuta; @OneToMany(mappedBy = "ruta") private List rutaSecuenciaList; @OneToMany(mappedBy = "ruta") diff --git a/src/com/rjconsultores/ventaboletos/service/EmpresaService.java b/src/com/rjconsultores/ventaboletos/service/EmpresaService.java index 1ff989b47..3050cdd2f 100644 --- a/src/com/rjconsultores/ventaboletos/service/EmpresaService.java +++ b/src/com/rjconsultores/ventaboletos/service/EmpresaService.java @@ -5,6 +5,7 @@ package com.rjconsultores.ventaboletos.service; import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.PuntoVenta; import com.rjconsultores.ventaboletos.entidad.Usuario; import java.util.List; @@ -26,4 +27,6 @@ public interface EmpresaService extends GenericService { public List obtenerIndTipo2(); // public List obtenerEmpresaU() + public List buscarNotInPuntoVtaComissao(PuntoVenta puntoVenta); + } diff --git a/src/com/rjconsultores/ventaboletos/service/GrupoRutaService.java b/src/com/rjconsultores/ventaboletos/service/GrupoRutaService.java new file mode 100644 index 000000000..a04b62f42 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/GrupoRutaService.java @@ -0,0 +1,20 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.service; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.GrupoRuta; + +/** + * + * @author Bruno H. G. Gouvêa + * + */ +public interface GrupoRutaService extends GenericService { + + public List buscarPorNome(String descgrupo); + +} diff --git a/src/com/rjconsultores/ventaboletos/service/PtovtaComissaoService.java b/src/com/rjconsultores/ventaboletos/service/PtovtaComissaoService.java index 97ed9a3c3..49997b008 100644 --- a/src/com/rjconsultores/ventaboletos/service/PtovtaComissaoService.java +++ b/src/com/rjconsultores/ventaboletos/service/PtovtaComissaoService.java @@ -7,6 +7,7 @@ package com.rjconsultores.ventaboletos.service; import java.util.List; import com.rjconsultores.ventaboletos.entidad.PtovtaComissao; +import com.rjconsultores.ventaboletos.entidad.PuntoVenta; @@ -15,6 +16,8 @@ import com.rjconsultores.ventaboletos.entidad.PtovtaComissao; public interface PtovtaComissaoService extends GenericService { public List buscar(int id); + + public List buscarByPuntaVenta(PuntoVenta puntaVenta); } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/EmpresaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/EmpresaServiceImpl.java index 1366987e5..9c1380fbf 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/EmpresaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/EmpresaServiceImpl.java @@ -13,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional; import com.rjconsultores.ventaboletos.dao.EmpresaDAO; import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.PuntoVenta; import com.rjconsultores.ventaboletos.service.EmpresaService; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; @@ -80,4 +81,13 @@ public class EmpresaServiceImpl implements EmpresaService { public List obtenerIndTipo2() { return empresaDAO.obtenerIndTipo2(); } + + /* (non-Javadoc) + * @see com.rjconsultores.ventaboletos.service.EmpresaService#buscarNotInPuntoVtaComissao(com.rjconsultores.ventaboletos.entidad.PuntoVenta) + */ + @Override + public List buscarNotInPuntoVtaComissao(PuntoVenta puntoVenta) { + return empresaDAO.buscarNotInPuntoVtaComissao(puntoVenta); + + } } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/GrupoRutaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/GrupoRutaServiceImpl.java new file mode 100644 index 000000000..f8939f297 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/GrupoRutaServiceImpl.java @@ -0,0 +1,67 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.service.impl; + +import com.rjconsultores.ventaboletos.dao.GrupoRutaDAO; +import com.rjconsultores.ventaboletos.entidad.GrupoRuta; +import com.rjconsultores.ventaboletos.service.GrupoRutaService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; +import java.util.Calendar; +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * + * @author Bruno H. G. Gouvêa + * + */ +@Service("grupoRutaService") +public class GrupoRutaServiceImpl implements GrupoRutaService { + + @Autowired + private GrupoRutaDAO grupoRutaDAO; + + public List obtenerTodos() { + return grupoRutaDAO.obtenerTodos(); + } + + public GrupoRuta obtenerID(Integer id) { + return grupoRutaDAO.obtenerID(id); + } + + @Transactional + public GrupoRuta suscribir(GrupoRuta entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return grupoRutaDAO.suscribir(entidad); + } + + @Transactional + public GrupoRuta actualizacion(GrupoRuta entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return grupoRutaDAO.actualizacion(entidad); + } + + @Transactional + public void borrar(GrupoRuta entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + grupoRutaDAO.actualizacion(entidad); + } + + public List buscarPorNome(String descgrupo) { + return grupoRutaDAO.buscarPorNome(descgrupo); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/PtovtaComissaoServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/PtovtaComissaoServiceImpl.java index 16859ee32..3152c57e1 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/PtovtaComissaoServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/PtovtaComissaoServiceImpl.java @@ -7,6 +7,7 @@ package com.rjconsultores.ventaboletos.service.impl; import com.rjconsultores.ventaboletos.dao.PtovtaComissaoDAO; import com.rjconsultores.ventaboletos.entidad.PtovtaComissao; +import com.rjconsultores.ventaboletos.entidad.PuntoVenta; import com.rjconsultores.ventaboletos.service.PtovtaComissaoService; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; import java.util.Calendar; @@ -64,6 +65,10 @@ public class PtovtaComissaoServiceImpl implements PtovtaComissaoService { public List buscar(int id) { return ptovtaComissaoDAO.buscar(id); } + + public List buscarByPuntaVenta(PuntoVenta puntaVenta){ + return ptovtaComissaoDAO.buscarByPuntaVenta(puntaVenta); + } }