fixed bug #7278 - Relatório Gratuidade: criação de filtros de origem, destino e tipo de gratuidade

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@54299 d1611594-4594-4d17-8e1d-87c2c4800839
master
frederico 2016-03-28 17:46:49 +00:00
parent b9233fe55a
commit ace0c68246
5 changed files with 113 additions and 11 deletions

View File

@ -35,8 +35,11 @@ public class RelatorioGratuidade extends Relatorio {
String empresa = parametros.get("empresa") != null ? parametros.get("empresa").toString() : ""; String empresa = parametros.get("empresa") != null ? parametros.get("empresa").toString() : "";
String agencia = parametros.get("agencia") != null ? parametros.get("agencia").toString() : ""; String agencia = parametros.get("agencia") != null ? parametros.get("agencia").toString() : "";
String ruta = parametros.get("ruta") != null ? parametros.get("ruta").toString() : ""; String ruta = parametros.get("ruta") != null ? 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() : "";
String sql = getSql(empresa, agencia, ruta, fecInicio, fecFinal); String sql = getSql(empresa, agencia, ruta, fecInicio, fecFinal, origem, destino, categoria);
System.out.println(sql); System.out.println(sql);
@ -44,15 +47,24 @@ public class RelatorioGratuidade extends Relatorio {
NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql); NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql);
stmt.setTimestamp("fecInicio", new java.sql.Timestamp(sdf.parse(fecInicio).getTime())); stmt.setTimestamp("fecInicio", new java.sql.Timestamp(sdf.parse(fecInicio).getTime()));
stmt.setTimestamp("fecFinal", new java.sql.Timestamp(sdf.parse(fecFinal).getTime())); stmt.setTimestamp("fecFinal", new java.sql.Timestamp(sdf.parse(fecFinal).getTime()));
if (empresa != null && !empresa.equals("")){ if(empresa != null && !empresa.equals("")){
stmt.setInt("empresa_id", Integer.parseInt(empresa)); stmt.setInt("empresa_id", Integer.parseInt(empresa));
} }
if (agencia != null && !agencia.equals("")){ if(agencia != null && !agencia.equals("")){
stmt.setInt("puntoventa_id", Integer.parseInt(agencia)); stmt.setInt("puntoventa_id", Integer.parseInt(agencia));
} }
if (ruta != null && !ruta.equals("")){ if(ruta != null && !ruta.equals("")){
stmt.setInt("ruta_id", Integer.parseInt(ruta)); 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(categoria != null && !categoria.equals("")){
stmt.setInt("categoria_id", Integer.parseInt(categoria));
}
ResultSet rset = null; ResultSet rset = null;
@ -97,7 +109,7 @@ public class RelatorioGratuidade extends Relatorio {
protected void processaParametros() throws Exception { protected void processaParametros() throws Exception {
} }
private String getSql(String empresa, String agencia, String ruta, String fecInicio, String fecFinal) { private String getSql(String empresa, String agencia, String ruta, String fecInicio, String fecFinal, String origem, String destino, String categoria) {
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
sql.append("SELECT b.feccorrida, ori.cveparada origen, des.cveparada destino, "); sql.append("SELECT b.feccorrida, ori.cveparada origen, des.cveparada destino, ");
sql.append("b.numkmviaje, r.descruta, b.corrida_id, b.fechorviaje, "); sql.append("b.numkmviaje, r.descruta, b.corrida_id, b.fechorviaje, ");
@ -133,6 +145,15 @@ public class RelatorioGratuidade extends Relatorio {
if (!ruta.isEmpty()){ if (!ruta.isEmpty()){
sql.append(" AND b.ruta_id = :ruta_id "); sql.append(" AND b.ruta_id = :ruta_id ");
} }
if(!origem.isEmpty()){
sql.append(" AND ori.parada_id = :origem_id ");
}
if(!destino.isEmpty()){
sql.append(" AND des.parada_id = :destino_id ");
}
if(!categoria.isEmpty()){
sql.append(" AND c.categoria_id = :categoria_id ");
}
return sql.toString(); return sql.toString();
} }

View File

@ -16,15 +16,19 @@ import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Event;
import org.zkoss.zul.Datebox; import org.zkoss.zul.Datebox;
import com.rjconsultores.ventaboletos.entidad.Categoria;
import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.Parada;
import com.rjconsultores.ventaboletos.entidad.PuntoVenta; import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
import com.rjconsultores.ventaboletos.entidad.Ruta; import com.rjconsultores.ventaboletos.entidad.Ruta;
import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioGratuidade; import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioGratuidade;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
import com.rjconsultores.ventaboletos.service.CategoriaService;
import com.rjconsultores.ventaboletos.service.EmpresaService; import com.rjconsultores.ventaboletos.service.EmpresaService;
import com.rjconsultores.ventaboletos.service.PuntoVentaService; import com.rjconsultores.ventaboletos.service.PuntoVentaService;
import com.rjconsultores.ventaboletos.service.RutaService; import com.rjconsultores.ventaboletos.service.RutaService;
import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar; import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar;
import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxParada;
import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxPuntoVenta; import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxPuntoVenta;
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
@ -36,24 +40,27 @@ public class RelatorioGratuidadeController extends MyGenericForwardComposer {
@Autowired @Autowired
private DataSource dataSourceRead; private DataSource dataSourceRead;
@Autowired @Autowired
private EmpresaService empresaService; private EmpresaService empresaService;
@Autowired @Autowired
private PuntoVentaService puntoVentaService; private PuntoVentaService puntoVentaService;
@Autowired @Autowired
private RutaService rutaService; private RutaService rutaService;
@Autowired
private CategoriaService categoriaService;
private Datebox datInicial; private Datebox datInicial;
private Datebox datFinal; private Datebox datFinal;
private MyComboboxEstandar cmbTeste; private MyComboboxEstandar cmbTeste;
private MyComboboxPuntoVenta cmbAgencia; private MyComboboxPuntoVenta cmbAgencia;
private MyComboboxEstandar cmbLinha; private MyComboboxEstandar cmbLinha;
private MyComboboxParada cmbOrigem;
private MyComboboxParada cmbDestino;
private MyComboboxEstandar cmbTipoGratuidade;
private List<Empresa> lsEmpresas; private List<Empresa> lsEmpresas;
private List<Ruta> lsLinhas; private List<Ruta> lsLinhas;
private List<Categoria> lsCategorias;
private void executarRelatorio() throws Exception { private void executarRelatorio() throws Exception {
@ -72,6 +79,15 @@ public class RelatorioGratuidadeController extends MyGenericForwardComposer {
if (cmbLinha.getSelectedIndex() != -1) { if (cmbLinha.getSelectedIndex() != -1) {
parametros.put("ruta", ((Ruta) cmbLinha.getSelectedItem().getValue()).getRutaId()); parametros.put("ruta", ((Ruta) cmbLinha.getSelectedItem().getValue()).getRutaId());
} }
if(cmbOrigem.getSelectedIndex() != -1){
parametros.put("origem", ((Parada) cmbOrigem.getSelectedItem().getValue()).getParadaId());
}
if(cmbDestino.getSelectedIndex() != -1){
parametros.put("destino", ((Parada) cmbDestino.getSelectedItem().getValue()).getParadaId());
}
if(cmbTipoGratuidade.getSelectedIndex() != -1){
parametros.put("categoria", ((Categoria) cmbTipoGratuidade.getSelectedItem().getValue()).getCategoriaId());
}
parametros.put("TITULO", Labels.getLabel("relatorioGratuidadeController.window.title")); parametros.put("TITULO", Labels.getLabel("relatorioGratuidadeController.window.title"));
@ -94,6 +110,7 @@ public class RelatorioGratuidadeController extends MyGenericForwardComposer {
lsLinhas = rutaService.obtenerTodos(); lsLinhas = rutaService.obtenerTodos();
lsEmpresas = empresaService.obtenerTodos(); lsEmpresas = empresaService.obtenerTodos();
lsCategorias = categoriaService.obtenerTodos();
super.doAfterCompose(comp); super.doAfterCompose(comp);
} }
@ -114,6 +131,14 @@ public class RelatorioGratuidadeController extends MyGenericForwardComposer {
this.lsLinhas = lsLinhas; this.lsLinhas = lsLinhas;
} }
public List<Categoria> getLsCategorias() {
return lsCategorias;
}
public void setLsCategorias(List<Categoria> lsCategorias) {
this.lsCategorias = lsCategorias;
}
public Datebox getDatInicial() { public Datebox getDatInicial() {
return datInicial; return datInicial;
} }
@ -146,4 +171,28 @@ public class RelatorioGratuidadeController extends MyGenericForwardComposer {
this.cmbLinha = cmbLinha; this.cmbLinha = cmbLinha;
} }
public MyComboboxParada getCmbOrigem() {
return cmbOrigem;
}
public void setCmbOrigem(MyComboboxParada cmbOrigem) {
this.cmbOrigem = cmbOrigem;
}
public MyComboboxParada getCmbDestino() {
return cmbDestino;
}
public void setCmbDestino(MyComboboxParada cmbDestino) {
this.cmbDestino = cmbDestino;
}
public MyComboboxEstandar getCmbTipoGratuidade() {
return cmbTipoGratuidade;
}
public void setCmbTipoGratuidade(MyComboboxEstandar cmbTipoGratuidade) {
this.cmbTipoGratuidade = cmbTipoGratuidade;
}
} }

View File

@ -5754,6 +5754,9 @@ relatorioGratuidadeController.window.title = Reporte Gratuidade
relatorioGratuidadeController.lbEmpresa.value = Empresa relatorioGratuidadeController.lbEmpresa.value = Empresa
relatorioGratuidadeController.lbAgencia.value = Punto Venta relatorioGratuidadeController.lbAgencia.value = Punto Venta
relatorioGratuidadeController.lbLinhas.value = Ruta relatorioGratuidadeController.lbLinhas.value = Ruta
relatorioGratuidadeController.lbOrigem.value = Origem
relatorioGratuidadeController.lbDestino.value = Destino
relatorioGratuidadeController.lbTipoGratuidade.value = Tipo de Gratuidade
relatorioGratuidadeController.lbDataIni.value = Fecha Inicio relatorioGratuidadeController.lbDataIni.value = Fecha Inicio
relatorioGratuidadeController.lbDataFin.value = Fecha Final relatorioGratuidadeController.lbDataFin.value = Fecha Final

View File

@ -5840,6 +5840,9 @@ relatorioGratuidadeController.window.title = Relatório Gratuidade
relatorioGratuidadeController.lbEmpresa.value = Empresa relatorioGratuidadeController.lbEmpresa.value = Empresa
relatorioGratuidadeController.lbAgencia.value = Agência relatorioGratuidadeController.lbAgencia.value = Agência
relatorioGratuidadeController.lbLinhas.value = Linha relatorioGratuidadeController.lbLinhas.value = Linha
relatorioGratuidadeController.lbOrigem.value = Origem
relatorioGratuidadeController.lbDestino.value = Destino
relatorioGratuidadeController.lbTipoGratuidade.value = Tipo de Gratuidade
relatorioGratuidadeController.lbDataIni.value = Data Inicio relatorioGratuidadeController.lbDataIni.value = Data Inicio
relatorioGratuidadeController.lbDataFin.value = Data Final relatorioGratuidadeController.lbDataFin.value = Data Final

View File

@ -7,7 +7,7 @@
<zk xmlns="http://www.zkoss.org/2005/zul"> <zk xmlns="http://www.zkoss.org/2005/zul">
<window id="winFiltroRelatorioGratuidade" <window id="winFiltroRelatorioGratuidade"
apply="${relatorioGratuidadeController}" apply="${relatorioGratuidadeController}"
contentStyle="overflow:auto" height="225px" width="550px" contentStyle="overflow:auto" height="320px" width="550px"
border="normal"> border="normal">
<grid fixedLayout="true"> <grid fixedLayout="true">
@ -40,6 +40,32 @@
use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar" use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar"
model="@{winFiltroRelatorioGratuidade$composer.lsLinhas}" /> model="@{winFiltroRelatorioGratuidade$composer.lsLinhas}" />
</row> </row>
<row>
<label
value="${c:l('relatorioGratuidadeController.lbOrigem.value')}" />
<combobox id="cmbOrigem" width="70%"
maxlength="60" mold="rounded" buttonVisible="true"
use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxParada"/>
</row>
<row>
<label
value="${c:l('relatorioGratuidadeController.lbDestino.value')}" />
<combobox id="cmbDestino" width="70%"
maxlength="60" mold="rounded" buttonVisible="true"
use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxParada"/>
</row>
<row>
<label
value="${c:l('relatorioGratuidadeController.lbTipoGratuidade.value')}" />
<combobox id="cmbTipoGratuidade" width="70%"
maxlength="60" mold="rounded" buttonVisible="true"
use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar"
model="@{winFiltroRelatorioGratuidade$composer.lsCategorias}"/>
</row>
<row> <row>
<label <label
value="${c:l('relatorioGratuidadeController.lbDataIni.value')}" /> value="${c:l('relatorioGratuidadeController.lbDataIni.value')}" />