Série para venda embarcada
bug#13748 dev:trevezani qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@91259 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
b432310fca
commit
fa89b8a1ec
|
@ -1,9 +1,12 @@
|
||||||
package com.rjconsultores.ventaboletos.dao;
|
package com.rjconsultores.ventaboletos.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.entidad.CtrlSerieEmbarcada;
|
import com.rjconsultores.ventaboletos.entidad.CtrlSerieEmbarcada;
|
||||||
import com.rjconsultores.ventaboletos.entidad.DispositivoEmbarcada;
|
import com.rjconsultores.ventaboletos.entidad.DispositivoEmbarcada;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Estado;
|
import com.rjconsultores.ventaboletos.entidad.Estado;
|
||||||
|
import com.rjconsultores.ventaboletos.vo.embarcada.SerieEmbarcada;
|
||||||
|
|
||||||
public interface CtrlSerieEmbarcadaDAO extends GenericDAO<CtrlSerieEmbarcada, Long> {
|
public interface CtrlSerieEmbarcadaDAO extends GenericDAO<CtrlSerieEmbarcada, Long> {
|
||||||
|
|
||||||
|
@ -11,5 +14,6 @@ public interface CtrlSerieEmbarcadaDAO extends GenericDAO<CtrlSerieEmbarcada, L
|
||||||
public CtrlSerieEmbarcada actualizacion(CtrlSerieEmbarcada entity);
|
public CtrlSerieEmbarcada actualizacion(CtrlSerieEmbarcada entity);
|
||||||
|
|
||||||
public Boolean validaDispositivoEmpresaEstadoCadastrado(DispositivoEmbarcada dispositivo, Empresa empresa, Estado estado);
|
public Boolean validaDispositivoEmpresaEstadoCadastrado(DispositivoEmbarcada dispositivo, Empresa empresa, Estado estado);
|
||||||
|
public List<SerieEmbarcada> buscarSeriesReaproveitar(final Integer empresaId, final Integer estadoId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.hibernate.transform.AliasToBeanResultTransformer;
|
||||||
|
import org.hibernate.type.LongType;
|
||||||
|
import org.hibernate.type.StringType;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -15,6 +20,7 @@ import com.rjconsultores.ventaboletos.entidad.CtrlSerieEmbarcada;
|
||||||
import com.rjconsultores.ventaboletos.entidad.DispositivoEmbarcada;
|
import com.rjconsultores.ventaboletos.entidad.DispositivoEmbarcada;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Estado;
|
import com.rjconsultores.ventaboletos.entidad.Estado;
|
||||||
|
import com.rjconsultores.ventaboletos.vo.embarcada.SerieEmbarcada;
|
||||||
|
|
||||||
@Repository("ctrlSerieEmbarcadaDAO")
|
@Repository("ctrlSerieEmbarcadaDAO")
|
||||||
public class CtrlSerieEmbarcadaHibernateDAO extends GenericHibernateDAO<CtrlSerieEmbarcada, Long> implements CtrlSerieEmbarcadaDAO {
|
public class CtrlSerieEmbarcadaHibernateDAO extends GenericHibernateDAO<CtrlSerieEmbarcada, Long> implements CtrlSerieEmbarcadaDAO {
|
||||||
|
@ -48,11 +54,11 @@ public class CtrlSerieEmbarcadaHibernateDAO extends GenericHibernateDAO<CtrlSer
|
||||||
|
|
||||||
public Boolean validaDispositivoEmpresaEstadoCadastrado(DispositivoEmbarcada dispositivo, Empresa empresa, Estado estado) {
|
public Boolean validaDispositivoEmpresaEstadoCadastrado(DispositivoEmbarcada dispositivo, Empresa empresa, Estado estado) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("select COUNT(se.ctrlSerieEmbarcadaId) ");
|
sb.append("select count(se.ctrlSerieEmbarcadaId) ");
|
||||||
sb.append("from CtrlSerieEmbarcada se ");
|
sb.append("from CtrlSerieEmbarcada se ");
|
||||||
sb.append("where se.activo = 1 ");
|
sb.append("where se.activo = 1 and se.indBaixado = 0 ");
|
||||||
sb.append("and se.dispositivoEmbarcada.dispositivoEmbarcadaId = :dispositivoEmbarcadaId ");
|
sb.append("and se.dispositivoEmbarcada.dispositivoEmbarcadaId = :dispositivoEmbarcadaId ");
|
||||||
sb.append("and se.empresaId = :empresaId ");
|
sb.append("and se.empresa.empresaId = :empresaId ");
|
||||||
sb.append("and se.estado.estadoId = :estadoId ");
|
sb.append("and se.estado.estadoId = :estadoId ");
|
||||||
|
|
||||||
Query qry = getSession().createQuery(sb.toString());
|
Query qry = getSession().createQuery(sb.toString());
|
||||||
|
@ -68,4 +74,25 @@ public class CtrlSerieEmbarcadaHibernateDAO extends GenericHibernateDAO<CtrlSer
|
||||||
|
|
||||||
return n.longValue() > 0;
|
return n.longValue() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public List<SerieEmbarcada> buscarSeriesReaproveitar(final Integer empresaId, final Integer estadoId) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("select se.ctrlserieembarcada_id as ctrlSerieEmbarcadaId, se.serie as serie, se.numerocorrente + 1 as numero ");
|
||||||
|
sb.append("from ctrl_serie_embarcada se ");
|
||||||
|
sb.append("left join ctrl_serie_embarcada seq on seq.ctrlserieembarcadaseq_id = se.ctrlserieembarcada_id ");
|
||||||
|
sb.append("where se.activo = 1 and se.ind_baixado = 1 and seq.ctrlserieembarcada_id is null and se.empresa_id = :empresaId and se.estado_id = :estadoId ");
|
||||||
|
sb.append("order by se.serie ");
|
||||||
|
|
||||||
|
Query query = getSession().createSQLQuery(sb.toString())
|
||||||
|
.addScalar("ctrlSerieEmbarcadaId", LongType.INSTANCE)
|
||||||
|
.addScalar("serie", StringType.INSTANCE)
|
||||||
|
.addScalar("numero", StringType.INSTANCE)
|
||||||
|
.setResultTransformer(new AliasToBeanResultTransformer(SerieEmbarcada.class));
|
||||||
|
|
||||||
|
query.setInteger("empresaId", empresaId);
|
||||||
|
query.setInteger("estadoId", estadoId);
|
||||||
|
|
||||||
|
return query.list();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
|
import javax.persistence.OneToOne;
|
||||||
import javax.persistence.SequenceGenerator;
|
import javax.persistence.SequenceGenerator;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
|
@ -27,8 +28,9 @@ public class CtrlSerieEmbarcada {
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "DISPOSITIVOEMBARCADA_ID", referencedColumnName = "DISPOSITIVOEMBARCADA_ID")
|
@JoinColumn(name = "DISPOSITIVOEMBARCADA_ID", referencedColumnName = "DISPOSITIVOEMBARCADA_ID")
|
||||||
private DispositivoEmbarcada dispositivoEmbarcada;
|
private DispositivoEmbarcada dispositivoEmbarcada;
|
||||||
@Column(name = "EMPRESA_ID")
|
@OneToOne
|
||||||
private Long empresaId;
|
@JoinColumn(name = "EMPRESA_ID")
|
||||||
|
private Empresa empresa;
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "ESTADO_ID", referencedColumnName = "ESTADO_ID")
|
@JoinColumn(name = "ESTADO_ID", referencedColumnName = "ESTADO_ID")
|
||||||
private Estado estado;
|
private Estado estado;
|
||||||
|
@ -40,6 +42,8 @@ public class CtrlSerieEmbarcada {
|
||||||
private String numeroCorrente;
|
private String numeroCorrente;
|
||||||
@Column(name = "IND_BAIXADO")
|
@Column(name = "IND_BAIXADO")
|
||||||
private Boolean indBaixado;
|
private Boolean indBaixado;
|
||||||
|
@Column(name = "CTRLSERIEEMBARCADASEQ_ID")
|
||||||
|
private Long ctrlSerieEmbarcadaSeqId;
|
||||||
@Column(name = "ACTIVO")
|
@Column(name = "ACTIVO")
|
||||||
private Boolean activo;
|
private Boolean activo;
|
||||||
@Basic(optional = false)
|
@Basic(optional = false)
|
||||||
|
@ -49,69 +53,102 @@ public class CtrlSerieEmbarcada {
|
||||||
@Column(name = "USUARIO_ID")
|
@Column(name = "USUARIO_ID")
|
||||||
private Integer usuarioId;
|
private Integer usuarioId;
|
||||||
|
|
||||||
|
public CtrlSerieEmbarcada() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public Long getCtrlSerieEmbarcadaId() {
|
public Long getCtrlSerieEmbarcadaId() {
|
||||||
return ctrlSerieEmbarcadaId;
|
return ctrlSerieEmbarcadaId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCtrlSerieEmbarcadaId(Long ctrlSerieEmbarcadaId) {
|
public void setCtrlSerieEmbarcadaId(Long ctrlSerieEmbarcadaId) {
|
||||||
this.ctrlSerieEmbarcadaId = ctrlSerieEmbarcadaId;
|
this.ctrlSerieEmbarcadaId = ctrlSerieEmbarcadaId;
|
||||||
}
|
}
|
||||||
public DispositivoEmbarcada getDispositivoEmbarcadaId() {
|
|
||||||
|
public DispositivoEmbarcada getDispositivoEmbarcada() {
|
||||||
return dispositivoEmbarcada;
|
return dispositivoEmbarcada;
|
||||||
}
|
}
|
||||||
public void setDispositivoEmbarcadaId(DispositivoEmbarcada dispositivoEmbarcadaId) {
|
|
||||||
this.dispositivoEmbarcada = dispositivoEmbarcadaId;
|
public void setDispositivoEmbarcada(DispositivoEmbarcada dispositivoEmbarcada) {
|
||||||
|
this.dispositivoEmbarcada = dispositivoEmbarcada;
|
||||||
}
|
}
|
||||||
public Long getEmpresaId() {
|
|
||||||
return empresaId;
|
public Empresa getEmpresa() {
|
||||||
|
return empresa;
|
||||||
}
|
}
|
||||||
public void setEmpresaId(Long empresaId) {
|
|
||||||
this.empresaId = empresaId;
|
public void setEmpresa(Empresa empresa) {
|
||||||
|
this.empresa = empresa;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Estado getEstado() {
|
public Estado getEstado() {
|
||||||
return estado;
|
return estado;
|
||||||
}
|
}
|
||||||
public void setEstado(Estado estadoId) {
|
|
||||||
this.estado = estadoId;
|
public void setEstado(Estado estado) {
|
||||||
|
this.estado = estado;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSerie() {
|
public String getSerie() {
|
||||||
return serie;
|
return serie;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSerie(String serie) {
|
public void setSerie(String serie) {
|
||||||
this.serie = serie;
|
this.serie = serie;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNumeroInicial() {
|
public String getNumeroInicial() {
|
||||||
return numeroInicial;
|
return numeroInicial;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNumeroInicial(String numeroInicial) {
|
public void setNumeroInicial(String numeroInicial) {
|
||||||
this.numeroInicial = numeroInicial;
|
this.numeroInicial = numeroInicial;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNumeroCorrente() {
|
public String getNumeroCorrente() {
|
||||||
return numeroCorrente;
|
return numeroCorrente;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNumeroCorrente(String numeroCorrente) {
|
public void setNumeroCorrente(String numeroCorrente) {
|
||||||
this.numeroCorrente = numeroCorrente;
|
this.numeroCorrente = numeroCorrente;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getIndBaixado() {
|
public Boolean getIndBaixado() {
|
||||||
return indBaixado;
|
return indBaixado;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIndBaixado(Boolean indBaixado) {
|
public void setIndBaixado(Boolean indBaixado) {
|
||||||
this.indBaixado = indBaixado;
|
this.indBaixado = indBaixado;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getCtrlSerieEmbarcadaSeqId() {
|
||||||
|
return ctrlSerieEmbarcadaSeqId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCtrlSerieEmbarcadaSeqId(Long ctrlSerieEmbarcadaSeqId) {
|
||||||
|
this.ctrlSerieEmbarcadaSeqId = ctrlSerieEmbarcadaSeqId;
|
||||||
|
}
|
||||||
|
|
||||||
public Boolean getActivo() {
|
public Boolean getActivo() {
|
||||||
return activo;
|
return activo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActivo(Boolean activo) {
|
public void setActivo(Boolean activo) {
|
||||||
this.activo = activo;
|
this.activo = activo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getFecmodif() {
|
public Date getFecmodif() {
|
||||||
return fecmodif;
|
return fecmodif;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFecmodif(Date fecmodif) {
|
public void setFecmodif(Date fecmodif) {
|
||||||
this.fecmodif = fecmodif;
|
this.fecmodif = fecmodif;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getUsuarioId() {
|
public Integer getUsuarioId() {
|
||||||
return usuarioId;
|
return usuarioId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsuarioId(Integer usuarioId) {
|
public void setUsuarioId(Integer usuarioId) {
|
||||||
this.usuarioId = usuarioId;
|
this.usuarioId = usuarioId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ import com.rjconsultores.ventaboletos.web.utilerias.spring.AppContext;
|
||||||
@Entity
|
@Entity
|
||||||
@SequenceGenerator(name = "USUARIO_SEQ", sequenceName = "USUARIO_SEQ", allocationSize = 1)
|
@SequenceGenerator(name = "USUARIO_SEQ", sequenceName = "USUARIO_SEQ", allocationSize = 1)
|
||||||
@Table(name = "USUARIO")
|
@Table(name = "USUARIO")
|
||||||
public class Usuario implements Serializable, Authentication, UserDetails {
|
public class Usuario implements Serializable, UserDetails/*, Authentication*/ {
|
||||||
|
|
||||||
public final static int CANT_DIAS_CONTRASENA = 999;
|
public final static int CANT_DIAS_CONTRASENA = 999;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,11 @@
|
||||||
*/
|
*/
|
||||||
package com.rjconsultores.ventaboletos.service;
|
package com.rjconsultores.ventaboletos.service;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.CtrlSerieEmbarcada;
|
||||||
|
import com.rjconsultores.ventaboletos.vo.embarcada.SerieEmbarcada;
|
||||||
|
|
||||||
public interface ControleSerieEmbarcadaService {
|
public interface ControleSerieEmbarcadaService {
|
||||||
|
|
||||||
|
public SerieEmbarcada buscarSerieEmbarcada(CtrlSerieEmbarcada controleSerieEmbarcada);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
/*
|
|
||||||
* To change this template, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
package com.rjconsultores.ventaboletos.service.impl;
|
package com.rjconsultores.ventaboletos.service.impl;
|
||||||
|
|
||||||
|
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 com.rjconsultores.ventaboletos.dao.CtrlSerieBPeDAO;
|
import com.rjconsultores.ventaboletos.dao.CtrlSerieBPeDAO;
|
||||||
import com.rjconsultores.ventaboletos.dao.CtrlSerieEmbarcadaDAO;
|
import com.rjconsultores.ventaboletos.dao.CtrlSerieEmbarcadaDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.CtrlSerieEmbarcada;
|
||||||
import com.rjconsultores.ventaboletos.service.ControleSerieEmbarcadaService;
|
import com.rjconsultores.ventaboletos.service.ControleSerieEmbarcadaService;
|
||||||
|
import com.rjconsultores.ventaboletos.vo.embarcada.SerieEmbarcada;
|
||||||
|
|
||||||
@Service("controleSerieEmbarcadaService")
|
@Service("controleSerieEmbarcadaService")
|
||||||
public class ControleSerieEmbarcadaServiceImpl implements ControleSerieEmbarcadaService {
|
public class ControleSerieEmbarcadaServiceImpl implements ControleSerieEmbarcadaService {
|
||||||
|
@ -18,6 +18,21 @@ public class ControleSerieEmbarcadaServiceImpl implements ControleSerieEmbarcada
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CtrlSerieBPeDAO ctrlSerieBPeDAO;
|
private CtrlSerieBPeDAO ctrlSerieBPeDAO;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SerieEmbarcada buscarSerieEmbarcada(CtrlSerieEmbarcada controleSerieEmbarcada) {
|
||||||
|
SerieEmbarcada retorno = null;
|
||||||
|
|
||||||
|
List<SerieEmbarcada> listaSeries = ctrlSerieEmbarcadaDAO.buscarSeriesReaproveitar(controleSerieEmbarcada.getEmpresa().getEmpresaId(),
|
||||||
|
controleSerieEmbarcada.getEstado().getEstadoId());
|
||||||
|
|
||||||
|
for (SerieEmbarcada disponivel : listaSeries) {
|
||||||
|
if (retorno == null) {
|
||||||
|
retorno = disponivel;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return retorno;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.rjconsultores.ventaboletos.vo.embarcada;
|
||||||
|
|
||||||
|
public class SerieEmbarcada {
|
||||||
|
private Long ctrlSerieEmbarcadaId;
|
||||||
|
private String serie;
|
||||||
|
private String numero;
|
||||||
|
|
||||||
|
public SerieEmbarcada() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getCtrlSerieEmbarcadaId() {
|
||||||
|
return ctrlSerieEmbarcadaId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCtrlSerieEmbarcadaId(Long ctrlSerieEmbarcadaId) {
|
||||||
|
this.ctrlSerieEmbarcadaId = ctrlSerieEmbarcadaId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSerie() {
|
||||||
|
return serie;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSerie(String serie) {
|
||||||
|
this.serie = serie;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNumero() {
|
||||||
|
return numero;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumero(String numero) {
|
||||||
|
this.numero = numero;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "SerieEmbarcada [ctrlSerieEmbarcadaId=" + ctrlSerieEmbarcadaId + ", serie=" + serie + ", numero=" + numero + "]";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue