fixed bug #7674: Correção no cálculo de pedágio
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@61096 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
5f40de5e20
commit
8b87c7d9eb
|
@ -14,14 +14,12 @@ import java.util.LinkedHashSet;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.rjconsultores.ventaboletos.constantes.Constantes;
|
||||
import com.rjconsultores.ventaboletos.dao.CalcularPeajeDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.CasetaPeaje;
|
||||
|
@ -84,7 +82,7 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
|
|||
.append(" inner join tramo t on t.tramo_id = rcom.tramo_id ")
|
||||
.append(" where r.ruta_id = :rutaId ")
|
||||
.append("), mytable as ( ")
|
||||
.append(" select eiorig.icms as icms_orig, eidest.icms as icms_dest, ")
|
||||
.append(" select eiorig.icms as icms, ")
|
||||
.append(" rseqorig.numsecuencia as origen_tramo_inicial_seq, rseqdest.numsecuencia as destino_tramo_final_seq, ")
|
||||
.append(" torig.tramo_id as tramo_orig, tdest.tramo_id as tramo_dest, ")
|
||||
.append(" tt.tra as tracomb, tt.orig as ttorig, tt.dest as ttdest, ")
|
||||
|
@ -101,10 +99,6 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
|
|||
.append(" inner join ciudad corig on corig.ciudad_id = porig.ciudad_id ")
|
||||
.append(" inner join estado eorig on eorig.estado_id = corig.estado_id ")
|
||||
.append(" inner join empresa_imposto eiorig on eiorig.empresa_id = e.empresa_id and eiorig.estado_id = eorig.estado_id ")
|
||||
.append(" inner join parada pdest on tdest.destino_id = pdest.parada_id ")
|
||||
.append(" inner join ciudad cdest on cdest.ciudad_id = pdest.ciudad_id ")
|
||||
.append(" inner join estado edest on edest.estado_id = cdest.estado_id ")
|
||||
.append(" inner join empresa_imposto eidest on eidest.empresa_id = e.empresa_id and eidest.estado_id = edest.estado_id ")
|
||||
.append(" inner join tramo_tmp tt on torig.origen_id = tt.orig and tdest.destino_id = tt.dest ")
|
||||
.append("), caseta_tramo_da_ruta as ( ")
|
||||
.append(" select rcas.rutacaseta_id as rutacasetaid, rcas.rutasecuencia_id as rutasecuenciaid, rcas.casetapeaje_id, ")
|
||||
|
@ -121,7 +115,7 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
|
|||
.append("select distinct origen_tramo_inicial_seq, destino_tramo_final_seq, tramo_orig, tramo_dest, tracomb, ttorig, ttdest, ")
|
||||
.append(" tracombdesc, tracomborig, tracombdest, tracombvia, tracombcantkm, tracombcantkmpago, tracombactivo, ")
|
||||
.append(" tracombfecmodif, tracombusuario, rutacasetaid, rutasecuenciaid, casetapeaje_id, tramoid, casetapeajeid, ")
|
||||
.append(" desccaseta, importeida, importevuelta, caspactivo, caspfecmodif, caspusuario, icms_orig, icms_dest ")
|
||||
.append(" desccaseta, importeida, importevuelta, caspactivo, caspfecmodif, caspusuario, icms ")
|
||||
.append("from mytable my ")
|
||||
.append(" inner join caseta_tramo_da_ruta ctr on ctr.numsecuencia between my.origen_tramo_inicial_seq and my.destino_tramo_final_seq ")
|
||||
.append(" order by tracomb ");
|
||||
|
@ -138,13 +132,13 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
|
|||
// pra cada ruta obter as combinacoes de tramos, cada tramo com sua lista de casetaPeaje
|
||||
public int[] gerarSQLInserirPeajes(List<Ruta> lsRuta, OrgaoConcedente orgao) {
|
||||
List<PeajeVO> peajes = new ArrayList<PeajeVO>();
|
||||
OrgaoConcedente orgaoConcedente = orgaoConcedenteService.obtenerID(orgao.getOrgaoConcedenteId());
|
||||
List<ClasseIndicePeaje> classeIndicePeajes = orgaoConcedente.getClassesIndicePeaje();
|
||||
orgao = orgaoConcedenteService.obtenerID(orgao.getOrgaoConcedenteId());
|
||||
List<ClasseIndicePeaje> classeIndicePeajes = orgao.getClassesIndicePeaje();
|
||||
for (Ruta ruta : lsRuta) {
|
||||
List<Object> lsObj = buscarCasetasPeajeWithinTramo(ruta);
|
||||
if (null != lsObj) {
|
||||
for (Object arrObj : lsObj) {
|
||||
peajes.add(PeajeVO.create(ruta, orgaoConcedente, (Object[]) arrObj, classeIndicePeajes));
|
||||
peajes.add(PeajeVO.create(ruta, orgao, (Object[]) arrObj, classeIndicePeajes));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -169,8 +163,8 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
|
|||
result = stmt.executeBatch();
|
||||
con.commit();
|
||||
recalcularExcecoesPedagio(peajes);
|
||||
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -287,7 +281,8 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
|
|||
private static BigDecimal getRutaCantAsientos(Ruta ruta) {
|
||||
try {
|
||||
return new BigDecimal(ruta.getCantAsientos());
|
||||
} catch (NullPointerException e) {
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
throw new RuntimeException("rutaSemQtdAsientos;" + ruta.getRutaId());
|
||||
}
|
||||
}
|
||||
|
@ -295,20 +290,14 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
|
|||
private static BigDecimal getImporte(Ruta ruta, Object[] obj) {
|
||||
if (ruta.getIndSentidoIda()) {
|
||||
return new BigDecimal(obj[22].toString());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return new BigDecimal(obj[23].toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static BigDecimal getIcms(Ruta ruta, Object[] obj) {
|
||||
String icms = null;
|
||||
if (ruta.getIndSentidoIda()) {
|
||||
icms = obj[27].toString();
|
||||
} else {
|
||||
icms = obj[28].toString();
|
||||
}
|
||||
|
||||
return new BigDecimal(icms)
|
||||
return new BigDecimal(obj[27].toString())
|
||||
.divide(A_HUNDRED, HIGH_PRECISION, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
|
@ -317,15 +306,15 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
|
|||
BigDecimal indice, BigDecimal rutaCantEixos, BigDecimal rutaCantAsientos) {
|
||||
|
||||
if (ApplicationProperties.getInstance().calculoPeajeReunidasANTT()) {
|
||||
//pedágio * eixo / indice - > REUNIDAS
|
||||
BigDecimal big = new BigDecimal((importe.doubleValue() * rutaCantEixos.doubleValue() / indice.doubleValue())) ;
|
||||
return big;
|
||||
}else{
|
||||
// (importe * rutaCantEixos) / (indice)
|
||||
return importe.multiply(rutaCantEixos)
|
||||
.divide(indice, HIGH_PRECISION, RoundingMode.HALF_UP);
|
||||
}
|
||||
else {
|
||||
return importe.multiply(rutaCantEixos)
|
||||
.divide(indice.multiply(rutaCantAsientos), HIGH_PRECISION, RoundingMode.HALF_UP)
|
||||
.divide(BigDecimal.ONE.subtract(icms), HIGH_PRECISION, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ((importe * rutaCantEixos) / (indice)) / ( 1 - icms)
|
||||
|
@ -353,8 +342,7 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
|
|||
}
|
||||
|
||||
private static BigDecimal getIndicePeaje(ClaseServicio claseServicio,
|
||||
OrgaoConcedente orgao,
|
||||
List<ClasseIndicePeaje> lsClasseIndicePeaje) {
|
||||
OrgaoConcedente orgao, List<ClasseIndicePeaje> lsClasseIndicePeaje) {
|
||||
|
||||
for (ClasseIndicePeaje classeIndicePeaje : lsClasseIndicePeaje) {
|
||||
if (claseServicio.equals(classeIndicePeaje.getClasseServicio())) {
|
||||
|
|
Loading…
Reference in New Issue