fixes bug#00000

qua:
dev:
Gerado apenas novo Jasper para testes.

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@104429 d1611594-4594-4d17-8e1d-87c2c4800839
master
valdevir 2020-11-22 16:00:40 +00:00
parent 623424d485
commit dc749ee132
6 changed files with 9 additions and 1964 deletions

View File

@ -11,6 +11,8 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.ArrayDataSource;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
@ -19,8 +21,8 @@ import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement;
public class RelatorioAproveitamentoFinanceiro extends Relatorio {
private final BigDecimal cem = new BigDecimal("100");
private static Logger log = Logger.getLogger(RelatorioAproveitamentoFinanceiro.class);
public RelatorioAproveitamentoFinanceiro(Map<String, Object> parametros, Connection conexao) throws Exception {
super(parametros, conexao);
@ -159,6 +161,7 @@ public class RelatorioAproveitamentoFinanceiro extends Relatorio {
viagens = viagens.add(domQtde);
dataResult.put("VIAGENS", viagens);
log.info("VIAGENS: " + viagens.toString() );
dataResult.put("ASSENTOS", assentos);
dataResult.put("TARIFA", tarifa);
dataResult.put("TOT_PASSAGEIROS", totPassageiros);
@ -201,7 +204,7 @@ public class RelatorioAproveitamentoFinanceiro extends Relatorio {
this.dados.add(dataResult);
}
this.resultSet = rset;
}
});
@ -230,7 +233,7 @@ public class RelatorioAproveitamentoFinanceiro extends Relatorio {
}
BigDecimal fin = totReceita.divide(dividendo, 4, BigDecimal.ROUND_HALF_UP);
fin = fin.multiply(cem);
fin = fin.multiply(new BigDecimal(new Long(100L)));
fin.setScale(2);
return fin;
}else{

View File

@ -1,241 +0,0 @@
/**
*
*/
package com.rjconsultores.ventaboletos.relatorios.impl;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.ArrayDataSource;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement;
public class RelatorioAproveitamentosFinanceiros extends Relatorio {
private final BigDecimal cem = new BigDecimal("100");
public RelatorioAproveitamentosFinanceiros(Map<String, Object> parametros, Connection conexao) throws Exception {
super(parametros, conexao);
this.setCustomDataSource(new ArrayDataSource(this) {
@Override
public void initDados() throws Exception {
Connection conexao = this.relatorio.getConexao();
Map<String, Object> parametros = this.relatorio.getParametros();
StringBuilder sql = new StringBuilder();
sql.append("select * from ( ");
sql.append(" SELECT ");
sql.append(" r.DESCRUTA as linha, ");
sql.append(" count( c.caja_id) as passageiros, ");
sql.append(" sum( c.PRECIOPAGADO )as valor, ");
sql.append(" to_char( c.FECHORVENTA, 'DY') as dia, ");
sql.append(" count(DISTINCT to_char( c.FECHORVENTA, 'WW')) as qtde, ");
sql.append(" r.indsentidoida as sentido, ");
sql.append(" da.cantasientos as assentos, ");
sql.append(" TO_CHAR(co.fechorsalidaoriginal ,'HH24:mi') as horario, ");
sql.append(" c.CORRIDA_ID as servico, ");
sql.append(" max(c.preciobase) as tarifa ");
sql.append(" FROM CAJA c ");
sql.append(" inner join corrida co ");
sql.append(" on c.CORRIDA_ID = co.CORRIDA_ID ");
sql.append(" and c.FECCORRIDA = co.FECCORRIDA ");
sql.append(" and co.ACTIVO = 1 ");
sql.append(" inner join ruta r ");
sql.append(" on c.RUTA_ID = r.RUTA_ID ");
sql.append(" and r.ACTIVO = 1 ");
sql.append(" inner join MARCA m ");
sql.append(" on m.marca_id = c.marca_id ");
sql.append(" and m.activo = 1 ");
sql.append(" left join rol_operativo ro ");
sql.append(" on ro.roloperativo_id = co.roloperativo_id ");
sql.append(" left join diagrama_autobus da ");
sql.append(" on ro.diagramaautobus_id = da.diagramaautobus_id ");
sql.append(" WHERE c.activo = 1 ");
sql.append(" AND m.EMPRESA_ID = :EMPRESA_ID ");
sql.append(" and c.FECHORVENTA >= :DATA_INICIAL ");
sql.append(" and c.FECHORVENTA <= :DATA_FINAL ");
if (parametros.get("LINHAS") != null && !possuiFiltroTodos("LINHAS")) {
sql.append(" and c.ruta_id IN (" + parametros.get("LINHAS").toString() + ")");
}
sql.append(" and c.MOTIVOCANCELACION_ID is null ");
sql.append(" and c.INDSTATUSBOLETO = 'V' ");
sql.append(" GROUP by r.DESCRUTA, r.indsentidoida, da.cantasientos, ");
sql.append(" to_char( c.FECHORVENTA, 'DY'), TO_CHAR(co.fechorsalidaoriginal ,'HH24:mi'), ");
sql.append(" c.CORRIDA_ID ");
sql.append(" ORDER by r.DESCRUTA, r.indsentidoida desc, to_char( c.FECHORVENTA, 'DY') ");
sql.append(" ) ");
sql.append("PIVOT ");
sql.append("( ");
sql.append(" max(valor) receita_ope, ");
sql.append(" count(qtde) qtde, ");
sql.append(" max(passageiros) tot ");
sql.append(" for dia in ('SEG', 'TER', 'QUA', 'QUI', 'SEX', 'SAB', 'DOM') ");
sql.append(") ");
NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql.toString());
stmt.setInt("EMPRESA_ID", Integer.valueOf(parametros.get("EMPRESA_ID").toString()));
stmt.setTimestamp("DATA_INICIAL", new Timestamp(DateUtil.inicioFecha((Date) parametros.get("DATA_INICIAL")).getTime()));
stmt.setTimestamp("DATA_FINAL", new Timestamp(DateUtil.fimFecha((Date) parametros.get("DATA_FINAL")).getTime()));
ResultSet rset = stmt.executeQuery();
rset.setFetchSize(500);
while (rset.next()) {
Map<String, Object> dataResult = new HashMap<String, Object>();
dataResult.put("LINHA", rset.getString("linha"));
dataResult.put("SENTIDO", rset.getString("sentido"));
dataResult.put("SERVICO", rset.getString("servico"));
dataResult.put("HORARIO", rset.getString("horario"));
BigDecimal assentos = limpaNulo(rset.getBigDecimal("assentos"));
BigDecimal tarifa = limpaNulo(rset.getBigDecimal("tarifa"));
BigDecimal totPassageiros = BigDecimal.ZERO;
BigDecimal totReceita = BigDecimal.ZERO;
BigDecimal viagens = BigDecimal.ZERO;
BigDecimal segReceitaOpe = limpaNulo(rset.getBigDecimal("'SEG'_RECEITA_OPE"));
BigDecimal segQtde = limpaNulo(rset.getBigDecimal("'SEG'_QTDE"));
BigDecimal segTot = limpaNulo(rset.getBigDecimal("'SEG'_TOT"));
totPassageiros = totPassageiros.add(segTot);
totReceita = totReceita.add(segReceitaOpe);
viagens = viagens.add(segQtde);
BigDecimal terReceitaOpe = limpaNulo(rset.getBigDecimal("'TER'_RECEITA_OPE"));
BigDecimal terQtde = limpaNulo(rset.getBigDecimal("'TER'_QTDE"));
BigDecimal terTot = limpaNulo(rset.getBigDecimal("'TER'_TOT"));
totPassageiros = totPassageiros.add(terTot);
totReceita = totReceita.add(terReceitaOpe);
viagens = viagens.add(terQtde);
BigDecimal quaReceitaOpe = limpaNulo(rset.getBigDecimal("'QUA'_RECEITA_OPE"));
BigDecimal quaQtde = limpaNulo(rset.getBigDecimal("'QUA'_QTDE"));
BigDecimal quaTot = limpaNulo(rset.getBigDecimal("'QUA'_TOT"));
totPassageiros = totPassageiros.add(quaTot);
totReceita = totReceita.add(quaReceitaOpe);
viagens = viagens.add(quaQtde);
BigDecimal quiReceitaOpe = limpaNulo(rset.getBigDecimal("'QUI'_RECEITA_OPE"));
BigDecimal quiQtde = limpaNulo(rset.getBigDecimal("'QUI'_QTDE"));
BigDecimal quiTot = limpaNulo(rset.getBigDecimal("'QUI'_TOT"));
totPassageiros = totPassageiros.add(quiTot);
totReceita = totReceita.add(quiReceitaOpe);
viagens = viagens.add(quiQtde);
BigDecimal sexReceitaOpe = limpaNulo(rset.getBigDecimal("'SEX'_RECEITA_OPE"));
BigDecimal sexQtde = limpaNulo(rset.getBigDecimal("'SEX'_QTDE"));
BigDecimal sexTot = limpaNulo(rset.getBigDecimal("'SEX'_TOT"));
totPassageiros = totPassageiros.add(sexTot);
totReceita = totReceita.add(sexReceitaOpe);
viagens = viagens.add(sexQtde);
BigDecimal sabReceitaOpe = limpaNulo(rset.getBigDecimal("'SAB'_RECEITA_OPE"));
BigDecimal sabQtde = limpaNulo(rset.getBigDecimal("'SAB'_QTDE"));
BigDecimal sabTot = limpaNulo(rset.getBigDecimal("'SAB'_TOT"));
totPassageiros = totPassageiros.add(sabTot);
totReceita = totReceita.add(sabReceitaOpe);
viagens = viagens.add(sabQtde);
BigDecimal domReceitaOpe = limpaNulo(rset.getBigDecimal("'DOM'_RECEITA_OPE"));
BigDecimal domQtde = limpaNulo(rset.getBigDecimal("'DOM'_QTDE"));
BigDecimal domTot = limpaNulo(rset.getBigDecimal("'DOM'_TOT"));
totPassageiros = totPassageiros.add(domTot);
totReceita = totReceita.add(domReceitaOpe);
viagens = viagens.add(domQtde);
dataResult.put("VIAGENS", viagens);
dataResult.put("ASSENTOS", assentos);
dataResult.put("TARIFA", tarifa);
dataResult.put("TOT_PASSAGEIROS", totPassageiros);
dataResult.put("TOT_RECEITA", totReceita);
dataResult.put("SEG_RECEITA_OPE", segReceitaOpe);
dataResult.put("SEG_QTDE", segQtde);
dataResult.put("SEG_TOT", segTot);
dataResult.put("SEG_FIN", calculaMedia(segReceitaOpe, tarifa, segQtde, segTot));
dataResult.put("TER_RECEITA_OPE", terReceitaOpe);
dataResult.put("TER_QTDE", terQtde);
dataResult.put("TER_TOT", terTot);
dataResult.put("TER_FIN", calculaMedia(terReceitaOpe, tarifa, terQtde, terTot));
dataResult.put("QUA_RECEITA_OPE", quaReceitaOpe);
dataResult.put("QUA_QTDE", quaQtde);
dataResult.put("QUA_TOT", quaTot);
dataResult.put("QUA_FIN", calculaMedia(quaReceitaOpe, tarifa, quaQtde, quaTot));
dataResult.put("QUI_RECEITA_OPE", quiReceitaOpe);
dataResult.put("QUI_QTDE", quiQtde);
dataResult.put("QUI_TOT", quiTot);
dataResult.put("QUI_FIN", calculaMedia(quiReceitaOpe, tarifa, quiQtde, quiTot));
dataResult.put("SEX_RECEITA_OPE", sexReceitaOpe);
dataResult.put("SEX_QTDE", sexQtde);
dataResult.put("SEX_TOT", sexTot);
dataResult.put("SEX_FIN", calculaMedia(sexReceitaOpe, tarifa, sexQtde, sexTot));
dataResult.put("SAB_RECEITA_OPE", sabReceitaOpe);
dataResult.put("SAB_QTDE", sabQtde);
dataResult.put("SAB_TOT", sabTot);
dataResult.put("SAB_FIN", calculaMedia(sabReceitaOpe, tarifa, sabQtde, sabTot));
dataResult.put("DOM_RECEITA_OPE", domReceitaOpe);
dataResult.put("DOM_QTDE", domQtde);
dataResult.put("DOM_TOT", domTot);
dataResult.put("DOM_FIN", calculaMedia(domReceitaOpe, tarifa, domQtde, domTot));
this.dados.add(dataResult);
}
this.resultSet = rset;
}
});
}
@Override
protected void processaParametros() throws Exception {
}
private BigDecimal limpaNulo( BigDecimal val ) {
if( val == null ) {
return BigDecimal.ZERO;
}else {
return val;
}
}
private BigDecimal calculaMedia(BigDecimal totReceita, BigDecimal tarifa, BigDecimal qtde, BigDecimal tot) {
if( qtde.intValue() != 0 && tot.intValue() !=0 ) {
BigDecimal dividendo = tarifa.multiply(qtde);
dividendo = dividendo.multiply(tot);
if(dividendo.intValue() == 0 ) {
return BigDecimal.ZERO;
}
BigDecimal fin = totReceita.divide(dividendo, 4, BigDecimal.ROUND_HALF_UP);
fin = fin.multiply(cem);
fin.setScale(2);
return fin;
}else{
return BigDecimal.ZERO;
}
}
}

View File

@ -1,13 +0,0 @@
#geral
msg.noData=Não foi possivel obter dados com os parâmetros informados.
#Labels cabeçalho
cabecalho.relatorio=Relatório:
cabecalho.periodo=Período:
cabecalho.periodoA=à
cabecalho.dataHora=Data/Hora:
cabecalho.impressorPor=Impresso por:
cabecalho.pagina=Página
cabecalho.de=de
cabecalho.filtros=Filtros:

View File

@ -25,7 +25,7 @@ import org.zkoss.zul.Textbox;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.Ruta;
import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioAproveitamentosFinanceiros;
import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioAproveitamentoFinanceiro;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
import com.rjconsultores.ventaboletos.service.RutaService;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
@ -155,7 +155,7 @@ public class RelatorioAproveitamentoFinanceiroController extends MyGenericForwar
}
parametros.put("FILTROS", filtro.toString());
relatorio = new RelatorioAproveitamentosFinanceiros(parametros, dataSourceRead.getConnection());
relatorio = new RelatorioAproveitamentoFinanceiro(parametros, dataSourceRead.getConnection());
Map args = new HashMap();
args.put("relatorio", relatorio);