Relatório por Empresa corrida (fixed bug #5394)

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@36186 d1611594-4594-4d17-8e1d-87c2c4800839
master
leonardo 2014-06-23 13:53:36 +00:00
parent b37e837642
commit 4fce3d7538
10 changed files with 531 additions and 0 deletions

View File

@ -0,0 +1,97 @@
package com.rjconsultores.ventaboletos.relatorios.impl;
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.DataSource;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioEmpresaCorridaBean;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioLinhasHorarioBean;
import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement;
public class RelatorioEmpresaCorrida extends Relatorio {
private List<RelatorioEmpresaCorridaBean> lsDadosRelatorio;
public RelatorioEmpresaCorrida(Map<String, Object> parametros, Connection conexao) throws Exception {
super(parametros, conexao);
this.setCustomDataSource(new DataSource(this) {
@Override
public void initDados() throws Exception {
Connection conexao = this.relatorio.getConexao();
Map<String, Object> parametros = this.relatorio.getParametros();
@SuppressWarnings("unchecked")
String fecInicio = parametros.get("fecInicio").toString();
@SuppressWarnings("unchecked")
String fecFinal = parametros.get("fecFinal").toString();
String sql = getSql(fecInicio, fecFinal);
System.out.println(sql);
NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql);
ResultSet rset = null;
rset = stmt.executeQuery();
lsDadosRelatorio = new ArrayList<RelatorioEmpresaCorridaBean>();
while (rset.next()) {
RelatorioEmpresaCorridaBean empresaCorridaBean = new RelatorioEmpresaCorridaBean();
empresaCorridaBean.setCorridaId(rset.getInt("corridaId"));
empresaCorridaBean.setEmpresa(rset.getString("empresa"));
empresaCorridaBean.setCoche(Integer.parseInt(rset.getString("coche")));
empresaCorridaBean.setDestino(rset.getString("destino"));
empresaCorridaBean.setDia(rset.getDate("dia"));
empresaCorridaBean.setHora(rset.getString("hora"));
empresaCorridaBean.setKmts(rset.getInt("kmts"));
empresaCorridaBean.setOrigem(rset.getString("origem"));
lsDadosRelatorio.add(empresaCorridaBean);
}
if (lsDadosRelatorio.size() > 0) {
setLsDadosRelatorio(lsDadosRelatorio);
}
}
});
}
public void setLsDadosRelatorio(List<RelatorioEmpresaCorridaBean> lsDadosRelatorio) {
this.setCollectionDataSource(new JRBeanCollectionDataSource(lsDadosRelatorio));
this.lsDadosRelatorio = lsDadosRelatorio;
}
@Override
protected void processaParametros() throws Exception {
}
private String getSql(String fecInicio, String fecFinal) {
StringBuffer sql = new StringBuffer();
sql.append(" select c.corrida_Id corridaId, e.nombempresa empresa, c.feccorrida dia, a.numautobus coche, ");
sql.append(" o.cveparada origem, d.cveparada destino, ");
sql.append(" to_char(c.fechorsalida, 'HH24:MI') Hora, t.cantkmreal KMTS ");
sql.append(" from corrida c ");
sql.append(" left join parada o on o.parada_id = c.origen_id ");
sql.append(" left join parada d on d.parada_id = c.destino_id ");
sql.append(" left join tramo t on t.origen_id = c.origen_id and t.destino_id = c.destino_id ");
sql.append(" left join empresa e on e.empresa_id = c.empresacorrida_id ");
sql.append(" inner join autobus a on a.autobus_id = c.autobus_id ");
sql.append(" where extract(month from c.feccorrida) = 6 ");
sql.append(" and c.activo = 1 and c.feccorrida between to_date('" + fecInicio + "', 'DD/MM/YYYY') and to_date('" + fecFinal + "', 'DD/MM/YYYY') ");
sql.append(" order by e.nombempresa, c.feccorrida ");
return sql.toString();
}
}

View File

@ -0,0 +1,27 @@
#geral
msg.noData=Não foi possivel obter dados com os parâmetros informados.
msg.a=à
#Labels header
header.titulo.relatorio=Relatório por Empresa Corrida
header.periodo=Período:
header.data.hora=Data/Hora\:
header.pagina=Página\:
header.filtro=Filtro\:
header.filtro.servico=Serviço\:
header.filtro.linha=Linha\:
header.filtro.grupo=Grupo de Linhas\:
#Labels detail
detail.dia=Dia
detail.coche=Carro
detail.origen=PASSAGEIROS
detail.destino=PARÂMETROS OPERACIONAIS
detail.hora=Hora
detail.kmts=Kmts
detail.corridaId=Corrida
linhas=Linhas

View File

@ -0,0 +1,206 @@
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="RelatorioEmpresaCorrida" pageWidth="595" pageHeight="842" whenNoDataType="NoDataSection" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="94834362-0ecc-46da-b0a2-5cdee355da3e">
<property name="ireport.zoom" value="1.5"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="fecInicio" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<parameter name="NOMBEMPRESA" class="java.lang.String"/>
<parameter name="fecFinal" class="java.lang.String"/>
<parameter name="USUARIO_ID" class="java.lang.String"/>
<parameter name="LINHA_FILTRO" class="java.lang.String"/>
<parameter name="SERVICO_FILTRO" class="java.lang.String"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="dia" class="java.util.Date"/>
<field name="coche" class="java.lang.Integer"/>
<field name="origem" class="java.lang.String"/>
<field name="destino" class="java.lang.String"/>
<field name="hora" class="java.lang.String"/>
<field name="kmts" class="java.lang.Integer"/>
<field name="empresa" class="java.lang.String"/>
<field name="corridaId" class="java.lang.Integer"/>
<group name="empresa">
<groupExpression><![CDATA[$F{empresa}]]></groupExpression>
<groupHeader>
<band height="69">
<textField>
<reportElement uuid="09306494-79f1-44dd-9eed-c39684384bbf" x="0" y="33" width="231" height="20"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{empresa}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="e8355048-a037-4837-866b-e6cf7a3e90ed" x="122" y="53" width="56" height="15"/>
<textElement markup="none">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$R{detail.coche}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="edd89ef1-92d6-4b5f-b249-851532fad9df" x="373" y="53" width="37" height="15"/>
<textElement markup="none">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$R{detail.hora}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="73c02335-4bbe-44ba-9c73-1201ed6b3967" x="410" y="53" width="47" height="15"/>
<textElement markup="none">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$R{detail.kmts}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="d88253ec-b6d4-4e99-b677-3c1a0b273a81" x="61" y="53" width="61" height="15"/>
<textElement markup="none">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$R{detail.dia}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="569add1e-cb73-4278-b800-fa44631527f6" x="274" y="53" width="99" height="15"/>
<textElement markup="none">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$R{detail.destino}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="31387dbf-1cdc-4c27-992f-2e439abea576" x="178" y="53" width="96" height="15"/>
<textElement markup="none">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$R{detail.origen}]]></textFieldExpression>
</textField>
<line>
<reportElement uuid="76104c33-e003-4a38-98bb-9db4d0f8636b" x="0" y="53" width="555" height="1"/>
</line>
<line>
<reportElement uuid="97639de4-d619-4f05-9b3e-e615b643b778" x="0" y="68" width="555" height="1"/>
</line>
<textField>
<reportElement uuid="12ef050d-3938-4dd6-8e82-bfeca7adaa2a" x="0" y="54" width="61" height="15"/>
<textElement markup="none">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$R{detail.corridaId}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
</group>
<background>
<band splitType="Stretch"/>
</background>
<pageHeader>
<band height="60" splitType="Stretch">
<textField>
<reportElement uuid="e5d4714c-07cc-42ff-a7a8-76d6f6d3e716" x="0" y="20" width="49" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$R{header.periodo}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="66b2d0f6-2bf1-4bc7-9ec0-a34444e04d60" x="401" y="0" width="56" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$R{header.data.hora}]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement uuid="8ca68351-fc00-4f19-b94f-f2fd1f41964f" x="533" y="20" width="22" height="20"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="be1692e9-f130-4d08-9173-6ca3e4699030" x="467" y="20" width="42" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$R{header.pagina}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="4914d9e7-6ce8-4512-b1f8-13f3b572ac50" x="49" y="20" width="182" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$P{fecInicio} + " à " + $P{fecFinal}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="652312bd-292a-424d-a234-5f157e3699c6" x="0" y="0" width="231" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$R{header.titulo.relatorio}]]></textFieldExpression>
</textField>
<textField pattern="dd/MM/yyyy HH:mm">
<reportElement uuid="6f671365-868e-41a6-81ee-a308d1d91e1d" x="457" y="0" width="98" height="20"/>
<textElement textAlignment="Left"/>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="7548d623-fb6c-48d4-b8b7-504f5437a79a" x="509" y="20" width="24" height="20"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}+" de"]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band splitType="Stretch"/>
</columnHeader>
<detail>
<band height="17" splitType="Stretch">
<textField>
<reportElement uuid="c29b2244-5b3e-48a2-9adf-8e10ee2a3856" x="178" y="0" width="96" height="16"/>
<textElement textAlignment="Left">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{origem}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement uuid="3111776a-f727-4313-841c-55dabd804df4" x="373" y="0" width="37" height="16"/>
<textElement textAlignment="Left">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{hora}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="3343aea7-212b-4bd5-a29c-8dcab3cb7568" x="122" y="0" width="56" height="16"/>
<textElement textAlignment="Left">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{coche}]]></textFieldExpression>
</textField>
<textField pattern="dd/MM/yyyy" isBlankWhenNull="true">
<reportElement uuid="b36dbddb-2fa9-48a5-809e-0e15ad54c529" x="61" y="0" width="61" height="16"/>
<textElement textAlignment="Left">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{dia}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement uuid="4a68f71a-7be1-467a-b3eb-641a0c1f9a48" x="410" y="0" width="47" height="16"/>
<textElement textAlignment="Left">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{kmts}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement uuid="cee727cd-cbc7-41d0-8020-d70aa33d8c9f" x="274" y="0" width="99" height="16"/>
<textElement textAlignment="Left">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{destino}]]></textFieldExpression>
</textField>
<textField pattern="" isBlankWhenNull="true">
<reportElement uuid="9f731da4-307a-4409-a8d5-28b2c4c40fce" x="0" y="1" width="61" height="16"/>
<textElement textAlignment="Left">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{corridaId}]]></textFieldExpression>
</textField>
</band>
</detail>
<noData>
<band height="20">
<textField>
<reportElement uuid="5a6c1b7b-2242-4cf1-b957-723b906ee620" x="0" y="0" width="803" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$R{msg.noData}]]></textFieldExpression>
</textField>
</band>
</noData>
</jasperReport>

View File

@ -0,0 +1,62 @@
package com.rjconsultores.ventaboletos.relatorios.utilitarios;
import java.util.Date;
public class RelatorioEmpresaCorridaBean {
protected Integer corridaId;
protected String empresa;
protected Date dia;
protected Integer coche;
protected String origem;
protected String destino;
protected String hora;
protected Integer kmts;
public Date getDia() {
return dia;
}
public void setDia(Date dia) {
this.dia = dia;
}
public Integer getCoche() {
return coche;
}
public void setCoche(Integer coche) {
this.coche = coche;
}
public String getOrigem() {
return origem;
}
public void setOrigem(String origem) {
this.origem = origem;
}
public String getDestino() {
return destino;
}
public void setDestino(String destino) {
this.destino = destino;
}
public String getHora() {
return hora;
}
public void setHora(String hora) {
this.hora = hora;
}
public Integer getKmts() {
return kmts;
}
public void setKmts(Integer kmts) {
this.kmts = kmts;
}
public String getEmpresa() {
return empresa;
}
public void setEmpresa(String empresa) {
this.empresa = empresa;
}
public Integer getCorridaId() {
return corridaId;
}
public void setCorridaId(Integer corridaId) {
this.corridaId = corridaId;
}
}

View File

@ -0,0 +1,61 @@
package com.rjconsultores.ventaboletos.web.gui.controladores.relatorios;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;
import javax.sql.DataSource;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.zkoss.util.resource.Labels;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zul.Datebox;
import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioEmpresaCorrida;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
@Controller("relatorioEmpresaCorridaController")
@Scope("prototype")
public class RelatorioEmpresaCorridaController extends MyGenericForwardComposer {
private static final long serialVersionUID = 1L;
private static Logger log = Logger.getLogger(RelatorioEmpresaCorridaController.class);
@Autowired
private DataSource dataSource;
private Datebox datInicial;
private Datebox datFinal;
private void executarRelatorio() throws Exception {
Map<String, Object> parametros = new HashMap<String, Object>();
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
parametros.put("fecInicio", sdf.format(this.datInicial.getValue()));
parametros.put("fecFinal", sdf.format(this.datFinal.getValue()));
Relatorio relatorio = new RelatorioEmpresaCorrida(parametros, dataSource.getConnection());
Map<String, Object> args = new HashMap<String, Object>();
args.put("relatorio", relatorio);
openWindow("/component/reportView.zul",
Labels.getLabel("relatorioEmpresaCorridaController.window.title"), args, MODAL);
}
public void onClick$btnExecutarRelatorio(Event ev) throws Exception {
executarRelatorio();
}
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
}
}

View File

@ -0,0 +1,25 @@
package com.rjconsultores.ventaboletos.web.utilerias.menu.item.relatorios;
import org.zkoss.util.resource.Labels;
import com.rjconsultores.ventaboletos.web.utilerias.PantallaUtileria;
import com.rjconsultores.ventaboletos.web.utilerias.menu.DefaultItemMenuSistema;
public class ItemMenuRelatorioEmpresaCorrida extends DefaultItemMenuSistema {
public ItemMenuRelatorioEmpresaCorrida() {
super("indexController.mniRelatorioEmpresaCorrida.label");
}
@Override
public String getClaveMenu() {
return "COM.RJCONSULTORES.ADMINISTRACION.GUI.RELATORIOS.MENU.RELATORIOEMPRESACORRIDA";
}
@Override
public void ejecutar() {
PantallaUtileria.openWindow("/gui/relatorios/filtroRelatorioEmpresaCorrida.zul",
Labels.getLabel("relatorioEmpresaCorridaController.window.title"), null, desktop);
}
}

View File

@ -223,6 +223,7 @@ indexController.mniRelatorioAcompanhamentoEquivalentes.label = Reporte acompaña
indexController.mniRelatorioLinhasHorario.label = Reporte de rutas por horário
indexController.mniRelatorioTaxasLinha.label = Reporte de tasas por linea
indexController.mniRelatorioSisdap.label=SISDAP
indexController.mniRelatorioEmpresaCorrida.label = Reporte de la Empresa Corrida
#PARTE REALIZADA POR MANUEL
indexController.mnCortesias.label = Cortesias para empleados
@ -292,6 +293,11 @@ relatorioAproveitamentoController.HoraServico.label = Hora servicio
relatorioAproveitamentoController.Classe.label = Clase
relatorioAproveitamentoController.btnBuscarServico.label = Buscar servicio
# Relatorio Empresa Corrida
relatorioEmpresaCorridaController.window.title=Reporte Empresa Corrida
relatorioEmpresaCorridaController.lbDataIni.value=Fecha Inicio
relatorioEmpresaCorridaController.lbDataFin.value=Fecha Final
#Relatorio rutas Horario
relatorioLinhasHorarioController.window.title = Reporte de rutas por horário
relatorioLinhasHorarioController.lbDataIni.value = Fecha inicial
@ -302,6 +308,7 @@ relatorioLinhasHorarioController.lbLote.label = Lote
relatorioLinhasHorarioController.lbLinha.label = Linea
relatorioLinhasHorarioController.lbServico.label = Clase
relatorioLinhasHorarioController.lbNumRuta.label = Num. linea
relatorioLinhasHorarioController.lbPrefixo.label = Prefijo

View File

@ -227,6 +227,7 @@ indexController.mniRelatorioLinhasHorario.label = Relatório de Linhas por Horá
indexController.mniRelatorioTaxasLinha.label = Relatório de Taxas por Linha
indexController.mniRelatorioDevolucaoBilhetes.label = Relatório de Devolução de Bilhetes
indexController.mniRelatorioSisdap.label=SISDAP
indexController.mniRelatorioEmpresaCorrida.label = Relatório por Empresa Corrida
#PARTE REALIZADA POR MANUEL
indexController.mnCortesias.label = Cortesias Para Funcionários
@ -298,6 +299,11 @@ relatorioAproveitamentoController.HoraServico.label = Hora Serviço
relatorioAproveitamentoController.Classe.label = Classe
relatorioAproveitamentoController.btnBuscarServico.label = Buscar Serviço
# Relatorio Empresa Corrida
relatorioEmpresaCorridaController.window.title=Relatório Empresa Corrida
relatorioEmpresaCorridaController.lbDataIni.value=Data Inicial
relatorioEmpresaCorridaController.lbDataFin.value=Data Final
#Relatorio Linhas Horario
relatorioLinhasHorarioController.window.title = Relatório de Linhas por Horário
relatorioLinhasHorarioController.lbDataIni.value = Data Inicial

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<?page contentType="text/html;charset=UTF-8"?>
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="winFiltroRelatorioEmpresaCorrida"?>
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
<zk xmlns="http://www.zkoss.org/2005/zul">
<window id="winFiltroRelatorioEmpresaCorrida"
apply="${relatorioEmpresaCorridaController}"
contentStyle="overflow:auto" height="264px" width="550px"
border="normal">
<grid fixedLayout="true">
<columns>
<column width="20%" />
<column width="30%" />
<column width="20%" />
<column width="30%" />
</columns>
<rows>
<row>
<label
value="${c:l('relatorioEmpresaCorridaController.lbDataIni.value')}" />
<datebox id="datInicial" width="90%"
format="dd/MM/yyyy" lenient="false" constraint="no empty"
maxlength="10" />
<label
value="${c:l('relatorioEmpresaCorridaController.lbDataFin.value')}" />
<datebox id="datFinal" width="90%"
format="dd/MM/yyyy" lenient="false" constraint="no empty"
maxlength="10" />
</row>
</rows>
</grid>
<toolbar>
<button id="btnExecutarRelatorio" image="/gui/img/find.png"
label="${c:l('relatorio.lb.btnExecutarRelatorio')}" />
</toolbar>
</window>
</zk>