Merge pull request 'Consulta e Legalização de Voucher feat bug#AL-4249' (!240) from AL-4279 into master
Reviewed-on: adm/ModelWeb#240 Reviewed-by: pinheiro <valdevir@rjconsultores.com.br>master
commit
8e35145d8e
2
pom.xml
2
pom.xml
|
@ -3,7 +3,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>br.com.rjconsultores</groupId>
|
<groupId>br.com.rjconsultores</groupId>
|
||||||
<artifactId>ModelWeb</artifactId>
|
<artifactId>ModelWeb</artifactId>
|
||||||
<version>1.89.0</version>
|
<version>1.90.0</version>
|
||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
<repository>
|
<repository>
|
||||||
|
|
|
@ -5,13 +5,37 @@ import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
@Target(ElementType.FIELD)
|
/**
|
||||||
|
* Anotação para marcar campos que devem ser renderizados e utilizados no Render Padrão {@link RenderPadrao}.
|
||||||
|
*
|
||||||
|
* A anotação permite configurar um conversor personalizado e especificar a posição de ordenação dos campos.
|
||||||
|
*/
|
||||||
|
@Target(ElementType.FIELD)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface Renderizado{
|
public @interface Renderizado {
|
||||||
Class<? extends Enum<?>> conversor() default DefaultEnum.class;
|
|
||||||
|
/**
|
||||||
String metodoConversor() default "buscarPeloValor";
|
* Define a classe do conversor que será usado para converter o valor do campo.
|
||||||
|
*
|
||||||
enum DefaultEnum{
|
* @return A classe Enum do conversor que deve obrigatoriamente
|
||||||
}
|
* implementar o um metodo String buscarPeloValor( String valor).
|
||||||
|
*/
|
||||||
|
Class<? extends Enum<?>> conversor() default DefaultEnum.class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define o nome do método do conversor que será chamado para converter o valor do campo.
|
||||||
|
*
|
||||||
|
* @return O nome do método do conversor. O padrão é "buscarPeloValor".
|
||||||
|
*/
|
||||||
|
String metodoConversor() default "buscarPeloValor";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define a posição de ordenação do campo. Campos com valores menores são ordenados primeiro.
|
||||||
|
*
|
||||||
|
* @return A posição numerica de ordenação do campo .
|
||||||
|
*/
|
||||||
|
int posicao() default Integer.MAX_VALUE;
|
||||||
|
|
||||||
|
enum DefaultEnum {
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.rjconsultores.ventaboletos.dao;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Voucher;
|
||||||
|
|
||||||
|
public interface VoucherDAO extends GenericDAO<Voucher, Long> {
|
||||||
|
|
||||||
|
public List<Voucher> buscarConsulta(Long voucherId, String numContrato, String nit, String nomeTransportadora, Date dataInicial, Date dataFinal, Integer origemId, Integer destinoId);
|
||||||
|
|
||||||
|
}
|
|
@ -7,10 +7,9 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.dao.GenericDAO;
|
|
||||||
|
|
||||||
import org.hibernate.Criteria;
|
import org.hibernate.Criteria;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.Query;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.criterion.Criterion;
|
import org.hibernate.criterion.Criterion;
|
||||||
import org.hibernate.criterion.Projections;
|
import org.hibernate.criterion.Projections;
|
||||||
|
@ -24,6 +23,8 @@ import org.hibernate.loader.criteria.CriteriaLoader;
|
||||||
import org.hibernate.persister.entity.OuterJoinLoadable;
|
import org.hibernate.persister.entity.OuterJoinLoadable;
|
||||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.dao.GenericDAO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author gleimar
|
* @author gleimar
|
||||||
|
|
|
@ -0,0 +1,165 @@
|
||||||
|
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hibernate.Criteria;
|
||||||
|
import org.hibernate.Query;
|
||||||
|
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;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.dao.VoucherDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Voucher;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Repository("voucherDAO")
|
||||||
|
public class VoucherHibernateDAO extends GenericHibernateDAO<Voucher, Long> implements VoucherDAO {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public VoucherHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||||
|
setSessionFactory(factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Voucher> obtenerTodos() {
|
||||||
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
|
c.add(Restrictions.eq(ACTIVO, Boolean.TRUE));
|
||||||
|
|
||||||
|
return c.list();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Voucher> buscarConsulta(Long voucherId,
|
||||||
|
String numContrato,
|
||||||
|
String nit,
|
||||||
|
String nomeTransportadora,
|
||||||
|
Date dataInicial,
|
||||||
|
Date dataFinal,
|
||||||
|
Integer origemId,
|
||||||
|
Integer destinoId) {
|
||||||
|
|
||||||
|
StringBuilder hql = new StringBuilder();
|
||||||
|
hql.append("SELECT v, ori.descParada AS descOrigem , des.descParada AS descDestino ");
|
||||||
|
hql.append("FROM Voucher v ");
|
||||||
|
|
||||||
|
setJoins( numContrato,
|
||||||
|
nit,
|
||||||
|
nomeTransportadora,
|
||||||
|
hql);
|
||||||
|
|
||||||
|
hql.append("WHERE v.activo = 1 ");
|
||||||
|
|
||||||
|
setClausulas(voucherId,
|
||||||
|
numContrato,
|
||||||
|
nit,
|
||||||
|
nomeTransportadora,
|
||||||
|
dataInicial,
|
||||||
|
dataFinal,
|
||||||
|
origemId,
|
||||||
|
destinoId,
|
||||||
|
hql);
|
||||||
|
|
||||||
|
hql.append("ORDER BY voucherId ");
|
||||||
|
|
||||||
|
Query query = getSession().createQuery(hql.toString());
|
||||||
|
|
||||||
|
setParametros(voucherId,
|
||||||
|
numContrato,
|
||||||
|
nit,
|
||||||
|
nomeTransportadora,
|
||||||
|
dataInicial,
|
||||||
|
dataFinal,
|
||||||
|
origemId,
|
||||||
|
destinoId,
|
||||||
|
query);
|
||||||
|
|
||||||
|
return query.list();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setJoins(String numContrato, String nit, String nomeTransportadora, StringBuilder hql) {
|
||||||
|
hql.append("LEFT JOIN Parada ori ON v.origenId = ori.origenId ");
|
||||||
|
hql.append("LEFT JOIN Parada des ON v.origenId = des.origenId ");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setClausulas(Long voucherId, String numContrato, String nit, String nomeTransportadora,
|
||||||
|
Date dataInicial, Date dataFinal, Integer origemId, Integer destinoId, StringBuilder hql) {
|
||||||
|
if(voucherId != null ){
|
||||||
|
hql.append(" AND v.voucherId = :voucherId ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(numContrato != null ){
|
||||||
|
hql.append(" AND v.voucherId = :voucherId ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(nit != null ){
|
||||||
|
hql.append(" AND v.voucherId = :voucherId ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(nomeTransportadora != null ){
|
||||||
|
hql.append(" AND v.voucherId = :voucherId ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dataInicial != null ){
|
||||||
|
hql.append(" AND v.dataValidade >= :dataInicial ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dataFinal != null ){
|
||||||
|
hql.append(" AND v.dataValidade <= :dataFinal ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(origemId != null ){
|
||||||
|
hql.append(" AND v.origenId = :origemId ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(destinoId != null ){
|
||||||
|
hql.append(" AND v.destinoId = :destinoId ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setParametros(Long voucherId,
|
||||||
|
String numContrato,
|
||||||
|
String nit,
|
||||||
|
String nomeTransportadora,
|
||||||
|
Date dataInicial,
|
||||||
|
Date dataFinal,
|
||||||
|
Integer origemId,
|
||||||
|
Integer destinoId,
|
||||||
|
Query query) {
|
||||||
|
|
||||||
|
if(voucherId != null ){
|
||||||
|
query.setLong("voucherId", voucherId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(numContrato != null ){
|
||||||
|
query.setString("numContrato", numContrato);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(nit != null ){
|
||||||
|
query.setString("nit", nit);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(nomeTransportadora != null ){
|
||||||
|
query.setString("nomeTransportadora", nomeTransportadora);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dataInicial != null ){
|
||||||
|
query.setDate("dataInicial", dataInicial);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dataFinal != null ){
|
||||||
|
query.setDate("dataFinal", dataFinal);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(origemId != null ){
|
||||||
|
query.setInteger("origemId", origemId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(destinoId != null ){
|
||||||
|
query.setInteger("destinoId", destinoId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -165,5 +165,10 @@ public class ContratoCorporativo implements Serializable {
|
||||||
hash = 59 * hash + (this.getContratoId() != null ? this.getContratoId().hashCode() : 0);
|
hash = 59 * hash + (this.getContratoId() != null ? this.getContratoId().hashCode() : 0);
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.getContratoId().toString();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -61,5 +61,13 @@ public class Transportadora implements Serializable{
|
||||||
@Column(name = "FECMODIF")
|
@Column(name = "FECMODIF")
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Date fecModif;
|
private Date fecModif;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return nomeTransportadora;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Transportadora(String nomeTransportadora) {
|
||||||
|
this.nomeTransportadora = nomeTransportadora;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,144 @@
|
||||||
|
package com.rjconsultores.ventaboletos.entidad;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import javax.persistence.Basic;
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.OneToOne;
|
||||||
|
import javax.persistence.SequenceGenerator;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.persistence.Temporal;
|
||||||
|
import javax.persistence.TemporalType;
|
||||||
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.anotacao.Renderizado;
|
||||||
|
import com.rjconsultores.ventaboletos.enums.SituacaoVoucher;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Entity
|
||||||
|
@SequenceGenerator(name = "VOUCHER_SEQ", sequenceName = "VOUCHER_SEQ", allocationSize = 1)
|
||||||
|
@Table(name = "VOUCHER")
|
||||||
|
public class Voucher implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -3684489881654368314L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Basic(optional = false)
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO, generator = "VOUCHER_SEQ")
|
||||||
|
@Renderizado( posicao = 1)
|
||||||
|
@Column(name = "VOUCHER_ID")
|
||||||
|
private Long voucherId;
|
||||||
|
|
||||||
|
@OneToOne(fetch = FetchType.LAZY)
|
||||||
|
@JoinColumn(name = "CONTRATO_ID")
|
||||||
|
@Renderizado( posicao = 2)
|
||||||
|
private ContratoCorporativo contrato;
|
||||||
|
|
||||||
|
@Column(name = "NOME_PASSAGEIRO", length = 150)
|
||||||
|
private String nomePassageiro;
|
||||||
|
|
||||||
|
@Column(name = "NUM_FATURA", length = 30)
|
||||||
|
private String numFatura;
|
||||||
|
|
||||||
|
@Column(name = "VALOR_LICITADO")
|
||||||
|
@Renderizado( posicao = 5 )
|
||||||
|
private BigDecimal valorLicitado;
|
||||||
|
|
||||||
|
@Renderizado( posicao = 6)
|
||||||
|
@Column(name = "VALOR_LEGALIZADO")
|
||||||
|
private BigDecimal valorLegalizado;
|
||||||
|
|
||||||
|
@Renderizado( posicao = 4)
|
||||||
|
@Column(name = "DATA_VALIDADE")
|
||||||
|
private Date dataValidade;
|
||||||
|
|
||||||
|
@Column(name = "DATA_INCLUSAO")
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
private Date dataInclusao;
|
||||||
|
|
||||||
|
@Column(name = "ORIGEN_ID")
|
||||||
|
private Integer origenId;
|
||||||
|
|
||||||
|
@Column(name = "DESTINO_ID")
|
||||||
|
private Integer destinoId;
|
||||||
|
|
||||||
|
@Column(name = "CLASESERVICIO_ID")
|
||||||
|
private Long claseServicioId;
|
||||||
|
|
||||||
|
@Column(name = "STATUS")
|
||||||
|
@Renderizado( conversor = SituacaoVoucher.class, posicao = 3)
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Column(name = "CLIENTECORPORATIVO_ID")
|
||||||
|
private Long clienteCorporativoId;
|
||||||
|
|
||||||
|
@Column(name = "MOTIVOCANCELACION_ID")
|
||||||
|
private Long motivoCancelacionId;
|
||||||
|
|
||||||
|
@Column(name = "GRUPOCONTRATO_ID")
|
||||||
|
private Long grupoContratoId;
|
||||||
|
|
||||||
|
@OneToOne(fetch = FetchType.LAZY)
|
||||||
|
@JoinColumn(name = "TRANSPORTADORA_ID")
|
||||||
|
private Transportadora transportadora;
|
||||||
|
|
||||||
|
@Column(name = "ACTIVO")
|
||||||
|
private boolean activo;
|
||||||
|
|
||||||
|
@Column(name = "FECMODIF")
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
private Date fecModif;
|
||||||
|
|
||||||
|
@Column(name = "USUARIO_ID")
|
||||||
|
private Integer usuarioId;
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
@Renderizado( posicao = 7 )
|
||||||
|
private transient String descOrigem;
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
@Renderizado( posicao = 8 )
|
||||||
|
private String descDestino;
|
||||||
|
|
||||||
|
public SituacaoVoucher getSituacaoVoucher() {
|
||||||
|
return SituacaoVoucher.buscarPeloValor(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Voucher other = (Voucher) obj;
|
||||||
|
return this.getVoucherId().equals(other.getVoucherId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int hash = 7;
|
||||||
|
hash = 59 * hash + (this.getVoucherId() != null ? this.getVoucherId().hashCode() : 0);
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.rjconsultores.ventaboletos.enums;
|
||||||
|
|
||||||
|
import org.zkoss.util.resource.Labels;
|
||||||
|
|
||||||
|
public enum SituacaoVoucher {
|
||||||
|
|
||||||
|
EMITIDO(0,Labels.getLabel("label.situacaoVoucher.emitido")),
|
||||||
|
LEGALIZADO(1,Labels.getLabel("label.situacaoVoucher.legalizado")),
|
||||||
|
FATURADO(2,Labels.getLabel("label.situacaoVoucher.faturado")),
|
||||||
|
CANCELADO(3,Labels.getLabel("label.situacaoVoucher.cancelado")),
|
||||||
|
;
|
||||||
|
|
||||||
|
private Integer valor;
|
||||||
|
private String descricao;
|
||||||
|
|
||||||
|
private SituacaoVoucher(Integer valor, String descricao) {
|
||||||
|
this.valor = valor;
|
||||||
|
this.descricao = descricao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescricao() {
|
||||||
|
return descricao;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getDescricao();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getValor() {
|
||||||
|
return valor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SituacaoVoucher buscarPeloValor(Integer valor) {
|
||||||
|
|
||||||
|
for (SituacaoVoucher tipo : SituacaoVoucher.values()) {
|
||||||
|
if (tipo.getValor().equals(valor)) {
|
||||||
|
return tipo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SituacaoVoucher buscarPeloValor(String valor) {
|
||||||
|
return buscarPeloValor( Integer.valueOf(valor));
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ public enum TipoLancamentoCaixa {
|
||||||
BILHETE_CONFIRMADO(4,Labels.getLabel("label.tipoLancamento.bilheteConfirmado"), false),
|
BILHETE_CONFIRMADO(4,Labels.getLabel("label.tipoLancamento.bilheteConfirmado"), false),
|
||||||
BILHETE_ABERTO(5,Labels.getLabel("label.tipoLancamento.bilheteAberto"), false),
|
BILHETE_ABERTO(5,Labels.getLabel("label.tipoLancamento.bilheteAberto"), false),
|
||||||
EVENTO_EXTRA(6,Labels.getLabel("label.tipoLancamento.eventoExtra"), false),
|
EVENTO_EXTRA(6,Labels.getLabel("label.tipoLancamento.eventoExtra"), false),
|
||||||
|
VOUCHER(7,Labels.getLabel("label.tipoLancamento.voucher"), false),
|
||||||
;
|
;
|
||||||
|
|
||||||
private Integer valor;
|
private Integer valor;
|
||||||
|
|
|
@ -8,7 +8,7 @@ import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||||
|
|
||||||
public interface ConvenioTransportadoraService extends GenericService<ConvenioTransportadora, Long> {
|
public interface ConvenioTransportadoraService extends GenericService<ConvenioTransportadora, Long> {
|
||||||
|
|
||||||
ConvenioTransportadora buscarPelaTransportadoraId(Long transportadoraId);
|
public ConvenioTransportadora buscarPelaTransportadoraId(Long transportadoraId);
|
||||||
|
|
||||||
public ConvenioTransportadora suscribirActualizar(ConvenioTransportadora convenio) throws BusinessException;
|
public ConvenioTransportadora suscribirActualizar(ConvenioTransportadora convenio) throws BusinessException;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.rjconsultores.ventaboletos.service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Voucher;
|
||||||
|
|
||||||
|
public interface VoucherService extends GenericService<Voucher, Long> {
|
||||||
|
|
||||||
|
List<Voucher> buscarConsulta(Long voucherId, String numContrato, String nit, String nomeTransportadora, Date dataInicial, Date dataFinal, Integer origemId, Integer destinoId);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.rjconsultores.ventaboletos.service.impl;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.dao.VoucherDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Voucher;
|
||||||
|
import com.rjconsultores.ventaboletos.service.VoucherService;
|
||||||
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||||
|
|
||||||
|
@Service("voucherService")
|
||||||
|
public class VoucherServiceImpl implements VoucherService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private VoucherDAO voucherDAO;
|
||||||
|
|
||||||
|
public List<Voucher> obtenerTodos() {
|
||||||
|
return voucherDAO.obtenerTodos();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Voucher obtenerID(Long id) {
|
||||||
|
return voucherDAO.obtenerID(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public Voucher suscribir(Voucher entidad) {
|
||||||
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
entidad.setFecModif(Calendar.getInstance().getTime());
|
||||||
|
entidad.setActivo(Boolean.TRUE);
|
||||||
|
|
||||||
|
return voucherDAO.suscribir(entidad);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public Voucher actualizacion(Voucher entidad) {
|
||||||
|
return voucherDAO.actualizacion(entidad);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void borrar(Voucher entidad) {
|
||||||
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
entidad.setFecModif(Calendar.getInstance().getTime());
|
||||||
|
entidad.setActivo(Boolean.FALSE);
|
||||||
|
|
||||||
|
voucherDAO.actualizacion(entidad);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Voucher> buscarConsulta(Long voucherId,
|
||||||
|
String numContrato,
|
||||||
|
String nit,
|
||||||
|
String nomeTransportadora,
|
||||||
|
Date dataInicial,
|
||||||
|
Date dataFinal,
|
||||||
|
Integer origemId,
|
||||||
|
Integer destinoId) {
|
||||||
|
return voucherDAO.buscarConsulta(voucherId,
|
||||||
|
numContrato,
|
||||||
|
nit,
|
||||||
|
nomeTransportadora,
|
||||||
|
dataInicial,
|
||||||
|
dataFinal,
|
||||||
|
origemId,
|
||||||
|
destinoId);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue