diff --git a/pom.xml b/pom.xml index a866012fe..9a8244bcc 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 br.com.rjconsultores ventaboletosadm - 1.96.0 + 1.97.0 war diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioVendasRequisicaoDetalhado.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioVendasRequisicaoDetalhado.java new file mode 100644 index 000000000..5b768ee99 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioVendasRequisicaoDetalhado.java @@ -0,0 +1,218 @@ +package com.rjconsultores.ventaboletos.relatorios.impl; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import com.rjconsultores.ventaboletos.relatorios.utilitarios.DataSource; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioVendasRequisicaoBean; +import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement; + +import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; + +public class RelatorioVendasRequisicaoDetalhado extends Relatorio { + + private static Logger log = LogManager.getLogger(RelatorioVendasRequisicaoDetalhado.class); + + private List lsDadosRelatorio; + + private String fecInicio; + private String fecFinal; + private Integer empresaId; + private Integer puntoventaId; + private Integer secretariaId; + private boolean agruparCliente; + + public RelatorioVendasRequisicaoDetalhado(Map parametros, Connection conexao, boolean agruparCliente) throws Exception { + super(parametros, conexao); + + this.agruparCliente = agruparCliente; + + this.setCustomDataSource(new DataSource(this) { + + @Override + public void initDados() throws Exception { + Map parametros = this.relatorio.getParametros(); + fecInicio = parametros.get("dataFiltroInicial").toString(); + fecFinal = parametros.get("dataFiltroFinal").toString(); + if(parametros.get("EMPRESA_ID")!=null){ + empresaId = Integer.valueOf(parametros.get("EMPRESA_ID").toString()); + } + if(parametros.get("PUNTOVENTA_ID")!=null){ + puntoventaId = Integer.valueOf(parametros.get("PUNTOVENTA_ID").toString()); + } + if(parametros.get("SECRETARIA_ID")!=null){ + secretariaId = Integer.valueOf(parametros.get("SECRETARIA_ID").toString()); + } + + Connection conexao = this.relatorio.getConexao(); + processarVendasRequisicao(conexao); + + setCollectionDataSource(new JRBeanCollectionDataSource(lsDadosRelatorio)); + } + + }); + } + + private void processarVendasRequisicao(Connection conexao) { + ResultSet rset = null; + NamedParameterStatement stmt = null; + + try { + + stmt = carregarNamedParameterStatement(conexao); + rset = stmt.executeQuery(); + processarResultado(rset); + fecharConexaoBanco(conexao, stmt, rset); + + } catch (Exception e) { + log.error(e.getMessage(), e); + } + + } + + private void fecharConexaoBanco(Connection conexao, NamedParameterStatement stmt, ResultSet rset) { + try { + if(rset != null && !rset.isClosed()) { + rset.close(); + } + if(stmt != null && !stmt.isClosed()) { + stmt.close(); + } + if(conexao != null && !conexao.isClosed()) { + conexao.close(); + } + } catch (SQLException e) { + log.error(e.getMessage(), e); + } + } + + private void processarResultado(ResultSet rset) throws SQLException { + if(lsDadosRelatorio == null) { + lsDadosRelatorio = new ArrayList(); + } + + while (rset.next()) { + RelatorioVendasRequisicaoBean bean = new RelatorioVendasRequisicaoBean(); + bean.setNumdocumento(rset.getString("REQUISICAO")); + bean.setSecretariaId(rset.getInt("SECRETARIA_ID")); + bean.setDescsecretaria(rset.getString("DESCSECRETARIA")); + bean.setPuntoventaId(rset.getInt("PUNTOVENTA_ID")); + bean.setBpe(rset.getInt("BPE")); + bean.setPassageiro(rset.getString("nombpasajero")); + bean.setDataVenda(rset.getDate("FECHORVENTA")); + bean.setNombpuntoventa(rset.getString("NOMBPUNTOVENTA")); + bean.setNombempresa(rset.getString("NOMBEMPRESA")); + bean.setEmpresaId(rset.getInt("EMPRESA_ID")); + bean.setOrigemId(rset.getString("ORIGEM_ID")); + bean.setOrigem(rset.getString("ORIGEM")); + bean.setDestinoId(rset.getString("DESTINO_ID")); + bean.setDestino(rset.getString("DESTINO")); + bean.setImporte(rset.getBigDecimal("IMPORTE")); + + if (agruparCliente) { + bean.setDescricaogrupo(bean.getSecretariaId() + "- " + bean.getDescsecretaria()); + } else { + bean.setDescricaogrupo(bean.getNombpuntoventa()); + } + + lsDadosRelatorio.add(bean); + } + + } + + private NamedParameterStatement carregarNamedParameterStatement(Connection conexao) throws SQLException { + String sql = getSql(); + log.info(sql); + + NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql); + + if(fecInicio != null) { + stmt.setString("fecInicio", fecInicio); + } + if(fecFinal != null) { + stmt.setString("fecFinal", fecFinal); + } + if(empresaId != null) { + stmt.setInt("EMPRESA_ID", empresaId); + } + if(puntoventaId != null && puntoventaId > -1) { + stmt.setInt("PUNTOVENTA_ID", puntoventaId); + } + if(secretariaId != null && secretariaId > -1) { + stmt.setInt("SECRETARIA_ID", secretariaId); + } + + return stmt; + } + + protected String getSql() { + + StringBuilder sQuery = new StringBuilder(); + sQuery.append("SELECT CDP.NUMDOCUMENTO AS REQUISICAO, SEC.CVESECRETARIA AS SECRETARIA_ID, SEC.DESCSECRETARIA, ORI.CVEPARADA AS ORIGEM_ID, ORI.DESCPARADA AS ORIGEM, DES.CVEPARADA AS DESTINO_ID, DES.DESCPARADA AS DESTINO, PV.PUNTOVENTA_ID AS PUNTOVENTA_ID, PV.NOMBPUNTOVENTA, E.NOMBEMPRESA, E.EMPRESA_ID, FP.DESCPAGO AS DESCPAGO, CFP.FORMAPAGO_ID, bpe.nbp as BPE, c.nombpasajero, C.FECHORVENTA, ") + .append(" CASE WHEN C.MOTIVOCANCELACION_ID IS NULL THEN COUNT(*) ELSE COUNT(*) * -1 end AS qtde, ") + .append(" SUM( CASE WHEN C.MOTIVOCANCELACION_ID IS NULL THEN cfp.importe ELSE cfp.importe * -1 end) AS importe ") + .append("FROM CAJA C ") + .append("JOIN PARADA ORI ON ORI.PARADA_ID = C.ORIGEN_ID ") + .append("JOIN PARADA DES ON DES.PARADA_ID = C.DESTINO_ID ") + .append("JOIN CAJA_FORMAPAGO CFP ON CFP.CAJA_ID = C.CAJA_ID AND CFP.ACTIVO = 1 ") + .append("LEFT JOIN CAJA_DET_PAGO CDP ON CDP.CAJAFORMAPAGO_ID = CFP.CAJAFORMAPAGO_ID AND CDP.ACTIVO = 1 ") + .append("JOIN SECRETARIA SEC ON CDP.OPCIONAL1 = SEC.SECRETARIA_ID ") + .append("JOIN FORMA_PAGO FP ON FP.FORMAPAGO_ID = CFP.FORMAPAGO_ID ") + .append("JOIN MARCA M ON C.MARCA_ID = M.MARCA_ID ") + .append("JOIN EMPRESA E ON E.EMPRESA_ID = M.EMPRESA_ID ") + .append("JOIN PUNTO_VENTA PV ON PV.PUNTOVENTA_ID = C.PUNTOVENTA_ID ") + .append("LEFT JOIN BPE bpe on ( c.transacao_id = bpe.boleto_id ) ") + .append("WHERE (FP.FORMAPAGO_ID = 11 OR FP.TIPO_PAGO = 6) ") + .append("AND C.ACTIVO = 1 ") + .append("AND C.INDREIMPRESION = 0 "); + + if(fecInicio != null) { + sQuery.append("AND NVL(C.FECHORVENTA_H,C.FECHORVENTA) >= TO_DATE(:fecInicio, 'dd/mm/yyyy hh24:mi') "); + } + if(fecFinal != null) { + sQuery.append("AND NVL(C.FECHORVENTA_H,C.FECHORVENTA) <= TO_DATE(:fecFinal, 'dd/mm/yyyy hh24:mi') "); + } + if(empresaId != null) { + sQuery.append("AND E.EMPRESA_ID = :EMPRESA_ID "); + } + if(puntoventaId != null && puntoventaId > -1) { + sQuery.append("AND C.PUNTOVENTA_ID = :PUNTOVENTA_ID "); + } + if(secretariaId != null && secretariaId > -1) { + sQuery.append("AND SEC.SECRETARIA_ID = :SECRETARIA_ID "); + } + + sQuery.append("GROUP BY CDP.NUMDOCUMENTO, SEC.CVESECRETARIA, SEC.DESCSECRETARIA,PV.NOMBPUNTOVENTA, PV.NOMBPUNTOVENTA, E.NOMBEMPRESA, E.EMPRESA_ID, FP.DESCPAGO, CFP.FORMAPAGO_ID, ORI.DESCPARADA, DES.DESCPARADA, CFP.IMPORTE, ORI.CVEPARADA, DES.CVEPARADA, PV.PUNTOVENTA_ID, C.MOTIVOCANCELACION_ID, bpe.NBP, c.nombpasajero, C.FECHORVENTA "); + + if (agruparCliente) { + sQuery.append("ORDER BY SEC.DESCSECRETARIA, PV.NOMBPUNTOVENTA, FP.DESCPAGO"); + } else { + sQuery.append("ORDER BY PV.NOMBPUNTOVENTA, SEC.DESCSECRETARIA, ori.cveparada, des.cveparada "); + } + + return sQuery.toString(); + + } + + @Override + protected void processaParametros() throws Exception { + } + + public List getLsDadosRelatorio() { + return lsDadosRelatorio; + } + + @Override + public String getNome() { + return super.getNome(); + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasRequisicaoDetalhado_en.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasRequisicaoDetalhado_en.properties new file mode 100644 index 000000000..c58ffc3c5 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasRequisicaoDetalhado_en.properties @@ -0,0 +1,28 @@ +#geral +msg.noData=It was not possible to obtain data with the provided parameters. + +#Labels cabeçalho +cabecalho.nome=Request Sales Report +cabecalho.relatorio=Report: +cabecalho.periodo=Period: +cabecalho.periodoA=to +cabecalho.dataHora=Date/Time: +cabecalho.impressorPor=Printed by: +cabecalho.pagina=Page +cabecalho.de=of +cabecalho.filtros=Filters: +cabecalho.usuario=User: +label.date=Date +label.COD = COD +label.empresa = Company +label.REQ = REQ. No +label.origem = Origin +label.destino = Destination +label.bpe = BPe +label.nome = Passenger Name +label.nombPuntoVenta=Agency +label.total=Total +label.puntoVenta=Agency: +label.diferenca=Difference +label.cliente=Client +label.total=Total \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasRequisicaoDetalhado_es.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasRequisicaoDetalhado_es.properties new file mode 100644 index 000000000..e14b54e3e --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasRequisicaoDetalhado_es.properties @@ -0,0 +1,28 @@ +#geral +msg.noData=No fue posible obtener datos con los parámetros informados. + +#Labels cabeçalho +cabecalho.nome=Informe de Ventas de Requisición +cabecalho.relatorio=Informe: +cabecalho.periodo=Período: +cabecalho.periodoA=a +cabecalho.dataHora=Fecha/Hora: +cabecalho.impressorPor=Impreso por: +cabecalho.pagina=Página +cabecalho.de=de +cabecalho.filtros=Filtros: +cabecalho.usuario=Usuario: +label.data=Fecha +label.COD = COD +label.empresa = Empresa +label.REQ = REQ. N +label.origem = Origen +label.destino = Destino +label.bpe = BPe +label.nome = Nombre del Pasajero +label.nombPuntoVenta=Agencia +label.total=Total +label.puntoVenta=Agencia: +label.diferenca=Diferencia +label.cliente=Cliente +label.total=Total \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasRequisicaoDetalhado_fr.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasRequisicaoDetalhado_fr.properties new file mode 100644 index 000000000..b49facb42 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasRequisicaoDetalhado_fr.properties @@ -0,0 +1,28 @@ +#geral +msg.noData=Impossible d'obtenir des données avec les paramètres informés. + +#Labels cabeçalho +cabecalho.nome=Rapport de Ventes de Requête +cabecalho.relatorio=Rapport: +cabecalho.periodo=Période: +cabecalho.periodoA=à +cabecalho.dataHora=Date/Heure: +cabecalho.impressorPor=Imprimé par: +cabecalho.pagina=Page +cabecalho.de=de +cabecalho.filtros=Filtres: +cabecalho.usuario=Utilisateur: +label.data=Date +label.COD = COD +label.empresa = Entreprise +label.REQ = REQ. N +label.origem = Origine +label.destino = Destination +label.bpe = BPe +label.nome = Nom du Passager +label.nombPuntoVenta=Agence +label.total=Total +label.puntoVenta=Agence: +label.diferenca=Différence +label.cliente=Client +label.total=Total \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasRequisicaoDetalhado_pt_BR.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasRequisicaoDetalhado_pt_BR.properties new file mode 100644 index 000000000..7dd5ac5b7 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasRequisicaoDetalhado_pt_BR.properties @@ -0,0 +1,28 @@ +#geral +msg.noData=Não foi possivel obter dados com os parâmetros informados. + +#Labels cabeçalho +cabecalho.nome=Relatório Vendas Requisição +cabecalho.relatorio=Relatório: +cabecalho.periodo=Período: +cabecalho.periodoA=à +cabecalho.dataHora=Data/Hora: +cabecalho.impressorPor=Impressor por: +cabecalho.pagina=Página +cabecalho.de=de +cabecalho.filtros=Filtros: +cabecalho.usuario=Usuário: +label.data=Data +label.COD = COD +label.empresa = Empresa +label.REQ = REQ. N +label.origem = Origen +label.destino = Destino +label.bpe = BPe +label.nome = Nome Passageiro +label.nombPuntoVenta=Agência +label.total=Total +label.puntoVenta=Agência: +label.diferenca=Diferença +label.cliente=Cliente +label.total=Total \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasInternetPTA.jrxml.bak b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasInternetPTA.jrxml.bak new file mode 100644 index 000000000..e337a398b --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasInternetPTA.jrxml.bak @@ -0,0 +1,384 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="32"> + <textField> + <reportElement x="191" y="5" width="382" height="27" uuid="766b74e4-28c9-4045-8538-343a8bc8e665"/> + <textElement textAlignment="Center" verticalAlignment="Middle"> + <font size="18" isBold="true"/> + </textElement> + <textFieldExpression><![CDATA[$R{cabecalho.nome}]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasRequisicaoDetalhado.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasRequisicaoDetalhado.jasper new file mode 100644 index 000000000..4f8326975 Binary files /dev/null and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasRequisicaoDetalhado.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasRequisicaoDetalhado.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasRequisicaoDetalhado.jrxml new file mode 100644 index 000000000..aa2a2938e --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasRequisicaoDetalhado.jrxml @@ -0,0 +1,298 @@ + + + + + +