From c422892f00d4f6120474e4d0cedf141c91d90f0a Mon Sep 17 00:00:00 2001 From: bruno Date: Wed, 19 Jun 2013 19:12:13 +0000 Subject: [PATCH] =?UTF-8?q?Reintegrando=20branch=20do=20projeto=20de=20rel?= =?UTF-8?q?at=C3=B3rios.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@27961 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../datasource/Vendas2CustomDS.java | 43 ++ .../relatorios/datasource/VendasCustomDS.java | 42 ++ .../parametros/RendimentoParamsImpl.java | 216 ++++++++++ .../render/RenderRelatorioAbstract.java | 106 +++++ .../render/RenderRelatorioJasper.java | 89 ++++ .../templates/RelatorioAproveitamento.jasper | Bin 0 -> 45662 bytes .../templates/RelatorioAproveitamento.jrxml | 388 ++++++++++++++++++ .../relatorios/utilitarios/IDataSource.java | 13 + .../relatorios/utilitarios/IParametros.java | 25 ++ .../utilitarios/IRenderRelatorio.java | 23 ++ .../relatorios/utilitarios/Relatorio.java | 97 +++++ .../utilitarios/SaidaRelatorio.java | 11 + .../RelatorioAproveitamentoController.java | 101 +++++ .../relatorios/RelatorioController.java | 133 ++++++ .../web/utilerias/CurrencyUtil.java | 30 ++ .../ItemMenuRelatorioAproveitamento.java | 25 ++ .../menu/item/relatorios/MenuRelatorios.java | 16 + .../utilerias/menu/menu_original.properties | 2 + web/WEB-INF/i3-label_pt_BR.label | 12 + web/component/reportView.zul | 30 ++ web/gui/img/pdf.png | Bin 0 -> 436 bytes .../filtroRelatorioAproveitamento.zul | 32 ++ 22 files changed, 1434 insertions(+) create mode 100644 src/java/com/rjconsultores/ventaboletos/relatorios/datasource/Vendas2CustomDS.java create mode 100644 src/java/com/rjconsultores/ventaboletos/relatorios/datasource/VendasCustomDS.java create mode 100644 src/java/com/rjconsultores/ventaboletos/relatorios/parametros/RendimentoParamsImpl.java create mode 100644 src/java/com/rjconsultores/ventaboletos/relatorios/render/RenderRelatorioAbstract.java create mode 100644 src/java/com/rjconsultores/ventaboletos/relatorios/render/RenderRelatorioJasper.java create mode 100644 src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAproveitamento.jasper create mode 100644 src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAproveitamento.jrxml create mode 100644 src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/IDataSource.java create mode 100644 src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/IParametros.java create mode 100644 src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/IRenderRelatorio.java create mode 100644 src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/Relatorio.java create mode 100644 src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/SaidaRelatorio.java create mode 100644 src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioAproveitamentoController.java create mode 100644 src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioController.java create mode 100644 src/java/com/rjconsultores/ventaboletos/web/utilerias/CurrencyUtil.java create mode 100644 src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/ItemMenuRelatorioAproveitamento.java create mode 100644 src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/MenuRelatorios.java create mode 100644 web/component/reportView.zul create mode 100644 web/gui/img/pdf.png create mode 100644 web/gui/relatorios/filtroRelatorioAproveitamento.zul diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/datasource/Vendas2CustomDS.java b/src/java/com/rjconsultores/ventaboletos/relatorios/datasource/Vendas2CustomDS.java new file mode 100644 index 000000000..1632dc7d1 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/datasource/Vendas2CustomDS.java @@ -0,0 +1,43 @@ +package com.rjconsultores.ventaboletos.relatorios.datasource; + +import com.rjconsultores.ventaboletos.relatorios.utilitarios.IDataSource; + +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRField; + +/** + */ +public class Vendas2CustomDS implements IDataSource { + + private Object[][] data = { + {"João", "123123"}, + {"Maria", "12312321"}, + {"Bruno", "3243"}, + {"Teste", "1234365612321"}, + + + }; + + private int index = -1; + + public Vendas2CustomDS() { + } + + public boolean next() throws JRException { + index++; + return (index < data.length); + } + + public Object getFieldValue(JRField field) throws JRException { + Object value = null; + String fieldName = field.getName(); + + if ("field1".equals(fieldName)) { + value = data[index][0]; + } else if ("field2".equals(fieldName)) { + value = data[index][1]; + }; + + return value; + } +} diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/datasource/VendasCustomDS.java b/src/java/com/rjconsultores/ventaboletos/relatorios/datasource/VendasCustomDS.java new file mode 100644 index 000000000..f108fdd53 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/datasource/VendasCustomDS.java @@ -0,0 +1,42 @@ +package com.rjconsultores.ventaboletos.relatorios.datasource; + +import com.rjconsultores.ventaboletos.relatorios.utilitarios.IDataSource; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRField; + +/** + */ +public class VendasCustomDS implements IDataSource { + + private Object[][] data = { + {"João", "123123"}, + {"Maria", "12312321"}, + {"Bruno", "3243"}, + {"Teste", "1234365612321"}, + + + }; + + private int index = -1; + + public VendasCustomDS() { + } + + public boolean next() throws JRException { + index++; + return (index < data.length); + } + + public Object getFieldValue(JRField field) throws JRException { + Object value = null; + String fieldName = field.getName(); + + if ("field1".equals(fieldName)) { + value = data[index][0]; + } else if ("field2".equals(fieldName)) { + value = data[index][1]; + }; + + return value; + } +} diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/parametros/RendimentoParamsImpl.java b/src/java/com/rjconsultores/ventaboletos/relatorios/parametros/RendimentoParamsImpl.java new file mode 100644 index 000000000..ade2fb06b --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/parametros/RendimentoParamsImpl.java @@ -0,0 +1,216 @@ +/** + * + */ +package com.rjconsultores.ventaboletos.relatorios.parametros; + + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.Map; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.IParametros; +import com.rjconsultores.ventaboletos.web.utilerias.CurrencyUtil; + +/** + * @author Bruno H. G. Gouvêa + * + */ +public class RendimentoParamsImpl implements IParametros { + + /* + * (non-Javadoc) + * + * @see com.rjconsultores.ventaboletos.relatorios.utilitarios.IParametros#initParametros() + */ + @Override + public void initParametros(Map parametros, Connection connection) throws Exception { + String sql = this.getSql(); + + PreparedStatement stmt = null; + ResultSet rset = null; + stmt = connection.prepareStatement(sql); + + stmt.setInt(1, Integer.valueOf((String) parametros.get("CORRIDA_ID"))); + stmt.setDate(2, (java.sql.Date) parametros.get("FECCORRIDA")); + rset = stmt.executeQuery(); + + if (rset.next()) { + parametros.put("P_NOMINAL_KM", CurrencyUtil.getCurrencyStrFromStr(rset.getString("NOMINAL_KM"))); + parametros.put("P_TOTAL_ARRECADADO", CurrencyUtil.getCurrencyStrFromStr(rset.getString("TOTAL_ARRECADADO"))); + parametros.put("P_ARRECADO_KM", CurrencyUtil.getCurrencyStrFromStr(rset.getString("ARRECADADO_KM"))); + parametros.put("P_OCUPACAO", rset.getString("OCUPACAO")+" %"); + parametros.put("P_OCUPACAO_ARRECADACAO", rset.getString("OCUPACAO_ARRECADACAO") +" %"); + parametros.put("P_TOTAL_NOMINAL", CurrencyUtil.getCurrencyStrFromStr(rset.getString("TOTAL_NOMINAL"))); + parametros.put("P_OCUPACAO_S_ARRECADACAO", rset.getString("OCUPACAO_S_ARRECADACAO") +" %"); + } + + } + + private String getSql() { + + StringBuilder sql = new StringBuilder(); + + sql.append("SELECT round(NVL(TAB.TOTAL_ARRECADADO,0),2) TOTAL_ARRECADADO, "); + sql.append(" round(NVL(TAB.TOTAL_ARRECADADO / TAB.KM_OCUPADA,0),2) ARRECADADO_KM, "); + sql.append(" round(NVL(TAB.TOTAL_NOMINAL,0),2) TOTAL_NOMINAL, "); + sql.append(" round(TAB.TOTAL_NOMINAL / TAB.KM_NOMINAL,2) NOMINAL_KM,"); + sql.append(" round((TAB.TOTAL_OCUPADOS/TAB.TOTAL_ACENTOS)*100,1) OCUPACAO, "); + sql.append(" round(((TAB.TOTAL_OCUPADOS-TAB.TOTAL_OCUPADOS_GRATUIDADE)/TAB.TOTAL_ACENTOS)*100,1) OCUPACAO_ARRECADACAO, "); + sql.append(" round((TAB.TOTAL_OCUPADOS_GRATUIDADE/TAB.TOTAL_ACENTOS)*100,1) OCUPACAO_S_ARRECADACAO "); + sql.append(" "); + sql.append(" FROM ( "); + sql.append("SELECT (SELECT SUM(BO.PRECIOBASE) "); + sql.append(" FROM BOLETO BO "); + sql.append(" WHERE BO.CORRIDA_ID = CR.CORRIDA_ID "); + sql.append(" AND BO.FECCORRIDA = CR.FECCORRIDA "); + sql.append(" AND BO.ACTIVO = 1 "); + sql.append(" AND (BO.MOTIVOCANCELACION_ID IS NULL OR "); + sql.append(" BO.MOTIVOCANCELACION_ID = 0)) TOTAL_ARRECADADO, "); + sql.append(" "); + sql.append(" (SELECT SUM(TR.CANTKMREAL * DA.CANTASIENTOS) "); + sql.append(" FROM CORRIDA_TRAMO CT, "); + sql.append(" TRAMO TR, "); + sql.append(" ROL_OPERATIVO RO, "); + sql.append(" DIAGRAMA_AUTOBUS DA "); + sql.append(" WHERE CT.CORRIDA_ID = CR.CORRIDA_ID "); + sql.append(" AND CT.FECCORRIDA = CR.FECCORRIDA "); + sql.append(" AND RO.ROLOPERATIVO_ID = CR.ROLOPERATIVO_ID "); + sql.append(" AND DA.DIAGRAMAAUTOBUS_ID = RO.DIAGRAMAAUTOBUS_ID "); + sql.append(" AND TR.TRAMO_ID = CT.TRAMO_ID "); + sql.append(" AND CT.ACTIVO = 1) KM_NOMINAL, "); + sql.append(" "); + sql.append(" (SELECT SUM((SELECT TR.CANTKMREAL "); + sql.append(" FROM BOLETO BO, CORRIDA_TRAMO CTD, CORRIDA_TRAMO CTO "); + sql.append(" WHERE BO.CORRIDA_ID = CR.CORRIDA_ID "); + sql.append(" AND BO.FECCORRIDA = CR.FECCORRIDA "); + sql.append(" AND BO.NUMASIENTO = DD.ASIENTO "); + sql.append(" AND BO.ORIGEN_ID = CTO.ORIGEN_ID "); + sql.append(" AND BO.DESTINO_ID = CTD.DESTINO_ID "); + sql.append(" AND CTD.CORRIDA_ID = CR.CORRIDA_ID "); + sql.append(" AND CTD.FECCORRIDA = CR.FECCORRIDA "); + sql.append(" AND CTO.CORRIDA_ID = CR.CORRIDA_ID "); + sql.append(" AND CTO.FECCORRIDA = CR.FECCORRIDA "); + sql.append(" AND CTO.ACTIVO = 1 "); + sql.append(" AND CTD.ACTIVO = 1 "); + sql.append(" AND CT.NUMSECUENCIA BETWEEN CTO.NUMSECUENCIA AND "); + sql.append(" CTD.NUMSECUENCIA "); + sql.append(" AND BO.ACTIVO = 1 "); + sql.append(" AND (BO.MOTIVOCANCELACION_ID IS NULL OR "); + sql.append(" BO.MOTIVOCANCELACION_ID = 0))) "); + sql.append(" FROM CORRIDA_TRAMO CT, "); + sql.append(" TRAMO TR, "); + sql.append(" ROL_OPERATIVO RO, "); + sql.append(" DET_DIAGRAMA_AUTOBUS DD "); + sql.append(" WHERE "); + sql.append(" CR.FECCORRIDA = CT.FECCORRIDA "); + sql.append(" AND CR.CORRIDA_ID = CT.CORRIDA_ID "); + sql.append(" AND CT.TRAMO_ID = TR.TRAMO_ID "); + sql.append(" AND CR.ROLOPERATIVO_ID = RO.ROLOPERATIVO_ID "); + sql.append(" AND RO.DIAGRAMAAUTOBUS_ID = DD.DIAGRAMAAUTOBUS_ID "); + sql.append(" AND DD.VENDIBLE = 1 "); + sql.append(" AND CT.ACTIVO = 1) KM_OCUPADA, "); + sql.append(" (SELECT SUM(TF.PRECIO) "); + sql.append(" FROM CORRIDA_TRAMO CT, "); + sql.append(" TRAMO TR, "); + sql.append(" ROL_OPERATIVO RO, "); + sql.append(" DET_DIAGRAMA_AUTOBUS DD, "); + sql.append(" TARIFA TF "); + sql.append(" WHERE "); + sql.append(" CR.FECCORRIDA = CT.FECCORRIDA "); + sql.append(" AND CR.CORRIDA_ID = CT.CORRIDA_ID "); + sql.append(" AND CT.TRAMO_ID = TR.TRAMO_ID "); + sql.append(" AND CR.ROLOPERATIVO_ID = RO.ROLOPERATIVO_ID "); + sql.append(" AND RO.DIAGRAMAAUTOBUS_ID = DD.DIAGRAMAAUTOBUS_ID "); + sql.append(" AND TF.TRAMO_ID = CT.TRAMO_ID "); + sql.append(" AND TF.ORIGEN_ID = CT.ORIGEN_ID "); + sql.append(" AND TF.DESTINO_ID = CT.DESTINO_ID "); + sql.append(" AND DD.VENDIBLE = 1 "); + sql.append(" AND CT.ACTIVO = 1) TOTAL_NOMINAL, "); + sql.append(" "); + sql.append(" (SELECT COUNT(1) "); + sql.append(" FROM CORRIDA_TRAMO CT, "); + sql.append(" TRAMO TR, "); + sql.append(" ROL_OPERATIVO RO, "); + sql.append(" DET_DIAGRAMA_AUTOBUS DD "); + sql.append(" WHERE "); + sql.append(" "); + sql.append(" CR.FECCORRIDA = CT.FECCORRIDA "); + sql.append(" AND CR.CORRIDA_ID = CT.CORRIDA_ID "); + sql.append(" AND CT.TRAMO_ID = TR.TRAMO_ID "); + sql.append(" AND CR.ROLOPERATIVO_ID = RO.ROLOPERATIVO_ID "); + sql.append(" AND RO.DIAGRAMAAUTOBUS_ID = DD.DIAGRAMAAUTOBUS_ID "); + sql.append(" AND DD.VENDIBLE = 1 "); + sql.append(" AND CT.ACTIVO = 1) TOTAL_ACENTOS, "); + sql.append(" "); + sql.append(" (SELECT COUNT( "); + sql.append(" (SELECT 1 "); + sql.append(" FROM BOLETO BO, CORRIDA_TRAMO CTD, CORRIDA_TRAMO CTO "); + sql.append(" WHERE BO.CORRIDA_ID = CR.CORRIDA_ID "); + sql.append(" AND BO.FECCORRIDA = CR.FECCORRIDA "); + sql.append(" AND BO.NUMASIENTO = DD.ASIENTO "); + sql.append(" AND BO.ORIGEN_ID = CTO.ORIGEN_ID "); + sql.append(" AND BO.DESTINO_ID = CTD.DESTINO_ID "); + sql.append(" AND CTD.CORRIDA_ID = CR.CORRIDA_ID "); + sql.append(" AND CTD.FECCORRIDA = CR.FECCORRIDA "); + sql.append(" AND CTO.CORRIDA_ID = CR.CORRIDA_ID "); + sql.append(" AND CTO.FECCORRIDA = CR.FECCORRIDA "); + sql.append(" AND CTO.ACTIVO = 1 "); + sql.append(" AND CTD.ACTIVO = 1 "); + sql.append(" AND CT.NUMSECUENCIA BETWEEN CTO.NUMSECUENCIA AND CTD.NUMSECUENCIA "); + sql.append(" AND BO.ACTIVO = 1 "); + sql.append(" AND (BO.MOTIVOCANCELACION_ID IS NULL OR "); + sql.append(" BO.MOTIVOCANCELACION_ID = 0))) "); + sql.append(" FROM "); + sql.append(" CORRIDA_TRAMO CT, "); + sql.append(" TRAMO TR, "); + sql.append(" ROL_OPERATIVO RO, "); + sql.append(" DET_DIAGRAMA_AUTOBUS DD "); + sql.append(" WHERE "); + sql.append(" CR.FECCORRIDA = CT.FECCORRIDA "); + sql.append(" AND CR.CORRIDA_ID = CT.CORRIDA_ID "); + sql.append(" AND CT.TRAMO_ID = TR.TRAMO_ID "); + sql.append(" AND CR.ROLOPERATIVO_ID = RO.ROLOPERATIVO_ID "); + sql.append(" AND RO.DIAGRAMAAUTOBUS_ID = DD.DIAGRAMAAUTOBUS_ID "); + sql.append(" AND DD.VENDIBLE = 1 "); + sql.append(" AND CT.ACTIVO = 1) TOTAL_OCUPADOS, "); + sql.append(" (SELECT COUNT( "); + sql.append(" (SELECT 1 "); + sql.append(" FROM BOLETO BO, CORRIDA_TRAMO CTD, CORRIDA_TRAMO CTO "); + sql.append(" WHERE BO.CORRIDA_ID = CR.CORRIDA_ID "); + sql.append(" AND BO.FECCORRIDA = CR.FECCORRIDA "); + sql.append(" AND BO.NUMASIENTO = DD.ASIENTO "); + sql.append(" AND BO.ORIGEN_ID = CTO.ORIGEN_ID "); + sql.append(" AND BO.DESTINO_ID = CTD.DESTINO_ID "); + sql.append(" AND CTD.CORRIDA_ID = CR.CORRIDA_ID "); + sql.append(" AND CTD.FECCORRIDA = CR.FECCORRIDA "); + sql.append(" AND CTO.CORRIDA_ID = CR.CORRIDA_ID "); + sql.append(" AND CTO.FECCORRIDA = CR.FECCORRIDA "); + sql.append(" AND BO.PRECIOBASE = 0 "); + sql.append(" AND CTO.ACTIVO = 1 "); + sql.append(" AND CTD.ACTIVO = 1 "); + sql.append(" AND CT.NUMSECUENCIA BETWEEN CTO.NUMSECUENCIA AND CTD.NUMSECUENCIA "); + sql.append(" AND BO.ACTIVO = 1 "); + sql.append(" AND (BO.MOTIVOCANCELACION_ID IS NULL OR "); + sql.append(" BO.MOTIVOCANCELACION_ID = 0))) "); + sql.append(" FROM "); + sql.append(" CORRIDA_TRAMO CT, "); + sql.append(" TRAMO TR, "); + sql.append(" ROL_OPERATIVO RO, "); + sql.append(" DET_DIAGRAMA_AUTOBUS DD "); + sql.append(" WHERE "); + sql.append(" CR.FECCORRIDA = CT.FECCORRIDA "); + sql.append(" AND CR.CORRIDA_ID = CT.CORRIDA_ID "); + sql.append(" AND CT.TRAMO_ID = TR.TRAMO_ID "); + sql.append(" AND CR.ROLOPERATIVO_ID = RO.ROLOPERATIVO_ID "); + sql.append(" AND RO.DIAGRAMAAUTOBUS_ID = DD.DIAGRAMAAUTOBUS_ID "); + sql.append(" AND DD.VENDIBLE = 1 "); + sql.append(" AND CT.ACTIVO = 1) TOTAL_OCUPADOS_GRATUIDADE "); + sql.append(" FROM CORRIDA CR "); + sql.append(" WHERE CR.CORRIDA_ID = ? "); + sql.append(" AND CR.FECCORRIDA = ? "); + sql.append(" ) TAB"); + + return sql.toString(); + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/render/RenderRelatorioAbstract.java b/src/java/com/rjconsultores/ventaboletos/relatorios/render/RenderRelatorioAbstract.java new file mode 100644 index 000000000..8e1267d76 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/render/RenderRelatorioAbstract.java @@ -0,0 +1,106 @@ +package com.rjconsultores.ventaboletos.relatorios.render; + +import java.io.InputStream; +import java.sql.Connection; +import java.util.HashMap; +import java.util.Map; + +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JasperFillManager; +import net.sf.jasperreports.engine.JasperPrint; + +import com.rjconsultores.ventaboletos.relatorios.utilitarios.IDataSource; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.IRenderRelatorio; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.SaidaRelatorio; + +/** + * Classe utilizada para padronizar alguns comportamentos genéricos do renderizador de relatórios + * + * @author Bruno H. G. Gouvêa + * + */ +public abstract class RenderRelatorioAbstract implements IRenderRelatorio { + + protected Relatorio relatorio; + protected IDataSource datasource; + protected Connection connection; + private Map parametros = new HashMap(); + protected JasperPrint jasperPrint; + + + /** + * @param relatorio + * Enum do tipo Relatorio contendo as configurações de geração de todos os relatórios + * @param connection + * Objeto de conexão do banco que será utilizado para geração do relatório, só deve ser passado se não for utilizado nenhum tipo de Custom Data Source + */ + public RenderRelatorioAbstract(Relatorio relatorio, Connection connection) { + this.connection = connection; + this.relatorio = relatorio; + } + + /** + * Renderiza o relatório solicitado + * + * @param saida + * Enum contendo o tipo da saida do relatório + * @return Retorna um array de bytes contendo o conteúdo do relatório renderizado. + * @throws Exception + * Excessão durante a renderização do relatório + */ + protected abstract byte[] render(SaidaRelatorio saida) throws Exception; + + + /** + * @param relatorio + * Enum do tipo Relatorio contendo as configurações de geração de todos os relatórios + */ + public RenderRelatorioAbstract(Relatorio relatorio) { + this.relatorio = relatorio; + } + + public Map getParametros() { + return parametros; + } + + public void setParametros(Map parametros) { + this.parametros = parametros; + this.parametros.put("NOME_RELATORIO", this.relatorio.getNome()); + } + + /* + * (non-Javadoc) + * + * @see com.rjconsultores.ventaboletos.relatorios.utilitarios.IRenderRelatorio#getConteudo() + */ + @Override + public byte[] getConteudo(SaidaRelatorio saida) throws Exception { + + + if(this.jasperPrint == null){ + + if(this.relatorio.getParametros()!=null) + this.relatorio.getParametros().initParametros(this.parametros, this.connection); + + InputStream iStemplate = this.getClass().getResourceAsStream("/com/rjconsultores/ventaboletos/relatorios/templates/"+this.relatorio.getTemplate()); + + + if (this.relatorio.getDatasource() != null) + this.jasperPrint = JasperFillManager.fillReport(iStemplate, this.getParametros(), (JRDataSource) this.datasource); + else + this.jasperPrint = JasperFillManager.fillReport(iStemplate, this.getParametros(), this.connection); + + } + + + + + + return this.render(saida); + + } + + + +} diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/render/RenderRelatorioJasper.java b/src/java/com/rjconsultores/ventaboletos/relatorios/render/RenderRelatorioJasper.java new file mode 100644 index 000000000..a66510941 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/render/RenderRelatorioJasper.java @@ -0,0 +1,89 @@ +package com.rjconsultores.ventaboletos.relatorios.render; + +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.sql.Connection; + +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JasperExportManager; +import net.sf.jasperreports.engine.JasperFillManager; +import net.sf.jasperreports.engine.JasperPrint; +import net.sf.jasperreports.engine.export.JRXlsExporter; +import net.sf.jasperreports.engine.export.JRXlsExporterParameter; + +import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.SaidaRelatorio; + +/** + * Implementação da classe abstrata de renderização acoplada a uma tecnologia de renderização especifica + * + * @author Bruno H. G. Gouvêa + * + */ +public class RenderRelatorioJasper extends RenderRelatorioAbstract { + + /** + * @param relatorio + * Enum do tipo Relatorio contendo as configurações de geração de todos os relatórios + * @param connection + * Objeto de conexão do banco que será utilizado para geração do relatório, só deve ser passado se não for utilizado nenhum tipo de Custom Data Source + * + * @throws Exception + * Excessão contendo regra de utilização da classe + */ + public RenderRelatorioJasper(Relatorio relatorio, Connection connection) throws Exception { + super(relatorio, connection); + + if (relatorio.getDatasource() != null) + throw new Exception("Este relatório esta configurado para utilizar um datasource customizado, não é necessário passar uma conexão de dados."); + } + + /** + * @param relatorio + * Enum do tipo Relatorio contendo as configurações de geração de todos os relatórios + * @throws Exception + * Excessão contendo regra de utilização da classe + */ + public RenderRelatorioJasper(Relatorio relatorio) throws Exception { + super(relatorio); + + if (relatorio.getDatasource() == null) + throw new Exception("Este relatório esta configurado para utilizar uma conexão direta com banco de dados, utilize o construtor com a passagem de parametros correta."); + + } + + /* + * (non-Javadoc) + * + * @see com.rjconsultores.ventaboletos.relatorios.utilitarios.IRenderRelatorio#render() + */ + @Override + protected byte[] render(SaidaRelatorio saida) throws JRException { + byte[] conteudo = null; + + + switch (saida) { + + case PDF: + conteudo = JasperExportManager.exportReportToPdf(this.jasperPrint); + break; + + case XLS: + JRXlsExporter exporterXLS = new JRXlsExporter(); + ByteArrayOutputStream output = new ByteArrayOutputStream(); + exporterXLS.setParameter(JRXlsExporterParameter.JASPER_PRINT, this.jasperPrint); + exporterXLS.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, output); + exporterXLS.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE); + exporterXLS.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE); + exporterXLS.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE); + exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE); + exporterXLS.exportReport(); + conteudo = output.toByteArray(); + break; + + } + + return conteudo; + } +} diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAproveitamento.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAproveitamento.jasper new file mode 100644 index 0000000000000000000000000000000000000000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{a3mOB%ng#q2`NYg)`CV*W#mxxnt~T+AYd4mGli(bY@P)l1RUeW)HP zzO4RAS^X9OdP4&G@j>=uVnIt9f2zgoMa<8%m`f1z3oT|JV&2kX6t*QK$OqA&YtW!; z(V!2ZK_3S0_oF#)vtOZUzebbEeEVDCz=-+cUF{xx9!#n%s*LH=uT`~c6m6ukqD)HY_;-6RIzXHo|^ilTS zLBoK>_)$Eqv7Y_`PiI#V1}cp9*t#__bxdK$n}(t3*Gsoi=ad-b^W zME2?n9yMGCjY_nI?A4Rj6WObG@h560*{icMP1>tz5WdO3m+?^y_+w=ay-QDWRF6M96;<77`QJ&iX6n?J! zHSD(-=As{^f6;2d)hb~Yt;~Y&gjOZrArRDv(O@Ku*~X|b-xxC%7-{2V5L>IU+gNQ(8f%P;jDYceBM8FV zWb8Bgj4O<|aV1J!gIw2wB(FotM?jJ{fh2DRN!|*Q{3J+n`u~#T{}ht^E4ifcS&-!C zK#~uFBp(7vJ_?dN0FrzHB>6><?LuZ-XSC2T8sNl6(my z`7%iI6_Df)K$5S4B;No@{s<)bCP?yUAj!8tl5c|~e+!a)2PFANkmS1{$v=Z6|6;Vd z3}dy+Wvp>k839+d5p>lWn_M2F&sA^4T@A*FYmSj|%{6wpjxa8D9cg^PHQ(6pYBH{O s9dF#`S_+b^0pG`RE6e6MdVS*4l8$dr6n67w%N2Gb+^hzr!)p4!0pO9*+5i9m literal 0 HcmV?d00001 diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAproveitamento.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAproveitamento.jrxml new file mode 100644 index 000000000..22e6b961f --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAproveitamento.jrxml @@ -0,0 +1,388 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="85" splitType="Stretch"> + <rectangle> + <reportElement uuid="8f226d21-ccdb-41b4-a01d-fb0712f0b4d3" x="0" y="0" width="555" height="30"/> + </rectangle> + <rectangle> + <reportElement uuid="b6aa9717-79c4-4f13-91df-9b0255003a16" x="0" y="40" width="555" height="39"/> + </rectangle> + <staticText> + <reportElement uuid="2e854857-9e82-43ae-bc7b-232319c1f259" x="12" y="0" width="65" height="15"/> + <textElement> + <font size="11" isBold="true"/> + </textElement> + <text><![CDATA[Relatório: ]]></text> + </staticText> + <textField> + <reportElement uuid="eb300dc6-1610-409d-8589-72b1539f86d3" x="77" y="0" width="478" height="15"/> + <textElement> + <font size="11"/> + </textElement> + <textFieldExpression><![CDATA[$P{NOME_RELATORIO}]]></textFieldExpression> + </textField> + <staticText> + <reportElement uuid="b76b0e17-99b2-4681-8f60-b5bd5512e897" x="12" y="15" width="65" height="15"/> + <textElement> + <font size="11" isBold="true"/> + </textElement> + <text><![CDATA[Serviço: ]]></text> + </staticText> + <staticText> + <reportElement uuid="bd889fb9-30d9-4023-b811-7f55e3213705" x="244" y="15" width="65" height="15"/> + <textElement> + <font size="11" isBold="true"/> + </textElement> + <text><![CDATA[Data:]]></text> + </staticText> + <textField> + <reportElement uuid="a3d3c093-a9f4-4b32-823f-b4f548e46c2f" x="77" y="15" width="167" height="15"/> + <textElement> + <font size="11"/> + </textElement> + <textFieldExpression><![CDATA[$P{CORRIDA_ID}]]></textFieldExpression> + </textField> + <staticText> + <reportElement uuid="021e9662-43c5-4054-a0d2-3fc8f6003111" x="12" y="40" width="78" height="11"/> + <textElement> + <font size="8"/> + </textElement> + <text><![CDATA[Total Arrecadado:]]></text> + </staticText> + <staticText> + <reportElement uuid="062b6b12-00e3-4389-8359-bf59b8879b4d" x="12" y="51" width="78" height="11"/> + <textElement> + <font size="8"/> + </textElement> + <text><![CDATA[Arrecadado/KM:]]></text> + </staticText> + <staticText> + <reportElement uuid="f2b94d48-f3b5-4781-ac11-ff28a41e0d90" x="197" y="40" width="105" height="11"/> + <textElement> + <font size="8"/> + </textElement> + <text><![CDATA[Ocupação:]]></text> + </staticText> + <staticText> + <reportElement uuid="58deb635-5e71-4614-b71e-d81d5dad85f0" x="197" y="51" width="105" height="11"/> + <textElement> + <font size="8"/> + </textElement> + <text><![CDATA[Ocupação com Arrecação:]]></text> + </staticText> + <staticText> + <reportElement uuid="eec1daa6-74c5-49bf-855f-602d5230dfa1" x="12" y="63" width="78" height="11"/> + <textElement> + <font size="8"/> + </textElement> + <text><![CDATA[Nominal/KM:]]></text> + </staticText> + <staticText> + <reportElement uuid="ccaffa74-0602-4168-b191-ba02c523221f" x="197" y="63" width="105" height="11"/> + <textElement> + <font size="8"/> + </textElement> + <text><![CDATA[Ocupação sem Arrecação:]]></text> + </staticText> + <staticText> + <reportElement uuid="12cf983e-3909-4cf6-94d8-dfc008edc47d" x="382" y="40" width="78" height="11"/> + <textElement> + <font size="8"/> + </textElement> + <text><![CDATA[Total Nominal:]]></text> + </staticText> + <line> + <reportElement uuid="5b56b7a4-1abd-43cc-8071-e949d5575a45" x="185" y="40" width="1" height="39" forecolor="#CCCCCC"/> + </line> + <line> + <reportElement uuid="98b93926-7900-4445-bbe6-024e456fd45e" x="370" y="40" width="1" height="39" forecolor="#CCCCCC"/> + </line> + <textField> + <reportElement uuid="bdfd7f9e-e50e-4a8b-bba4-2fc8a909f38b" x="90" y="63" width="78" height="11"/> + <textElement> + <font size="8"/> + </textElement> + <textFieldExpression><![CDATA[$P{P_NOMINAL_KM}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="7eb2d8d3-4a3f-40cd-8117-8e53ab128f34" x="90" y="40" width="96" height="11"/> + <textElement> + <font size="8"/> + </textElement> + <textFieldExpression><![CDATA[$P{P_TOTAL_ARRECADADO}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="64600377-6028-4c56-b0f1-3acf6ceeb708" x="90" y="51" width="95" height="11"/> + <textElement> + <font size="8"/> + </textElement> + <textFieldExpression><![CDATA[$P{P_ARRECADO_KM}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="6b68d2b4-0fa0-41a4-bdf5-0eaccb7d1f59" x="302" y="40" width="100" height="11"/> + <textElement> + <font size="8"/> + </textElement> + <textFieldExpression><![CDATA[$P{P_OCUPACAO}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="66317ebd-e503-420c-8886-8385b782770d" x="302" y="51" width="69" height="11"/> + <textElement> + <font size="8"/> + </textElement> + <textFieldExpression><![CDATA[$P{P_OCUPACAO_ARRECADACAO}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="a6ff7221-60b5-4d08-b7e8-7b10db0b97a6" x="302" y="63" width="68" height="11"/> + <textElement> + <font size="8"/> + </textElement> + <textFieldExpression><![CDATA[$P{P_OCUPACAO_S_ARRECADACAO}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="9eebfdd7-504b-4e98-8893-63bdb8c02b54" x="468" y="40" width="87" height="11"/> + <textElement> + <font size="8"/> + </textElement> + <textFieldExpression><![CDATA[$P{P_TOTAL_NOMINAL}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="0eccc14c-3288-43e8-8731-7c876e4d659e" x="309" y="15" width="100" height="15"/> + <textElement/> + <textFieldExpression><![CDATA[$P{DATA}]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/IDataSource.java b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/IDataSource.java new file mode 100644 index 000000000..eed0e9194 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/IDataSource.java @@ -0,0 +1,13 @@ +package com.rjconsultores.ventaboletos.relatorios.utilitarios; + +import net.sf.jasperreports.engine.JRDataSource; + +/** + * Interface para desacoplamento do datasource + * + * @author Bruno H. G. Gouvêa + * + */ +public interface IDataSource extends JRDataSource { + +} \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/IParametros.java b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/IParametros.java new file mode 100644 index 000000000..fced7e5f7 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/IParametros.java @@ -0,0 +1,25 @@ +/** + * + */ +package com.rjconsultores.ventaboletos.relatorios.utilitarios; + +import java.sql.Connection; +import java.util.Map; + +/** + * @author Bruno H. G. Gouvêa + * + */ +public interface IParametros { + + + + + /** + * @param parametros + * @param connection + * @throws Exception + */ + void initParametros(Map parametros, Connection connection) throws Exception; + +} diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/IRenderRelatorio.java b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/IRenderRelatorio.java new file mode 100644 index 000000000..1f5b18db1 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/IRenderRelatorio.java @@ -0,0 +1,23 @@ +package com.rjconsultores.ventaboletos.relatorios.utilitarios; + +/** + * Interface de renderização de relatórios + * + * @author Bruno H. G. Gouvêa + * + */ +public interface IRenderRelatorio { + + /** + * Retorna o relatório renderizado, ou chama a rederização caso seja necessário. + * + * @param saida + * Enum contendo o tipo da saida do relatório + * @return Retorna um array de bytes contendo o conteúdo do relatório renderizado. + * @throws Exception + * Excessão durante a renderização do relatório + */ + public byte[] getConteudo(SaidaRelatorio saida) throws Exception; + + +} \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/Relatorio.java b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/Relatorio.java new file mode 100644 index 000000000..298b9c892 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/Relatorio.java @@ -0,0 +1,97 @@ +package com.rjconsultores.ventaboletos.relatorios.utilitarios; + +import java.util.HashMap; +import java.util.Map; + +import com.rjconsultores.ventaboletos.relatorios.datasource.*; +import com.rjconsultores.ventaboletos.relatorios.parametros.*; + +/** + * + * Enum complexo contendo as configurações dos relatórios disponíveis no sistema. + * + * @author Bruno H. G. Gouvêa + * + */ +/** + * @author Bruno H. G. Gouvêa + * + */ +public enum Relatorio { + + RELATORIO_APROVEITAMENTO(1, "RelatorioAproveitamento.jasper", "Relatório de Aproveitamento",new RendimentoParamsImpl(), null), + RELATORIO_SERVICOS(2, "Servicos.jasper", "Relatório de Serviços", null, new Vendas2CustomDS()), + RELATORIO_EXEMPLO(3, "ExemploFoo.jrxml", "Relatório Foo", null, null); + + private int codigo; + private String template; + private String nome; + protected IDataSource datasource; + private IParametros parametros; + + private static Map mapCodigoToRelatorio; + + /** + * @param codigo + * Identificador do relatório + * @param template + * Arquivo de template do relatório + * @param nome + * Nome/Descrição do relátorio + * @param datasource + * Custom Data Source do relátorio, só deve ser informado caso o relátorio não possua acesso direto ao banco + */ + private Relatorio(int codigo, String template, String nome, IParametros parametros, IDataSource datasource) { + this.codigo = codigo; + this.setTemplate(template); + this.setNome(nome); + this.datasource = datasource; + this.parametros = parametros; + } + + public static Relatorio getRelatorio(int i) { + if (mapCodigoToRelatorio == null) { + initMapeamento(); + } + return mapCodigoToRelatorio.get(i); + } + + private static void initMapeamento() { + mapCodigoToRelatorio = new HashMap(); + for (Relatorio s : values()) { + mapCodigoToRelatorio.put(s.codigo, s); + } + } + + public String getTemplate() { + return template; + } + + public void setTemplate(String template) { + this.template = template; + } + + public String getNome() { + return nome; + } + + public void setNome(String nome) { + this.nome = nome; + } + + public IDataSource getDatasource() { + return datasource; + } + + public void setDatasource(IDataSource datasource) { + this.datasource = datasource; + } + + public IParametros getParametros() { + return parametros; + } + + public void setParametros(IParametros parametros) { + this.parametros = parametros; + } +} \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/SaidaRelatorio.java b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/SaidaRelatorio.java new file mode 100644 index 000000000..acb164ea5 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/SaidaRelatorio.java @@ -0,0 +1,11 @@ +package com.rjconsultores.ventaboletos.relatorios.utilitarios; + +/** + * + * + * @author Bruno H. G. Gouvêa + * + */ +public enum SaidaRelatorio { + PDF,XLS +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioAproveitamentoController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioAproveitamentoController.java new file mode 100644 index 000000000..5b6f59e5c --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioAproveitamentoController.java @@ -0,0 +1,101 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.web.gui.controladores.relatorios; + +import java.util.HashMap; +import java.util.Map; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Controller; +import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.event.Event; +import org.zkoss.zul.Datebox; +import org.zkoss.zul.Div; +import org.zkoss.zul.Iframe; + +import com.rjconsultores.ventaboletos.relatorios.render.RenderRelatorioJasper; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; +import com.rjconsultores.ventaboletos.utilerias.DateUtil; +import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; +import com.rjconsultores.ventaboletos.web.utilerias.MyTextbox; + +/** + * + * @author Administrador + */ +@Controller("relatorioAproveitamentoController") +@Scope("prototype") +public class RelatorioAproveitamentoController extends MyGenericForwardComposer { + + private Datebox fecCorrida; + private Div divResultadoRelatorio; + private Iframe iframeRelatorio; + private MyTextbox txtCorridaId; + + @Autowired + private DataSource dataSource; + + public Iframe getIframeRelatorio() { + return iframeRelatorio; + } + + public void setIframeRelatorio(Iframe iframeRelatorio) { + this.iframeRelatorio = iframeRelatorio; + } + + public Div getDivResultadoRelatorio() { + return divResultadoRelatorio; + } + + public void setDivResultadoRelatorio(Div divResultadoRelatorio) { + this.divResultadoRelatorio = divResultadoRelatorio; + } + + public Datebox getFecCorrida() { + return fecCorrida; + } + + public void setFecCorrida(Datebox fecCorrida) { + this.fecCorrida = fecCorrida; + } + + @Override + public void doAfterCompose(Component comp) throws Exception { + super.doAfterCompose(comp); + + } + + public void onClick$btnExecutarRelatorio(Event ev) throws Exception { + executarRelatorio(); + } + + /** + * @throws Exception + * + */ + private void executarRelatorio() throws Exception { + + Map parametros = new HashMap(); + + RenderRelatorioJasper render = new RenderRelatorioJasper(Relatorio.RELATORIO_APROVEITAMENTO, dataSource.getConnection()); + + parametros.put("CORRIDA_ID", this.txtCorridaId.getValue()); + parametros.put("FECCORRIDA", new java.sql.Date(((java.util.Date) this.fecCorrida.getValue()).getTime())); + parametros.put("DATA", DateUtil.getStringDate((java.util.Date) this.fecCorrida.getValue())); // Utilizada para exibição no cabeçalho + + render.setParametros(parametros); + + Map args = new HashMap(); + args.put("renderRelatorio", render); + + openWindow("/component/reportView.zul", + Relatorio.RELATORIO_APROVEITAMENTO.getNome(), args, MODAL); + + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioController.java new file mode 100644 index 000000000..9cf65d4f4 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioController.java @@ -0,0 +1,133 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.web.gui.controladores.relatorios; + + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Controller; +import org.zkoss.util.media.AMedia; +import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.Executions; +import org.zkoss.zk.ui.event.Event; +import org.zkoss.zul.Div; +import org.zkoss.zul.Filedownload; +import org.zkoss.zul.Iframe; +import org.zkoss.zul.Toolbarbutton; + +import com.rjconsultores.ventaboletos.relatorios.render.RenderRelatorioJasper; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.SaidaRelatorio; +import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; + +/** + * + * @author Administrador + */ +@Controller("relatorioController") +@Scope("prototype") +public class RelatorioController extends MyGenericForwardComposer { + + + private Div divResultadoRelatorio; + private Iframe iframeRelatorio; + private Toolbarbutton btnSalvarPDF; + private Toolbarbutton btnSalvarXLS; + private AMedia conteudoRelatorioPDF; + private AMedia conteudoRelatorioXLS; + private RenderRelatorioJasper renderRelatorio; + + + /** + * @return the btnSalvarPDF + */ + public Toolbarbutton getBtnSalvarPDF() { + return btnSalvarPDF; + } + + + /** + * @param btnSalvarPDF the btnSalvarPDF to set + */ + public void setBtnSalvarPDF(Toolbarbutton btnSalvarPDF) { + this.btnSalvarPDF = btnSalvarPDF; + } + + + /** + * @return the btnSalvarXLS + */ + public Toolbarbutton getBtnSalvarXLS() { + return btnSalvarXLS; + } + + + /** + * @param btnSalvarXLS the btnSalvarXLS to set + */ + public void setBtnSalvarXLS(Toolbarbutton btnSalvarXLS) { + this.btnSalvarXLS = btnSalvarXLS; + } + + + + public Iframe getIframeRelatorio() { + return iframeRelatorio; + } + + + public void setIframeRelatorio(Iframe iframeRelatorio) { + this.iframeRelatorio = iframeRelatorio; + } + + + public Div getDivResultadoRelatorio() { + return divResultadoRelatorio; + } + + + public void setDivResultadoRelatorio(Div divResultadoRelatorio) { + this.divResultadoRelatorio = divResultadoRelatorio; + } + + + + @Override + public void doAfterCompose(Component comp) throws Exception { + super.doAfterCompose(comp); + + this.renderRelatorio = (RenderRelatorioJasper) Executions.getCurrent().getArg().get("renderRelatorio"); + + final InputStream mediais = new ByteArrayInputStream(this.renderRelatorio.getConteudo(SaidaRelatorio.PDF)); + + conteudoRelatorioPDF = new AMedia("relatorio.pdf", "pdf", null, mediais); + + + + iframeRelatorio.setContent(conteudoRelatorioPDF); + + + } + + + public void onClick$btnSalvarPDF(Event ev) { + Filedownload.save(conteudoRelatorioPDF.getStreamData(), "application/pdf", "relatorio.pdf"); + } + + public void onClick$btnSalvarXLS(Event ev) throws Exception { + final InputStream mediais = new ByteArrayInputStream(this.renderRelatorio.getConteudo(SaidaRelatorio.XLS)); + + conteudoRelatorioXLS = new AMedia("relatorio.xls", "xls", null, mediais); + Filedownload.save(conteudoRelatorioXLS.getStreamData(), "application/xls", "relatorio.xls"); + } + + + + + + + +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/CurrencyUtil.java b/src/java/com/rjconsultores/ventaboletos/web/utilerias/CurrencyUtil.java new file mode 100644 index 000000000..8cce24545 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/CurrencyUtil.java @@ -0,0 +1,30 @@ +/** + * + */ +package com.rjconsultores.ventaboletos.web.utilerias; + +import java.text.DecimalFormat; +import java.util.Currency; + +/** + * @author Bruno H. G. Gouvêa + * + */ +public final class CurrencyUtil { + + + public static String getCurrencyStrFromStr(String value){ + + + double doubleValue = Double.parseDouble(value); + Currency currency = Currency.getInstance("BRL"); + DecimalFormat formato = new DecimalFormat(currency.getSymbol() + "#,##0.00"); + + + + + return formato.format(doubleValue); + + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/ItemMenuRelatorioAproveitamento.java b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/ItemMenuRelatorioAproveitamento.java new file mode 100644 index 000000000..d2c80d3f4 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/ItemMenuRelatorioAproveitamento.java @@ -0,0 +1,25 @@ +package com.rjconsultores.ventaboletos.web.utilerias.menu.item.relatorios; + +import org.zkoss.util.resource.Labels; + +import com.rjconsultores.ventaboletos.web.utilerias.PantallaUtileria; +import com.rjconsultores.ventaboletos.web.utilerias.menu.DefaultItemMenuSistema; + +public class ItemMenuRelatorioAproveitamento extends DefaultItemMenuSistema { + + public ItemMenuRelatorioAproveitamento() { + super("indexController.mniRelatorioAproveitamento.label"); + } + + @Override + public String getClaveMenu() { + return "COM.RJCONSULTORES.ADMINISTRACION.GUI.RELATORIOS.MENU.RELATORIOAPROVEITAMENTO"; + } + + @Override + public void ejecutar() { + PantallaUtileria.openWindow("/gui/relatorios/filtroRelatorioAproveitamento.zul", + Labels.getLabel("relatorioAproveitamentoController.window.title"), null,desktop); + + } +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/MenuRelatorios.java b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/MenuRelatorios.java new file mode 100644 index 000000000..cf5c858af --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/MenuRelatorios.java @@ -0,0 +1,16 @@ +package com.rjconsultores.ventaboletos.web.utilerias.menu.item.relatorios; + +import com.rjconsultores.ventaboletos.web.utilerias.menu.DefaultItemMenuSistema; + +public class MenuRelatorios extends DefaultItemMenuSistema { + + public MenuRelatorios() { + super("indexController.mniRelatorios.label"); + } + + @Override + public String getClaveMenu() { + return "COM.RJCONSULTORES.ADMINISTRACION.GUI.RELATORIOS"; + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/menu_original.properties b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/menu_original.properties index af749aa9b..4539dace0 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/menu_original.properties +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/menu_original.properties @@ -110,3 +110,5 @@ informes.categoriaVenta=com.rjconsultores.ventaboletos.web.utilerias.menu.item.i informes.ventasPuntoVenta=com.rjconsultores.ventaboletos.web.utilerias.menu.item.informes.ItemMenuVentasPuntoVenta ayuda=com.rjconsultores.ventaboletos.web.utilerias.menu.item.ayuda.MenuAyuda ayuda.version=com.rjconsultores.ventaboletos.web.utilerias.menu.item.ayuda.ItemMenuVersion +relatorios=com.rjconsultores.ventaboletos.web.utilerias.menu.item.relatorios.MenuRelatorios +relatorios.relatorioAproveitamento=com.rjconsultores.ventaboletos.web.utilerias.menu.item.relatorios.ItemMenuRelatorioAproveitamento diff --git a/web/WEB-INF/i3-label_pt_BR.label b/web/WEB-INF/i3-label_pt_BR.label index 06bb4025d..657ee2ffa 100644 --- a/web/WEB-INF/i3-label_pt_BR.label +++ b/web/WEB-INF/i3-label_pt_BR.label @@ -56,6 +56,10 @@ MSG.necesita.formaPago = Forma de Pagamento Obrigatória lb.id = ID lb.dec = Descrição lb.Equivalencia = Equivalencia +lb.btnExecutarRelatorio = Executar Relatório +lb.btnSalvarRelatorio = Salvar Relatório +lb.btnSalvarRelatorioPdf = Salvar Relatório em PDF +lb.btnSalvarRelatorioXls = Salvar Relatório em XLS # tooltip botões @@ -66,6 +70,7 @@ tooltiptext.btnAgregar = Incluir tooltiptext.btnGuardar = Salvar tooltiptext.btnPesquisa = Pesquisa + # Pantalla de início de sesión: winLogin.title = Conectar winLogin.lblUsuario = Usuário: @@ -201,6 +206,8 @@ indexController.mniConfigLayoutImpressaoBoleto.label = Config Layout Impressão indexController.mniAliasServico.label = Alias Localidade indexController.mniCliente.label = Cliente indexController.mniTarjetaCredito.label = Cartão de Crédito +indexController.mniRelatorios.label = Relatórios +indexController.mniRelatorioAproveitamento.label = Relatório de Aproveitamento #PARTE REALIZADA POR MANUEL indexController.mnCortesias.label = Cortesias Para Funcionários @@ -224,6 +231,11 @@ busquedaClaseServicioController.btnPesquisa.label = Pesquisa busquedaClaseServicioController.lhDesc.label = Descrição busquedaClaseServicioController.lhId.label = ID +#Relatórios +relatorioAproveitamentoController.window.title = Relatório de Aproveitamento +relatorioAproveitamentoController.lbFecCorrida.value = Data Serviço +relatorioAproveitamentoController.lbServico.value = N. Serviço + # Pantalla Editar Classe editarClaseServicioController.window.title = Tipo de Classe editarClaseServicioController.btnApagar.tooltiptext = Eliminar diff --git a/web/component/reportView.zul b/web/component/reportView.zul new file mode 100644 index 000000000..f790eeea6 --- /dev/null +++ b/web/component/reportView.zul @@ -0,0 +1,30 @@ + + + + + + + + + +
+ + + + + + + + + +