Série para venda embarcada
bug#13748 dev:trevezani qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@91233 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
50359b3e8c
commit
b432310fca
|
@ -0,0 +1,7 @@
|
||||||
|
package com.rjconsultores.ventaboletos.dao;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.CtrlSerieBPe;
|
||||||
|
|
||||||
|
public interface CtrlSerieBPeDAO extends GenericDAO<CtrlSerieBPe, Long> {
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,15 @@
|
||||||
package com.rjconsultores.ventaboletos.dao;
|
package com.rjconsultores.ventaboletos.dao;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.entidad.CtrlSerieEmbarcada;
|
import com.rjconsultores.ventaboletos.entidad.CtrlSerieEmbarcada;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.DispositivoEmbarcada;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Estado;
|
||||||
|
|
||||||
public interface CtrlSerieEmbarcadaDAO extends GenericDAO<CtrlSerieEmbarcada, Long> {
|
public interface CtrlSerieEmbarcadaDAO extends GenericDAO<CtrlSerieEmbarcada, Long> {
|
||||||
|
|
||||||
|
public CtrlSerieEmbarcada suscribir(CtrlSerieEmbarcada entity);
|
||||||
|
public CtrlSerieEmbarcada actualizacion(CtrlSerieEmbarcada entity);
|
||||||
|
|
||||||
|
public Boolean validaDispositivoEmpresaEstadoCadastrado(DispositivoEmbarcada dispositivo, Empresa empresa, Estado estado);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
package com.rjconsultores.ventaboletos.dao;
|
package com.rjconsultores.ventaboletos.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.entidad.DispositivoEmbarcada;
|
import com.rjconsultores.ventaboletos.entidad.DispositivoEmbarcada;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
||||||
|
|
||||||
public interface DispositivoEmbarcadaDAO extends GenericDAO<DispositivoEmbarcada, Long> {
|
public interface DispositivoEmbarcadaDAO extends GenericDAO<DispositivoEmbarcada, Long> {
|
||||||
|
|
||||||
public DispositivoEmbarcada buscarMac(String mac);
|
public DispositivoEmbarcada buscarMac(String mac);
|
||||||
public DispositivoEmbarcada buscarImei(String imei);
|
public DispositivoEmbarcada buscarImei(String imei);
|
||||||
|
public List<DispositivoEmbarcada> buscarPorEmpresaPuntoVenta(Empresa empresa, PuntoVenta puntoventa);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.dao.CtrlSerieBPeDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.CtrlSerieBPe;
|
||||||
|
|
||||||
|
@Repository("ctrlSerieBPeDAO")
|
||||||
|
public class CtrlSerieBPeHibernateDAO extends GenericHibernateDAO<CtrlSerieBPe, Long> implements CtrlSerieBPeDAO {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(CtrlSerieBPeHibernateDAO.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public CtrlSerieBPeHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||||
|
setSessionFactory(factory);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,18 +1,71 @@
|
||||||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.Query;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.dao.CtrlSerieEmbarcadaDAO;
|
import com.rjconsultores.ventaboletos.dao.CtrlSerieEmbarcadaDAO;
|
||||||
import com.rjconsultores.ventaboletos.entidad.CtrlSerieEmbarcada;
|
import com.rjconsultores.ventaboletos.entidad.CtrlSerieEmbarcada;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.DispositivoEmbarcada;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Estado;
|
||||||
|
|
||||||
@Repository("ctrlSerieEmbarcadaDAO")
|
@Repository("ctrlSerieEmbarcadaDAO")
|
||||||
public class CtrlSerieEmbarcadaHibernateDAO extends GenericHibernateDAO<CtrlSerieEmbarcada, Long> implements CtrlSerieEmbarcadaDAO {
|
public class CtrlSerieEmbarcadaHibernateDAO extends GenericHibernateDAO<CtrlSerieEmbarcada, Long> implements CtrlSerieEmbarcadaDAO {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(CtrlSerieEmbarcadaHibernateDAO.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public CtrlSerieEmbarcadaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
public CtrlSerieEmbarcadaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||||
setSessionFactory(factory);
|
setSessionFactory(factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public CtrlSerieEmbarcada suscribir(CtrlSerieEmbarcada entity) {
|
||||||
|
try {
|
||||||
|
this.getHibernateTemplate().save(entity);
|
||||||
|
getHibernateTemplate().flush();
|
||||||
|
|
||||||
|
return entity;
|
||||||
|
} catch (final HibernateException ex) {
|
||||||
|
throw convertHibernateAccessException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public CtrlSerieEmbarcada actualizacion(CtrlSerieEmbarcada entity) {
|
||||||
|
entity = getHibernateTemplate().merge(entity);
|
||||||
|
getHibernateTemplate().flush();
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean validaDispositivoEmpresaEstadoCadastrado(DispositivoEmbarcada dispositivo, Empresa empresa, Estado estado) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("select COUNT(se.ctrlSerieEmbarcadaId) ");
|
||||||
|
sb.append("from CtrlSerieEmbarcada se ");
|
||||||
|
sb.append("where se.activo = 1 ");
|
||||||
|
sb.append("and se.dispositivoEmbarcada.dispositivoEmbarcadaId = :dispositivoEmbarcadaId ");
|
||||||
|
sb.append("and se.empresaId = :empresaId ");
|
||||||
|
sb.append("and se.estado.estadoId = :estadoId ");
|
||||||
|
|
||||||
|
Query qry = getSession().createQuery(sb.toString());
|
||||||
|
qry.setLong("dispositivoEmbarcadaId", dispositivo.getDispositivoEmbarcadaId());
|
||||||
|
qry.setLong("empresaId", empresa.getEmpresaId());
|
||||||
|
qry.setLong("estadoId", estado.getEstadoId());
|
||||||
|
|
||||||
|
Number n = (Number) qry.uniqueResult();
|
||||||
|
|
||||||
|
if (n == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return n.longValue() > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.hibernate.Criteria;
|
import org.hibernate.Criteria;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.Query;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.criterion.Order;
|
import org.hibernate.criterion.Order;
|
||||||
import org.hibernate.criterion.Restrictions;
|
import org.hibernate.criterion.Restrictions;
|
||||||
|
@ -12,14 +13,15 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.dao.DispositivoEmbarcadaDAO;
|
import com.rjconsultores.ventaboletos.dao.DispositivoEmbarcadaDAO;
|
||||||
import com.rjconsultores.ventaboletos.entidad.DispositivoEmbarcada;
|
import com.rjconsultores.ventaboletos.entidad.DispositivoEmbarcada;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
||||||
|
|
||||||
@Repository("dispositivoEmbarcadaDAO")
|
@Repository("dispositivoEmbarcadaDAO")
|
||||||
public class DispositivoEmbarcadaHibernateDAO extends GenericHibernateDAO<DispositivoEmbarcada, Long>
|
public class DispositivoEmbarcadaHibernateDAO extends GenericHibernateDAO<DispositivoEmbarcada, Long> implements DispositivoEmbarcadaDAO {
|
||||||
implements DispositivoEmbarcadaDAO {
|
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(DispositivoEmbarcadaHibernateDAO.class);
|
private static final Logger log = LoggerFactory.getLogger(DispositivoEmbarcadaHibernateDAO.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -55,6 +57,7 @@ public class DispositivoEmbarcadaHibernateDAO extends GenericHibernateDAO<Dispos
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public DispositivoEmbarcada suscribir(DispositivoEmbarcada entity) {
|
public DispositivoEmbarcada suscribir(DispositivoEmbarcada entity) {
|
||||||
try {
|
try {
|
||||||
this.getHibernateTemplate().save(entity);
|
this.getHibernateTemplate().save(entity);
|
||||||
|
@ -68,10 +71,25 @@ public class DispositivoEmbarcadaHibernateDAO extends GenericHibernateDAO<Dispos
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public DispositivoEmbarcada actualizacion(DispositivoEmbarcada entity) {
|
public DispositivoEmbarcada actualizacion(DispositivoEmbarcada entity) {
|
||||||
entity = getHibernateTemplate().merge(entity);
|
entity = getHibernateTemplate().merge(entity);
|
||||||
getHibernateTemplate().flush();
|
getHibernateTemplate().flush();
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public List<DispositivoEmbarcada> buscarPorEmpresaPuntoVenta(Empresa empresa, PuntoVenta puntoventa) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("from DispositivoEmbarcada de ");
|
||||||
|
sb.append("where activo = 1 ");
|
||||||
|
sb.append("and de.empresaId = :empresaId ");
|
||||||
|
sb.append("and de.puntoVentaId = :puntoVentaId ");
|
||||||
|
|
||||||
|
Query qry = getSession().createQuery(sb.toString());
|
||||||
|
qry.setLong("empresaId", empresa.getEmpresaId());
|
||||||
|
qry.setLong("puntoVentaId", puntoventa.getPuntoventaId());
|
||||||
|
|
||||||
|
return qry.list();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
package com.rjconsultores.ventaboletos.entidad;
|
||||||
|
|
||||||
|
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.SequenceGenerator;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.persistence.Temporal;
|
||||||
|
import javax.persistence.TemporalType;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@SequenceGenerator(name = "CTRL_SERIE_BPE_SEQ", sequenceName = "CTRL_SERIE_BPE_SEQ", allocationSize = 1)
|
||||||
|
@Table(name = "CTRL_SERIE_BPE")
|
||||||
|
public class CtrlSerieBPe {
|
||||||
|
@Id
|
||||||
|
@Basic(optional = false)
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO, generator = "CTRL_SERIE_BPE_SEQ")
|
||||||
|
@Column(name = "CTRLSERIEBPE_ID")
|
||||||
|
private Long ctrlSerieBPeId;
|
||||||
|
|
||||||
|
@Column(name = "EMPRESA_ID")
|
||||||
|
private Long empresaId;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "ESTADO_ID", referencedColumnName = "ESTADO_ID")
|
||||||
|
private Estado estado;
|
||||||
|
|
||||||
|
@Column(name = "NUMSERIE")
|
||||||
|
private String serie;
|
||||||
|
|
||||||
|
@Column(name = "ACTIVO")
|
||||||
|
private Boolean activo;
|
||||||
|
|
||||||
|
@Basic(optional = false)
|
||||||
|
@Column(name = "FECMODIF")
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
private Date fecmodif;
|
||||||
|
|
||||||
|
@Column(name = "USUARIO_ID")
|
||||||
|
private Integer usuarioId;
|
||||||
|
|
||||||
|
public CtrlSerieBPe() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getCtrlSerieBPeId() {
|
||||||
|
return ctrlSerieBPeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCtrlSerieBPeId(Long ctrlSerieBPeId) {
|
||||||
|
this.ctrlSerieBPeId = ctrlSerieBPeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getEmpresaId() {
|
||||||
|
return empresaId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmpresaId(Long empresaId) {
|
||||||
|
this.empresaId = empresaId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Estado getEstado() {
|
||||||
|
return estado;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEstado(Estado estado) {
|
||||||
|
this.estado = estado;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSerie() {
|
||||||
|
return serie;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSerie(String serie) {
|
||||||
|
this.serie = serie;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "CtrlSerieBPe [ctrlSerieBPeId=" + ctrlSerieBPeId + ", empresaId=" + empresaId + ", estado=" + estado + ", serie=" + serie + ", activo=" + activo + ", fecmodif=" + fecmodif + ", usuarioId=" + usuarioId + "]";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.rjconsultores.ventaboletos.service;
|
||||||
|
|
||||||
|
public interface ControleSerieEmbarcadaService {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.rjconsultores.ventaboletos.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.dao.CtrlSerieBPeDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.dao.CtrlSerieEmbarcadaDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.service.ControleSerieEmbarcadaService;
|
||||||
|
|
||||||
|
@Service("controleSerieEmbarcadaService")
|
||||||
|
public class ControleSerieEmbarcadaServiceImpl implements ControleSerieEmbarcadaService {
|
||||||
|
@Autowired
|
||||||
|
private CtrlSerieEmbarcadaDAO ctrlSerieEmbarcadaDAO;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CtrlSerieBPeDAO ctrlSerieBPeDAO;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue