git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@28914 d1611594-4594-4d17-8e1d-87c2c4800839
parent
3b031de5ed
commit
c2cbaab6b1
|
@ -3,6 +3,8 @@ package com.rjconsultores.ventaboletos.dao;
|
||||||
import java.sql.Date;
|
import java.sql.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Estado;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Feriado;
|
import com.rjconsultores.ventaboletos.entidad.Feriado;
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +12,6 @@ public interface FeriadoDAO extends GenericDAO<Feriado, Integer> {
|
||||||
|
|
||||||
public List<Feriado> buscar(Date fecferiado);
|
public List<Feriado> buscar(Date fecferiado);
|
||||||
|
|
||||||
public boolean ehFeriado(Date fecFeriado);
|
public boolean ehFeriado(Date fecFeriado, Empresa empresa, Estado estadoOrigem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,59 +19,54 @@ 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;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author MCosso
|
* @author MCosso
|
||||||
*/
|
*/
|
||||||
@Repository("estadoDAO")
|
@Repository("estadoDAO")
|
||||||
public class EstadoHibernateDAO extends GenericHibernateDAO<Estado, Integer>
|
public class EstadoHibernateDAO extends GenericHibernateDAO<Estado, Integer>
|
||||||
implements EstadoDAO {
|
implements EstadoDAO {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public EstadoHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
public EstadoHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||||
setSessionFactory(factory);
|
setSessionFactory(factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Estado> obtenerTodos() {
|
public List<Estado> obtenerTodos() {
|
||||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
c.addOrder(Order.asc("nombestado"));
|
c.addOrder(Order.asc("nombestado"));
|
||||||
|
|
||||||
return c.list();
|
return c.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Estado> buscar(String nombestado, Pais pais) {
|
public List<Estado> buscar(String nombestado, Pais pais) {
|
||||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
c.add(Restrictions.eq("nombestado", nombestado));
|
c.add(Restrictions.eq("nombestado", nombestado));
|
||||||
c.add(Restrictions.eq("pais", pais));
|
c.add(Restrictions.eq("pais", pais));
|
||||||
|
|
||||||
return c.list();
|
return c.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Estado> buscarNotInEmpresaImposto(Empresa empresa) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
public List<Estado> buscarNotInEmpresaImposto(Empresa empresa) {
|
sb.append(" select es ");
|
||||||
StringBuilder sb = new StringBuilder();
|
sb.append(" from Estado es ");
|
||||||
|
sb.append(" where es.activo = 1 ");
|
||||||
sb.append(" select es ");
|
sb.append(" and es.estadoId not in ( ");
|
||||||
sb.append(" from Estado es ");
|
sb.append(" select ei.estado.estadoId from EmpresaImposto ei ");
|
||||||
sb.append(" where es.activo = 1 ");
|
sb.append(" where ei.activo = 1 and ei.empresa.empresaId =:empresaId ");
|
||||||
sb.append(" and es.estadoId not in ( ");
|
sb.append(" )");
|
||||||
sb.append(" select ei.estado.estadoId from EmpresaImposto ei ");
|
sb.append(" order by es.nombestado");
|
||||||
sb.append(" where ei.activo = 1 and ei.empresa.empresaId =:empresaId ");
|
|
||||||
sb.append(" )");
|
|
||||||
sb.append(" order by es.nombestado");
|
|
||||||
|
|
||||||
|
|
||||||
Query query = getSession().createQuery(sb.toString());
|
Query query = getSession().createQuery(sb.toString());
|
||||||
query.setParameter("empresaId", empresa.getEmpresaId());
|
query.setParameter("empresaId", empresa.getEmpresaId());
|
||||||
|
|
||||||
List<Estado> lsEstado = query.list();
|
List<Estado> lsEstado = query.list();
|
||||||
|
|
||||||
|
|
||||||
return lsEstado;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return lsEstado;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,51 +14,48 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.dao.FeriadoDAO;
|
import com.rjconsultores.ventaboletos.dao.FeriadoDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Estado;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Feriado;
|
import com.rjconsultores.ventaboletos.entidad.Feriado;
|
||||||
|
|
||||||
|
|
||||||
@Repository("feriadoDAO")
|
@Repository("feriadoDAO")
|
||||||
public class FeriadoHibernateDAO extends GenericHibernateDAO<Feriado, Integer> implements FeriadoDAO {
|
public class FeriadoHibernateDAO extends GenericHibernateDAO<Feriado, Integer> implements FeriadoDAO {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public FeriadoHibernateDAO(
|
public FeriadoHibernateDAO(
|
||||||
@Qualifier("sessionFactory") SessionFactory factory) {
|
@Qualifier("sessionFactory") SessionFactory factory) {
|
||||||
setSessionFactory(factory);
|
setSessionFactory(factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Feriado> obtenerTodos() {
|
|
||||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
|
||||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
|
||||||
c.addOrder(Order.asc("id"));
|
|
||||||
|
|
||||||
return c.list();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Feriado> buscar(Date descferiado) {
|
|
||||||
String hql = " select new com.rjconsultores.ventaboletos.entidad.Feriado(feriado.feriadoId, feriado.fecferiado,feriado.descferiado) from Feriado feriado" +
|
|
||||||
" where feriado.activo = 1 and feriado.fecferiado =:data";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Query sq = getSession().createQuery(hql);
|
|
||||||
sq.setParameter("data", descferiado);
|
|
||||||
List<Feriado> lsMarca = sq.list();
|
|
||||||
return lsMarca;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean ehFeriado(Date fecFeriado) {
|
public List<Feriado> obtenerTodos() {
|
||||||
Criteria c= makeCriteria();
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
|
c.addOrder(Order.asc("id"));
|
||||||
|
|
||||||
|
return c.list();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Feriado> buscar(Date descferiado) {
|
||||||
|
String hql = " select new com.rjconsultores.ventaboletos.entidad.Feriado(feriado.feriadoId, feriado.fecferiado,feriado.descferiado) from Feriado feriado" +
|
||||||
|
" where feriado.activo = 1 and feriado.fecferiado =:data";
|
||||||
|
|
||||||
|
Query sq = getSession().createQuery(hql);
|
||||||
|
sq.setParameter("data", descferiado);
|
||||||
|
List<Feriado> lsMarca = sq.list();
|
||||||
|
return lsMarca;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean ehFeriado(Date fecFeriado, Empresa empresa, Estado estadoOrigem) {
|
||||||
|
Criteria c = makeCriteria();
|
||||||
|
|
||||||
c.add(Restrictions.eq("activo", true));
|
c.add(Restrictions.eq("activo", true));
|
||||||
c.add(Restrictions.eq("fecferiado", fecFeriado));
|
c.add(Restrictions.eq("fecferiado", fecFeriado));
|
||||||
|
c.add(Restrictions.or(Restrictions.eq("estado", estadoOrigem), Restrictions.isNull("estado")));
|
||||||
|
c.add(Restrictions.or(Restrictions.eq("empresa", empresa), Restrictions.isNull("empresa")));
|
||||||
c.setProjection(Projections.rowCount());
|
c.setProjection(Projections.rowCount());
|
||||||
|
|
||||||
|
|
||||||
return HibernateFix.count(c.uniqueResult()) > 0;
|
return HibernateFix.count(c.uniqueResult()) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,20 +5,16 @@
|
||||||
package com.rjconsultores.ventaboletos.entidad;
|
package com.rjconsultores.ventaboletos.entidad;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.persistence.Basic;
|
import javax.persistence.Basic;
|
||||||
import javax.persistence.CascadeType;
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
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.ManyToOne;
|
import javax.persistence.OneToOne;
|
||||||
import javax.persistence.OneToMany;
|
|
||||||
import javax.persistence.SequenceGenerator;
|
import javax.persistence.SequenceGenerator;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
|
@ -33,28 +29,32 @@ import javax.persistence.TemporalType;
|
||||||
@Table(name = "FERIADO")
|
@Table(name = "FERIADO")
|
||||||
public class Feriado implements Serializable {
|
public class Feriado implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@Id
|
@Id
|
||||||
@Basic(optional = false)
|
@Basic(optional = false)
|
||||||
@Column(name = "FERIADO_ID")
|
@Column(name = "FERIADO_ID")
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO, generator = "FERIADO_SEQ")
|
@GeneratedValue(strategy = GenerationType.AUTO, generator = "FERIADO_SEQ")
|
||||||
private Integer feriadoId;
|
private Integer feriadoId;
|
||||||
@Column(name = "FECFERIADO")
|
@Column(name = "FECFERIADO")
|
||||||
@Temporal(TemporalType.DATE)
|
@Temporal(TemporalType.DATE)
|
||||||
private Date fecferiado;
|
private Date fecferiado;
|
||||||
@Column(name = "DESCFERIADO")
|
@Column(name = "DESCFERIADO")
|
||||||
private String descferiado;
|
private String descferiado;
|
||||||
@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;
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "ESTADO_ID")
|
||||||
|
private Estado estado;
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "EMPRESA_ID")
|
||||||
|
private Empresa empresa;
|
||||||
|
|
||||||
|
public Feriado(Integer feriadoId, Date fecferiado, String descferiado) {
|
||||||
|
|
||||||
public Feriado(Integer feriadoId, Date fecferiado, String descferiado) {
|
|
||||||
super();
|
super();
|
||||||
this.feriadoId = feriadoId;
|
this.feriadoId = feriadoId;
|
||||||
this.fecferiado = fecferiado;
|
this.fecferiado = fecferiado;
|
||||||
|
@ -62,13 +62,13 @@ public class Feriado implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Feriado() {
|
public Feriado() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Feriado(Integer feriadoId) {
|
public Feriado(Integer feriadoId) {
|
||||||
this.feriadoId = feriadoId;
|
this.feriadoId = feriadoId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getFeriadoId() {
|
public Integer getFeriadoId() {
|
||||||
return feriadoId;
|
return feriadoId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,59 +93,66 @@ public class Feriado implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getFecmodif() {
|
public Date getFecmodif() {
|
||||||
return fecmodif;
|
return fecmodif;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Estado getEstado() {
|
||||||
|
return estado;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEstado(Estado estado) {
|
||||||
|
this.estado = estado;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Empresa getEmpresa() {
|
||||||
|
return empresa;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmpresa(Empresa empresa) {
|
||||||
|
this.empresa = empresa;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int hash = 0;
|
||||||
|
hash += (feriadoId != null ? feriadoId.hashCode() : 0);
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object object) {
|
||||||
|
if (!(object instanceof Feriado)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Feriado other = (Feriado) object;
|
||||||
|
if ((this.feriadoId == null && other.feriadoId != null) || (this.feriadoId != null && !this.feriadoId.equals(other.feriadoId))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Override
|
public String toString() {
|
||||||
public int hashCode() {
|
return this.descferiado;
|
||||||
int hash = 0;
|
}
|
||||||
hash += (feriadoId != null ? feriadoId.hashCode() : 0);
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object object) {
|
|
||||||
// TODO: Warning - this method won't work in the case the id fields are
|
|
||||||
// not set
|
|
||||||
if (!(object instanceof Feriado)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Feriado other = (Feriado) object;
|
|
||||||
if ((this.feriadoId == null && other.feriadoId != null) || (this.feriadoId != null && !this.feriadoId.equals(other.feriadoId))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return this.descferiado;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,6 @@ public class Ruta implements Serializable {
|
||||||
this.usuarioId = usuarioId;
|
this.usuarioId = usuarioId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Integer getNumRuta() {
|
public Integer getNumRuta() {
|
||||||
return numRuta;
|
return numRuta;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +230,6 @@ public class Ruta implements Serializable {
|
||||||
this.orgaoConcedente = orgaoConcedente;
|
this.orgaoConcedente = orgaoConcedente;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Boolean getIndSentidoIda() {
|
public Boolean getIndSentidoIda() {
|
||||||
return indSentidoIda;
|
return indSentidoIda;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,13 +33,16 @@ import com.rjconsultores.ventaboletos.entidad.Corrida;
|
||||||
import com.rjconsultores.ventaboletos.entidad.CorridaCtrl;
|
import com.rjconsultores.ventaboletos.entidad.CorridaCtrl;
|
||||||
import com.rjconsultores.ventaboletos.entidad.CorridaTramo;
|
import com.rjconsultores.ventaboletos.entidad.CorridaTramo;
|
||||||
import com.rjconsultores.ventaboletos.entidad.DiagramaAutobus;
|
import com.rjconsultores.ventaboletos.entidad.DiagramaAutobus;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
import com.rjconsultores.ventaboletos.entidad.EsquemaAsiento;
|
import com.rjconsultores.ventaboletos.entidad.EsquemaAsiento;
|
||||||
import com.rjconsultores.ventaboletos.entidad.EsquemaCorrida;
|
import com.rjconsultores.ventaboletos.entidad.EsquemaCorrida;
|
||||||
import com.rjconsultores.ventaboletos.entidad.EsquemaTramo;
|
import com.rjconsultores.ventaboletos.entidad.EsquemaTramo;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Estado;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Marca;
|
import com.rjconsultores.ventaboletos.entidad.Marca;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Parada;
|
import com.rjconsultores.ventaboletos.entidad.Parada;
|
||||||
import com.rjconsultores.ventaboletos.entidad.RolOperativo;
|
import com.rjconsultores.ventaboletos.entidad.RolOperativo;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.RutaSecuencia;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Tramo;
|
import com.rjconsultores.ventaboletos.entidad.Tramo;
|
||||||
import com.rjconsultores.ventaboletos.entidad.TramoServicio;
|
import com.rjconsultores.ventaboletos.entidad.TramoServicio;
|
||||||
import com.rjconsultores.ventaboletos.entidad.TramoTiempo;
|
import com.rjconsultores.ventaboletos.entidad.TramoTiempo;
|
||||||
|
@ -50,7 +53,7 @@ import com.rjconsultores.ventaboletos.service.CorridaService;
|
||||||
import com.rjconsultores.ventaboletos.service.EsquemaAsientoService;
|
import com.rjconsultores.ventaboletos.service.EsquemaAsientoService;
|
||||||
import com.rjconsultores.ventaboletos.service.EsquemaCorridaService;
|
import com.rjconsultores.ventaboletos.service.EsquemaCorridaService;
|
||||||
import com.rjconsultores.ventaboletos.service.EsquemaTramoService;
|
import com.rjconsultores.ventaboletos.service.EsquemaTramoService;
|
||||||
import com.rjconsultores.ventaboletos.service.FeriadoService;
|
import com.rjconsultores.ventaboletos.service.RutaSecuenciaService;
|
||||||
import com.rjconsultores.ventaboletos.service.RutaService;
|
import com.rjconsultores.ventaboletos.service.RutaService;
|
||||||
import com.rjconsultores.ventaboletos.service.TramoServicioService;
|
import com.rjconsultores.ventaboletos.service.TramoServicioService;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||||
|
@ -87,6 +90,8 @@ public class CorridaServiceImpl implements CorridaService {
|
||||||
private EsquemaCorridaDAO esquemaCorridaDAO;
|
private EsquemaCorridaDAO esquemaCorridaDAO;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ConstanteService constanteService;
|
private ConstanteService constanteService;
|
||||||
|
@Autowired
|
||||||
|
private RutaSecuenciaService rutaSecuenciaService;
|
||||||
private static Logger log = Logger.getLogger(CorridaServiceImpl.class);
|
private static Logger log = Logger.getLogger(CorridaServiceImpl.class);
|
||||||
private PlatformTransactionManager transactionManager;
|
private PlatformTransactionManager transactionManager;
|
||||||
@Transient
|
@Transient
|
||||||
|
@ -94,8 +99,6 @@ public class CorridaServiceImpl implements CorridaService {
|
||||||
@Transient
|
@Transient
|
||||||
private int cantCorridaCommit;
|
private int cantCorridaCommit;
|
||||||
@Autowired
|
@Autowired
|
||||||
private FeriadoService feriadoService;
|
|
||||||
@Autowired
|
|
||||||
private FeriadoCache feriadoCache;
|
private FeriadoCache feriadoCache;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -334,8 +337,18 @@ public class CorridaServiceImpl implements CorridaService {
|
||||||
return dataCorreta;
|
return dataCorreta;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isFeriado(java.sql.Date data) {
|
private boolean isFeriado(java.sql.Date data, EsquemaCorrida esquemaCorrida) {
|
||||||
return feriadoCache.ehFeriado(data);
|
Empresa empresa = esquemaCorrida.getEmpresa();
|
||||||
|
|
||||||
|
Estado estadoOrigem = null;
|
||||||
|
List<RutaSecuencia> lsRutaSequencia = rutaSecuenciaService.buscarSecuenciaOrdenado(esquemaCorrida.getRuta());
|
||||||
|
if (!lsRutaSequencia.isEmpty()) {
|
||||||
|
Tramo tramoOrigem = lsRutaSequencia.get(0).getTramo();
|
||||||
|
Parada origem = tramoOrigem.getOrigem();
|
||||||
|
estadoOrigem = origem.getCiudad().getEstado();
|
||||||
|
}
|
||||||
|
|
||||||
|
return feriadoCache.ehFeriado(data, empresa, estadoOrigem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -393,7 +406,7 @@ public class CorridaServiceImpl implements CorridaService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tramoServicioService.existenTiemposTramosEsquema(esquemaCorrida.getEsquemacorridaId())){
|
if (!tramoServicioService.existenTiemposTramosEsquema(esquemaCorrida.getEsquemacorridaId())) {
|
||||||
log.info("nao foi cadastrado o tempo de todos os trechos do esquema corrida=" + esquemaCorrida.getEsquemacorridaId());
|
log.info("nao foi cadastrado o tempo de todos os trechos do esquema corrida=" + esquemaCorrida.getEsquemacorridaId());
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -614,9 +627,10 @@ public class CorridaServiceImpl implements CorridaService {
|
||||||
cantCorridaGenerada = 0;
|
cantCorridaGenerada = 0;
|
||||||
cantCorridaCommit = 1;
|
cantCorridaCommit = 1;
|
||||||
java.sql.Date data = new java.sql.Date(dataGeracao.getTime());
|
java.sql.Date data = new java.sql.Date(dataGeracao.getTime());
|
||||||
Boolean isFeriado = this.isFeriado(data);
|
|
||||||
|
|
||||||
for (EsquemaCorrida esquemaCorrida : lsEsquemaCorrida) {
|
for (EsquemaCorrida esquemaCorrida : lsEsquemaCorrida) {
|
||||||
|
Boolean isFeriado = this.isFeriado(data, esquemaCorrida);
|
||||||
|
|
||||||
log.info("esquema=" + esquemaCorrida.getEsquemacorridaId() + " numCorrida=" + esquemaCorrida.getNumCorrida());
|
log.info("esquema=" + esquemaCorrida.getEsquemacorridaId() + " numCorrida=" + esquemaCorrida.getNumCorrida());
|
||||||
|
|
||||||
if (!esquemaCorridaDAO.esHijoRebote(esquemaCorrida)) {
|
if (!esquemaCorridaDAO.esHijoRebote(esquemaCorrida)) {
|
||||||
|
@ -791,7 +805,7 @@ public class CorridaServiceImpl implements CorridaService {
|
||||||
tmp.setTime(dataGeracao);
|
tmp.setTime(dataGeracao);
|
||||||
tmp.add(Calendar.DAY_OF_MONTH, 1);
|
tmp.add(Calendar.DAY_OF_MONTH, 1);
|
||||||
java.sql.Date data = new java.sql.Date(dataGeracao.getTime());
|
java.sql.Date data = new java.sql.Date(dataGeracao.getTime());
|
||||||
Boolean isFeriado = this.isFeriado(data);
|
Boolean isFeriado = this.isFeriado(data, esquemaCorrida);
|
||||||
|
|
||||||
return generarCorrida(esquemaCorrida.getEsquemaCorridaRebote(), tmp.getTime(), false, isFeriado);
|
return generarCorrida(esquemaCorrida.getEsquemaCorridaRebote(), tmp.getTime(), false, isFeriado);
|
||||||
}
|
}
|
||||||
|
@ -894,7 +908,7 @@ public class CorridaServiceImpl implements CorridaService {
|
||||||
|
|
||||||
while (DateUtil.compareOnlyDate(dataDe, dataAte) <= 0) {
|
while (DateUtil.compareOnlyDate(dataDe, dataAte) <= 0) {
|
||||||
|
|
||||||
Boolean isFeriado = this.isFeriado(new java.sql.Date(dataDe.getTime()));
|
Boolean isFeriado = this.isFeriado(new java.sql.Date(dataDe.getTime()), esquemaCorrida);
|
||||||
|
|
||||||
generarCorrida(esquemaCorrida, dataDe, false, isFeriado);
|
generarCorrida(esquemaCorrida, dataDe, false, isFeriado);
|
||||||
|
|
||||||
|
|
|
@ -12,41 +12,99 @@ import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.dao.FeriadoDAO;
|
import com.rjconsultores.ventaboletos.dao.FeriadoDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Estado;
|
||||||
|
|
||||||
@Service("feriadoCache")
|
@Service("feriadoCache")
|
||||||
@Scope(value="prototype")
|
@Scope(value = "prototype")
|
||||||
public class FeriadoCache {
|
public class FeriadoCache {
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(FeriadoCache.class);
|
private static Logger log = LoggerFactory.getLogger(FeriadoCache.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private FeriadoDAO feriadoDAO;
|
private FeriadoDAO feriadoDAO;
|
||||||
private Map<String,Boolean> mapFeriado;
|
private Map<KeyFeriadoMap, Boolean> mapFeriado;
|
||||||
|
|
||||||
|
|
||||||
public FeriadoCache() {
|
public FeriadoCache() {
|
||||||
mapFeriado = new LinkedHashMap<String, Boolean>();
|
mapFeriado = new LinkedHashMap<KeyFeriadoMap, Boolean>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean ehFeriado(Date dataFeriado){
|
public boolean ehFeriado(Date dataFeriado, Empresa empresa, Estado estadoOrigem) {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
||||||
String strDataFeriado = sdf.format(dataFeriado);
|
String strDataFeriado = sdf.format(dataFeriado);
|
||||||
|
KeyFeriadoMap key = new KeyFeriadoMap(strDataFeriado, empresa.getEmpresaId(), estadoOrigem.getEstadoId());
|
||||||
|
|
||||||
Boolean ehFeriado = mapFeriado.get(strDataFeriado);
|
Boolean ehFeriado = mapFeriado.get(key);
|
||||||
|
|
||||||
if (ehFeriado == null){
|
if (ehFeriado == null) {
|
||||||
ehFeriado = feriadoDAO.ehFeriado(new java.sql.Date(dataFeriado.getTime()));
|
ehFeriado = feriadoDAO.ehFeriado(new java.sql.Date(dataFeriado.getTime()), empresa, estadoOrigem);
|
||||||
|
|
||||||
mapFeriado.put(strDataFeriado, ehFeriado);
|
mapFeriado.put(key, ehFeriado);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug("feriado " + strDataFeriado + " = " + ehFeriado);
|
log.debug("data feriado = " + strDataFeriado + "; empresa = " + empresa.getNombempresa() + "; estado = " + estadoOrigem.getNombestado() + "; eh feriado = " + ehFeriado);
|
||||||
|
|
||||||
return ehFeriado;
|
return ehFeriado;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void limpar(){
|
public void limpar() {
|
||||||
mapFeriado.clear();
|
mapFeriado.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class KeyFeriadoMap {
|
||||||
|
private String dataFeriado;
|
||||||
|
private Integer empresaId;
|
||||||
|
private Integer estadoOrigemId;
|
||||||
|
|
||||||
|
public KeyFeriadoMap(String dataFeriado, Integer empresaId, Integer estadoOrigemId) {
|
||||||
|
super();
|
||||||
|
this.dataFeriado = dataFeriado;
|
||||||
|
this.empresaId = empresaId;
|
||||||
|
this.estadoOrigemId = estadoOrigemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + getOuterType().hashCode();
|
||||||
|
result = prime * result + ((dataFeriado == null) ? 0 : dataFeriado.hashCode());
|
||||||
|
result = prime * result + ((empresaId == null) ? 0 : empresaId.hashCode());
|
||||||
|
result = prime * result + ((estadoOrigemId == null) ? 0 : estadoOrigemId.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;
|
||||||
|
KeyFeriadoMap other = (KeyFeriadoMap) obj;
|
||||||
|
if (!getOuterType().equals(other.getOuterType()))
|
||||||
|
return false;
|
||||||
|
if (dataFeriado == null) {
|
||||||
|
if (other.dataFeriado != null)
|
||||||
|
return false;
|
||||||
|
} else if (!dataFeriado.equals(other.dataFeriado))
|
||||||
|
return false;
|
||||||
|
if (empresaId == null) {
|
||||||
|
if (other.empresaId != null)
|
||||||
|
return false;
|
||||||
|
} else if (!empresaId.equals(other.empresaId))
|
||||||
|
return false;
|
||||||
|
if (estadoOrigemId == null) {
|
||||||
|
if (other.estadoOrigemId != null)
|
||||||
|
return false;
|
||||||
|
} else if (!estadoOrigemId.equals(other.estadoOrigemId))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private FeriadoCache getOuterType() {
|
||||||
|
return FeriadoCache.this;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue