From d487beed489bf211574a3ce148060c96242809da Mon Sep 17 00:00:00 2001 From: Leonardo Oliveira Date: Wed, 31 Jul 2024 19:45:58 -0300 Subject: [PATCH 1/4] commit parcial --- .../impl/RelatorioDetalheContrato.java | 132 +++++ .../templates/RelatorioDetalheContrato.jrxml | 544 ++++++++++++++++++ .../RelatorioDetalheContratoBean.java | 113 ++++ .../RelatorioDetalheContratoController.java | 34 ++ .../filtroRelatorioDetalheContrato.zul | 71 +++ 5 files changed, 894 insertions(+) create mode 100644 src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDetalheContrato.java create mode 100644 src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDetalheContrato.jrxml create mode 100644 src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioDetalheContratoBean.java create mode 100644 src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioDetalheContratoController.java create mode 100644 web/gui/relatorios/filtroRelatorioDetalheContrato.zul diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDetalheContrato.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDetalheContrato.java new file mode 100644 index 000000000..082a7f523 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDetalheContrato.java @@ -0,0 +1,132 @@ +package com.rjconsultores.ventaboletos.relatorios.impl; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import com.rjconsultores.ventaboletos.enums.DataGeracaoLegalizacaoEnum; +import com.rjconsultores.ventaboletos.enums.EstadoBilheteConsultarEnum; +import com.rjconsultores.ventaboletos.enums.IndStatusBoleto; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.DataSource; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioCorridasBean; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioDetalheContratoBean; +import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement; + +import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; + +public class RelatorioDetalheContrato extends Relatorio { + + private List lsDadosRelatorio; + + public RelatorioDetalheContrato(Map parametros, Connection conexao) throws Exception { + super(parametros, conexao); + + this.setCustomDataSource(new DataSource(this) { + @Override + public void initDados() throws Exception { + + Connection conexao = this.relatorio.getConexao(); + Map parametros = this.relatorio.getParametros(); + + Date dataInicial = (Date) parametros.get("DATA_DE"); + Date dataFinal = (Date) parametros.get("DATA_ATE"); + DataGeracaoLegalizacaoEnum geracao = (DataGeracaoLegalizacaoEnum) parametros.get("GERACAO"); + EstadoBilheteConsultarEnum estadoBilhetes = (EstadoBilheteConsultarEnum) parametros.get("ESTADO_BILHETES"); + Long numContrato = (Long) parametros.get("NUM_CONTRATO"); + Boolean saldoContrato = (Boolean) parametros.get("SALDO_CONTRATO"); + + NamedParameterStatement nps = new NamedParameterStatement(conexao, getSql(origem, destino)); + nps.setDate("inicioViagem", new java.sql.Date(dataInicial.getTime())); + nps.setDate("fimViagem", new java.sql.Date(dataFinal.getTime())); + + + nps.setInt("numServico", (Integer) parametros.get("CORRIDA_ID")); + nps.setInt("empresaId", Integer.valueOf((String) parametros.get("EMPRESA_ID"))); + if (origem != -1) { + nps.setInt("origemId", (Integer) parametros.get("ORIGEN_ID")); + } + if (destino != -1) { + nps.setInt("destinoId", (Integer) parametros.get("DESTINO_ID")); + } + + ResultSet rset = nps.executeQuery(); + + List ls = new ArrayList(); + + while (rset.next()) { + + RelatorioDetalheContratoBean detalhe = new RelatorioDetalheContratoBean(); + detalhe.setBoleto((Long)rset.getObject("contratoId")); + detalhe.setDataVenda((Date)rset.getObject("dataVenda")); + detalhe.setDestino(rset.getObject("destino").toString()); + detalhe.setOrigem(rset.getObject("origem").toString()); + detalhe.setEmpresa(rset.getObject("empresa").toString()); + detalhe.setEstado((EstadoBilheteConsultarEnum)rset.getObject("estado")); + detalhe.setFatura(rset.getObject("fatura").toString()); + detalhe.setLegalizado((DataGeracaoLegalizacaoEnum)rset.getObject("")); + detalhe.setNomePassageiro(rset.getObject("cliente").toString()); + detalhe.setNomeUsuario(rset.getObject("usuario").toString()); + detalhe.setPassageiroCod((Long)rset.getObject("clicod")); + detalhe.setPassagem(rset.getObject(0)); + detalhe.setPrecioPagado((BigDecimal)rset.getBigDecimal("valorUnit")); + detalhe.setPreco((BigDecimal)rset.getBigDecimal("valorTiquete")); + detalhe.setTipoDoc(rset.getObject("tipoDoc")); + + ls.add(detalhe); + } + + setLsDadosRelatorio(ls); + + } + }); + } + + private String getSql(Integer origem, Integer destino) { + StringBuilder sb = new StringBuilder(); + sb.append("select cc.contrato_id as contratoId, c.fechorviaje as dataVenda, \r\n" + + "tipoidentificacion_id tipoDoc, numfoliosistema as fatura, 'estado' as estado, \r\n" + + "porigen.descparada as origem, pdestino.descparada as destino, 1, c.preciopagado as valorUnit, \r\n" + + "c.preciopagado as valorTiquete, e.nombempresa as empresa, c.cliente_id as clicod, cli.nombcliente cliente, \r\n" + + "u.nombusuario as usuario\r\n" + + "from caja c \r\n" + + "join caixa_contrato cc on cc.caja_id = c.caja_id\r\n" + + "join empresa e on e.empresa_id = c.empresacorrida_id\r\n" + + "join cliente cli on cli.cliente_id = c.cliente_id\r\n" + + "join parada porigen on c.origen_id = porigen.parada_id \r\n" + + "join parada pdestino on c.destino_id = pdestino.parada_id\r\n" + + "join usuario u on u.usuario_id = c.usuario_id"); + + if(origem != -1){ + sb.append(" and b.origen_id = :origemId "); + } + + if(destino != -1){ + sb.append(" and b.destino_id = :destinoId "); + } + + sb.append(" and e.empresa_id = :empresaId "); + sb.append(" and b.corrida_id = :numServico "); + sb.append(" and b.feccorrida between :inicioViagem and :fimViagem "); + sb.append(" order by b.motivocancelacion_id, b.fechorventa "); + + return sb.toString(); + } + + @Override + protected void processaParametros() throws Exception { + } + + public List getLsDadosRelatorio() { + return lsDadosRelatorio; + } + + public void setLsDadosRelatorio(List lsDadosRelatorio) { + this.setCollectionDataSource(new JRBeanCollectionDataSource(lsDadosRelatorio)); + this.lsDadosRelatorio = lsDadosRelatorio; + } +} diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDetalheContrato.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDetalheContrato.jrxml new file mode 100644 index 000000000..f04eb92fa --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDetalheContrato.jrxml @@ -0,0 +1,544 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="102" splitType="Stretch"> + <textField> + <reportElement uuid="bdb170bb-bfe6-4ea2-8702-2df0b015cd7d" x="141" y="20" width="1023" height="20"/> + <textElement/> + <textFieldExpression><![CDATA[$P{EMPRESA}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="f6fe1c2b-09af-45e6-9883-f6aa7fe3016c" x="0" y="0" width="1015" height="20"/> + <textElement markup="none"> + <font size="14" isBold="true"/> + </textElement> + <textFieldExpression><![CDATA[$R{header.titulo.relatorio}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="3d8e6261-3551-411a-ab47-8ed23e80f41e" x="0" y="20" width="141" height="20"/> + <textElement markup="none"/> + <textFieldExpression><![CDATA[$R{header.empresa}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="6c1cdde2-67c3-4a56-9744-5a4d249115f9" x="141" y="40" width="161" height="20"/> + <textElement/> + <textFieldExpression><![CDATA[$P{CONTRATO}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="4f697f82-2de4-4665-af6f-4cc16270d631" x="302" y="40" width="79" height="20"/> + <textElement markup="none"/> + <textFieldExpression><![CDATA[$R{header.executado}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="20a767f1-d0d5-4485-9d6c-3c762e97bc70" x="0" y="60" width="141" height="20"/> + <textElement markup="none"/> + <textFieldExpression><![CDATA[$R{header.valor.contrato}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="96572021-01f9-4d05-938c-11ca5721f81c" x="1015" y="0" width="149" height="20"/> + <textElement textAlignment="Right"/> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="e24ed6f5-a072-4bda-b735-ef26b59fa179" x="0" y="80" width="141" height="20"/> + <textElement markup="none"/> + <textFieldExpression><![CDATA[$R{header.valor.adicionado}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="efc3193a-c42a-4935-95ee-84f086336574" x="302" y="80" width="79" height="20"/> + <textElement markup="none"/> + <textFieldExpression><![CDATA[$R{header.quota.atual}]]></textFieldExpression> + </textField> + <textField pattern="dd/MM/yyyy"> + <reportElement uuid="110852df-8752-44d8-98ae-534a5cb8d5e2" x="141" y="80" width="161" height="20"/> + <textElement/> + <textFieldExpression><![CDATA[$P{VALOR_ADICIONADO}]]></textFieldExpression> + </textField> + <textField pattern="dd/MM/yyyy"> + <reportElement uuid="4d410653-2490-49ff-b176-530feaeab535" x="381" y="80" width="463" height="20"/> + <textElement/> + <textFieldExpression><![CDATA[$P{QUOTA_ATUAL}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="2879d620-3c3b-465f-9459-f94154b9e9c7" x="381" y="40" width="463" height="20"/> + <textElement/> + <textFieldExpression><![CDATA[$P{EXECUTADO}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="06d06c40-6984-4a32-90e2-48e1d8cdcc9b" x="141" y="60" width="161" height="20"/> + <textElement/> + <textFieldExpression><![CDATA[$P{VALOR_CONTRATO}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="577578e8-3add-42a2-88c0-df7647b59844" x="0" y="40" width="141" height="20"/> + <textElement markup="none"/> + <textFieldExpression><![CDATA[$R{header.contrato}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="481f4afe-f201-4297-b478-8b654dbc15e6" x="302" y="60" width="79" height="20"/> + <textElement markup="none"/> + <textFieldExpression><![CDATA[$R{header.destino}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="145e00cf-dde5-4ca3-b799-b15de40d3606" x="381" y="60" width="463" height="20"/> + <textElement/> + <textFieldExpression><![CDATA[$P{DESTINO}]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioDetalheContratoBean.java b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioDetalheContratoBean.java new file mode 100644 index 000000000..0f9df8627 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioDetalheContratoBean.java @@ -0,0 +1,113 @@ +package com.rjconsultores.ventaboletos.relatorios.utilitarios; + +import java.math.BigDecimal; +import java.util.Date; + +public class RelatorioDetalheContratoBean { + + private Long boleto; + private Date dataVenda; + private String tipoDoc; + private String fatura; + private String estado; + private String origem; + private String destino; + private String passagem; + private BigDecimal preco; + private BigDecimal precioPagado; + private String empresa; + private Long passageiroCod; + private String nomePassageiro; + private Integer legalizado; + private String nomeUsuario; + public Long getBoleto() { + return boleto; + } + public void setBoleto(Long boleto) { + this.boleto = boleto; + } + public Date getDataVenda() { + return dataVenda; + } + public void setDataVenda(Date dataVenda) { + this.dataVenda = dataVenda; + } + public String getTipoDoc() { + return tipoDoc; + } + public void setTipoDoc(String tipoDoc) { + this.tipoDoc = tipoDoc; + } + public String getFatura() { + return fatura; + } + public void setFatura(String fatura) { + this.fatura = fatura; + } + public String getEstado() { + return estado; + } + public void setEstado(String estado) { + this.estado = estado; + } + public String getOrigem() { + return origem; + } + public void setOrigem(String origem) { + this.origem = origem; + } + public String getDestino() { + return destino; + } + public void setDestino(String destino) { + this.destino = destino; + } + public String getPassagem() { + return passagem; + } + public void setPassagem(String passagem) { + this.passagem = passagem; + } + public BigDecimal getPreco() { + return preco; + } + public void setPreco(BigDecimal preco) { + this.preco = preco; + } + public BigDecimal getPrecioPagado() { + return precioPagado; + } + public void setPrecioPagado(BigDecimal precioPagado) { + this.precioPagado = precioPagado; + } + public String getEmpresa() { + return empresa; + } + public void setEmpresa(String empresa) { + this.empresa = empresa; + } + public Long getPassageiroCod() { + return passageiroCod; + } + public void setPassageiroCod(Long passageiroCod) { + this.passageiroCod = passageiroCod; + } + public String getNomePassageiro() { + return nomePassageiro; + } + public void setNomePassageiro(String nomePassageiro) { + this.nomePassageiro = nomePassageiro; + } + public Integer getLegalizado() { + return legalizado; + } + public void setLegalizado(Integer legalizado) { + this.legalizado = legalizado; + } + public String getNomeUsuario() { + return nomeUsuario; + } + public void setNomeUsuario(String nomeUsuario) { + this.nomeUsuario = nomeUsuario; + } +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioDetalheContratoController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioDetalheContratoController.java new file mode 100644 index 000000000..b4c997f26 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioDetalheContratoController.java @@ -0,0 +1,34 @@ +package com.rjconsultores.ventaboletos.web.gui.controladores.relatorios; + +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.zul.Combobox; +import org.zkoss.zul.Datebox; +import org.zkoss.zul.Intbox; + +import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxParada; +import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxParadaCve; +import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; + +@Controller("relatorioDetalheContratoController") +@Scope("prototype") +public class RelatorioDetalheContratoController extends MyGenericForwardComposer { + + private static final long serialVersionUID = 1L; + @Autowired + private DataSource dataSourceRead; + + + private Datebox datInicial; + private Datebox datFinal; + private Intbox txtCorridaId; + private Combobox cmbEmpresa; + private MyComboboxParada cmbParadaOrigem; + private MyComboboxParadaCve cmbParadaOrigemCve; + private MyComboboxParada cmbParadaDestino; + private MyComboboxParadaCve cmbParadaDestinoCve; + +} diff --git a/web/gui/relatorios/filtroRelatorioDetalheContrato.zul b/web/gui/relatorios/filtroRelatorioDetalheContrato.zul new file mode 100644 index 000000000..30bbf7eed --- /dev/null +++ b/web/gui/relatorios/filtroRelatorioDetalheContrato.zul @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +