diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioSegundaViaSeguroOpcional.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioSegundaViaSeguroOpcional.java new file mode 100644 index 000000000..00da7f53e --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioSegundaViaSeguroOpcional.java @@ -0,0 +1,164 @@ +package com.rjconsultores.ventaboletos.relatorios.impl; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +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.relatorios.utilitarios.DataSource; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioSegundaViaBean; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioSegundaViaSeguroOpcionalBean; +import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement; + +import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; + +public class RelatorioSegundaViaSeguroOpcional extends Relatorio { + + private static Logger log = Logger.getLogger(RelatorioSegundaViaSeguroOpcional.class); + private SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); + private List lsDadosRelatorio; + + public RelatorioSegundaViaSeguroOpcional(Map parametros, Connection conexao) throws Exception { + super(parametros, conexao); + + this.setCustomDataSource(new DataSource(this) { + @Override + public void initDados() throws Exception { + + Map parametros = this.relatorio.getParametros(); + + Date dataInicial = (Date) parametros.get("dataInicial"); + Date dataFinal = (Date) parametros.get("dataFinal"); + Integer empresaId = (Integer) parametros.get("empresaId"); + Integer puntoVentaId = (Integer) parametros.get("puntoVentaId"); + + String sql = getSqlDados(dataInicial, dataFinal, empresaId, puntoVentaId); + ResultSet rset = null; + NamedParameterStatement stmt = null; + Connection conexao = this.relatorio.getConexao(); + + stmt = new NamedParameterStatement(conexao, sql); + stmt.setTimestamp("dataInicial", getDataHoraInicial(dataInicial)); + stmt.setTimestamp("dataFinal", getDataHoraFinal(dataFinal)); + + parametros.put("dataInicial", sdf.format(dataInicial)); + parametros.put("dataFinal", sdf.format(dataFinal)); + try { + rset = stmt.executeQuery(); + + lsDadosRelatorio = new ArrayList(); + while (rset.next()) { + lsDadosRelatorio.add(criarRelatorioSegundaViaBean(rset)); + } + setCollectionDataSource(new JRBeanCollectionDataSource(lsDadosRelatorio)); + } catch (Exception e) { + log.error(e.getMessage(), e); + } finally { + try { + if (rset != null) { + rset.close(); + } + if (stmt != null) { + stmt.close(); + } + } catch (SQLException e) { + log.error(e.getMessage(), e); + } + } + } + + private RelatorioSegundaViaSeguroOpcionalBean criarRelatorioSegundaViaBean(ResultSet rset) throws SQLException { + RelatorioSegundaViaSeguroOpcionalBean r = new RelatorioSegundaViaSeguroOpcionalBean(); + + r.setBilheteiro(rset.getString("bilheteiro")); + r.setBilhete(rset.getString("numfoliosistema")); + r.setDataVenda(rset.getDate("dataVenda")); + r.setDataViagem(rset.getDate("dataViagem")); + r.setSeguro(rset.getBigDecimal("seguro")); + r.setNomeAgencia(rset.getString("nomeAgencia")); + r.setLinha(rset.getString("linha")); + r.setNumBpe(rset.getString("numBpe")); + r.setNumeroApolice(rset.getString("numeroApolice")); + return r; + } + }); + } + + public void setLsDadosRelatorio(List lsDadosRelatorio) { + this.setCollectionDataSource(new JRBeanCollectionDataSource(lsDadosRelatorio)); + this.lsDadosRelatorio = lsDadosRelatorio; + } + + private String getSqlDados(Date dataInicial, Date dataFinal, Integer empresaId, Integer puntoVentaId) { + StringBuilder sql = new StringBuilder(); + + sql.append("SELECT DISTINCT B.BOLETO_ID, "); + sql.append(" PT.NOMBPUNTOVENTA AS nomeAgencia, "); + sql.append(" USUARIO.NOMBUSUARIO AS bilheteiro, "); + sql.append(" B.FECHORVENTA AS dataVenda, "); + sql.append(" B.FECHORVIAJE AS dataViagem, "); + sql.append(" R.DESCRUTA AS linha,"); + sql.append(" B.NUMFOLIOSISTEMA as numfoliosistema, "); + sql.append(" SEG.VALOR AS seguro, "); + sql.append(" B.NUM_BPE AS numBpe, "); + sql.append(" SEG.NUMSEGURO AS numeroApolice "); + sql.append("FROM BOLETO B "); + sql.append("INNER JOIN EVENTO_EXTRA EE ON (EE.BOLETO_ID = B.BOLETO_ID) "); + sql.append("INNER JOIN USUARIO USUARIO ON B.USUARIO_ID = USUARIO.USUARIO_ID "); + sql.append("INNER JOIN RUTA R ON R.RUTA_ID = B.RUTA_ID "); + sql.append("INNER JOIN PUNTO_VENTA PT ON PT.PUNTOVENTA_ID = B.PUNTOVENTA_ID "); + sql.append("INNER JOIN SEGPOLV SEG ON (SEG.BOLETO_ID = B.BOLETO_ID) "); + + + sql.append("WHERE EE.INDSEGUNDAVIAIMPRESSA = 1 AND B.MOTIVOREIMPRESION_ID = 99 "); + if (dataInicial != null && dataFinal != null) { + sql.append(" AND EE.FECSEGUNDAVIA BETWEEN :dataInicial and :dataFinal "); + } + if (empresaId != null && empresaId != -1) { + sql.append(" AND B.EMPRESACORRIDA_ID = " + empresaId); + } + if (puntoVentaId != null && puntoVentaId != -1) { + sql.append(" AND B.PUNTOVENTA_ID = " + puntoVentaId); + } + sql.append(" ORDER BY B.NUMFOLIOSISTEMA, B.BOLETO_ID "); + + return sql.toString(); + } + + @Override + protected void processaParametros() throws Exception { + + } + + private Timestamp getDataHoraInicial(Date dataInicial) { + Calendar calendar = Calendar.getInstance(); + + calendar.setTime(dataInicial); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + + return new Timestamp(calendar.getTime().getTime()); + } + + private Timestamp getDataHoraFinal(Date dataFinal) { + Calendar calendar = Calendar.getInstance(); + + calendar.setTime(dataFinal); + calendar.set(Calendar.HOUR_OF_DAY, 23); + calendar.set(Calendar.MINUTE, 59); + calendar.set(Calendar.SECOND, 59); + + return new Timestamp(calendar.getTime().getTime()); + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioSegundaViaSeguroOpcional_es.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioSegundaViaSeguroOpcional_es.properties new file mode 100644 index 000000000..efd1ba043 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioSegundaViaSeguroOpcional_es.properties @@ -0,0 +1,41 @@ +cabecalho.nome=Relatório Segunda Via de Seguro Opcional +cabecalho.periodo=Período +cabecalho.periodoA=à +cabecalho.puntoVenta=Agência: +cabecalho.empresa=Empresa: +label.servico=Serviço +label.dataEmbarque=Data Embarque +label.dataSegundaVia=Data Seg.Via +label.origem=Origem +label.destino=Destino +label.codOrigem=Cod.O +label.codDestino=Cod.D +label.poltrona=Poltrona +label.dataVenda=Data Venda +label.bilheteiro=Bilheteiro +label.bilhete=Bilhete +label.puntoVenta=Agência +label.tarifa=Tarifa +label.taxa=Taxa +label.seguro=Valor Apólice +label.pedagio=Pedágio +label.coo=Coo +label.preImpresso=Pre Imp. +label.serieImpFiscal=Série +label.nomeEmpresa=Empresa +label.nomeAgencia=Agência +label.dataServico=Data Serviço +label.horaServico=Hrs.Servic +label.horaTransacao=Hora Trans. +label.linha=Linha +label.ccf=ccf +label.ecfOriginal=ECF.ORI +label.ecfSegundaVia=ECF.2º via +label.utr=UTR +label.tpp=TPP +label.siglaTipoPassagem=Sigl.Tip.Pass +label.tipoPassagem=Tp.Pass +label.valorTotal=Vlr.Tot +msg.noData=Não foi possivel obter dados com os parâmetros informados. +label.numBpe=BP-e +label.numeroApolice=Número Apólice \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioSegundaViaSeguroOpcional_pt_BR.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioSegundaViaSeguroOpcional_pt_BR.properties new file mode 100644 index 000000000..efd1ba043 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioSegundaViaSeguroOpcional_pt_BR.properties @@ -0,0 +1,41 @@ +cabecalho.nome=Relatório Segunda Via de Seguro Opcional +cabecalho.periodo=Período +cabecalho.periodoA=à +cabecalho.puntoVenta=Agência: +cabecalho.empresa=Empresa: +label.servico=Serviço +label.dataEmbarque=Data Embarque +label.dataSegundaVia=Data Seg.Via +label.origem=Origem +label.destino=Destino +label.codOrigem=Cod.O +label.codDestino=Cod.D +label.poltrona=Poltrona +label.dataVenda=Data Venda +label.bilheteiro=Bilheteiro +label.bilhete=Bilhete +label.puntoVenta=Agência +label.tarifa=Tarifa +label.taxa=Taxa +label.seguro=Valor Apólice +label.pedagio=Pedágio +label.coo=Coo +label.preImpresso=Pre Imp. +label.serieImpFiscal=Série +label.nomeEmpresa=Empresa +label.nomeAgencia=Agência +label.dataServico=Data Serviço +label.horaServico=Hrs.Servic +label.horaTransacao=Hora Trans. +label.linha=Linha +label.ccf=ccf +label.ecfOriginal=ECF.ORI +label.ecfSegundaVia=ECF.2º via +label.utr=UTR +label.tpp=TPP +label.siglaTipoPassagem=Sigl.Tip.Pass +label.tipoPassagem=Tp.Pass +label.valorTotal=Vlr.Tot +msg.noData=Não foi possivel obter dados com os parâmetros informados. +label.numBpe=BP-e +label.numeroApolice=Número Apólice \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioSegundaViaSeguroOpcional.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioSegundaViaSeguroOpcional.jasper new file mode 100644 index 000000000..ed7d21b05 Binary files /dev/null and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioSegundaViaSeguroOpcional.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioSegundaViaSeguroOpcional.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioSegundaViaSeguroOpcional.jrxml new file mode 100644 index 000000000..1648c7c55 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioSegundaViaSeguroOpcional.jrxml @@ -0,0 +1,236 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="109" splitType="Stretch"> + <textField> + <reportElement uuid="6d12efc3-f23b-431a-bfb1-9950e6bfe6fc" x="53" y="61" width="259" height="20"/> + <textElement/> + <textFieldExpression><![CDATA[$P{puntoVenta}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="7830e707-ce31-4907-8665-aa462d023a82" x="0" y="20" width="603" height="20"/> + <textElement> + <font isBold="true"/> + </textElement> + <textFieldExpression><![CDATA[$R{cabecalho.periodo} + " " + $P{dataInicial} + " " + $R{cabecalho.periodoA} + " " + $P{dataFinal}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="b148e230-ff82-488a-bcdd-5ceb2ea723e3" x="0" y="0" width="603" height="20"/> + <textElement markup="none"> + <font size="14" isBold="true"/> + </textElement> + <textFieldExpression><![CDATA[$R{cabecalho.nome}]]></textFieldExpression> + </textField> + <textField pattern="dd/MM/yyyy HH:mm"> + <reportElement uuid="1f9eb9ba-8865-4a88-9dbb-471a1907d3c5" x="603" y="0" width="229" height="20"/> + <textElement textAlignment="Right"> + <font isBold="true"/> + </textElement> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="47f0b61e-1ba4-43e4-9a4a-c8e17972b943" x="0" y="61" width="53" height="20"/> + <textElement/> + <textFieldExpression><![CDATA[$R{cabecalho.puntoVenta}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="f4c6e5b9-844d-440a-9a47-719101152087" x="0" y="41" width="53" height="20"/> + <textElement markup="none"/> + <textFieldExpression><![CDATA[$R{cabecalho.empresa}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="6985a79c-5487-47e6-acf7-e94ef7c24073" x="53" y="41" width="259" height="20"/> + <textElement/> + <textFieldExpression><![CDATA[$P{empresa}]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioSegundaViaSeguroOpcionalBean.java b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioSegundaViaSeguroOpcionalBean.java new file mode 100644 index 000000000..f5bb1401a --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioSegundaViaSeguroOpcionalBean.java @@ -0,0 +1,15 @@ +package com.rjconsultores.ventaboletos.relatorios.utilitarios; + +public class RelatorioSegundaViaSeguroOpcionalBean extends RelatorioSegundaViaBean { + + private String numeroApolice; + + public String getNumeroApolice() { + return numeroApolice; + } + + public void setNumeroApolice(String numeroApolice) { + this.numeroApolice = numeroApolice; + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioSegundaViaController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioSegundaViaController.java index 7ee81bcf8..820c91546 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioSegundaViaController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioSegundaViaController.java @@ -20,6 +20,7 @@ import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.PuntoVenta; import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioSegundaVia; import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioSegundaViaBoleto; +import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioSegundaViaSeguroOpcional; import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; import com.rjconsultores.ventaboletos.service.EmpresaService; import com.rjconsultores.ventaboletos.service.PuntoVentaService; @@ -50,6 +51,7 @@ public class RelatorioSegundaViaController extends MyGenericForwardComposer { private Radio rdTipoCaja; private Radio rdTipoBoleto; + private Radio rdTipoSeguroOpcional; public void onClick$btnExecutarRelatorio(Event ev) throws Exception { executarRelatorio(); @@ -77,6 +79,8 @@ public class RelatorioSegundaViaController extends MyGenericForwardComposer { relatorio = new RelatorioSegundaVia(parametros, dataSourceRead.getConnection()); } else if(rdTipoBoleto.isChecked()) { relatorio = new RelatorioSegundaViaBoleto(parametros, dataSourceRead.getConnection()); + } else if(rdTipoSeguroOpcional.isChecked()) { + relatorio = new RelatorioSegundaViaSeguroOpcional(parametros, dataSourceRead.getConnection()); } Map args = new HashMap(); diff --git a/web/WEB-INF/i3-label_es_MX.label b/web/WEB-INF/i3-label_es_MX.label index 6e2c043b1..a14be923f 100644 --- a/web/WEB-INF/i3-label_es_MX.label +++ b/web/WEB-INF/i3-label_es_MX.label @@ -998,6 +998,8 @@ relatorioSegundaViaController.lbTipoCajaDescricao.value=Emite informe basado en relatorioSegundaViaController.lbTipoBoleto.value=Ocupación relatorioSegundaViaController.lbTipoBoletoDescricao.value=Emite informe basado en la ocupación del servicio relatorioSegundaViaController.lbTipoRelatorio.value=Referência +relatorioSegundaViaController.lbTipoSeguroOpcional.value=Seguro Opcional +relatorioSegundaViaController.lbTipoSeguroOpcionalDescricao.value=Emite relatório de emissao de 2ª via de seguro opcional #Relatório de Serviço Bloqueado na Venda Internet relatorioServicoBloqueadoVendaInternetController.window.title = Reporte corrida bgloqueada en venta internet diff --git a/web/WEB-INF/i3-label_pt_BR.label b/web/WEB-INF/i3-label_pt_BR.label index 016f1d636..d21b37d3d 100644 --- a/web/WEB-INF/i3-label_pt_BR.label +++ b/web/WEB-INF/i3-label_pt_BR.label @@ -1183,6 +1183,8 @@ relatorioSegundaViaController.lbTipoCajaDescricao.value=Emite relatório baseado relatorioSegundaViaController.lbTipoBoleto.value=Ocupação relatorioSegundaViaController.lbTipoBoletoDescricao.value=Emite relatório baseado na ocupação do serviço relatorioSegundaViaController.lbTipoRelatorio.value=Referência +relatorioSegundaViaController.lbTipoSeguroOpcional.value=Seguro Opcional +relatorioSegundaViaController.lbTipoSeguroOpcionalDescricao.value=Emite relatório de emissao de 2ª via de seguro opcional #Relatorio Consulta Antt relatorioConsultaAnttController.window.title=Relatório Consulta ANTT diff --git a/web/gui/relatorios/filtroRelatorioSegundaVia.zul b/web/gui/relatorios/filtroRelatorioSegundaVia.zul index 7eb35cb0d..cc829d9fb 100644 --- a/web/gui/relatorios/filtroRelatorioSegundaVia.zul +++ b/web/gui/relatorios/filtroRelatorioSegundaVia.zul @@ -57,6 +57,9 @@ +