diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioVendasBoletos.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioVendasBoletos.java deleted file mode 100644 index 1016b82d4..000000000 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioVendasBoletos.java +++ /dev/null @@ -1,274 +0,0 @@ -package com.rjconsultores.ventaboletos.relatorios.impl; - -import java.sql.Connection; -import java.sql.Date; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; - -import org.apache.log4j.Logger; - -import com.rjconsultores.ventaboletos.relatorios.utilitarios.DataSource; -import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; -import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioVendasPacotesBoletosBean; -import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement; - -public class RelatorioVendasBoletos extends Relatorio { - - private static Logger log = Logger.getLogger(RelatorioVendasBoletos.class); - - private SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); - - private List lsDadosRelatorio; - - private Date fecInicio; - private Date fecFinal; - private Integer empresaId; - private Integer origenId; - private Integer destinoId; - - public RelatorioVendasBoletos(Map parametros, Connection conexao, final String... nomeSubReporte) throws Exception { - super(parametros, conexao); - - this.setCustomDataSource(new DataSource(this) { - - - @Override - public void initDados() throws Exception { - Map parametros = this.relatorio.getParametros(); - fecInicio = new java.sql.Date(sdf.parse(parametros.get("fecInicio").toString()).getTime()); - fecFinal = new java.sql.Date(sdf.parse(parametros.get("fecFinal").toString()).getTime()); - empresaId = parametros.get("empresaId") != null && !parametros.get("empresaId").equals("null") ? Integer.valueOf(parametros.get("empresaId").toString()) : null; - origenId = parametros.get("origenId") != null && !parametros.get("origenId").equals("null") ? Integer.valueOf(parametros.get("origenId").toString()) : null; - destinoId = parametros.get("destinoId") != null && !parametros.get("destinoId").equals("null") ? Integer.valueOf(parametros.get("destinoId").toString()) : null; - - Connection conexao = this.relatorio.getConexao(); - processarVendasPacote(conexao); - processarVendasPacoteCancelados(conexao); - - setNomeSubReporte(nomeSubReporte); - setLsDadosRelatorio(lsDadosRelatorio); - } - - }); - } - - private void processarVendasPacote(Connection conexao) { - ResultSet rset = null; - NamedParameterStatement stmt = null; - - try { - stmt = carregarNamedParameterStatement(conexao, false); - rset = stmt.executeQuery(); - - if(lsDadosRelatorio == null) { - lsDadosRelatorio = new ArrayList(); - } - - while (rset.next()) { - RelatorioVendasPacotesBoletosBean relatorioVendasBoletosBean = carregarRelatorioVendasBoletosBean(rset); - Integer idx = carregarIndice(relatorioVendasBoletosBean); - - if(idx != null) { - relatorioVendasBoletosBean = lsDadosRelatorio.get(idx); - } - - relatorioVendasBoletosBean.setRelatorioVendasPacotesBoletosItemBeans(carregarItens(rset, relatorioVendasBoletosBean, relatorioVendasBoletosBean.getRelatorioVendasPacotesBoletosItemBeans())); - - if(idx != null) { - lsDadosRelatorio.set(idx, relatorioVendasBoletosBean); - } else { - lsDadosRelatorio.add(relatorioVendasBoletosBean); - } - } - - } catch (Exception e) { - log.error(e.getMessage(), e); - } finally { - try { - if(rset != null) { - rset.close(); - } - if(stmt != null) { - stmt.close(); - } - } catch (SQLException e) { - log.error(e.getMessage(), e); - } - } - - } - - private List carregarItens(ResultSet rset, RelatorioVendasPacotesBoletosBean relatorioVendasPacotesBoletosBean, List itens) throws SQLException { - RelatorioVendasPacotesBoletosBean.RelatorioVendasPacotesBoletosItemBean relatorioVendasPacotesBoletosItemBean = relatorioVendasPacotesBoletosBean.new RelatorioVendasPacotesBoletosItemBean(); - relatorioVendasPacotesBoletosItemBean.setDesccategoria(rset.getString("desccategoria")); - relatorioVendasPacotesBoletosItemBean.setQtde(rset.getLong("qtde")); - relatorioVendasPacotesBoletosItemBean.setSimportetaxaembarque(rset.getBigDecimal("simportetaxaembarque")); - relatorioVendasPacotesBoletosItemBean.setSimportepedagio(rset.getBigDecimal("simportepedagio")); - relatorioVendasPacotesBoletosItemBean.setSimporteoutros(rset.getBigDecimal("simporteoutros")); - relatorioVendasPacotesBoletosItemBean.setSimporteseguro(rset.getBigDecimal("simporteseguro")); - relatorioVendasPacotesBoletosItemBean.setSpreciobase(rset.getBigDecimal("spreciobase")); - relatorioVendasPacotesBoletosItemBean.setDesconto(rset.getBigDecimal("desconto")); - - if(itens == null) { - itens = new ArrayList(); - } - itens.add(relatorioVendasPacotesBoletosItemBean); - - return itens; - } - - private Integer carregarIndice(RelatorioVendasPacotesBoletosBean relatorioVendasBoletosBean) { - Integer idx = null; - if(lsDadosRelatorio.contains(relatorioVendasBoletosBean)) { - idx = lsDadosRelatorio.indexOf(relatorioVendasBoletosBean); - relatorioVendasBoletosBean = lsDadosRelatorio.get(idx); - } - return idx; - } - - private RelatorioVendasPacotesBoletosBean carregarRelatorioVendasBoletosBean(ResultSet rset) throws SQLException { - RelatorioVendasPacotesBoletosBean relatorioVendasPacotesBoletosBean = new RelatorioVendasPacotesBoletosBean(); - relatorioVendasPacotesBoletosBean.setDescdestino(rset.getString("destino")); - relatorioVendasPacotesBoletosBean.setDescorigen(rset.getString("origem")); - relatorioVendasPacotesBoletosBean.setCvedestino(rset.getString("cvedestino")); - relatorioVendasPacotesBoletosBean.setCveorigen(rset.getString("cveorigem")); - - return relatorioVendasPacotesBoletosBean; - } - - private void processarVendasPacoteCancelados(Connection conexao) { - ResultSet rset = null; - NamedParameterStatement stmt = null; - - try { - stmt = carregarNamedParameterStatement(conexao, true); - rset = stmt.executeQuery(); - - if(lsDadosRelatorio == null) { - lsDadosRelatorio = new ArrayList(); - } - - while (rset.next()) { - RelatorioVendasPacotesBoletosBean relatorioVendasBoletosBean = carregarRelatorioVendasBoletosBean(rset); - Integer idx = carregarIndice(relatorioVendasBoletosBean); - - if(idx != null) { - relatorioVendasBoletosBean = lsDadosRelatorio.get(idx); - } - - relatorioVendasBoletosBean.setRelatorioVendasPacotesBoletosItemBeansCancelados(carregarItens(rset, relatorioVendasBoletosBean, relatorioVendasBoletosBean.getRelatorioVendasPacotesBoletosItemBeansCancelados())); - - if(idx != null) { - lsDadosRelatorio.set(idx, relatorioVendasBoletosBean); - } else { - lsDadosRelatorio.add(relatorioVendasBoletosBean); - } - } - - } catch (Exception e) { - log.error(e.getMessage(), e); - } finally { - try { - if(rset != null) { - rset.close(); - } - if(stmt != null) { - stmt.close(); - } - } catch (SQLException e) { - log.error(e.getMessage(), e); - } - } - - } - - private NamedParameterStatement carregarNamedParameterStatement(Connection conexao, boolean cancelados) throws SQLException { - String sql = getSqlPacotes(cancelados); - log.info(sql); - - NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql); - - if(fecInicio != null) { - stmt.setDate("fecInicio", fecInicio); - } - if(fecFinal != null) { - stmt.setDate("fecFinal", fecFinal); - } - if (empresaId != null){ - stmt.setInt("empresaId", empresaId); - } - if(origenId != null) { - stmt.setInt("origenId", origenId); - } - if(destinoId != null) { - stmt.setInt("destinoId", destinoId); - } - - return stmt; - } - - protected String getSqlPacotes(boolean cancelado) { - StringBuilder sQuery = new StringBuilder(); - - sQuery.append("SELECT DES.CVEPARADA AS CVEDESTINO, ORI.CVEPARADA AS CVEORIGEM, ORI.DESCPARADA AS ORIGEM, DES.DESCPARADA AS DESTINO, CAT.DESCCATEGORIA AS DESCCATEGORIA, ") - .append("COUNT(B.BOLETO_ID) AS QTDE, SUM(B.IMPORTETAXAEMBARQUE) AS SIMPORTETAXAEMBARQUE, SUM(B.IMPORTEPEDAGIO) AS SIMPORTEPEDAGIO, ") - .append("SUM(B.IMPORTEOUTROS) AS SIMPORTEOUTROS, SUM(B.IMPORTESEGURO) AS SIMPORTESEGURO, SUM(B.PRECIOBASE) AS SPRECIOBASE, SUM(B.PRECIOBASE - B.PRECIOPAGADO) AS DESCONTO ") - .append("FROM BOLETO B ") - .append("LEFT JOIN PARADA ORI ON ORI.PARADA_ID = B.ORIGEN_ID ") - .append("LEFT JOIN PARADA DES ON DES.PARADA_ID = B.DESTINO_ID ") - .append("LEFT JOIN CATEGORIA CAT ON CAT.CATEGORIA_ID = B.CATEGORIA_ID ") - .append("WHERE B.ACTIVO = 1 "); - - if(!cancelado) { - sQuery.append("AND B.INDSTATUSBOLETO = 'V' ") - .append("AND B.MOTIVOCANCELACION_ID IS NULL "); - } else { - sQuery.append("AND B.MOTIVOCANCELACION_ID IS NOT NULL "); - } - - if(empresaId != null) { - sQuery.append("AND B.EMPRESACORRIDA_ID = :empresaId "); - } - - if(origenId != null) { - sQuery.append("AND B.ORIGEN_ID = :origenId "); - } - - if(destinoId != null) { - sQuery.append("AND B.DESTINO_ID = :destinoId "); - } - - if(fecInicio != null) { - sQuery.append("AND B.FECHORVENTA >= :fecInicio "); - } - - if(fecFinal != null) { - sQuery.append("AND B.FECHORVENTA <= :fecFinal "); - } - - sQuery.append("GROUP BY DES.CVEPARADA, ORI.CVEPARADA, ORI.DESCPARADA, DES.DESCPARADA, CAT.DESCCATEGORIA ") - .append("ORDER BY DES.CVEPARADA, ORI.CVEPARADA, ORI.DESCPARADA, DES.DESCPARADA, CAT.DESCCATEGORIA "); - - return sQuery.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/impl/RelatorioVendasPacotesBoletos.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioVendasPacotesBoletos.java index 3937dc429..893e04dd9 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioVendasPacotesBoletos.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioVendasPacotesBoletos.java @@ -60,6 +60,8 @@ public class RelatorioVendasPacotesBoletos extends Relatorio { Connection conexao = this.relatorio.getConexao(); processarVendasPacote(conexao); + processarVendasAvulsas(conexao); + processarVendasAvulsasCancelados(conexao); processarVendasPacoteTotais(); setNomeSubReporte(nomeSubReporte); @@ -74,7 +76,7 @@ public class RelatorioVendasPacotesBoletos extends Relatorio { NamedParameterStatement stmt = null; try { - stmt = carregarNamedParameterStatement(conexao, false); + stmt = carregarNamedParameterStatementVendasPacotes(conexao, false); rset = stmt.executeQuery(); if(lsDadosRelatorio == null) { @@ -85,13 +87,13 @@ public class RelatorioVendasPacotesBoletos extends Relatorio { RelatorioVendasPacotesBoletosBean relatorioVendasBoletosBean = carregarRelatorioVendasBoletosBean(rset); Integer idx = carregarIndice(relatorioVendasBoletosBean); - if(idx != null) { + if(idx > -1) { relatorioVendasBoletosBean = lsDadosRelatorio.get(idx); } - relatorioVendasBoletosBean.setRelatorioVendasPacotesBoletosItemBeans(carregarItens(rset, relatorioVendasBoletosBean, relatorioVendasBoletosBean.getRelatorioVendasPacotesBoletosItemBeans())); + relatorioVendasBoletosBean.setRelatorioVendasPacotesBoletosItemBeans(carregarItens(rset, relatorioVendasBoletosBean, relatorioVendasBoletosBean.getRelatorioVendasPacotesBoletosItemBeans(), false)); - if(idx != null) { + if(idx > -1) { lsDadosRelatorio.set(idx, relatorioVendasBoletosBean); } else { lsDadosRelatorio.add(relatorioVendasBoletosBean); @@ -115,7 +117,7 @@ public class RelatorioVendasPacotesBoletos extends Relatorio { } - private List carregarItens(ResultSet rset, RelatorioVendasPacotesBoletosBean relatorioVendasPacotesBoletosBean, List itens) throws SQLException { + private List carregarItens(ResultSet rset, RelatorioVendasPacotesBoletosBean relatorioVendasPacotesBoletosBean, List itens, Boolean cancelado) throws SQLException { RelatorioVendasPacotesBoletosBean.RelatorioVendasPacotesBoletosItemBean relatorioVendasPacotesBoletosItemBean = relatorioVendasPacotesBoletosBean.new RelatorioVendasPacotesBoletosItemBean(); relatorioVendasPacotesBoletosItemBean.setNumruta(rset.getString("numruta")); relatorioVendasPacotesBoletosItemBean.setDescruta(rset.getString("descruta")); @@ -130,6 +132,8 @@ public class RelatorioVendasPacotesBoletos extends Relatorio { relatorioVendasPacotesBoletosItemBean.setDesconto(rset.getBigDecimal("desconto")); relatorioVendasPacotesBoletosItemBean.setSituacao(SituacaoVendaPacote.getSituacaoVendaPacote(rset.getInt("situacao"))); relatorioVendasPacotesBoletosItemBean.setQtdeImpresso(rset.getInt("qtdeimpresso")); + relatorioVendasPacotesBoletosItemBean.setTipoVenda(rset.getString("tipovenda")); + relatorioVendasPacotesBoletosItemBean.setAvulsoCancelado(cancelado); if(itens == null) { itens = new ArrayList(); @@ -140,7 +144,7 @@ public class RelatorioVendasPacotesBoletos extends Relatorio { } private Integer carregarIndice(RelatorioVendasPacotesBoletosBean relatorioVendasBoletosBean) { - Integer idx = null; + Integer idx = -1; if(lsDadosRelatorio.contains(relatorioVendasBoletosBean)) { idx = lsDadosRelatorio.indexOf(relatorioVendasBoletosBean); relatorioVendasBoletosBean = lsDadosRelatorio.get(idx); @@ -158,8 +162,8 @@ public class RelatorioVendasPacotesBoletos extends Relatorio { return relatorioVendasPacotesBoletosBean; } - private NamedParameterStatement carregarNamedParameterStatement(Connection conexao, boolean cancelados) throws SQLException { - String sql = getSqlPacotes(cancelados); + private NamedParameterStatement carregarNamedParameterStatementVendasPacotes(Connection conexao, boolean cancelados) throws SQLException { + String sql = getSqlVendasPacotes(cancelados); log.info(sql); NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql); @@ -195,13 +199,14 @@ public class RelatorioVendasPacotesBoletos extends Relatorio { return stmt; } - protected String getSqlPacotes(boolean cancelado) { + protected String getSqlVendasPacotes(boolean cancelado) { StringBuilder sQuery = new StringBuilder(); sQuery.append("SELECT DES.CVEPARADA AS CVEDESTINO, ORI.CVEPARADA AS CVEORIGEM, ORI.DESCPARADA AS ORIGEM, DES.DESCPARADA AS DESTINO, R.NUMRUTA, R.DESCRUTA, PC.NOMCONVENIO, TTP.DESCTIPOTARIFA, VP.SITUACAO, ") .append("SUM(CASE WHEN B.MOTIVOCANCELACION_ID = 16 THEN 1 ELSE 0 END) AS QTDEIMPRESSO, ") .append("COUNT(TVP.TARIFAVENDAPACOTE_ID) AS QTDE, SUM(B.IMPORTETAXAEMBARQUE) AS SIMPORTETAXAEMBARQUE, SUM(B.IMPORTEPEDAGIO) AS SIMPORTEPEDAGIO, ") - .append("SUM(B.IMPORTEOUTROS) AS SIMPORTEOUTROS, SUM(B.IMPORTESEGURO) AS SIMPORTESEGURO, SUM(B.PRECIOBASE) AS SPRECIOBASE, SUM(B.PRECIOBASE - B.PRECIOPAGADO) AS DESCONTO ") + .append("SUM(B.IMPORTEOUTROS) AS SIMPORTEOUTROS, SUM(B.IMPORTESEGURO) AS SIMPORTESEGURO, SUM(B.PRECIOBASE) AS SPRECIOBASE, SUM(B.PRECIOBASE - B.PRECIOPAGADO) AS DESCONTO, ") + .append("'PACOTE' AS TIPOVENDA ") .append("FROM VENDA_PACOTE VP ") .append("INNER JOIN PACOTE P ON P.PACOTE_ID = VP.PACOTE_ID AND P.ACTIVO = 1 ") .append("LEFT JOIN TARIFA_VENDA_PACOTE TVP ON TVP.VENDAPACOTE_ID = VP.VENDAPACOTE_ID ") @@ -250,8 +255,8 @@ public class RelatorioVendasPacotesBoletos extends Relatorio { sQuery.append("AND TTP.TIPOTARIFAPACOTE_ID = :tipoTarifaPacoteId "); } - sQuery.append("GROUP BY DES.CVEPARADA, ORI.CVEPARADA, ORI.DESCPARADA, DES.DESCPARADA, R.NUMRUTA, R.DESCRUTA, PC.NOMCONVENIO, TTP.DESCTIPOTARIFA, VP.SITUACAO ") - .append("ORDER BY DES.CVEPARADA, ORI.CVEPARADA, ORI.DESCPARADA, DES.DESCPARADA, R.NUMRUTA, R.DESCRUTA, PC.NOMCONVENIO, TTP.DESCTIPOTARIFA, VP.SITUACAO "); + sQuery.append("GROUP BY DES.CVEPARADA, ORI.CVEPARADA, ORI.DESCPARADA, DES.DESCPARADA, R.NUMRUTA, R.DESCRUTA, PC.NOMCONVENIO, TTP.DESCTIPOTARIFA, VP.SITUACAO, 'PACOTE' ") + .append("ORDER BY DES.CVEPARADA, ORI.CVEPARADA, ORI.DESCPARADA, DES.DESCPARADA, R.NUMRUTA, R.DESCRUTA, PC.NOMCONVENIO, TTP.DESCTIPOTARIFA, VP.SITUACAO, 'PACOTE' "); return sQuery.toString(); } @@ -293,5 +298,183 @@ public class RelatorioVendasPacotesBoletos extends Relatorio { this.setCollectionDataSource(new JRBeanCollectionDataSource(lsDadosRelatorio)); this.lsDadosRelatorio = lsDadosRelatorio; } + + private void processarVendasAvulsas(Connection conexao) { + ResultSet rset = null; + NamedParameterStatement stmt = null; + + try { + stmt = carregarNamedParameterStatementVendasAvulsas(conexao, false); + rset = stmt.executeQuery(); + + if(lsDadosRelatorio == null) { + lsDadosRelatorio = new ArrayList(); + } + + while (rset.next()) { + RelatorioVendasPacotesBoletosBean relatorioVendasBoletosBean = carregarRelatorioVendasBoletosBean(rset); + Integer idx = carregarIndice(relatorioVendasBoletosBean); + + if(idx > -1) { + relatorioVendasBoletosBean = lsDadosRelatorio.get(idx); + } + + relatorioVendasBoletosBean.setRelatorioVendasPacotesBoletosItemBeans(carregarItens(rset, relatorioVendasBoletosBean, relatorioVendasBoletosBean.getRelatorioVendasPacotesBoletosItemBeans(), false)); + + if(idx > -1) { + lsDadosRelatorio.set(idx, relatorioVendasBoletosBean); + } else { + lsDadosRelatorio.add(relatorioVendasBoletosBean); + } + } + + } catch (Exception e) { + log.error(e.getMessage(), e); + } finally { + try { + if(rset != null) { + rset.close(); + } + if(stmt != null) { + stmt.close(); + } + } catch (SQLException e) { + log.error(e.getMessage(), e); + } + } + + } + + private NamedParameterStatement carregarNamedParameterStatementVendasAvulsas(Connection conexao, boolean cancelados) throws SQLException { + String sql = getSqlVendasAvulsos(cancelados); + log.info(sql); + + NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql); + + if(fecVendaInicio != null) { + stmt.setTimestamp("fecInicio", fecVendaInicio); + } + if(fecVendaFinal != null) { + stmt.setTimestamp("fecFinal", fecVendaFinal); + } + if(fecPacoteInicio != null) { + stmt.setTimestamp("fecViajeInicio", fecPacoteInicio); + } + if(fecPacoteFinal != null) { + stmt.setTimestamp("fecViajeFinal", fecPacoteFinal); + } + if (empresaId != null && empresaId > 0){ + stmt.setInt("empresaId", empresaId); + } + if(origenId != null) { + stmt.setInt("origenId", origenId); + } + if(destinoId != null) { + stmt.setInt("destinoId", destinoId); + } + + return stmt; + } + + protected String getSqlVendasAvulsos(boolean cancelado) { + StringBuilder sQuery = new StringBuilder(); + + sQuery.append("SELECT DES.CVEPARADA AS CVEDESTINO, ORI.CVEPARADA AS CVEORIGEM, ORI.DESCPARADA AS ORIGEM, DES.DESCPARADA AS DESTINO, ") + .append("CAT.DESCCATEGORIA AS DESCTIPOTARIFA, R.NUMRUTA, R.DESCRUTA, NULL AS SITUACAO, 1 AS QTDEIMPRESSO, NULL AS NOMCONVENIO, 'AVULSO' AS TIPOVENDA, ") + .append("COUNT(B.BOLETO_ID) AS QTDE, SUM(B.IMPORTETAXAEMBARQUE) AS SIMPORTETAXAEMBARQUE, SUM(B.IMPORTEPEDAGIO) AS SIMPORTEPEDAGIO, ") + .append("SUM(B.IMPORTEOUTROS) AS SIMPORTEOUTROS, SUM(B.IMPORTESEGURO) AS SIMPORTESEGURO, SUM(B.PRECIOBASE) AS SPRECIOBASE, SUM(B.PRECIOBASE - B.PRECIOPAGADO) AS DESCONTO ") + .append("FROM BOLETO B ") + .append("LEFT JOIN PARADA ORI ON ORI.PARADA_ID = B.ORIGEN_ID ") + .append("LEFT JOIN PARADA DES ON DES.PARADA_ID = B.DESTINO_ID ") + .append("LEFT JOIN CATEGORIA CAT ON CAT.CATEGORIA_ID = B.CATEGORIA_ID ") + .append("LEFT JOIN RUTA R ON R.RUTA_ID = B.RUTA_ID ") + .append("WHERE B.ACTIVO = 1 "); + + if(!cancelado) { + sQuery.append("AND B.INDSTATUSBOLETO = 'V' ") + .append("AND B.MOTIVOCANCELACION_ID IS NULL "); + } else { + sQuery.append("AND B.MOTIVOCANCELACION_ID IS NOT NULL "); + } + + if (empresaId != null && empresaId > 0){ + sQuery.append("AND B.EMPRESACORRIDA_ID = :empresaId "); + } + + if(origenId != null) { + sQuery.append("AND B.ORIGEN_ID = :origenId "); + } + + if(destinoId != null) { + sQuery.append("AND B.DESTINO_ID = :destinoId "); + } + + if(fecVendaInicio != null) { + sQuery.append("AND B.FECHORVENTA >= :fecInicio "); + } + + if(fecVendaFinal != null) { + sQuery.append("AND B.FECHORVENTA <= :fecFinal "); + } + + if(fecPacoteInicio != null) { + sQuery.append("AND B.FECHORVIAJE >= :fecViajeInicio "); + } + + if(fecPacoteFinal != null) { + sQuery.append("AND B.FECHORVIAJE <= :fecViajeFinal "); + } + + sQuery.append("GROUP BY DES.CVEPARADA, ORI.CVEPARADA, ORI.DESCPARADA, DES.DESCPARADA, CAT.DESCCATEGORIA, R.NUMRUTA, R.DESCRUTA, NULL, 1, NULL, 'AVULSO' ") + .append("ORDER BY DES.CVEPARADA, ORI.CVEPARADA, ORI.DESCPARADA, DES.DESCPARADA, CAT.DESCCATEGORIA, R.NUMRUTA, R.DESCRUTA, NULL, 1, NULL, 'AVULSO' "); + + return sQuery.toString(); + } + + private void processarVendasAvulsasCancelados(Connection conexao) { + ResultSet rset = null; + NamedParameterStatement stmt = null; + + try { + stmt = carregarNamedParameterStatementVendasAvulsas(conexao, true); + rset = stmt.executeQuery(); + + if(lsDadosRelatorio == null) { + lsDadosRelatorio = new ArrayList(); + } + + while (rset.next()) { + RelatorioVendasPacotesBoletosBean relatorioVendasBoletosBean = carregarRelatorioVendasBoletosBean(rset); + Integer idx = carregarIndice(relatorioVendasBoletosBean); + + if(idx > -1) { + relatorioVendasBoletosBean = lsDadosRelatorio.get(idx); + } + + relatorioVendasBoletosBean.setRelatorioVendasPacotesBoletosItemBeansCancelados(carregarItens(rset, relatorioVendasBoletosBean, relatorioVendasBoletosBean.getRelatorioVendasPacotesBoletosItemBeansCancelados(), true)); + + if(idx > -1) { + lsDadosRelatorio.set(idx, relatorioVendasBoletosBean); + } else { + lsDadosRelatorio.add(relatorioVendasBoletosBean); + } + } + + } catch (Exception e) { + log.error(e.getMessage(), e); + } finally { + try { + if(rset != null) { + rset.close(); + } + if(stmt != null) { + stmt.close(); + } + } catch (SQLException e) { + log.error(e.getMessage(), e); + } + } + + } } diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasPacotesBoletosItem_es.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasPacotesBoletosItem_es.properties index 665da9364..8f554b7cf 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasPacotesBoletosItem_es.properties +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasPacotesBoletosItem_es.properties @@ -13,4 +13,5 @@ label.cancelado=Cancelado label.sim=Si label.nao=No label.ruta=Ruta -label.impresso=Impresso \ No newline at end of file +label.impresso=Impresso +label.tipoVenda=Tipo Venda \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasPacotesBoletosItem_pt_BR.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasPacotesBoletosItem_pt_BR.properties index f68b4fe4a..554a63eb9 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasPacotesBoletosItem_pt_BR.properties +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasPacotesBoletosItem_pt_BR.properties @@ -13,4 +13,5 @@ label.cancelado=Cancelado label.sim=Sim label.nao=Não label.ruta=Rota -label.impresso=Impresso \ No newline at end of file +label.impresso=Impresso +label.tipoVenda=Tipo Venda \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasPacotesBoletosItem.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasPacotesBoletosItem.jasper index 42b105212..371782eda 100644 Binary files a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasPacotesBoletosItem.jasper and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasPacotesBoletosItem.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasPacotesBoletosItem.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasPacotesBoletosItem.jrxml index 8aaf5700d..3a3826349 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasPacotesBoletosItem.jrxml +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasPacotesBoletosItem.jrxml @@ -1,7 +1,7 @@ - - + + @@ -17,6 +17,7 @@ + @@ -56,72 +57,72 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -129,34 +130,34 @@ - + - + - + - + - + - + - + - + - + - + @@ -165,106 +166,116 @@ - + - + - + - + - + - + - + - + - + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -272,34 +283,34 @@ - + - + - + - + - + - + - + - + - + - + @@ -308,34 +319,44 @@ - + - + - + - + - + - + - + - + - + + + + + + + + + + + @@ -345,58 +366,58 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -407,37 +428,34 @@ - + - + - + - + - + - + - + - - - - + - + diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioVendasPacotesBoletosBean.java b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioVendasPacotesBoletosBean.java index f1d69a314..6f4d5feb4 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioVendasPacotesBoletosBean.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioVendasPacotesBoletosBean.java @@ -6,7 +6,7 @@ import java.util.List; import com.rjconsultores.ventaboletos.enums.SituacaoVendaPacote; public class RelatorioVendasPacotesBoletosBean { - + private String cveorigen; private String cvedestino; private String descorigen; @@ -45,7 +45,6 @@ public class RelatorioVendasPacotesBoletosBean { private String descruta; private String nomconvenio; private String desctipotarifa; - private String desccategoria; private Long qtde; private BigDecimal simportetaxaembarque; private BigDecimal simportepedagio; @@ -55,6 +54,8 @@ public class RelatorioVendasPacotesBoletosBean { private BigDecimal spreciobase; private SituacaoVendaPacote situacao; private Integer qtdeImpresso; + private String tipoVenda; + private Boolean avulsoCancelado; public String getNomconvenio() { return nomconvenio; @@ -148,16 +149,12 @@ public class RelatorioVendasPacotesBoletosBean { this.spreciobase = spreciobase; } - public String getDesccategoria() { - return desccategoria; - } - - public void setDesccategoria(String desccategoria) { - this.desccategoria = desccategoria; - } - public Boolean getCancelado() { - return SituacaoVendaPacote.CANCELADO.equals(getSituacao()); + if(getAvulsoCancelado() != null && getAvulsoCancelado()) { + return getAvulsoCancelado(); + } else { + return SituacaoVendaPacote.CANCELADO.equals(getSituacao()); + } } public SituacaoVendaPacote getSituacao() { @@ -196,12 +193,13 @@ public class RelatorioVendasPacotesBoletosBean { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((desccategoria == null) ? 0 : desccategoria.hashCode()); result = prime * result + ((descruta == null) ? 0 : descruta.hashCode()); result = prime * result + ((desctipotarifa == null) ? 0 : desctipotarifa.hashCode()); result = prime * result + ((nomconvenio == null) ? 0 : nomconvenio.hashCode()); result = prime * result + ((numruta == null) ? 0 : numruta.hashCode()); result = prime * result + ((situacao == null) ? 0 : situacao.hashCode()); + result = prime * result + ((tipoVenda == null) ? 0 : tipoVenda.hashCode()); + result = prime * result + ((avulsoCancelado == null) ? 0 : avulsoCancelado.hashCode()); return result; } @@ -214,11 +212,6 @@ public class RelatorioVendasPacotesBoletosBean { if (getClass() != obj.getClass()) return false; RelatorioVendasPacotesBoletosItemBean other = (RelatorioVendasPacotesBoletosItemBean) obj; - if (desccategoria == null) { - if (other.desccategoria != null) - return false; - } else if (!desccategoria.equals(other.desccategoria)) - return false; if (descruta == null) { if (other.descruta != null) return false; @@ -241,6 +234,8 @@ public class RelatorioVendasPacotesBoletosBean { return false; if (situacao != other.situacao) return false; + if (tipoVenda != other.tipoVenda) + return false; return true; } @@ -256,6 +251,22 @@ public class RelatorioVendasPacotesBoletosBean { return qtdeImpresso != null && qtdeImpresso > 0; } + public String getTipoVenda() { + return tipoVenda; + } + + public void setTipoVenda(String tipoVenda) { + this.tipoVenda = tipoVenda; + } + + public Boolean getAvulsoCancelado() { + return avulsoCancelado; + } + + public void setAvulsoCancelado(Boolean avulsoCancelado) { + this.avulsoCancelado = avulsoCancelado; + } + } @Override