bug #0009077- Merge branch com Trunk
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@69161 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
1cc8a591e0
commit
83edc2d646
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.rjconsultores.ventaboletos.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.PrecioFixoPedagio;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Administrador
|
||||||
|
*/
|
||||||
|
public interface PrecioFixoPedagioDAO extends GenericDAO<PrecioFixoPedagio, Integer> {
|
||||||
|
|
||||||
|
public List<PrecioFixoPedagio> buscarPorNome(String nomeClaseServicio);
|
||||||
|
|
||||||
|
public List<PrecioFixoPedagio> buscarTodosExceto(Integer ... idClase);
|
||||||
|
|
||||||
|
public List<PrecioFixoPedagio> buscarPorEmpresasDoUsuario (String idEmpresasUsuario);
|
||||||
|
|
||||||
|
public List<PrecioFixoPedagio> buscarPrecioFixoPedagio(PrecioFixoPedagio obj);
|
||||||
|
}
|
|
@ -32,9 +32,11 @@ import com.rjconsultores.ventaboletos.entidad.ExcepcionPeaje;
|
||||||
import com.rjconsultores.ventaboletos.entidad.ExcepcionPeajeVigencia;
|
import com.rjconsultores.ventaboletos.entidad.ExcepcionPeajeVigencia;
|
||||||
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
|
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Parada;
|
import com.rjconsultores.ventaboletos.entidad.Parada;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.PrecioFixoPedagio;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||||
import com.rjconsultores.ventaboletos.entidad.RutaCombinacion;
|
import com.rjconsultores.ventaboletos.entidad.RutaCombinacion;
|
||||||
import com.rjconsultores.ventaboletos.service.OrgaoConcedenteService;
|
import com.rjconsultores.ventaboletos.service.OrgaoConcedenteService;
|
||||||
|
import com.rjconsultores.ventaboletos.service.PrecioFixoPedagioService;
|
||||||
import com.rjconsultores.ventaboletos.service.RutaCombinacionService;
|
import com.rjconsultores.ventaboletos.service.RutaCombinacionService;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties;
|
import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||||
|
@ -48,6 +50,9 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RutaCombinacionService rutaCombinacionService;
|
private RutaCombinacionService rutaCombinacionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PrecioFixoPedagioService precioFixoPedagioService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public CalcularPeajeHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
public CalcularPeajeHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||||
|
@ -171,7 +176,20 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
|
||||||
if (null != lsObj) {
|
if (null != lsObj) {
|
||||||
for (Object arrObj : lsObj) {
|
for (Object arrObj : lsObj) {
|
||||||
BigDecimal bigKm = new BigDecimal(((Object[]) arrObj)[11].toString()) ;
|
BigDecimal bigKm = new BigDecimal(((Object[]) arrObj)[11].toString()) ;
|
||||||
peajes.add(PeajeVO.create(ruta, orgao, (Object[]) arrObj, classeIndicePeajes, usaICMS, bigKm));
|
PeajeVO pvo = PeajeVO.create(ruta, orgao, (Object[]) arrObj, classeIndicePeajes, usaICMS, bigKm);
|
||||||
|
|
||||||
|
PrecioFixoPedagio pfp = new PrecioFixoPedagio();
|
||||||
|
pfp.setOrgaoConcedenteId(orgao);
|
||||||
|
pfp.setClasseId(ruta.getClaseServicio());
|
||||||
|
CasetaPeaje pracaPedagio = new CasetaPeaje();
|
||||||
|
pracaPedagio.setCasetaPeajeId(pvo.casetaPeajeId);
|
||||||
|
pfp.setPracaPedagioId(pracaPedagio);
|
||||||
|
List<PrecioFixoPedagio> list = precioFixoPedagioService.buscarPrecioFixoPedagio(pfp);
|
||||||
|
if(list.size()>1){
|
||||||
|
pvo.importePeaje = list.get(0).getValorFixo();
|
||||||
|
}
|
||||||
|
|
||||||
|
peajes.add(pvo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.debug("****** FIM LINHA : "+ruta.toString()+" . INSTRUCOES DE INSERT NO BANCO PRONTAS ******");
|
log.debug("****** FIM LINHA : "+ruta.toString()+" . INSTRUCOES DE INSERT NO BANCO PRONTAS ******");
|
||||||
|
@ -440,6 +458,7 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
|
||||||
pvo.orgaoId = orgao.getOrgaoConcedenteId();
|
pvo.orgaoId = orgao.getOrgaoConcedenteId();
|
||||||
pvo.casetaPeajeId = Integer.parseInt(obj[20].toString());
|
pvo.casetaPeajeId = Integer.parseInt(obj[20].toString());
|
||||||
pvo.indicePeaje = getIndicePeaje(ruta.getClaseServicio(), orgao, lsClasseIndicePeaje);
|
pvo.indicePeaje = getIndicePeaje(ruta.getClaseServicio(), orgao, lsClasseIndicePeaje);
|
||||||
|
|
||||||
pvo.importePeaje = calculateImportePeaje(ruta, orgao, obj, pvo.indicePeaje, usaICMS, km);
|
pvo.importePeaje = calculateImportePeaje(ruta, orgao, obj, pvo.indicePeaje, usaICMS, km);
|
||||||
|
|
||||||
pvo.activo = 1;
|
pvo.activo = 1;
|
||||||
|
|
|
@ -0,0 +1,89 @@
|
||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hibernate.Criteria;
|
||||||
|
import org.hibernate.Query;
|
||||||
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.hibernate.criterion.Order;
|
||||||
|
import org.hibernate.criterion.Restrictions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.dao.ClasseServicoDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.dao.PrecioFixoPedagioDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.PrecioFixoPedagio;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Administrador
|
||||||
|
*/
|
||||||
|
@Repository("precoFixoPedagioDAO")
|
||||||
|
public class PrecioFixoPedagioHibernateDAO extends GenericHibernateDAO<PrecioFixoPedagio, Integer> implements PrecioFixoPedagioDAO {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public PrecioFixoPedagioHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||||
|
setSessionFactory(factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PrecioFixoPedagio> obtenerTodos() {
|
||||||
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
|
c.addOrder(Order.asc("descclase"));
|
||||||
|
|
||||||
|
return c.list();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PrecioFixoPedagio> buscarPorEmpresasDoUsuario(String empresasUsuario) {
|
||||||
|
|
||||||
|
String consulta = "SELECT DISTINCT mcs.marcaClaseservicioPK.claseservicio "
|
||||||
|
+ "FROM MarcaClaseServicio mcs "
|
||||||
|
+ "WHERE mcs.marcaClaseservicioPK.marca.empresa.empresaId IN (:empresas) ";
|
||||||
|
|
||||||
|
List<Integer> ids = new ArrayList<Integer>();
|
||||||
|
for (String empresa : empresasUsuario.split(",")) {
|
||||||
|
ids.add(new Integer(empresa));
|
||||||
|
}
|
||||||
|
Query query = getSession().createQuery(consulta);
|
||||||
|
query.setParameterList("empresas", ids);
|
||||||
|
|
||||||
|
List<PrecioFixoPedagio> result = (List<PrecioFixoPedagio>) query.list();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PrecioFixoPedagio> buscarPorNome(String nomeClaseServicio) {
|
||||||
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
|
c.add(Restrictions.eq("descclase", nomeClaseServicio));
|
||||||
|
|
||||||
|
return c.list();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PrecioFixoPedagio> buscarTodosExceto(Integer... idClase) {
|
||||||
|
Criteria c = this.makeCriteria();
|
||||||
|
for (Integer id : idClase) {
|
||||||
|
c.add(Restrictions.ne("claseservicioId", id));
|
||||||
|
}
|
||||||
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
|
c.addOrder(Order.asc("descclase"));
|
||||||
|
|
||||||
|
return c.list();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public List<PrecioFixoPedagio> buscarPrecioFixoPedagio(PrecioFixoPedagio obj) {
|
||||||
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
|
c.add(Restrictions.eq("pracaPedagioId.casetaPeajeId", obj.getPracaPedagioId().getCasetaPeajeId()));
|
||||||
|
c.add(Restrictions.eq("orgaoConcedenteId.orgaoConcedenteId", obj.getOrgaoConcedenteId().getOrgaoConcedenteId()));
|
||||||
|
c.add(Restrictions.eq("classeId.claseservicioId", obj.getClasseId().getClaseservicioId()));
|
||||||
|
c.setMaxResults(1);
|
||||||
|
return c.list();
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,6 +25,8 @@ import javax.persistence.TemporalType;
|
||||||
|
|
||||||
import org.hibernate.annotations.Fetch;
|
import org.hibernate.annotations.Fetch;
|
||||||
import org.hibernate.annotations.FetchMode;
|
import org.hibernate.annotations.FetchMode;
|
||||||
|
import org.hibernate.annotations.LazyCollection;
|
||||||
|
import org.hibernate.annotations.LazyCollectionOption;
|
||||||
import org.hibernate.annotations.Where;
|
import org.hibernate.annotations.Where;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
|
@ -60,6 +62,10 @@ public class CasetaPeaje implements Serializable, Comparable<CasetaPeaje>, Clone
|
||||||
inverseJoinColumns = { @JoinColumn(name = "RUTASECUENCIA_ID") })
|
inverseJoinColumns = { @JoinColumn(name = "RUTASECUENCIA_ID") })
|
||||||
private List<RutaSecuencia> lsRutaSecuencia;
|
private List<RutaSecuencia> lsRutaSecuencia;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "pracaPedagioId", cascade=CascadeType.ALL)
|
||||||
|
@LazyCollection(LazyCollectionOption.FALSE)
|
||||||
|
private List<PrecioFixoPedagio> lsPrecoFixoPedagio;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -151,6 +157,15 @@ public class CasetaPeaje implements Serializable, Comparable<CasetaPeaje>, Clone
|
||||||
|
|
||||||
public void setLsCasetaPeajeExcepcion(List<CasetaPeajeExcepcion> lsCasetaPeajeExcepcion) {
|
public void setLsCasetaPeajeExcepcion(List<CasetaPeajeExcepcion> lsCasetaPeajeExcepcion) {
|
||||||
this.lsCasetaPeajeExcepcion = lsCasetaPeajeExcepcion;
|
this.lsCasetaPeajeExcepcion = lsCasetaPeajeExcepcion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PrecioFixoPedagio> getLsPrecoFixoPedagio() {
|
||||||
|
return lsPrecoFixoPedagio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLsPrecoFixoPedagio(List<PrecioFixoPedagio> lsPrecoFixoPedagio) {
|
||||||
|
this.lsPrecoFixoPedagio = lsPrecoFixoPedagio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,141 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.rjconsultores.ventaboletos.entidad;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import javax.persistence.Basic;
|
||||||
|
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.ManyToOne;
|
||||||
|
import javax.persistence.OneToOne;
|
||||||
|
import javax.persistence.SequenceGenerator;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Bruno Neves
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@SequenceGenerator(name = "PRECIO_FIXO_PEDAGIO_SEQ", sequenceName = "PRECIO_FIXO_PEDAGIO_SEQ", allocationSize = 1)
|
||||||
|
@Table(name = "PRECIO_FIXO_PEDAGIO")
|
||||||
|
public class PrecioFixoPedagio implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Basic(optional = false)
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO, generator = "PRECIO_FIXO_PEDAGIO_SEQ")
|
||||||
|
@Column(name = "PRECIOFIXO_ID")
|
||||||
|
private Integer precioFixoId;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "PRACA_PEDAGIO_ID", referencedColumnName = "CASETAPEAJE_ID")
|
||||||
|
private CasetaPeaje pracaPedagioId;
|
||||||
|
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "ORGAO_CONCEDENTE_ID", referencedColumnName = "ORGAOCONCEDENTE_ID")
|
||||||
|
private OrgaoConcedente orgaoConcedenteId;
|
||||||
|
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "CLASSE_SERVICO_ID", referencedColumnName = "CLASESERVICIO_ID")
|
||||||
|
private ClaseServicio classeId;
|
||||||
|
|
||||||
|
@Column(name = "VALOR_FIXO")
|
||||||
|
private BigDecimal valorFixo;
|
||||||
|
|
||||||
|
public Integer getPrecioFixoId() {
|
||||||
|
return precioFixoId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrecioFixoId(Integer precioFixoId) {
|
||||||
|
this.precioFixoId = precioFixoId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CasetaPeaje getPracaPedagioId() {
|
||||||
|
return pracaPedagioId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPracaPedagioId(CasetaPeaje pracaPedagioId) {
|
||||||
|
this.pracaPedagioId = pracaPedagioId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrgaoConcedente getOrgaoConcedenteId() {
|
||||||
|
return orgaoConcedenteId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrgaoConcedenteId(OrgaoConcedente orgaoConcedenteId) {
|
||||||
|
this.orgaoConcedenteId = orgaoConcedenteId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClaseServicio getClasseId() {
|
||||||
|
return classeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClasseId(ClaseServicio classeId) {
|
||||||
|
this.classeId = classeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getValorFixo() {
|
||||||
|
return valorFixo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValorFixo(BigDecimal valorFixo) {
|
||||||
|
this.valorFixo = valorFixo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((classeId == null) ? 0 : classeId.hashCode());
|
||||||
|
result = prime * result + ((orgaoConcedenteId == null) ? 0 : orgaoConcedenteId.hashCode());
|
||||||
|
result = prime * result + ((pracaPedagioId == null) ? 0 : pracaPedagioId.hashCode());
|
||||||
|
result = prime * result + ((precioFixoId == null) ? 0 : precioFixoId.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;
|
||||||
|
PrecioFixoPedagio other = (PrecioFixoPedagio) obj;
|
||||||
|
if (classeId == null) {
|
||||||
|
if (other.classeId != null)
|
||||||
|
return false;
|
||||||
|
} else if (!classeId.equals(other.classeId))
|
||||||
|
return false;
|
||||||
|
if (orgaoConcedenteId == null) {
|
||||||
|
if (other.orgaoConcedenteId != null)
|
||||||
|
return false;
|
||||||
|
} else if (!orgaoConcedenteId.equals(other.orgaoConcedenteId))
|
||||||
|
return false;
|
||||||
|
if (pracaPedagioId == null) {
|
||||||
|
if (other.pracaPedagioId != null)
|
||||||
|
return false;
|
||||||
|
} else if (!pracaPedagioId.equals(other.pracaPedagioId))
|
||||||
|
return false;
|
||||||
|
if (precioFixoId == null) {
|
||||||
|
if (other.precioFixoId != null)
|
||||||
|
return false;
|
||||||
|
} else if (!precioFixoId.equals(other.precioFixoId))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.rjconsultores.ventaboletos.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.PrecioFixoPedagio;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Administrador
|
||||||
|
*/
|
||||||
|
public interface PrecioFixoPedagioService extends GenericService<PrecioFixoPedagio, Integer> {
|
||||||
|
|
||||||
|
public List<PrecioFixoPedagio> buscarPorNome(String nomeClaseServicio);
|
||||||
|
|
||||||
|
public List<PrecioFixoPedagio> buscarTodosExceto(Integer ... idClase);
|
||||||
|
|
||||||
|
public List<PrecioFixoPedagio> buscarPorEmpresasDoUsuario (List<Empresa> empresasUsuario);
|
||||||
|
|
||||||
|
public Boolean validarInclusaoPrecoFixo(PrecioFixoPedagio precoFixoPedagio);
|
||||||
|
|
||||||
|
public List<PrecioFixoPedagio> buscarPrecioFixoPedagio(PrecioFixoPedagio obj);
|
||||||
|
}
|
|
@ -0,0 +1,110 @@
|
||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.rjconsultores.ventaboletos.service.impl;
|
||||||
|
|
||||||
|
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.PrecioFixoPedagioDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.dao.hibernate.PrecioFixoPedagioHibernateDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.PrecioFixoPedagio;
|
||||||
|
import com.rjconsultores.ventaboletos.service.PrecioFixoPedagioService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Administrador
|
||||||
|
*/
|
||||||
|
@Service("precioFixoPedagioService")
|
||||||
|
public class PrecioFixoPedagioServiceImpl implements PrecioFixoPedagioService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PrecioFixoPedagioDAO precioFixoPedagioDAO;
|
||||||
|
@Autowired
|
||||||
|
private PrecioFixoPedagioHibernateDAO precioFixoPedagioHibernateDAO;
|
||||||
|
|
||||||
|
public List<PrecioFixoPedagio> obtenerTodos() {
|
||||||
|
return precioFixoPedagioDAO.obtenerTodos();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrecioFixoPedagio obtenerID(Integer id) {
|
||||||
|
return precioFixoPedagioDAO.obtenerID(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<PrecioFixoPedagio> buscarPorNome(String nomeClaseServicio) {
|
||||||
|
return precioFixoPedagioDAO.buscarPorNome(nomeClaseServicio);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PrecioFixoPedagio> buscarTodosExceto(Integer ... idClase){
|
||||||
|
return precioFixoPedagioDAO.buscarTodosExceto(idClase);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PrecioFixoPedagio> buscarPorEmpresasDoUsuario (List<Empresa> empresasUsuario) {
|
||||||
|
|
||||||
|
if(empresasUsuario == null || empresasUsuario.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder idEmpresasBuilder = new StringBuilder();
|
||||||
|
String idEmpresas = "";
|
||||||
|
|
||||||
|
for (Empresa empresa : empresasUsuario) {
|
||||||
|
idEmpresasBuilder.append(empresa.getEmpresaId().toString()).append(",");
|
||||||
|
}
|
||||||
|
|
||||||
|
idEmpresasBuilder = idEmpresasBuilder.deleteCharAt(idEmpresasBuilder.length() -1);
|
||||||
|
idEmpresas = idEmpresasBuilder.toString();
|
||||||
|
|
||||||
|
List<PrecioFixoPedagio> result = (List<PrecioFixoPedagio>) precioFixoPedagioDAO.buscarPorEmpresasDoUsuario(idEmpresas);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PrecioFixoPedagio suscribir(PrecioFixoPedagio entidad) {
|
||||||
|
|
||||||
|
return precioFixoPedagioDAO.suscribir(entidad);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public PrecioFixoPedagio actualizacion(PrecioFixoPedagio entidad) {
|
||||||
|
return precioFixoPedagioDAO.actualizacion(entidad);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void borrar(PrecioFixoPedagio entidad) {
|
||||||
|
precioFixoPedagioDAO.borrar(entidad);
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public Boolean validarInclusaoPrecoFixo(PrecioFixoPedagio precoFixoPedagio) {
|
||||||
|
List<PrecioFixoPedagio> precos = buscar(precoFixoPedagio);
|
||||||
|
|
||||||
|
|
||||||
|
if(precos.isEmpty()){
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Boolean.FALSE;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<PrecioFixoPedagio> buscar(PrecioFixoPedagio precoFixoPedagio) {
|
||||||
|
|
||||||
|
return precioFixoPedagioHibernateDAO.buscarPrecioFixoPedagio(precoFixoPedagio);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PrecioFixoPedagio> buscarPrecioFixoPedagio(PrecioFixoPedagio obj) {
|
||||||
|
|
||||||
|
return precioFixoPedagioDAO.buscarPrecioFixoPedagio(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue