julio 2017-08-01 00:23:45 +00:00
parent 3cbae2c600
commit 6132f44c7e
12 changed files with 1774 additions and 337 deletions

View File

@ -0,0 +1,41 @@
package com.rjconsultores.ventaboletos.relatorios.impl;
import java.sql.Connection;
import java.util.List;
import java.util.Map;
import com.rjconsultores.ventaboletos.entidad.Estado;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
import com.rjconsultores.ventaboletos.utilerias.fiscal.vo.FiscalRdi;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
public class RelatorioRDI extends Relatorio {
@SuppressWarnings("unchecked")
public RelatorioRDI(final Map<String, Object> parametros, Connection conexao) throws Exception {
super(parametros, conexao);
List<Estado> estados = (List<Estado>) parametros.get("estados");
String ufs = null;
for (Estado estado : estados) {
if (ufs == null)
ufs = estado.getCveestado() + ";";
else
ufs = ufs + estado.getCveestado() + ";";
}
parametros.put("ufs", ufs);
this.setCustomXls(true);
List<FiscalRdi> list = (List<FiscalRdi>) parametros.get("list");
this.setCollectionDataSource(new JRBeanCollectionDataSource(list));
}
@Override
protected void processaParametros() throws Exception {
}
}

View File

@ -0,0 +1,2 @@
#geral
msg.noData=No se pudo obtener datos con los parámetros reportados.

View File

@ -0,0 +1,2 @@
#geral
msg.noData=Não foi possivel obter dados com os parâmetros informados.

View File

@ -0,0 +1,132 @@
package com.rjconsultores.ventaboletos.web.gui.controladores.impressaofiscal;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.sql.DataSource;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.zkoss.util.resource.Labels;
import org.zkoss.zhtml.Messagebox;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.WrongValueException;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zul.Datebox;
import org.zkoss.zul.Radio;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.Estado;
import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioRDI;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
import com.rjconsultores.ventaboletos.service.EmpresaService;
import com.rjconsultores.ventaboletos.service.EstadoService;
import com.rjconsultores.ventaboletos.service.FiscalService;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
import com.rjconsultores.ventaboletos.utilerias.fiscal.vo.FiscalRdi;
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.RenderEstadoUf;
@Controller("busquedaRelatorioRDIController")
@Scope("prototype")
public class BusquedaRelatorioRDIController extends MyGenericForwardComposer {
private static final long serialVersionUID = 1L;
private static Logger log = Logger.getLogger(BusquedaRelatorioRDIController.class);
@Autowired
private DataSource dataSourceRead;
@Autowired
private FiscalService fiscalService;
@Autowired
private EmpresaService empresaService;
@Autowired
private EstadoService estadoService;
private List<Empresa> lsEmpresa;
private List<Estado> lsEstado;
private Datebox datInicial;
private Datebox datFinal;
private MyComboboxEstandar cmbEmpresa;
private MyListbox estadoList;
private Radio radSim;
@Override
public void doAfterCompose(Component comp) throws Exception {
lsEmpresa = empresaService.obtenerTodos();
lsEstado = estadoService.obtenerTodos();
super.doAfterCompose(comp);
estadoList.setItemRenderer(new RenderEstadoUf());
estadoList.setData(lsEstado);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
private void executar() throws InterruptedException {
try {
Empresa empresa = cmbEmpresa.getSelectedItem() == null ? null : (Empresa) cmbEmpresa.getSelectedItem().getValue();
List<Estado> estados = new ArrayList<Estado>();
for (Object ob : estadoList.getSelectedsItens()) {
estados.add((Estado) ob);
}
List<FiscalRdi> list = fiscalService.buscarRelatorioRDI(datInicial.getValue(), datFinal.getValue(), empresa, estados, radSim.isChecked());
Map<String, Object> parametros = new HashMap<String, Object>();
parametros.put("list", list);
parametros.put("empresa", empresa.getNombempresa());
parametros.put("inicio", datInicial.getValue());
parametros.put("fim", datFinal.getValue());
parametros.put("estados", estados);
parametros.put("usuario", UsuarioLogado.getUsuarioLogado().getClaveUsuario());
Relatorio relatorio = new RelatorioRDI(parametros, dataSourceRead.getConnection());
Map args = new HashMap();
args.put("relatorio", relatorio);
openWindow("/component/reportView.zul",
Labels.getLabel("indexController.mnRelatorioRDI.label"), args, MODAL);
} catch (InterruptedException e) {
log.error("", e);
} catch (WrongValueException e) {
log.error("", e);
} catch (SQLException e) {
log.error("", e);
} catch (Exception e) {
log.error("", e);
Messagebox.show(e.getMessage(),
Labels.getLabel("indexController.mnImpressaoRMD.label"),
Messagebox.OK, Messagebox.INFORMATION);
}
}
public void onClick$btnExecutar(Event ev) throws InterruptedException {
executar();
}
public List<Empresa> getLsEmpresa() {
return lsEmpresa;
}
public List<Estado> getLsEstado() {
return lsEstado;
}
}

View File

@ -1,337 +0,0 @@
/**
*
*/
package com.rjconsultores.ventaboletos.web.utilerias;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.sql.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
public class NamedParameterStatement {
/** The statement this object is wrapping. */
private final PreparedStatement statement;
/** Maps parameter names to arrays of ints which are the parameter indices. */
private final Map indexMap;
/**
* Creates a NamedParameterStatement. Wraps a call to c.{@link Connection#prepareStatement(java.lang.String) prepareStatement}.
*
* @param connection
* the database connection
* @param query
* the parameterized query
* @throws SQLException
* if the statement could not be created
*/
public NamedParameterStatement(Connection connection, String query) throws
SQLException {
indexMap = new HashMap();
String parsedQuery = parse(query, indexMap);
statement = connection.prepareStatement(parsedQuery);
}
/**
* Parses a query with named parameters. The parameter-index mappings are put into the map, and the parsed query is returned. DO NOT CALL FROM CLIENT CODE. This method is non-private so JUnit code can test it.
*
* @param query
* query to parse
* @param paramMap
* map to hold parameter-index mappings
* @return the parsed query
*/
static final String parse(String query, Map paramMap) {
// I was originally using regular expressions, but they didn't work well for ignoring
// parameter-like strings inside quotes.
int length = query.length();
StringBuffer parsedQuery = new StringBuffer(length);
boolean inSingleQuote = false;
boolean inDoubleQuote = false;
int index = 1;
for (int i = 0; i < length; i++) {
char c = query.charAt(i);
if (inSingleQuote) {
if (c == '\'') {
inSingleQuote = false;
}
} else if (inDoubleQuote) {
if (c == '"') {
inDoubleQuote = false;
}
} else {
if (c == '\'') {
inSingleQuote = true;
} else if (c == '"') {
inDoubleQuote = true;
} else if (c == ':' && i + 1 < length &&
Character.isJavaIdentifierStart(query.charAt(i + 1))) {
int j = i + 2;
while (j < length && Character.isJavaIdentifierPart(query.charAt(j))) {
j++;
}
String name = query.substring(i + 1, j);
c = '?'; // replace the parameter with a question mark
i += name.length(); // skip past the end if the parameter
List indexList = (List) paramMap.get(name);
if (indexList == null) {
indexList = new LinkedList();
paramMap.put(name, indexList);
}
indexList.add(new Integer(index));
index++;
}
}
parsedQuery.append(c);
}
// replace the lists of Integer objects with arrays of ints
for (Iterator itr = paramMap.entrySet().iterator(); itr.hasNext();) {
Map.Entry entry = (Map.Entry) itr.next();
List list = (List) entry.getValue();
int[] indexes = new int[list.size()];
int i = 0;
for (Iterator itr2 = list.iterator(); itr2.hasNext();) {
Integer x = (Integer) itr2.next();
indexes[i++] = x.intValue();
}
entry.setValue(indexes);
}
return parsedQuery.toString();
}
/**
* Returns the indexes for a parameter.
*
* @param name
* parameter name
* @return parameter indexes
* @throws IllegalArgumentException
* if the parameter does not exist
*/
private int[] getIndexes(String name) {
int[] indexes = (int[]) indexMap.get(name);
if (indexes == null) {
throw new IllegalArgumentException("Parameter not found: " + name);
}
return indexes;
}
/**
* Sets a parameter.
*
* @param name
* parameter name
* @param value
* parameter value
* @throws SQLException
* if an error occurred
* @throws IllegalArgumentException
* if the parameter does not exist
* @see PreparedStatement#setObject(int, java.lang.Object)
*/
public void setObject(String name, Object value) throws SQLException {
int[] indexes = getIndexes(name);
for (int i = 0; i < indexes.length; i++) {
statement.setObject(indexes[i], value);
}
}
/**
* Sets a parameter.
*
* @param name
* parameter name
* @param value
* parameter value
* @throws SQLException
* if an error occurred
* @throws IllegalArgumentException
* if the parameter does not exist
* @see PreparedStatement#setString(int, java.lang.String)
*/
public void setString(String name, String value) throws SQLException {
int[] indexes = getIndexes(name);
for (int i = 0; i < indexes.length; i++) {
statement.setString(indexes[i], value);
}
}
/**
* Sets a parameter.
*
* @param name
* parameter name
* @param value
* parameter value
* @throws SQLException
* if an error occurred
* @throws IllegalArgumentException
* if the parameter does not exist
* @see PreparedStatement#setInt(int, int)
*/
public void setInt(String name, int value) throws SQLException {
int[] indexes = getIndexes(name);
for (int i = 0; i < indexes.length; i++) {
statement.setInt(indexes[i], value);
}
}
/**
* Sets a parameter.
*
* @param name
* parameter name
* @param value
* parameter value
* @throws SQLException
* if an error occurred
* @throws IllegalArgumentException
* if the parameter does not exist
* @see PreparedStatement#setInt(int, int)
*/
public void setLong(String name, long value) throws SQLException {
int[] indexes = getIndexes(name);
for (int i = 0; i < indexes.length; i++) {
statement.setLong(indexes[i], value);
}
}
public void setDate(String name, Date value) throws SQLException {
int[] indexes = getIndexes(name);
for (int i = 0; i < indexes.length; i++) {
statement.setDate(indexes[i], value);
}
}
public void setNull(String name, int sqlType) throws SQLException {
int[] indexes = getIndexes(name);
for (int i = 0; i < indexes.length; i++) {
statement.setNull(indexes[i], sqlType);
}
}
public void setBoolean(String name, Boolean value) throws SQLException {
int[] indexes = getIndexes(name);
for (int i = 0; i < indexes.length; i++) {
statement.setBoolean(indexes[i], value);
}
}
/**
* Sets a parameter.
*
* @param name
* parameter name
* @param value
* parameter value
* @throws SQLException
* if an error occurred
* @throws IllegalArgumentException
* if the parameter does not exist
* @see PreparedStatement#setTimestamp(int, java.sql.Timestamp)
*/
public void setTimestamp(String name, Timestamp value) throws SQLException
{
int[] indexes = getIndexes(name);
for (int i = 0; i < indexes.length; i++) {
statement.setTimestamp(indexes[i], value);
}
}
/**
* Returns the underlying statement.
*
* @return the statement
*/
public PreparedStatement getStatement() {
return statement;
}
/**
* Executes the statement.
*
* @return true if the first result is a {@link ResultSet}
* @throws SQLException
* if an error occurred
* @see PreparedStatement#execute()
*/
public boolean execute() throws SQLException {
return statement.execute();
}
/**
* Executes the statement, which must be a query.
*
* @return the query results
* @throws SQLException
* if an error occurred
* @see PreparedStatement#executeQuery()
*/
public ResultSet executeQuery() throws SQLException {
return statement.executeQuery();
}
/**
* Executes the statement, which must be an SQL INSERT, UPDATE or DELETE statement; or an SQL statement that returns nothing, such as a DDL statement.
*
* @return number of rows affected
* @throws SQLException
* if an error occurred
* @see PreparedStatement#executeUpdate()
*/
public int executeUpdate() throws SQLException {
return statement.executeUpdate();
}
/**
* Closes the statement.
*
* @throws SQLException
* if an error occurred
* @see Statement#close()
*/
public void close() throws SQLException {
statement.close();
}
public Boolean isClosed() throws SQLException {
return statement.isClosed();
}
/**
* Adds the current set of parameters as a batch entry.
*
* @throws SQLException
* if something went wrong
*/
public void addBatch() throws SQLException {
statement.addBatch();
}
/**
* Executes all of the batched statements.
*
* See {@link Statement#executeBatch()} for details.
*
* @return update counts for each statement
* @throws SQLException
* if something went wrong
*/
public int[] executeBatch() throws SQLException {
return statement.executeBatch();
}
}

View File

@ -0,0 +1,24 @@
package com.rjconsultores.ventaboletos.web.utilerias.menu.item.relatorios.impressaofiscal;
import org.zkoss.util.resource.Labels;
import com.rjconsultores.ventaboletos.web.utilerias.PantallaUtileria;
import com.rjconsultores.ventaboletos.web.utilerias.menu.DefaultItemMenuSistema;
public class ItemMenuRelatorioRDI extends DefaultItemMenuSistema {
public ItemMenuRelatorioRDI() {
super("indexController.mnRelatorioRDI.label");
}
@Override
public String getClaveMenu() {
return "COM.RJCONSULTORES.ADMINISTRACION.GUI.RELATORIOS.RELATORIORDI";
}
@Override
public void ejecutar() {
PantallaUtileria.openWindow("/gui/impressaofiscal/busquedaRelatorioRDI.zul",
Labels.getLabel("indexController.mnRelatorioRDI.label"), getArgs(), desktop);
}
}

View File

@ -0,0 +1,30 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.rjconsultores.ventaboletos.web.utilerias.render;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.ListitemRenderer;
import com.rjconsultores.ventaboletos.entidad.Estado;
/**
*
* @author MCosso
*/
public class RenderEstadoUf implements ListitemRenderer {
public void render(Listitem lstm, Object o) throws Exception {
Estado estado = (Estado) o;
Listcell lc = new Listcell();
lc = new Listcell(estado.getCveestado());
lc.setParent(lstm);
lstm.setAttribute("data", estado);
}
}

View File

@ -317,6 +317,9 @@ indexController.mnSubMenuExportacaoFiscal.label=Exportação Fiscal
indexController.mniExportacaoFiscalECF.label=ECF
indexController.mniExportacaoFiscalRMD.label=RMD
indexController.mnImpressaoRMD.label=Impressão RMD
indexController.mnRelatorioRDI.label=Relatório RDI
indexController.mniSubMenuClientePacote.label=Paquete
indexController.mniManutencaoPacote.label=Mantenimiento Paquete
@ -519,12 +522,24 @@ relatorioReceitaDiariaAgenciaController.rdIndAgenciaDevol.cmbReceitaImposto.cmbI
relatorioReceitaDiariaAgenciaController.rdIndAgenciaDevol.cmbReceitaImposto.cmbItemReceitaBagagem = Ingresos de equipaje
#Relatorio Impressao RMD
busquedaImpressaoRMDController.mnImpressaoRMD.label = Impressão RMD
busquedaImpressaoRMDController.label.RMD = RMD
busquedaImpressaoRMDController.labelRadio.tipo = Tipo de Impressão:
busquedaImpressaoRMDController.labelRadio.radBPR = BPR
busquedaImpressaoRMDController.labelRadio.radECF = ECF
busquedaImpressaoRMDController.select.RMD = É necessario selecionar um RMD
busquedaImpressaoRMDController.MSG.gravarRMDPergunta = Deseja gravar nos registros de vendas, o vínculo com o numero de RMD selecionado?
busquedaImpressaoRMDController.labelfolio.RMD = Nº Controle de Formulário:
busquedaImpressaoRMDController.labelfolio.RMD.fim = Até
#Relatorio RDI
busquedaRelatorioRDIController.label = Relatório RDI
busquedaRelatorioRDIController.btnExe.label = Executar
busquedaRelatorioRDIController.lbEmpresa.value = Empresa
busquedaRelatorioRDIController.estado.label = Estado
busquedaRelatorioRDIController.receitaTerceiros.label = Receita de Terceiros
busquedaRelatorioRDIController.labelRadio.radSim = Sim
busquedaRelatorioRDIController.labelRadio.radNao = Não
#Devolução de Bilhetes
relatorioDevolucaoBilhetesAgenciaController.window.title = Relatório de Devolução de Bilhetes

View File

@ -324,6 +324,7 @@ indexController.mniExportacaoFiscalECF.label=ECF
indexController.mniExportacaoFiscalRMD.label=RMD
indexController.mnImpressaoRMD.label=Impressão RMD
indexController.mnRelatorioRDI.label=Relatório RDI
indexController.mniSubMenuClientePacote.label=Pacote
indexController.mniManutencaoPacote.label=Manutenção Pacote
@ -566,6 +567,15 @@ busquedaImpressaoRMDController.MSG.gravarRMDPergunta = Deseja gravar nos registr
busquedaImpressaoRMDController.labelfolio.RMD = Nº Controle de Formulário:
busquedaImpressaoRMDController.labelfolio.RMD.fim = Até
#Relatorio RDI
busquedaRelatorioRDIController.label = Relatório RDI
busquedaRelatorioRDIController.btnExe.label = Executar
busquedaRelatorioRDIController.lbEmpresa.value = Empresa
busquedaRelatorioRDIController.estado.label = Estado
busquedaRelatorioRDIController.receitaTerceiros.label = Receita de Terceiros
busquedaRelatorioRDIController.labelRadio.radSim = Sim
busquedaRelatorioRDIController.labelRadio.radNao = Não
#Devolução de Bilhetes
relatorioDevolucaoBilhetesAgenciaController.window.title = Relatório de Devolução de Bilhetes
relatorioDevolucaoBilhetesAgenciaController.lbDataIni.value = Data Inicial

View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<?page title="RelgerencialEmpresa" contentType="text/html;charset=UTF-8"?>
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="winBusquedaRelatorioRDI"?>
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
<zk>
<window id="winBusquedaRelatorioRDI"
title="${c:l('indexController.mnRelatorioRDI.label')}"
apply="${busquedaRelatorioRDIController}" contentStyle="overflow:auto"
width="660px" border="normal">
<grid fixedLayout="true">
<columns>
<column width="20%" />
<column width="30%" />
<column width="20%" />
<column width="30%" />
</columns>
<rows>
<row>
<label
value="${c:l('busquedaImportacionFiscalController.lbDataIni.value')}" />
<datebox id="datInicial" width="90%"
format="dd/MM/yyyy" constraint="no empty" maxlength="10" />
<label
value="${c:l('busquedaImportacionFiscalController.lbDataFin.value')}" />
<datebox id="datFinal" width="90%"
format="dd/MM/yyyy" constraint="no empty" maxlength="10" />
</row>
<row spans="1, 3">
<label
value="${c:l('busquedaRelatorioRDIController.lbEmpresa.value')}" />
<combobox id="cmbEmpresa" style="width: 483px;"
mold="rounded" buttonVisible="true"
use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar"
model="@{winBusquedaRelatorioRDI$composer.lsEmpresa}"
constraint="no empty" />
</row>
<row spans="1, 3">
<label
value="${c:l('busquedaRelatorioRDIController.estado.label')}" />
<listbox id="estadoList" rows="10" vflex="false"
width="90%" multiple="true" checkmark="true"
use="com.rjconsultores.ventaboletos.web.utilerias.MyListbox">
</listbox>
</row>
<row spans="1, 3">
<label
value="${c:l('busquedaRelatorioRDIController.receitaTerceiros.label')}" />
<radiogroup id="receitaTerceiros">
<radio id="radSim"
label="${c:l('busquedaRelatorioRDIController.labelRadio.radSim')}"
checked="true" />
<radio id="radNao"
label="${c:l('busquedaRelatorioRDIController.labelRadio.radNao')}" />
</radiogroup>
</row>
</rows>
</grid>
<toolbar>
<button id="btnExecutar" image="/gui/img/enginer.png"
label="${c:l('busquedaRelatorioRDIController.btnExe.label')}" />
</toolbar>
</window>
</zk>