git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@28397 d1611594-4594-4d17-8e1d-87c2c4800839
parent
9bdb8f6700
commit
0669a03ca9
|
@ -4,13 +4,9 @@ import java.util.List;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.entidad.Cliente;
|
import com.rjconsultores.ventaboletos.entidad.Cliente;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public interface ClienteDAO extends GenericDAO<Cliente, Integer> {
|
public interface ClienteDAO extends GenericDAO<Cliente, Integer> {
|
||||||
|
|
||||||
public List<Cliente> buscar(String nombCliente);
|
public List<Cliente> buscar(String nombCliente);
|
||||||
|
|
||||||
|
public Cliente buscarPorNumeroFidelidade(Integer numeroFidelidade);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hibernate.Criteria;
|
import org.hibernate.Criteria;
|
||||||
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;
|
||||||
|
@ -14,9 +13,6 @@ import org.springframework.stereotype.Repository;
|
||||||
import com.rjconsultores.ventaboletos.dao.ClienteDAO;
|
import com.rjconsultores.ventaboletos.dao.ClienteDAO;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Cliente;
|
import com.rjconsultores.ventaboletos.entidad.Cliente;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Repository("clienteDAO")
|
@Repository("clienteDAO")
|
||||||
public class ClienteHibernateDAO extends GenericHibernateDAO<Cliente, Integer>
|
public class ClienteHibernateDAO extends GenericHibernateDAO<Cliente, Integer>
|
||||||
implements ClienteDAO {
|
implements ClienteDAO {
|
||||||
|
@ -41,10 +37,22 @@ public class ClienteHibernateDAO extends GenericHibernateDAO<Cliente, Integer>
|
||||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
c.add(Restrictions.eq("nombcliente", nombCliente));
|
c.add(Restrictions.eq("nombcliente", nombCliente));
|
||||||
|
|
||||||
|
|
||||||
return c.list();
|
return c.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Cliente buscarPorNumeroFidelidade(Integer numeroFidelidade) {
|
||||||
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
|
|
||||||
|
Criteria clienteFidelidad = null;
|
||||||
|
clienteFidelidad = c.createCriteria("listClienteFidelidad");
|
||||||
|
clienteFidelidad.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
|
|
||||||
|
Criteria tarjetaFidelidad = null;
|
||||||
|
tarjetaFidelidad = clienteFidelidad.createCriteria("tarjetaFidelidad");
|
||||||
|
tarjetaFidelidad.add(Restrictions.eq("numTarjeta", numeroFidelidade));
|
||||||
|
tarjetaFidelidad.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
|
|
||||||
|
return (Cliente) c.uniqueResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,20 +12,16 @@ import javax.persistence.Basic;
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.NamedQueries;
|
|
||||||
import javax.persistence.NamedQuery;
|
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.OneToOne;
|
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;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -34,108 +30,81 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||||
@Entity
|
@Entity
|
||||||
@SequenceGenerator(name = "CLIENTE_SEQ", sequenceName = "CLIENTE_SEQ", allocationSize = 1)
|
@SequenceGenerator(name = "CLIENTE_SEQ", sequenceName = "CLIENTE_SEQ", allocationSize = 1)
|
||||||
@Table(name = "CLIENTE")
|
@Table(name = "CLIENTE")
|
||||||
|
|
||||||
public class Cliente implements Serializable {
|
public class Cliente implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@Id
|
@Id
|
||||||
@Basic(optional = false)
|
@Basic(optional = false)
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO, generator = "CLIENTE_SEQ")
|
@GeneratedValue(strategy = GenerationType.AUTO, generator = "CLIENTE_SEQ")
|
||||||
@Column(name = "CLIENTE_ID")
|
@Column(name = "CLIENTE_ID")
|
||||||
private Integer clienteId;
|
private Integer clienteId;
|
||||||
|
|
||||||
@Column(name = "NOMBCLIENTE")
|
@Column(name = "NOMBCLIENTE")
|
||||||
private String nombcliente;
|
private String nombcliente;
|
||||||
|
|
||||||
@Column(name = "APELLIDOPATERNO")
|
@Column(name = "APELLIDOPATERNO")
|
||||||
private String apellidopaterno;
|
private String apellidopaterno;
|
||||||
|
|
||||||
@Column(name = "APELLIDOMATERNO")
|
@Column(name = "APELLIDOMATERNO")
|
||||||
private String apellidomaterno;
|
private String apellidomaterno;
|
||||||
|
|
||||||
@Column(name = "FECNACIMIENTO")
|
@Column(name = "FECNACIMIENTO")
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Date fecnacimiento;
|
private Date fecnacimiento;
|
||||||
|
|
||||||
@Column(name = "NUMRFC")
|
@Column(name = "NUMRFC")
|
||||||
private String numrfc;
|
private String numrfc;
|
||||||
|
|
||||||
@Column(name = "NUMTELEFONO")
|
@Column(name = "NUMTELEFONO")
|
||||||
private String numtelefono;
|
private String numtelefono;
|
||||||
|
|
||||||
@Column(name = "NUMTELEFONODOS")
|
@Column(name = "NUMTELEFONODOS")
|
||||||
private String numtelefonodos;
|
private String numtelefonodos;
|
||||||
|
|
||||||
@Column(name = "NUMFAX")
|
@Column(name = "NUMFAX")
|
||||||
private String numfax;
|
private String numfax;
|
||||||
|
|
||||||
@Column(name = "NUMEXTENSION")
|
@Column(name = "NUMEXTENSION")
|
||||||
private String numextension;
|
private String numextension;
|
||||||
|
|
||||||
@Column(name = "NUMEXTENSIONDOS")
|
@Column(name = "NUMEXTENSIONDOS")
|
||||||
private String numextensiondos;
|
private String numextensiondos;
|
||||||
|
|
||||||
|
|
||||||
@JoinColumn(name = "TIPOOCUPACION_ID")
|
@JoinColumn(name = "TIPOOCUPACION_ID")
|
||||||
@OneToOne(cascade = CascadeType.ALL)
|
@OneToOne(cascade = CascadeType.ALL)
|
||||||
private TipoOcupacion tipoocupacionId;
|
private TipoOcupacion tipoocupacionId;
|
||||||
|
|
||||||
@Column(name = "MEDIOINFORMATIVO_ID")
|
@Column(name = "MEDIOINFORMATIVO_ID")
|
||||||
private Integer medioinformativoId;
|
private Integer medioinformativoId;
|
||||||
|
|
||||||
|
|
||||||
@JoinColumn(name = "MOTIVOVIAJE_ID")
|
@JoinColumn(name = "MOTIVOVIAJE_ID")
|
||||||
@OneToOne(cascade = CascadeType.ALL)
|
@OneToOne(cascade = CascadeType.ALL)
|
||||||
private MotivoViaje motivoviajeId;
|
private MotivoViaje motivoviajeId;
|
||||||
|
|
||||||
@Column(name = "INDSEXO")
|
@Column(name = "INDSEXO")
|
||||||
private String indsexo;
|
private String indsexo;
|
||||||
|
|
||||||
@Column(name = "NUMCURP")
|
@Column(name = "NUMCURP")
|
||||||
private String numcurp;
|
private String numcurp;
|
||||||
|
|
||||||
@Column(name = "CANTHIJOS")
|
@Column(name = "CANTHIJOS")
|
||||||
private Integer canthijos;
|
private Integer canthijos;
|
||||||
|
|
||||||
@Column(name = "DESCCORREO")
|
@Column(name = "DESCCORREO")
|
||||||
private String desccorreo;
|
private String desccorreo;
|
||||||
|
|
||||||
@Column(name = "EDAD")
|
@Column(name = "EDAD")
|
||||||
private Integer edad;
|
private Integer edad;
|
||||||
|
|
||||||
@Column(name = "ESTADOCIVIL_ID")
|
@Column(name = "ESTADOCIVIL_ID")
|
||||||
private Integer estadocivilId;
|
private Integer estadocivilId;
|
||||||
|
|
||||||
@Column(name = "GRADOESTUDIO_ID")
|
@Column(name = "GRADOESTUDIO_ID")
|
||||||
private Integer gradoestudioId;
|
private Integer gradoestudioId;
|
||||||
|
|
||||||
@Column(name = "EQUIVALENCIA_ID")
|
@Column(name = "EQUIVALENCIA_ID")
|
||||||
private String equivalenciaId;
|
private String equivalenciaId;
|
||||||
|
|
||||||
@Column(name = "ACTIVO")
|
@Column(name = "ACTIVO")
|
||||||
private Boolean activo;
|
private Boolean activo;
|
||||||
|
|
||||||
@Column(name = "FECMODIF")
|
@Column(name = "FECMODIF")
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Date fecmodif;
|
private Date fecmodif;
|
||||||
|
|
||||||
@Column(name = "USUARIO_ID")
|
@Column(name = "USUARIO_ID")
|
||||||
private Integer usuarioId;
|
private Integer usuarioId;
|
||||||
|
|
||||||
@Column(name = "DESCCONTRASENA")
|
@Column(name = "DESCCONTRASENA")
|
||||||
private String desccontrasena;
|
private String desccontrasena;
|
||||||
|
|
||||||
@Column(name = "NUMLADA")
|
@Column(name = "NUMLADA")
|
||||||
private String numlada;
|
private String numlada;
|
||||||
|
|
||||||
@Column(name = "INDCAMBIOCONTRASENA")
|
@Column(name = "INDCAMBIOCONTRASENA")
|
||||||
private Integer indcambiocontrasena;
|
private Integer indcambiocontrasena;
|
||||||
|
|
||||||
|
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "clienteId")
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "clienteId")
|
||||||
private List<ClienteDireccion> lsClienteDireccion;
|
private List<ClienteDireccion> lsClienteDireccion;
|
||||||
|
@OneToMany(cascade = CascadeType.ALL)
|
||||||
|
@JoinColumn(name = "CLIENTE_ID", referencedColumnName = "CLIENTE_ID")
|
||||||
|
private List<ClienteFidelidad> listClienteFidelidad;
|
||||||
|
@Column(name = "NUMIDENTIFICAUNO")
|
||||||
|
private String numIdentificaUno;
|
||||||
|
@Column(name = "NUMIDENTIFICADOS")
|
||||||
|
private String numIdentificaDos;
|
||||||
|
|
||||||
public Cliente() {
|
public Cliente() {
|
||||||
}
|
}
|
||||||
|
@ -368,7 +337,6 @@ public class Cliente implements Serializable {
|
||||||
this.indcambiocontrasena = indcambiocontrasena;
|
this.indcambiocontrasena = indcambiocontrasena;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<ClienteDireccion> getLsClienteDireccion() {
|
public List<ClienteDireccion> getLsClienteDireccion() {
|
||||||
return lsClienteDireccion;
|
return lsClienteDireccion;
|
||||||
}
|
}
|
||||||
|
@ -377,6 +345,30 @@ public class Cliente implements Serializable {
|
||||||
this.lsClienteDireccion = lsClienteDireccion;
|
this.lsClienteDireccion = lsClienteDireccion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ClienteFidelidad> getListClienteFidelidad() {
|
||||||
|
return listClienteFidelidad;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setListClienteFidelidad(List<ClienteFidelidad> listClienteFidelidad) {
|
||||||
|
this.listClienteFidelidad = listClienteFidelidad;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNumIdentificaUno() {
|
||||||
|
return numIdentificaUno;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumIdentificaUno(String numIdentificaUno) {
|
||||||
|
this.numIdentificaUno = numIdentificaUno;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNumIdentificaDos() {
|
||||||
|
return numIdentificaDos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumIdentificaDos(String numIdentificaDos) {
|
||||||
|
this.numIdentificaDos = numIdentificaDos;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int hash = 0;
|
int hash = 0;
|
||||||
|
@ -386,7 +378,6 @@ public class Cliente implements Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object object) {
|
public boolean equals(Object object) {
|
||||||
// TODO: Warning - this method won't work in the case the id fields are not set
|
|
||||||
if (!(object instanceof Cliente)) {
|
if (!(object instanceof Cliente)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -401,5 +392,4 @@ public class Cliente implements Serializable {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "com.rjconsultores.ventaboletos.entidad.Cliente[ clienteId=" + clienteId + " ]";
|
return "com.rjconsultores.ventaboletos.entidad.Cliente[ clienteId=" + clienteId + " ]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,128 @@
|
||||||
|
package com.rjconsultores.ventaboletos.entidad;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import javax.persistence.Basic;
|
||||||
|
import javax.persistence.CascadeType;
|
||||||
|
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.OneToOne;
|
||||||
|
import javax.persistence.SequenceGenerator;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.persistence.Temporal;
|
||||||
|
import javax.persistence.TemporalType;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@SequenceGenerator(name = "CLIENTE_FIDELIDAD_SEQ", sequenceName = "CLIENTE_FIDELIDAD_SEQ", allocationSize = 1)
|
||||||
|
@Table(name = "CLIENTE_FIDELIDAD")
|
||||||
|
public class ClienteFidelidad implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
@Id
|
||||||
|
@Basic(optional = false)
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO, generator = "CLIENTE_FIDELIDAD_SEQ")
|
||||||
|
@Column(name = "CLIENTEFIDELIDAD_ID")
|
||||||
|
private Integer clienteFidelidadId;
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "CLIENTE_ID")
|
||||||
|
private Cliente cliente;
|
||||||
|
@OneToOne(cascade = CascadeType.ALL)
|
||||||
|
@JoinColumn(name = "TARJETAFIDELIDAD_ID")
|
||||||
|
private TarjetaFidelidad tarjetaFidelidad;
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "EMPRESA_ID")
|
||||||
|
private Empresa empresa;
|
||||||
|
@Column(name = "ACTIVO")
|
||||||
|
private Boolean activo;
|
||||||
|
@Column(name = "FECMODIF")
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
private Date fecmodif;
|
||||||
|
@Column(name = "USUARIO_ID")
|
||||||
|
private Integer usuarioId;
|
||||||
|
|
||||||
|
public Integer getClienteFidelidadId() {
|
||||||
|
return clienteFidelidadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClienteFidelidadId(Integer clienteFidelidadId) {
|
||||||
|
this.clienteFidelidadId = clienteFidelidadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TarjetaFidelidad getTarjetaFidelidad() {
|
||||||
|
return tarjetaFidelidad;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTarjetaFidelidad(TarjetaFidelidad tarjetaFidelidad) {
|
||||||
|
this.tarjetaFidelidad = tarjetaFidelidad;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Empresa getEmpresa() {
|
||||||
|
return empresa;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmpresa(Empresa empresa) {
|
||||||
|
this.empresa = empresa;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cliente getCliente() {
|
||||||
|
return cliente;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCliente(Cliente cliente) {
|
||||||
|
this.cliente = cliente;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((clienteFidelidadId == null) ? 0 : clienteFidelidadId.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
ClienteFidelidad other = (ClienteFidelidad) obj;
|
||||||
|
if (clienteFidelidadId == null) {
|
||||||
|
if (other.clienteFidelidadId != null)
|
||||||
|
return false;
|
||||||
|
} else if (!clienteFidelidadId.equals(other.clienteFidelidadId))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -33,7 +33,7 @@ public class TarjetaFidelidad implements Serializable {
|
||||||
@Column(name = "TARJETAFIDELIDAD_ID")
|
@Column(name = "TARJETAFIDELIDAD_ID")
|
||||||
private Integer tarjetaFidelidadId;
|
private Integer tarjetaFidelidadId;
|
||||||
@Column(name = "NUMTARJETA")
|
@Column(name = "NUMTARJETA")
|
||||||
private String numTarjeta;
|
private Integer numTarjeta;
|
||||||
@Column(name = "DESCGENERACION")
|
@Column(name = "DESCGENERACION")
|
||||||
private String descGeneracion;
|
private String descGeneracion;
|
||||||
@Column(name = "ACTIVO")
|
@Column(name = "ACTIVO")
|
||||||
|
@ -68,11 +68,11 @@ public class TarjetaFidelidad implements Serializable {
|
||||||
this.fecmodif = fecmodif;
|
this.fecmodif = fecmodif;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNumTarjeta() {
|
public Integer getNumTarjeta() {
|
||||||
return numTarjeta;
|
return numTarjeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNumTarjeta(String numTarjeta) {
|
public void setNumTarjeta(Integer numTarjeta) {
|
||||||
this.numTarjeta = numTarjeta;
|
this.numTarjeta = numTarjeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,6 @@ public class TarjetaFidelidad implements Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object object) {
|
public boolean equals(Object object) {
|
||||||
// TODO: Warning - this method won't work in the case the id fields are not set
|
|
||||||
if (!(object instanceof TarjetaFidelidad)) {
|
if (!(object instanceof TarjetaFidelidad)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,9 @@ import java.util.List;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.entidad.Cliente;
|
import com.rjconsultores.ventaboletos.entidad.Cliente;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public interface ClienteService extends GenericService<Cliente, Integer> {
|
public interface ClienteService extends GenericService<Cliente, Integer> {
|
||||||
|
|
||||||
public List<Cliente> buscar(String numCliente);
|
public List<Cliente> buscar(String numCliente);
|
||||||
|
|
||||||
|
public Cliente buscarPorNumeroFidelidade(Integer numeroFidelidade);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.rjconsultores.ventaboletos.service;
|
||||||
|
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ImportacaoClientesService {
|
||||||
|
public List<String[]> lerArquivo(Reader reader);
|
||||||
|
|
||||||
|
public String[] salvarClientes(List<String[]> clientes);
|
||||||
|
}
|
|
@ -51,7 +51,6 @@ public class ClienteServiceImpl implements ClienteService {
|
||||||
return clienteDAO.actualizacion(entidad);
|
return clienteDAO.actualizacion(entidad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void borrar(Cliente entidad) {
|
public void borrar(Cliente entidad) {
|
||||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
@ -61,10 +60,12 @@ public class ClienteServiceImpl implements ClienteService {
|
||||||
clienteDAO.actualizacion(entidad);
|
clienteDAO.actualizacion(entidad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<Cliente> buscar(String numbCliente) {
|
public List<Cliente> buscar(String numbCliente) {
|
||||||
return clienteDAO.buscar(numbCliente);
|
return clienteDAO.buscar(numbCliente);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Cliente buscarPorNumeroFidelidade(Integer numeroFidelidade) {
|
||||||
|
return clienteDAO.buscarPorNumeroFidelidade(numeroFidelidade);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,109 @@
|
||||||
|
package com.rjconsultores.ventaboletos.service.impl;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Cliente;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.ClienteFidelidad;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.TarjetaFidelidad;
|
||||||
|
import com.rjconsultores.ventaboletos.service.ClienteService;
|
||||||
|
import com.rjconsultores.ventaboletos.service.ImportacaoClientesService;
|
||||||
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||||
|
|
||||||
|
@Service("importacaoClientesService")
|
||||||
|
public class ImportacaoClientesServiceImpl implements ImportacaoClientesService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ClienteService clienteService;
|
||||||
|
private static Logger log = Logger.getLogger(ImportacaoClientesServiceImpl.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String[]> lerArquivo(Reader reader) {
|
||||||
|
String linha = null;
|
||||||
|
List<String[]> listaClientes = new ArrayList<String[]>();
|
||||||
|
try {
|
||||||
|
BufferedReader leitor = new BufferedReader(reader);
|
||||||
|
|
||||||
|
while ((linha = leitor.readLine()) != null) {
|
||||||
|
String[] dados = linha.split(",");
|
||||||
|
listaClientes.add(dados);
|
||||||
|
}
|
||||||
|
|
||||||
|
leitor.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return listaClientes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] salvarClientes(List<String[]> clientes) {
|
||||||
|
StringBuilder qtdeGravados = new StringBuilder();
|
||||||
|
StringBuilder erros = new StringBuilder();
|
||||||
|
|
||||||
|
Integer inseridos = 0;
|
||||||
|
Integer atualizados = 0;
|
||||||
|
for (int i = 0; i < clientes.size(); i++) {
|
||||||
|
String[] cliente = clientes.get(i);
|
||||||
|
try {
|
||||||
|
String nomeCliente = cliente[1].replace("\"", "").toUpperCase();
|
||||||
|
if (nomeCliente.length() > 60) {
|
||||||
|
nomeCliente = nomeCliente.substring(0, 59);
|
||||||
|
}
|
||||||
|
|
||||||
|
Cliente clienteGravar = clienteService.buscarPorNumeroFidelidade(Integer.parseInt(cliente[0]));
|
||||||
|
if (clienteGravar == null) {
|
||||||
|
clienteGravar = new Cliente();
|
||||||
|
clienteGravar.setNombcliente(nomeCliente);
|
||||||
|
clienteGravar.setNumIdentificaUno(cliente[3]);
|
||||||
|
|
||||||
|
TarjetaFidelidad tarjetaFidelidad = new TarjetaFidelidad();
|
||||||
|
tarjetaFidelidad.setActivo(Boolean.TRUE);
|
||||||
|
tarjetaFidelidad.setFecmodif(Calendar.getInstance().getTime());
|
||||||
|
tarjetaFidelidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
// cast para Integer para remover 0 a esquedas:
|
||||||
|
tarjetaFidelidad.setNumTarjeta(Integer.parseInt(cliente[0]));
|
||||||
|
|
||||||
|
ClienteFidelidad clienteFidelidad = new ClienteFidelidad();
|
||||||
|
clienteFidelidad.setTarjetaFidelidad(tarjetaFidelidad);
|
||||||
|
clienteFidelidad.setActivo(Boolean.TRUE);
|
||||||
|
clienteFidelidad.setFecmodif(Calendar.getInstance().getTime());
|
||||||
|
clienteFidelidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
clienteFidelidad.setCliente(clienteGravar);
|
||||||
|
List<ClienteFidelidad> ls = new ArrayList<ClienteFidelidad>();
|
||||||
|
ls.add(clienteFidelidad);
|
||||||
|
clienteGravar.setListClienteFidelidad(ls);
|
||||||
|
|
||||||
|
clienteService.suscribir(clienteGravar);
|
||||||
|
inseridos = inseridos + 1;
|
||||||
|
} else {
|
||||||
|
clienteGravar.setNombcliente(nomeCliente);
|
||||||
|
clienteGravar.setNumIdentificaUno(cliente[3]);
|
||||||
|
clienteService.actualizacion(clienteGravar);
|
||||||
|
|
||||||
|
atualizados = atualizados + 1;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
erros.append("Linha ").append(i).append(" do arquivo de clientes, erro: ").append(e.getCause().getCause()).append("\n");
|
||||||
|
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qtdeGravados.append("Gravados ").append(inseridos + atualizados).append(" clientes de ").append(clientes.size()).append(" importados.\n");
|
||||||
|
qtdeGravados.append("Atualizados ").append(atualizados).append(" clientes.\n");
|
||||||
|
qtdeGravados.append("Inseridos ").append(inseridos).append(" novos clientes.");
|
||||||
|
|
||||||
|
String[] resultado = { qtdeGravados.toString(), erros.toString() };
|
||||||
|
|
||||||
|
return resultado;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,30 +1,18 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE hibernate-configuration PUBLIC
|
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
|
||||||
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
|
|
||||||
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
|
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
|
||||||
<hibernate-configuration>
|
<hibernate-configuration>
|
||||||
|
<session-factory name="">
|
||||||
<session-factory>
|
|
||||||
|
|
||||||
<property name="connection.driver_class">oracle.jdbc.OracleDriver</property>
|
<property name="connection.driver_class">oracle.jdbc.OracleDriver</property>
|
||||||
|
|
||||||
<property name="connection.url">jdbc:oracle:thin:@sistema.grupoguanabara.net.br:1521:ORCL</property>
|
<property name="connection.url">jdbc:oracle:thin:@sistema.grupoguanabara.net.br:1521:ORCL</property>
|
||||||
|
|
||||||
<property name="connection.username">vtabol</property>
|
<property name="connection.username">vtabol</property>
|
||||||
|
|
||||||
<property name="connection.password">vtax05</property>
|
<property name="connection.password">vtax05</property>
|
||||||
<!-- <property name="connection.url">jdbc:oracle:thin:@10.17.55.116:1521:XE</property> -->
|
<!-- <property name="connection.url">jdbc:oracle:thin:@10.17.55.116:1521:XE</property>
|
||||||
|
<property name="connection.username">dbo_pruebavtabol</property> <property
|
||||||
<!-- <property name="connection.username">dbo_pruebavtabol</property> -->
|
name="connection.password">venda</property> -->
|
||||||
|
|
||||||
<!-- <property name="connection.password">venda</property> -->
|
|
||||||
|
|
||||||
<property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
|
<property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
|
||||||
|
|
||||||
<property name="show_sql">true</property>
|
<property name="show_sql">true</property>
|
||||||
|
|
||||||
<property name="hibernate.query.substitutions">true 1, false 0</property>
|
<property name="hibernate.query.substitutions">true 1, false 0</property>
|
||||||
|
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.AlertaCtrl" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.AlertaCtrl" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.Autobus" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.Autobus" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.Autorizacion" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.Autorizacion" />
|
||||||
|
@ -47,7 +35,8 @@
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.CoeficienteTarifa" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.CoeficienteTarifa" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.Colonia" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.Colonia" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.ClaseServicio" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.ClaseServicio" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.ClaseservicioEquivalencia" />
|
<mapping
|
||||||
|
class="com.rjconsultores.ventaboletos.entidad.ClaseservicioEquivalencia" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.ComisionistaExterno" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.ComisionistaExterno" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.CompaniaBancaria" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.CompaniaBancaria" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.Conductor" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.Conductor" />
|
||||||
|
@ -55,8 +44,10 @@
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.ConexionCtrl" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.ConexionCtrl" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.ConexionCtrlTemp" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.ConexionCtrlTemp" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.ConexionTemp" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.ConexionTemp" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.ConfigRestriccionPago" />
|
<mapping
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.ConfRestricaoCanalVenta" />
|
class="com.rjconsultores.ventaboletos.entidad.ConfigRestriccionPago" />
|
||||||
|
<mapping
|
||||||
|
class="com.rjconsultores.ventaboletos.entidad.ConfRestricaoCanalVenta" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.Convenio" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.Convenio" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.ConvenioDet" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.ConvenioDet" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.Constante" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.Constante" />
|
||||||
|
@ -93,7 +84,8 @@
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.Moneda" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.Moneda" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.MarcaClaseServicio" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.MarcaClaseServicio" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.MotivoCancelacion" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.MotivoCancelacion" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.MotivocancelacionEquivalencia" />
|
<mapping
|
||||||
|
class="com.rjconsultores.ventaboletos.entidad.MotivocancelacionEquivalencia" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.MotivoReimpresion" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.MotivoReimpresion" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.MotivoViaje" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.MotivoViaje" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.Nodo" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.Nodo" />
|
||||||
|
@ -141,7 +133,8 @@
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.ProdVigencia" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.ProdVigencia" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.ProductoServicio" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.ProductoServicio" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.PtovtaEmpresa" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.PtovtaEmpresa" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.PtoVtaUsuarioBancario" />
|
<mapping
|
||||||
|
class="com.rjconsultores.ventaboletos.entidad.PtoVtaUsuarioBancario" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.PuntoVenta" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.PuntoVenta" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.Redondeo" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.Redondeo" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.RedondeoCtrl" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.RedondeoCtrl" />
|
||||||
|
@ -151,7 +144,8 @@
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.ReservacionCtrl" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.ReservacionCtrl" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.ReservacionMarca" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.ReservacionMarca" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.ReservacionMercado" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.ReservacionMercado" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.ReservacionPuntoVenta" />
|
<mapping
|
||||||
|
class="com.rjconsultores.ventaboletos.entidad.ReservacionPuntoVenta" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.RestriccionPago" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.RestriccionPago" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.RolOperativo" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.RolOperativo" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.Ruta" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.Ruta" />
|
||||||
|
@ -173,7 +167,8 @@
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.TipoCambioCtrl" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.TipoCambioCtrl" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.TipoCambioCiudad" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.TipoCambioCiudad" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.TipoCorte" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.TipoCorte" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.TipoCortesiaDescuento" />
|
<mapping
|
||||||
|
class="com.rjconsultores.ventaboletos.entidad.TipoCortesiaDescuento" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.TipoCortesia" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.TipoCortesia" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.TipoDomicilio" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.TipoDomicilio" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.TipoEmpleado" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.TipoEmpleado" />
|
||||||
|
@ -201,7 +196,5 @@
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.TipoEventoExtra" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.TipoEventoExtra" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.AjusteEventoExtra" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.AjusteEventoExtra" />
|
||||||
<mapping class="com.rjconsultores.ventaboletos.entidad.TarjetaViaje" />
|
<mapping class="com.rjconsultores.ventaboletos.entidad.TarjetaViaje" />
|
||||||
|
|
||||||
</session-factory>
|
</session-factory>
|
||||||
|
|
||||||
</hibernate-configuration>
|
</hibernate-configuration>
|
||||||
|
|
Loading…
Reference in New Issue