bug #6829
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@50151 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
8c3b74df60
commit
c8abc8469c
|
@ -1,6 +1,23 @@
|
||||||
package com.rjconsultores.ventaboletos.web.utilerias.menu.item.relatorios;
|
package com.rjconsultores.ventaboletos.web.utilerias.menu.item.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.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
import javax.activation.MimetypesFileTypeMap;
|
||||||
|
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 {
|
||||||
|
|
||||||
|
@ -14,72 +31,72 @@ public class ItemMenuRelatorioArquivoBGM extends DefaultItemMenuSistema {
|
||||||
public String getClaveMenu() {
|
public String getClaveMenu() {
|
||||||
return "COM.RJCONSULTORES.ADMINISTRACION.GUI.RELATORIOS.MENU.RELATORIOARQUIVOBGM";
|
return "COM.RJCONSULTORES.ADMINISTRACION.GUI.RELATORIOS.MENU.RELATORIOARQUIVOBGM";
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// @Override
|
@Override
|
||||||
// public void ejecutar() {
|
public void ejecutar() {
|
||||||
// DataSource ds = null;
|
DataSource ds = null;
|
||||||
// try {
|
try {
|
||||||
// ds = (DataSource)AppContext.getApplicationContext().getBean("dataSource");
|
ds = (DataSource) AppContext.getApplicationContext().getBean("dataSource");
|
||||||
// Totalbus totalbus = new Totalbus(ds.getConnection());
|
Totalbus totalbus = new Totalbus(ds.getConnection());
|
||||||
// String fileName = System.getProperty("jboss.server.log.dir") + "/arquivobgm.txt";
|
String fileName = System.getProperty("jboss.server.log.dir") + "/arquivobgm.txt";
|
||||||
// String fileZip = System.getProperty("jboss.server.log.dir") + "/arquivobgm.zip";
|
String fileZip = System.getProperty("jboss.server.log.dir") + "/arquivobgm.zip";
|
||||||
// FileInputStream inputStream;
|
FileInputStream inputStream;
|
||||||
// Arquivo.GravaArquivo(fileName, totalbus.getDespesasReceitas(null, null));
|
Arquivo.GravaArquivo(fileName, totalbus.getDespesasReceitas(null, null));
|
||||||
//
|
|
||||||
// excluirArquivosZip();
|
excluirArquivosZip();
|
||||||
// compactarArquivo(fileZip, fileName);
|
compactarArquivo(fileZip, fileName);
|
||||||
// File file = new File(fileZip);
|
File file = new File(fileZip);
|
||||||
// if (file.exists()) {
|
if (file.exists()) {
|
||||||
// inputStream = new FileInputStream(file);
|
inputStream = new FileInputStream(file);
|
||||||
// Filedownload.save(inputStream, new MimetypesFileTypeMap().getContentType(file), file.getName());
|
Filedownload.save(inputStream, new MimetypesFileTypeMap().getContentType(file), file.getName());
|
||||||
// }
|
}
|
||||||
// file.delete();
|
file.delete();
|
||||||
// } catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// e.printStackTrace();
|
e.printStackTrace();
|
||||||
// } finally {
|
} finally {
|
||||||
// try {
|
try {
|
||||||
// ds.getConnection().close();
|
ds.getConnection().close();
|
||||||
// } catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// // TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
// e.printStackTrace();
|
e.printStackTrace();
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public static void compactarArquivo(String arqSaida,String arqEntrada) throws IOException{
|
public static void compactarArquivo(String arqSaida,String arqEntrada) throws IOException{
|
||||||
// int cont;
|
int cont;
|
||||||
// byte[] dados = new byte[TAMANHO_BUFFER];
|
byte[] dados = new byte[TAMANHO_BUFFER];
|
||||||
// BufferedInputStream origem = null;
|
BufferedInputStream origem = null;
|
||||||
// FileInputStream streamDeEntrada = null;
|
FileInputStream streamDeEntrada = null;
|
||||||
// FileOutputStream destino = null;
|
FileOutputStream destino = null;
|
||||||
// ZipOutputStream saida = null;
|
ZipOutputStream saida = null;
|
||||||
// ZipEntry entry = null;
|
ZipEntry entry = null;
|
||||||
// try {
|
try {
|
||||||
// destino = new FileOutputStream(new File(arqSaida));
|
destino = new FileOutputStream(new File(arqSaida));
|
||||||
// saida = new ZipOutputStream(new BufferedOutputStream(destino));
|
saida = new ZipOutputStream(new BufferedOutputStream(destino));
|
||||||
// File file = new File(arqEntrada);
|
File file = new File(arqEntrada);
|
||||||
// streamDeEntrada = new FileInputStream(file);
|
streamDeEntrada = new FileInputStream(file);
|
||||||
// origem = new BufferedInputStream(streamDeEntrada, TAMANHO_BUFFER);
|
origem = new BufferedInputStream(streamDeEntrada, TAMANHO_BUFFER);
|
||||||
// entry = new ZipEntry(file.getName());
|
entry = new ZipEntry(file.getName());
|
||||||
// saida.putNextEntry(entry);
|
saida.putNextEntry(entry);
|
||||||
// while((cont = origem.read(dados, 0, TAMANHO_BUFFER)) != -1) {
|
while((cont = origem.read(dados, 0, TAMANHO_BUFFER)) != -1) {
|
||||||
// saida.write(dados, 0, cont);
|
saida.write(dados, 0, cont);
|
||||||
// }
|
}
|
||||||
// origem.close();
|
origem.close();
|
||||||
// saida.close();
|
saida.close();
|
||||||
// } catch(IOException e) {
|
} catch(IOException e) {
|
||||||
// throw new IOException(e.getMessage());
|
throw new IOException(e.getMessage());
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// private void excluirArquivosZip(){
|
private void excluirArquivosZip(){
|
||||||
// File pasta = new File(System.getProperty("jboss.server.log.dir"));
|
File pasta = new File(System.getProperty("jboss.server.log.dir"));
|
||||||
// File[] arquivos = pasta.listFiles();
|
File[] arquivos = pasta.listFiles();
|
||||||
//
|
|
||||||
// for(File arquivo : arquivos) {
|
for(File arquivo : arquivos) {
|
||||||
// if(arquivo.getName().endsWith("zip")) {
|
if(arquivo.getName().endsWith("zip")) {
|
||||||
// arquivo.delete();
|
arquivo.delete();
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue