diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDemandasDetalhado.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDemandasDetalhado.java index 0ded36dfc..8f80644d1 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDemandasDetalhado.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDemandasDetalhado.java @@ -99,9 +99,11 @@ public class RelatorioDemandasDetalhado extends RelatorioDemandas { sql.append(" ON "); sql.append(" e.EMPRESA_ID = bol.EMPRESACORRIDA_ID "); sql.append(" WHERE "); - sql.append(" bol.FECHORVIAJE >= :DATA_INICIAL "); - sql.append(" AND bol.FECHORVIAJE <= :DATA_FINAL "); - sql.append(" AND BOL.MOTIVOCANCELACION_ID IS NULL "); + sql.append(" BOL.MOTIVOCANCELACION_ID IS NULL "); + if (parametros.get("HORA_INICIAL") == null && parametros.get("HORA_FINAL") == null) { + sql.append(" and bol.FECHORVIAJE >= :DATA_INICIAL "); + sql.append(" AND bol.FECHORVIAJE <= :DATA_FINAL "); + } if (parametros.get("RUTA_ID") != null) { sql.append(" AND r.RUTA_ID = :RUTA_ID "); } @@ -192,9 +194,11 @@ public class RelatorioDemandasDetalhado extends RelatorioDemandas { sql.append(" LEFT JOIN empresa e "); sql.append(" ON e.EMPRESA_ID = c.EMPRESACORRIDA_ID "); sql.append(" WHERE "); - sql.append(" c.FECHORSALIDA >= :DATA_INICIAL "); - sql.append(" AND c.FECHORSALIDA <= :DATA_FINAL "); - sql.append(" and c.activo = 1 "); + sql.append(" c.activo = 1 "); + if (parametros.get("HORA_INICIAL") == null && parametros.get("HORA_FINAL") == null) { + sql.append(" and c.FECHORSALIDA >= :DATA_INICIAL "); + sql.append(" AND c.FECHORSALIDA <= :DATA_FINAL "); + } if (parametros.get("PARADA_ID") != null) { sql.append(" AND p_origem.PARADA_ID = :PARADA_ID "); @@ -250,8 +254,10 @@ public class RelatorioDemandasDetalhado extends RelatorioDemandas { if (parametros.get("TIPO_SERVICO") != null) { stmt.setInt("TIPO_SERVICO", Integer.valueOf(parametros.get("TIPO_SERVICO").toString())); } - stmt.setTimestamp("DATA_INICIAL", new Timestamp(DateUtil.inicioFecha((Date) parametros.get("DATA_INICIAL")).getTime())); - stmt.setTimestamp("DATA_FINAL", new Timestamp(DateUtil.fimFecha((Date) parametros.get("DATA_FINAL")).getTime())); + if (parametros.get("HORA_INICIAL") == null && parametros.get("HORA_FINAL") == null) { + stmt.setTimestamp("DATA_INICIAL", new Timestamp(DateUtil.inicioFecha((Date) parametros.get("DATA_INICIAL")).getTime())); + stmt.setTimestamp("DATA_FINAL", new Timestamp(DateUtil.fimFecha((Date) parametros.get("DATA_FINAL")).getTime())); + } ResultSet rset = stmt.executeQuery(); diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDemandasDetalhadoNovoLayout.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDemandasDetalhadoNovoLayout.java index e41b93efe..8eb3c5567 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDemandasDetalhadoNovoLayout.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDemandasDetalhadoNovoLayout.java @@ -76,7 +76,9 @@ public class RelatorioDemandasDetalhadoNovoLayout extends RelatorioDemandas { sql.append(" join tipo_servicio ts on ts.tiposervicio_id = co.tiposervicio_id "); sql.append("where ct.activo = 1 "); sql.append(" and bo.motivocancelacion_id is null and bo.numasiento is not null and bo.indstatusoperacion = 'F' "); - sql.append(" and co.fechorsalida >= :DATA_INICIAL and co.fechorsalida <= :DATA_FINAL "); + if (parametros.get("HORA_INICIAL") == null && parametros.get("HORA_FINAL") == null) { + sql.append(" and co.fechorsalida >= :DATA_INICIAL and co.fechorsalida <= :DATA_FINAL "); + } sql.append(" and co.activo = 1 and bo.activo = 1 and ct.activo = 1 and r.activo = 1 and e.activo = 1 and ori.activo = 1 and "); sql.append(" des.activo = 1 and cs.activo = 1 and ro.activo = 1 and da.activo = 1 and ts.activo = 1 "); @@ -160,7 +162,9 @@ public class RelatorioDemandasDetalhadoNovoLayout extends RelatorioDemandas { sql.append(" ON ts.tiposervicio_id = co.tiposervicio_id "); sql.append(" WHERE ct.activo = 1 "); sql.append(" and co.activo = 1 "); - sql.append(" and co.FECHORSALIDA >= :DATA_INICIAL and co.FECHORSALIDA <= :DATA_FINAL "); + if (parametros.get("HORA_INICIAL") == null && parametros.get("HORA_FINAL") == null) { + sql.append(" and co.FECHORSALIDA >= :DATA_INICIAL and co.FECHORSALIDA <= :DATA_FINAL "); + } sql.append((parametros.get("EMPRESA_ID") != null) ? " and e.empresa_id = :EMPRESA_ID " : ""); sql.append((parametros.get("RUTA_ID") != null) ? " and r.ruta_id = :RUTA_ID " : ""); @@ -211,8 +215,10 @@ public class RelatorioDemandasDetalhadoNovoLayout extends RelatorioDemandas { if (parametros.get("TIPO_SERVICO") != null) stmt.setInt("TIPO_SERVICO", Integer.valueOf(parametros.get("TIPO_SERVICO").toString())); - stmt.setTimestamp("DATA_INICIAL", new Timestamp(DateUtil.inicioFecha((Date) parametros.get("DATA_INICIAL")).getTime())); - stmt.setTimestamp("DATA_FINAL", new Timestamp(DateUtil.fimFecha((Date) parametros.get("DATA_FINAL")).getTime())); + if (parametros.get("HORA_INICIAL") == null && parametros.get("HORA_FINAL") == null) { + stmt.setTimestamp("DATA_INICIAL", new Timestamp(DateUtil.inicioFecha((Date) parametros.get("DATA_INICIAL")).getTime())); + stmt.setTimestamp("DATA_FINAL", new Timestamp(DateUtil.fimFecha((Date) parametros.get("DATA_FINAL")).getTime())); + } ResultSet rset = stmt.executeQuery(); while (rset.next()) { diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioDemandasConsolidado.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioDemandasConsolidado.java index 914202776..4747f9f46 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioDemandasConsolidado.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioDemandasConsolidado.java @@ -64,9 +64,11 @@ public class RelatorioDemandasConsolidado extends RelatorioDemandas { sql.append(" LEFT JOIN TIPO_SERVICIO ts_normal ON ts_normal.TIPOSERVICIO_ID = cor.TIPOSERVICIO_ID and ts_normal.TIPOSERVICIO_ID = 1 "); sql.append(" LEFT JOIN TIPO_SERVICIO ts_extra ON ts_extra.TIPOSERVICIO_ID = cor.TIPOSERVICIO_ID and ts_extra.TIPOSERVICIO_ID = 2 "); sql.append(" LEFT JOIN empresa e ON e.EMPRESA_ID = bol.EMPRESACORRIDA_ID "); - sql.append(" WHERE "); - sql.append(" bol.FECHORVIAJE >= :DATA_INICIAL "); - sql.append(" AND bol.FECHORVIAJE <= :DATA_FINAL "); + sql.append(" WHERE 1=1 "); + if (parametros.get("HORA_INICIAL") == null && parametros.get("HORA_FINAL") == null) { + sql.append(" and bol.FECHORVIAJE >= :DATA_INICIAL "); + sql.append(" AND bol.FECHORVIAJE <= :DATA_FINAL "); + } sql.append(" AND bol.MOTIVOCANCELACION_ID is null "); if (parametros.get("RUTA_ID") != null) { @@ -127,9 +129,10 @@ public class RelatorioDemandasConsolidado extends RelatorioDemandas { stmt.setInt("TIPO_SERVICO", Integer.valueOf(parametros.get("TIPO_SERVICO").toString())); } - - stmt.setTimestamp("DATA_INICIAL", new Timestamp(DateUtil.inicioFecha(dataInicial.getTime()).getTime())); - stmt.setTimestamp("DATA_FINAL", new Timestamp(DateUtil.fimFecha(dataFinal.getTime()).getTime())); + if (parametros.get("HORA_INICIAL") == null && parametros.get("HORA_FINAL") == null) { + stmt.setTimestamp("DATA_INICIAL", new Timestamp(DateUtil.inicioFecha(dataInicial.getTime()).getTime())); + stmt.setTimestamp("DATA_FINAL", new Timestamp(DateUtil.fimFecha(dataFinal.getTime()).getTime())); + } ResultSet rset = stmt.executeQuery(); diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioDemandasController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioDemandasController.java index f9bd46089..9d1fe955c 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioDemandasController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioDemandasController.java @@ -212,7 +212,7 @@ public class RelatorioDemandasController extends MyGenericForwardComposer { SimpleDateFormat formatDate = new SimpleDateFormat("hh:mm"); filtro.append(" Hora de Saída: "); - if(horaInicial.getValue()!= null){ + if(horaInicial.getValue() != null){ filtro.append("De "); filtro.append(formatDate.format(horaInicial.getValue()) ); parametros.put("HORA_INICIAL", horaInicial.getValue()); diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioDemandasDiario.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioDemandasDiario.java index a41b266e6..59d5df926 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioDemandasDiario.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioDemandasDiario.java @@ -84,9 +84,11 @@ public class RelatorioDemandasDiario extends RelatorioDemandas { sql.append(" LEFT JOIN empresa e "); sql.append(" ON "); sql.append(" e.EMPRESA_ID = bol.EMPRESACORRIDA_ID "); - sql.append(" WHERE "); - sql.append(" bol.FECHORVIAJE >= :DATA_INICIAL "); - sql.append(" AND bol.FECHORVIAJE <= :DATA_FINAL "); + sql.append(" WHERE 1=1 "); + if (parametros.get("HORA_INICIAL") == null && parametros.get("HORA_FINAL") == null) { + sql.append(" and bol.FECHORVIAJE >= :DATA_INICIAL "); + sql.append(" AND bol.FECHORVIAJE <= :DATA_FINAL "); + } sql.append(" AND bol.MOTIVOCANCELACION_ID is null "); if (parametros.get("RUTA_ID") != null) { sql.append(" AND r.RUTA_ID = :RUTA_ID "); @@ -148,9 +150,10 @@ public class RelatorioDemandasDiario extends RelatorioDemandas { if (parametros.get("TIPO_SERVICO") != null) { stmt.setInt("TIPO_SERVICO", Integer.valueOf(parametros.get("TIPO_SERVICO").toString())); } - stmt.setTimestamp("DATA_INICIAL", new Timestamp(DateUtil.inicioFecha((Date) parametros.get("DATA_INICIAL")).getTime())); - stmt.setTimestamp("DATA_FINAL", new Timestamp(DateUtil.fimFecha((Date) parametros.get("DATA_FINAL")).getTime())); - + if (parametros.get("HORA_INICIAL") == null && parametros.get("HORA_FINAL") == null) { + stmt.setTimestamp("DATA_INICIAL", new Timestamp(DateUtil.inicioFecha((Date) parametros.get("DATA_INICIAL")).getTime())); + stmt.setTimestamp("DATA_FINAL", new Timestamp(DateUtil.fimFecha((Date) parametros.get("DATA_FINAL")).getTime())); + } ResultSet rset = stmt.executeQuery(); while (rset.next()) {