- Esqueleto internacionalização de relatório

- Ajustes relatório de rendimento
- Refactoring

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@28084 d1611594-4594-4d17-8e1d-87c2c4800839
master
bruno 2013-06-21 14:03:23 +00:00
parent 98cf29e2e5
commit f2ef5c08aa
13 changed files with 210 additions and 138 deletions

View File

@ -0,0 +1,16 @@
#geral
msg.noData=Não foi possivel obter dados com os parâmetros informados.
#Labels cabeçalho
cabecalho.relatorio=Relatório:
cabecalho.servico=Serviço:
cabecalho.data=Data:
#Labels header
sumario.totalArrecadado=Total Arrecadado:
sumario.arrecadadoKm=Arrecadado/KM:
sumario.nominalKm=Nominal/KM:
sumario.ocupacao=Ocupação:
sumario.ocupacaoComArrecadacao=Ocupação com Arrecadação:
sumario.ocupacaoSemArrecadacao=Ocupação sem Arrecadação
sumario.totalNominal=Total Nominal:

View File

@ -7,6 +7,7 @@ package com.rjconsultores.ventaboletos.relatorios.parametros;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.IParametros; import com.rjconsultores.ventaboletos.relatorios.utilitarios.IParametros;
import com.rjconsultores.ventaboletos.web.utilerias.CurrencyUtil; import com.rjconsultores.ventaboletos.web.utilerias.CurrencyUtil;
@ -23,7 +24,7 @@ public class RendimentoParamsImpl implements IParametros {
* @see com.rjconsultores.ventaboletos.relatorios.utilitarios.IParametros#initParametros() * @see com.rjconsultores.ventaboletos.relatorios.utilitarios.IParametros#initParametros()
*/ */
@Override @Override
public void initParametros(Map<String, Object> parametros, Connection connection) throws Exception { public void processaParametros(Map<String, Object> parametros, Connection connection) throws Exception {
String sql = this.getSql(); String sql = this.getSql();
PreparedStatement stmt = null; PreparedStatement stmt = null;
@ -35,13 +36,18 @@ public class RendimentoParamsImpl implements IParametros {
rset = stmt.executeQuery(); rset = stmt.executeQuery();
if (rset.next()) { 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"))); // TODO Alterar para injeção de acordo com usuário logado ou outro meio para obter o Locale correto
parametros.put("P_ARRECADO_KM", CurrencyUtil.getCurrencyStrFromStr(rset.getString("ARRECADADO_KM"))); Locale locale = new Locale("pt", "BR");
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_NOMINAL_KM", CurrencyUtil.getCurrencyStrFromStr(rset.getString("NOMINAL_KM"), locale));
parametros.put("P_OCUPACAO_S_ARRECADACAO", rset.getString("OCUPACAO_S_ARRECADACAO") +" %"); parametros.put("P_TOTAL_ARRECADADO", CurrencyUtil.getCurrencyStrFromStr(rset.getString("TOTAL_ARRECADADO"), locale));
parametros.put("P_ARRECADO_KM", CurrencyUtil.getCurrencyStrFromStr(rset.getString("ARRECADADO_KM"), locale));
parametros.put("P_OCUPACAO", CurrencyUtil.getPercentStrFromStr(rset.getString("OCUPACAO"), locale));
parametros.put("P_OCUPACAO_ARRECADACAO", CurrencyUtil.getPercentStrFromStr(rset.getString("OCUPACAO_ARRECADACAO"), locale));
parametros.put("P_TOTAL_NOMINAL", CurrencyUtil.getCurrencyStrFromStr(rset.getString("TOTAL_NOMINAL"), locale));
parametros.put("P_OCUPACAO_S_ARRECADACAO", CurrencyUtil.getPercentStrFromStr(rset.getString("OCUPACAO_S_ARRECADACAO"), locale) );
} }
} }
@ -109,23 +115,29 @@ public class RendimentoParamsImpl implements IParametros {
sql.append(" AND RO.DIAGRAMAAUTOBUS_ID = DD.DIAGRAMAAUTOBUS_ID "); sql.append(" AND RO.DIAGRAMAAUTOBUS_ID = DD.DIAGRAMAAUTOBUS_ID ");
sql.append(" AND DD.VENDIBLE = 1 "); sql.append(" AND DD.VENDIBLE = 1 ");
sql.append(" AND CT.ACTIVO = 1) KM_OCUPADA, "); sql.append(" AND CT.ACTIVO = 1) KM_OCUPADA, ");
sql.append(" (SELECT SUM(TF.PRECIO) ");
sql.append(" FROM CORRIDA_TRAMO CT, "); sql.append(" (SELECT SUM(TF.PRECIO) ");
sql.append(" TRAMO TR, "); sql.append(" FROM TRAMO TR, ");
sql.append(" ROL_OPERATIVO RO, "); sql.append(" ROL_OPERATIVO RO, ");
sql.append(" DET_DIAGRAMA_AUTOBUS DD, "); sql.append(" DET_DIAGRAMA_AUTOBUS DD, ");
sql.append(" TARIFA TF "); sql.append(" TARIFA TF, ");
sql.append(" WHERE "); sql.append(" VIGENCIA_TARIFA VT ");
sql.append(" CR.FECCORRIDA = CT.FECCORRIDA "); sql.append(" WHERE RO.ROLOPERATIVO_ID = CR.ROLOPERATIVO_ID ");
sql.append(" AND CR.CORRIDA_ID = CT.CORRIDA_ID "); sql.append(" AND RO.DIAGRAMAAUTOBUS_ID = DD.DIAGRAMAAUTOBUS_ID ");
sql.append(" AND CT.TRAMO_ID = TR.TRAMO_ID "); sql.append(" AND TF.CLASESERVICIO_ID = CR.CLASESERVICIO_ID ");
sql.append(" AND CR.ROLOPERATIVO_ID = RO.ROLOPERATIVO_ID "); sql.append(" AND DD.VENDIBLE = 1 ");
sql.append(" AND RO.DIAGRAMAAUTOBUS_ID = DD.DIAGRAMAAUTOBUS_ID "); sql.append(" AND TR.ORIGEN_ID = CR.ORIGEN_ID ");
sql.append(" AND TF.TRAMO_ID = CT.TRAMO_ID "); sql.append(" AND TR.DESTINO_ID = CR.DESTINO_ID ");
sql.append(" AND TF.ORIGEN_ID = CT.ORIGEN_ID "); sql.append(" AND TF.MARCA_ID = CR.MARCA_ID ");
sql.append(" AND TF.DESTINO_ID = CT.DESTINO_ID "); sql.append(" AND TF.RUTA_ID = CR.RUTA_ID ");
sql.append(" AND DD.VENDIBLE = 1 "); sql.append(" AND TF.TRAMO_ID = TR.TRAMO_ID ");
sql.append(" AND CT.ACTIVO = 1) TOTAL_NOMINAL, "); sql.append(" AND TF.STATUSTARIFA = 'A' ");
sql.append(" AND TF.ACTIVO = 1 ");
sql.append(" AND TF.VIGENCIATARIFA_ID = VT.VIGENCIATARIFA_ID ");
sql.append(" AND VT.ACTIVO = 1 ");
sql.append(" AND CR.FECCORRIDA BETWEEN VT.FECINICIOVIGENCIA AND ");
sql.append(" VT.FECFINVIGENCIA) TOTAL_NOMINAL,");
sql.append(" "); sql.append(" ");
sql.append(" (SELECT COUNT(1) "); sql.append(" (SELECT COUNT(1) ");
sql.append(" FROM CORRIDA_TRAMO CT, "); sql.append(" FROM CORRIDA_TRAMO CT, ");

View File

@ -58,7 +58,16 @@ public abstract class RenderRelatorioAbstract implements IRenderRelatorio {
public void setParametros(Map<String, Object> parametros) { public void setParametros(Map<String, Object> parametros) {
this.parametros = parametros; this.parametros = parametros;
this.parametros.put("NOME_RELATORIO", this.relatorio.getNome()); }
public void preRender(){
this.initParametros();
}
public void initParametros(){
this.parametros.put("NOME_RELATORIO", this.relatorio.getDescricao());
this.parametros.put("MSG_NO_DATA", this.relatorio.getNome());
} }
/* /*
@ -68,7 +77,7 @@ public abstract class RenderRelatorioAbstract implements IRenderRelatorio {
*/ */
@Override @Override
public byte[] getConteudo(SaidaRelatorio saida) throws Exception { public byte[] getConteudo(SaidaRelatorio saida) throws Exception {
this.preRender();
return this.render(saida); return this.render(saida);
} }

View File

@ -3,8 +3,11 @@ package com.rjconsultores.ventaboletos.relatorios.render;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.InputStream; import java.io.InputStream;
import java.sql.Connection; import java.sql.Connection;
import java.util.Locale;
import java.util.ResourceBundle;
import net.sf.jasperreports.engine.JRDataSource; import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRParameter;
import net.sf.jasperreports.engine.JasperExportManager; import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager; import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.JasperPrint;
@ -53,6 +56,21 @@ public class RenderRelatorioJasper extends RenderRelatorioAbstract {
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."); 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.");
} }
@Override
public void preRender(){
super.preRender();
this.initBundler();
}
private void initBundler(){
// TODO Alterar para injeção de acordo com usuário logado ou outro meio para obter o Locale correto
Locale locale = new Locale("pt", "BR");
ResourceBundle resource = ResourceBundle.getBundle("com.rjconsultores.ventaboletos.relatorios.internacionalizacao."+this.relatorio.getNome(), locale);
this.parametros.put(JRParameter.REPORT_RESOURCE_BUNDLE, resource);
}
/* /*
* (non-Javadoc) * (non-Javadoc)
@ -66,9 +84,9 @@ public class RenderRelatorioJasper extends RenderRelatorioAbstract {
if (this.jasperPrint == null) { if (this.jasperPrint == null) {
if (this.relatorio.getParametros() != null) if (this.relatorio.getParametros() != null)
this.relatorio.getParametros().initParametros(this.parametros, this.connection); this.relatorio.getParametros().processaParametros(this.parametros, this.connection);
InputStream iStemplate = this.getClass().getResourceAsStream("/com/rjconsultores/ventaboletos/relatorios/templates/" + this.relatorio.getTemplate()); InputStream iStemplate = this.getClass().getResourceAsStream("/com/rjconsultores/ventaboletos/relatorios/templates/" + this.relatorio.getNome()+".jasper");
if (this.relatorio.getDatasource() != null) if (this.relatorio.getDatasource() != null)
this.jasperPrint = JasperFillManager.fillReport(iStemplate, this.getParametros(), (JRDataSource) this.datasource); this.jasperPrint = JasperFillManager.fillReport(iStemplate, this.getParametros(), (JRDataSource) this.datasource);

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="RelatorioAproveitamento" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="3308e98f-a36a-4ee6-bb41-be017c32427e"> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="RelatorioAproveitamento" pageWidth="595" pageHeight="842" whenNoDataType="NoDataSection" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="3308e98f-a36a-4ee6-bb41-be017c32427e">
<property name="ireport.zoom" value="1.5"/> <property name="ireport.zoom" value="1.5"/>
<property name="ireport.x" value="0"/> <property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/> <property name="ireport.y" value="0"/>
@ -95,20 +95,13 @@ ORDER BY VT.NUMSECUENCIA, TO_NUMBER(DD.ASIENTO)]]>
<band splitType="Stretch"/> <band splitType="Stretch"/>
</background> </background>
<title> <title>
<band height="85" splitType="Stretch"> <band height="84" splitType="Stretch">
<rectangle> <rectangle>
<reportElement uuid="8f226d21-ccdb-41b4-a01d-fb0712f0b4d3" x="0" y="0" width="555" height="30"/> <reportElement uuid="8f226d21-ccdb-41b4-a01d-fb0712f0b4d3" x="0" y="0" width="555" height="30"/>
</rectangle> </rectangle>
<rectangle> <rectangle>
<reportElement uuid="b6aa9717-79c4-4f13-91df-9b0255003a16" x="0" y="40" width="555" height="39"/> <reportElement uuid="b6aa9717-79c4-4f13-91df-9b0255003a16" x="0" y="40" width="555" height="39"/>
</rectangle> </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> <textField>
<reportElement uuid="eb300dc6-1610-409d-8589-72b1539f86d3" x="77" y="0" width="478" height="15"/> <reportElement uuid="eb300dc6-1610-409d-8589-72b1539f86d3" x="77" y="0" width="478" height="15"/>
<textElement> <textElement>
@ -116,20 +109,20 @@ ORDER BY VT.NUMSECUENCIA, TO_NUMBER(DD.ASIENTO)]]>
</textElement> </textElement>
<textFieldExpression><![CDATA[$P{NOME_RELATORIO}]]></textFieldExpression> <textFieldExpression><![CDATA[$P{NOME_RELATORIO}]]></textFieldExpression>
</textField> </textField>
<staticText> <textField>
<reportElement uuid="b76b0e17-99b2-4681-8f60-b5bd5512e897" x="12" y="15" width="65" height="15"/> <reportElement uuid="a125ac5c-e00c-4ac5-bc03-317c514f1ad8" x="12" y="15" width="65" height="15"/>
<textElement> <textElement markup="none">
<font size="11" isBold="true"/> <font size="11" isBold="true"/>
</textElement> </textElement>
<text><![CDATA[Serviço: ]]></text> <textFieldExpression><![CDATA[$R{cabecalho.servico}]]></textFieldExpression>
</staticText> </textField>
<staticText> <textField>
<reportElement uuid="bd889fb9-30d9-4023-b811-7f55e3213705" x="244" y="15" width="65" height="15"/> <reportElement uuid="88bb80e0-40a4-490c-914a-01a41178168b" x="244" y="15" width="65" height="15"/>
<textElement> <textElement markup="none">
<font size="11" isBold="true"/> <font size="11" isBold="true"/>
</textElement> </textElement>
<text><![CDATA[Data:]]></text> <textFieldExpression><![CDATA[$R{cabecalho.data}]]></textFieldExpression>
</staticText> </textField>
<textField> <textField>
<reportElement uuid="a3d3c093-a9f4-4b32-823f-b4f548e46c2f" x="77" y="15" width="167" height="15"/> <reportElement uuid="a3d3c093-a9f4-4b32-823f-b4f548e46c2f" x="77" y="15" width="167" height="15"/>
<textElement> <textElement>
@ -137,55 +130,55 @@ ORDER BY VT.NUMSECUENCIA, TO_NUMBER(DD.ASIENTO)]]>
</textElement> </textElement>
<textFieldExpression><![CDATA[$P{CORRIDA_ID}]]></textFieldExpression> <textFieldExpression><![CDATA[$P{CORRIDA_ID}]]></textFieldExpression>
</textField> </textField>
<staticText> <textField>
<reportElement uuid="021e9662-43c5-4054-a0d2-3fc8f6003111" x="12" y="40" width="78" height="11"/> <reportElement uuid="995111bb-4726-421b-a538-db8b53b3f206" x="12" y="40" width="78" height="11"/>
<textElement> <textElement markup="none">
<font size="8"/> <font size="8"/>
</textElement> </textElement>
<text><![CDATA[Total Arrecadado:]]></text> <textFieldExpression><![CDATA[$R{sumario.totalArrecadado}]]></textFieldExpression>
</staticText> </textField>
<staticText> <textField>
<reportElement uuid="062b6b12-00e3-4389-8359-bf59b8879b4d" x="12" y="51" width="78" height="11"/> <reportElement uuid="3a0c6793-e57f-44c7-8588-1692055bf62a" x="12" y="51" width="78" height="11"/>
<textElement> <textElement markup="none">
<font size="8"/> <font size="8"/>
</textElement> </textElement>
<text><![CDATA[Arrecadado/KM:]]></text> <textFieldExpression><![CDATA[$R{sumario.arrecadadoKm}]]></textFieldExpression>
</staticText> </textField>
<staticText> <textField>
<reportElement uuid="f2b94d48-f3b5-4781-ac11-ff28a41e0d90" x="197" y="40" width="105" height="11"/> <reportElement uuid="a0ec9db5-a7be-4407-b257-e49dd7fe6811" x="197" y="40" width="105" height="11"/>
<textElement> <textElement markup="none">
<font size="8"/> <font size="8"/>
</textElement> </textElement>
<text><![CDATA[Ocupação:]]></text> <textFieldExpression><![CDATA[$R{sumario.ocupacao}]]></textFieldExpression>
</staticText> </textField>
<staticText> <textField>
<reportElement uuid="58deb635-5e71-4614-b71e-d81d5dad85f0" x="197" y="51" width="105" height="11"/> <reportElement uuid="0325af45-b23b-45ba-a8c6-dea75a36bb75" x="197" y="51" width="105" height="11"/>
<textElement> <textElement markup="none">
<font size="8"/> <font size="8"/>
</textElement> </textElement>
<text><![CDATA[Ocupação com Arrecação:]]></text> <textFieldExpression><![CDATA[$R{sumario.ocupacaoComArrecadacao}]]></textFieldExpression>
</staticText> </textField>
<staticText> <textField>
<reportElement uuid="eec1daa6-74c5-49bf-855f-602d5230dfa1" x="12" y="63" width="78" height="11"/> <reportElement uuid="bec7dafe-b775-495d-8233-301b351597ac" x="12" y="63" width="78" height="11"/>
<textElement> <textElement markup="none">
<font size="8"/> <font size="8"/>
</textElement> </textElement>
<text><![CDATA[Nominal/KM:]]></text> <textFieldExpression><![CDATA[$R{sumario.nominalKm}]]></textFieldExpression>
</staticText> </textField>
<staticText> <textField>
<reportElement uuid="ccaffa74-0602-4168-b191-ba02c523221f" x="197" y="63" width="105" height="11"/> <reportElement uuid="fcaa51c2-2057-4aa4-bb84-adae3ef5c34e" x="197" y="63" width="105" height="11"/>
<textElement> <textElement markup="none">
<font size="8"/> <font size="8"/>
</textElement> </textElement>
<text><![CDATA[Ocupação sem Arrecação:]]></text> <textFieldExpression><![CDATA[$R{sumario.ocupacaoSemArrecadacao}]]></textFieldExpression>
</staticText> </textField>
<staticText> <textField>
<reportElement uuid="12cf983e-3909-4cf6-94d8-dfc008edc47d" x="382" y="40" width="78" height="11"/> <reportElement uuid="5cc7b439-0a60-4581-a67c-83519a4fd977" x="382" y="40" width="78" height="11"/>
<textElement> <textElement markup="none">
<font size="8"/> <font size="8"/>
</textElement> </textElement>
<text><![CDATA[Total Nominal:]]></text> <textFieldExpression><![CDATA[$R{sumario.totalNominal}]]></textFieldExpression>
</staticText> </textField>
<line> <line>
<reportElement uuid="5b56b7a4-1abd-43cc-8071-e949d5575a45" x="185" y="40" width="1" height="39" forecolor="#CCCCCC"/> <reportElement uuid="5b56b7a4-1abd-43cc-8071-e949d5575a45" x="185" y="40" width="1" height="39" forecolor="#CCCCCC"/>
</line> </line>
@ -193,50 +186,50 @@ ORDER BY VT.NUMSECUENCIA, TO_NUMBER(DD.ASIENTO)]]>
<reportElement uuid="98b93926-7900-4445-bbe6-024e456fd45e" x="370" y="40" width="1" height="39" forecolor="#CCCCCC"/> <reportElement uuid="98b93926-7900-4445-bbe6-024e456fd45e" x="370" y="40" width="1" height="39" forecolor="#CCCCCC"/>
</line> </line>
<textField> <textField>
<reportElement uuid="bdfd7f9e-e50e-4a8b-bba4-2fc8a909f38b" x="90" y="63" width="78" height="11"/> <reportElement uuid="bdfd7f9e-e50e-4a8b-bba4-2fc8a909f38b" x="90" y="63" width="85" height="11"/>
<textElement> <textElement textAlignment="Right">
<font size="8"/> <font size="8"/>
</textElement> </textElement>
<textFieldExpression><![CDATA[$P{P_NOMINAL_KM}]]></textFieldExpression> <textFieldExpression><![CDATA[$P{P_NOMINAL_KM}]]></textFieldExpression>
</textField> </textField>
<textField> <textField>
<reportElement uuid="7eb2d8d3-4a3f-40cd-8117-8e53ab128f34" x="90" y="40" width="96" height="11"/> <reportElement uuid="7eb2d8d3-4a3f-40cd-8117-8e53ab128f34" x="90" y="40" width="85" height="11"/>
<textElement> <textElement textAlignment="Right">
<font size="8"/> <font size="8"/>
</textElement> </textElement>
<textFieldExpression><![CDATA[$P{P_TOTAL_ARRECADADO}]]></textFieldExpression> <textFieldExpression><![CDATA[$P{P_TOTAL_ARRECADADO}]]></textFieldExpression>
</textField> </textField>
<textField> <textField>
<reportElement uuid="64600377-6028-4c56-b0f1-3acf6ceeb708" x="90" y="51" width="95" height="11"/> <reportElement uuid="64600377-6028-4c56-b0f1-3acf6ceeb708" x="90" y="51" width="85" height="11"/>
<textElement> <textElement textAlignment="Right">
<font size="8"/> <font size="8"/>
</textElement> </textElement>
<textFieldExpression><![CDATA[$P{P_ARRECADO_KM}]]></textFieldExpression> <textFieldExpression><![CDATA[$P{P_ARRECADO_KM}]]></textFieldExpression>
</textField> </textField>
<textField> <textField>
<reportElement uuid="6b68d2b4-0fa0-41a4-bdf5-0eaccb7d1f59" x="302" y="40" width="100" height="11"/> <reportElement uuid="6b68d2b4-0fa0-41a4-bdf5-0eaccb7d1f59" x="302" y="40" width="58" height="11"/>
<textElement> <textElement textAlignment="Right">
<font size="8"/> <font size="8"/>
</textElement> </textElement>
<textFieldExpression><![CDATA[$P{P_OCUPACAO}]]></textFieldExpression> <textFieldExpression><![CDATA[$P{P_OCUPACAO}]]></textFieldExpression>
</textField> </textField>
<textField> <textField>
<reportElement uuid="66317ebd-e503-420c-8886-8385b782770d" x="302" y="51" width="69" height="11"/> <reportElement uuid="66317ebd-e503-420c-8886-8385b782770d" x="302" y="51" width="58" height="11"/>
<textElement> <textElement textAlignment="Right">
<font size="8"/> <font size="8"/>
</textElement> </textElement>
<textFieldExpression><![CDATA[$P{P_OCUPACAO_ARRECADACAO}]]></textFieldExpression> <textFieldExpression><![CDATA[$P{P_OCUPACAO_ARRECADACAO}]]></textFieldExpression>
</textField> </textField>
<textField> <textField>
<reportElement uuid="a6ff7221-60b5-4d08-b7e8-7b10db0b97a6" x="302" y="63" width="68" height="11"/> <reportElement uuid="a6ff7221-60b5-4d08-b7e8-7b10db0b97a6" x="302" y="63" width="58" height="11"/>
<textElement> <textElement textAlignment="Right">
<font size="8"/> <font size="8"/>
</textElement> </textElement>
<textFieldExpression><![CDATA[$P{P_OCUPACAO_S_ARRECADACAO}]]></textFieldExpression> <textFieldExpression><![CDATA[$P{P_OCUPACAO_S_ARRECADACAO}]]></textFieldExpression>
</textField> </textField>
<textField> <textField>
<reportElement uuid="9eebfdd7-504b-4e98-8893-63bdb8c02b54" x="468" y="40" width="87" height="11"/> <reportElement uuid="9eebfdd7-504b-4e98-8893-63bdb8c02b54" x="468" y="40" width="74" height="11"/>
<textElement> <textElement textAlignment="Right">
<font size="8"/> <font size="8"/>
</textElement> </textElement>
<textFieldExpression><![CDATA[$P{P_TOTAL_NOMINAL}]]></textFieldExpression> <textFieldExpression><![CDATA[$P{P_TOTAL_NOMINAL}]]></textFieldExpression>
@ -246,12 +239,19 @@ ORDER BY VT.NUMSECUENCIA, TO_NUMBER(DD.ASIENTO)]]>
<textElement/> <textElement/>
<textFieldExpression><![CDATA[$P{DATA}]]></textFieldExpression> <textFieldExpression><![CDATA[$P{DATA}]]></textFieldExpression>
</textField> </textField>
<textField>
<reportElement uuid="11a895de-bf79-45dc-8d47-ea6ef8bf562c" x="12" y="0" width="65" height="15"/>
<textElement>
<font size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{cabecalho.relatorio}]]></textFieldExpression>
</textField>
</band> </band>
</title> </title>
<summary> <summary>
<band height="63" splitType="Stretch"> <band height="47">
<crosstab> <crosstab>
<reportElement uuid="eff55ca1-3935-4726-82a1-4a15e4518714" x="0" y="0" width="555" height="63"/> <reportElement uuid="eff55ca1-3935-4726-82a1-4a15e4518714" x="0" y="0" width="555" height="47"/>
<rowGroup name="ASIENTO" width="70"> <rowGroup name="ASIENTO" width="70">
<bucket class="java.math.BigDecimal"> <bucket class="java.math.BigDecimal">
<bucketExpression><![CDATA[$F{ASIENTO}]]></bucketExpression> <bucketExpression><![CDATA[$F{ASIENTO}]]></bucketExpression>
@ -385,4 +385,15 @@ ORDER BY VT.NUMSECUENCIA, TO_NUMBER(DD.ASIENTO)]]>
</crosstab> </crosstab>
</band> </band>
</summary> </summary>
<noData>
<band height="50">
<textField>
<reportElement uuid="4a218426-e82c-4eed-9f30-eb9430eef10b" x="12" y="16" width="530" height="20"/>
<textElement markup="none">
<font size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{msg.noData}]]></textFieldExpression>
</textField>
</band>
</noData>
</jasperReport> </jasperReport>

View File

@ -20,6 +20,6 @@ public interface IParametros {
* @param connection * @param connection
* @throws Exception * @throws Exception
*/ */
void initParametros(Map<String, Object> parametros, Connection connection) throws Exception; void processaParametros(Map<String, Object> parametros, Connection connection) throws Exception;
} }

View File

@ -19,5 +19,5 @@ public interface IRenderRelatorio {
*/ */
public byte[] getConteudo(SaidaRelatorio saida) throws Exception; public byte[] getConteudo(SaidaRelatorio saida) throws Exception;
} }

View File

@ -19,13 +19,13 @@ import com.rjconsultores.ventaboletos.relatorios.parametros.*;
*/ */
public enum Relatorio { public enum Relatorio {
RELATORIO_APROVEITAMENTO(1, "RelatorioAproveitamento.jasper", "Relatório de Aproveitamento",new RendimentoParamsImpl(), null), RELATORIO_APROVEITAMENTO(1, "RelatorioAproveitamento", "Relatório de Aproveitamento",new RendimentoParamsImpl(), null),
RELATORIO_SERVICOS(2, "Servicos.jasper", "Relatório de Serviços", null, new Vendas2CustomDS()), RELATORIO_SERVICOS(2, "Servicosr", "Relatório de Serviços", null, new Vendas2CustomDS()),
RELATORIO_EXEMPLO(3, "ExemploFoo.jrxml", "Relatório Foo", null, null); RELATORIO_EXEMPLO(3, "ExemploFoo", "Relatório Foo", null, null);
private int codigo; private int codigo;
private String template;
private String nome; private String nome;
private String descricao;
protected IDataSource datasource; protected IDataSource datasource;
private IParametros parametros; private IParametros parametros;
@ -41,9 +41,9 @@ public enum Relatorio {
* @param datasource * @param datasource
* Custom Data Source do relátorio, só deve ser informado caso o relátorio não possua acesso direto ao banco * 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) { private Relatorio(int codigo, String nome, String descricao, IParametros parametros, IDataSource datasource) {
this.codigo = codigo; this.codigo = codigo;
this.setTemplate(template); this.setDescricao(descricao);
this.setNome(nome); this.setNome(nome);
this.datasource = datasource; this.datasource = datasource;
this.parametros = parametros; this.parametros = parametros;
@ -63,13 +63,6 @@ public enum Relatorio {
} }
} }
public String getTemplate() {
return template;
}
public void setTemplate(String template) {
this.template = template;
}
public String getNome() { public String getNome() {
return nome; return nome;
@ -94,4 +87,12 @@ public enum Relatorio {
public void setParametros(IParametros parametros) { public void setParametros(IParametros parametros) {
this.parametros = parametros; this.parametros = parametros;
} }
public String getDescricao() {
return descricao;
}
public void setDescricao(String descricao) {
this.descricao = descricao;
}
} }

View File

@ -3,28 +3,30 @@
*/ */
package com.rjconsultores.ventaboletos.web.utilerias; package com.rjconsultores.ventaboletos.web.utilerias;
import java.text.DecimalFormat; import java.text.NumberFormat;
import java.util.Currency; import java.util.Locale;
/** /**
* @author Bruno H. G. Gouvêa <bruno@rjconsultores.com.br> * @author Bruno H. G. Gouvêa <bruno@rjconsultores.com.br>
* *
*/ */
public final class CurrencyUtil { public final class CurrencyUtil {
public static String getCurrencyStrFromStr(String value, Locale locale) {
NumberFormat moedaFormat =
NumberFormat.getCurrencyInstance(locale);
return moedaFormat.format(Double.parseDouble(value));
}
public static String getPercentStrFromStr(String value, Locale locale) {
public static String getCurrencyStrFromStr(String value){
NumberFormat percentFormat = NumberFormat.getPercentInstance(locale);
percentFormat.setMinimumFractionDigits(2);
double doubleValue = Double.parseDouble(value);
Currency currency = Currency.getInstance("BRL");
DecimalFormat formato = new DecimalFormat(currency.getSymbol() + "#,##0.00");
return formato.format(doubleValue);
return percentFormat.format(Double.parseDouble(value));
} }
} }

View File

@ -56,10 +56,13 @@ MSG.necesita.formaPago = Forma de Pagamento Obrigatória
lb.id = ID lb.id = ID
lb.dec = Descrição lb.dec = Descrição
lb.Equivalencia = Equivalencia lb.Equivalencia = Equivalencia
lb.btnExecutarRelatorio = Executar Relatório
lb.btnSalvarRelatorio = Salvar Relatório # Relatório
lb.btnSalvarRelatorioPdf = Salvar Relatório em PDF relatorio.lb.btnExecutarRelatorio = Executar Relatório
lb.btnSalvarRelatorioXls = Salvar Relatório em XLS relatorio.lb.btnSalvarRelatorio = Salvar Relatório
relatorio.lb.btnSalvarRelatorioPdf = Salvar Relatório em PDF
relatorio.lb.btnSalvarRelatorioXls = Salvar Relatório em XLS
relatorio.parametro.msgNoData = Não foi possivel obter dados com os parâmetros informados.
# tooltip botões # tooltip botões

View File

@ -11,10 +11,10 @@
<div id="divResultadoRelatorio"> <div id="divResultadoRelatorio">
<toolbar> <toolbar>
<toolbarbutton label="Salvar PDF" id="btnSalvarPDF" image="/gui/img/pdf.png" width="95px" <toolbarbutton label="Salvar PDF" id="btnSalvarPDF" image="/gui/img/pdf.png" width="95px"
tooltiptext="${c:l('lb.btnSalvarRelatorioPdf')}" /> tooltiptext="${c:l('relatorio.lb.btnSalvarRelatorioPdf')}" />
<separator orient="vertical" /> <separator orient="vertical" />
<toolbarbutton label="Salvar XLS" id="btnSalvarXLS" image="/gui/img/excel.png" width="95px" <toolbarbutton label="Salvar XLS" id="btnSalvarXLS" image="/gui/img/excel.png" width="95px"
tooltiptext="${c:l('lb.btnSalvarRelatorioXls')}" /> tooltiptext="${c:l('relatorio.lb.btnSalvarRelatorioXls')}" />
<separator orient="vertical" /> <separator orient="vertical" />

View File

@ -15,17 +15,17 @@
<rows> <rows>
<row> <row>
<label value="${c:l('relatorioAproveitamentoController.lbServico.value')}"/> <label value="${c:l('relatorioAproveitamentoController.lbServico.value')}"/>
<textbox id="txtCorridaId" width="90%" use="com.rjconsultores.ventaboletos.web.utilerias.MyTextbox" constraint="no empty"/> <textbox id="txtCorridaId" width="90%" use="com.rjconsultores.ventaboletos.web.utilerias.MyTextbox" constraint="no empty" maxlength="7"/>
</row> </row>
<row> <row>
<label value="${c:l('relatorioAproveitamentoController.lbFecCorrida.value')}"/> <label value="${c:l('relatorioAproveitamentoController.lbFecCorrida.value')}"/>
<datebox id="fecCorrida" width="90%" format="dd/MM/yyyy" lenient="false" constraint="no empty"/> <datebox id="fecCorrida" width="90%" format="dd/MM/yyyy" lenient="false" constraint="no empty" maxlength="10"/>
</row> </row>
</rows> </rows>
</grid> </grid>
<toolbar> <toolbar>
<button id="btnExecutarRelatorio" image="/gui/img/find.png" <button id="btnExecutarRelatorio" image="/gui/img/find.png"
label="${c:l('lb.btnExecutarRelatorio')}"/> label="${c:l('relatorio.lb.btnExecutarRelatorio')}"/>
</toolbar> </toolbar>
</window> </window>
</zk> </zk>