igor.rodrigo 2016-04-20 14:33:04 +00:00
parent e0d185df89
commit 7ee55105e5
10 changed files with 467 additions and 0 deletions

View File

@ -0,0 +1,115 @@
package com.rjconsultores.ventaboletos.relatorios.impl;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.imageio.ImageIO;
import org.slf4j.Logger;
import com.rjconsultores.ventaboletos.dao.hibernate.CajaHibernateDAO;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.ArrayDataSource;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement;
public class RelatorioCarteirinha extends Relatorio {
private static Logger log = org.slf4j.LoggerFactory.getLogger(RelatorioCarteirinha.class);
public RelatorioCarteirinha(Map<String, Object> parametros, Connection conexao) throws Exception {
super(parametros, conexao);
this.setCustomDataSource(new ArrayDataSource(this) {
public void initDados() throws Exception {
Connection conexao = this.relatorio.getConexao();
buscarDadosEmpresa(conexao, this.dados, this.resultSet);
}
});
}
@Override
protected void processaParametros() throws Exception {
}
private void buscarDadosEmpresa(Connection conexao, List<Map<String, Object>> dados, ResultSet resultSet) throws SQLException {
StringBuilder sqlLogoEmpresa = new StringBuilder();
sqlLogoEmpresa.append(" SELECT IE.NUMINSCRICAOESTADUAL, M.LOGOTIPOMARCA, E.LOGRADOURO, M.DESCMARCA, E.BAIRRO, ");
sqlLogoEmpresa.append(" C.NOMBCIUDAD, ES.NOMBESTADO, E.CEP, E.NUMTELEFONO, E.NUMERO, E.CNPJ ");
sqlLogoEmpresa.append(" FROM MARCA M ");
sqlLogoEmpresa.append(" INNER JOIN EMPRESA E ON M.EMPRESA_ID = E.EMPRESA_ID ");
sqlLogoEmpresa.append(" INNER JOIN CIUDAD C ON E.CIUDAD_ID = C.CIUDAD_ID ");
sqlLogoEmpresa.append(" INNER JOIN ESTADO ES ON ES.ESTADO_ID = C.ESTADO_ID ");
sqlLogoEmpresa.append(" INNER JOIN INSCRICAO_ESTADUAL IE ON IE.EMPRESA_ID = E.EMPRESA_ID ");
sqlLogoEmpresa.append(" WHERE M.EMPRESA_ID = :empresaId ");
sqlLogoEmpresa.append(" AND C.ESTADO_ID = IE.ESTADO_ID ");
sqlLogoEmpresa.append(" AND LOGOTIPOMARCA IS NOT NULL ");
NamedParameterStatement stmt = new NamedParameterStatement(conexao, sqlLogoEmpresa.toString());
stmt.setInt("empresaId", Integer.valueOf(parametros.get("EMPRESA_ID").toString()));
ResultSet rset = stmt.executeQuery();
while (rset.next()) {
Map<String, Object> dataResult = new HashMap<String, Object>();
InputStream blob = rset.getBinaryStream("LOGOTIPOMARCA");
BufferedImage image = null;
try {
image = ImageIO.read(blob);
} catch (IOException e) {
log.error("", e);
}
dataResult.put("logomarca", image);
dataResult.put("nomeEmpresa", rset.getString("DESCMARCA"));
dataResult.put("enderecoEmpresa" , construirStringEnderecoCompleto(rset));
dataResult.put("cepTelefoneEmpresa", construirStringCepTelefone(rset));
dataResult.put("cnpjIEstadualEmpresa", contruirStringCnpjIEstadual(rset));
dataResult.put("local", rset.getString("NOMBCIUDAD"));
imprimirQuantidadePorPagina(dados, dataResult);
}
resultSet = rset;
}
private void imprimirQuantidadePorPagina(List<Map<String, Object>> dados, Map<String, Object> dataResult) {
final Integer QUANTIDADE_POR_PAGINA = 8;
for(int i = 0; i < QUANTIDADE_POR_PAGINA; i++){
dados.add(dataResult);
}
}
private String contruirStringCnpjIEstadual(ResultSet rset) throws SQLException {
StringBuilder cnpjIEstadualEmpresa = new StringBuilder();
cnpjIEstadualEmpresa.append("CNPJ ");
cnpjIEstadualEmpresa.append(rset.getString("CNPJ"));
cnpjIEstadualEmpresa.append(" - ");
cnpjIEstadualEmpresa.append("Inscr. Estadual ");
cnpjIEstadualEmpresa.append(rset.getString("NUMINSCRICAOESTADUAL"));
return cnpjIEstadualEmpresa.toString();
}
private String construirStringCepTelefone(ResultSet rset) throws SQLException {
StringBuilder cepTelefoneEmpresa = new StringBuilder();
cepTelefoneEmpresa.append("CEP ");
cepTelefoneEmpresa.append(rset.getString("CEP"));
cepTelefoneEmpresa.append(" - ");
cepTelefoneEmpresa.append("Fone ");
cepTelefoneEmpresa.append(rset.getString("NUMTELEFONO"));
return cepTelefoneEmpresa.toString();
}
private String construirStringEnderecoCompleto(ResultSet rset) throws SQLException {
StringBuilder enderecoCompleto = new StringBuilder();
enderecoCompleto.append(rset.getString("LOGRADOURO"));
enderecoCompleto.append(", ");
enderecoCompleto.append(rset.getString("NUMERO"));
enderecoCompleto.append(" - ");
enderecoCompleto.append(rset.getString("BAIRRO"));
enderecoCompleto.append(" - ");
enderecoCompleto.append(rset.getString("NOMBCIUDAD"));
enderecoCompleto.append(" - ");
enderecoCompleto.append(rset.getString("NOMBESTADO"));
return enderecoCompleto.toString();
}
}

View File

@ -0,0 +1,8 @@
label.titulo=CARTEIRA DE IDENTIFICAÇÃO - PASSE ESCOLAR
label.numero =
label.nome = Nome
label.endereco = Endereço
label.escola = Escola
label.trajeto = Trajeto
label.assinatura = Assinatura
label.de = De

View File

@ -0,0 +1,8 @@
label.titulo=CARTEIRA DE IDENTIFICAÇÃO - PASSE ESCOLAR
label.numero =
label.nome = Nome
label.endereco = Endereço
label.escola = Escola
label.trajeto = Trajeto
label.assinatura = Assinatura
label.de = De

View File

@ -0,0 +1,158 @@
<?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="RelatorioCarteirinha" columnCount="2" printOrder="Horizontal" pageWidth="555" pageHeight="802" columnWidth="277" columnSpacing="1" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="45e60734-3047-4ed1-864d-5c96cbf2a87c">
<property name="ireport.zoom" value="1.2396694214876032"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<style name="style1"/>
<field name="nomeEmpresa" class="java.lang.String"/>
<field name="enderecoEmpresa" class="java.lang.String"/>
<field name="cepTelefoneEmpresa" class="java.lang.String"/>
<field name="cnpjIEstadualEmpresa" class="java.lang.String"/>
<field name="local" class="java.lang.String"/>
<field name="logomarca" class="java.awt.Image"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band splitType="Stretch"/>
</title>
<pageHeader>
<band splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band splitType="Stretch"/>
</columnHeader>
<detail>
<band height="188" splitType="Stretch">
<rectangle>
<reportElement uuid="bc55347b-529d-42a3-be9a-ff3ffcff7c5e" x="5" y="35" width="267" height="148"/>
</rectangle>
<textField>
<reportElement uuid="df8ed424-684c-48a4-8aa3-5ecd916e17b9" x="139" y="39" width="108" height="7"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$F{nomeEmpresa}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="e8992c9f-8d48-44cc-90fa-811f36c50c11" x="139" y="48" width="108" height="7"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$F{enderecoEmpresa}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="394f5c12-2c2c-4163-8bc3-acd6f3bc5d28" x="139" y="56" width="108" height="7"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$F{cepTelefoneEmpresa}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="79715320-72a3-4dc0-aa97-db4093ff03a4" x="139" y="64" width="108" height="7"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$F{cnpjIEstadualEmpresa}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="1b9eb694-5e65-461d-89dd-76725bfe36c7" x="34" y="73" width="211" height="14"/>
<textElement textAlignment="Center" markup="none">
<font size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.titulo}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="7cbd4d0f-3dae-42f9-a4fa-9f9f9491e6f7" x="91" y="119" width="37" height="7"/>
<textElement markup="none">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.trajeto}]]></textFieldExpression>
</textField>
<rectangle>
<reportElement uuid="83734f3b-766a-4763-be16-45b5069c07a4" x="17" y="89" width="61" height="45"/>
</rectangle>
<textField>
<reportElement uuid="4b3cd63f-ddbd-435b-8706-f5a644bc952f" x="91" y="112" width="37" height="7"/>
<textElement markup="none">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.escola}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="8301812f-003b-4eb8-96e8-3a24614bb2b3" x="91" y="105" width="48" height="7"/>
<textElement markup="none">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.endereco}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="9cb7ec2e-f157-4aea-ab7b-949d4407876e" x="91" y="89" width="23" height="8"/>
<textElement markup="none">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.numero}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="db03a582-9ac3-4bd4-8601-b03e61d2d574" x="91" y="97" width="35" height="7"/>
<textElement markup="none">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.nome}]]></textFieldExpression>
</textField>
<image isUsingCache="true" evaluationTime="Auto">
<reportElement uuid="26b05150-ef3c-4858-b212-0bfac5b8acf8" x="17" y="39" width="97" height="32"/>
<imageExpression><![CDATA[$F{logomarca}]]></imageExpression>
</image>
<textField>
<reportElement uuid="03905d16-be95-4402-a96c-94285b306567" x="139" y="148" width="58" height="11"/>
<textElement textAlignment="Center" verticalAlignment="Middle" markup="none">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.assinatura}]]></textFieldExpression>
</textField>
<line>
<reportElement uuid="a6e3aac5-6397-4ff0-981b-3e1b0d434947" x="91" y="147" width="156" height="1"/>
</line>
<textField>
<reportElement uuid="9d29c54f-cd25-4a3d-bf57-376894802d22" x="34" y="159" width="118" height="17"/>
<textElement textAlignment="Right" verticalAlignment="Bottom">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$F{local}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="3748a0d2-52f4-4d70-a615-94aabc419f3f" x="174" y="160" width="19" height="16"/>
<textElement textAlignment="Center" verticalAlignment="Bottom" markup="none">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.de}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="6c415b9e-2080-4767-a59d-197438e3b97c" x="207" y="160" width="19" height="16"/>
<textElement textAlignment="Center" verticalAlignment="Bottom" markup="none">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.de}]]></textFieldExpression>
</textField>
<line>
<reportElement uuid="6bf20d11-5d97-4565-8410-7291317323dc" x="154" y="176" width="17" height="1"/>
</line>
<line>
<reportElement uuid="706ea1ac-43a2-4a2d-a3d1-1fa7c0710b0d" x="190" y="176" width="17" height="1"/>
</line>
<line>
<reportElement uuid="b848dfe9-dc25-48ea-8fdf-b199f540b06e" x="228" y="176" width="17" height="1"/>
</line>
</band>
</detail>
<columnFooter>
<band splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band splitType="Stretch"/>
</pageFooter>
<summary>
<band splitType="Stretch"/>
</summary>
</jasperReport>

View File

@ -0,0 +1,100 @@
package com.rjconsultores.ventaboletos.web.gui.controladores.relatorios;
import java.util.HashMap;
import java.util.List;
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.util.resource.Labels;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zul.Comboitem;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioCarteirinha;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
import com.rjconsultores.ventaboletos.service.ConstanteService;
import com.rjconsultores.ventaboletos.service.EmpresaService;
import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar;
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
@Controller("relatorioCarterinhaController")
@Scope("prototype")
public class RelatorioCarteirinhaController extends MyGenericForwardComposer {
private static final long serialVersionUID = 1L;
private MyComboboxEstandar cmbEmpresa;
private List<Empresa> lsEmpresa;
@Autowired
private EmpresaService empresaService;
@Autowired
private ConstanteService constanteService;
@Autowired
private DataSource dataSourceRead;
@Override
public void doAfterCompose(Component comp) throws Exception {
lsEmpresa = empresaService.obtenerTodos();
super.doAfterCompose(comp);
}
/**
* @throws Exception
*
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
private void executarRelatorio() throws Exception {
Comboitem itemEmpresa = cmbEmpresa.getSelectedItem();
if(itemEmpresa != null){
Relatorio relatorio;
Map<String, Object> parametros = new HashMap<String, Object>();
StringBuilder filtro = new StringBuilder();
filtro.append("Empresa: ");
if (itemEmpresa != null) {
Empresa empresa = (Empresa) itemEmpresa.getValue();
parametros.put("EMPRESA_ID", empresa.getEmpresaId());
filtro.append(empresa.getNombempresa() + ";");
}
relatorio = new RelatorioCarteirinha(parametros, dataSourceRead.getConnection());
Map args = new HashMap();
args.put("relatorio", relatorio);
openWindow("/component/reportView.zul",
Labels.getLabel("carteirinhaController.window.title"), args, MODAL);
}
}
public void onClick$btnExecutarRelatorio(Event ev) throws Exception{
executarRelatorio();
}
private void executarPesquisa() {
}
public void onClick$btnPesquisa(Event ev) {
executarPesquisa();
}
public List<Empresa> getLsEmpresa() {
return lsEmpresa;
}
public void setLsEmpresa(List<Empresa> lsEmpresa) {
this.lsEmpresa = lsEmpresa;
}
public MyComboboxEstandar getCmbEmpresa() {
return cmbEmpresa;
}
public void setCmbEmpresa(MyComboboxEstandar cmbEmpresa) {
this.cmbEmpresa = cmbEmpresa;
}
}

View File

@ -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 ItemMenuCarteirinha extends DefaultItemMenuSistema {
public ItemMenuCarteirinha() {
super("indexController.calteirinha.label");
}
@Override
public String getClaveMenu() {
return "COM.RJCONSULTORES.ADMINISTRACION.GUI.CARTEIRINHA";
}
@Override
public void ejecutar() {
PantallaUtileria.openWindow("/gui/relatorios/filtroCarteirinha.zul",
Labels.getLabel("carteirinhaController.window.title"), getArgs(), desktop);
}
}

View File

@ -6327,6 +6327,14 @@ editarConexionExcepcionRutaController.btnPesquisa.label=Pesquisa
editarConexionExcepcionRutaController.lbRuta.label=Linha editarConexionExcepcionRutaController.lbRuta.label=Linha
editarConexionExcepcionRutaController.rutaId.label=Linha ID editarConexionExcepcionRutaController.rutaId.label=Linha ID
#Carteirinha
indexController.calteirinha.label = Carteirinha
carteirinhaController.window.title = Carteirinha
relatorioCarterinhaController.lbEmpresa.value = Empresa
relatorioCancelamentoVendaCartaoController.quantidadeImprimir.value = Quantidade
relatorio.lb.btnGerarCarteirinha = Gerar carteirinha
editarConexionExcepcionRutaController.rutaId.label=Linha ID
# Importacion Fiscal # Importacion Fiscal
busquedaImportacionFiscalEcfController.window.title=Impressão Fiscal :: ECF busquedaImportacionFiscalEcfController.window.title=Impressão Fiscal :: ECF
busquedaImportacionFiscalEcfCanceladosController.window.title=Impressão Fiscal :: ECF Cancelados busquedaImportacionFiscalEcfCanceladosController.window.title=Impressão Fiscal :: ECF Cancelados

View File

@ -6473,6 +6473,16 @@ editarConexionExcepcionRutaController.btnPesquisa.label=Pesquisa
editarConexionExcepcionRutaController.lbRuta.label=Linha editarConexionExcepcionRutaController.lbRuta.label=Linha
editarConexionExcepcionRutaController.rutaId.label=Linha ID editarConexionExcepcionRutaController.rutaId.label=Linha ID
#Carteirinha
indexController.calteirinha.label = Carteirinha
carteirinhaController.window.title = Carteirinha
relatorioCarterinhaController.lbEmpresa.value = Empresa
relatorioCancelamentoVendaCartaoController.quantidadeImprimir.value = Quantidade
relatorio.lb.btnGerarCarteirinha = Gerar carteirinha
editarConexionExcepcionRutaController.rutaId.label=Linha ID
# Importacion Fiscal # Importacion Fiscal
busquedaImportacionFiscalEcfController.window.title=Impressão Fiscal :: ECF busquedaImportacionFiscalEcfController.window.title=Impressão Fiscal :: ECF
busquedaImportacionFiscalEcfCanceladosController.window.title=Impressão Fiscal :: ECF Cancelados busquedaImportacionFiscalEcfCanceladosController.window.title=Impressão Fiscal :: ECF Cancelados

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<?page contentType="text/html;charset=UTF-8"?>
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="winFiltroCarteirinha"?>
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
<zk xmlns="http://www.zkoss.org/2005/zul">
<window id="winFiltroCarteirinha"
apply="${relatorioCarterinhaController}" contentStyle="overflow:auto"
height="98px" width="350px" border="normal">
<grid fixedLayout="true">
<columns>
<column width="25%" />
<column width="30%" />
</columns>
<rows>
<row spans="1,3">
<label
value="${c:l('relatorioCarterinhaController.lbEmpresa.value')}" />
<combobox id="cmbEmpresa"
buttonVisible="true"
use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar"
model="@{winFiltroCarteirinha$composer.lsEmpresa}"
width="100%"
constraint="no empty" />
</row>
</rows>
</grid>
<toolbar>
<button id="btnExecutarRelatorio" image="/gui/img/find.png"
label="${c:l('relatorio.lb.btnGerarCarteirinha')}" />
</toolbar>
</window>
</zk>