From 0fb448f1a4834b65f69b41d65fb05c75a5234cba Mon Sep 17 00:00:00 2001 From: "fabricio.oliveira" Date: Fri, 12 Apr 2019 14:09:23 +0000 Subject: [PATCH] 0013746: Menu Dispositivo Venda Embarcada fixes bug#13746 dev:Leo qua:Jose git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@91880 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../ventaboletos/dao/BoletoDAO.java | 17 +++++++ .../dao/hibernate/BoletoHibernateDAO.java | 42 ++++++++++++++++ .../ventaboletos/entidad/Boleto.java | 49 +++++++++++++------ .../entidad/DispositivoEmbarcada.java | 17 ++++--- .../ventaboletos/service/BoletoService.java | 16 ++++++ .../service/impl/BoletoServiceImpl.java | 28 +++++++++++ 6 files changed, 146 insertions(+), 23 deletions(-) create mode 100644 src/com/rjconsultores/ventaboletos/dao/BoletoDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/dao/hibernate/BoletoHibernateDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/service/BoletoService.java create mode 100644 src/com/rjconsultores/ventaboletos/service/impl/BoletoServiceImpl.java diff --git a/src/com/rjconsultores/ventaboletos/dao/BoletoDAO.java b/src/com/rjconsultores/ventaboletos/dao/BoletoDAO.java new file mode 100644 index 000000000..26369ecc7 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/BoletoDAO.java @@ -0,0 +1,17 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.dao; + +import com.rjconsultores.ventaboletos.entidad.Boleto; + +/** + * + * @author Fabricio + */ + +public interface BoletoDAO extends GenericDAO { + public Boleto buscarPeloImeiDoDispositivo(String imei); + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/BoletoHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/BoletoHibernateDAO.java new file mode 100644 index 000000000..cfb71fd40 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/BoletoHibernateDAO.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 org.hibernate.Criteria; +import org.hibernate.SessionFactory; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Repository; + +import com.rjconsultores.ventaboletos.dao.BoletoDAO; +import com.rjconsultores.ventaboletos.entidad.Boleto; + +/** + * + * @author Fabricio + */ +@Repository("boletoDAO") +public class BoletoHibernateDAO extends GenericHibernateDAO implements BoletoDAO { + + @Autowired + public BoletoHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + + public Boleto buscarPeloImeiDoDispositivo(String imei) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("imeiDispositivoEmbarcada", imei)); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.addOrder(Order.desc("fechorventa")); + c.setFirstResult(0); + c.setMaxResults(1); + + return (Boleto) c.uniqueResult(); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/Boleto.java b/src/com/rjconsultores/ventaboletos/entidad/Boleto.java index 192441732..7f18b1838 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/Boleto.java +++ b/src/com/rjconsultores/ventaboletos/entidad/Boleto.java @@ -6,6 +6,9 @@ import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToOne; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; @@ -44,8 +47,9 @@ public class Boleto implements java.io.Serializable { @Column(name = "DESTINO_ID", precision = 7, scale = 0) private Integer destinoId; - @Column(name = "PUNTOVENTA_ID", precision = 7, scale = 0) - private Integer puntoventaId; + @JoinColumn(name = "PUNTOVENTA_ID", referencedColumnName = "PUNTOVENTA_ID") + @ManyToOne + private PuntoVenta puntoVenta; @Column(name = "CORRIDA_ID", precision = 7, scale = 0) private Integer corridaId; @@ -196,8 +200,9 @@ public class Boleto implements java.io.Serializable { @Column(name = "FECMODIF", length = 7) private Date fecmodif; - @Column(name = "USUARIO_ID", precision = 7, scale = 0) - private Integer usuarioId; + @OneToOne + @JoinColumn(name = "USUARIO_ID", referencedColumnName = "USUARIO_ID") + private Usuario usuario; @Column(name = "NODO_ID", precision = 2, scale = 0) private Byte nodoId; @@ -313,6 +318,9 @@ public class Boleto implements java.io.Serializable { @Column(name = "ESTADOCIVIL_ID", precision = 2, scale = 0) private Byte estadocivilId; + + @Column(name = "IMEI_DISPOSITIVO_EMBARCADA", length = 20) + private String imeiDispositivoEmbarcada; public Boleto() { } @@ -322,7 +330,7 @@ public class Boleto implements java.io.Serializable { } public Boleto(long boletoId, String numasiento, Integer categoriaId, String numfoliosistema, Byte claseservicioId, - Short marcaId, Integer origenId, Integer destinoId, Integer puntoventaId, Integer corridaId, + Short marcaId, Integer origenId, Integer destinoId, PuntoVenta puntoVenta, Integer corridaId, Date feccorrida, String nombpasajero, BigDecimal preciobase, BigDecimal preciopagado, BigDecimal descuentoamparado, Byte tipoventaId, String numseriepreimpresa, String numfoliopreimpreso, Date fechorviaje, Date fechorventa, BigDecimal numkmviaje, String numoperacion, String indstatusoperacion, @@ -334,7 +342,7 @@ public class Boleto implements java.io.Serializable { Long clientefidelidadId, Integer opcional1, Integer opcional2, String opcional3, BigDecimal preciocargoextra, BigDecimal porccategoria, BigDecimal preciopricing, Integer usuarioremotoId, Integer puntoventaremotoId, Byte canttransferencia, String numdocdescuento, Boolean activo, Date fecmodif, - Integer usuarioId, Byte nodoId, Long entregaboletoId, BigDecimal importecategoria, Integer clienteId, + Usuario usuario, Byte nodoId, Long entregaboletoId, BigDecimal importecategoria, Integer clienteId, Long boletooriginalId, BigDecimal importetaxaembarque, BigDecimal importepedagio, BigDecimal importeoutros, BigDecimal importeseguro, String descorgaodoc, String desctipodoc, String descnumdoc, String numfidelidad, String infopasajero, Boolean indconexion, Integer rutaId, Integer levanteId, @@ -351,7 +359,7 @@ public class Boleto implements java.io.Serializable { this.marcaId = marcaId; this.origenId = origenId; this.destinoId = destinoId; - this.puntoventaId = puntoventaId; + this.puntoVenta = puntoVenta; this.corridaId = corridaId; this.feccorrida = feccorrida; this.nombpasajero = nombpasajero; @@ -400,7 +408,7 @@ public class Boleto implements java.io.Serializable { this.numdocdescuento = numdocdescuento; this.activo = activo; this.fecmodif = fecmodif; - this.usuarioId = usuarioId; + this.usuario = usuario; this.nodoId = nodoId; this.entregaboletoId = entregaboletoId; this.importecategoria = importecategoria; @@ -505,12 +513,12 @@ public class Boleto implements java.io.Serializable { this.destinoId = destinoId; } - public Integer getPuntoventaId() { - return this.puntoventaId; + public PuntoVenta getPuntoVenta() { + return puntoVenta; } - public void setPuntoventaId(Integer puntoventaId) { - this.puntoventaId = puntoventaId; + public void setPuntoVenta(PuntoVenta puntoVenta) { + this.puntoVenta = puntoVenta; } public Integer getCorridaId() { @@ -897,12 +905,13 @@ public class Boleto implements java.io.Serializable { this.fecmodif = fecmodif; } - public Integer getUsuarioId() { - return this.usuarioId; + + public Usuario getUsuario() { + return usuario; } - public void setUsuarioId(Integer usuarioId) { - this.usuarioId = usuarioId; + public void setUsuario(Usuario usuario) { + this.usuario = usuario; } public Byte getNodoId() { @@ -1209,4 +1218,12 @@ public class Boleto implements java.io.Serializable { this.estadocivilId = estadocivilId; } + public String getImeiDispositivoEmbarcada() { + return imeiDispositivoEmbarcada; + } + + public void setImeiDispositivoEmbarcada(String imeiDispositivoEmbarcada) { + this.imeiDispositivoEmbarcada = imeiDispositivoEmbarcada; + } + } diff --git a/src/com/rjconsultores/ventaboletos/entidad/DispositivoEmbarcada.java b/src/com/rjconsultores/ventaboletos/entidad/DispositivoEmbarcada.java index c28bfcf74..98801dc77 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/DispositivoEmbarcada.java +++ b/src/com/rjconsultores/ventaboletos/entidad/DispositivoEmbarcada.java @@ -15,6 +15,7 @@ import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; +import javax.persistence.OneToOne; import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.persistence.Temporal; @@ -62,8 +63,9 @@ public class DispositivoEmbarcada { @Column(name = "FECMODIF") @Temporal(TemporalType.TIMESTAMP) private Date fecmodif; - @Column(name = "USUARIO_ID") - private Integer usuarioId; + @OneToOne + @JoinColumn(name = "USUARIO_ID", referencedColumnName = "USUARIO_ID") + private Usuario usuario; @OneToMany(mappedBy="dispositivoEmbarcada", cascade = CascadeType.ALL, fetch = FetchType.EAGER) private List series = new ArrayList(); @@ -159,12 +161,13 @@ public class DispositivoEmbarcada { public void setFecmodif(Date fecmodif) { this.fecmodif = fecmodif; } - public Integer getUsuarioId() { - return usuarioId; + + public Usuario getUsuario() { + return usuario; + } + public void setUsuario(Usuario usuario) { + this.usuario = usuario; } - public void setUsuarioId(Integer usuarioId) { - this.usuarioId = usuarioId; - } public List getSeries() { return series; } diff --git a/src/com/rjconsultores/ventaboletos/service/BoletoService.java b/src/com/rjconsultores/ventaboletos/service/BoletoService.java new file mode 100644 index 000000000..2dd1daf7e --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/BoletoService.java @@ -0,0 +1,16 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.service; + +import com.rjconsultores.ventaboletos.entidad.Boleto; + +/** + * + * @author Fabricio + */ +public interface BoletoService { + + public Boleto buscarPeloImeiDoDispositivo(String imei); +} \ No newline at end of file diff --git a/src/com/rjconsultores/ventaboletos/service/impl/BoletoServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/BoletoServiceImpl.java new file mode 100644 index 000000000..ebf378b92 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/BoletoServiceImpl.java @@ -0,0 +1,28 @@ +/* + * 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.BoletoDAO; +import com.rjconsultores.ventaboletos.entidad.Boleto; +import com.rjconsultores.ventaboletos.service.BoletoService; + +/** + * + * @author Fabricio + */ +@Service("boletoService") +public class BoletoServiceImpl implements BoletoService { + + @Autowired + private BoletoDAO boletoDAO; + + public Boleto buscarPeloImeiDoDispositivo(String imei) { + return boletoDAO.buscarPeloImeiDoDispositivo(imei); + } + +}