leonardo 2015-12-23 18:17:01 +00:00
parent 8928a37c6f
commit 0b80c378ed
12 changed files with 306 additions and 87 deletions

7
.checkstyle 100644
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
<fileset name="all" enabled="true" check-config-name="Sun Checks" local="false">
<file-match-pattern match-pattern="." include-pattern="true"/>
</fileset>
</fileset-config>

View File

@ -84,6 +84,7 @@
<classpathentry kind="lib" path="/LibreriasAdmVenta/spring-security-web-3.0.7.RELEASE.jar"/> <classpathentry kind="lib" path="/LibreriasAdmVenta/spring-security-web-3.0.7.RELEASE.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/CustomAdmVenta"/> <classpathentry combineaccessrules="false" kind="src" path="/CustomAdmVenta"/>
<classpathentry combineaccessrules="false" kind="src" path="/modelWeb"/> <classpathentry combineaccessrules="false" kind="src" path="/modelWeb"/>
<classpathentry kind="src" path="/IntegracaoReceitaDespesa"/>
<classpathentry kind="lib" path="/LibreriasAdmVenta/groovy-all-1.7.5.jar"/> <classpathentry kind="lib" path="/LibreriasAdmVenta/groovy-all-1.7.5.jar"/>
<classpathentry kind="lib" path="/LibreriasAdmVenta/jfreechart-1.0.12.jar"/> <classpathentry kind="lib" path="/LibreriasAdmVenta/jfreechart-1.0.12.jar"/>
<classpathentry kind="lib" path="/LibreriasAdmVenta/poi-3.8-20120326.jar"/> <classpathentry kind="lib" path="/LibreriasAdmVenta/poi-3.8-20120326.jar"/>
@ -103,9 +104,6 @@
<attribute name="owner.project.facets" value="java"/> <attribute name="owner.project.facets" value="java"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/WSTotvs"/> <classpathentry combineaccessrules="false" kind="src" path="/WSTotvs"/>
<classpathentry kind="lib" path="/LibreriasAdmVenta/integracaoReceitaDespesa.jar"/>
<classpathentry kind="output" path="build/classes"/> <classpathentry kind="output" path="build/classes"/>
</classpath> </classpath>

View File

@ -7,6 +7,7 @@
<project>LibreriasAdmVenta</project> <project>LibreriasAdmVenta</project>
<project>CustomAdmVenta</project> <project>CustomAdmVenta</project>
<project>WSTotvs</project> <project>WSTotvs</project>
<project>IntegracaoReceitaDespesa</project>
</projects> </projects>
<buildSpec> <buildSpec>
<buildCommand> <buildCommand>

View File

@ -0,0 +1,5 @@
XDOCLETBUILDERACTIVE=true
XDOCLETHOME=
XDOCLETUSEGLOBAL=true
XDOCLETVERSION=1.2.1
eclipse.preferences.version=1

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false

View File

@ -12,6 +12,9 @@
<dependent-module archiveName="WSTotvs.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/WSTotvs/WSTotvs"> <dependent-module archiveName="WSTotvs.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/WSTotvs/WSTotvs">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
<dependent-module archiveName="IntegracaoReceitaDespesa.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/IntegracaoReceitaDespesa/IntegracaoReceitaDespesa">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/ventaboletosadm/build/classes"/> <property name="java-output-path" value="/ventaboletosadm/build/classes"/>
<property name="context-root" value="/ventaboletosadm"/> <property name="context-root" value="/ventaboletosadm"/>
</wb-module> </wb-module>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.wst.ws.service.policy.projectEnabled=false

View File

@ -0,0 +1,210 @@
package com.rjconsultores.ventaboletos.web.gui.controladores.relatorios;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.activation.MimetypesFileTypeMap;
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.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zul.Datebox;
import org.zkoss.zul.Filedownload;
import com.rjconsultores.integracaoreceitadespesa.Arquivo;
import com.rjconsultores.integracaoreceitadespesa.dao.Totalbus;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEmpresa;
import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxParada;
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
@Controller("relatorioArquivoBGMController")
@Scope("prototype")
public class RelatorioArquivoBGMController extends MyGenericForwardComposer {
private static final long serialVersionUID = 1L;
private static Logger log = Logger.getLogger(RelatorioArquivoBGMController.class);
private static final int TAMANHO_BUFFER = 4096; // 4kb
private MyComboboxEmpresa cmbEmpresa;
private MyComboboxParada cmbPuntoVenta;
private Datebox datInicial;
private Datebox datFinal;
@Autowired
private DataSource dataSource;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
}
public void onClick$btnExecutarRelatorio(Event ev) throws Exception {
executarRelatorio();
}
/**
* @throws Exception
*
*/
private void executarRelatorio() throws Exception {
excluirArquivosZip();
List<File> files = new ArrayList<File>();
Calendar cal = Calendar.getInstance();
// Seta primeiro dia da iteração
cal.setTime(datInicial.getValue());
Calendar calFinal = Calendar.getInstance();
calFinal.setTime(datFinal.getValue());
// seta dia e mês finais para limite da iteração
int diaFinal = calFinal.get(Calendar.DAY_OF_MONTH);
int mesFinal = calFinal.get(Calendar.MONTH);
while (cal.get(Calendar.DAY_OF_MONTH) <= diaFinal && cal.get(Calendar.MONTH) <= mesFinal) {
String fileName = System.getProperty("jboss.server.log.dir") + "/BGM-" + cal.get(Calendar.YEAR) + "" + (cal.get(Calendar.MONTH) + 1) + "" + cal.get(Calendar.DAY_OF_MONTH) + ".txt";
File file = new File(fileName);
Totalbus totalbus = new Totalbus(dataSource.getConnection());
Arquivo.GravaArquivo(file.getAbsolutePath(), totalbus.getDespesasReceitas(
cmbPuntoVenta.getSelectedItem() == null ? null : ((PuntoVenta)cmbPuntoVenta.getSelectedItem().getValue()).getPuntoventaId(),
cmbPuntoVenta.getSelectedItem() == null ? null : ((Empresa)cmbPuntoVenta.getSelectedItem().getValue()).getEmpresaId(),
cal.getTime()));
// adiciona um dia para iteração
cal.add(Calendar.DAY_OF_MONTH, 1);
files.add(file);
}
String fileZip = System.getProperty("jboss.server.log.dir") + "\\ArquivosBGM.zip";
FileInputStream inputStream;
compactarArquivos(files, fileZip);
File filez = new File(fileZip);
if (filez.exists()) {
inputStream = new FileInputStream(filez);
Filedownload.save(inputStream, new MimetypesFileTypeMap().getContentType(filez), filez.getName());
}
filez.delete();
}
public static void compactarArquivo(String arqSaida,String arqEntrada) throws IOException{
int cont;
byte[] dados = new byte[TAMANHO_BUFFER];
BufferedInputStream origem = null;
FileInputStream streamDeEntrada = null;
FileOutputStream destino = null;
ZipOutputStream saida = null;
ZipEntry entry = null;
try {
destino = new FileOutputStream(new File(arqSaida));
saida = new ZipOutputStream(new BufferedOutputStream(destino));
File file = new File(arqEntrada);
streamDeEntrada = new FileInputStream(file);
origem = new BufferedInputStream(streamDeEntrada, TAMANHO_BUFFER);
entry = new ZipEntry(file.getName());
saida.putNextEntry(entry);
while((cont = origem.read(dados, 0, TAMANHO_BUFFER)) != -1) {
saida.write(dados, 0, cont);
}
origem.close();
saida.close();
} catch(IOException e) {
throw new IOException(e.getMessage());
}
}
private void compactarArquivos(List<File> arquivosEOuPastas, String arquivoDeSaida){
System.out.println(arquivoDeSaida);
// Create a buffer for reading the files
byte[] buf = new byte[1024];
try {
// Create the ZIP file
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(arquivoDeSaida));
// Compress the files
for (File f : arquivosEOuPastas) {
FileInputStream in = new FileInputStream(f.getPath());
// Add ZIP entry to output stream.
out.putNextEntry(new ZipEntry(f.getName()));
System.out.println(f.getPath());
// Transfer bytes from the file to the ZIP file
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
// Complete the entry
out.closeEntry();
in.close();
f.delete();
}
// Complete the ZIP file
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private void excluirArquivosZip(){
File pasta = new File(System.getProperty("jboss.server.log.dir"));
File[] arquivos = pasta.listFiles();
for(File arquivo : arquivos) {
if(arquivo.getName().endsWith("zip")) {
arquivo.delete();
}
}
}
public MyComboboxEmpresa getCmbEmpresa() {
return cmbEmpresa;
}
public void setCmbEmpresa(MyComboboxEmpresa cmbEmpresa) {
this.cmbEmpresa = cmbEmpresa;
}
public MyComboboxParada getCmbPuntoVenta() {
return cmbPuntoVenta;
}
public void setCmbPuntoVenta(MyComboboxParada cmbPuntoVenta) {
this.cmbPuntoVenta = cmbPuntoVenta;
}
public Datebox getDatInicial() {
return datInicial;
}
public void setDatInicial(Datebox datInicial) {
this.datInicial = datInicial;
}
public Datebox getDatFinal() {
return datFinal;
}
public void setDatFinal(Datebox datFinal) {
this.datFinal = datFinal;
}
}

View File

@ -1,28 +1,12 @@
package com.rjconsultores.ventaboletos.web.utilerias.menu.item.relatorios; package com.rjconsultores.ventaboletos.web.utilerias.menu.item.relatorios;
import java.io.BufferedInputStream; import org.zkoss.util.resource.Labels;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.activation.MimetypesFileTypeMap; import com.rjconsultores.ventaboletos.web.utilerias.PantallaUtileria;
import javax.sql.DataSource;
import org.zkoss.zul.Filedownload;
import com.rjconsultores.integracaoreceitadespesa.Arquivo;
import com.rjconsultores.integracaoreceitadespesa.dao.Totalbus;
import com.rjconsultores.ventaboletos.web.utilerias.menu.DefaultItemMenuSistema; import com.rjconsultores.ventaboletos.web.utilerias.menu.DefaultItemMenuSistema;
import com.rjconsultores.ventaboletos.web.utilerias.spring.AppContext;
public class ItemMenuRelatorioArquivoBGM extends DefaultItemMenuSistema { public class ItemMenuRelatorioArquivoBGM extends DefaultItemMenuSistema {
private static final int TAMANHO_BUFFER = 4096; // 4kb
public ItemMenuRelatorioArquivoBGM() { public ItemMenuRelatorioArquivoBGM() {
super("indexController.mniRelatorioArquivoBGM.label"); super("indexController.mniRelatorioArquivoBGM.label");
} }
@ -34,69 +18,7 @@ public class ItemMenuRelatorioArquivoBGM extends DefaultItemMenuSistema {
@Override @Override
public void ejecutar() { public void ejecutar() {
DataSource ds = null; PantallaUtileria.openWindow("/gui/relatorios/filtroRelatorioArquivoBGM.zul",
try { Labels.getLabel("indexController.mniRelatorioArquivoBGM.label"), getArgs() ,desktop);
ds = (DataSource) AppContext.getApplicationContext().getBean("dataSource");
Totalbus totalbus = new Totalbus(ds.getConnection());
String fileName = System.getProperty("jboss.server.log.dir") + "/arquivobgm.txt";
String fileZip = System.getProperty("jboss.server.log.dir") + "/arquivobgm.zip";
FileInputStream inputStream;
Arquivo.GravaArquivo(fileName, totalbus.getDespesasReceitas(null, null));
excluirArquivosZip();
compactarArquivo(fileZip, fileName);
File file = new File(fileZip);
if (file.exists()) {
inputStream = new FileInputStream(file);
Filedownload.save(inputStream, new MimetypesFileTypeMap().getContentType(file), file.getName());
}
file.delete();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
ds.getConnection().close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public static void compactarArquivo(String arqSaida,String arqEntrada) throws IOException{
int cont;
byte[] dados = new byte[TAMANHO_BUFFER];
BufferedInputStream origem = null;
FileInputStream streamDeEntrada = null;
FileOutputStream destino = null;
ZipOutputStream saida = null;
ZipEntry entry = null;
try {
destino = new FileOutputStream(new File(arqSaida));
saida = new ZipOutputStream(new BufferedOutputStream(destino));
File file = new File(arqEntrada);
streamDeEntrada = new FileInputStream(file);
origem = new BufferedInputStream(streamDeEntrada, TAMANHO_BUFFER);
entry = new ZipEntry(file.getName());
saida.putNextEntry(entry);
while((cont = origem.read(dados, 0, TAMANHO_BUFFER)) != -1) {
saida.write(dados, 0, cont);
}
origem.close();
saida.close();
} catch(IOException e) {
throw new IOException(e.getMessage());
}
}
private void excluirArquivosZip(){
File pasta = new File(System.getProperty("jboss.server.log.dir"));
File[] arquivos = pasta.listFiles();
for(File arquivo : arquivos) {
if(arquivo.getName().endsWith("zip")) {
arquivo.delete();
}
}
} }
} }

View File

@ -6031,3 +6031,10 @@ editarConexionController.MSG.conexaoFixa1 = Informe la conexión fijo del primer
editarConexionController.MSG.conexaoFixa2 = Informe la conexión fijo del segundo paso de la conexión. editarConexionController.MSG.conexaoFixa2 = Informe la conexión fijo del segundo paso de la conexión.
editarConexionController.MSG.conexaoFixa3 = Informe la conexión fijo del tercero paso de la conexión. editarConexionController.MSG.conexaoFixa3 = Informe la conexión fijo del tercero paso de la conexión.
editarConexionController.MSG.conexaoFixa4 = Informe la conexión fijo del cuarto paso de la conexión. editarConexionController.MSG.conexaoFixa4 = Informe la conexión fijo del cuarto paso de la conexión.
# Relatorio Arquivo BGM
relatorioArquivoBGMController.lbDataIni.value = Data Inicial
relatorioArquivoBGMController.lbDataFin.value = Data Final
relatorioArquivoBGMController.lbEmpresa.value = Empresa
relatorioArquivoBGMController.lbPuntoVenta.value = Agência

View File

@ -6176,3 +6176,9 @@ relatorioObservacaoEventosFinanceirosController.lbDataIni.value = Data Inicio
relatorioObservacaoEventosFinanceirosController.lbDataFin.value = Data Final relatorioObservacaoEventosFinanceirosController.lbDataFin.value = Data Final
relatorioObservacaoEventosFinanceirosController.lbEmpresa.value = Empresa relatorioObservacaoEventosFinanceirosController.lbEmpresa.value = Empresa
relatorioObservacaoEventosFinanceirosController.lbPuntoVenta.value = Punto venta relatorioObservacaoEventosFinanceirosController.lbPuntoVenta.value = Punto venta
# Relatorio Arquivo BGM
relatorioArquivoBGMController.lbDataIni.value = Data Inicial
relatorioArquivoBGMController.lbDataFin.value = Data Final
relatorioArquivoBGMController.lbEmpresa.value = Empresa
relatorioArquivoBGMController.lbPuntoVenta.value = Agência

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<?page contentType="text/html;charset=UTF-8"?>
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="winRelatorioArquivoBGM"?>
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
<zk xmlns="http://www.zkoss.org/2005/zul">
<window id="winRelatorioArquivoBGM"
apply="${relatorioArquivoBGMController}"
contentStyle="overflow:auto" height="250px" width="560px"
border="normal">
<grid fixedLayout="true">
<columns>
<column width="30%" />
<column width="70%" />
</columns>
<rows>
<row>
<label
value="${c:l('relatorioArquivoBGMController.lbDataIni.value')}" />
<datebox id="datInicial"
format="dd/MM/yyyy" lenient="false" constraint="no empty"
maxlength="10" />
</row>
<row>
<label
value="${c:l('relatorioArquivoBGMController.lbDataFin.value')}" />
<datebox id="datFinal"
format="dd/MM/yyyy" lenient="false" constraint="no empty"
maxlength="10" />
</row>
<row>
<label
value="${c:l('relatorioArquivoBGMController.lbEmpresa.value')}" />
<combobox id="cmbEmpresa"
use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEmpresa"
mold="rounded" buttonVisible="true"
width="70%" />
</row>
<row>
<label
value="${c:l('relatorioArquivoBGMController.lbPuntoVenta.value')}" />
<combobox id="cmbPuntoVenta"
use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxParada"
mold="rounded" buttonVisible="true"
width="70%" />
</row>
</rows>
</grid>
<toolbar>
<button id="btnExecutarRelatorio" image="/gui/img/find.png"
label="${c:l('relatorio.lb.btnExecutarRelatorio')}" />
</toolbar>
</window>
</zk>