Relatório por Empresa Corrida (fixed bug #5518)

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@36761 d1611594-4594-4d17-8e1d-87c2c4800839
master
leonardo 2014-07-22 20:36:16 +00:00
parent c2be6566c3
commit e733439154
5 changed files with 115 additions and 110 deletions

View File

@ -83,92 +83,72 @@ public class RelatorioEmpresaCorrida extends Relatorio {
private String getSql(String empresa) {
StringBuffer sql = new StringBuffer();
sql.append("SELECT DISTINCT empresa_id, ");
sql.append("SELECT DISTINCT e.empresa_id, ");
sql.append(" r.ruta_id, ");
sql.append(" r.descruta AS linea, ");
sql.append(" nombempresa, ");
sql.append(" Concat(o.descparada, Concat('-', d.descparada)) ");
sql.append(" linea, ");
sql.append(" (SELECT COALESCE(Sum(preciopagado), 0) ");
sql.append(" FROM boleto b1 ");
sql.append(" WHERE b1.motivocancelacion_id IS NULL ");
sql.append(" AND b1.empresacorrida_id = empresa_id ");
sql.append(" AND b1.origen_id = b.origen_id ");
sql.append(" AND b1.destino_id = b.destino_id ");
sql.append(" AND b1.fechorventa BETWEEN :fecInicio AND :fecFinal) boletos, ");
sql.append(" (SELECT COALESCE(Sum(preciopagado), 0) ");
sql.append(" FROM boleto b1 ");
sql.append(" WHERE b1.motivocancelacion_id IS NOT NULL AND b1.indstatusboleto = 'C' ");
sql.append(" AND b1.empresacorrida_id = empresa_id ");
sql.append(" AND b1.origen_id = b.origen_id ");
sql.append(" AND b1.destino_id = b.destino_id ");
sql.append(" AND b1.fechorventa BETWEEN :fecInicio AND :fecFinal) abonos, ");
sql.append(" (SELECT COALESCE(Sum(cantkmreal), 0) ");
sql.append(" FROM tramo t, ruta_combinacion rc, ");
sql.append(" boleto b1, ");
sql.append(" autobus a, ");
sql.append(" corrida c ");
sql.append(" WHERE t.origen_id = b1.origen_id ");
sql.append(" AND b1.ruta_id = rc.ruta_id ");
sql.append(" AND rc.activo = 1 ");
sql.append(" AND t.tramo_id = rc.tramo_id ");
sql.append(" AND t.destino_id = b1.destino_id ");
sql.append(" AND c.corrida_id = b1.corrida_id ");
sql.append(" AND a.autobus_id = c.autobus_id ");
sql.append(" AND b1.empresacorrida_id = empresa_id ");
sql.append(" AND a.empresa_id = empresa_id ");
sql.append(" AND b1.origen_id = b.origen_id ");
sql.append(" AND b1.destino_id = b.destino_id ");
sql.append(" AND b1.fechorventa BETWEEN :fecInicio AND :fecFinal) kmOnibusProprio, ");
sql.append(" (SELECT COALESCE(Sum(cantkmreal), 0) ");
sql.append(" FROM tramo t, ruta_combinacion rc, ");
sql.append(" boleto b1, ");
sql.append(" autobus a, ");
sql.append(" corrida c ");
sql.append(" WHERE t.origen_id = b1.origen_id ");
sql.append(" AND b1.ruta_id = rc.ruta_id ");
sql.append(" AND rc.activo = 1 ");
sql.append(" AND t.tramo_id = rc.tramo_id ");
sql.append(" AND t.destino_id = b1.destino_id ");
sql.append(" AND c.corrida_id = b1.corrida_id ");
sql.append(" AND a.autobus_id = c.autobus_id ");
sql.append(" AND b1.empresacorrida_id = empresa_id ");
sql.append(" AND a.empresa_id <> empresa_id ");
sql.append(" AND b1.origen_id = b.origen_id ");
sql.append(" AND b1.destino_id = b.destino_id ");
sql.append(" AND b1.fechorventa BETWEEN :fecInicio AND :fecFinal) kmOnibusArrendados, ");
sql.append(" (SELECT COALESCE(Sum(cantkmreal), 0) ");
sql.append(" FROM tramo t, ruta_combinacion rc, ");
sql.append(" boleto b1 ");
sql.append(" WHERE t.origen_id = b1.origen_id ");
sql.append(" AND b1.ruta_id = rc.ruta_id ");
sql.append(" AND rc.activo = 1 ");
sql.append(" AND t.tramo_id = rc.tramo_id ");
sql.append(" AND t.destino_id = b1.destino_id ");
sql.append(" AND b1.motivocancelacion_id is null ");
sql.append(" AND b1.empresacorrida_id = empresa_id ");
sql.append(" AND b1.origen_id = b.origen_id ");
sql.append(" AND b1.destino_id = b.destino_id ");
sql.append(" AND b1.fechorventa BETWEEN :fecInicio AND :fecFinal) kmTotal, ");
sql.append(" (SELECT COALESCE(Count(boleto_id), 0) ");
sql.append(" FROM boleto b1 ");
sql.append(" WHERE b1.empresacorrida_id = empresa_id ");
sql.append(" AND b1.motivocancelacion_id IS NULL ");
sql.append(" AND b1.origen_id = b.origen_id ");
sql.append(" AND b1.destino_id = b.destino_id ");
sql.append(" AND b1.fechorventa BETWEEN :fecInicio AND :fecFinal) passageirosTransp ");
sql.append("FROM empresa, ");
sql.append(" parada o, ");
sql.append(" parada d, ");
sql.append(" boleto b ");
sql.append("WHERE o.parada_id = b.origen_id ");
sql.append(" AND d.parada_id = b.destino_id ");
sql.append(" AND b.motivocancelacion_id IS NULL ");
sql.append(" AND b.empresacorrida_id = empresa_id ");
sql.append(" COALESCE(Sum(CASE ");
sql.append(" WHEN b.motivocancelacion_id IS NULL THEN ");
sql.append(" b.preciopagado ");
sql.append(" ELSE 0 ");
sql.append(" END), 0) boletos, ");
sql.append(" COALESCE(Sum(CASE ");
sql.append(" WHEN b.motivocancelacion_id IS NOT NULL ");
sql.append(" AND b.indstatusboleto = 'C' THEN ");
sql.append(" b.preciopagado ");
sql.append(" ELSE 0 ");
sql.append(" END), 0) abonos, ");
sql.append(" COALESCE(Count(b.boleto_id), 0) passageirosTransp, ");
sql.append(" COALESCE(km2.kmtotal, 0) kmtotal, ");
sql.append(" COALESCE(km2.kmonibusproprio, 0) kmOnibusProprio, ");
sql.append(" COALESCE(km2.kmonibusarrendados, 0) kmOnibusArrendados ");
sql.append("FROM boleto b ");
sql.append(" INNER JOIN marca m ");
sql.append(" ON m.marca_id = b.marca_id ");
sql.append(" INNER JOIN empresa e ");
sql.append(" ON e.empresa_id = m.empresa_id ");
sql.append(" INNER JOIN ruta r ");
sql.append(" ON r.ruta_id = b.ruta_id ");
sql.append(" LEFT JOIN (SELECT c1.ruta_id ruta_id, ");
sql.append(" c1.EMPRESACORRIDA_ID empresa_id, ");
sql.append(" COALESCE(Sum(t1.cantkmreal), 0) kmtotal, ");
sql.append(" COALESCE(Sum(CASE ");
sql.append(" WHEN a.empresa_id = c1.empresacorrida_id ");
sql.append(" THEN ");
sql.append(" t1.cantkmreal ");
sql.append(" ELSE 0 ");
sql.append(" END), 0) kmOnibusProprio, ");
sql.append(" COALESCE(Sum(CASE ");
sql.append(" WHEN a.empresa_id <> ");
sql.append(" c1.empresacorrida_id THEN ");
sql.append(" t1.cantkmreal ");
sql.append(" ELSE 0 ");
sql.append(" END), 0) kmOnibusArrendados ");
sql.append(" FROM tramo t1 ");
sql.append(" INNER JOIN corrida_tramo ct ");
sql.append(" ON ct.tramo_id = t1.tramo_id ");
sql.append(" INNER JOIN corrida c1 ");
sql.append(" ON ct.corrida_id = c1.corrida_id ");
sql.append(" AND ct.feccorrida = c1.feccorrida ");
sql.append(" INNER JOIN autobus a ");
sql.append(" ON ct.autobus_id = a.autobus_id ");
sql.append(" WHERE c1.feccorrida BETWEEN :fecInicio AND :fecFinal ");
sql.append(" GROUP BY c1.ruta_id, ");
sql.append(" c1.EMPRESACORRIDA_ID) km2 ");
sql.append(" ON ( km2.ruta_id = r.ruta_id ");
sql.append(" AND km2.empresa_id = e.empresa_id ) ");
sql.append("WHERE b.fechorventa BETWEEN :fecInicio AND :fecFinal ");
if (empresa != null && !empresa.isEmpty()){
sql.append(" AND empresa_id = :empresa_id ");
sql.append(" AND e.empresa_id = :empresa_id ");
}
sql.append(" AND b.fechorventa BETWEEN :fecInicio AND :fecFinal ");
sql.append("ORDER BY empresa_id, ");
sql.append("GROUP BY e.empresa_id, ");
sql.append(" r.ruta_id, ");
sql.append(" r.descruta, ");
sql.append(" e.nombempresa, ");
sql.append(" km2.kmtotal, ");
sql.append(" km2.kmonibusproprio, ");
sql.append(" km2.kmonibusarrendados ");
sql.append("ORDER BY nombempresa, ");
sql.append(" linea ");
return sql.toString();

View File

@ -16,8 +16,8 @@ header.filtro.grupo=Grupo de l
detail.linea=Línea origen - destino
detail.boletos=Recaudaciones Boletos ($)
detail.abonos=Recaudaciones abonos ($)
detail.kmOnibusProprio=Distancia recorrida ómnibus propios (km)
detail.kmOnibusArrendados=Distancia recorrida ómnibus arrendados (km)
detail.kmOnibusProprio=Total Km ómnibus propios
detail.kmOnibusArrendados=Total Km ómnibus arrendados (km)
detail.kmTotal=Distancia recorrida total (km)
detail.pasajerosTransportados=Pasajeros transportados

View File

@ -0,0 +1,25 @@
#geral
msg.noData=No se pudo obtener datos con los parámetros reportados.
msg.a=a
#Labels header
header.periodo=Período:
header.data.hora=Data/Hora\:
header.pagina=Página\:
header.filtro=Filtro\:
header.filtro.servico=Serviço\:
header.filtro.linha=Linhas\:
header.filtro.grupo=Grupo de linhas\:
#Labels detail
detail.linea=Linha origem - destino
detail.boletos=Boletos ($)
detail.abonos=Abonos ($)
detail.kmOnibusProprio=Total Km ônibus próprio
detail.kmOnibusArrendados=Total Km ônibus arrendados
detail.kmTotal=Distância recorrida total (km)
detail.pasajerosTransportados=Passageiros transportados
linhas=Linhas

View File

@ -1,7 +1,7 @@
<?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" resourceBundle="RelatorioEmpresaCorrida" whenResourceMissingType="Empty" uuid="94834362-0ecc-46da-b0a2-5cdee355da3e">
<property name="ireport.zoom" value="1.5"/>
<property name="ireport.x" value="264"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="48"/>
<parameter name="fecInicio" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
@ -53,8 +53,8 @@
<textFieldExpression><![CDATA[$F{empresa}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="e8355048-a037-4837-866b-e6cf7a3e90ed" x="221" y="21" width="74" height="47"/>
<textElement textAlignment="Justified" markup="none">
<reportElement uuid="e8355048-a037-4837-866b-e6cf7a3e90ed" x="215" y="20" width="67" height="47"/>
<textElement textAlignment="Center" markup="none">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$R{detail.abonos}]]></textFieldExpression>
@ -74,21 +74,21 @@
<textFieldExpression><![CDATA[$R{detail.pasajerosTransportados}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="d88253ec-b6d4-4e99-b677-3c1a0b273a81" x="137" y="21" width="73" height="48"/>
<textElement textAlignment="Justified" markup="none">
<reportElement uuid="d88253ec-b6d4-4e99-b677-3c1a0b273a81" x="137" y="21" width="67" height="48"/>
<textElement textAlignment="Center" markup="none">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$R{detail.boletos}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="569add1e-cb73-4278-b800-fa44631527f6" x="359" y="20" width="43" height="48"/>
<reportElement uuid="569add1e-cb73-4278-b800-fa44631527f6" x="350" y="20" width="52" height="48"/>
<textElement textAlignment="Justified" markup="none">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$R{detail.kmOnibusArrendados}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="31387dbf-1cdc-4c27-992f-2e439abea576" x="306" y="21" width="43" height="48"/>
<reportElement uuid="31387dbf-1cdc-4c27-992f-2e439abea576" x="292" y="20" width="48" height="48"/>
<textElement textAlignment="Justified" markup="none">
<font size="10"/>
</textElement>
@ -111,8 +111,8 @@
</groupHeader>
<groupFooter>
<band height="48">
<textField isBlankWhenNull="true">
<reportElement uuid="96095298-1c13-4089-8a8b-fd324b377e45" x="137" y="3" width="73" height="16"/>
<textField pattern="#,##0.00" isBlankWhenNull="true">
<reportElement uuid="96095298-1c13-4089-8a8b-fd324b377e45" x="137" y="3" width="67" height="16"/>
<textElement textAlignment="Right">
<font size="10"/>
</textElement>
@ -121,18 +121,18 @@
<line>
<reportElement uuid="6cef9de7-7dee-488b-aea7-3d02a8e3634a" x="0" y="0" width="555" height="1"/>
</line>
<textField>
<reportElement uuid="354a3daa-dbb6-45c0-93c3-b9c4f485cbb5" x="221" y="3" width="74" height="16"/>
<textField pattern="#,##0.00">
<reportElement uuid="354a3daa-dbb6-45c0-93c3-b9c4f485cbb5" x="215" y="3" width="67" height="16"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$V{sum.abonos}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="2f518abc-f4b9-411b-bb4f-5e58c0a2b301" x="306" y="3" width="43" height="16"/>
<reportElement uuid="2f518abc-f4b9-411b-bb4f-5e58c0a2b301" x="292" y="3" width="48" height="16"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$V{sum.kmOnibusProprio}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="6ce0a6db-3435-4ef2-be61-273af168410f" x="359" y="2" width="43" height="16"/>
<reportElement uuid="6ce0a6db-3435-4ef2-be61-273af168410f" x="350" y="2" width="52" height="16"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$V{sum.kmOnibusArrendados}]]></textFieldExpression>
</textField>
@ -201,13 +201,6 @@
</columnHeader>
<detail>
<band height="35" splitType="Stretch">
<textField>
<reportElement uuid="c29b2244-5b3e-48a2-9adf-8e10ee2a3856" x="306" y="1" width="43" height="34"/>
<textElement textAlignment="Right">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{kmOnibusProprio}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement uuid="3111776a-f727-4313-841c-55dabd804df4" x="415" y="1" width="62" height="34"/>
<textElement textAlignment="Right">
@ -215,8 +208,8 @@
</textElement>
<textFieldExpression><![CDATA[$F{kmTotal}]]></textFieldExpression>
</textField>
<textField pattern="">
<reportElement uuid="3343aea7-212b-4bd5-a29c-8dcab3cb7568" x="221" y="1" width="74" height="34"/>
<textField pattern="#,##0.00">
<reportElement uuid="3343aea7-212b-4bd5-a29c-8dcab3cb7568" x="215" y="0" width="67" height="34"/>
<textElement textAlignment="Right">
<font size="10"/>
</textElement>
@ -230,7 +223,7 @@
<textFieldExpression><![CDATA[$F{pasajerosTransportados}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement uuid="cee727cd-cbc7-41d0-8020-d70aa33d8c9f" x="359" y="0" width="43" height="34"/>
<reportElement uuid="cee727cd-cbc7-41d0-8020-d70aa33d8c9f" x="350" y="0" width="52" height="34"/>
<textElement textAlignment="Right">
<font size="10"/>
</textElement>
@ -243,13 +236,20 @@
</textElement>
<textFieldExpression><![CDATA[$F{linea}]]></textFieldExpression>
</textField>
<textField pattern="" isBlankWhenNull="false">
<reportElement uuid="b36dbddb-2fa9-48a5-809e-0e15ad54c529" x="137" y="1" width="73" height="34"/>
<textField pattern="#,##0.00" isBlankWhenNull="false">
<reportElement uuid="b36dbddb-2fa9-48a5-809e-0e15ad54c529" x="137" y="1" width="67" height="34"/>
<textElement textAlignment="Right">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{boletos}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="c29b2244-5b3e-48a2-9adf-8e10ee2a3856" x="292" y="0" width="48" height="34"/>
<textElement textAlignment="Right">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{kmOnibusProprio}]]></textFieldExpression>
</textField>
</band>
</detail>
<noData>