diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioLogAuditoria.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioLogAuditoria.java new file mode 100644 index 000000000..0fb1329ee --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioLogAuditoria.java @@ -0,0 +1,44 @@ +/** + * + */ +package com.rjconsultores.ventaboletos.relatorios.impl; + +import java.sql.Connection; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.rjconsultores.ventaboletos.entidad.LogAuditoria; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.LogAuditoriaBean; + +import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; + +public class RelatorioLogAuditoria extends RelatorioDemandas { + public RelatorioLogAuditoria(Map parametros, Connection conexao, List list) throws Exception { + super(parametros, conexao); + + List listaBean = new ArrayList(); + + for (Object object : list) { + LogAuditoria log = (LogAuditoria)object; + LogAuditoriaBean bean = new LogAuditoriaBean(); + + bean.setIdAuditado(log.getIdAuditado()); + bean.setCampoAlterado(log.getCampoAlterado()); + bean.setEmpresa(log.getEmpresa().getNombempresa()); + bean.setUsuario(log.getUsuario().getNombusuario()); + bean.setClasseAlterada(log.getClasseAlterada()); + bean.setClassePrincipal(log.getClassePrincipal()); + bean.setTela(log.getTela()); + bean.setDataAlteracao(log.getFecmodif()); + bean.setCampoAlterado(log.getCampoAlterado()); + bean.setValorAtual(log.getValorNovo()); + bean.setValorAnterior(log.getValorAnterior()); + bean.setTipoAlteracao(log.getTipoAlteracao()); + listaBean.add(bean); + } + setCollectionDataSource(new JRBeanCollectionDataSource(listaBean)); + + + } +} diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioLogAuditoria_es_MX.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioLogAuditoria_es_MX.properties new file mode 100644 index 000000000..6fe06ebf7 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioLogAuditoria_es_MX.properties @@ -0,0 +1,19 @@ +TITULO = Relatório Log de Auditoria +PERIODO = PERÍODO +header.data.hora=Data/Hora\: +cabecalho.impressorPor=Impresso por + +DATA_ALTERACAO = DATA ATLERAÇÃO +ID_AUDITADO = ID AUDITADO +EMPRESA = EMPRESA +USUARIO = USUARIO +TIPO_ALTERACAO = TIPO ALTERAÇÃO +TELA = TELA +CAMPO_ALTERADO = CAMPO ALTERADO +VALOR_ATUAL = VALOR ATUAL +VALOR_ANTERIOR = VALOR ANTERIOR +CLASSE_ALTERADA = CLASSE ALTERADA +CLASSE_PRINCIPAL = CLASSE PRINCIPAL + + +msg.noData=Não foi possivel obter dados com os parâmetros informados. \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioLogAuditoria_pt_BR.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioLogAuditoria_pt_BR.properties new file mode 100644 index 000000000..6fe06ebf7 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioLogAuditoria_pt_BR.properties @@ -0,0 +1,19 @@ +TITULO = Relatório Log de Auditoria +PERIODO = PERÍODO +header.data.hora=Data/Hora\: +cabecalho.impressorPor=Impresso por + +DATA_ALTERACAO = DATA ATLERAÇÃO +ID_AUDITADO = ID AUDITADO +EMPRESA = EMPRESA +USUARIO = USUARIO +TIPO_ALTERACAO = TIPO ALTERAÇÃO +TELA = TELA +CAMPO_ALTERADO = CAMPO ALTERADO +VALOR_ATUAL = VALOR ATUAL +VALOR_ANTERIOR = VALOR ANTERIOR +CLASSE_ALTERADA = CLASSE ALTERADA +CLASSE_PRINCIPAL = CLASSE PRINCIPAL + + +msg.noData=Não foi possivel obter dados com os parâmetros informados. \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioLogAuditoria.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioLogAuditoria.jasper new file mode 100644 index 000000000..40a68f4eb Binary files /dev/null and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioLogAuditoria.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioLogAuditoria.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioLogAuditoria.jrxml new file mode 100644 index 000000000..765749e72 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioLogAuditoria.jrxml @@ -0,0 +1,267 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/LogAuditoriaBean.java b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/LogAuditoriaBean.java new file mode 100644 index 000000000..4ede980e1 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/LogAuditoriaBean.java @@ -0,0 +1,107 @@ +package com.rjconsultores.ventaboletos.relatorios.utilitarios; + +import java.util.Date; + +public class LogAuditoriaBean { + + private String idAuditado; + private String empresa; + private String valorAnterior; + private String valorAtual; + private String campoAlterado; + private String classeAlterada; + private String classePrincipal; + private String tela; + private String tipoAlteracao; + private Date dataAlteracao; + private String usuario; + + public String getIdAuditado() { + return idAuditado; + } + + public void setIdAuditado(String idAuditado) { + this.idAuditado = idAuditado; + } + + public String getEmpresa() { + return empresa; + } + + public void setEmpresa(String empresa) { + this.empresa = empresa; + } + + public String getValorAnterior() { + return valorAnterior; + } + + public void setValorAnterior(String valorAnterior) { + this.valorAnterior = valorAnterior; + } + + public String getValorAtual() { + return valorAtual; + } + + public void setValorAtual(String valorAtual) { + this.valorAtual = valorAtual; + } + + public String getCampoAlterado() { + return campoAlterado; + } + + public void setCampoAlterado(String campoAlterado) { + this.campoAlterado = campoAlterado; + } + + public String getClasseAlterada() { + return classeAlterada; + } + + public void setClasseAlterada(String classeAlterada) { + this.classeAlterada = classeAlterada; + } + + public String getClassePrincipal() { + return classePrincipal; + } + + public void setClassePrincipal(String classePrincipal) { + this.classePrincipal = classePrincipal; + } + + public String getTela() { + return tela; + } + + public void setTela(String tela) { + this.tela = tela; + } + + public String getTipoAlteracao() { + return tipoAlteracao; + } + + public void setTipoAlteracao(String tipoAlteracao) { + this.tipoAlteracao = tipoAlteracao; + } + + public Date getDataAlteracao() { + return dataAlteracao; + } + + public void setDataAlteracao(Date dataAlteracao) { + this.dataAlteracao = dataAlteracao; + } + + public String getUsuario() { + return usuario; + } + + public void setUsuario(String usuario) { + this.usuario = usuario; + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/BusquedaLogAuditoriaController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/BusquedaLogAuditoriaController.java index b9a27e432..6e3db91ea 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/BusquedaLogAuditoriaController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/BusquedaLogAuditoriaController.java @@ -2,8 +2,13 @@ package com.rjconsultores.ventaboletos.web.gui.controladores.seguridad; import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import javax.sql.DataSource; + +import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; @@ -13,11 +18,18 @@ 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.Comboitem; import org.zkoss.zul.Datebox; import org.zkoss.zul.Paging; import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.Estado; import com.rjconsultores.ventaboletos.entidad.LogAuditoria; +import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioBPe; +import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioBPeRejeitadoEnvioContingencia; +import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioBpeNumeracaoReuso; +import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioLogAuditoria; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; import com.rjconsultores.ventaboletos.service.LogAuditoriaService; import com.rjconsultores.ventaboletos.utilerias.DateUtil; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; @@ -31,6 +43,7 @@ import com.rjconsultores.ventaboletos.web.utilerias.render.RenderLogAuditoria; import com.trg.search.Filter; import br.com.rjconsultores.auditador.enums.AuditadorTipoAlteracao; +import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; @Controller("busquedaLogAuditoriaController") @Scope("prototype") @@ -63,6 +76,8 @@ public class BusquedaLogAuditoriaController extends MyGenericForwardComposer { private MyTextbox txtValorNovo; private MyTextbox txtValorAnterior; private MyTextbox txtIdAuditado; + @Autowired + private DataSource dataSourceRead; @Override public void doAfterCompose(Component comp) throws Exception { @@ -79,7 +94,7 @@ public class BusquedaLogAuditoriaController extends MyGenericForwardComposer { return lsEmpresa; } - private void refreshLista() { + private void refreshLista(boolean isGerarRelatorio) throws Exception { HibernateSearchObject sistemaBusqueda = new HibernateSearchObject(LogAuditoria.class, pagingLogAuditoria.getPageSize()); Date dataInicio = dtInicio.getValue(); @@ -134,20 +149,89 @@ public class BusquedaLogAuditoriaController extends MyGenericForwardComposer { sistemaBusqueda.addFilterEqual("activo", Boolean.TRUE); plwLogAuditoria.init(sistemaBusqueda, logAuditoriaList, pagingLogAuditoria); + if (logAuditoriaList.getData().length == 0) { - try { - Messagebox.show(Labels.getLabel("MSG.ningunRegistro"), - Labels.getLabel("busquedaLogAuditoriaController.window.title"), - Messagebox.OK, Messagebox.INFORMATION); - } catch (InterruptedException ex) { - log.error("", ex); + if(isGerarRelatorio){ + throw new Exception(Labels.getLabel("MSG.ningunRegistroRelatorio")); + }else{ + try { + Messagebox.show(Labels.getLabel("MSG.ningunRegistro"),Labels.getLabel("busquedaLogAuditoriaController.window.title"), Messagebox.OK, Messagebox.INFORMATION); + } catch (InterruptedException ex) { + log.error("", ex); + } } } - } - public void onClick$btnPesquisa(Event ev) { - refreshLista(); + public void onClick$btnPesquisa(Event ev) throws Exception { + refreshLista(false); + } + @SuppressWarnings("unchecked") + public void onClick$btnGerarRelatorio(Event ev) throws Exception { + + try { + refreshLista(true); + } catch (Exception e) { + Messagebox.show(e.getMessage(), Labels.getLabel("busquedaLogAuditoriaController.window.title"), Messagebox.OK, Messagebox.INFORMATION); + return; + } + + + Map parametros = new HashMap(); + StringBuilder filtro = new StringBuilder(); + + + parametros.put("DATA_FINAL", (java.util.Date) dtInicio.getValue()); + parametros.put("DATA_INICIAL", (java.util.Date) dtFim.getValue()); + parametros.put("NOME_RELATORIO", Labels.getLabel("busquedaLogAuditoriaController.window.title")); + parametros.put("USUARIO_ID", UsuarioLogado.getUsuarioLogado().getUsuarioId().toString()); + parametros.put("NOME_USUARIO", UsuarioLogado.getUsuarioLogado().getNombusuario()); + + + + filtro.append("Empresa: "); + Comboitem item = null; + + if (cmbEmpresa.getSelectedItem() != null) { + item = cmbEmpresa.getSelectedItem(); + if (item != null) { + Empresa empresa = (Empresa) item.getValue(); + filtro.append(empresa.getNombempresa()).append(";"); + } + } else { + filtro.append(" Todas; "); + } + if (cmbTela.getSelectedItem() != null) { + item = cmbTela.getSelectedItem(); + if (item != null) { + filtro.append(cmbTela.getValue()).append(";"); + } + } else { + filtro.append(" Todas; "); + } + + if (cmbTipoAlteracao.getSelectedItem() != null) { + item = cmbTipoAlteracao.getSelectedItem(); + if (item != null) { + filtro.append(cmbTipoAlteracao.getValue()).append(";"); + } + } else { + filtro.append(" Todas; "); + } + + + parametros.put("FILTROS", filtro.toString()); + + Relatorio relatorio = null; + relatorio = new RelatorioLogAuditoria(parametros, dataSourceRead.getConnection(), logAuditoriaList.getListData()); + + + @SuppressWarnings("rawtypes") + Map args = new HashMap(); + args.put("relatorio", relatorio); + + openWindow("/component/reportView.zul", Labels.getLabel("busquedaLogAuditoriaController.window.title"), args, MODAL); + } public List getTipoAlteracaoList() { diff --git a/web/WEB-INF/i3-label_es_MX.label b/web/WEB-INF/i3-label_es_MX.label index c7810e2e3..9c731fe97 100644 --- a/web/WEB-INF/i3-label_es_MX.label +++ b/web/WEB-INF/i3-label_es_MX.label @@ -9295,6 +9295,8 @@ busquedaLogAuditoriaController.lblValorAnterior = Valor Anterior busquedaLogAuditoriaController.lblClasseAlterada = Clase cambiada busquedaLogAuditoriaController.lblClassePrincipal = Clase Principal busquedaLogAuditoriaController.lblIdAuditado = ID Auditado +busquedaLogAuditoriaController.lblGerarRelatorio = Generar Report + #DispositivoOperadorVendaEmbarcada dispositivoVendaEmbarcadaController.window.title= Operador por Dispositivo Venda Embarcada diff --git a/web/WEB-INF/i3-label_pt_BR.label b/web/WEB-INF/i3-label_pt_BR.label index 33f97050a..ff1515006 100644 --- a/web/WEB-INF/i3-label_pt_BR.label +++ b/web/WEB-INF/i3-label_pt_BR.label @@ -10013,6 +10013,7 @@ busquedaLogAuditoriaController.lblValorAnterior = Valor Anterior busquedaLogAuditoriaController.lblClasseAlterada = Classe Alterada busquedaLogAuditoriaController.lblClassePrincipal = Classe Principal busquedaLogAuditoriaController.lblIdAuditado = ID Auditado +busquedaLogAuditoriaController.lblGerarRelatorio = Gerar Relatório #DispositivoOperadorVendaEmbarcada dispositivoVendaEmbarcadaController.window.title= Operador por Dispositivo Venda Embarcada diff --git a/web/gui/seguridad/busquedaLogAuditoria.zul b/web/gui/seguridad/busquedaLogAuditoria.zul index 8583481d3..dd5040ead 100644 --- a/web/gui/seguridad/busquedaLogAuditoria.zul +++ b/web/gui/seguridad/busquedaLogAuditoria.zul @@ -94,6 +94,7 @@