diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioTabelaPreco.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioTabelaPreco.java index a973cf8c4..d6425dbbf 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioTabelaPreco.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioTabelaPreco.java @@ -1,9 +1,8 @@ package com.rjconsultores.ventaboletos.relatorios.impl; import java.awt.image.BufferedImage; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.io.IOException; import java.sql.Connection; import java.sql.ResultSet; import java.util.HashMap; @@ -11,6 +10,7 @@ import java.util.Map; import javax.imageio.ImageIO; +import com.rjconsultores.ventaboletos.entidad.Marca; import com.rjconsultores.ventaboletos.relatorios.utilitarios.ArrayDataSource; import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; import com.rjconsultores.ventaboletos.service.SegVKMService; @@ -32,27 +32,25 @@ public class RelatorioTabelaPreco extends Relatorio { Connection conexao = this.relatorio.getConexao(); NamedParameterStatement stmt = new NamedParameterStatement(conexao, getSql()); ResultSet rset = stmt.executeQuery(); - - BufferedImage artespLogo= - ImageIO.read(getClass().getResource(this.relatorio.getBaseDir()+"/imagens/artesp.png")); - parametros.put("artesp_logo", artespLogo); + + setReportImages(); String series = RelatorioTabelaPreco.this.segVKMService.seriePorEmpresa((Integer) parametros.get("EMPRESA_ID")); while (rset.next()) { Map dataResult = new HashMap(); - + if (isLayoutArtesp) { dataResult.put("seguroOpcional", RelatorioTabelaPreco.this.segVKMService.buscarSeguroPorKm(rset.getLong("kmReal"), - series, (Integer) parametros.get("ORGAO_CONCEDENTE_ID"))); + series, (Integer) parametros.get("ORGAO_CONCEDENTE_ID"))); } - + dataResult.put("origem", rset.getString("origem")); dataResult.put("destino", rset.getString("destino")); dataResult.put("tarifa", rset.getBigDecimal("tarifa")); dataResult.put("pedagio", rset.getBigDecimal("pedagio")); dataResult.put("taxaEmbarque", rset.getBigDecimal("taxaEmbarque")); - + dataResult.put("outros", rset.getBigDecimal("outros")); dataResult.put("tipoClasse", rset.getString("tipoClasse")); dataResult.put("empresa", rset.getString("empresa")); @@ -73,6 +71,19 @@ public class RelatorioTabelaPreco extends Relatorio { }); } + protected void setReportImages() throws IOException { + BufferedImage empresaLogo = null; + Marca marca = (Marca) parametros.get("MARCA"); + if (marca != null && marca.getLogotipomarca() != null) { + empresaLogo = ImageIO.read(new ByteArrayInputStream(marca.getLogotipomarca())); + } + BufferedImage artespLogo = ImageIO.read(getClass().getResource(getBaseDir() + "/imagens/artesp.png")); + + parametros.put("artesp_logo", artespLogo); + parametros.put("empresa_logo", empresaLogo); + + } + @Override protected void processaParametros() throws Exception { } diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioTabelaPrecoArtesp.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioTabelaPrecoArtesp.jasper index 1af1d1acf..483ba40ec 100644 Binary files a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioTabelaPrecoArtesp.jasper and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioTabelaPrecoArtesp.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioTabelaPrecoArtesp.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioTabelaPrecoArtesp.jrxml index 4a056c25c..9265ecbd5 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioTabelaPrecoArtesp.jrxml +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioTabelaPrecoArtesp.jrxml @@ -1,10 +1,10 @@ - + - + @@ -35,22 +35,28 @@ - <band height="36" splitType="Stretch"> + <band height="47" splitType="Stretch"> <textField> - <reportElement uuid="5d83d8a8-01aa-4022-9583-6808e65d2ec8" mode="Opaque" x="0" y="0" width="321" height="33" backcolor="#FFFF66"/> + <reportElement uuid="5d83d8a8-01aa-4022-9583-6808e65d2ec8" mode="Opaque" x="0" y="0" width="321" height="47" backcolor="#FFFF66"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font fontName="SansSerif" size="20" isBold="true"/> </textElement> <textFieldExpression><![CDATA[$F{origem}]]></textFieldExpression> </textField> <textField> - <reportElement uuid="2c5b01a1-51db-478a-a307-83c9df5cea6e" x="321" y="0" width="539" height="33"/> - <textElement verticalAlignment="Middle"> + <reportElement uuid="2c5b01a1-51db-478a-a307-83c9df5cea6e" x="363" y="0" width="497" height="47"> + <printWhenExpression><![CDATA[($P{empresa_logo})==null]]></printWhenExpression> + </reportElement> + <textElement textAlignment="Center" verticalAlignment="Middle"> <font fontName="SansSerif" size="14" isBold="true"/> <paragraph leftIndent="4"/> </textElement> <textFieldExpression><![CDATA[$F{empresa}]]></textFieldExpression> </textField> + <image onErrorType="Blank"> + <reportElement uuid="71c314ae-5bbd-41d2-a548-b80de625c9b0" x="363" y="0" width="497" height="47"/> + <imageExpression><![CDATA[$P{empresa_logo}]]></imageExpression> + </image> </band> diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioTabelaPrecoController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioTabelaPrecoController.java index 764b89a75..91c1980e9 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioTabelaPrecoController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioTabelaPrecoController.java @@ -1,6 +1,5 @@ package com.rjconsultores.ventaboletos.web.gui.controladores.relatorios; -import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -18,7 +17,6 @@ import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.event.Event; import org.zkoss.zul.Checkbox; import org.zkoss.zul.Comboitem; -import org.zkoss.zul.ListModelArray; import org.zkoss.zul.ListModelList; import org.zkoss.zul.Paging; @@ -30,10 +28,10 @@ import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa; import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioTabelaPreco; import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; import com.rjconsultores.ventaboletos.service.EmpresaService; +import com.rjconsultores.ventaboletos.service.MarcaService; import com.rjconsultores.ventaboletos.service.OrgaoConcedenteService; import com.rjconsultores.ventaboletos.service.ParadaService; import com.rjconsultores.ventaboletos.service.SegVKMService; -import com.rjconsultores.ventaboletos.service.TramoService; import com.rjconsultores.ventaboletos.service.VigenciaTarifaService; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar; @@ -77,6 +75,8 @@ public class RelatorioTabelaPrecoController extends MyGenericForwardComposer { private DataSource dataSourceRead; @Autowired private SegVKMService segVKMService; + @Autowired + private MarcaService marcaService; private List destinoList; private List lsVigencia; @@ -118,6 +118,7 @@ public class RelatorioTabelaPrecoController extends MyGenericForwardComposer { Empresa empresa = (Empresa) itemEmpresa.getValue(); parametros.put("EMPRESA_ID", empresa.getEmpresaId()); parametros.put("EMPRESA", empresa.getNombempresa()); + parametros.put("MARCA",marcaService.buscarMarcaPorEmpresa(Arrays.asList(empresa)).get(0)); } if (cmbOrgaoConcedente.getSelectedItem() != null) {