diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAcompanhamentoEquivalentes.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAcompanhamentoEquivalentes.java index 23dbc274c..21058755c 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAcompanhamentoEquivalentes.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAcompanhamentoEquivalentes.java @@ -445,6 +445,7 @@ public class RelatorioAcompanhamentoEquivalentes extends Relatorio { sql.append(" inner join ROL_OPERATIVO ro on ro.ROLOPERATIVO_ID = C.ROLOPERATIVO_ID "); sql.append(" LEFT JOIN BOLETO BO ON ((BO.MOTIVOCANCELACION_ID IS NULL OR BO.MOTIVOCANCELACION_ID = 0 ) "); sql.append(" AND C.CORRIDA_ID = BO.CORRIDA_ID AND C.FECCORRIDA = BO.FECCORRIDA "); + sql.append(" AND BO.INDSTATUSOPERACION = 'F' AND BO.ACTIVO = 1 "); sql.append(" AND BO.CATEGORIA_ID <> ").append(CONSTANTE_GRATUIDADE_CRIANCA).append(" ), ") ; sql.append(" (SELECT SUM(TR1.CANTKMREAL) EL, "); sql.append(" CR.CORRIDA_ID, "); @@ -491,7 +492,7 @@ public class RelatorioAcompanhamentoEquivalentes extends Relatorio { sql.append(" CR.FECCORRIDA "); sql.append(" FROM CORRIDA CR "); sql.append(" LEFT JOIN BOLETO BO ON (CR.CORRIDA_ID = BO.CORRIDA_ID AND CR.FECCORRIDA = BO.FECCORRIDA "); - sql.append(" AND BO.INDSTATUSOPERACION = 'F' "); + sql.append(" AND BO.INDSTATUSOPERACION = 'F' AND BO.ACTIVO = 1 "); sql.append(" AND BO.MOTIVOCANCELACION_ID IS NULL OR BO.MOTIVOCANCELACION_ID = 0 "); sql.append(" AND BO.CATEGORIA_ID <> ").append(CONSTANTE_GRATUIDADE_CRIANCA).append(") "); sql.append(" INNER JOIN (SELECT SUM(TR1.CANTKMREAL) KM, CR.CORRIDA_ID, CR.FECCORRIDA "); diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioKmProgramada.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioKmProgramada.java index 32ecabb3e..73a9496f2 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioKmProgramada.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioKmProgramada.java @@ -7,11 +7,9 @@ import java.sql.Connection; import java.sql.ResultSet; import java.sql.Timestamp; import java.text.SimpleDateFormat; -import java.util.Date; import java.util.HashMap; import java.util.Map; -import com.rjconsultores.ventaboletos.entidad.Constante; import com.rjconsultores.ventaboletos.relatorios.utilitarios.ArrayDataSource; import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; import com.rjconsultores.ventaboletos.service.ConstanteService; @@ -42,33 +40,27 @@ public class RelatorioKmProgramada extends Relatorio { public void processaParametros() throws Exception { } - - - private ConstanteService constanteService; - public RelatorioKmProgramada(Map parametros, Connection conexao, ConstanteService constanteService) throws Exception { super(parametros, conexao); - this.constanteService = constanteService; this.setCustomDataSource(new ArrayDataSource(this) { public void initDados() throws Exception { Connection conexao = this.relatorio.getConexao(); Map parametros = this.relatorio.getParametros(); - final Integer CARTAO_CREDITO = 2; - String sql = getSql(parametros.get("EMPRESA_ID")+""); + String sql = getSql(parametros); NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); stmt.setTimestamp("fecInicio", new Timestamp(DateUtil.inicioFecha(sdf.parse(parametros.get("DATA_INICIAL").toString())).getTime())); stmt.setTimestamp("fecFinal", new Timestamp(DateUtil.inicioFecha(sdf.parse( parametros.get("DATA_FINAL").toString())).getTime())); - // stmt.setTimestamp("data_final", new Timestamp(DateUtil.fimFecha((Date) parametros.get("DATA_FINAL")).getTime())); - // stmt.setInt("formaPago1", CARTAO_CREDITO); - if(parametros.get("EMPRESA_ID" )!= null){ - stmt.setInt("empresaId", Integer.valueOf(parametros.get("EMPRESA_ID" )== null ?"0":parametros.get("EMPRESA_ID") + "")); + if(parametros.get("EMPRESA_ID" ) != null){ + stmt.setInt("empresaId", Integer.valueOf(parametros.get("EMPRESA_ID" ).toString())); + } + if(parametros.get("RUTA_ID" ) != null){ + stmt.setInt("rutaId", Integer.valueOf(parametros.get("RUTA_ID" ).toString())); } - ResultSet rset = stmt.executeQuery(); while (rset.next()) { @@ -91,13 +83,8 @@ public class RelatorioKmProgramada extends Relatorio { }); } - private String getSql(String empresaId) { + private String getSql(Map parametros) { StringBuilder sql = new StringBuilder(); - - /* Boletos apenas com venda e cancelamento direto com corrida */ - - - sql.append(" select"); sql.append(" geral.Linhas,"); sql.append(" geral.Empresa,"); @@ -127,7 +114,6 @@ public class RelatorioKmProgramada extends Relatorio { sql.append(" ELSE null"); sql.append(" END), 0 )) as KMTotal,"); - sql.append("(NVL( COUNT("); sql.append(" CASE"); sql.append(" WHEN geral.TIPOSERVICIO_ID = 1"); @@ -152,49 +138,16 @@ public class RelatorioKmProgramada extends Relatorio { sql.append(" WHERE "); sql.append(" c.ACTIVO=1"); sql.append(" and c.FECCORRIDA BETWEEN :fecInicio and :fecFinal"); - if (!empresaId.equals("null")) { + + if(parametros.get("EMPRESA_ID" ) != null){ sql.append(" and c.EMPRESACORRIDA_ID = :empresaId "); } + if(parametros.get("RUTA_ID" ) != null){ + sql.append(" and r.RUTA_ID = :rutaId "); + } + sql.append(") geral group by geral.Linhas, geral.Empresa, geral.DescLinha, geral.KMPadrao"); - - - - -// sql.append("SELECT DISTINCT c.RUTA_ID AS Linhas,"); -// sql.append(" c.EMPRESACORRIDA_ID AS Empresa,"); -// sql.append(" r.DESCRUTA AS DescLinha,"); -// sql.append(" SUM(t.CANTKMREAL) AS KMPadrao,"); -// sql.append(" COUNT("); -// sql.append(" CASE"); -// sql.append(" WHEN c.TIPOSERVICIO_ID = 1"); -// sql.append(" THEN 1"); -// sql.append(" ELSE NULL"); -// sql.append(" END ) AS SRVNormal,"); -// sql.append(" COUNT("); -// sql.append(" CASE"); -// sql.append(" WHEN c.TIPOSERVICIO_ID = 2"); -// sql.append(" THEN 1"); -// sql.append(" ELSE NULL"); -// sql.append(" END ) AS SRVExtra,"); -// sql.append(" COUNT (c.CORRIDA_ID) AS SRVTotal"); -// sql.append(" FROM CORRIDA c"); -// sql.append(" JOIN CORRIDA_TRAMO ct"); -// sql.append(" ON ct.CORRIDA_ID = c.CORRIDA_ID"); -// sql.append(" AND ct.FECCORRIDA = c.FECCORRIDA"); -// sql.append(" JOIN TRAMO t"); -// sql.append(" ON ct.TRAMO_ID = t.TRAMO_ID"); -// sql.append(" JOIN RUTA r "); -// sql.append(" on c.RUTA_ID = r.RUTA_ID"); -// sql.append(" WHERE "); -// sql.append(" c.FECCORRIDA BETWEEN :fecInicio and :fecFinal"); -// if (empresaId != null) { -// sql.append(" and c.EMPRESACORRIDA_ID = :empresaId "); -// } -// sql.append(" GROUP BY c.RUTA_ID,"); -// sql.append(" c.EMPRESACORRIDA_ID,"); -// sql.append(" r.DESCRUTA "); - return sql.toString(); } } diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioOrigemDestino.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioOrigemDestino.java index d4659f8f7..4cbfff9cc 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioOrigemDestino.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioOrigemDestino.java @@ -153,6 +153,7 @@ public class RelatorioOrigemDestino extends Relatorio { sql.append(" INNER JOIN PARADA O ON O.PARADA_ID = CA.ORIGEN_ID "); sql.append(" INNER JOIN PARADA D ON D.PARADA_ID = CA.DESTINO_ID "); sql.append(" WHERE CA.ACTIVO = 1 "); + sql.append(" AND CA.INDSTATUSOPERACION = 'F' "); sql.append(" AND CA.MOTIVOCANCELACION_ID IS NULL "); if(StringUtils.isNotBlank(CONSTANTE_GRATUIDADE_CRIANCA)) { @@ -396,7 +397,24 @@ public class RelatorioOrigemDestino extends Relatorio { sql.append(" AND CO.FECCORRIDA BETWEEN to_date('" + dataDe + "','dd/mm/yyyy HH24:mi:ss') AND to_date('" + dataAte + "','dd/mm/yyyy HH24:mi:ss') "); sql.append(" AND CO.ACTIVO = 1 "); sql.append(" ) VIAGENS, "); - sql.append(" TR.cantkmreal KM_CORRIDA, "); + + /* Carrega KM Corrida */ + sql.append(" ( "); + sql.append(" SELECT sum(tr1.cantkmreal) / count(cr.corrida_id) "); + sql.append(" FROM CORRIDA CR "); + sql.append(" INNER JOIN RUTA_COMBINACION RS ON RS.RUTA_ID = CR.RUTA_ID "); + sql.append(" INNER JOIN TRAMO TR1 ON TR1.TRAMO_ID = RS.TRAMO_ID "); + sql.append(" AND(TR1.ORIGEN_ID = CR.ORIGEN_ID "); + sql.append(" AND TR1.DESTINO_ID = CR.DESTINO_ID) "); + sql.append(" WHERE CR.ACTIVO = 1 "); + sql.append(" AND RS.ACTIVO = 1 "); + sql.append(" AND TR1.ACTIVO = 1 "); + sql.append(" AND CR.CORRIDA_ID = RESULTADO.corrida_id "); + sql.append((" AND CR.EMPRESACORRIDA_ID IN (") + empresaIds + ") "); + sql.append(" AND CR.FECCORRIDA BETWEEN to_date('" + dataDe + "','dd/mm/yyyy HH24:mi:ss') AND to_date('" + dataAte + "','dd/mm/yyyy HH24:mi:ss') "); + sql.append(" GROUP BY CR.CORRIDA_ID, CR.ROLOPERATIVO_ID "); + sql.append(" ) KM_CORRIDA, "); + sql.append(" (SELECT AVG(DA.cantasientos) "); sql.append(" FROM corrida CO "); sql.append(" INNER JOIN rol_operativo ROL ON ROL.roloperativo_id = CO.roloperativo_id "); diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAcompanhamentoEquivalentes.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAcompanhamentoEquivalentes.jasper index 73dce00a4..200f06706 100644 Binary files a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAcompanhamentoEquivalentes.jasper and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAcompanhamentoEquivalentes.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAcompanhamentoEquivalentes.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAcompanhamentoEquivalentes.jrxml index a76f40fc1..38893c019 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAcompanhamentoEquivalentes.jrxml +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAcompanhamentoEquivalentes.jrxml @@ -1,8 +1,8 @@ - - - - + + + + @@ -245,13 +245,13 @@ - + - + @@ -263,12 +263,12 @@ - + - + @@ -278,204 +278,204 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -518,24 +518,24 @@ - + - + - + - + @@ -564,354 +564,354 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + 28]]> - + 29]]> - + 30]]> - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + 28]]> - + 29]]> - + 30]]> - + - + - + @@ -925,175 +925,175 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + 28]]> @@ -1101,7 +1101,7 @@ - + 29]]> @@ -1109,7 +1109,7 @@ - + 30]]> @@ -1117,7 +1117,7 @@ - + @@ -1137,17 +1137,17 @@ - + - + - + diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioOrigemDestino.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioOrigemDestino.jasper index 95de32ed8..413c05002 100644 Binary files a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioOrigemDestino.jasper and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioOrigemDestino.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioOrigemDestino.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioOrigemDestino.jrxml index 95b7dea9c..58d3451fc 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioOrigemDestino.jrxml +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioOrigemDestino.jrxml @@ -1,8 +1,8 @@ - + - + @@ -398,24 +398,24 @@ - + - + - + - + @@ -515,12 +515,12 @@ - + - + @@ -532,17 +532,17 @@ - + - + - + diff --git a/web/gui/relatorios/filtroRelatorioKmProgramada.zul b/web/gui/relatorios/filtroRelatorioKmProgramada.zul index 2a2c3a5e2..e94f6ece2 100644 --- a/web/gui/relatorios/filtroRelatorioKmProgramada.zul +++ b/web/gui/relatorios/filtroRelatorioKmProgramada.zul @@ -33,7 +33,7 @@ maxlength="10" /> - + - +