Relatório por Empresa corrida (fixed bug #5394)
Relatório por Empresa de Ônibus (fixed bug #5393) git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@36303 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
fb6cf5e9b9
commit
a95afc0fa7
|
@ -29,19 +29,19 @@ public class RelatorioEmpresaCorrida extends Relatorio {
|
|||
|
||||
Map<String, Object> parametros = this.relatorio.getParametros();
|
||||
|
||||
String fecInicio = parametros.get("fecInicio").toString();
|
||||
String fecFinal = parametros.get("fecFinal").toString();
|
||||
String fecInicio = parametros.get("fecInicio").toString() + " 00:00:00";
|
||||
String fecFinal = parametros.get("fecFinal").toString() + " 23:59:59";
|
||||
|
||||
String sql = getSql(fecInicio, fecFinal);
|
||||
String sql = getSql();
|
||||
|
||||
System.out.println(sql);
|
||||
|
||||
NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql);
|
||||
ResultSet rset = null;
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
||||
stmt.setDate("fecInicio", new java.sql.Date(sdf.parse(fecInicio).getTime()));
|
||||
stmt.setDate("fecFinal", new java.sql.Date(sdf.parse(fecFinal).getTime()));
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
|
||||
stmt.setTimestamp("fecInicio", new java.sql.Timestamp(sdf.parse(fecInicio).getTime()));
|
||||
stmt.setTimestamp("fecFinal", new java.sql.Timestamp(sdf.parse(fecFinal).getTime()));
|
||||
|
||||
rset = stmt.executeQuery();
|
||||
|
||||
|
@ -78,7 +78,7 @@ public class RelatorioEmpresaCorrida extends Relatorio {
|
|||
protected void processaParametros() throws Exception {
|
||||
}
|
||||
|
||||
private String getSql(String fecInicio, String fecFinal) {
|
||||
private String getSql() {
|
||||
StringBuffer sql = new StringBuffer();
|
||||
|
||||
sql.append("SELECT DISTINCT empresa_id, ");
|
||||
|
@ -94,17 +94,20 @@ public class RelatorioEmpresaCorrida extends Relatorio {
|
|||
sql.append(" AND b1.fechorventa BETWEEN :fecInicio AND :fecFinal) boletos, ");
|
||||
sql.append(" (SELECT COALESCE(Sum(preciopagado), 0) ");
|
||||
sql.append(" FROM boleto b1 ");
|
||||
sql.append(" WHERE b1.motivocancelacion_id IS NOT NULL ");
|
||||
sql.append(" WHERE b1.motivocancelacion_id IS NOT NULL AND b1.indstatusboleto = 'C' ");
|
||||
sql.append(" AND b1.empresacorrida_id = empresa_id ");
|
||||
sql.append(" AND b1.origen_id = b.origen_id ");
|
||||
sql.append(" AND b1.destino_id = b.destino_id ");
|
||||
sql.append(" AND b1.fechorventa BETWEEN :fecInicio AND :fecFinal) abonos, ");
|
||||
sql.append(" (SELECT COALESCE(Sum(cantkmreal), 0) ");
|
||||
sql.append(" FROM tramo t, ");
|
||||
sql.append(" FROM tramo t, ruta_combinacion rc, ");
|
||||
sql.append(" boleto b1, ");
|
||||
sql.append(" autobus a, ");
|
||||
sql.append(" corrida c ");
|
||||
sql.append(" WHERE t.origen_id = b1.origen_id ");
|
||||
sql.append(" AND b1.ruta_id = rc.ruta_id ");
|
||||
sql.append(" AND rc.activo = 1 ");
|
||||
sql.append(" AND t.tramo_id = rc.tramo_id ");
|
||||
sql.append(" AND t.destino_id = b1.destino_id ");
|
||||
sql.append(" AND c.corrida_id = b1.corrida_id ");
|
||||
sql.append(" AND a.autobus_id = c.autobus_id ");
|
||||
|
@ -114,11 +117,14 @@ public class RelatorioEmpresaCorrida extends Relatorio {
|
|||
sql.append(" AND b1.destino_id = b.destino_id ");
|
||||
sql.append(" AND b1.fechorventa BETWEEN :fecInicio AND :fecFinal) kmOnibusProprio, ");
|
||||
sql.append(" (SELECT COALESCE(Sum(cantkmreal), 0) ");
|
||||
sql.append(" FROM tramo t, ");
|
||||
sql.append(" FROM tramo t, ruta_combinacion rc, ");
|
||||
sql.append(" boleto b1, ");
|
||||
sql.append(" autobus a, ");
|
||||
sql.append(" corrida c ");
|
||||
sql.append(" WHERE t.origen_id = b1.origen_id ");
|
||||
sql.append(" AND b1.ruta_id = rc.ruta_id ");
|
||||
sql.append(" AND rc.activo = 1 ");
|
||||
sql.append(" AND t.tramo_id = rc.tramo_id ");
|
||||
sql.append(" AND t.destino_id = b1.destino_id ");
|
||||
sql.append(" AND c.corrida_id = b1.corrida_id ");
|
||||
sql.append(" AND a.autobus_id = c.autobus_id ");
|
||||
|
@ -128,10 +134,14 @@ public class RelatorioEmpresaCorrida extends Relatorio {
|
|||
sql.append(" AND b1.destino_id = b.destino_id ");
|
||||
sql.append(" AND b1.fechorventa BETWEEN :fecInicio AND :fecFinal) kmOnibusArrendados, ");
|
||||
sql.append(" (SELECT COALESCE(Sum(cantkmreal), 0) ");
|
||||
sql.append(" FROM tramo t, ");
|
||||
sql.append(" FROM tramo t, ruta_combinacion rc, ");
|
||||
sql.append(" boleto b1 ");
|
||||
sql.append(" WHERE t.origen_id = b1.origen_id ");
|
||||
sql.append(" AND b1.ruta_id = rc.ruta_id ");
|
||||
sql.append(" AND rc.activo = 1 ");
|
||||
sql.append(" AND t.tramo_id = rc.tramo_id ");
|
||||
sql.append(" AND t.destino_id = b1.destino_id ");
|
||||
sql.append(" AND b1.motivocancelacion_id is null ");
|
||||
sql.append(" AND b1.empresacorrida_id = empresa_id ");
|
||||
sql.append(" AND b1.origen_id = b.origen_id ");
|
||||
sql.append(" AND b1.destino_id = b.destino_id ");
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.rjconsultores.ventaboletos.relatorios.impl;
|
|||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -29,14 +30,17 @@ public class RelatorioEmpresaOnibus extends Relatorio {
|
|||
|
||||
Map<String, Object> parametros = this.relatorio.getParametros();
|
||||
|
||||
String fecInicio = parametros.get("fecInicio").toString();
|
||||
String fecFinal = parametros.get("fecFinal").toString();
|
||||
String fecInicio = parametros.get("fecInicio").toString() + " 00:00:00";
|
||||
String fecFinal = parametros.get("fecFinal").toString() + " 23:59:59";
|
||||
|
||||
String sql = getSql(fecInicio, fecFinal);
|
||||
String sql = getSql();
|
||||
|
||||
System.out.println(sql);
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
|
||||
NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql);
|
||||
stmt.setTimestamp("fecInicio", new java.sql.Timestamp(sdf.parse(fecInicio).getTime()));
|
||||
stmt.setTimestamp("fecFinal", new java.sql.Timestamp(sdf.parse(fecFinal).getTime()));
|
||||
ResultSet rset = null;
|
||||
|
||||
rset = stmt.executeQuery();
|
||||
|
@ -74,20 +78,21 @@ public class RelatorioEmpresaOnibus extends Relatorio {
|
|||
protected void processaParametros() throws Exception {
|
||||
}
|
||||
|
||||
private String getSql(String fecInicio, String fecFinal) {
|
||||
private String getSql() {
|
||||
StringBuffer sql = new StringBuffer();
|
||||
|
||||
sql.append(" select c.corrida_Id corridaId, e.nombempresa empresa, c.feccorrida dia, a.numautobus coche, ");
|
||||
sql.append(" o.cveparada origem, d.cveparada destino, ");
|
||||
sql.append(" to_char(c.fechorsalida, 'HH24:MI') Hora, t.cantkmreal KMTS ");
|
||||
sql.append(" from corrida c ");
|
||||
sql.append(" left join ruta_combinacion rc on rc.ruta_id = c.ruta_id ");
|
||||
sql.append(" left join parada o on o.parada_id = c.origen_id ");
|
||||
sql.append(" left join parada d on d.parada_id = c.destino_id ");
|
||||
sql.append(" left join tramo t on t.origen_id = c.origen_id and t.destino_id = c.destino_id ");
|
||||
sql.append(" left join tramo t on t.origen_id = c.origen_id and t.destino_id = c.destino_id and t.tramo_id = rc.tramo_id ");
|
||||
sql.append(" inner join autobus a on a.autobus_id = c.autobus_id ");
|
||||
sql.append(" left join empresa e on e.empresa_id = a.empresa_id ");
|
||||
sql.append(" where extract(month from c.feccorrida) = 6 ");
|
||||
sql.append(" and c.activo = 1 and c.feccorrida between to_date('" + fecInicio + "', 'DD/MM/YYYY') and to_date('" + fecFinal + "', 'DD/MM/YYYY') ");
|
||||
sql.append(" and c.activo = 1 and rc.activo = 1 and c.feccorrida between :fecInicio and :fecFinal ");
|
||||
sql.append(" order by e.nombempresa, c.feccorrida ");
|
||||
|
||||
return sql.toString();
|
||||
|
|
Loading…
Reference in New Issue