fix bug #0009037 - corrigido duplicação de preço na geração do preço do pedagio

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@69375 d1611594-4594-4d17-8e1d-87c2c4800839
master
bruno.neves 2017-05-26 22:31:28 +00:00
parent 490f734bc7
commit db0b6b31ad
2 changed files with 150 additions and 7 deletions

View File

@ -10,12 +10,14 @@ import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.velocity.runtime.directive.Foreach;
import org.hibernate.Query; import org.hibernate.Query;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -150,10 +152,12 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
boolean isOrgaoNull = orgao == null; boolean isOrgaoNull = orgao == null;
List<String> updates = new ArrayList<String>(); List<String> updates = new ArrayList<String>();
List<PeajeVO> peajes = new ArrayList<PeajeVO>(); List<PeajeVO> peajes = new ArrayList<PeajeVO>();
List<ClasseIndicePeaje> classeIndicePeajes = new ArrayList<ClasseIndicePeaje>(); List<ClasseIndicePeaje> classeIndicePeajes = new ArrayList<ClasseIndicePeaje>();
if(orgao != null){ if(orgao != null){
orgao = orgaoConcedenteService.obtenerID(orgao.getOrgaoConcedenteId()); orgao = orgaoConcedenteService.obtenerID(orgao.getOrgaoConcedenteId());
classeIndicePeajes = orgao.getClassesIndicePeaje(); classeIndicePeajes = orgao.getClassesIndicePeaje();
isOrgaoNull = orgao == null;
} }
log.debug("****** INICIO DO PROCESSO DE CALCULO DE PEDAGIO ******"); log.debug("****** INICIO DO PROCESSO DE CALCULO DE PEDAGIO ******");
@ -165,6 +169,7 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
List<Object> lsObj = buscarCasetasPeajeWithinTramo(ruta); List<Object> lsObj = buscarCasetasPeajeWithinTramo(ruta);
log.debug("****** QTD COMBINAÇÕES DE TRECHOS x QTD PEDAGIOS POR TRECHO: "+lsObj.size()+" ******"); log.debug("****** QTD COMBINAÇÕES DE TRECHOS x QTD PEDAGIOS POR TRECHO: "+lsObj.size()+" ******");
if(isOrgaoNull){ if(isOrgaoNull){
orgao = orgaoConcedenteService.obtenerID(ruta.getOrgaoConcedente().getOrgaoConcedenteId()); orgao = orgaoConcedenteService.obtenerID(ruta.getOrgaoConcedente().getOrgaoConcedenteId());
classeIndicePeajes = orgao.getClassesIndicePeaje(); classeIndicePeajes = orgao.getClassesIndicePeaje();
@ -172,7 +177,6 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
updates.add(update); updates.add(update);
} }
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()) ;
@ -187,6 +191,7 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
List<PrecioFixoPedagio> list = precioFixoPedagioService.buscarPrecioFixoPedagio(pfp); List<PrecioFixoPedagio> list = precioFixoPedagioService.buscarPrecioFixoPedagio(pfp);
if(list.size()>=1){ if(list.size()>=1){
pvo.importePeaje = list.get(0).getValorFixo(); pvo.importePeaje = list.get(0).getValorFixo();
} }
@ -197,6 +202,18 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
} }
log.debug("****** FIM DO PROCESSO DE CALCULO DE PEDAGIO ******"); log.debug("****** FIM DO PROCESSO DE CALCULO DE PEDAGIO ******");
if(peajes.size()>1){
for (int i = 0 ; peajes.size()>i;) {
int posicao = peajes.lastIndexOf(peajes.get(i));
if(posicao != i){
peajes.remove(posicao);
i=0;
}else{
i++;
}
}
}
StringBuilder updateSql = new StringBuilder(); StringBuilder updateSql = new StringBuilder();
if(isOrgaoNull == false){ if(isOrgaoNull == false){
updateSql = new StringBuilder() updateSql = new StringBuilder()
@ -515,5 +532,92 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
.append(")") .append(")")
.toString(); .toString();
} }
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((activo == null) ? 0 : activo.hashCode());
result = prime * result + ((cantAsientos == null) ? 0 : cantAsientos.hashCode());
result = prime * result + ((cantEixos == null) ? 0 : cantEixos.hashCode());
result = prime * result + ((casetaPeajeId == null) ? 0 : casetaPeajeId.hashCode());
result = prime * result + ((destinoId == null) ? 0 : destinoId.hashCode());
result = prime * result + ((importePeaje == null) ? 0 : importePeaje.hashCode());
result = prime * result + ((indicePeaje == null) ? 0 : indicePeaje.hashCode());
result = prime * result + ((orgaoId == null) ? 0 : orgaoId.hashCode());
result = prime * result + ((origenId == null) ? 0 : origenId.hashCode());
result = prime * result + ((rutaId == null) ? 0 : rutaId.hashCode());
result = prime * result + ((usuarioId == null) ? 0 : usuarioId.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;
PeajeVO other = (PeajeVO) obj;
if (activo == null) {
if (other.activo != null)
return false;
} else if (!activo.equals(other.activo))
return false;
if (cantAsientos == null) {
if (other.cantAsientos != null)
return false;
} else if (!cantAsientos.equals(other.cantAsientos))
return false;
if (cantEixos == null) {
if (other.cantEixos != null)
return false;
} else if (!cantEixos.equals(other.cantEixos))
return false;
if (casetaPeajeId == null) {
if (other.casetaPeajeId != null)
return false;
} else if (!casetaPeajeId.equals(other.casetaPeajeId))
return false;
if (destinoId == null) {
if (other.destinoId != null)
return false;
} else if (!destinoId.equals(other.destinoId))
return false;
if (importePeaje == null) {
if (other.importePeaje != null)
return false;
} else if (!importePeaje.equals(other.importePeaje))
return false;
if (indicePeaje == null) {
if (other.indicePeaje != null)
return false;
} else if (!indicePeaje.equals(other.indicePeaje))
return false;
if (orgaoId == null) {
if (other.orgaoId != null)
return false;
} else if (!orgaoId.equals(other.orgaoId))
return false;
if (origenId == null) {
if (other.origenId != null)
return false;
} else if (!origenId.equals(other.origenId))
return false;
if (rutaId == null) {
if (other.rutaId != null)
return false;
} else if (!rutaId.equals(other.rutaId))
return false;
if (usuarioId == null) {
if (other.usuarioId != null)
return false;
} else if (!usuarioId.equals(other.usuarioId))
return false;
return true;
}
} }
} }

View File

@ -5,6 +5,7 @@ package com.rjconsultores.ventaboletos.entidad;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Basic; import javax.persistence.Basic;
import javax.persistence.Column; import javax.persistence.Column;
@ -17,6 +18,8 @@ import javax.persistence.ManyToOne;
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.TemporalType;
/** /**
* @author Bruno Neves * @author Bruno Neves
@ -39,20 +42,31 @@ public class PrecioFixoPedagio implements Serializable {
private Integer precioFixoId; private Integer precioFixoId;
@ManyToOne @ManyToOne
@JoinColumn(name = "PRACA_PEDAGIO_ID", referencedColumnName = "CASETAPEAJE_ID") @JoinColumn(name = "PRACAPEDAGIO_ID", referencedColumnName = "CASETAPEAJE_ID")
private CasetaPeaje pracaPedagioId; private CasetaPeaje pracaPedagioId;
@OneToOne @OneToOne
@JoinColumn(name = "ORGAO_CONCEDENTE_ID", referencedColumnName = "ORGAOCONCEDENTE_ID") @JoinColumn(name = "ORGAOCONCEDENTE_ID", referencedColumnName = "ORGAOCONCEDENTE_ID")
private OrgaoConcedente orgaoConcedenteId; private OrgaoConcedente orgaoConcedenteId;
@OneToOne @OneToOne
@JoinColumn(name = "CLASSE_SERVICO_ID", referencedColumnName = "CLASESERVICIO_ID") @JoinColumn(name = "CLASSESERVICO_ID", referencedColumnName = "CLASESERVICIO_ID")
private ClaseServicio classeId; private ClaseServicio classeId;
@Column(name = "VALOR_FIXO") @Column(name = "VALORFIXO")
private BigDecimal valorFixo; private BigDecimal valorFixo;
@Column(name = "ACTIVO")
private Boolean activo;
@Column(name = "FECMODIF")
@Temporal(TemporalType.TIMESTAMP)
private Date fecmodif;
@Column(name = "USUARIO_ID")
private Integer usuarioId;
public Integer getPrecioFixoId() { public Integer getPrecioFixoId() {
return precioFixoId; return precioFixoId;
} }
@ -93,6 +107,31 @@ public class PrecioFixoPedagio implements Serializable {
this.valorFixo = valorFixo; this.valorFixo = valorFixo;
} }
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;
}
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;