Relatório por Empresa Corrida - Continuação (fixed bug #5458)

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@36492 d1611594-4594-4d17-8e1d-87c2c4800839
master
leonardo 2014-07-10 13:28:16 +00:00
parent cc25456045
commit 367f28c038
5 changed files with 51 additions and 5 deletions

View File

@ -31,8 +31,9 @@ public class RelatorioEmpresaCorrida extends Relatorio {
String fecInicio = parametros.get("fecInicio").toString() + " 00:00:00"; String fecInicio = parametros.get("fecInicio").toString() + " 00:00:00";
String fecFinal = parametros.get("fecFinal").toString() + " 23:59:59"; String fecFinal = parametros.get("fecFinal").toString() + " 23:59:59";
String empresa = parametros.get("empresa") != null ? parametros.get("empresa").toString() : "";
String sql = getSql(); String sql = getSql(empresa);
System.out.println(sql); System.out.println(sql);
@ -42,7 +43,9 @@ public class RelatorioEmpresaCorrida extends Relatorio {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
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("")){
stmt.setInt("empresa_id", Integer.parseInt(empresa));
}
rset = stmt.executeQuery(); rset = stmt.executeQuery();
lsDadosRelatorio = new ArrayList<RelatorioEmpresaCorridaBean>(); lsDadosRelatorio = new ArrayList<RelatorioEmpresaCorridaBean>();
@ -78,7 +81,7 @@ public class RelatorioEmpresaCorrida extends Relatorio {
protected void processaParametros() throws Exception { protected void processaParametros() throws Exception {
} }
private String getSql() { private String getSql(String empresa) {
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
sql.append("SELECT DISTINCT empresa_id, "); sql.append("SELECT DISTINCT empresa_id, ");
@ -161,6 +164,9 @@ public class RelatorioEmpresaCorrida extends Relatorio {
sql.append(" AND d.parada_id = b.destino_id "); sql.append(" AND d.parada_id = b.destino_id ");
sql.append(" AND b.motivocancelacion_id IS NULL "); sql.append(" AND b.motivocancelacion_id IS NULL ");
sql.append(" AND b.empresacorrida_id = empresa_id "); sql.append(" AND b.empresacorrida_id = empresa_id ");
if (empresa != null && !empresa.isEmpty()){
sql.append(" AND empresa_id = :empresa_id ");
}
sql.append(" AND b.fechorventa BETWEEN :fecInicio AND :fecFinal "); sql.append(" AND b.fechorventa BETWEEN :fecInicio AND :fecFinal ");
sql.append("ORDER BY empresa_id, "); sql.append("ORDER BY empresa_id, ");
sql.append(" linea "); sql.append(" linea ");

View File

@ -2,6 +2,7 @@ package com.rjconsultores.ventaboletos.web.gui.controladores.relatorios;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import javax.sql.DataSource; import javax.sql.DataSource;
@ -15,9 +16,11 @@ 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.relatorios.impl.RelatorioEmpresaOnibus; import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioEmpresaCorrida; import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioEmpresaCorrida;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
import com.rjconsultores.ventaboletos.service.EmpresaService;
import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar;
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
@Controller("relatorioEmpresaCorridaController") @Controller("relatorioEmpresaCorridaController")
@ -28,17 +31,27 @@ public class RelatorioEmpresaCorridaController extends MyGenericForwardComposer
@Autowired @Autowired
private DataSource dataSource; private DataSource dataSource;
@Autowired
private EmpresaService empresaService;
private Datebox datInicial; private Datebox datInicial;
private Datebox datFinal; private Datebox datFinal;
private MyComboboxEstandar cmbEmpresa;
private List<Empresa> lsEmpresas;
private void executarRelatorio() throws Exception { private void executarRelatorio() throws Exception {
Map<String, Object> parametros = new HashMap<String, Object>(); Map<String, Object> parametros = new HashMap<String, Object>();
Empresa empresa = cmbEmpresa.getSelectedItem() != null ? (Empresa)cmbEmpresa.getSelectedItem().getValue() : null;
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
parametros.put("fecInicio", sdf.format(this.datInicial.getValue())); parametros.put("fecInicio", sdf.format(this.datInicial.getValue()));
parametros.put("fecFinal", sdf.format(this.datFinal.getValue())); parametros.put("fecFinal", sdf.format(this.datFinal.getValue()));
if (empresa != null){
parametros.put("empresa", empresa.getEmpresaId());
}
parametros.put("TITULO", Labels.getLabel("relatorioEmpresaCorridaController.window.title")); parametros.put("TITULO", Labels.getLabel("relatorioEmpresaCorridaController.window.title"));
Relatorio relatorio = new RelatorioEmpresaCorrida(parametros, dataSource.getConnection()); Relatorio relatorio = new RelatorioEmpresaCorrida(parametros, dataSource.getConnection());
@ -57,7 +70,24 @@ public class RelatorioEmpresaCorridaController extends MyGenericForwardComposer
@Override @Override
public void doAfterCompose(Component comp) throws Exception { public void doAfterCompose(Component comp) throws Exception {
lsEmpresas = empresaService.obtenerTodos();
super.doAfterCompose(comp); super.doAfterCompose(comp);
} }
public MyComboboxEstandar getCmbEmpresa() {
return cmbEmpresa;
}
public void setCmbEmpresa(MyComboboxEstandar cmbEmpresa) {
this.cmbEmpresa = cmbEmpresa;
}
public List<Empresa> getLsEmpresas() {
return lsEmpresas;
}
public void setLsEmpresas(List<Empresa> lsEmpresas) {
this.lsEmpresas = lsEmpresas;
}
} }

View File

@ -300,6 +300,7 @@ relatorioAproveitamentoController.btnBuscarServico.label = Buscar servicio
relatorioEmpresaCorridaController.window.title=Reporte Empresa Corrida relatorioEmpresaCorridaController.window.title=Reporte Empresa Corrida
relatorioEmpresaCorridaController.lbDataIni.value=Fecha Inicio relatorioEmpresaCorridaController.lbDataIni.value=Fecha Inicio
relatorioEmpresaCorridaController.lbDataFin.value=Fecha Final relatorioEmpresaCorridaController.lbDataFin.value=Fecha Final
relatorioEmpresaCorridaController.lbEmpresa.value=Empresa
# Relatorio Empresa Onibus # Relatorio Empresa Onibus
relatorioEmpresaOnibusController.window.title=Reporte Empresa Onibus relatorioEmpresaOnibusController.window.title=Reporte Empresa Onibus

View File

@ -305,6 +305,7 @@ relatorioAproveitamentoController.btnBuscarServico.label = Buscar Serviço
relatorioEmpresaCorridaController.window.title=Relatório Empresa Corrida relatorioEmpresaCorridaController.window.title=Relatório Empresa Corrida
relatorioEmpresaCorridaController.lbDataIni.value=Data Inicial relatorioEmpresaCorridaController.lbDataIni.value=Data Inicial
relatorioEmpresaCorridaController.lbDataFin.value=Data Final relatorioEmpresaCorridaController.lbDataFin.value=Data Final
relatorioEmpresaCorridaController.lbEmpresa.value=Empresa
# Relatorio Empresa Onibus # Relatorio Empresa Onibus
relatorioEmpresaOnibusController.window.title=Relatório Empresa Ônibus relatorioEmpresaOnibusController.window.title=Relatório Empresa Ônibus

View File

@ -30,6 +30,14 @@
format="dd/MM/yyyy" lenient="false" constraint="no empty" format="dd/MM/yyyy" lenient="false" constraint="no empty"
maxlength="10" /> maxlength="10" />
</row> </row>
<row>
<label
value="${c:l('relatorioEmpresaCorridaController.lbEmpresa.value')}" />
<combobox id="cmbEmpresa"
use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar"
mold="rounded" buttonVisible="true"
width="70%" model="@{winFiltroRelatorioEmpresaCorrida$composer.lsEmpresas}" />
</row>
</rows> </rows>
</grid> </grid>
<toolbar> <toolbar>