diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAcompanhamentoEquivalentes.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAcompanhamentoEquivalentes.java new file mode 100644 index 000000000..e0112cb87 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAcompanhamentoEquivalentes.java @@ -0,0 +1,269 @@ +/** + * + */ +package com.rjconsultores.ventaboletos.relatorios.impl; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +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.relatorios.utilitarios.Relatorio; +import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement; + +/** + * @author Bruno H. G. Gouvêa + * + */ +public class RelatorioAcompanhamentoEquivalentes extends Relatorio { + + enum IndicadorRelatorio { + + MPE(1), RECEITA_KM(2), RECEITA_VIAGEM(3), IAP(4), PAXKM(5), ABSOLUTO(6), EQ(7); + + public final int valor; + + IndicadorRelatorio(int valorOpcao) { + valor = valorOpcao; + } + + public static IndicadorRelatorio fromInt(Integer value) { + if (value != null) { + for (IndicadorRelatorio b : IndicadorRelatorio.values()) { + if (value.equals(b.valor)) { + return b; + } + } + } + return null; + } + } + + /** + * @param parametros + * @param conexao + * @throws Exception + */ + public RelatorioAcompanhamentoEquivalentes(Map parametros, Connection conexao) throws Exception { + super(parametros, conexao); + // TODO Auto-generated constructor stub + + this.setCustomDataSource(new ArrayDataSource(this) { + + protected void prepareQuery() throws SQLException { + + Connection conexao = this.relatorio.getConexao(); + Map parametros = this.relatorio.getParametros(); + String sql = getSql(); + NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql); + + if (parametros.get("EMPRESA_ID") != null) + stmt.setInt("EMPRESA_ID", (Integer) parametros.get("EMPRESA_ID")); + else + stmt.setNull("EMPRESA_ID", java.sql.Types.INTEGER); + + if (parametros.get("TIPOSERVICIO_ID") != null) + stmt.setInt("TIPOSERVICIO_ID", (Integer) parametros.get("TIPOSERVICIO_ID")); + else + stmt.setNull("TIPOSERVICIO_ID", java.sql.Types.INTEGER); + + stmt.setDate("DATA_MES", new java.sql.Date(((Date) parametros.get("DATA_MES")).getTime())); + + this.resultSet = stmt.executeQuery(); + } + + @Override + public void initDados() throws Exception { + + + this.prepareQuery(); + + Date dataInicial = (Date) this.relatorio.getParametros().get("DATA_MES"); + + while (this.resultSet.next()) { + + + Integer rolOperativoId = this.resultSet.getInt("ROLOPERATIVO_ID"); + Integer corridaId = this.resultSet.getInt("CORRIDA_ID"); + Map row = new HashMap(); + BigDecimal totalMes = BigDecimal.ZERO; + Integer totalDias = 0; + + + row.put("LINHA", this.resultSet.getString("SIGLA")); + row.put("LOTACAO", this.resultSet.getInt("ASSENTOS")); + row.put("SERVICO", this.resultSet.getString("TIPO_SERVICO")); + row.put("CODIGO", this.resultSet.getInt("CORRIDA_ID")); + row.put("HORARIO", this.resultSet.getString("HORARIO")); + row.put("INTERESTADUAL", this.resultSet.getString("INTERESTADUAL")); + row.put("GRUPO_LINHA", this.resultSet.getString("GRUPO_LINHA")); + + Calendar cal = Calendar.getInstance(); + cal.setTime(dataInicial); + cal.set(Calendar.DATE, 1); + + // Roda todos os dias do mes + for (int dia = 1 ; dia <= cal.getActualMaximum(Calendar.DATE) ; dia++) { + + BigDecimal valor = getValorByIndicador(cal.getTime(), corridaId, rolOperativoId, (Integer) this.relatorio.getParametros().get("INDICADOR")); + + if (valor != null) { + totalMes = totalMes.add(valor); + totalDias++; + } + + row.put(String.valueOf(cal.get(Calendar.DATE)), valor); + + if(cal.get(Calendar.DATE) < cal.getActualMaximum(Calendar.DATE)) + cal.add(Calendar.DATE, 1); + + } + + System.out.println("Total mes "+totalMes+ "Total dias"+ totalDias); + if(totalMes != null && !totalMes.equals(BigDecimal.ZERO) && totalDias > 0) + row.put("MEDIA", totalMes.divide(BigDecimal.valueOf(totalDias))); + + this.dados.add(row); + + } + + } + + protected BigDecimal getValorByIndicador(Date data, Integer corridaId, Integer rolOperativoId, Integer indicador) throws SQLException { + + String sql = null; + + switch (IndicadorRelatorio.fromInt(indicador)) { + case MPE: + break; + case ABSOLUTO: + sql = getSqlIndicadorAbsoluto(); + break; + case EQ: + + break; + case IAP: + + break; + case PAXKM: + + break; + case RECEITA_KM: + + break; + case RECEITA_VIAGEM: + + break; + } + + return getValorIndicador(data, corridaId, sql); + } + + }); + } + + protected String getSqlIndicadorAbsoluto() { + + StringBuilder sql = new StringBuilder(); + + sql.append(" SELECT SUM(1) AS VALOR"); + sql.append(" FROM BOLETO BO "); + sql.append(" WHERE BO.INDSTATUSOPERACION = 'F' "); + sql.append(" AND BO.ACTIVO = 1 "); + sql.append(" AND (BO.MOTIVOCANCELACION_ID IS NULL OR BO.MOTIVOCANCELACION_ID = 0) "); + sql.append(" AND BO.INDREIMPRESION = 0 "); + sql.append(" AND BO.CORRIDA_ID = :CORRIDA_ID "); + sql.append(" AND BO.FECCORRIDA = :FECCORRIDA "); + + return sql.toString(); + + } + + protected BigDecimal getValorIndicador(Date data, Integer corridaId, String sql) throws SQLException { + + Connection conexao = this.getConexao(); + BigDecimal retorno = null; + NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql); + + stmt.setInt("CORRIDA_ID", corridaId); + stmt.setDate("FECCORRIDA", new java.sql.Date(data.getTime())); + + ResultSet resultSet = stmt.executeQuery(); + + if (resultSet.next()) + retorno = resultSet.getBigDecimal("VALOR"); + + resultSet.close(); + stmt.close(); + + return retorno; + } + + /* + * (non-Javadoc) + * + * @see com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio#processaParametros() + */ + @Override + public void processaParametros() throws Exception { + } + + private String getSql() { + + StringBuilder sql = new StringBuilder(); + + sql.append(" SELECT DISTINCT RT.RUTA_ID, "); + sql.append(" CR.CORRIDA_ID, "); + sql.append(" RT.DESCRUTA, "); + sql.append(" DA.CANTASIENTOS ASSENTOS, "); + sql.append(" PO.CVEPARADA||' - '||PD.CVEPARADA SIGLA, "); + sql.append(" TO_CHAR(CR.FECHORSALIDAORIGINAL, 'HH24:MI') HORARIO, "); + sql.append(" CR.ROLOPERATIVO_ID, "); + sql.append(" CASE "); + sql.append(" WHEN CO.ESTADO_ID <> CD.ESTADO_ID THEN "); + sql.append(" 'S' "); + sql.append(" ELSE "); + sql.append(" 'N' "); + sql.append(" END INTERESTADUAL, "); + sql.append(" NVL(GR.DESCGRUPO, 'Não Definido') GRUPO_LINHA, "); + sql.append(" (CASE "); + sql.append(" WHEN CR.TIPOSERVICIO_ID = 2 THEN "); + sql.append(" 'Extra' "); + sql.append(" ELSE "); + sql.append(" NULL "); + sql.append(" END) TIPO_SERVICO "); + sql.append(" "); + sql.append(" FROM RUTA RT, "); + sql.append(" CORRIDA CR, "); + sql.append(" TRAMO TR, "); + sql.append(" ROL_OPERATIVO RO, "); + sql.append(" DIAGRAMA_AUTOBUS DA, "); + sql.append(" GRUPO_RUTA GR, "); + sql.append(" PARADA PO, "); + sql.append(" PARADA PD, "); + sql.append(" CIUDAD CO, "); + sql.append(" CIUDAD CD "); + sql.append(" WHERE RT.RUTA_ID = CR.RUTA_ID "); + sql.append(" AND CR.EMPRESACORRIDA_ID = NVL(:EMPRESA_ID, CR.EMPRESACORRIDA_ID) "); + sql.append(" AND CR.ORIGEN_ID = PO.PARADA_ID "); + sql.append(" AND CR.DESTINO_ID = PD.PARADA_ID "); + sql.append(" AND PO.CIUDAD_ID = CO.CIUDAD_ID "); + sql.append(" AND PD.CIUDAD_ID = CD.CIUDAD_ID "); + sql.append(" AND RT.GRUPORUTA_ID = GR.GRUPORUTA_ID(+) "); + sql.append(" AND RO.ROLOPERATIVO_ID = CR.ROLOPERATIVO_ID "); + sql.append(" AND RO.DIAGRAMAAUTOBUS_ID = DA.DIAGRAMAAUTOBUS_ID "); + sql.append(" AND TR.ORIGEN_ID = CR.ORIGEN_ID "); + sql.append(" AND TR.DESTINO_ID = CR.DESTINO_ID "); + sql.append(" AND CR.TIPOSERVICIO_ID = NVL(:TIPOSERVICIO_ID, CR.TIPOSERVICIO_ID) "); + sql.append(" AND TO_CHAR(CR.FECCORRIDA, 'MMYYYY') = TO_CHAR(:DATA_MES, 'MMYYYY') "); + sql.append(" ORDER BY INTERESTADUAL, GRUPO_LINHA, SIGLA"); + + return sql.toString(); + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioReceitaDiariaAgencia_pt_BR.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioReceitaDiariaAgencia_pt_BR.properties index 735c7ea62..2cdde92d3 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioReceitaDiariaAgencia_pt_BR.properties +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioReceitaDiariaAgencia_pt_BR.properties @@ -5,6 +5,8 @@ msg.noData=N cabecalho.relatorio=Relatório: cabecalho.periodo=Período: cabecalho.periodoA=à - -rodape.pagina=Página -rodape.de=de \ No newline at end of file +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/internacionalizacao/RelatorioResumoLinhasAnalitico_pt_BR.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioResumoLinhasAnalitico_pt_BR.properties index 45f4f75b6..e1826f5f2 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioResumoLinhasAnalitico_pt_BR.properties +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioResumoLinhasAnalitico_pt_BR.properties @@ -3,8 +3,14 @@ msg.noData=N #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: rodape.pagina=Página rodape.de=de \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioResumoLinhas_pt_BR.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioResumoLinhas_pt_BR.properties index 45f4f75b6..01f6ecc2b 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioResumoLinhas_pt_BR.properties +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioResumoLinhas_pt_BR.properties @@ -3,8 +3,11 @@ msg.noData=N #Labels cabeçalho +cabecalho.relatorio=Relatório: cabecalho.periodo=Período: cabecalho.periodoA=à - -rodape.pagina=Página -rodape.de=de \ No newline at end of file +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/RelatorioAcompanhamentoEquivalentes.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAcompanhamentoEquivalentes.jrxml new file mode 100644 index 000000000..2d8367cf5 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAcompanhamentoEquivalentes.jrxml @@ -0,0 +1,730 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="79" splitType="Stretch"> + <textField> + <reportElement uuid="9e87eb2d-1887-4b55-8185-532290be371a" x="0" y="24" width="275" height="15"/> + <textElement> + <font size="10"/> + </textElement> + <textFieldExpression><![CDATA[$P{EMPRESA}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="13cd1307-cc98-498c-8bac-618957350b22" x="0" y="40" width="275" height="20"/> + <textElement> + <font size="10"/> + </textElement> + <textFieldExpression><![CDATA[$P{NOME_RELATORIO}]]></textFieldExpression> + </textField> + <textField pattern="MM/yyyy" isBlankWhenNull="false"> + <reportElement uuid="4408d1db-05db-4538-944d-5561074f2706" mode="Transparent" x="66" y="60" width="53" height="15" forecolor="#000000" backcolor="#FFFFFF"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" markup="none"> + <font fontName="SansSerif" size="9" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$P{DATA_MES}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement uuid="c714d8a2-a41a-4fc8-848c-9cb455c3a0c7" mode="Transparent" x="1" y="60" width="65" height="15" forecolor="#000000" backcolor="#FFFFFF"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" markup="none"> + <font fontName="SansSerif" size="9" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{cabecalho.periodo}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="e5254cd0-647f-4b22-be4c-cce9afc5a10f" x="669" y="40" width="100" height="20"/> + <textElement textAlignment="Right"> + <font size="10"/> + </textElement> + <textFieldExpression><![CDATA["Página: "+$V{PAGE_NUMBER}]]></textFieldExpression> + </textField> + <textField pattern="dd/MM/yyyy"> + <reportElement uuid="55b08ff2-e470-4b59-8c56-58e6fa05ccd5" x="669" y="25" width="100" height="15"/> + <textElement textAlignment="Right"> + <font size="10"/> + </textElement> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + <line> + <reportElement uuid="afaaa1cf-1a3e-4a42-9fa3-e634a66fc3d3" x="1" y="76" width="797" height="1"/> + </line> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 28]]> + + + + + + + 29]]> + + + + + + + 30]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 28]]> + + + + + + + 29]]> + + + + + + + 30]]> + + + + + + + + + + + + 30]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 28]]> + + + + + + + 29]]> + + + + + + + 30]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioReceitaDiariaAgencia.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioReceitaDiariaAgencia.jasper index 87f611227..60b4783d8 100644 Binary files a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioReceitaDiariaAgencia.jasper and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioReceitaDiariaAgencia.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioReceitaDiariaAgencia.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioReceitaDiariaAgencia.jrxml index 27a4532dc..b165ce189 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioReceitaDiariaAgencia.jrxml +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioReceitaDiariaAgencia.jrxml @@ -1,8 +1,8 @@ - - + +