1-Será adotado como validade a ser impressa na carteira o campo data fim do cadastro de estudante.
2-Como o cadastro pode ter mais de uma data fim, será considerado, no momento da impressão, o último data fim.
3-Não serão impressas as carteiras cuja a data fim seja menor ou igual a data atual. 

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@64946 d1611594-4594-4d17-8e1d-87c2c4800839
master
daniel.zauli 2017-01-13 18:14:42 +00:00
parent 9d1846cdf4
commit 5d643109b7
9 changed files with 383 additions and 31 deletions

View File

@ -7,6 +7,7 @@ import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -28,11 +29,12 @@ public class RelatorioCarteirinha extends Relatorio {
private static Logger log = org.slf4j.LoggerFactory.getLogger(RelatorioCarteirinha.class);
private List<Cliente> clientes;
private Integer tipoLayout;
public RelatorioCarteirinha(Map<String, Object> parametros, final List<Cliente> lsClienteSelecionados, Connection conexao) throws Exception {
public RelatorioCarteirinha(Map<String, Object> parametros, final List<Cliente> lsClienteSelecionados, Connection conexao, Integer tipoLayout) throws Exception {
super(parametros, conexao);
this.clientes = lsClienteSelecionados;
this.tipoLayout = tipoLayout;
this.setCustomDataSource(new ArrayDataSource(this) {
public void initDados() throws Exception {
Connection conexao = this.relatorio.getConexao();
@ -41,6 +43,16 @@ public class RelatorioCarteirinha extends Relatorio {
});
}
@Override
public String getNome() {
if(tipoLayout.intValue() == 1 ){
return this.getClass().getSimpleName();
}else{
return "RelatorioCarteirinhaLayout2";
}
}
@Override
protected void processaParametros() throws Exception {
}
@ -70,14 +82,28 @@ public class RelatorioCarteirinha extends Relatorio {
log.error("", e);
}
for(int i = 0; i < clientes.size(); i++){
Map<String, Object> dataResult = new HashMap<String, Object>();
preencherDadosCliente(i, dataResult);
preencherDadosEmpresa(dados, rset, image, dataResult);
if(validadeDescuentoValida(clientes.get(i))){
Map<String, Object> dataResult = new HashMap<String, Object>();
preencherDadosCliente(i, dataResult);
preencherDadosEmpresa(dados, rset, image, dataResult);
}
}
}
resultSet = rset;
}
private boolean validadeDescuentoValida(Cliente c){
boolean b = false;
if(c.getLsClienteDescuento() != null && !c.getLsClienteDescuento().isEmpty()){
for(ClienteDescuento cd : c.getLsClienteDescuento()){
if(cd.getFecFin().after(Calendar.getInstance().getTime())){
b = true;
}
}
}
return b;
}
private void preencherDadosEmpresa(List<Map<String, Object>> dados, ResultSet rset, BufferedImage image, Map<String, Object> dataResult) throws SQLException {
dataResult.put("logomarca", image);
dataResult.put("nomeEmpresa", rset.getString("DESCMARCA") != null ? rset.getString("DESCMARCA") : "");
@ -115,13 +141,40 @@ public class RelatorioCarteirinha extends Relatorio {
}else{
dataResult.put("escola", "");
}
Date validadeDate = null;
if(clientes.get(i).getLsClienteDescuento() != null && !clientes.get(i).getLsClienteDescuento().isEmpty() &&
clientes.get(i).getLsClienteDescuento().get(0) != null){
validadeDate = clientes.get(i).getLsClienteDescuento().get(0).getFecFin();
}
for(ClienteDescuento cd : clientes.get(i).getLsClienteDescuento()){
if(validadeDate != null && cd.getFecFin().before(validadeDate) ){
validadeDate = cd.getFecFin();
}
}
if(validadeDate != null ){
dataResult.put("validade", validadeDate.toString() );
}else{
dataResult.put("validade", "" );
}
if(clientes.get(i).getLsClienteDescuento() != null && clientes.get(i).getLsClienteDescuento().size() > 0){
StringBuilder trechosDescuento = new StringBuilder();
for(ClienteDescuento clienteDescuento : clientes.get(i).getLsClienteDescuento()){
trechosDescuento.append(clienteDescuento.getOrigem().getDescparada());
if(tipoLayout.intValue() == 2 && clienteDescuento.getOrigem().getParadaId().intValue() != -1 ){
trechosDescuento.append(clienteDescuento.getOrigem().getCveparada());
}else{
trechosDescuento.append(clienteDescuento.getOrigem().getDescparada());
}
trechosDescuento.append(" >> ");
trechosDescuento.append(clienteDescuento.getDestino().getDescparada());
if(tipoLayout.intValue() == 2 && clienteDescuento.getDestino().getParadaId().intValue() != -1 ){
trechosDescuento.append(clienteDescuento.getDestino().getCveparada());
}else{
trechosDescuento.append(clienteDescuento.getDestino().getDescparada());
}
trechosDescuento.append(",");
}
trechosDescuento.deleteCharAt(trechosDescuento.length()-1);
@ -195,4 +248,12 @@ public class RelatorioCarteirinha extends Relatorio {
enderecoCompleto.append(rset.getString("NOMBESTADO") != null ? rset.getString("NOMBESTADO") : "" );
return enderecoCompleto.toString();
}
public Integer getTipoLayout() {
return tipoLayout;
}
public void setTipoLayout(Integer tipoLayout) {
this.tipoLayout = tipoLayout;
}
}

View File

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

View File

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

View File

@ -0,0 +1,216 @@
<?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="RelatorioCarteirinhaLayout2" 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="3.0"/>
<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"/>
<field name="nomeCliente" class="java.lang.String"/>
<field name="enderecoCliente" class="java.lang.String"/>
<field name="escola" class="java.lang.String"/>
<field name="trajeto" class="java.lang.String"/>
<field name="numeroCliente" class="java.lang.String"/>
<field name="dia" class="java.lang.String"/>
<field name="mes" class="java.lang.String"/>
<field name="ano" class="java.lang.String"/>
<field name="validade" class="java.lang.String"/>
<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="3" y="18" width="270" height="167"/>
<graphicElement>
<pen lineWidth="0.5"/>
</graphicElement>
</rectangle>
<textField>
<reportElement uuid="394f5c12-2c2c-4163-8bc3-acd6f3bc5d28" x="152" y="28" width="108" height="7"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$F{cepTelefoneEmpresa}]]></textFieldExpression>
</textField>
<rectangle>
<reportElement uuid="83734f3b-766a-4763-be16-45b5069c07a4" x="8" y="68" width="86" height="112"/>
<graphicElement>
<pen lineWidth="0.5"/>
</graphicElement>
</rectangle>
<textField>
<reportElement uuid="9cb7ec2e-f157-4aea-ab7b-949d4407876e" positionType="Float" x="98" y="70" width="48" height="8"/>
<textElement markup="none">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.numero}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="db03a582-9ac3-4bd4-8601-b03e61d2d574" positionType="Float" x="98" y="82" width="48" 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="20" y="20" width="97" height="32"/>
<imageExpression><![CDATA[$F{logomarca}]]></imageExpression>
</image>
<textField>
<reportElement uuid="03905d16-be95-4402-a96c-94285b306567" positionType="Float" x="146" y="146" 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" positionType="Float" x="98" y="145" width="156" height="1"/>
<graphicElement>
<pen lineWidth="0.5"/>
</graphicElement>
</line>
<textField>
<reportElement uuid="9d29c54f-cd25-4a3d-bf57-376894802d22" x="96" y="172" width="100" height="10"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$F{local}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="3748a0d2-52f4-4d70-a615-94aabc419f3f" x="208" y="172" width="15" height="10"/>
<textElement textAlignment="Center" verticalAlignment="Middle" markup="none">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.de}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="6c415b9e-2080-4767-a59d-197438e3b97c" x="240" y="172" width="15" height="10"/>
<textElement textAlignment="Center" verticalAlignment="Middle" markup="none">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.de}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement uuid="5039e861-4bf5-430f-abf0-98cfa54698f8" positionType="Float" x="125" y="70" width="146" height="8" isPrintWhenDetailOverflows="true"/>
<textElement>
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$F{numeroCliente}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement uuid="e420ff44-ca6a-4aac-b83d-a5150c5fd324" positionType="Float" x="125" y="93" width="146" height="7" isPrintWhenDetailOverflows="true"/>
<textElement>
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$F{enderecoCliente}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement uuid="f51b30e5-1cd8-4172-9430-e6a1e294ed16" positionType="Float" x="125" y="82" width="146" height="7" isPrintWhenDetailOverflows="true"/>
<textElement>
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$F{nomeCliente}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement uuid="6c7dee6a-2ca8-4b8b-8e6e-143ac88d6870" positionType="Float" x="125" y="103" width="146" height="7" isPrintWhenDetailOverflows="true"/>
<textElement>
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$F{trajeto}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="e8992c9f-8d48-44cc-90fa-811f36c50c11" x="152" y="20" width="108" height="7"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$F{enderecoEmpresa}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="79715320-72a3-4dc0-aa97-db4093ff03a4" x="117" y="36" width="143" height="7"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$F{cnpjIEstadualEmpresa}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="8301812f-003b-4eb8-96e8-3a24614bb2b3" positionType="Float" x="98" y="93" width="48" height="7"/>
<textElement markup="none">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.endereco}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="7cbd4d0f-3dae-42f9-a4fa-9f9f9491e6f7" positionType="Float" x="98" y="103" width="48" height="7"/>
<textElement markup="none">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.trajeto}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="1b9eb694-5e65-461d-89dd-76725bfe36c7" x="39" y="53" 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="d81de290-edf0-4e39-af32-7ab6a4cc944c" x="195" y="172" width="13" height="10"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$F{dia}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="8c8e7468-0133-4b72-a5c2-0374b3a77229" x="223" y="172" width="17" height="10"/>
<textElement verticalAlignment="Middle">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$F{mes}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="6bab4624-e5ad-4ac0-98a9-8c686673ba08" x="255" y="172" width="17" height="10"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$F{ano}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="9be91eac-834d-4bfa-8258-dd01d7f41469" positionType="Float" x="98" y="113" width="48" height="7"/>
<textElement markup="none">
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.validade}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement uuid="e617009a-58ad-41a3-a614-8d9c50424987" positionType="Float" x="127" y="113" width="146" height="7" isPrintWhenDetailOverflows="true"/>
<textElement>
<font size="5"/>
</textElement>
<textFieldExpression><![CDATA[$F{validade}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band splitType="Stretch"/>
</pageFooter>
<summary>
<band splitType="Stretch"/>
</summary>
</jasperReport>

View File

@ -17,6 +17,7 @@ import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zul.Comboitem;
import org.zkoss.zul.Paging;
import org.zkoss.zul.Radio;
import com.rjconsultores.ventaboletos.dao.hibernate.ClienteDescuentoHibernateDAO;
import com.rjconsultores.ventaboletos.dao.hibernate.ClienteDireccionHibernateDAO;
@ -46,6 +47,7 @@ public class RelatorioCarteirinhaController extends MyGenericForwardComposer {
private MyComboboxEstandar cmbEmpresa;
private List<Empresa> lsEmpresa;
private Radio layout1;
@Autowired
private EmpresaService empresaService;
@ -84,33 +86,65 @@ public class RelatorioCarteirinhaController extends MyGenericForwardComposer {
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
private void executarRelatorio() throws Exception {
Comboitem itemEmpresa = cmbEmpresa.getSelectedItem();
if(itemEmpresa != null && clienteSelList.getData() != null && clienteSelList.getData().length > 0){
Relatorio relatorio;
Map<String, Object> parametros = new HashMap<String, Object>();
StringBuilder filtro = new StringBuilder();
List<Cliente> lsClienteSelecionados = new ArrayList(Arrays.asList(clienteSelList.getData()));
filtro.append("Empresa: ");
Empresa empresa = (Empresa) itemEmpresa.getValue();
parametros.put("EMPRESA_ID", empresa.getEmpresaId());
filtro.append(empresa.getNombempresa() + ";");
relatorio = new RelatorioCarteirinha(parametros, lsClienteSelecionados, dataSourceRead.getConnection());
Map args = new HashMap();
args.put("relatorio", relatorio);
openWindow("/component/reportView.zul",
Labels.getLabel("carteirinhaController.window.title"), args, MODAL);
}
try {
if(clienteSelList.getData() == null || clienteSelList.getData().length == 0){
Messagebox.show(Labels.getLabel("relatorioCarterinhaController.selecao.cliente"), Labels.getLabel("carteirinhaController.window.title"),
Messagebox.OK, Messagebox.INFORMATION);
if(layout1.isChecked()){
Comboitem itemEmpresa = cmbEmpresa.getSelectedItem();
if(itemEmpresa != null && clienteSelList.getData() != null && clienteSelList.getData().length > 0){
Relatorio relatorio;
Map<String, Object> parametros = new HashMap<String, Object>();
StringBuilder filtro = new StringBuilder();
List<Cliente> lsClienteSelecionados = new ArrayList(Arrays.asList(clienteSelList.getData()));
filtro.append("Empresa: ");
Empresa empresa = (Empresa) itemEmpresa.getValue();
parametros.put("EMPRESA_ID", empresa.getEmpresaId());
filtro.append(empresa.getNombempresa() + ";");
relatorio = new RelatorioCarteirinha(parametros, lsClienteSelecionados, dataSourceRead.getConnection(), 1);
Map args = new HashMap();
args.put("relatorio", relatorio);
openWindow("/component/reportView.zul",
Labels.getLabel("carteirinhaController.window.title"), args, MODAL);
}
} catch (InterruptedException ex) {
ex.printStackTrace();
try {
if(clienteSelList.getData() == null || clienteSelList.getData().length == 0){
Messagebox.show(Labels.getLabel("relatorioCarterinhaController.selecao.cliente"), Labels.getLabel("carteirinhaController.window.title"),
Messagebox.OK, Messagebox.INFORMATION);
}
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}else{
Comboitem itemEmpresa = cmbEmpresa.getSelectedItem();
if(itemEmpresa != null && clienteSelList.getData() != null && clienteSelList.getData().length > 0){
Relatorio relatorio;
Map<String, Object> parametros = new HashMap<String, Object>();
StringBuilder filtro = new StringBuilder();
List<Cliente> lsClienteSelecionados = new ArrayList(Arrays.asList(clienteSelList.getData()));
filtro.append("Empresa: ");
Empresa empresa = (Empresa) itemEmpresa.getValue();
parametros.put("EMPRESA_ID", empresa.getEmpresaId());
filtro.append(empresa.getNombempresa() + ";");
relatorio = new RelatorioCarteirinha(parametros, lsClienteSelecionados, dataSourceRead.getConnection(), 2);
Map args = new HashMap();
args.put("relatorio", relatorio);
openWindow("/component/reportView.zul",
Labels.getLabel("carteirinhaController.window.title"), args, MODAL);
}
try {
if(clienteSelList.getData() == null || clienteSelList.getData().length == 0){
Messagebox.show(Labels.getLabel("relatorioCarterinhaController.selecao.cliente"), Labels.getLabel("carteirinhaController.window.title"),
Messagebox.OK, Messagebox.INFORMATION);
}
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
}
public void onClick$btnExecutarRelatorio(Event ev) throws Exception{

View File

@ -6763,6 +6763,7 @@ relatorioCarterinhaController.lblIdCliente = Id
relatorioCarterinhaController.lblDocumento = Documento
relatorioCarterinhaController.selecao.cliente = Seleccione al menos un cliente
editarConexionExcepcionRutaController.rutaId.label=Linea ID
relatorioCarterinhaController.lblLayout = Layout
# Importacion Fiscal
busquedaImportacionFiscalEcfController.window.title=Impresión Fiscal :: ECF

View File

@ -6936,6 +6936,8 @@ relatorioCarterinhaController.nomeEscola = Escola
relatorioCarterinhaController.lblIdCliente = Id
relatorioCarterinhaController.lblDocumento = Documento
relatorioCarterinhaController.selecao.cliente = Selecione pelo menos um cliente
relatorioCarterinhaController.lblLayout = Layout
editarConexionExcepcionRutaController.rutaId.label=Linha ID

View File

@ -66,6 +66,26 @@
</bandpopup>
</bandbox>
</row>
<row spans="1,6">
<label
value="${c:l('relatorioCarterinhaController.lblLayout')}" />
<grid>
<columns>
<column width="50%" />
<column width="50%" />
</columns>
<rows>
<row>
<radiogroup Id="layouts" >
<radio id="layout1"
label="1" checked = "true"/>
<radio id="layout2"
label="2" />
</radiogroup>
</row>
</rows>
</grid>
</row>
<row spans="7">
<listbox id="clienteSelList" mold="paging"
use="com.rjconsultores.ventaboletos.web.utilerias.MyListbox"