diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioCorridas.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioCorridas.java index 564e26319..485f338e0 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioCorridas.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioCorridas.java @@ -28,14 +28,21 @@ public class RelatorioCorridas extends Relatorio { Connection conexao = this.relatorio.getConexao(); Map parametros = this.relatorio.getParametros(); + + Integer origem = (Integer) parametros.get("ORIGEN_ID"); + Integer destino = (Integer) parametros.get("DESTINO_ID"); - NamedParameterStatement nps = new NamedParameterStatement(conexao, getSql()); + NamedParameterStatement nps = new NamedParameterStatement(conexao, getSql(origem, destino)); nps.setInt("numServico", (Integer) parametros.get("CORRIDA_ID")); nps.setInt("empresaId", Integer.valueOf((String) parametros.get("EMPRESA_ID"))); nps.setDate("inicioViagem", (java.sql.Date) parametros.get("DATA_DE")); nps.setDate("fimViagem", (java.sql.Date) parametros.get("DATA_ATE")); - nps.setInt("origemId", (Integer) parametros.get("ORIGEN_ID")); - nps.setInt("destinoId", (Integer) parametros.get("DESTINO_ID")); + if (origem != -1) { + nps.setInt("origemId", (Integer) parametros.get("ORIGEN_ID")); + } + if (destino != -1) { + nps.setInt("destinoId", (Integer) parametros.get("DESTINO_ID")); + } ResultSet rset = nps.executeQuery(); @@ -85,7 +92,7 @@ public class RelatorioCorridas extends Relatorio { }); } - private String getSql() { + private String getSql(Integer origem, Integer destino) { StringBuilder sb = new StringBuilder(); sb.append("select b.corrida_id as servico, "); sb.append(" porigen.descparada as origem, "); @@ -118,8 +125,12 @@ public class RelatorioCorridas extends Relatorio { sb.append(" left join clase_servicio cs on b.claseservicio_id = cs.claseservicio_id "); sb.append("where b.activo = 1 "); sb.append(" and b.motivocancelacion_id is null "); + if(origem != -1){ sb.append(" and b.origen_id = :origemId "); + } + if(destino != -1){ sb.append(" and b.destino_id = :destinoId "); + } sb.append(" and e.empresa_id = :empresaId "); sb.append(" and b.corrida_id = :numServico "); sb.append(" and b.feccorrida between :inicioViagem and :fimViagem ");