diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDemandasDetalhadoNovoLayout.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDemandasDetalhadoNovoLayout.java new file mode 100644 index 000000000..a0e576d59 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDemandasDetalhadoNovoLayout.java @@ -0,0 +1,145 @@ +/** + * + */ +package com.rjconsultores.ventaboletos.relatorios.impl; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import com.rjconsultores.ventaboletos.relatorios.utilitarios.ArrayDataSource; +import com.rjconsultores.ventaboletos.utilerias.DateUtil; +import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement; + +public class RelatorioDemandasDetalhadoNovoLayout extends RelatorioDemandas { + public RelatorioDemandasDetalhadoNovoLayout(Map parametros, Connection conexao) throws Exception { + super(parametros, conexao); + this.setCustomDataSource(new ArrayDataSource(this) { + @Override + public void initDados() throws Exception { + Connection conexao = this.relatorio.getConexao(); + Map parametros = this.relatorio.getParametros(); + + Calendar dataInicial = Calendar.getInstance(); + dataInicial.setTime((Date) parametros.get("DATA_INICIAL")); + + Calendar dataFinal = Calendar.getInstance(); + dataFinal.setTime((Date) parametros.get("DATA_FINAL")); + + Calendar horaInicial = Calendar.getInstance(); + if (parametros.get("HORA_INICIAL") != null) + horaInicial.setTime((Date) parametros.get("HORA_INICIAL")); + + Calendar horaFinal = Calendar.getInstance(); + if (parametros.get("HORA_FINAL") != null) + horaFinal.setTime((Date) parametros.get("HORA_FINAL")); + + SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); + + StringBuilder sql = new StringBuilder(); + sql.append("select "); + sql.append(" trunc(co.feccorrida) as data_corrida, "); + sql.append(" trunc(bo.fechorviaje) as data, "); + sql.append(" r.descruta as linha, "); + sql.append(" r.numruta as codlinha, "); + sql.append(" co.corrida_id as servico, "); + sql.append(" case when ((ori.indvisibleinternet is null or ori.indvisibleinternet = 1) "); + sql.append(" and (des.indvisibleinternet is null or des.indvisibleinternet = 1)) then 'SIM' else 'NÃO' end as internet, "); + sql.append(" bo.fechorviaje as horario, "); + sql.append(" ori.descparada as origem, "); + sql.append(" des.descparada as destino, "); + sql.append(" cs.descclase as classe, "); + sql.append(" da.cantasientos as capacidade, "); + sql.append(" count(bo.boleto_id) as ocupacao, "); + sql.append(" ts.descservicio as tipo_servico, "); + sql.append(" ct.plataforma as plataforma, "); + sql.append(" e.nombempresa as empresa "); + sql.append("from boleto bo "); + sql.append(" join corrida co on co.corrida_id = bo.corrida_id and co.feccorrida = bo.feccorrida "); + sql.append(" join corrida_tramo ct on ct.corrida_id = bo.corrida_id and bo.feccorrida = ct.feccorrida and ct.origen_id = bo.origen_id "); + sql.append(" join ruta r on co.ruta_id = r.ruta_id "); + sql.append(" left join empresa e on e.empresa_id = bo.empresacorrida_id "); + sql.append(" join parada ori on ori.parada_id = bo.origen_id "); + sql.append(" join parada des on des.parada_id = bo.destino_id "); + sql.append(" join clase_servicio cs on cs.claseservicio_id = co.claseservicio_id "); + sql.append(" join rol_operativo ro on ro.roloperativo_id = co.roloperativo_id "); + sql.append(" join diagrama_autobus da on ro.diagramaautobus_id = da.diagramaautobus_id "); + 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 bo.fechorviaje >= :DATA_INICIAL and bo.fechorviaje <= :DATA_FINAL "); + sql.append((parametros.get("RUTA_ID") != null) ? " and r.ruta_id = :RUTA_ID " : ""); + sql.append((parametros.get("EMPRESA_ID") != null) ? " and e.empresa_id = :EMPRESA_ID " : ""); + sql.append((parametros.get("PARADA_ID") != null) ? " and bo.origen_id = :PARADA_ID " : ""); + sql.append((parametros.get("TIPO_SERVICO") != null) ? " and ts.tiposervicio_id = :TIPO_SERVICO " : ""); + + if (parametros.get("HORA_INICIAL") != null && parametros.get("HORA_FINAL") != null) { + sql.append(" AND "); + sql.append(" ( "); + do { + mesclarDataHora(dataInicial, horaInicial); + sql.append(" bo.fechorviaje between to_date('" + format.format(dataInicial.getTime()) + "', 'dd/MM/yyyy HH24:MI:ss') "); + mesclarDataHora(dataInicial, horaFinal); + sql.append(" and to_date('" + format.format(dataInicial.getTime()) + "', 'dd/MM/yyyy HH24:MI:ss')"); + dataInicial.add(Calendar.DAY_OF_MONTH, 1); + if (!dataInicial.after(dataFinal)) { + sql.append(" or "); + } + + } while (!dataInicial.after(dataFinal)); + sql.append(" ) "); + } + + sql.append("group by trunc(co.feccorrida), trunc(bo.fechorviaje), r.descruta, r.numruta, co.corrida_id, "); + sql.append(" case when ((ori.indvisibleinternet is null or ori.indvisibleinternet = 1) "); + sql.append(" and (des.indvisibleinternet is null or des.indvisibleinternet = 1)) then 'SIM' else 'NÃO' end, "); + sql.append(" bo.fechorviaje, ori.descparada, des.descparada, cs.descclase, "); + sql.append(" da.cantasientos, ts.descservicio, ct.plataforma, e.nombempresa "); + sql.append("order by e.nombempresa, data, linha, servico, origem, destino "); + + NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql.toString()); + if (parametros.get("EMPRESA_ID") != null) + stmt.setInt("EMPRESA_ID", Integer.valueOf(parametros.get("EMPRESA_ID").toString())); + + if (parametros.get("PARADA_ID") != null) + stmt.setInt("PARADA_ID", Integer.valueOf(parametros.get("PARADA_ID").toString())); + + if (parametros.get("RUTA_ID") != null) + stmt.setInt("RUTA_ID", Integer.valueOf(parametros.get("RUTA_ID").toString())); + + 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())); + + ResultSet rset = stmt.executeQuery(); + while (rset.next()) { + Map dataResult = new HashMap(); + dataResult.put("DATA", rset.getDate("DATA")); + dataResult.put("LINHA", rset.getString("LINHA")); + dataResult.put("SERVICO", rset.getBigDecimal("SERVICO")); + dataResult.put("INTERNET", rset.getString("INTERNET")); + dataResult.put("HORARIO", rset.getTimestamp("HORARIO")); + dataResult.put("ORIGEM", rset.getString("ORIGEM")); + dataResult.put("DESTINO", rset.getString("DESTINO")); + dataResult.put("CLASSE", rset.getString("CLASSE")); + dataResult.put("CAPACIDADE", rset.getInt("CAPACIDADE")); + dataResult.put("TIPO_SERVICO", rset.getString("TIPO_SERVICO")); + dataResult.put("PLATAFORMA", rset.getString("PLATAFORMA")); + dataResult.put("OCUPACAO", rset.getInt("OCUPACAO")); + dataResult.put("EMPRESA", rset.getString("EMPRESA")); + dataResult.put("CODLINHA", rset.getString("CODLINHA")); + this.dados.add(dataResult); + } + this.resultSet = rset; + + } + }); + } +} diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioDemandasDetalhadoNovoLayout_pt_BR.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioDemandasDetalhadoNovoLayout_pt_BR.properties new file mode 100644 index 000000000..01f6ecc2b --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioDemandasDetalhadoNovoLayout_pt_BR.properties @@ -0,0 +1,13 @@ +#geral +msg.noData=Não foi possivel obter dados com os parâmetros informados. + + +#Labels cabeçalho +cabecalho.relatorio=Relatório: +cabecalho.periodo=Período: +cabecalho.periodoA=à +cabecalho.dataHora=Data/Hora: +cabecalho.impressorPor=Impressor por: +cabecalho.pagina=Página +cabecalho.de=de +cabecalho.filtros=Filtros: \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDemandasDetalhadoNovoLayout.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDemandasDetalhadoNovoLayout.jasper new file mode 100644 index 000000000..4897fe064 Binary files /dev/null and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDemandasDetalhadoNovoLayout.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDemandasDetalhadoNovoLayout.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDemandasDetalhadoNovoLayout.jrxml new file mode 100644 index 000000000..4bc6b096a --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDemandasDetalhadoNovoLayout.jrxml @@ -0,0 +1,265 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="13"> + <staticText> + <reportElement x="92" y="0" width="46" height="13" uuid="9fc7e58e-8625-41c4-a8ee-6454f6382d46"/> + <textElement textAlignment="Center"> + <font size="8" isBold="true"/> + </textElement> + <text><![CDATA[Serviço]]></text> + </staticText> + <staticText> + <reportElement x="0" y="0" width="61" height="13" uuid="3766fa33-6281-4576-a9d1-3b984e1976d3"/> + <textElement textAlignment="Center"> + <font size="8" isBold="true"/> + </textElement> + <text><![CDATA[Data]]></text> + </staticText> + <staticText> + <reportElement x="182" y="0" width="46" height="13" uuid="7e1f6b82-8a1f-4719-b942-41f0d7027aa8"/> + <textElement textAlignment="Center"> + <font size="8" isBold="true"/> + </textElement> + <text><![CDATA[Horário]]></text> + </staticText> + <staticText> + <reportElement mode="Transparent" x="611" y="0" width="50" height="13" forecolor="#000000" backcolor="#FFFFFF" uuid="95367884-2b52-4bbd-b716-852ff13290e9"/> + <textElement textAlignment="Center" verticalAlignment="Top" rotation="None" markup="none"> + <font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <text><![CDATA[Ocupação]]></text> + </staticText> + <staticText> + <reportElement mode="Transparent" x="348" y="0" width="120" height="13" forecolor="#000000" backcolor="#FFFFFF" uuid="a39ab8f3-becb-44e3-b4f5-b7c43889508c"/> + <textElement textAlignment="Center" verticalAlignment="Top" rotation="None" markup="none"> + <font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <text><![CDATA[Destino]]></text> + </staticText> + <staticText> + <reportElement mode="Transparent" x="661" y="0" width="68" height="13" forecolor="#000000" backcolor="#FFFFFF" uuid="170230ea-2a12-4444-9f13-c706d557ae8d"/> + <textElement textAlignment="Center" verticalAlignment="Top" rotation="None" markup="none"> + <font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <text><![CDATA[Tipo]]></text> + </staticText> + <staticText> + <reportElement mode="Transparent" x="228" y="0" width="120" height="13" forecolor="#000000" backcolor="#FFFFFF" uuid="c0542d93-dde4-448d-932c-453d6a4a6882"/> + <textElement textAlignment="Center" verticalAlignment="Top" rotation="None" markup="none"> + <font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <text><![CDATA[Origem]]></text> + </staticText> + <staticText> + <reportElement mode="Transparent" x="558" y="0" width="53" height="13" forecolor="#000000" backcolor="#FFFFFF" uuid="9c65b631-065c-49af-ab2c-3bcea583eaea"/> + <textElement textAlignment="Center" verticalAlignment="Top" rotation="None" markup="none"> + <font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <text><![CDATA[Capacidade]]></text> + </staticText> + <staticText> + <reportElement mode="Transparent" x="468" y="0" width="90" height="13" forecolor="#000000" backcolor="#FFFFFF" uuid="a7f96097-c8fd-4ba0-bea7-7b40a0fc81f7"/> + <textElement textAlignment="Center" verticalAlignment="Top" rotation="None" markup="none"> + <font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <text><![CDATA[Classe]]></text> + </staticText> + <staticText> + <reportElement mode="Transparent" x="729" y="0" width="51" height="13" forecolor="#000000" backcolor="#FFFFFF" uuid="0452264c-0f27-46d6-84ad-0fba6e5abdfa"/> + <textElement textAlignment="Center" verticalAlignment="Top" rotation="None" markup="none"> + <font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <text><![CDATA[Plataforma]]></text> + </staticText> + <staticText> + <reportElement mode="Transparent" x="780" y="0" width="62" height="13" forecolor="#000000" backcolor="#FFFFFF" uuid="f596b16a-f9d9-42f5-b86f-3f468b0deb8f"/> + <textElement textAlignment="Center" verticalAlignment="Top" rotation="None" markup="none"> + <font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <text><![CDATA[%Ocupação]]></text> + </staticText> + <staticText> + <reportElement x="61" y="0" width="31" height="13" uuid="3766fa33-6281-4576-a9d1-3b984e1976d3"/> + <textElement textAlignment="Center"> + <font size="8" isBold="true"/> + </textElement> + <text><![CDATA[Linha]]></text> + </staticText> + <staticText> + <reportElement x="138" y="0" width="44" height="13" uuid="a427bc80-0924-441c-896b-a888a929d4f5"/> + <textElement textAlignment="Center"> + <font size="8" isBold="true"/> + </textElement> + <text><![CDATA[Internet]]></text> + </staticText> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 58aa2ace8..e03b1ab14 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 @@ -30,6 +30,7 @@ import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.Parada; import com.rjconsultores.ventaboletos.entidad.Ruta; import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioDemandasDetalhado; +import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioDemandasDetalhadoNovoLayout; import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; import com.rjconsultores.ventaboletos.service.EmpresaService; import com.rjconsultores.ventaboletos.service.ParadaService; @@ -148,14 +149,19 @@ public class RelatorioDemandasController extends MyGenericForwardComposer { } public void onClick$btnExecutarRelatorio(Event ev) throws Exception { - executarRelatorio(); + executarRelatorio(false); + } + + + public void onClick$btnExecutarRelatorioNovoLayout(Event ev) throws Exception { + executarRelatorio(true); } /** * @throws Exception * */ - private void executarRelatorio() throws Exception { + private void executarRelatorio(boolean novoLayout) throws Exception { Relatorio relatorio; Map parametros = new HashMap(); StringBuilder filtro = new StringBuilder(); @@ -238,7 +244,12 @@ public class RelatorioDemandasController extends MyGenericForwardComposer { if (detalhado.isChecked()) { - relatorio = new RelatorioDemandasDetalhado(parametros, dataSourceRead.getConnection()); + + if (novoLayout) + relatorio = new RelatorioDemandasDetalhadoNovoLayout(parametros, dataSourceRead.getConnection()); + else + relatorio = new RelatorioDemandasDetalhado(parametros, dataSourceRead.getConnection()); + } else if (diario.isChecked()) { relatorio = new RelatorioDemandasDiario(parametros, dataSourceRead.getConnection()); } else { diff --git a/web/gui/relatorios/filtroRelatorioDemandas.zul b/web/gui/relatorios/filtroRelatorioDemandas.zul index 49e95b565..749aa9a31 100644 --- a/web/gui/relatorios/filtroRelatorioDemandas.zul +++ b/web/gui/relatorios/filtroRelatorioDemandas.zul @@ -6,7 +6,7 @@ + height="268px" width="600px" border="normal"> @@ -120,6 +120,9 @@