Merge pull request 'AL-2696' (!212) from AL-2696 into master

Reviewed-on: adm/VentaBoletosAdm#212
Reviewed-by: Lucas Taiã <lucas@rjconsultores.com.br>
master 1.8.10
wallace 2023-07-06 21:20:16 +00:00
commit 853ad89771
9 changed files with 2155 additions and 15 deletions

View File

@ -4,11 +4,11 @@
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.rjconsultores</groupId>
<artifactId>ventaboletosadm</artifactId>
<version>1.8.9</version>
<version>1.8.10</version>
<packaging>war</packaging>
<properties>
<modelWeb.version>1.6.6</modelWeb.version>
<modelWeb.version>1.6.7</modelWeb.version>
<flyway.version>1.5.2</flyway.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

View File

@ -0,0 +1,375 @@
/**
*
*/
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.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
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;
import com.rjconsultores.ventaboletos.vo.parada.ParadaVO;
import com.rjconsultores.ventaboletos.vo.ruta.RutaVO;
import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement;
public class RelatorioAproveitamentoFinanceiroTrecho extends Relatorio {
private static Logger log = Logger.getLogger(RelatorioAproveitamentoFinanceiroTrecho.class);
public RelatorioAproveitamentoFinanceiroTrecho(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();
String sqlCombinacoes = gerarCombinacaoTrechos(parametros);
StringBuilder sql = getSQL(parametros, sqlCombinacoes);
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("NUMLINHA", rset.getString("numLinha"));
dataResult.put("SENTIDO", rset.getString("sentido"));
dataResult.put("SERVICO", rset.getString("servico"));
dataResult.put("HORARIO", rset.getString("horario"));
dataResult.put("ORIGEM", rset.getString("origem"));
dataResult.put("DESTINO", rset.getString("destino"));
//Quantidade de assentos do diagrana autobus
BigDecimal assentos = limpaNulo(rset.getBigDecimal("assentos"));
BigDecimal tarifa = limpaNulo(rset.getBigDecimal("tarifa"));
BigDecimal totPassageiros = BigDecimal.ZERO;
BigDecimal totReceita = BigDecimal.ZERO;
Integer viagens =0;
BigDecimal segReceitaOpe = limpaNulo(rset.getBigDecimal("'2'_RECEITA_OPE"));
Integer segQtde = rset.getInt("'2'_QTDE");
BigDecimal segTot = limpaNulo(rset.getBigDecimal("'2'_TOT"));
totPassageiros = totPassageiros.add(segTot);
totReceita = totReceita.add(segReceitaOpe);
viagens = viagens + segQtde;
BigDecimal terReceitaOpe = limpaNulo(rset.getBigDecimal("'3'_RECEITA_OPE"));
Integer terQtde = rset.getInt("'3'_QTDE");
BigDecimal terTot = limpaNulo(rset.getBigDecimal("'3'_TOT"));
totPassageiros = totPassageiros.add(terTot);
totReceita = totReceita.add(terReceitaOpe);
viagens = viagens .intValue() + terQtde.intValue();
BigDecimal quaReceitaOpe = limpaNulo(rset.getBigDecimal("'4'_RECEITA_OPE"));
Integer quaQtde = rset.getInt("'4'_QTDE");
BigDecimal quaTot = limpaNulo(rset.getBigDecimal("'4'_TOT"));
totPassageiros = totPassageiros.add(quaTot);
totReceita = totReceita.add(quaReceitaOpe);
viagens = viagens.intValue() + quaQtde.intValue();
BigDecimal quiReceitaOpe = limpaNulo(rset.getBigDecimal("'5'_RECEITA_OPE"));
Integer quiQtde = rset.getInt("'5'_QTDE");
BigDecimal quiTot = limpaNulo(rset.getBigDecimal("'5'_TOT"));
totPassageiros = totPassageiros.add(quiTot);
totReceita = totReceita.add(quiReceitaOpe);
viagens = viagens.intValue() + quiQtde.intValue();
BigDecimal sexReceitaOpe = limpaNulo(rset.getBigDecimal("'6'_RECEITA_OPE"));
Integer sexQtde = rset.getInt("'6'_QTDE");
BigDecimal sexTot = limpaNulo(rset.getBigDecimal("'6'_TOT"));
totPassageiros = totPassageiros.add(sexTot);
totReceita = totReceita.add(sexReceitaOpe);
viagens = viagens.intValue() + sexQtde.intValue();
BigDecimal sabReceitaOpe = limpaNulo(rset.getBigDecimal("'7'_RECEITA_OPE"));
Integer sabQtde = rset.getInt("'7'_QTDE");
BigDecimal sabTot = limpaNulo(rset.getBigDecimal("'7'_TOT"));
totPassageiros = totPassageiros.add(sabTot);
totReceita = totReceita.add(sabReceitaOpe);
viagens = viagens.intValue() + sabQtde.intValue();
BigDecimal domReceitaOpe = limpaNulo(rset.getBigDecimal("'1'_RECEITA_OPE"));
Integer domQtde = rset.getInt("'1'_QTDE");
BigDecimal domTot = limpaNulo(rset.getBigDecimal("'1'_TOT"));
totPassageiros = totPassageiros.add(domTot);
totReceita = totReceita.add(domReceitaOpe);
viagens = viagens.intValue() + domQtde.intValue();
dataResult.put("VIAGENS", new BigDecimal(viagens));
log.info("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", new BigDecimal(segQtde));
dataResult.put("SEG_TOT", segTot);
dataResult.put("SEG_FIN", calculaMedia(segReceitaOpe, tarifa, segQtde, assentos));
dataResult.put("TER_RECEITA_OPE", terReceitaOpe);
dataResult.put("TER_QTDE", new BigDecimal(terQtde));
dataResult.put("TER_TOT", terTot);
dataResult.put("TER_FIN", calculaMedia(terReceitaOpe, tarifa, terQtde, assentos));
dataResult.put("QUA_RECEITA_OPE", quaReceitaOpe);
dataResult.put("QUA_QTDE", new BigDecimal(quaQtde));
dataResult.put("QUA_TOT", quaTot);
dataResult.put("QUA_FIN", calculaMedia(quaReceitaOpe, tarifa, quaQtde, assentos));
dataResult.put("QUI_RECEITA_OPE", quiReceitaOpe);
dataResult.put("QUI_QTDE", new BigDecimal(quiQtde));
dataResult.put("QUI_TOT", quiTot);
dataResult.put("QUI_FIN", calculaMedia(quiReceitaOpe, tarifa, quiQtde, assentos));
dataResult.put("SEX_RECEITA_OPE", sexReceitaOpe);
dataResult.put("SEX_QTDE", new BigDecimal(sexQtde));
dataResult.put("SEX_TOT", sexTot);
dataResult.put("SEX_FIN", calculaMedia(sexReceitaOpe, tarifa, sexQtde, assentos));
dataResult.put("SAB_RECEITA_OPE", sabReceitaOpe);
dataResult.put("SAB_QTDE", new BigDecimal(sabQtde));
dataResult.put("SAB_TOT", sabTot);
dataResult.put("SAB_FIN", calculaMedia(sabReceitaOpe, tarifa, sabQtde, assentos));
dataResult.put("DOM_RECEITA_OPE", domReceitaOpe);
dataResult.put("DOM_QTDE", new BigDecimal(domQtde));
dataResult.put("DOM_TOT", domTot);
dataResult.put("DOM_FIN", calculaMedia(domReceitaOpe, tarifa, domQtde, assentos));
this.dados.add(dataResult);
}
this.resultSet = rset;
}
private StringBuilder getSQL(Map<String, Object> parametros, String sqlCombinacoes) {
StringBuilder sql = new StringBuilder();
sql.append(" select TB.*, ");
sql.append(" (SELECT ");
sql.append(" max (TF.PRECIO) ");
sql.append(" FROM ");
sql.append(" CORRIDA CR, ");
sql.append(" TRAMO TR, ");
sql.append(" RUTA R, ");
sql.append(" RUTA_COMBINACION RC, ");
sql.append(" TARIFA TF, ");
sql.append(" VIGENCIA_TARIFA VT ");
sql.append(" WHERE ");
sql.append(" CR.CORRIDA_ID = TB.SERVICO ");
sql.append(" AND CR.FECCORRIDA BETWEEN :DATA_INICIAL and :DATA_FINAL ");
sql.append(" AND CR.RUTA_ID = TB.RUTAID ");
sql.append(" AND CR.RUTA_ID = R.RUTA_ID AND R.ACTIVO = 1 ");
sql.append(" AND CR.RUTA_ID = RC.RUTA_ID AND RC.ACTIVO = 1 ");
sql.append(" AND RC.TRAMO_ID = TR.TRAMO_ID ");
sql.append(" AND TF.TRAMO_ID = TR.TRAMO_ID ");
sql.append(" AND TF.MARCA_ID = CR.MARCA_ID ");
sql.append(" AND TF.RUTA_ID = CR.RUTA_ID ");
sql.append(" AND TF.STATUSTARIFA = 'A' ");
sql.append(" AND CR.ACTIVO <> 0 ");
sql.append(" AND TF.ACTIVO = 1 ");
sql.append(" AND TR.ORIGEN_ID = CR.ORIGEN_ID ");
sql.append(" AND TR.DESTINO_ID = CR.DESTINO_ID ");
sql.append(" AND TF.VIGENCIATARIFA_ID = VT.VIGENCIATARIFA_ID ");
sql.append(" AND TF.ORGAOCONCEDENTE_ID = R.ORGAOCONCEDENTE_ID ");
sql.append(" AND VT.ACTIVO = 1 ");
sql.append(" AND CR.FECCORRIDA BETWEEN VT.FECINICIOVIGENCIA AND VT.FECFINVIGENCIA ");
sql.append(" AND TF.CLASESERVICIO_ID = CR.CLASESERVICIO_ID ");
sql.append(" ) TARIFA ");
sql.append(" from ");
sql.append(" ( ");
sql.append(" select * from ( ");
sql.append(" SELECT ");
sql.append(" r.DESCRUTA as linha, ");
sql.append(" r.NUMRUTA as numLinha, ");
sql.append(" r.ruta_id as rutaid, ");
sql.append(" count( c.boleto_id) as passageiros, ");
sql.append(" sum( coalesce(c.preciopagado, 0) )as valor, ");
sql.append(" to_char( co.FECCORRIDA, 'D') as dia, ");
// Quantidade de dias da semana diferente vendidas
// "WW" Esse parâmetro para o to_char tras o dia da semana da data
sql.append(" coalesce(count(DISTINCT to_char( co.FECCORRIDA, 'WW')), 0) 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(" co.CORRIDA_ID as servico, ");
sql.append(" ORI.descparada as origem, ");
sql.append(" DES.descparada as destino ");
sql.append(" FROM boleto c ");
sql.append(" RIGHT OUTER 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 co.RUTA_ID = r.RUTA_ID ");
sql.append(" and r.ACTIVO = 1 ");
sql.append(" inner join MARCA m ");
sql.append(" on m.marca_id = co.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(" left join corrida_tramo ct ON ct.corrida_id = co.corrida_id and ct.FECCORRIDA = co.FECCORRIDA and ct.ACTIVO = 1 ");
sql.append(" left join tramo t ON t.TRAMO_ID = ct.TRAMO_ID and t.ACTIVO = 1 ");
sql.append(" left join parada ORI ON ORI.parada_id = c.origen_id ");
sql.append(" left join parada DES ON DES.parada_id = c.destino_id ");
sql.append(" WHERE co.activo = 1 ");
sql.append(" AND c.activo = 1 ");
sql.append(" AND m.EMPRESA_ID = :EMPRESA_ID ");
sql.append(" and co.FECCORRIDA >= :DATA_INICIAL ");
sql.append(" and co.FECCORRIDA <= :DATA_FINAL ");
if (parametros.get("LINHAS") != null && !possuiFiltroTodos("LINHAS")) {
sql.append(" and co.ruta_id IN (" + parametros.get("LINHAS").toString() + ")");
}
if (sqlCombinacoes != null && !sqlCombinacoes.isEmpty()) {
sql.append(" " +sqlCombinacoes+ " ");
}
sql.append(" and c.MOTIVOCANCELACION_ID is null ");
sql.append(" GROUP by r.DESCRUTA, r.ruta_id, r.indsentidoida, r.NUMRUTA, da.cantasientos, ");
sql.append(" to_char( co.FECCORRIDA, 'D'), TO_CHAR(co.fechorsalidaoriginal ,'HH24:mi'), ");
sql.append(" co.CORRIDA_ID, ORI.descparada, DES.descparada ");
sql.append(" ORDER by r.DESCRUTA, r.indsentidoida desc, to_char( co.FECCORRIDA, 'D') ");
sql.append(" ) ");
sql.append("PIVOT ");
sql.append("( ");
sql.append(" max(valor) receita_ope, ");
sql.append(" max(qtde) qtde, ");
sql.append(" max(passageiros) tot ");
sql.append(" for dia in ('1', '2', '3', '4', '5', '6', '7') ");
sql.append(") ");
sql.append(") TB");
return sql;
}
});
}
@Override
protected void processaParametros() throws Exception {
}
private BigDecimal limpaNulo( BigDecimal val ) {
if( val == null ) {
return BigDecimal.ZERO;
}else {
return val;
}
}
/**
* Faz calculo da media na seguinte formula (Tot. Rceita / (tarifa * qtde * assentos))
* (1427,17 / (108,30*1*42)) * 100
* @param totReceita
* @param tarifa
* @param qtde (Quantidade viagens do dia da semana no periodo.
* Ex 01 a 07, sendo 01 Domingo e 07 Sabado, tera sempre quantidade igual a 7 se o servico for executado todo dia)
* @param tot
* @return
*/
private BigDecimal calculaMedia(BigDecimal totReceita, BigDecimal tarifa, Integer qtde, BigDecimal tot) {
if( qtde.intValue() != 0 && tot.intValue() !=0 ) {
//Multiplica a tarifa pela quantidade de viagens no dia da semana (Segunda, terça...) no período
BigDecimal dividendo = tarifa.multiply(new BigDecimal(qtde));
//Multiplica o dividendo pelo total de passegeiros
dividendo = dividendo.multiply(tot);
if(dividendo.intValue() == 0 ) {
return BigDecimal.ZERO;
}
BigDecimal fin = totReceita.divide(dividendo, 4, BigDecimal.ROUND_HALF_UP);
fin = fin.multiply(new BigDecimal(new Long(100L))).setScale(2);
return fin !=null ? fin : BigDecimal.ZERO;
}else{
return BigDecimal.ZERO;
}
}
private String gerarCombinacaoTrechos(Map<String, Object> parametros) {
String linhas = (String) parametros.get("LINHAS");
String[] arrayLinhas = null;
if(linhas != null) {
arrayLinhas = linhas.split(";");
}
@SuppressWarnings("unchecked")
List<RutaVO> trechos = (List<RutaVO>) parametros.get("TRECHOS");
List<ParadaVO> listParada1 = new ArrayList<>();
List<ParadaVO> listParada2 = new ArrayList<>();
StringBuilder sql = new StringBuilder();
for (RutaVO tramoVO : trechos) {
listParada1.add(new ParadaVO(tramoVO.getOrigenId(), tramoVO.getRutaId().intValue()));
}
listParada2.addAll(listParada1);
if (trechos != null) {
LinkedList<List<ParadaVO>> lists = new LinkedList<List<ParadaVO>>();
lists.add(listParada1);
lists.add(listParada2);
Set<String> combinacoes = new TreeSet<String>();
sql.append("AND (");
for (ParadaVO s : lists.removeFirst())
combinacoes.add(s.getParadaId().toString());
while (!lists.isEmpty()) {
List<ParadaVO> next = lists.removeFirst();
Set<String> novasCombinacoes = new TreeSet<String>();
for (String s1 : combinacoes) {
for (ParadaVO s2 : next) {
novasCombinacoes.add(s1 + ";" + s2.getParadaId());
sql.append("(c.origen_id = ").append(s1).append(" AND c.destino_id = ").append(s2.getParadaId()).append(" and c.ruta_id = " + s2.getRutaId() + " ) OR ");
}
}
combinacoes = novasCombinacoes;
}
// Remover o último " OR " da string
if (combinacoes.size() > 0) {
sql.delete(sql.length() - 4, sql.length());
}
sql.append(")");
}
return sql.toString();
}
}

View File

@ -0,0 +1,13 @@
#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

@ -21,23 +21,29 @@ import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zul.Comboitem;
import org.zkoss.zul.Datebox;
import org.zkoss.zul.Radiogroup;
import org.zkoss.zul.Row;
import org.zkoss.zul.Textbox;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.Ruta;
import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioAproveitamentoFinanceiro;
import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioAproveitamentoFinanceiroTrecho;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
import com.rjconsultores.ventaboletos.service.RutaService;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
import com.rjconsultores.ventaboletos.vo.ruta.RutaVO;
import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar;
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
import com.rjconsultores.ventaboletos.web.utilerias.MyListbox;
import com.rjconsultores.ventaboletos.web.utilerias.render.RenderRelatorioAproveitamentoFinanceiro;
import com.rjconsultores.ventaboletos.web.utilerias.render.RenderRelatorioAproveitamentoFinanceiroTrecho;
@Controller("relatorioAproveitamentoFinanceiroController")
@Scope("prototype")
@SuppressWarnings({ "rawtypes", "unchecked" })
public class RelatorioAproveitamentoFinanceiroController extends MyGenericForwardComposer {
private static final long serialVersionUID = 1L;
@ -48,17 +54,19 @@ public class RelatorioAproveitamentoFinanceiroController extends MyGenericForwar
private Datebox datInicial;
private Datebox datFinal;
private MyComboboxEstandar cmbEmpresa;
private List<Empresa> lsEmpresa;
private ArrayList<RutaVO> rutaVO = new ArrayList<RutaVO>();
@Autowired
private RutaService rutaService;
private MyListbox linhaList;
private MyListbox trechoList;
private MyListbox linhaListSelList;
private Textbox txtPalavraPesquisaLinha;
private ArrayList<Ruta> lsNumLinha = new ArrayList<Ruta>();
private Radiogroup rgLayout;
private Row rowTrecho;
@Override
public void doAfterCompose(Component comp) throws Exception {
@ -67,6 +75,26 @@ public class RelatorioAproveitamentoFinanceiroController extends MyGenericForwar
lsEmpresa = UsuarioLogado.getUsuarioLogado().getEmpresa();
linhaList.setItemRenderer(new RenderRelatorioAproveitamentoFinanceiro());
linhaListSelList.setItemRenderer(new RenderRelatorioAproveitamentoFinanceiro());
trechoList.setItemRenderer(new RenderRelatorioAproveitamentoFinanceiroTrecho());
}
public void carregarTramos(Ruta rutaSelecionada) {
List<RutaVO> lsRutaVO = rutaService.buscaRutaParadas(rutaSelecionada.getRutaId());
RutaVO ultimaRuta = lsRutaVO.get(lsRutaVO.size()-1);
RutaVO novaRuta = new RutaVO(ultimaRuta.getRutaId(), ultimaRuta.getNumRuta(), ultimaRuta.getPrefixo(),ultimaRuta.getDescruta(),ultimaRuta.getDescDestino(), ultimaRuta.getNumSecuencia(), ultimaRuta.getDestinoId(), ultimaRuta.getDestinoId());
novaRuta.setDescOrigem(novaRuta.getDescParada());
lsRutaVO.add(novaRuta);
List<RutaVO> lsRutaVOAux = new ArrayList();
lsRutaVOAux.addAll(trechoList.getListData());
lsRutaVOAux.addAll(lsRutaVO);
trechoList.setData(lsRutaVOAux);
}
public void actualizarDados(List<RutaVO> listaRutaVO) {
}
public List<Empresa> getLsEmpresa() {
@ -80,6 +108,7 @@ public class RelatorioAproveitamentoFinanceiroController extends MyGenericForwar
public void onDoubleClick$linhaList(Event ev) {
Ruta rutaAux = (Ruta) linhaList.getSelected();
linhaListSelList.addItemNovo(rutaAux);
carregarTramos(rutaAux);
}
private void executarPesquisaLinha() {
@ -112,7 +141,16 @@ public class RelatorioAproveitamentoFinanceiroController extends MyGenericForwar
}
private void executarRelatorio() throws Exception {
Relatorio relatorio;
if(rgLayout.getSelectedItem().getValue().equals("EMISSAO_LINHA")) {
executarRelatorioLinha();
}else {
executarRelatorioTrecho();
}
}
private void executarRelatorioLinha() throws Exception {
Map<String, Object> parametros = new HashMap<String, Object>();
StringBuilder filtro = new StringBuilder();
@ -155,7 +193,7 @@ public class RelatorioAproveitamentoFinanceiroController extends MyGenericForwar
}
parametros.put("FILTROS", filtro.toString());
relatorio = new RelatorioAproveitamentoFinanceiro(parametros, dataSourceRead.getConnection());
Relatorio relatorio = new RelatorioAproveitamentoFinanceiro(parametros, dataSourceRead.getConnection());
Map args = new HashMap();
args.put("relatorio", relatorio);
@ -163,4 +201,57 @@ public class RelatorioAproveitamentoFinanceiroController extends MyGenericForwar
openWindow("/component/reportView.zul",
Labels.getLabel("relatorioAproveitamentoFinanceiroController.window.title"), args, MODAL);
}
private void executarRelatorioTrecho() throws Exception {
Map<String, Object> parametros = new HashMap<String, Object>();
StringBuilder filtro = new StringBuilder();
filtro.append("Linha: ");
String linhaIds = "";
String linhas = "";
List<Ruta> lslinhaSelecionados = new ArrayList(Arrays.asList(linhaListSelList.getData()));
if (lslinhaSelecionados.isEmpty()) {
linhas = "Todas";
} else {
for (int i = 0; i < lslinhaSelecionados.size(); i++) {
Ruta linha = lslinhaSelecionados.get(i);
linhas = linhas + linha.getDescruta() + ", ";
linhaIds = linhaIds + linha.getRutaId() + ", ";
}
// removendo ultima virgula
linhaIds = linhaIds.substring(0, linhaIds.length() - 2);
linhas = linhas.substring(0, linhas.length() - 2);
parametros.put("LINHAS", linhaIds);
}
filtro.append(linhas).append(";");
parametros.put("DATA_INICIAL", (java.util.Date) this.datInicial.getValue());
parametros.put("DATA_FINAL", (java.util.Date) this.datFinal.getValue());
parametros.put("NOME_RELATORIO", Labels.getLabel("relatorioAproveitamentoFinanceiroController.window.title"));
parametros.put("USUARIO", UsuarioLogado.getUsuarioLogado().getNombusuario());
parametros.put("TRECHOS", trechoList.getListData());
filtro.append(" Empresa: ");
Comboitem itemEmpresa = cmbEmpresa.getSelectedItem();
if (itemEmpresa != null) {
Empresa empresa = (Empresa) itemEmpresa.getValue();
parametros.put("EMPRESA_ID", empresa.getEmpresaId());
parametros.put("EMPRESA", empresa.getNombempresa());
filtro.append(empresa.getNombempresa() + ";");
} else {
filtro.append(" Todas;");
}
parametros.put("FILTROS", filtro.toString());
Relatorio relatorio = new RelatorioAproveitamentoFinanceiroTrecho(parametros, dataSourceRead.getConnection());
Map args = new HashMap();
args.put("relatorio", relatorio);
openWindow("/component/reportView.zul",
Labels.getLabel("relatorioAproveitamentoFinanceiroController.window.title"), args, MODAL);
}
}

View File

@ -0,0 +1,61 @@
/**
*
*/
package com.rjconsultores.ventaboletos.web.utilerias.render;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zul.Button;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.ListitemRenderer;
import com.rjconsultores.ventaboletos.vo.ruta.RutaVO;
import com.rjconsultores.ventaboletos.web.utilerias.MyListbox;
/**
* @author Wallace
*
*/
public class RenderRelatorioAproveitamentoFinanceiroTrecho implements ListitemRenderer {
@Override
public void render(Listitem lstm, Object o) throws Exception {
RutaVO ruta = (RutaVO) o;
Listcell lc = new Listcell(ruta.getNumRuta().toString());
lc.setParent(lstm);
lc = new Listcell(ruta.getPrefixo());
lc.setParent(lstm);
lc = new Listcell(ruta.getDescruta());
lc.setParent(lstm);
lc = new Listcell(ruta.getDescOrigem());
lc.setParent(lstm);
Button btn = new Button();
lc = new Listcell();
lc.setParent(lstm);
btn.setWidth("16");
btn.setHeight("16");
btn.setImage("/gui/img/remove.png");
btn.addEventListener("onClick", new EventListener() {
@Override
public void onEvent(Event event) throws Exception {
MyListbox listBox = (MyListbox) event.getTarget().getParent().getParent().getParent();
Listitem listItem = (Listitem) event.getTarget().getParent().getParent();
listBox.removeItem((RutaVO) listItem.getAttribute("data"));
}
});
lc.appendChild(btn);
lstm.setAttribute("data", ruta);
}
}

View File

@ -10421,6 +10421,14 @@ relatorioAproveitamentoFinanceiroController.lbEmpresa.value = Empresa
relatorioAproveitamentoFinanceiroController.btnPesquisa.label = Buscar
relatorioAproveitamentoFinanceiroController.btnLimpar.label = Limpar
relatorioAproveitamentoFinanceiroController.lbNumero.value = Número Agência
relatorioAproveitamentoFinanceiroController.window.title = Relatório de Aproveitamento Financeiro
relatorioAproveitamentoFinanceiroController.linha = Relatório por Linha
relatorioAproveitamentoFinanceiroController.trecho = Relatório por Trecho
relatorioAproveitamentoFinanceiroController.lbOrigem.value = Origem
relatorioAproveitamentoFinanceiroController.lbDestino.value = Destino
relatorioAproveitamentoFinanceiroController.lbNumRuta.label = Num. Linha
relatorioAproveitamentoFinanceiroController.lbPrefixo.label = Prefixo
relatorioLinhasHorarioController.lbOrgao.label = Orgão Concedente
#Relatório MMPH - DER-PR
relatorioMmphDerController.window.title = Relatório MMPH - DER-PR

View File

@ -6,7 +6,7 @@
<zk xmlns="http://www.zkoss.org/2005/zul">
<window id="winFiltroRelatorioAproveitamentoFinanceiro"
apply="${relatorioAproveitamentoFinanceiroController}"
contentStyle="overflow:auto" height="286px" width="550px"
contentStyle="overflow:auto" height="286px" width="700px"
border="normal">
<grid fixedLayout="true">
@ -46,10 +46,25 @@
model="@{winFiltroRelatorioAproveitamentoFinanceiro$composer.lsEmpresa}"
width="95%" />
</row>
<row spans="3">
<radiogroup Id="rgLayout" >
<label value="${c:l('relatorioAproveitamentoFinanceiroController.linha')}" />
<radio value="EMISSAO_LINHA" checked = "true">
<attribute name="onCheck">
rowTrecho.setVisible(false);
</attribute>
</radio>
<label value="${c:l('relatorioAproveitamentoFinanceiroController.trecho')}" />
<radio value="EMISSAO_TRECHO">
<attribute name="onCheck">
rowTrecho.setVisible(true);
</attribute>
</radio>
</radiogroup>
</row>
<row spans="1,3">
<label
value="${c:l('relatorioLinhasHorarioController.lbLinha.label')}" />
<bandbox id="bbPesquisaLinha" width="100%"
mold="rounded" readonly="true">
<bandpopup>
@ -69,11 +84,9 @@
use="com.rjconsultores.ventaboletos.web.utilerias.MyListbox"
vflex="true" multiple="false" height="60%" width="410px">
<listhead>
<listheader
label="${c:l('relatorioLinhasHorarioController.lbNumRuta.label')}"
label="${c:l('relatorioAproveitamentoFinanceiroController.lbNumRuta.label')}"
width="18%" />
<listheader
label="${c:l('relatorioLinhasHorarioController.lbPrefixo.label')}"
width="20%" />
@ -92,13 +105,13 @@
<row>
<cell colspan="4">
<borderlayout height="124px">
<borderlayout height="80px">
<center border="0">
<listbox id="linhaListSelList"
mold="paging"
use="com.rjconsultores.ventaboletos.web.utilerias.MyListbox"
vflex="true" multiple="true" height="60%" width="100%">
vflex="true" multiple="true" height="60%" width="97%">
<listhead>
<listheader
label="${c:l('relatorioLinhasHorarioController.lbNumRuta.label')}"
@ -118,6 +131,33 @@
</borderlayout>
</cell>
</row>
<row id="rowTrecho" visible="false">
<cell colspan="4">
<borderlayout height="80px">
<center border="0">
<listbox id="trechoList"
height="400px"
use="com.rjconsultores.ventaboletos.web.utilerias.MyListbox"
multiple="false" width="97%">
<listhead>
<listheader
label="${c:l('relatorioAproveitamentoFinanceiroController.lbNumRuta.label')}"
width="18%" />
<listheader
label="${c:l('relatorioAproveitamentoFinanceiroController.lbPrefixo.label')}"
width="20%" />
<listheader
label="${c:l('lb.dec')}" width="30%" />
<listheader
label="${c:l('relatorioAproveitamentoFinanceiroController.lbOrigem.value')}" width="35%" />
<listheader width="20%" />
</listhead>
</listbox>
</center>
</borderlayout>
</cell>
</row>
</rows>
</grid>