issue #8301 - Logo Empresa

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@64723 d1611594-4594-4d17-8e1d-87c2c4800839
master
edgar 2017-01-09 18:27:09 +00:00
parent 238af96266
commit 9d3663627d
4 changed files with 38 additions and 20 deletions

View File

@ -1,9 +1,8 @@
package com.rjconsultores.ventaboletos.relatorios.impl; package com.rjconsultores.ventaboletos.relatorios.impl;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.ByteArrayInputStream;
import java.io.FileInputStream; import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection; import java.sql.Connection;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.HashMap; import java.util.HashMap;
@ -11,6 +10,7 @@ import java.util.Map;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import com.rjconsultores.ventaboletos.entidad.Marca;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.ArrayDataSource; import com.rjconsultores.ventaboletos.relatorios.utilitarios.ArrayDataSource;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
import com.rjconsultores.ventaboletos.service.SegVKMService; import com.rjconsultores.ventaboletos.service.SegVKMService;
@ -33,9 +33,7 @@ public class RelatorioTabelaPreco extends Relatorio {
NamedParameterStatement stmt = new NamedParameterStatement(conexao, getSql()); NamedParameterStatement stmt = new NamedParameterStatement(conexao, getSql());
ResultSet rset = stmt.executeQuery(); ResultSet rset = stmt.executeQuery();
BufferedImage artespLogo= setReportImages();
ImageIO.read(getClass().getResource(this.relatorio.getBaseDir()+"/imagens/artesp.png"));
parametros.put("artesp_logo", artespLogo);
String series = RelatorioTabelaPreco.this.segVKMService.seriePorEmpresa((Integer) parametros.get("EMPRESA_ID")); String series = RelatorioTabelaPreco.this.segVKMService.seriePorEmpresa((Integer) parametros.get("EMPRESA_ID"));
while (rset.next()) { while (rset.next()) {
@ -44,7 +42,7 @@ public class RelatorioTabelaPreco extends Relatorio {
if (isLayoutArtesp) { if (isLayoutArtesp) {
dataResult.put("seguroOpcional", dataResult.put("seguroOpcional",
RelatorioTabelaPreco.this.segVKMService.buscarSeguroPorKm(rset.getLong("kmReal"), 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("origem", rset.getString("origem"));
@ -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 @Override
protected void processaParametros() throws Exception { protected void processaParametros() throws Exception {
} }

View File

@ -1,10 +1,10 @@
<?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="RelatorioTabelaPreco" pageWidth="900" pageHeight="842" orientation="Landscape" columnWidth="860" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="5edc9f7a-8634-485f-96f7-c65a462aa868"> <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="RelatorioTabelaPreco" pageWidth="900" pageHeight="842" orientation="Landscape" columnWidth="860" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="5edc9f7a-8634-485f-96f7-c65a462aa868">
<property name="ireport.zoom" value="1.000000000000004"/> <property name="ireport.zoom" value="1.000000000000004"/>
<property name="ireport.x" value="38"/> <property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/> <property name="ireport.y" value="0"/>
<parameter name="BASE_DIR" class="java.lang.String"/>
<parameter name="artesp_logo" class="java.lang.Object"/> <parameter name="artesp_logo" class="java.lang.Object"/>
<parameter name="empresa_logo" class="java.lang.Object"/>
<field name="origem" class="java.lang.String"/> <field name="origem" class="java.lang.String"/>
<field name="destino" class="java.lang.String"/> <field name="destino" class="java.lang.String"/>
<field name="tarifa" class="java.math.BigDecimal"/> <field name="tarifa" class="java.math.BigDecimal"/>
@ -35,22 +35,28 @@
<band splitType="Stretch"/> <band splitType="Stretch"/>
</background> </background>
<title> <title>
<band height="36" splitType="Stretch"> <band height="47" splitType="Stretch">
<textField> <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"> <textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="SansSerif" size="20" isBold="true"/> <font fontName="SansSerif" size="20" isBold="true"/>
</textElement> </textElement>
<textFieldExpression><![CDATA[$F{origem}]]></textFieldExpression> <textFieldExpression><![CDATA[$F{origem}]]></textFieldExpression>
</textField> </textField>
<textField> <textField>
<reportElement uuid="2c5b01a1-51db-478a-a307-83c9df5cea6e" x="321" y="0" width="539" height="33"/> <reportElement uuid="2c5b01a1-51db-478a-a307-83c9df5cea6e" x="363" y="0" width="497" height="47">
<textElement verticalAlignment="Middle"> <printWhenExpression><![CDATA[($P{empresa_logo})==null]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="SansSerif" size="14" isBold="true"/> <font fontName="SansSerif" size="14" isBold="true"/>
<paragraph leftIndent="4"/> <paragraph leftIndent="4"/>
</textElement> </textElement>
<textFieldExpression><![CDATA[$F{empresa}]]></textFieldExpression> <textFieldExpression><![CDATA[$F{empresa}]]></textFieldExpression>
</textField> </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> </band>
</title> </title>
<pageHeader> <pageHeader>

View File

@ -1,6 +1,5 @@
package com.rjconsultores.ventaboletos.web.gui.controladores.relatorios; package com.rjconsultores.ventaboletos.web.gui.controladores.relatorios;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
@ -18,7 +17,6 @@ import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Event;
import org.zkoss.zul.Checkbox; import org.zkoss.zul.Checkbox;
import org.zkoss.zul.Comboitem; import org.zkoss.zul.Comboitem;
import org.zkoss.zul.ListModelArray;
import org.zkoss.zul.ListModelList; import org.zkoss.zul.ListModelList;
import org.zkoss.zul.Paging; 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.impl.RelatorioTabelaPreco;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
import com.rjconsultores.ventaboletos.service.EmpresaService; import com.rjconsultores.ventaboletos.service.EmpresaService;
import com.rjconsultores.ventaboletos.service.MarcaService;
import com.rjconsultores.ventaboletos.service.OrgaoConcedenteService; import com.rjconsultores.ventaboletos.service.OrgaoConcedenteService;
import com.rjconsultores.ventaboletos.service.ParadaService; import com.rjconsultores.ventaboletos.service.ParadaService;
import com.rjconsultores.ventaboletos.service.SegVKMService; import com.rjconsultores.ventaboletos.service.SegVKMService;
import com.rjconsultores.ventaboletos.service.TramoService;
import com.rjconsultores.ventaboletos.service.VigenciaTarifaService; import com.rjconsultores.ventaboletos.service.VigenciaTarifaService;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar; import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar;
@ -77,6 +75,8 @@ public class RelatorioTabelaPrecoController extends MyGenericForwardComposer {
private DataSource dataSourceRead; private DataSource dataSourceRead;
@Autowired @Autowired
private SegVKMService segVKMService; private SegVKMService segVKMService;
@Autowired
private MarcaService marcaService;
private List<Parada> destinoList; private List<Parada> destinoList;
private List<VigenciaTarifa> lsVigencia; private List<VigenciaTarifa> lsVigencia;
@ -118,6 +118,7 @@ public class RelatorioTabelaPrecoController extends MyGenericForwardComposer {
Empresa empresa = (Empresa) itemEmpresa.getValue(); Empresa empresa = (Empresa) itemEmpresa.getValue();
parametros.put("EMPRESA_ID", empresa.getEmpresaId()); parametros.put("EMPRESA_ID", empresa.getEmpresaId());
parametros.put("EMPRESA", empresa.getNombempresa()); parametros.put("EMPRESA", empresa.getNombempresa());
parametros.put("MARCA",marcaService.buscarMarcaPorEmpresa(Arrays.asList(empresa)).get(0));
} }
if (cmbOrgaoConcedente.getSelectedItem() != null) { if (cmbOrgaoConcedente.getSelectedItem() != null) {