leonardo 2016-03-28 13:47:47 +00:00
parent 134cf97d5e
commit 3529bc704e
1 changed files with 38 additions and 28 deletions

View File

@ -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,11 +75,15 @@ 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);
Connection con = null;
try{
con = 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) + "" + (cal.get(Calendar.MONTH) + 1) + "" + cal.get(Calendar.DAY_OF_MONTH) + ".txt";
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);
Totalbus totalbus = new Totalbus(dataSource.getConnection());
Totalbus totalbus = new Totalbus(con);
log.debug("gerando arquivo...");
Arquivo.GravaArquivo(file.getAbsolutePath(), totalbus.getDespesasReceitas(
@ -103,6 +109,10 @@ public class RelatorioArquivoBGMController extends MyGenericForwardComposer {
Filedownload.save(inputStream, new MimetypesFileTypeMap().getContentType(filez), filez.getName());
}
filez.delete();
} finally {
con.close();
}
}
public static void compactarArquivo(String arqSaida,String arqEntrada) throws IOException{