fixed bug #9577 - Correção de arredondamento em query de atualização de pedágio.
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@72814 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
02a384ca65
commit
d94fbe3019
|
@ -161,7 +161,7 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
|||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa, Integer usuarioId, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro, Boolean calculaTPP, Empresa empresa, OrgaoConcedente orgaoConcedente) {
|
||||
//Apago antes as tarifas que podem estar como activo =0
|
||||
//Apago antes as tarifas que podem estar como activo =0
|
||||
apagarTarifasInativas(vigenciaTarifa, empresa, orgaoConcedente);
|
||||
|
||||
// Insiro as tarifas que não existem
|
||||
|
@ -238,10 +238,10 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
|||
query = query.substring(0, query.length() - 1);
|
||||
query += "))";
|
||||
}
|
||||
|
||||
|
||||
long qtd = 0;
|
||||
Query q = getSession().createQuery(query);
|
||||
|
||||
|
||||
qtd = (Long) q.list().get(0);
|
||||
|
||||
return qtd;
|
||||
|
@ -278,25 +278,25 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
|||
sql.append(" merge into tarifa_oficial ");
|
||||
sql.append(" using ");
|
||||
sql.append(" ( ");
|
||||
sql.append(" WITH tarifas_ofic as ( ");
|
||||
sql.append(" select tarifaoficial_id, ORGAOCONCEDENTE_ID, ruta_id , origen_id , DESTINO_ID from tarifa_oficial where activo = 1");
|
||||
sql.append(" WITH tarifas_ofic as ( ");
|
||||
sql.append(" select tarifaoficial_id, ORGAOCONCEDENTE_ID, ruta_id , origen_id , DESTINO_ID from tarifa_oficial where activo = 1");
|
||||
sql.append(" ), ");
|
||||
|
||||
|
||||
sql.append(" noArtesp as (select p.destino_id dest, p.origen_id as orig , p.ruta_id as idruta ,p.orgaoconcedente_id as idorgao, ");
|
||||
sql.append(" p.importepeaje as importe , p.activo as actv from peaje p inner join tarifas_ofic tof on ");
|
||||
sql.append(" p.ORGAOCONCEDENTE_ID = tof.ORGAOCONCEDENTE_ID and p.ruta_id = tof.ruta_id ");
|
||||
sql.append(" and p.ORIGEN_ID = tof.ORIGEN_ID and p.DESTINO_ID = tof.DESTINO_ID and p.activo = 1), ");
|
||||
|
||||
|
||||
sql.append(" linha as ( select * from ruta where ruta_id in (select ruta_id from tarifas_ofic ) ) , ");
|
||||
sql.append(" linha_voltaId as (select ru.ruta_id rutavolta_id, t_1.ruta_id as ida from ruta ru ");
|
||||
sql.append(" inner join linha t_1 on ru.prefixo like t_1.prefixo ");
|
||||
sql.append(" and ru.orgaoconcedente_id = t_1.orgaoconcedente_id ");
|
||||
sql.append(" and ru.indsentidoIda <> t_1.indsentidoIda ");
|
||||
sql.append(" and ( (ru.numruta like t_1.numruta) or (ru.numruta like (to_char(to_Number(t_1.numruta)+1))) ) ");
|
||||
sql.append(" and ( (ru.numruta like t_1.numruta) or (ru.numruta like (to_char(to_Number(t_1.numruta)+1))) ) ");
|
||||
sql.append(" and ru.ruta_id <> t_1.ruta_id ");
|
||||
sql.append(" and ru.claseservicio_id = t_1.claseservicio_id ");
|
||||
sql.append(" and ru.claseservicio_id = t_1.claseservicio_id ");
|
||||
sql.append(" where ru.activo = 1), ");
|
||||
|
||||
|
||||
sql.append(" artesp as ( ");
|
||||
sql.append(" SELECT * ");
|
||||
sql.append(" FROM peaje p ");
|
||||
|
@ -306,9 +306,9 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
|||
sql.append(" AND p.ORIGEN_ID = tof.ORIGEN_ID ");
|
||||
sql.append(" AND p.DESTINO_ID = tof.DESTINO_ID ");
|
||||
sql.append(" AND p.activo = 1 ");
|
||||
|
||||
|
||||
sql.append(" union ");
|
||||
|
||||
|
||||
sql.append(" SELECT * ");
|
||||
sql.append(" FROM peaje p ");
|
||||
sql.append(" INNER JOIN tarifas_ofic tof ");
|
||||
|
@ -316,19 +316,19 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
|||
sql.append(" AND p.ruta_id = (select rutavolta_id from linha_voltaId where linha_voltaId.ida = tof.ruta_id) ");
|
||||
sql.append(" AND p.DESTINO_ID = tof.ORIGEN_ID ");
|
||||
sql.append(" AND p.ORIGEN_ID = tof.DESTINO_ID ");
|
||||
sql.append(" AND p.activo = 1 ");
|
||||
sql.append(" AND p.ruta_id = (select rutavolta_id from linha_voltaId where linha_voltaId.ida = tof.ruta_id) ");
|
||||
sql.append(" AND p.activo = 1 ");
|
||||
sql.append(" AND p.ruta_id = (select rutavolta_id from linha_voltaId where linha_voltaId.ida = tof.ruta_id) ");
|
||||
sql.append(" ) , ");
|
||||
sql.append(" resultado as ( ");
|
||||
sql.append(" select distinct tof.tarifaoficial_id tarifaoficial_id, tof.ruta_id as ruta, ");
|
||||
sql.append(" ( case tof.orgaoconcedente_id ");
|
||||
sql.append(" when 21 then ( select (sum(importepeaje)/2) from artesp ar where ar.tarifaoficial_id = tof.tarifaoficial_id ) ");
|
||||
sql.append(" select distinct tof.tarifaoficial_id tarifaoficial_id, tof.ruta_id as ruta, ");
|
||||
sql.append(" ( case tof.orgaoconcedente_id ");
|
||||
sql.append(" when 21 then ( select (sum(round(importepeaje,2))/2) from artesp ar where ar.tarifaoficial_id = tof.tarifaoficial_id ) ");
|
||||
sql.append(" else ( select distinct sum(noar.importe) from noArtesp noar where noar.idorgao = tof.ORGAOCONCEDENTE_ID and noar.idruta = tof.ruta_id ");
|
||||
sql.append(" and noar.ORIG = tof.ORIGEN_ID and noar.DEST = tof.DESTINO_ID and noar.actv = 1 ) ");
|
||||
sql.append(" end ) importepeaje from tarifas_ofic tof ");
|
||||
sql.append(" ), ");
|
||||
sql.append(" peaje_tarifas as ( select * from resultado ) ");
|
||||
sql.append(" select pf.tarifaoficial_id , sum(importepeaje) as soma from peaje_tarifas pf Group by pf.tarifaoficial_id ");
|
||||
sql.append(" peaje_tarifas as ( select * from resultado ) ");
|
||||
sql.append(" select pf.tarifaoficial_id , sum(round(importepeaje,2)) as soma from peaje_tarifas pf Group by pf.tarifaoficial_id ");
|
||||
sql.append(" ");
|
||||
sql.append(" ) tarifa_importe ");
|
||||
sql.append(" on (tarifa_oficial.tarifaoficial_id = tarifa_importe.tarifaoficial_id) ");
|
||||
|
@ -347,7 +347,7 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
|||
sql.append(" p.ORGAOCONCEDENTE_ID = tof.ORGAOCONCEDENTE_ID and p.ruta_id = tof.ruta_id ");
|
||||
sql.append(" and p.ORIGEN_ID = tof.ORIGEN_ID and p.DESTINO_ID = tof.DESTINO_ID and p.activo = 1 ");
|
||||
sql.append(" ) ");
|
||||
sql.append(" select pf.tarifaoficial_id , sum(importepeaje) as soma from peaje_tarifas pf Group by pf.tarifaoficial_id ");
|
||||
sql.append(" select pf.tarifaoficial_id , sum(round(importepeaje,2)) as soma from peaje_tarifas pf Group by pf.tarifaoficial_id ");
|
||||
sql.append(" ");
|
||||
sql.append(" ) tarifa_importe ");
|
||||
sql.append(" on (tarifa_oficial.tarifaoficial_id = tarifa_importe.tarifaoficial_id) ");
|
||||
|
@ -355,7 +355,7 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
|||
sql.append(" update set ");
|
||||
sql.append(" importepedagio = tarifa_importe.soma ");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Connection conn = getSession().connection();
|
||||
Statement stmt;
|
||||
|
@ -363,8 +363,8 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
|||
stmt = conn.createStatement();
|
||||
stmt.executeUpdate(sql.toString());
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
log.error("Erro na atualização do pedágio");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue