Relatórios -> Venda de Comissão de Cancelados

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@66142 d1611594-4594-4d17-8e1d-87c2c4800839
master
lucas.calixto 2017-02-22 14:02:00 +00:00
parent 681d0708d7
commit 5aca6357fb
6 changed files with 343 additions and 10 deletions

View File

@ -16,6 +16,7 @@ import com.rjconsultores.ventaboletos.constantes.Constantes;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.DataSource;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioVendasComissaoBean;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioVendasComissaoCancelamentoBean;
import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
@ -25,6 +26,7 @@ public class RelatorioVendasComissao extends Relatorio {
private static Logger log = Logger.getLogger(RelatorioVendasComissao.class);
private List<RelatorioVendasComissaoBean> lsDadosRelatorio;
private List<RelatorioVendasComissaoCancelamentoBean> lsDadosRelatorioCancelamento;
private Timestamp fecInicio;
private Timestamp fecFinal;
@ -49,7 +51,13 @@ public class RelatorioVendasComissao extends Relatorio {
Connection conexao = this.relatorio.getConexao();
processarVendasComissao(conexao);
setLsDadosRelatorio(lsDadosRelatorio);
if (apenasCancelados) {
setCollectionDataSource(new JRBeanCollectionDataSource(lsDadosRelatorioCancelamento));
} else {
setCollectionDataSource(new JRBeanCollectionDataSource(lsDadosRelatorio));
}
}
});
@ -60,14 +68,15 @@ public class RelatorioVendasComissao extends Relatorio {
NamedParameterStatement stmt = null;
try {
if(lsDadosRelatorio == null) {
lsDadosRelatorio = new ArrayList<RelatorioVendasComissaoBean>();
}
/* Processando vendas normais */
stmt = carregarNamedParameterStatement(conexao);
rset = stmt.executeQuery();
processarResultado(rset);
if (apenasCancelados) {
processarResultadoCancelamento(rset);
} else {
processarResultado(rset);
}
fecharConexaoBanco(stmt, rset);
} catch (Exception e) {
@ -90,6 +99,9 @@ public class RelatorioVendasComissao extends Relatorio {
}
private void processarResultado(ResultSet rset) throws SQLException {
if(lsDadosRelatorio == null) {
lsDadosRelatorio = new ArrayList<RelatorioVendasComissaoBean>();
}
while (rset.next()) {
RelatorioVendasComissaoBean relatorioVendaComissao = new RelatorioVendasComissaoBean();
relatorioVendaComissao.setNumPuntoVenta(rset.getString("NUMPUNTOVENTA"));
@ -127,6 +139,23 @@ public class RelatorioVendasComissao extends Relatorio {
}
private void processarResultadoCancelamento(ResultSet rset) throws SQLException {
if(lsDadosRelatorioCancelamento == null) {
lsDadosRelatorioCancelamento = new ArrayList<RelatorioVendasComissaoCancelamentoBean>();
}
while (rset.next()) {
RelatorioVendasComissaoCancelamentoBean relatorioVendaComissao = new RelatorioVendasComissaoCancelamentoBean();
relatorioVendaComissao.setNumFolioSistema(rset.getString("NUMFOLIOSISTEMA"));
relatorioVendaComissao.setCorridaId(rset.getInt("CORRIDA_ID"));
relatorioVendaComissao.setFecHorViaje(rset.getDate("FECHORVIAJE"));
relatorioVendaComissao.setNumAsiento(rset.getString("NUMASIENTO"));
relatorioVendaComissao.setPrecioTotalPagado(rset.getBigDecimal("TOTAL"));
relatorioVendaComissao.setFecHorVenta(rset.getDate("FECHORVENTA"));
lsDadosRelatorioCancelamento.add(relatorioVendaComissao);
}
}
private boolean isCancelamento(String indstatusboleto) {
return "C".equals(indstatusboleto);
}
@ -163,7 +192,7 @@ public class RelatorioVendasComissao extends Relatorio {
}
private NamedParameterStatement carregarNamedParameterStatement(Connection conexao) throws SQLException {
String sql = getSql();
String sql = apenasCancelados ? getSqlCancelados() : getSql();
log.info(sql);
NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql);
@ -211,6 +240,25 @@ public class RelatorioVendasComissao extends Relatorio {
return sQuery.toString();
}
protected String getSqlCancelados() {
StringBuilder sQuery = new StringBuilder();
sQuery.append("SELECT C.NUMFOLIOSISTEMA, C.CORRIDA_ID, C.FECHORVIAJE, C.NUMASIENTO, C.PRECIOPAGADO, C.FECHORVENTA, ")
.append("(COALESCE (C.PRECIOPAGADO,0) + COALESCE (C.IMPORTETAXAEMBARQUE,0) + COALESCE (C.IMPORTESEGURO,0) + COALESCE (C.IMPORTEPEDAGIO,0) + COALESCE (C.IMPORTEOUTROS,0)) AS TOTAL ")
.append("FROM CAJA C ")
.append("JOIN MARCA M ON M.MARCA_ID = C.MARCA_ID ")
.append("WHERE C.INDCANCELACION = 1 AND C.INDSTATUSBOLETO = 'C' ");
sQuery.append("AND C.FECHORVENTA BETWEEN :fecInicio AND :fecFinal ");
if(parametros.get("EMPRESA_ID")!= null) {
sQuery.append("AND M.EMPRESA_ID =:EMPRESA_ID ");
}
return sQuery.toString();
}
@Override
protected void processaParametros() throws Exception {
}
@ -218,10 +266,13 @@ public class RelatorioVendasComissao extends Relatorio {
public List<RelatorioVendasComissaoBean> getLsDadosRelatorio() {
return lsDadosRelatorio;
}
public void setLsDadosRelatorio(List<RelatorioVendasComissaoBean> lsDadosRelatorio) {
this.setCollectionDataSource(new JRBeanCollectionDataSource(lsDadosRelatorio));
this.lsDadosRelatorio = lsDadosRelatorio;
@Override
public String getNome() {
if (apenasCancelados) {
return "RelatorioVendasComissaoCancelamento";
}
return super.getNome();
}
}

View File

@ -0,0 +1,21 @@
#geral
msg.noData=Não foi possivel obter dados com os parâmetros informados.
#Labels cabeçalho
cabecalho.nome=Relatório Vendas para Comissão
cabecalho.relatorio=Relatório:
cabecalho.periodo=Período:
cabecalho.periodoA=à
cabecalho.dataHora=Data/Hora:
cabecalho.impressorPor=Impressor por:
cabecalho.pagina=Página
cabecalho.de=de
cabecalho.filtros=Filtros:
cabecalho.usuario=Usuário:
label.total=Total
label.numFolioSistema=Número de Entradas
label.corridaId=Número de Servicio
label.fecHorViaje=Data Servicio
label.numAsiento=Número de Asiento
label.precioTotalPagado=Valor de Entradas
label.fecHorVenta=Fecha de Regreso

View File

@ -0,0 +1,21 @@
#geral
msg.noData=Não foi possivel obter dados com os parâmetros informados.
#Labels cabeçalho
cabecalho.nome=Relatório Vendas para Comissão
cabecalho.relatorio=Relatório:
cabecalho.periodo=Período:
cabecalho.periodoA=à
cabecalho.dataHora=Data/Hora:
cabecalho.impressorPor=Impressor por:
cabecalho.pagina=Página
cabecalho.de=de
cabecalho.filtros=Filtros:
cabecalho.usuario=Usuário:
label.total=Total
label.numFolioSistema=Número do Bilhete
label.corridaId=Número do Serviço
label.fecHorViaje=Data do Serviço
label.numAsiento=Poltrona
label.precioTotalPagado=Valor do Bilhete
label.fecHorVenta=Data da Devolução

View File

@ -0,0 +1,172 @@
<?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="RelatorioVendasComissao" pageWidth="842" pageHeight="595" orientation="Landscape" whenNoDataType="NoDataSection" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="84b9dfcf-8ec5-4f51-80cc-7339e3b158b4">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="91"/>
<property name="ireport.y" value="0"/>
<parameter name="fecInicio" class="java.lang.String"/>
<parameter name="fecFinal" class="java.lang.String"/>
<parameter name="noDataRelatorio" class="java.lang.String"/>
<parameter name="empresa" class="java.lang.String"/>
<parameter name="apenasCancelados" class="java.lang.Boolean"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="numFolioSistema" class="java.lang.String"/>
<field name="corridaId" class="java.lang.Integer"/>
<field name="fecHorViaje" class="java.util.Date"/>
<field name="numAsiento" class="java.lang.String"/>
<field name="precioTotalPagado" class="java.math.BigDecimal"/>
<field name="fecHorVenta" class="java.util.Date"/>
<variable name="vPrecioTotalPagado" class="java.math.BigDecimal" calculation="Sum">
<variableExpression><![CDATA[$F{precioTotalPagado}]]></variableExpression>
</variable>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="81" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="620" height="20" uuid="43b2c28d-4760-4890-b00d-25e931e79c74"/>
<textElement markup="none">
<font size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{cabecalho.nome}]]></textFieldExpression>
</textField>
<textField pattern="dd/MM/yyyy HH:mm">
<reportElement x="638" y="0" width="164" height="20" uuid="4d1bcd65-c9a6-44b4-8dca-cc3c4c20c9a5"/>
<textElement textAlignment="Right">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="20" width="620" height="20" uuid="fd05bd35-30d9-4baf-aa56-f8e5d3c3268b"/>
<textElement>
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{cabecalho.periodo} + " " + $P{fecInicio} + " " + $R{cabecalho.periodoA} + " " + $P{fecFinal}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="53" y="41" width="139" height="20" uuid="8fa1c53b-1da7-4d4d-a75c-ab1543acae2a"/>
<textFieldExpression><![CDATA[$P{empresa}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="0" y="41" width="53" height="20" uuid="a91f6081-4740-4e36-8965-41b6cde4cc20"/>
<text><![CDATA[Empresa:]]></text>
</staticText>
<textField>
<reportElement x="0" y="61" width="139" height="20" uuid="f1811f21-420c-4faf-87d2-2d46e1b74118"/>
<textElement>
<font isBold="true" pdfFontName="Helvetica-Bold"/>
</textElement>
<textFieldExpression><![CDATA[$P{apenasCancelados} ? "Apenas cancelamentos" : ""]]></textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
<band height="21" splitType="Stretch">
<textField>
<reportElement x="607" y="0" width="195" height="20" uuid="6a8a0843-7236-40a3-98ae-5fbf59b4cfec"/>
<textElement textAlignment="Right">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{cabecalho.pagina} + " " + $V{PAGE_NUMBER}+ " " + $R{cabecalho.de} + " " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height="23" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="102" height="20" uuid="a3dea313-f2a7-4388-bd91-5c02e8612b8e"/>
<textFieldExpression><![CDATA[$R{label.numFolioSistema}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="721" y="0" width="80" height="20" uuid="a2ea7cea-d8ab-4c0e-bee0-4dafb3866c1f"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$R{label.precioTotalPagado}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="556" y="0" width="120" height="20" uuid="43d6ee75-8459-4b9e-8cbe-ca2819d3198a"/>
<textFieldExpression><![CDATA[$R{label.fecHorVenta}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="263" y="1" width="80" height="20" uuid="2d666aaf-65a6-4c3f-acd3-e65483a78256"/>
<textFieldExpression><![CDATA[$R{label.numAsiento}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="388" y="1" width="120" height="20" uuid="8a39b1b1-6ebd-4f33-adea-c28a9988eaae"/>
<textFieldExpression><![CDATA[$R{label.fecHorViaje}]]></textFieldExpression>
</textField>
<line>
<reportElement positionType="Float" x="0" y="21" width="802" height="1" uuid="811af238-a027-48e9-bd6f-eee885474929"/>
</line>
<textField>
<reportElement x="129" y="0" width="100" height="20" uuid="cfac237e-06b7-4c98-b7f1-285f5ec2c8b3"/>
<textFieldExpression><![CDATA[$R{label.corridaId}]]></textFieldExpression>
</textField>
</band>
</columnHeader>
<detail>
<band height="22" splitType="Stretch">
<textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="721" y="0" width="80" height="20" isPrintWhenDetailOverflows="true" uuid="b18fae2e-6454-42b0-a68c-04cf790ddfd6"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{precioTotalPagado}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="129" y="0" width="100" height="20" isPrintWhenDetailOverflows="true" uuid="cebb836f-d485-4d50-98e0-0678bb715fb9"/>
<textFieldExpression><![CDATA[$F{corridaId}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="263" y="1" width="80" height="20" isPrintWhenDetailOverflows="true" uuid="09b0cd36-1946-406f-923a-172b8a4f1ac6"/>
<textFieldExpression><![CDATA[$F{numAsiento}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" pattern="dd/MM/yyyy h.mm a" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="388" y="1" width="120" height="20" isPrintWhenDetailOverflows="true" uuid="8cdbdd14-c9f1-45d8-bf41-a4066930f5a4"/>
<textFieldExpression><![CDATA[$F{fecHorViaje}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="102" height="20" isPrintWhenDetailOverflows="true" uuid="c98526c0-c36f-42df-9308-452ac671044c"/>
<textFieldExpression><![CDATA[$F{numFolioSistema}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" pattern="dd/MM/yyyy h.mm a" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="556" y="0" width="120" height="20" isPrintWhenDetailOverflows="true" uuid="040c8de3-f836-40bc-96bd-761a7f5b46ef"/>
<textFieldExpression><![CDATA[$F{fecHorVenta}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band splitType="Stretch"/>
</pageFooter>
<summary>
<band height="26" splitType="Stretch">
<line>
<reportElement positionType="Float" x="0" y="2" width="802" height="1" uuid="c8dfd524-14cc-454c-afc0-3ce9f8d0ead8"/>
</line>
<textField>
<reportElement x="104" y="5" width="615" height="20" uuid="38a0f957-1b50-46f9-b79f-c631baf8937b"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$R{label.total}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="721" y="5" width="80" height="20" isPrintWhenDetailOverflows="true" uuid="f22b1a6f-2e0b-4771-acf3-b7460874f730"/>
<textElement textAlignment="Right">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$V{vPrecioTotalPagado}]]></textFieldExpression>
</textField>
</band>
</summary>
<noData>
<band height="24">
<textField isBlankWhenNull="true">
<reportElement positionType="Float" x="0" y="0" width="555" height="20" isPrintWhenDetailOverflows="true" uuid="d7df66c6-4dc0-4f3b-88f4-b22094d29091"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$R{msg.noData}]]></textFieldExpression>
</textField>
</band>
</noData>
</jasperReport>

View File

@ -0,0 +1,68 @@
package com.rjconsultores.ventaboletos.relatorios.utilitarios;
import java.math.BigDecimal;
import java.util.Date;
public class RelatorioVendasComissaoCancelamentoBean {
private String numFolioSistema;
private Integer corridaId;
private Date fecHorViaje;
private String numAsiento;
private BigDecimal precioTotalPagado;
private Date fecHorVenta;
public String getNumFolioSistema() {
return numFolioSistema;
}
public void setNumFolioSistema(String numFolioSistema) {
this.numFolioSistema = numFolioSistema;
}
public Integer getCorridaId() {
return corridaId;
}
public void setCorridaId(Integer corridaId) {
this.corridaId = corridaId;
}
public Date getFecHorViaje() {
return fecHorViaje;
}
public void setFecHorViaje(Date fecHorViaje) {
this.fecHorViaje = fecHorViaje;
}
public String getNumAsiento() {
return numAsiento;
}
public void setNumAsiento(String numAsiento) {
this.numAsiento = numAsiento;
}
public BigDecimal getPrecioTotalPagado() {
return precioTotalPagado;
}
public void setPrecioTotalPagado(BigDecimal precioTotalPagado) {
this.precioTotalPagado = precioTotalPagado;
}
public Date getFecHorVenta() {
return fecHorVenta;
}
public void setFecHorVenta(Date fecHorVenta) {
this.fecHorVenta = fecHorVenta;
}
}