fixes bug #7962
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@60540 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
b425ab8c19
commit
f20bc07835
|
@ -24,6 +24,7 @@ import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||||
import com.rjconsultores.ventaboletos.entidad.TarifaOficial;
|
import com.rjconsultores.ventaboletos.entidad.TarifaOficial;
|
||||||
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
||||||
|
import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties;
|
||||||
|
|
||||||
@Repository("tarifaOficialDAO")
|
@Repository("tarifaOficialDAO")
|
||||||
public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial, Integer> implements TarifaOficialDAO {
|
public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial, Integer> implements TarifaOficialDAO {
|
||||||
|
@ -262,6 +263,69 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
||||||
|
|
||||||
public void atualizarPedagio() {
|
public void atualizarPedagio() {
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
|
|
||||||
|
if (ApplicationProperties.getInstance().artespPedagioIdaVoltaDivPor2()) {
|
||||||
|
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 and 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.ruta_id <> t_1.ruta_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 ");
|
||||||
|
sql.append(" INNER JOIN tarifas_ofic tof ");
|
||||||
|
sql.append(" ON p.ORGAOCONCEDENTE_ID = tof.ORGAOCONCEDENTE_ID ");
|
||||||
|
sql.append(" AND p.ruta_id = tof.ruta_id ");
|
||||||
|
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 ");
|
||||||
|
sql.append(" ON p.ORGAOCONCEDENTE_ID = tof.ORGAOCONCEDENTE_ID ");
|
||||||
|
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(" ) , ");
|
||||||
|
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(" 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(" ");
|
||||||
|
sql.append(" ) tarifa_importe ");
|
||||||
|
sql.append(" on (tarifa_oficial.tarifaoficial_id = tarifa_importe.tarifaoficial_id) ");
|
||||||
|
sql.append(" when matched then ");
|
||||||
|
sql.append(" update set ");
|
||||||
|
sql.append(" importepedagio = tarifa_importe.soma ");
|
||||||
|
}else{
|
||||||
sql.append(" merge into tarifa_oficial ");
|
sql.append(" merge into tarifa_oficial ");
|
||||||
sql.append(" using ");
|
sql.append(" using ");
|
||||||
sql.append(" ( ");
|
sql.append(" ( ");
|
||||||
|
@ -280,6 +344,8 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
||||||
sql.append(" when matched then ");
|
sql.append(" when matched then ");
|
||||||
sql.append(" update set ");
|
sql.append(" update set ");
|
||||||
sql.append(" importepedagio = tarifa_importe.soma ");
|
sql.append(" importepedagio = tarifa_importe.soma ");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Connection conn = getSession().connection();
|
Connection conn = getSession().connection();
|
||||||
Statement stmt;
|
Statement stmt;
|
||||||
|
|
|
@ -159,6 +159,12 @@ public class ApplicationProperties {
|
||||||
return property.equals("1");
|
return property.equals("1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean artespPedagioIdaVoltaDivPor2() {
|
||||||
|
String property = p.getProperty("artespPedagioIdaVoltaDivPor2", "0");
|
||||||
|
return property.equals("1");
|
||||||
|
}
|
||||||
|
|
||||||
public Integer maxSizeNumCorrida(){
|
public Integer maxSizeNumCorrida(){
|
||||||
String property = p.getProperty("maxSizeNumCorrida", "-1");
|
String property = p.getProperty("maxSizeNumCorrida", "-1");
|
||||||
return Integer.parseInt(property);
|
return Integer.parseInt(property);
|
||||||
|
|
Loading…
Reference in New Issue