alexandre.lima 2017-06-27 19:19:27 +00:00
parent 21537e96f7
commit 41e0443226
1 changed files with 188 additions and 187 deletions

View File

@ -48,7 +48,6 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
this.setCustomDataSource(new DataSource(this) { this.setCustomDataSource(new DataSource(this) {
@Override @Override
public void initDados() throws Exception { public void initDados() throws Exception {
Map<String, Object> parametros = this.relatorio.getParametros(); Map<String, Object> parametros = this.relatorio.getParametros();
@ -67,11 +66,11 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
processarVendasPacote(conexao); processarVendasPacote(conexao);
/* Caso o filtro de data de venda de pacote seja informado, não trazer bilhetes avulsos */ /* Caso o filtro de data de venda de pacote seja informado, não trazer bilhetes avulsos */
if(fecPacoteInicio == null && fecPacoteFinal == null) { if (fecPacoteInicio == null && fecPacoteFinal == null) {
if(situacaoBilheteId == null || !CANCELADOS.equals(situacaoBilheteId)) { if (situacaoBilheteId == null || !CANCELADOS.equals(situacaoBilheteId)) {
processarVendasAvulsas(conexao); processarVendasAvulsas(conexao);
} }
if(situacaoBilheteId == null || CANCELADOS.equals(situacaoBilheteId)) { if (situacaoBilheteId == null || CANCELADOS.equals(situacaoBilheteId)) {
processarVendasAvulsasCancelados(conexao); processarVendasAvulsasCancelados(conexao);
} }
} }
@ -92,7 +91,7 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
stmt = carregarNamedParameterStatementVendasPacotes(conexao); stmt = carregarNamedParameterStatementVendasPacotes(conexao);
rset = stmt.executeQuery(); rset = stmt.executeQuery();
if(lsDadosRelatorio == null) { if (lsDadosRelatorio == null) {
lsDadosRelatorio = new ArrayList<RelatorioVendasPacotesBoletosBean>(); lsDadosRelatorio = new ArrayList<RelatorioVendasPacotesBoletosBean>();
} }
@ -100,13 +99,13 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
RelatorioVendasPacotesBoletosBean relatorioVendasBoletosBean = carregarRelatorioVendasBoletosBean(rset); RelatorioVendasPacotesBoletosBean relatorioVendasBoletosBean = carregarRelatorioVendasBoletosBean(rset);
Integer idx = carregarIndice(relatorioVendasBoletosBean); Integer idx = carregarIndice(relatorioVendasBoletosBean);
if(idx > -1) { if (idx > -1) {
relatorioVendasBoletosBean = lsDadosRelatorio.get(idx); relatorioVendasBoletosBean = lsDadosRelatorio.get(idx);
} }
relatorioVendasBoletosBean.setRelatorioVendasPacotesBoletosItemBeans(carregarItens(rset, relatorioVendasBoletosBean, relatorioVendasBoletosBean.getRelatorioVendasPacotesBoletosItemBeans(), false)); relatorioVendasBoletosBean.setRelatorioVendasPacotesBoletosItemBeans(carregarItens(rset, relatorioVendasBoletosBean, relatorioVendasBoletosBean.getRelatorioVendasPacotesBoletosItemBeans(), false));
if(idx > -1) { if (idx > -1) {
lsDadosRelatorio.set(idx, relatorioVendasBoletosBean); lsDadosRelatorio.set(idx, relatorioVendasBoletosBean);
} else { } else {
lsDadosRelatorio.add(relatorioVendasBoletosBean); lsDadosRelatorio.add(relatorioVendasBoletosBean);
@ -117,10 +116,10 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} finally { } finally {
try { try {
if(rset != null) { if (rset != null) {
rset.close(); rset.close();
} }
if(stmt != null) { if (stmt != null) {
stmt.close(); stmt.close();
} }
} catch (SQLException e) { } catch (SQLException e) {
@ -148,7 +147,7 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
relatorioVendasPacotesBoletosItemBean.setTipoVenda(rset.getString("tipovenda")); relatorioVendasPacotesBoletosItemBean.setTipoVenda(rset.getString("tipovenda"));
relatorioVendasPacotesBoletosItemBean.setAvulsoCancelado(cancelado); relatorioVendasPacotesBoletosItemBean.setAvulsoCancelado(cancelado);
if(itens == null) { if (itens == null) {
itens = new ArrayList<RelatorioVendasPacotesBoletosBean.RelatorioVendasPacotesBoletosItemBean>(); itens = new ArrayList<RelatorioVendasPacotesBoletosBean.RelatorioVendasPacotesBoletosItemBean>();
} }
itens.add(relatorioVendasPacotesBoletosItemBean); itens.add(relatorioVendasPacotesBoletosItemBean);
@ -158,7 +157,7 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
private Integer carregarIndice(RelatorioVendasPacotesBoletosBean relatorioVendasBoletosBean) { private Integer carregarIndice(RelatorioVendasPacotesBoletosBean relatorioVendasBoletosBean) {
Integer idx = -1; Integer idx = -1;
if(lsDadosRelatorio.contains(relatorioVendasBoletosBean)) { if (lsDadosRelatorio.contains(relatorioVendasBoletosBean)) {
idx = lsDadosRelatorio.indexOf(relatorioVendasBoletosBean); idx = lsDadosRelatorio.indexOf(relatorioVendasBoletosBean);
relatorioVendasBoletosBean = lsDadosRelatorio.get(idx); relatorioVendasBoletosBean = lsDadosRelatorio.get(idx);
} }
@ -181,35 +180,35 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql); NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql);
if(fecVendaInicio != null) { if (fecVendaInicio != null) {
stmt.setTimestamp("fecVendaInicio", fecVendaInicio); stmt.setTimestamp("fecVendaInicio", fecVendaInicio);
} }
if(fecVendaFinal != null) { if (fecVendaFinal != null) {
stmt.setTimestamp("fecVendaFinal", fecVendaFinal); stmt.setTimestamp("fecVendaFinal", fecVendaFinal);
} }
if(fecPacoteInicio != null) { if (fecPacoteInicio != null) {
stmt.setTimestamp("fecPacoteInicio", fecPacoteInicio); stmt.setTimestamp("fecPacoteInicio", fecPacoteInicio);
} }
if(fecPacoteFinal != null) { if (fecPacoteFinal != null) {
stmt.setTimestamp("fecPacoteFinal", fecPacoteFinal); stmt.setTimestamp("fecPacoteFinal", fecPacoteFinal);
} }
if (empresaId != null && empresaId > 0){ if (empresaId != null && empresaId > 0) {
stmt.setInt("empresaId", empresaId); stmt.setInt("empresaId", empresaId);
} }
if(origenId != null && origenId > 0){ if (origenId != null && origenId > 0) {
stmt.setInt("origenId", origenId); stmt.setInt("origenId", origenId);
} }
if(destinoId != null && destinoId > 0){ if (destinoId != null && destinoId > 0) {
stmt.setInt("destinoId", destinoId); stmt.setInt("destinoId", destinoId);
} }
if(usuarioId != null) { if (usuarioId != null) {
stmt.setInt("usuarioId", usuarioId); stmt.setInt("usuarioId", usuarioId);
} }
if(tipoTarifaPacoteId != null && tipoTarifaPacoteId > 0) { if (tipoTarifaPacoteId != null && tipoTarifaPacoteId > 0) {
stmt.setInt("tipoTarifaPacoteId", tipoTarifaPacoteId); stmt.setInt("tipoTarifaPacoteId", tipoTarifaPacoteId);
} }
if(situacaoBilheteId != null) { if (situacaoBilheteId != null) {
stmt.setInt("situacaoPacote",SituacaoVendaPacote.CANCELADO.getShortValue()); stmt.setInt("situacaoPacote", SituacaoVendaPacote.CANCELADO.getShortValue());
} }
return stmt; return stmt;
@ -219,83 +218,83 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
StringBuilder sQuery = new StringBuilder(); 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, ") 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("SUM(CASE WHEN B.MOTIVOCANCELACION_ID = 16 THEN 1 ELSE 0 END) AS QTDEIMPRESSO, ")
.append("COUNT(TVP.TARIFAVENDAPACOTE_ID) AS QTDE, SUM(T.IMPORTETAXAEMBARQUE) AS SIMPORTETAXAEMBARQUE, SUM(T.IMPORTEPEDAGIO) AS SIMPORTEPEDAGIO, ") .append("COUNT(TVP.TARIFAVENDAPACOTE_ID) AS QTDE, SUM(T.IMPORTETAXAEMBARQUE) AS SIMPORTETAXAEMBARQUE, SUM(T.IMPORTEPEDAGIO) AS SIMPORTEPEDAGIO, ")
.append("SUM(NVL(T.IMPORTEOUTROS,0)) AS SIMPORTEOUTROS, SUM(NVL(T.IMPORTESEGURO,0)) AS SIMPORTESEGURO, SUM(NVL(B.PRECIOBASE,0)) AS SPRECIOBASE, ") .append("SUM(NVL(T.IMPORTEOUTROS,0)) AS SIMPORTEOUTROS, SUM(NVL(T.IMPORTESEGURO,0)) AS SIMPORTESEGURO, SUM(NVL(B.PRECIOBASE,0)) AS SPRECIOBASE, ")
.append(" SUM( ") .append(" SUM( ")
.append(" B.PRECIOBASE+NVL(T.IMPORTETAXAEMBARQUE,0)+NVL(T.IMPORTEPEDAGIO,0)+NVL(T.IMPORTESEGURO,0)+NVL(T.IMPORTEOUTROS,0)- ") .append(" B.PRECIOBASE+NVL(T.IMPORTETAXAEMBARQUE,0)+NVL(T.IMPORTEPEDAGIO,0)+NVL(T.IMPORTESEGURO,0)+NVL(T.IMPORTEOUTROS,0)- ")
.append(" B.PRECIOPAGADO-NVL(B.IMPORTETAXAEMBARQUE,0)-NVL(B.IMPORTEPEDAGIO,0)-NVL(B.IMPORTESEGURO,0)-NVL(B.IMPORTEOUTROS,0) ") .append(" B.PRECIOPAGADO-NVL(B.IMPORTETAXAEMBARQUE,0)-NVL(B.IMPORTEPEDAGIO,0)-NVL(B.IMPORTESEGURO,0)-NVL(B.IMPORTEOUTROS,0) ")
.append(" ) AS DESCONTO, ") .append(" ) AS DESCONTO, ")
.append("'PACOTE' AS TIPOVENDA ") .append("'PACOTE' AS TIPOVENDA ")
.append("FROM VENDA_PACOTE VP ") .append("FROM VENDA_PACOTE VP ")
.append("INNER JOIN PACOTE P ON P.PACOTE_ID = VP.PACOTE_ID AND P.ACTIVO = 1 ") .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 ") .append("LEFT JOIN TARIFA_VENDA_PACOTE TVP ON TVP.VENDAPACOTE_ID = VP.VENDAPACOTE_ID ")
.append("INNER JOIN BOLETO B ON B.BOLETO_ID = TVP.BOLETO_ID ") .append("INNER JOIN BOLETO B ON B.BOLETO_ID = TVP.BOLETO_ID ")
.append("LEFT JOIN RUTA R ON R.RUTA_ID = B.RUTA_ID ") .append("LEFT JOIN RUTA R ON R.RUTA_ID = B.RUTA_ID ")
.append("LEFT JOIN PARADA ORI ON ORI.PARADA_ID = B.ORIGEN_ID ") .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 PARADA DES ON DES.PARADA_ID = B.DESTINO_ID ")
.append("LEFT JOIN PACOTE_TARIFA PT ON PT.PACOTETARIFA_ID = TVP.PACOTETARIFA_ID ") .append("LEFT JOIN PACOTE_TARIFA PT ON PT.PACOTETARIFA_ID = TVP.PACOTETARIFA_ID ")
.append("LEFT JOIN TIPO_TARIFA_PACOTE TTP ON TTP.TIPOTARIFAPACOTE_ID = PT.TIPOTARIFAPACOTE_ID ") .append("LEFT JOIN TIPO_TARIFA_PACOTE TTP ON TTP.TIPOTARIFAPACOTE_ID = PT.TIPOTARIFAPACOTE_ID ")
.append("LEFT JOIN PACOTE_CONVENIO PC ON PC.PACOTECONVENIO_ID = TVP.PACOTECONVENIO_ID AND PC.ACTIVO = 1 ") .append("LEFT JOIN PACOTE_CONVENIO PC ON PC.PACOTECONVENIO_ID = TVP.PACOTECONVENIO_ID AND PC.ACTIVO = 1 ")
.append("LEFT JOIN VIGENCIA_TARIFA VT ON B.FECHORVENTA BETWEEN VT.FECINICIOVIGENCIA AND VT.FECFINVIGENCIA ") .append("LEFT JOIN VIGENCIA_TARIFA VT ON B.FECHORVENTA BETWEEN VT.FECINICIOVIGENCIA AND VT.FECFINVIGENCIA ")
.append("LEFT JOIN TARIFA T ON T.RUTA_ID = B.RUTA_ID ") .append("LEFT JOIN TARIFA T ON T.RUTA_ID = B.RUTA_ID ")
.append(" AND T.DESTINO_ID = B.DESTINO_ID ") .append(" AND T.DESTINO_ID = B.DESTINO_ID ")
.append(" AND T.ORIGEN_ID = B.ORIGEN_ID ") .append(" AND T.ORIGEN_ID = B.ORIGEN_ID ")
.append(" AND T.CLASESERVICIO_ID = B.CLASESERVICIO_ID ") .append(" AND T.CLASESERVICIO_ID = B.CLASESERVICIO_ID ")
.append(" AND T.ACTIVO = 1 ") .append(" AND T.ACTIVO = 1 ")
.append(" AND VT.VIGENCIATARIFA_ID = T.VIGENCIATARIFA_ID ") .append(" AND VT.VIGENCIATARIFA_ID = T.VIGENCIATARIFA_ID ")
.append(" AND T.ORGAOCONCEDENTE_ID = R.ORGAOCONCEDENTE_ID ") .append(" AND T.ORGAOCONCEDENTE_ID = R.ORGAOCONCEDENTE_ID ")
.append("WHERE 1=1 "); .append("WHERE 1=1 ");
if(fecVendaInicio != null) { if (fecVendaInicio != null) {
sQuery.append("AND VP.DATAVENDA >= :fecVendaInicio "); sQuery.append("AND VP.DATAVENDA >= :fecVendaInicio ");
} }
if(fecVendaFinal != null) { if (fecVendaFinal != null) {
sQuery.append("AND VP.DATAVENDA <= :fecVendaFinal "); sQuery.append("AND VP.DATAVENDA <= :fecVendaFinal ");
} }
if(fecPacoteInicio != null) { if (fecPacoteInicio != null) {
sQuery.append("AND VP.DATAPACOTE >= :fecPacoteInicio "); sQuery.append("AND VP.DATAPACOTE >= :fecPacoteInicio ");
} }
if(fecPacoteFinal != null) { if (fecPacoteFinal != null) {
sQuery.append("AND VP.DATAPACOTE <= :fecPacoteFinal "); sQuery.append("AND VP.DATAPACOTE <= :fecPacoteFinal ");
} }
if(empresaId != null && empresaId > 0){ if (empresaId != null && empresaId > 0) {
sQuery.append("AND P.EMPRESA_ID = :empresaId "); sQuery.append("AND P.EMPRESA_ID = :empresaId ");
} }
if(origenId != null && origenId > 0){ if (origenId != null && origenId > 0) {
sQuery.append("AND B.ORIGEN_ID = :origenId "); sQuery.append("AND B.ORIGEN_ID = :origenId ");
} }
if(destinoId != null && destinoId > 0){ if (destinoId != null && destinoId > 0) {
sQuery.append("AND B.DESTINO_ID = :destinoId "); sQuery.append("AND B.DESTINO_ID = :destinoId ");
} }
if(usuarioId != null) { if (usuarioId != null) {
sQuery.append("AND VP.USUARIO_ID = :usuarioId "); sQuery.append("AND VP.USUARIO_ID = :usuarioId ");
} }
if(tipoTarifaPacoteId != null && tipoTarifaPacoteId > 0) { if (tipoTarifaPacoteId != null && tipoTarifaPacoteId > 0) {
sQuery.append("AND TTP.TIPOTARIFAPACOTE_ID = :tipoTarifaPacoteId "); sQuery.append("AND TTP.TIPOTARIFAPACOTE_ID = :tipoTarifaPacoteId ");
} }
if(situacaoBilheteId != null) { if (situacaoBilheteId != null) {
} }
if(situacaoBilheteId != null && !CANCELADOS.equals(situacaoBilheteId)) { if (situacaoBilheteId != null && !CANCELADOS.equals(situacaoBilheteId)) {
sQuery.append("AND VP.SITUACAO <> :situacaoPacote "); sQuery.append("AND VP.SITUACAO <> :situacaoPacote ");
} }
if(situacaoBilheteId != null && CANCELADOS.equals(situacaoBilheteId)) { if (situacaoBilheteId != null && CANCELADOS.equals(situacaoBilheteId)) {
sQuery.append("AND VP.SITUACAO = :situacaoPacote "); sQuery.append("AND VP.SITUACAO = :situacaoPacote ");
} }
sQuery.append("GROUP BY DES.CVEPARADA, ORI.CVEPARADA, ORI.DESCPARADA, DES.DESCPARADA, R.NUMRUTA, R.DESCRUTA, PC.NOMCONVENIO, TTP.DESCTIPOTARIFA, VP.SITUACAO, 'PACOTE' ") 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' "); .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(); return sQuery.toString();
} }
@ -303,22 +302,24 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
private void processarVendasPacoteTotais() { private void processarVendasPacoteTotais() {
List<RelatorioVendasPacotesBoletosBean.RelatorioVendasPacotesBoletosItemTotaisBean> totais = new ArrayList<RelatorioVendasPacotesBoletosBean.RelatorioVendasPacotesBoletosItemTotaisBean>(); List<RelatorioVendasPacotesBoletosBean.RelatorioVendasPacotesBoletosItemTotaisBean> totais = new ArrayList<RelatorioVendasPacotesBoletosBean.RelatorioVendasPacotesBoletosItemTotaisBean>();
for (RelatorioVendasPacotesBoletosBean relatorioVendasPacotesBoletosBean : lsDadosRelatorio) { for (RelatorioVendasPacotesBoletosBean relatorioVendasPacotesBoletosBean : lsDadosRelatorio) {
for (RelatorioVendasPacotesBoletosItemBean item : relatorioVendasPacotesBoletosBean.getRelatorioVendasPacotesBoletosItemBeans()) { if (relatorioVendasPacotesBoletosBean.getRelatorioVendasPacotesBoletosItemBeans() != null) {
RelatorioVendasPacotesBoletosBean.RelatorioVendasPacotesBoletosItemTotaisBean total = relatorioVendasPacotesBoletosBean.new RelatorioVendasPacotesBoletosItemTotaisBean(); for (RelatorioVendasPacotesBoletosItemBean item : relatorioVendasPacotesBoletosBean.getRelatorioVendasPacotesBoletosItemBeans()) {
total.setTrecho(relatorioVendasPacotesBoletosBean.getCveorigen()+"-"+relatorioVendasPacotesBoletosBean.getCvedestino()); RelatorioVendasPacotesBoletosBean.RelatorioVendasPacotesBoletosItemTotaisBean total = relatorioVendasPacotesBoletosBean.new RelatorioVendasPacotesBoletosItemTotaisBean();
total.setCategoria(item.getDesctipotarifa()); total.setTrecho(relatorioVendasPacotesBoletosBean.getCveorigen() + "-" + relatorioVendasPacotesBoletosBean.getCvedestino());
total.setQtde(0l); total.setCategoria(item.getDesctipotarifa());
Integer idx = null; total.setQtde(0l);
if(totais.contains(total)) { Integer idx = null;
idx = totais.indexOf(total); if (totais.contains(total)) {
total = totais.get(idx); idx = totais.indexOf(total);
} total = totais.get(idx);
total.setQtde(total.getQtde() + item.getQtde()); }
total.setQtde(total.getQtde() + item.getQtde());
if(idx == null) { if (idx == null) {
totais.add(total); totais.add(total);
} else { } else {
totais.set(idx, total); totais.set(idx, total);
}
} }
} }
} }
@ -346,7 +347,7 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
stmt = carregarNamedParameterStatementVendasAvulsas(conexao, false); stmt = carregarNamedParameterStatementVendasAvulsas(conexao, false);
rset = stmt.executeQuery(); rset = stmt.executeQuery();
if(lsDadosRelatorio == null) { if (lsDadosRelatorio == null) {
lsDadosRelatorio = new ArrayList<RelatorioVendasPacotesBoletosBean>(); lsDadosRelatorio = new ArrayList<RelatorioVendasPacotesBoletosBean>();
} }
@ -354,13 +355,13 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
RelatorioVendasPacotesBoletosBean relatorioVendasBoletosBean = carregarRelatorioVendasBoletosBean(rset); RelatorioVendasPacotesBoletosBean relatorioVendasBoletosBean = carregarRelatorioVendasBoletosBean(rset);
Integer idx = carregarIndice(relatorioVendasBoletosBean); Integer idx = carregarIndice(relatorioVendasBoletosBean);
if(idx > -1) { if (idx > -1) {
relatorioVendasBoletosBean = lsDadosRelatorio.get(idx); relatorioVendasBoletosBean = lsDadosRelatorio.get(idx);
} }
relatorioVendasBoletosBean.setRelatorioVendasPacotesBoletosItemBeans(carregarItens(rset, relatorioVendasBoletosBean, relatorioVendasBoletosBean.getRelatorioVendasPacotesBoletosItemBeans(), false)); relatorioVendasBoletosBean.setRelatorioVendasPacotesBoletosItemBeans(carregarItens(rset, relatorioVendasBoletosBean, relatorioVendasBoletosBean.getRelatorioVendasPacotesBoletosItemBeans(), false));
if(idx > -1) { if (idx > -1) {
lsDadosRelatorio.set(idx, relatorioVendasBoletosBean); lsDadosRelatorio.set(idx, relatorioVendasBoletosBean);
} else { } else {
lsDadosRelatorio.add(relatorioVendasBoletosBean); lsDadosRelatorio.add(relatorioVendasBoletosBean);
@ -371,10 +372,10 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} finally { } finally {
try { try {
if(rset != null) { if (rset != null) {
rset.close(); rset.close();
} }
if(stmt != null) { if (stmt != null) {
stmt.close(); stmt.close();
} }
} catch (SQLException e) { } catch (SQLException e) {
@ -390,25 +391,25 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql); NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql);
if(fecVendaInicio != null) { if (fecVendaInicio != null) {
stmt.setTimestamp("fecInicio", fecVendaInicio); stmt.setTimestamp("fecInicio", fecVendaInicio);
} }
if(fecVendaFinal != null) { if (fecVendaFinal != null) {
stmt.setTimestamp("fecFinal", fecVendaFinal); stmt.setTimestamp("fecFinal", fecVendaFinal);
} }
if(fecPacoteInicio != null) { if (fecPacoteInicio != null) {
stmt.setTimestamp("fecViajeInicio", fecPacoteInicio); stmt.setTimestamp("fecViajeInicio", fecPacoteInicio);
} }
if(fecPacoteFinal != null) { if (fecPacoteFinal != null) {
stmt.setTimestamp("fecViajeFinal", fecPacoteFinal); stmt.setTimestamp("fecViajeFinal", fecPacoteFinal);
} }
if (empresaId != null && empresaId > 0){ if (empresaId != null && empresaId > 0) {
stmt.setInt("empresaId", empresaId); stmt.setInt("empresaId", empresaId);
} }
if(origenId != null) { if (origenId != null) {
stmt.setInt("origenId", origenId); stmt.setInt("origenId", origenId);
} }
if(destinoId != null) { if (destinoId != null) {
stmt.setInt("destinoId", destinoId); stmt.setInt("destinoId", destinoId);
} }
@ -419,53 +420,53 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
StringBuilder sQuery = new StringBuilder(); StringBuilder sQuery = new StringBuilder();
sQuery.append("SELECT DES.CVEPARADA AS CVEDESTINO, ORI.CVEPARADA AS CVEORIGEM, ORI.DESCPARADA AS ORIGEM, DES.DESCPARADA AS DESTINO, ") 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("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("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(NVL(B.DESCUENTOAMPARADO,0)) AS DESCONTO ") .append("SUM(B.IMPORTEOUTROS) AS SIMPORTEOUTROS, SUM(B.IMPORTESEGURO) AS SIMPORTESEGURO, SUM(B.PRECIOBASE) AS SPRECIOBASE, SUM(NVL(B.DESCUENTOAMPARADO,0)) AS DESCONTO ")
.append("FROM BOLETO B ") .append("FROM BOLETO B ")
.append("LEFT JOIN PARADA ORI ON ORI.PARADA_ID = B.ORIGEN_ID ") .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 PARADA DES ON DES.PARADA_ID = B.DESTINO_ID ")
.append("LEFT JOIN CATEGORIA CAT ON CAT.CATEGORIA_ID = B.CATEGORIA_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("LEFT JOIN RUTA R ON R.RUTA_ID = B.RUTA_ID ")
.append("WHERE B.ACTIVO = 1 "); .append("WHERE B.ACTIVO = 1 ");
if(!cancelado) { if (!cancelado) {
sQuery.append("AND B.INDSTATUSBOLETO = 'V' ") sQuery.append("AND B.INDSTATUSBOLETO = 'V' ")
.append("AND B.MOTIVOCANCELACION_ID IS NULL "); .append("AND B.MOTIVOCANCELACION_ID IS NULL ");
} else { } else {
sQuery.append("AND B.MOTIVOCANCELACION_ID IS NOT NULL "); sQuery.append("AND B.MOTIVOCANCELACION_ID IS NOT NULL ");
} }
if (empresaId != null && empresaId > 0){ if (empresaId != null && empresaId > 0) {
sQuery.append("AND B.EMPRESACORRIDA_ID = :empresaId "); sQuery.append("AND B.EMPRESACORRIDA_ID = :empresaId ");
} }
if(origenId != null) { if (origenId != null) {
sQuery.append("AND B.ORIGEN_ID = :origenId "); sQuery.append("AND B.ORIGEN_ID = :origenId ");
} }
if(destinoId != null) { if (destinoId != null) {
sQuery.append("AND B.DESTINO_ID = :destinoId "); sQuery.append("AND B.DESTINO_ID = :destinoId ");
} }
if(fecVendaInicio != null) { if (fecVendaInicio != null) {
sQuery.append("AND B.FECHORVENTA >= :fecInicio "); sQuery.append("AND B.FECHORVENTA >= :fecInicio ");
} }
if(fecVendaFinal != null) { if (fecVendaFinal != null) {
sQuery.append("AND B.FECHORVENTA <= :fecFinal "); sQuery.append("AND B.FECHORVENTA <= :fecFinal ");
} }
if(fecPacoteInicio != null) { if (fecPacoteInicio != null) {
sQuery.append("AND B.FECHORVIAJE >= :fecViajeInicio "); sQuery.append("AND B.FECHORVIAJE >= :fecViajeInicio ");
} }
if(fecPacoteFinal != null) { if (fecPacoteFinal != null) {
sQuery.append("AND B.FECHORVIAJE <= :fecViajeFinal "); 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' ") 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' "); .append("ORDER BY DES.CVEPARADA, ORI.CVEPARADA, ORI.DESCPARADA, DES.DESCPARADA, CAT.DESCCATEGORIA, R.NUMRUTA, R.DESCRUTA, NULL, 1, NULL, 'AVULSO' ");
return sQuery.toString(); return sQuery.toString();
} }
@ -478,7 +479,7 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
stmt = carregarNamedParameterStatementVendasAvulsas(conexao, true); stmt = carregarNamedParameterStatementVendasAvulsas(conexao, true);
rset = stmt.executeQuery(); rset = stmt.executeQuery();
if(lsDadosRelatorio == null) { if (lsDadosRelatorio == null) {
lsDadosRelatorio = new ArrayList<RelatorioVendasPacotesBoletosBean>(); lsDadosRelatorio = new ArrayList<RelatorioVendasPacotesBoletosBean>();
} }
@ -486,13 +487,13 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
RelatorioVendasPacotesBoletosBean relatorioVendasBoletosBean = carregarRelatorioVendasBoletosBean(rset); RelatorioVendasPacotesBoletosBean relatorioVendasBoletosBean = carregarRelatorioVendasBoletosBean(rset);
Integer idx = carregarIndice(relatorioVendasBoletosBean); Integer idx = carregarIndice(relatorioVendasBoletosBean);
if(idx > -1) { if (idx > -1) {
relatorioVendasBoletosBean = lsDadosRelatorio.get(idx); relatorioVendasBoletosBean = lsDadosRelatorio.get(idx);
} }
relatorioVendasBoletosBean.setRelatorioVendasPacotesBoletosItemBeansCancelados(carregarItens(rset, relatorioVendasBoletosBean, relatorioVendasBoletosBean.getRelatorioVendasPacotesBoletosItemBeansCancelados(), true)); relatorioVendasBoletosBean.setRelatorioVendasPacotesBoletosItemBeansCancelados(carregarItens(rset, relatorioVendasBoletosBean, relatorioVendasBoletosBean.getRelatorioVendasPacotesBoletosItemBeansCancelados(), true));
if(idx > -1) { if (idx > -1) {
lsDadosRelatorio.set(idx, relatorioVendasBoletosBean); lsDadosRelatorio.set(idx, relatorioVendasBoletosBean);
} else { } else {
lsDadosRelatorio.add(relatorioVendasBoletosBean); lsDadosRelatorio.add(relatorioVendasBoletosBean);
@ -503,10 +504,10 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} finally { } finally {
try { try {
if(rset != null) { if (rset != null) {
rset.close(); rset.close();
} }
if(stmt != null) { if (stmt != null) {
stmt.close(); stmt.close();
} }
} catch (SQLException e) { } catch (SQLException e) {