fixes bug #7288
fixes bug #7287 git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@54283 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
134cf97d5e
commit
3529bc704e
|
@ -6,6 +6,7 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
@ -26,6 +27,7 @@ import org.zkoss.zul.Filedownload;
|
|||
|
||||
import com.rjconsultores.integracaoreceitadespesa.Arquivo;
|
||||
import com.rjconsultores.integracaoreceitadespesa.dao.Totalbus;
|
||||
import com.rjconsultores.integracaoreceitadespesa.entidades.DespesaReceita;
|
||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEmpresa;
|
||||
|
@ -73,36 +75,44 @@ public class RelatorioArquivoBGMController extends MyGenericForwardComposer {
|
|||
// 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);
|
||||
Connection con = null;
|
||||
try{
|
||||
con = dataSource.getConnection();
|
||||
|
||||
Totalbus totalbus = new Totalbus(dataSource.getConnection());
|
||||
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) + "" + DespesaReceita.lpad(Integer.toString(cal.get(Calendar.MONTH) + 1), "0", 2) + "" + DespesaReceita.lpad(Integer.toString(cal.get(Calendar.DAY_OF_MONTH)), "0", 2) + ".txt";
|
||||
File file = new File(fileName);
|
||||
|
||||
log.debug("gerando arquivo...");
|
||||
Arquivo.GravaArquivo(file.getAbsolutePath(), totalbus.getDespesasReceitas(
|
||||
cmbPuntoVenta.getSelectedItem() == null ? null : ((PuntoVenta)cmbPuntoVenta.getSelectedItem().getValue()).getPuntoventaId(),
|
||||
cmbEmpresa.getSelectedItem() == null ? null : ((Empresa)cmbEmpresa.getSelectedItem().getValue()).getEmpresaId(),
|
||||
cal.getTime()));
|
||||
// adiciona um dia para iteração
|
||||
cal.add(Calendar.DAY_OF_MONTH, 1);
|
||||
files.add(file);
|
||||
}
|
||||
Totalbus totalbus = new Totalbus(con);
|
||||
|
||||
log.debug("gerando arquivo...");
|
||||
Arquivo.GravaArquivo(file.getAbsolutePath(), totalbus.getDespesasReceitas(
|
||||
cmbPuntoVenta.getSelectedItem() == null ? null : ((PuntoVenta)cmbPuntoVenta.getSelectedItem().getValue()).getPuntoventaId(),
|
||||
cmbEmpresa.getSelectedItem() == null ? null : ((Empresa)cmbEmpresa.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";
|
||||
log.debug("nome arquivo: " + fileZip);
|
||||
FileInputStream inputStream;
|
||||
String fileZip = System.getProperty("jboss.server.log.dir") + "/ArquivosBGM.zip";
|
||||
log.debug("nome arquivo: " + fileZip);
|
||||
FileInputStream inputStream;
|
||||
|
||||
compactarArquivos(files, fileZip);
|
||||
File filez = new File(fileZip);
|
||||
log.info(filez.exists());
|
||||
if (filez.exists()) {
|
||||
log.debug("download dos arquivos");
|
||||
inputStream = new FileInputStream(filez);
|
||||
Filedownload.save(inputStream, new MimetypesFileTypeMap().getContentType(filez), filez.getName());
|
||||
compactarArquivos(files, fileZip);
|
||||
File filez = new File(fileZip);
|
||||
log.info(filez.exists());
|
||||
if (filez.exists()) {
|
||||
log.debug("download dos arquivos");
|
||||
inputStream = new FileInputStream(filez);
|
||||
Filedownload.save(inputStream, new MimetypesFileTypeMap().getContentType(filez), filez.getName());
|
||||
}
|
||||
filez.delete();
|
||||
|
||||
} finally {
|
||||
con.close();
|
||||
}
|
||||
filez.delete();
|
||||
}
|
||||
|
||||
public static void compactarArquivo(String arqSaida,String arqEntrada) throws IOException{
|
||||
|
|
Loading…
Reference in New Issue