diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioLinhasHorarioSimplificado.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioLinhasHorarioSimplificado.java new file mode 100644 index 000000000..f9b643834 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioLinhasHorarioSimplificado.java @@ -0,0 +1,653 @@ +package com.rjconsultores.ventaboletos.relatorios.impl; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + +import com.rjconsultores.ventaboletos.entidad.Corrida; +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.GrupoRuta; +import com.rjconsultores.ventaboletos.entidad.Ruta; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.DataSource; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioLinhasHorarioBean; +import com.rjconsultores.ventaboletos.service.ConstanteService; +import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement; +import com.rjconsultores.ventaboletos.web.utilerias.spring.AppContext; + +import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; + +@SuppressWarnings({"unused", "unchecked"}) +public class RelatorioLinhasHorarioSimplificado extends Relatorio { + + private static Logger log = Logger.getLogger(RelatorioLinhasHorarioSimplificado.class); + private List lsDadosRelatorio; + private static String CONSTANTE_GRATUIDADE_CRIANCA; + + public RelatorioLinhasHorarioSimplificado(Map parametros, Connection conexao) throws Exception { + super(parametros, conexao); + + this.setCustomDataSource(new DataSource(this) { + @Override + public void initDados() throws Exception { + + CONSTANTE_GRATUIDADE_CRIANCA = buscarConstante("GRATUIDADE_CRIANCA"); + + Connection conexao = this.relatorio.getConexao(); + + Map parametros = this.relatorio.getParametros(); + + ArrayList lsNumLinha = (ArrayList) parametros.get("lsNumLinha"); + ArrayList lsNumServico = (ArrayList) parametros.get("lsNumServico"); + + String servicoFiltro = ""; + if (lsNumServico.size() > 0) { + for (Corrida corrida : lsNumServico) { + if (lsNumServico.indexOf(corrida) == 0) { + servicoFiltro = "" + corrida.getId().getCorridaId(); + } else { + servicoFiltro += ", " + corrida.getId().getCorridaId(); + } + } + } else { + servicoFiltro = "TODOS"; + } + parametros.put("SERVICO_FILTRO", servicoFiltro); + + String linhaFiltro = ""; + if (lsNumLinha.size() > 0) { + for (Ruta ruta : lsNumLinha) { + if (lsNumLinha.indexOf(ruta) == 0) { + linhaFiltro = "" + ruta.getRutaId(); + } else { + linhaFiltro += ", " + ruta.getRutaId(); + } + } + } else { + linhaFiltro = "TODOS"; + } + parametros.put("LINHA_FILTRO", linhaFiltro); + + Empresa empresa = (Empresa) parametros.get("EMPRESA"); + + GrupoRuta grupoRuta = (GrupoRuta) parametros.get("GRUPORUTA"); + + Integer tipoServico = (Integer) parametros.get("TIPOSERVICIO_ID"); + + String sql = getSql(lsNumLinha, lsNumServico, empresa, tipoServico, grupoRuta); + + NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql); + ResultSet rset = null; + if (parametros.get("HORA_INICIAL") == null) { + stmt.setTimestamp("DATA_INICIO", (Timestamp) parametros.get("DATA_INICIO")); + stmt.setTimestamp("DATA_FINAL", (Timestamp) parametros.get("DATA_FINAL")); + + }else { + setaParametroDataHora(parametros, stmt); + } + + rset = stmt.executeQuery(); + + lsDadosRelatorio = new ArrayList(); + + BigDecimal totalPassagens = BigDecimal.ZERO; + BigDecimal totalSeguro = BigDecimal.ZERO; + BigDecimal totalBagagens = BigDecimal.ZERO; + BigDecimal totalSeuroOpcional = BigDecimal.ZERO; + BigDecimal totalTotal = BigDecimal.ZERO; + BigDecimal totalOrdinario = BigDecimal.ZERO; + BigDecimal totalExtra = BigDecimal.ZERO; + BigDecimal totalViagem = BigDecimal.ZERO; + BigDecimal totalKmRodado = BigDecimal.ZERO; + BigDecimal totalAbsoluto = BigDecimal.ZERO; + BigDecimal totalEquivalente = BigDecimal.ZERO; + BigDecimal mediaMPA = BigDecimal.ZERO; + BigDecimal mediaMPE = BigDecimal.ZERO; + BigDecimal mediaRsPorKm = BigDecimal.ZERO; + BigDecimal totalEQ = BigDecimal.ZERO; + BigDecimal mediaRSPorViagem = BigDecimal.ZERO; + BigDecimal totalPaxKMOfertado = BigDecimal.ZERO; + BigDecimal totalPaxKMTransportado = BigDecimal.ZERO; + BigDecimal totalIAP = BigDecimal.ZERO; + + BigDecimal totalTxEmbarque = BigDecimal.ZERO; + BigDecimal totalPedagio = BigDecimal.ZERO; + + String group = null; + while (rset.next()) { + RelatorioLinhasHorarioBean horarioBean = new RelatorioLinhasHorarioBean(); + + group = ((String) rset.getObject("GRUPO_RUTA")); + horarioBean.setGrupoRuta(group); + horarioBean.setTipoLinha((String) rset.getObject("TIPO_LINHA")); + horarioBean.setHora((String) rset.getObject("HORA")); + horarioBean.setServico((BigDecimal) rset.getObject("SERVICO")); + + if (rset.getObject("SENTIDO") != null) { + horarioBean.convetSentido((BigDecimal) rset.getObject("SENTIDO")); + } else { + horarioBean.convetSentido(null); + } + + horarioBean.setLot((BigDecimal) rset.getObject("LOT")); + horarioBean.setCla((String) rset.getObject("CLA")); + horarioBean.setExtensao((BigDecimal) rset.getObject("EXTENSAO")); + horarioBean.setTarifa((BigDecimal) rset.getObject("TARIFA")); + horarioBean.setPassagens((BigDecimal) rset.getObject("PASSAGENS")); + horarioBean.setSeguro((BigDecimal) rset.getObject("SEGURO")); + horarioBean.setBagagens((BigDecimal) rset.getObject("BAGAGENS")); + + horarioBean.setTxEmbarque((BigDecimal) rset.getObject("TX_EMBARQUE")); + horarioBean.setPedagio((BigDecimal) rset.getObject("PEDAGIO")); + + // Substituir a coluna Seg. Opcional por Tx. Embarque + horarioBean.setSegOpc(horarioBean.getTxEmbarque()); + + horarioBean.setOrd((BigDecimal) rset.getObject("ORD")); + horarioBean.setExtra((BigDecimal) rset.getObject("EXTRA")); + horarioBean.setAbsol((BigDecimal) rset.getObject("ABSOL")); + + horarioBean.setOrigem((String) rset.getObject("ORIGEM")); + horarioBean.setDestino((String) rset.getObject("DESTINO")); + horarioBean.setSomaExtensaoTrecho((BigDecimal) rset.getObject("EXTENSAO_TRECHO")); + horarioBean.setPaxKmTransportado((BigDecimal) rset.getObject("KM_REAL")); + horarioBean.setDescRuta((String) rset.getObject("DESCRUTA")); + horarioBean = trecho(horarioBean); + + horarioBean = calcTotal(horarioBean); + horarioBean = calcMediaReceitaTotal(horarioBean); + + horarioBean = calcTotalViagem(horarioBean); + horarioBean = calcKmRodado(horarioBean); + horarioBean = calcEquivalente(horarioBean); + horarioBean = calcMpa(horarioBean); + horarioBean = calcMpe(horarioBean); + horarioBean = calcRsKm(horarioBean); + horarioBean = calcEq(horarioBean); + horarioBean = calcRsViagem(horarioBean); + horarioBean = calcPaxKmOfertado(horarioBean); + horarioBean = calcIap(horarioBean); + + lsDadosRelatorio.add(horarioBean); + + totalPassagens = totalPassagens.add(horarioBean.getPassagens() != null ? horarioBean.getPassagens() : BigDecimal.ZERO); + totalSeguro = totalSeguro.add(horarioBean.getSeguro() != null ? horarioBean.getSeguro() : BigDecimal.ZERO); + totalBagagens = totalBagagens.add(horarioBean.getBagagens() != null ? horarioBean.getBagagens() : BigDecimal.ZERO); + totalSeuroOpcional = totalSeuroOpcional.add(horarioBean.getSegOpc() != null ? horarioBean.getSegOpc() : BigDecimal.ZERO); + totalTotal = totalTotal.add(horarioBean.getTotal() != null ? horarioBean.getTotal() : BigDecimal.ZERO); + totalOrdinario = totalOrdinario.add(horarioBean.getOrd() != null ? horarioBean.getOrd() : BigDecimal.ZERO); + totalExtra = totalExtra.add(horarioBean.getExtra() != null ? horarioBean.getExtra() : BigDecimal.ZERO); + totalViagem = totalViagem.add(horarioBean.getTotalViagem() != null ? horarioBean.getTotalViagem() : BigDecimal.ZERO); + totalKmRodado = totalKmRodado.add(horarioBean.getKmRodado() != null ? horarioBean.getKmRodado() : BigDecimal.ZERO); + totalAbsoluto = totalAbsoluto.add(horarioBean.getAbsol() != null ? horarioBean.getAbsol() : BigDecimal.ZERO); + totalEquivalente = totalEquivalente.add(horarioBean.getEquivalente() != null ? horarioBean.getEquivalente() : BigDecimal.ZERO); + + totalTxEmbarque = totalTxEmbarque.add(horarioBean.getTxEmbarque() != null ? horarioBean.getTxEmbarque() : BigDecimal.ZERO); + totalPedagio = totalPedagio.add(horarioBean.getPedagio() != null ? horarioBean.getPedagio() : BigDecimal.ZERO); + + mediaMPA = mediaMPA.add(horarioBean.getMpa() != null ? horarioBean.getMpa() : BigDecimal.ZERO); + mediaMPE = mediaMPE.add(horarioBean.getMpe() != null ? horarioBean.getMpe() : BigDecimal.ZERO); + + mediaRsPorKm = mediaRsPorKm.add(horarioBean.getRsKm() != null ? horarioBean.getRsKm() : BigDecimal.ZERO); + + totalEQ = totalEQ.add(horarioBean.getEq() != null ? horarioBean.getEq() : BigDecimal.ZERO); + + mediaRSPorViagem = mediaRSPorViagem.add(horarioBean.getRsViagem() != null ? horarioBean.getRsViagem() : BigDecimal.ZERO); + + totalPaxKMOfertado = totalPaxKMOfertado.add(horarioBean.getPaxKmOfertado() != null ? horarioBean.getPaxKmOfertado() : BigDecimal.ZERO); + totalPaxKMTransportado = totalPaxKMTransportado.add(horarioBean.getPaxKmTransportado() != null ? horarioBean.getPaxKmTransportado() : BigDecimal.ZERO); + + totalIAP = totalIAP.add(horarioBean.getIap()); + + } + + BigDecimal qtdeRegistros = new BigDecimal(lsDadosRelatorio.size()); + + if (lsDadosRelatorio.size() > 0) { + + setLsDadosRelatorio(lsDadosRelatorio); + parametros.put("TOTAL_PASSAGENS", totalPassagens); + parametros.put("TOTAL_SEGURO", totalSeguro); + parametros.put("TOTAL_BAGAGENS", totalBagagens); + parametros.put("TOTAL_SEURO_OPCIONAL", totalSeuroOpcional); + parametros.put("TOTAL_TOTAL", totalTotal); + parametros.put("TOTAL_ORDINARIO", totalOrdinario); + parametros.put("TOTAL_EXTRA", totalExtra); + parametros.put("TOTAL_VIAGEM", totalViagem); + parametros.put("TOTAL_KM_RODADO", totalKmRodado); + parametros.put("TOTAL_ABSOLUTO", totalAbsoluto); + parametros.put("TOTAL_EQUIVALENTE", totalEquivalente); + parametros.put("MEDIA_MPA", mediaMPA); + parametros.put("MEDIA_MPE", mediaMPE); + parametros.put("MEDIA_RS_POR_KM", mediaRsPorKm); + parametros.put("TOTAL_EQ", totalEQ); + parametros.put("TOTAL_TX_EMBARQUE", totalTxEmbarque); + parametros.put("TOTAL_PEDAGIO", totalPedagio); + parametros.put("MEDIA_RS_POR_VIAGEM", mediaRSPorViagem); + parametros.put("TOTAL_PAX_KM_OFERTADO", totalPaxKMOfertado); + parametros.put("TOTAL_PAX_KM_TRANSPORTADO", totalPaxKMTransportado); + parametros.put("TOTAL_IAP", totalIAP); + + } + } + + }); + + } + + private void setaParametroDataHora(Map parametros, NamedParameterStatement stmt) throws SQLException { + Calendar dataInicial = Calendar.getInstance(); + dataInicial.setTime((Date) parametros.get("DATA_INICIO")); + Calendar horaInicialCal = Calendar.getInstance(); + horaInicialCal.setTime((Date) parametros.get("HORA_INICIAL")); + mesclarDataHora(dataInicial, horaInicialCal); + stmt.setTimestamp("DATA_INICIO", new Timestamp(dataInicial.getTimeInMillis())); + if (parametros.get("HORA_FINAL") != null) { + Calendar dataFinal = Calendar.getInstance(); + dataFinal.setTime((Date) parametros.get("DATA_FINAL")); + Calendar horaFinalCal = Calendar.getInstance(); + horaFinalCal.setTime((Date) parametros.get("HORA_FINAL")); + mesclarDataHora(dataFinal, horaFinalCal); + stmt.setTimestamp("DATA_FINAL", new Timestamp( dataFinal.getTimeInMillis())); + }else { + stmt.setTimestamp("DATA_FINAL", (Timestamp) parametros.get("DATA_FINAL")); + } + } + + public List getLsDadosRelatorio() { + + return lsDadosRelatorio; + } + + public void setLsDadosRelatorio(List lsDadosRelatorio) { + this.setCollectionDataSource(new JRBeanCollectionDataSource(lsDadosRelatorio)); + this.lsDadosRelatorio = lsDadosRelatorio; + } + + private RelatorioLinhasHorarioBean trecho(RelatorioLinhasHorarioBean horarioBean) { + horarioBean.setTrecho(horarioBean.getOrigem() + " - " + horarioBean.getDestino()); + return horarioBean; + } + + private RelatorioLinhasHorarioBean calcTotal(RelatorioLinhasHorarioBean horarioBean) { + BigDecimal total = horarioBean.getPassagens(); + total = total.add(horarioBean.getBagagens()); + total = total.add(horarioBean.getSeguro()); + total = total.add(horarioBean.getPedagio()); + total = total.add(horarioBean.getTxEmbarque()); + horarioBean.setTotal(total); + return horarioBean; + } + + private RelatorioLinhasHorarioBean calcMediaReceitaTotal(RelatorioLinhasHorarioBean horarioBean) { + BigDecimal mediaTotal = horarioBean.getPassagens(); + horarioBean.setMediaReceitaViagem(mediaTotal); + return horarioBean; + } + + private RelatorioLinhasHorarioBean calcTotalViagem(RelatorioLinhasHorarioBean horarioBean) { + BigDecimal totalViagem = horarioBean.getOrd().add(horarioBean.getExtra()); + horarioBean.setTotalViagem(totalViagem); + return horarioBean; + } + + private RelatorioLinhasHorarioBean calcKmRodado(RelatorioLinhasHorarioBean horarioBean) { + BigDecimal kmRodado = horarioBean.getTotalViagem().multiply(horarioBean.getExtensao()); + horarioBean.setKmRodado(kmRodado); + return horarioBean; + } + + private RelatorioLinhasHorarioBean calcEquivalente(RelatorioLinhasHorarioBean horarioBean) { + BigDecimal equivalente = new BigDecimal(0); + try { + equivalente = horarioBean.getSomaExtensaoTrecho().divide(horarioBean.getExtensao(), 2, RoundingMode.HALF_UP); + } catch (ArithmeticException e) { + equivalente = BigDecimal.ZERO; + } catch (NullPointerException nex) { + equivalente = BigDecimal.ZERO; + } catch (Exception ex) { + log.error("", ex); + } + horarioBean.setEquivalente(equivalente); + + return horarioBean; + } + + private RelatorioLinhasHorarioBean calcMpa(RelatorioLinhasHorarioBean horarioBean) { + BigDecimal mpa = new BigDecimal(0); + try { + mpa = horarioBean.getAbsol().divide(horarioBean.getTotalViagem(), 2, 4); + } catch (ArithmeticException e) { + mpa = BigDecimal.ZERO; + } catch (NullPointerException nex) { + mpa = BigDecimal.ZERO; + } catch (Exception ex) { + log.error("", ex); + } + horarioBean.setMpa(mpa); + return horarioBean; + } + + private RelatorioLinhasHorarioBean calcMpe(RelatorioLinhasHorarioBean horarioBean) { + BigDecimal mpe = horarioBean.getEquivalente().divide(horarioBean.getTotalViagem(), 2, 4); + horarioBean.setMpe(mpe); + return horarioBean; + } + + private RelatorioLinhasHorarioBean calcRsKm(RelatorioLinhasHorarioBean horarioBean) { + BigDecimal rsKm = horarioBean.getTotal().divide(horarioBean.getKmRodado(), 2, 4); + horarioBean.setRsKm(rsKm); + return horarioBean; + } + + private RelatorioLinhasHorarioBean calcEq(RelatorioLinhasHorarioBean horarioBean) { + BigDecimal eq = null; + try { + eq = horarioBean.getMediaReceitaViagem().divide(horarioBean.getTarifa(), 2, 4); + } catch (ArithmeticException e) { + eq = BigDecimal.ZERO; + } catch (NullPointerException nex) { + eq = BigDecimal.ZERO; + } catch (Exception ex) { + log.error("", ex); + } + horarioBean.setEq(eq); + return horarioBean; + } + + private RelatorioLinhasHorarioBean calcRsViagem(RelatorioLinhasHorarioBean horarioBean) { + BigDecimal RSViagem = horarioBean.getPassagens().divide(horarioBean.getTotalViagem(), 2, 4); + horarioBean.setRsViagem(RSViagem); + return horarioBean; + } + + private RelatorioLinhasHorarioBean calcPaxKmOfertado(RelatorioLinhasHorarioBean horarioBean) { + BigDecimal paxKmOfertado = horarioBean.getLot().multiply(horarioBean.getTotalViagem()); + paxKmOfertado = paxKmOfertado.multiply(horarioBean.getExtensao()); + horarioBean.setPaxKmOfertado(paxKmOfertado); + return horarioBean; + } + + private RelatorioLinhasHorarioBean calcIap(RelatorioLinhasHorarioBean horarioBean) { + BigDecimal iap = null; + BigDecimal CENTO = BigDecimal.TEN.multiply(BigDecimal.TEN); + try { + iap = (horarioBean.getPaxKmTransportado().multiply(CENTO)).divide(horarioBean.getPaxKmOfertado(), 2, 4); + } catch (ArithmeticException e) { + iap = BigDecimal.ZERO; + } catch (NullPointerException nex) { + iap = BigDecimal.ZERO; + } catch (Exception ex) { + log.error("", ex); + } + horarioBean.setIap(iap); + return horarioBean; + } + + private BigDecimal calcTotalIap(BigDecimal totalPaxKMTransportado, BigDecimal totalPaxKMOfertado) { + BigDecimal iap = null; + BigDecimal CENTO = BigDecimal.TEN.multiply(BigDecimal.TEN); + try { + iap = (totalPaxKMTransportado.multiply(CENTO)).divide(totalPaxKMOfertado, 2, 4); + } catch (ArithmeticException e) { + iap = BigDecimal.ZERO; + } catch (NullPointerException nex) { + iap = BigDecimal.ZERO; + } catch (Exception ex) { + log.error("", ex); + } + return iap; + } + + @Override + protected void processaParametros() throws Exception { + } + + private String getSql(ArrayList lsNumLinha, ArrayList lsNumServico, Empresa empresa, Integer tipoServico, GrupoRuta grupoRuta) { + + StringBuffer sql = new StringBuffer(); + sql.append(" SELECT "); + sql.append(" GRUPO_RUTA, "); + sql.append(" HORA, "); + sql.append(" DESCRUTA, "); + sql.append(" SERVICO, "); + sql.append(" SENTIDO , "); + sql.append(" LOT, "); + sql.append(" CLA, "); + sql.append(" TARIFA, "); + sql.append(" ORIGEM, "); + sql.append(" DESTINO, "); + sql.append(" EXTENSAO, "); + sql.append(" COALESCE(SUM(EQUIVALENTE * EXTENSAO) ,0) AS EXTENSAO_TRECHO, "); + sql.append(" COALESCE(BAGAGENS, 0) AS BAGAGENS, "); + sql.append(" COALESCE(SUM(SEGURO), 0) AS SEGURO, "); + sql.append(" COALESCE(SUM(TX_EMBARQUE), 0) AS TX_EMBARQUE, "); + sql.append(" COALESCE(SUM(PEDAGIO), 0) AS PEDAGIO, "); + sql.append(" COALESCE(SUM(PASSAGENS), 0) AS PASSAGENS, "); + sql.append(" ORD, "); + sql.append(" EXTRA, "); + sql.append(" TIPO_LINHA, "); + sql.append(" ABSOL, "); + sql.append(" COALESCE(SUM(KM_REAL), 0) AS KM_REAL "); + sql.append(" FROM "); + sql.append(" (SELECT "); + sql.append(" R.RUTA_ID, "); + sql.append(" R.DESCRUTA AS DESCRUTA, "); + sql.append(" NVL(GR.DESCGRUPO, 'Não Definido') AS GRUPO_RUTA, "); + sql.append(" TO_CHAR(C.FECHORSALIDA, 'HH24:MI') AS HORA, "); + sql.append(" C.CORRIDA_ID AS SERVICO, "); + sql.append(" R.INDSENTIDOIDA AS SENTIDO, "); + sql.append(" DA.CANTASIENTOS AS LOT, "); + sql.append(" NVL(CS.DESCCLASE, '') AS CLA, "); + sql.append(" MAX(NVL(TF.PRECIOORIGINAL, 0)) AS TARIFA, "); + sql.append(" ORIGEM.CVEPARADA AS ORIGEM, "); + sql.append(" DESTINO.CVEPARADA AS DESTINO, "); + sql.append(" EXTENSAO AS EXTENSAO, "); + sql.append(" CJ.EQUIVALENTE AS EQUIVALENTE, "); + sql.append(" SUM(EE.IMPINGRESO) AS BAGAGENS, "); + sql.append(" CJ.IMPORTESEGURO AS SEGURO, "); + sql.append(" CJ.IMPORTETAXAEMBARQUE AS TX_EMBARQUE, "); + sql.append(" CJ.IMPORTEPEDAGIO AS PEDAGIO, "); + sql.append(" CJ.PRECIOPAGADO AS PASSAGENS, "); + sql.append(" CJ.BOLETO_ID, "); + sql.append(" TB2.ORD, "); + sql.append(" TB2.EXTRA, "); + sql.append(" CASE WHEN CO.ESTADO_ID <> CD.ESTADO_ID THEN 'INTERESTADUAL' ELSE 'INTERMUNICIPAL' END TIPO_LINHA, "); + sql.append(" ABSOL, "); + sql.append(" CJ.KM_REAL AS KM_REAL "); + sql.append(" FROM CORRIDA C "); + sql.append(" INNER JOIN ("); + sql.append(" SELECT "); + sql.append(" C.CORRIDA_ID, "); + sql.append(" c.ruta_id as c_ruta_id, "); + sql.append(" Destino.Cveparada AS DESTINO, "); + sql.append(" ORIGEM.CVEPARADA AS ORIGEM, "); + sql.append(" C.ROLOPERATIVO_ID, "); + sql.append(" TO_CHAR(C.FECHORSALIDA, 'HH24:MI') AS HORASALIDA, "); + sql.append(" COUNT(CASE WHEN C.TIPOSERVICIO_ID = 1 THEN 1 ELSE NULL END) AS ORD, "); + sql.append(" COUNT(CASE WHEN C.TIPOSERVICIO_ID = 2 THEN 1 ELSE NULL END) AS EXTRA "); + sql.append(" FROM CORRIDA C "); + sql.append(" INNER JOIN PARADA ORIGEM ON C.Origen_Id = ORIGEM.PARADA_ID "); + sql.append(" INNER JOIN PARADA DESTINO ON C.DESTINO_ID = DESTINO.PARADA_ID "); + + sql.append(empresa == null ? "" : " INNER JOIN MARCA M ON (C.MARCA_ID = M.MARCA_ID AND M.EMPRESA_ID=" + empresa.getEmpresaId() + ")"); + + sql.append(" WHERE "); + sql.append(" EXISTS (SELECT * FROM CAJA CA WHERE CA.CORRIDA_ID = C.CORRIDA_ID AND CA.FECCORRIDA = C.FECCORRIDA AND CA.MOTIVOCANCELACION_ID IS NULL) "); + sql.append(" AND C.FECCORRIDA BETWEEN :DATA_INICIO AND :DATA_FINAL "); + sql.append(" GROUP BY C.CORRIDA_ID, "); + sql.append(" C.ROLOPERATIVO_ID, "); + sql.append(" c.ruta_id, "); + sql.append(" Destino.Cveparada, "); + sql.append(" ORIGEM.CVEPARADA, "); + sql.append(" TO_CHAR(C.FECHORSALIDA, 'HH24:MI') "); + sql.append(" ) TB2 ON (TB2.CORRIDA_ID = C.CORRIDA_ID and tb2.c_ruta_id = c.ruta_id ) "); + sql.append(" AND TB2.ROLOPERATIVO_ID = C.ROLOPERATIVO_ID "); + sql.append(" AND TB2.HORASALIDA = TO_CHAR(C.FECHORSALIDA, 'HH24:MI') "); + sql.append(" INNER JOIN ("); + sql.append(" SELECT "); + sql.append(" C.CORRIDA_ID, "); + sql.append(" c.ruta_id as c_ruta_id, "); + sql.append(" C.ROLOPERATIVO_ID, "); + sql.append(" C.DESTINO_ID, "); + sql.append(" C.ORIGEN_ID, "); + sql.append(" TO_CHAR(C.FECHORSALIDA, 'HH24:MI') AS HORASALIDA, "); + sql.append(" COUNT(B.BOLETO_ID) AS ABSOL "); + sql.append(" FROM CORRIDA C "); + + sql.append(empresa == null ? "" : " INNER JOIN MARCA M ON (C.MARCA_ID = M.MARCA_ID AND M.EMPRESA_ID=" + empresa.getEmpresaId() + ")"); + + sql.append(" LEFT JOIN BOLETO B ON (B.CORRIDA_ID = C.CORRIDA_ID AND B.FECCORRIDA = C.FECCORRIDA AND B.ACTIVO = 1 AND B.MOTIVOCANCELACION_ID IS NULL "); + sql.append(" AND B.CATEGORIA_ID <> ").append(CONSTANTE_GRATUIDADE_CRIANCA).append(") "); + sql.append(" WHERE C.ACTIVO = 1 AND C.FECCORRIDA BETWEEN :DATA_INICIO AND :DATA_FINAL "); + + if (lsNumServico.size() > 0) { + for (Corrida corrida : lsNumServico) { + if (lsNumServico.indexOf(corrida) == 0) { + sql.append(" AND B.CORRIDA_ID IN ( " + corrida.getId().getCorridaId()); + } else { + sql.append(" , " + corrida.getId().getCorridaId() + " "); + } + } + sql.append(" ) "); + } + + sql.append(" GROUP BY C.CORRIDA_ID, c.ruta_id, C.ROLOPERATIVO_ID, C.DESTINO_ID, C.ORIGEN_ID, TO_CHAR(C.FECHORSALIDA, 'HH24:MI') "); + sql.append(" ) TB4 ON (TB4.CORRIDA_ID = C.CORRIDA_ID and tb4.c_ruta_id = c.ruta_id) "); + sql.append(" AND c.DESTINO_ID = TB4.DESTINO_ID "); + sql.append(" AND c.ORIGEN_ID = TB4.ORIGEN_ID "); + sql.append(" AND TB4.ROLOPERATIVO_ID = C.ROLOPERATIVO_ID "); + sql.append(" AND TB4.HORASALIDA = TO_CHAR(C.FECHORSALIDA, 'HH24:MI') "); + + sql.append("LEFT JOIN "); + sql.append(" (SELECT CO.FECCORRIDA, "); + sql.append(" CO.CORRIDA_ID, "); + sql.append(" CO.ROLOPERATIVO_ID, "); + sql.append(" CO.RUTA_ID, "); + sql.append(" CO.EMPRESACORRIDA_ID, "); + sql.append(" BO.BOLETO_ID, "); + sql.append(" BO.NUMKMVIAJE * COUNT(1) AS KM_REAL, "); + sql.append(" CASE "); + sql.append("WHEN T.CANTKMREAL<>0 AND BO.NUMKMVIAJE<>0 "); + sql.append("THEN ROUND(BO.NUMKMVIAJE * COUNT(1) / T.CANTKMREAL, 3) "); + sql.append("ELSE 0 "); + sql.append("END AS EQUIVALENTE, "); + sql.append(" NVL(BO.IMPORTESEGURO, 0) AS IMPORTESEGURO, "); + sql.append(" NVL(BO.IMPORTETAXAEMBARQUE, 0) AS IMPORTETAXAEMBARQUE, "); + sql.append(" NVL(BO.IMPORTEPEDAGIO, 0) AS IMPORTEPEDAGIO, "); + sql.append(" NVL(BO.PRECIOPAGADO, 0) AS PRECIOPAGADO "); + sql.append(" FROM CORRIDA CO "); + sql.append(empresa == null ? "" : " INNER JOIN MARCA M ON (CO.MARCA_ID = M.MARCA_ID AND M.EMPRESA_ID=" + empresa.getEmpresaId() + ")"); + sql.append(" INNER JOIN BOLETO BO ON CO.CORRIDA_ID = BO.CORRIDA_ID AND CO.FECCORRIDA = BO.FECCORRIDA AND BO.ACTIVO = 1 "); + sql.append(" INNER JOIN RUTA_COMBINACION RC ON RC.RUTA_ID = CO.RUTA_ID "); + sql.append(" INNER JOIN TRAMO T ON RC.TRAMO_ID = T.TRAMO_ID AND T.ORIGEN_ID = BO.ORIGEN_ID AND T.DESTINO_ID = BO.DESTINO_ID "); + sql.append(" WHERE CO.ACTIVO = 1 "); + sql.append(" AND RC.ACTIVO = 1"); + sql.append(" AND T.ACTIVO = 1"); + sql.append(" AND BO.INDSTATUSBOLETO != 'S' AND BO.MOTIVOCANCELACION_ID IS NULL "); + sql.append(" AND BO.CATEGORIA_ID <> ").append(CONSTANTE_GRATUIDADE_CRIANCA); + sql.append(" AND BO.FECCORRIDA BETWEEN :DATA_INICIO AND :DATA_FINAL "); + + if (lsNumServico.size() > 0) { + for (Corrida corrida : lsNumServico) { + if (lsNumServico.indexOf(corrida) == 0) { + sql.append(" AND BO.CORRIDA_ID IN ( " + corrida.getId().getCorridaId()); + } else { + sql.append(" , " + corrida.getId().getCorridaId() + " "); + } + } + sql.append(" ) "); + } + + sql.append(" GROUP BY CO.FECCORRIDA, CO.CORRIDA_ID, CO.ROLOPERATIVO_ID, CO.RUTA_ID, CO.EMPRESACORRIDA_ID, BO.NUMKMVIAJE, BO.BOLETO_ID, T.CANTKMREAL, "); + sql.append(" NVL(BO.IMPORTESEGURO, 0), NVL(BO.IMPORTETAXAEMBARQUE, 0), NVL(BO.IMPORTEPEDAGIO, 0), NVL(BO.PRECIOPAGADO, 0)) CJ "); + sql.append(" ON (CJ.CORRIDA_ID = C.CORRIDA_ID AND CJ.FECCORRIDA = C.FECCORRIDA AND CJ.ROLOPERATIVO_ID = C.ROLOPERATIVO_ID "); + sql.append(" AND CJ.RUTA_ID = C.RUTA_ID AND CJ.EMPRESACORRIDA_ID = C.EMPRESACORRIDA_ID) "); + sql.append("INNER JOIN PARADA ORIGEM ON (C.ORIGEN_ID = ORIGEM.PARADA_ID ) "); + sql.append("INNER JOIN PARADA DESTINO ON ( C.DESTINO_ID = DESTINO.PARADA_ID ) "); + sql.append("INNER JOIN CIUDAD CO ON (CO.CIUDAD_ID = ORIGEM.CIUDAD_ID ) "); + sql.append("INNER JOIN CIUDAD CD ON (CD.CIUDAD_ID = DESTINO.CIUDAD_ID ) "); + sql.append("INNER JOIN RUTA R ON (C.RUTA_ID = R.RUTA_ID ) "); + sql.append("LEFT JOIN GRUPO_RUTA GR ON (R.GRUPORUTA_ID = GR.GRUPORUTA_ID ) "); + sql.append("LEFT JOIN ROL_OPERATIVO RO ON (C.ROLOPERATIVO_ID = RO.ROLOPERATIVO_ID ) "); + sql.append("LEFT JOIN DIAGRAMA_AUTOBUS DA ON (DA.DIAGRAMAAUTOBUS_ID = RO.DIAGRAMAAUTOBUS_ID ) "); + sql.append("LEFT JOIN CLASE_SERVICIO CS ON (CS.CLASESERVICIO_ID = C.CLASESERVICIO_ID ) "); + sql.append("LEFT JOIN EVENTO_EXTRA EE ON (EE.CORRIDA_ID = C.CORRIDA_ID AND EE.FECCORRIDA = C.FECCORRIDA AND EE.TIPOEVENTOEXTRA_ID = 1 ) "); + sql.append("LEFT JOIN TARIFA TF ON (TF.CLASESERVICIO_ID = C.CLASESERVICIO_ID AND TF.DESTINO_ID = C.DESTINO_ID AND TF.ORIGEN_ID = C.ORIGEN_ID AND TF.MARCA_ID = C.MARCA_ID AND TF.RUTA_ID = C.RUTA_ID ) "); + sql.append("LEFT JOIN VIGENCIA_TARIFA VTF ON (TF.VIGENCIATARIFA_ID = VTF.VIGENCIATARIFA_ID AND C.FECCORRIDA BETWEEN VTF.FECINICIOVIGENCIA AND VTF.FECFINVIGENCIA ) "); + sql.append("INNER JOIN "); + sql.append("( "); + sql.append("SELECT RC.RUTA_ID, T.ORIGEN_ID, T.DESTINO_ID, NVL(T.CANTKMREAL,0) AS EXTENSAO "); + sql.append("FROM RUTA_COMBINACION RC "); + sql.append("INNER JOIN TRAMO T ON RC.TRAMO_ID = T.TRAMO_ID "); + sql.append("WHERE RC.ACTIVO = 1 "); + sql.append(") TB5 ON TB5.RUTA_ID = C.RUTA_ID "); + sql.append("AND TB5.ORIGEN_ID = ORIGEM.PARADA_ID "); + sql.append("AND TB5.DESTINO_ID = DESTINO.PARADA_ID "); + sql.append("WHERE C.FECCORRIDA BETWEEN :DATA_INICIO AND :DATA_FINAL "); + + sql.append(" "); + + if (lsNumServico.size() > 0) { + for (Corrida corrida : lsNumServico) { + if (lsNumServico.indexOf(corrida) == 0) { + sql.append(" AND C.CORRIDA_ID IN ( " + corrida.getId().getCorridaId()); + } else { + sql.append(" , " + corrida.getId().getCorridaId() + " "); + } + } + sql.append(" ) "); + } + + sql.append(grupoRuta == null ? "" : " AND R.GRUPORUTA_ID IN ( " + grupoRuta.getGrupoRutaId() + " ) "); + + if (lsNumLinha.size() > 0) { + for (Ruta ruta : lsNumLinha) { + if (lsNumLinha.indexOf(ruta) == 0) { + sql.append(" AND R.RUTA_ID IN ( " + ruta.getRutaId()); + } else { + sql.append(" , " + ruta.getRutaId() + " "); + } + } + sql.append(" ) "); + } + + sql.append(tipoServico > 0 ? " AND C.TIPOSERVICIO_ID = " + tipoServico + " " : ""); + + sql.append(" AND C.ACTIVO <> 0 AND ORIGEM.ACTIVO = 1 AND DESTINO.ACTIVO = 1 AND TB2.ORIGEM = ORIGEM.CVEPARADA AND TB2.DESTINO = DESTINO.CVEPARADA "); + sql.append("AND R.ACTIVO = 1 AND RO.ACTIVO = 1 AND DA.ACTIVO = 1 AND CS.ACTIVO = 1 "); + sql.append("GROUP BY R.RUTA_ID, R.DESCRUTA, NVL(GR.DESCGRUPO, 'Não Definido'), TO_CHAR(C.FECHORSALIDA, 'HH24:MI'), C.CORRIDA_ID, R.INDSENTIDOIDA, "); + sql.append(" DA.CANTASIENTOS, CS.DESCCLASE, TB5.EXTENSAO, TB2.ORD, TB2.EXTRA, ABSOL, "); + sql.append(" CO.ESTADO_ID, CD.ESTADO_ID, ORIGEM.CVEPARADA, DESTINO.CVEPARADA, CJ.PRECIOPAGADO, "); + sql.append(" CJ.IMPORTESEGURO, CJ.IMPORTETAXAEMBARQUE, CJ.IMPORTEPEDAGIO, "); + sql.append(" CJ.EQUIVALENTE, CJ.KM_REAL , CJ.BOLETO_ID ) "); + sql.append("GROUP BY GRUPO_RUTA, HORA, DESCRUTA, SERVICO, SENTIDO, LOT, CLA, TARIFA, ORIGEM, DESTINO, "); + sql.append(" EXTENSAO, BAGAGENS, ORD, EXTRA, TIPO_LINHA, ABSOL "); + sql.append("ORDER BY TIPO_LINHA, GRUPO_RUTA, SERVICO, ORIGEM, DESTINO "); + + return sql.toString(); + } + + + private String buscarConstante(String nomeConstante) { + ConstanteService constanteService = (ConstanteService) AppContext.getApplicationContext().getBean("constanteService"); + return constanteService.buscarPorNomeConstante(nomeConstante).getValorconstante(); + } + + protected void mesclarDataHora(Calendar pData, Calendar pHora) { + pData.set(Calendar.HOUR_OF_DAY, pHora.get(Calendar.HOUR_OF_DAY)); + pData.set(Calendar.MINUTE, pHora.get(Calendar.MINUTE)); + pData.set(Calendar.SECOND, pHora.get(Calendar.SECOND)); + + } +} diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioLinhasHorarioSimplificado_pt_BR.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioLinhasHorarioSimplificado_pt_BR.properties new file mode 100644 index 000000000..86c7ababb --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioLinhasHorarioSimplificado_pt_BR.properties @@ -0,0 +1,60 @@ +#geral +msg.noData=Não foi possivel obter dados com os parâmetros informados. +msg.a=à + +#Labels header +header.titulo.relatorio=Resumo de Linhas por Horário - RLH +header.periodo=Per\u00EDodo\: +header.data.hora=Data/Hora\: +header.pagina=P\u00E1gina\: +header.filtro=Filtro\: +header.filtro.servico=Servi\u00E7o\: +header.filtro.linha=Linha\: +header.filtro.grupo=Grupo de Linhas\: +cabecalho.impressorPor=Impresso por + +#Labels detail + +detail.receita=RECEITA +detail.viagens=VIAGENS +detail.passageiros=PASSAGEIROS +detail.parametrosOperacionais=PARÂMETROS OPERACIONAIS +detail.hora=Hora +detail.servico=Serviço +detail.trecho=Trecho +detail.setido=Sentido +detail.lot=Lot. +detail.cal=Cla. +detail.extensao=Extensão +detail.tarifa=Tarifa +detail.passagens=Passagens +detail.seguro=Seguro +detail.bagagens=Bagagens +detail.segOpc=Tx. Embarque +detail.total=Total +detail.ord=Ord. +detail.extra=Extra +detail.totalViagem=Total +detail.km.rodad=Km Rodad. +detail.absol=Absol. +detail.equivalente=Equivalente +detail.mpa=MPA +detail.mpe=MPE +detail.rsKm=R$/Km +detail.eq=Eq. +detail.rsViagem=R$/Viagem +detail.paxOfer=Pax.Km Ofer. +detail.paxTrans=Pax.Km Transportado +detail.iap=IAP% +detail.pedagio=Pedágio +detail.linha=Linha + +#Group + +group.total=Total do Grupo +sub.total=Sub Total +total.geral=Total Geral + +linhas=Linhas + + diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioLinhasHorario_pt_BR.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioLinhasHorario_pt_BR.properties index 0c458ecbc..160257214 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioLinhasHorario_pt_BR.properties +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioLinhasHorario_pt_BR.properties @@ -11,6 +11,7 @@ header.filtro=Filtro\: header.filtro.servico=Servi\u00E7o\: header.filtro.linha=Linha\: header.filtro.grupo=Grupo de Linhas\: +cabecalho.impressorPor=Impresso por #Labels detail diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioLinhasHorario.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioLinhasHorario.jasper index 4bb74426e..f0ce59170 100644 Binary files a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioLinhasHorario.jasper and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioLinhasHorario.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioLinhasHorario.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioLinhasHorario.jrxml index 24dc401af..807f48402 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioLinhasHorario.jrxml +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioLinhasHorario.jrxml @@ -1,8 +1,8 @@ - - + + @@ -32,6 +32,7 @@ + @@ -239,174 +240,160 @@ - - - - - - - - + - - - - - - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -418,169 +405,169 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -594,298 +581,323 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - - - - - - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -894,196 +906,196 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1103,149 +1115,149 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1254,7 +1266,8 @@ - + + diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioLinhasHorarioSimplificado.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioLinhasHorarioSimplificado.jasper new file mode 100644 index 000000000..c1fa77ba0 Binary files /dev/null and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioLinhasHorarioSimplificado.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioLinhasHorarioSimplificado.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioLinhasHorarioSimplificado.jrxml new file mode 100644 index 000000000..7fb2c9171 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioLinhasHorarioSimplificado.jrxml @@ -0,0 +1,611 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band splitType="Stretch"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioLinhasHorarioBean.java b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioLinhasHorarioBean.java index fb6a46f76..fadf52629 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioLinhasHorarioBean.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioLinhasHorarioBean.java @@ -41,6 +41,8 @@ public class RelatorioLinhasHorarioBean { private BigDecimal ordLinha; private BigDecimal extraLinha; private BigDecimal somaExtensaoTrecho; + private String descRuta; + public RelatorioLinhasHorarioBean() { } @@ -354,4 +356,11 @@ public class RelatorioLinhasHorarioBean { public void setSomaExtensaoTrecho(BigDecimal somaExtensaoTrecho) { this.somaExtensaoTrecho = somaExtensaoTrecho; } + public String getDescRuta() { + return descRuta; + } + + public void setDescRuta(String descRuta) { + this.descRuta = descRuta; + } } diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioLinhasHorarioController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioLinhasHorarioController.java index 02ee43324..2673b6786 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioLinhasHorarioController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioLinhasHorarioController.java @@ -17,23 +17,27 @@ import org.zkoss.util.resource.Labels; import org.zkoss.zhtml.Messagebox; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.event.Event; +import org.zkoss.zul.Checkbox; import org.zkoss.zul.Combobox; import org.zkoss.zul.Datebox; import org.zkoss.zul.Intbox; import org.zkoss.zul.Radio; import org.zkoss.zul.Textbox; +import org.zkoss.zul.Timebox; import com.rjconsultores.ventaboletos.entidad.Corrida; import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.GrupoRuta; import com.rjconsultores.ventaboletos.entidad.Ruta; import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioLinhasHorario; +import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioLinhasHorarioSimplificado; import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; import com.rjconsultores.ventaboletos.service.CorridaService; import com.rjconsultores.ventaboletos.service.EmpresaService; import com.rjconsultores.ventaboletos.service.GrupoRutaService; import com.rjconsultores.ventaboletos.service.RutaService; import com.rjconsultores.ventaboletos.utilerias.DateUtil; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; import com.rjconsultores.ventaboletos.web.utilerias.MyListbox; import com.rjconsultores.ventaboletos.web.utilerias.render.RenderCorridaOrigemDestino; @@ -84,6 +88,9 @@ public class RelatorioLinhasHorarioController extends MyGenericForwardComposer { private Radio rdOrdinario; private Radio rdExtraOrdinario; private Radio rdTodos; + private Checkbox chkSimplificado; + private Timebox horaInicial; + private Timebox horaFinal; @SuppressWarnings({ "unchecked", "rawtypes" }) private void executarRelatorio() throws Exception { @@ -116,6 +123,11 @@ public class RelatorioLinhasHorarioController extends MyGenericForwardComposer { parametros.put("DATA_INICIO", dataInicio); parametros.put("DATA_FINAL", dataFinal); + + parametros.put("ISSIMPLIFICADO", chkSimplificado.isChecked()); + parametros.put("USUARIO_ID", UsuarioLogado.getUsuarioLogado().getUsuarioId().toString()); + parametros.put("NOME_USUARIO", UsuarioLogado.getUsuarioLogado().getNombusuario().toString()); + if(cmbEmpresa.getSelectedItem() != null && cmbEmpresa.getSelectedItem().getValue() != null) { Empresa empresa = (Empresa) cmbEmpresa.getSelectedItem().getValue(); @@ -145,8 +157,19 @@ public class RelatorioLinhasHorarioController extends MyGenericForwardComposer { parametros.put("lsNumLinha", lsNumLinha); parametros.put("lsNumServico", lsNumServico); - - Relatorio relatorio = new RelatorioLinhasHorario(parametros, dataSourceRead.getConnection()); + Relatorio relatorio = null; + if(!chkSimplificado.isChecked()) { + relatorio = new RelatorioLinhasHorario(parametros, dataSourceRead.getConnection()); + }else { + if(horaInicial.getValue() != null){ + parametros.put("HORA_INICIAL", horaInicial.getValue()); + } + if(horaFinal.getValue()!= null){ + parametros.put("HORA_FINAL", horaFinal.getValue()); + } + relatorio = new RelatorioLinhasHorarioSimplificado(parametros, dataSourceRead.getConnection()); + + } Map args = new HashMap(); args.put("relatorio", relatorio); diff --git a/web/WEB-INF/i3-label_pt_BR.label b/web/WEB-INF/i3-label_pt_BR.label index 6f6d153c8..e6dd80224 100644 --- a/web/WEB-INF/i3-label_pt_BR.label +++ b/web/WEB-INF/i3-label_pt_BR.label @@ -643,6 +643,9 @@ relatorioLinhasHorarioController.rdTipoServico.label = Tipos de Serviços relatorioLinhasHorarioController.rdOrdinario.label = Ordinários relatorioLinhasHorarioController.rdExtraOrdinario.label = Extraordinários relatorioLinhasHorarioController.rdTodos.label = Todos +relatorioLinhasHorarioController.lblSimplificado.value = Emite relatório Simplificado +relatorioLinhasHorarioController.lbHoraSaidaInicial.value = Hora Saída +relatorioLinhasHorarioController.lbHoraSaidaFinal.value = à #Relatorio Trecho Vendido relatorioTrechoVendidoController.lbDataIni.value = Data Inicial @@ -918,7 +921,7 @@ relatorioDemandasController.lbFiltrarGratuidadeCrianca.value = Excluir Gratuidad relatorioDemandasController.lbTipoRelatorioDetalhado.value = Detalhado relatorioDemandasController.lbTipoRelatorioDiario.value = Diário relatorioDemandasController.lbTipoRelatorioConsolidado.value = Consolidado -relatorioDemandasController.ConstanteGratuidadeError = A constante 'GRATUIDADE CRIANÇA' não esta definida no banco de dados +relatorioDemandasController.ConstanteGratuidadeError = A constante 'GRATUIDADE CRIANÇA' não esta definida no banco de dadosf #Relatorio de Cancelamento de Passagem por Cartão relatorioCancelamentoVendaCartaoController.window.title = Relatório de Cancelamento de Venda por Cartão diff --git a/web/gui/relatorios/filtroRelatorioLinhasHorario.zul b/web/gui/relatorios/filtroRelatorioLinhasHorario.zul index b3024164b..ebe830c87 100644 --- a/web/gui/relatorios/filtroRelatorioLinhasHorario.zul +++ b/web/gui/relatorios/filtroRelatorioLinhasHorario.zul @@ -7,15 +7,15 @@ - - - - + + + + @@ -32,6 +32,20 @@ format="dd/MM/yyyy" constraint="no empty" maxlength="10" /> + + @@ -82,7 +96,6 @@ - @@ -220,6 +233,13 @@ + + + + + +