From 17b1dd9111c764731b87ce6734d487378edd6b6c Mon Sep 17 00:00:00 2001 From: walace Date: Thu, 15 Feb 2018 19:45:46 +0000 Subject: [PATCH] fixes bug #10624 git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@78952 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../relatorios/impl/RelatorioGratuidade.java | 53 ++++++++-- .../RelatorioGratuidadeController.java | 55 +++++++++++ .../relatorios/filtroRelatorioGratuidade.zul | 99 ++++++++++++------- 3 files changed, 164 insertions(+), 43 deletions(-) diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioGratuidade.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioGratuidade.java index 8f5e3ba49..835406823 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioGratuidade.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioGratuidade.java @@ -49,13 +49,16 @@ public class RelatorioGratuidade extends Relatorio { } String empresa = parametros.get("empresa") != null ? parametros.get("empresa").toString() : ""; String agencia = parametros.get("agencia") != null ? parametros.get("agencia").toString() : ""; + String ruta = parametros.get("ruta") != null && !parametros.get("ruta").equals(-1) ? parametros.get("ruta").toString() : ""; + String origem = parametros.get("origem") != null ? parametros.get("origem").toString() : ""; + String destino = parametros.get("destino") != null ? parametros.get("destino").toString() : ""; String categoria = parametros.get("categoria") != null ? parametros.get("categoria").toString() : ""; + orgaoConcedenteId = parametros.get("orgao_concedente_id") != null ? (Integer) parametros.get("orgao_concedente_id") : null; + - String sql = getSql(empresa, agencia, fecInicioViagem, fecFinalViagem, fecInicioVenda, fecFinalVenda, categoria); - - System.out.println(sql); - + String sql = getSql(empresa, agencia, ruta, fecInicioViagem, fecFinalViagem, fecInicioVenda, fecFinalVenda, origem, destino, categoria); + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"); NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql); if (fecInicioViagem != null) { @@ -76,9 +79,15 @@ public class RelatorioGratuidade extends Relatorio { if(agencia != null && !agencia.equals("")){ stmt.setInt("puntoventa_id", Integer.parseInt(agencia)); } -// if(categoria != null && !categoria.equals("")){ -// stmt.setInt("categoria_id", Integer.parseInt(categoria)); -// } + if(ruta != null && !ruta.equals("")){ + stmt.setInt("ruta_id", Integer.parseInt(ruta)); + } + if(origem != null && !origem.equals("")){ + stmt.setInt("origem_id", Integer.parseInt(origem)); + } + if(destino != null && !destino.equals("")){ + stmt.setInt("destino_id", Integer.parseInt(destino)); + } if(orgaoConcedenteId != null){ stmt.setInt("orgao_concedente_id", orgaoConcedenteId); } @@ -146,7 +155,7 @@ public class RelatorioGratuidade extends Relatorio { protected void processaParametros() throws Exception { } - private String getSql(String empresa, String agencia, String fecInicioViagem, String fecFinalViagem, String fecInicioVenda, String fecFinalVenda, String categoria) { + private String getSql(String empresa, String agencia, String ruta, String fecInicioViagem, String fecFinalViagem, String fecInicioVenda, String fecFinalVenda, String origem, String destino, String categoria) { StringBuilder sb = new StringBuilder(); @@ -226,9 +235,21 @@ public class RelatorioGratuidade extends Relatorio { if (!agencia.isEmpty() && !agencia.equals("-1")){ sb.append(" AND b.puntoventa_id = :puntoventa_id "); } + if (!ruta.isEmpty() && !ruta.equals("-1")){ + sb.append(" AND b.ruta_id = :ruta_id "); + } + if(!origem.isEmpty()){ + sb.append(" AND ori.parada_id = :origem_id "); + } + if(!destino.isEmpty()){ + sb.append(" AND des.parada_id = :destino_id "); + } if(!categoria.isEmpty()){ sb.append(" AND ca.categoria_id in ("+ categoria +") "); } + if(orgaoConcedenteId != null){ + sb.append(" AND r.orgaoconcedente_id = :orgao_concedente_id "); + } sb.append(" "); sb.append(" UNION ALL "); sb.append(" "); @@ -302,10 +323,22 @@ public class RelatorioGratuidade extends Relatorio { sb.append("AND c.empresacorrida_id = :empresa_id "); } if (!agencia.isEmpty() && !agencia.equals("-1")){ - sb.append(" AND c.puntoventa_id = :puntoventa_id "); + sb.append("AND c.puntoventa_id = :puntoventa_id "); + } + if (!ruta.isEmpty() && !ruta.equals("-1")){ + sb.append("AND c.ruta_id = :ruta_id "); + } + if(!origem.isEmpty()){ + sb.append("AND ori.parada_id = :origem_id "); + } + if(!destino.isEmpty()){ + sb.append("AND des.parada_id = :destino_id "); } if(!categoria.isEmpty()){ - sb.append(" AND ca.categoria_id in ("+ categoria +") "); + sb.append("AND ca.categoria_id in ("+ categoria +") "); + } + if(orgaoConcedenteId != null){ + sb.append("AND r.orgaoconcedente_id = :orgao_concedente_id "); } sb.append(") "); sb.append("ORDER BY 5,15"); diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioGratuidadeController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioGratuidadeController.java index cfe705a51..5cc547836 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioGratuidadeController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioGratuidadeController.java @@ -46,6 +46,10 @@ public class RelatorioGratuidadeController extends MyGenericForwardComposer { private EmpresaService empresaService; @Autowired private CategoriaService categoriaService; + @Autowired + private RutaService rutaService; + @Autowired + private OrgaoConcedenteService orgaocConcedenteService; private Datebox datInicialViagem; private Datebox datFinalViagem; @@ -54,12 +58,18 @@ public class RelatorioGratuidadeController extends MyGenericForwardComposer { private MyComboboxEstandar cmbEmpresa; private MyComboboxPuntoVenta cmbAgencia; private MyComboboxEstandar cmbTipoGratuidade; + private MyComboboxEstandar cmbOrgaoConcedente; + private MyComboboxEstandar cmbLinha; + private MyComboboxParada cmbOrigem; + private MyComboboxParada cmbDestino; private List lsEmpresas; private List lsCategorias; + private List lsLinhas; private MyListbox selectedTipoGratuidadeList; private List listSelectedTipoGratuidade; + private List lsOrgaoConcedente; public void onClick$btnRemoveTipoGratuidade(Event ev) throws InterruptedException { @@ -146,6 +156,34 @@ public class RelatorioGratuidadeController extends MyGenericForwardComposer { if (cmbAgencia.getSelectedIndex() != -1) { parametros.put("agencia", ((PuntoVenta) cmbAgencia.getSelectedItem().getValue()).getPuntoventaId()); } + if (cmbLinha.getSelectedItem() != null) { + if (!cmbLinha.getSelectedItem().getValue().equals("-1")) { + parametros.put("ruta", ((Ruta) cmbLinha.getSelectedItem().getValue()).getRutaId()); + } + } + if (cmbOrigem.getSelectedItem() != null) { + if (!cmbOrigem.getSelectedItem().getValue().equals("-1")) { + parametros.put("origem", ((Parada) cmbOrigem.getSelectedItem().getValue()).getParadaId()); + } + } + if (cmbDestino.getSelectedItem() != null) { + if (!cmbDestino.getSelectedItem().getValue().equals("-1")) { + parametros.put("destino", ((Parada) cmbDestino.getSelectedItem().getValue()).getParadaId()); + } + } + if (cmbTipoGratuidade.getSelectedItem() != null) { + if (!cmbTipoGratuidade.getSelectedItem().getValue().equals("-1")) { + parametros.put("categoria", ((Categoria) cmbTipoGratuidade.getSelectedItem().getValue()).getCategoriaId()); + } + } + + if (cmbOrgaoConcedente.getSelectedItem() != null) { + if(!cmbOrgaoConcedente.getSelectedItem().getValue().equals("-1")){ + OrgaoConcedente orgaoConcedente = (OrgaoConcedente) cmbOrgaoConcedente.getSelectedItem().getValue(); + parametros.put("orgao_concedente_id", orgaoConcedente.getOrgaoConcedenteId()); + parametros.put("orgao_concedente_desc", orgaoConcedente.getDescOrgao()); + } + } if(cmbTipoGratuidade.getSelectedIndex() != -1){ if (listSelectedTipoGratuidade.size() > 0) { String categoriasExpression = null; @@ -179,8 +217,10 @@ public class RelatorioGratuidadeController extends MyGenericForwardComposer { public void doAfterCompose(Component comp) throws Exception { + lsLinhas = rutaService.obtenerTodos(); lsEmpresas = empresaService.obtenerTodos(); lsCategorias = categoriaService.obtenerTodos(); + lsOrgaoConcedente = orgaocConcedenteService.obtenerTodos(); listSelectedTipoGratuidade = new ArrayList(); super.doAfterCompose(comp); @@ -198,7 +238,14 @@ public class RelatorioGratuidadeController extends MyGenericForwardComposer { public List getLsCategorias() { return lsCategorias; } + public List getLsLinhas() { + return lsLinhas; + } + public void setLsLinhas(List lsLinhas) { + this.lsLinhas = lsLinhas; + } + public void setLsCategorias(List lsCategorias) { this.lsCategorias = lsCategorias; } @@ -227,6 +274,14 @@ public class RelatorioGratuidadeController extends MyGenericForwardComposer { this.datInicialVenda = datInicialVenda; } + public List getLsOrgaoConcedente() { + return lsOrgaoConcedente; + } + + public void setLsOrgaoConcedente(List lsOrgaoConcedente) { + this.lsOrgaoConcedente = lsOrgaoConcedente; + } + public Datebox getDatFinalVenda() { return datFinalVenda; } diff --git a/web/gui/relatorios/filtroRelatorioGratuidade.zul b/web/gui/relatorios/filtroRelatorioGratuidade.zul index a20f86712..255a0bc2e 100644 --- a/web/gui/relatorios/filtroRelatorioGratuidade.zul +++ b/web/gui/relatorios/filtroRelatorioGratuidade.zul @@ -6,9 +6,8 @@ + apply="${relatorioGratuidadeController}" contentStyle="overflow:auto" + height="460px" width="550px" border="normal"> @@ -19,7 +18,8 @@ - - @@ -65,25 +62,60 @@ + + - + + + + + + + + + + + + @@ -97,8 +129,8 @@