fixes bug#14354

qua:
dev:

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@93701 d1611594-4594-4d17-8e1d-87c2c4800839
master
walace 2019-05-23 22:07:32 +00:00
parent 5471b76821
commit 3632ee018e
1 changed files with 31 additions and 23 deletions

View File

@ -10,6 +10,7 @@ import java.sql.SQLException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@ -52,6 +53,7 @@ import com.rjconsultores.ventaboletos.service.EmpresaService;
import com.rjconsultores.ventaboletos.service.OrgaoConcedenteService; import com.rjconsultores.ventaboletos.service.OrgaoConcedenteService;
import com.rjconsultores.ventaboletos.service.ParadaService; import com.rjconsultores.ventaboletos.service.ParadaService;
import com.rjconsultores.ventaboletos.service.RutaService; import com.rjconsultores.ventaboletos.service.RutaService;
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar; import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar;
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
@ -204,9 +206,9 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardCompo
int linha = NUM_LINHA_INICIO; int linha = NUM_LINHA_INICIO;
HSSFRow row = null; HSSFRow row = null;
String dataAtual = DateUtil.getStringDate(new Date(),"dd-MM-yy");
sheet1 = wb.createSheet("07-08-19"); sheet1 = wb.createSheet(dataAtual);
geraCabecalho(sheet1, "07-08-19", wb); geraCabecalho(sheet1, dataAtual, wb);
Map<String, Integer> linhas = new HashMap<String, Integer>(); Map<String, Integer> linhas = new HashMap<String, Integer>();
int totalGeral = 0; int totalGeral = 0;
@ -281,25 +283,8 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardCompo
Messagebox.OK, Messagebox.INFORMATION); Messagebox.OK, Messagebox.INFORMATION);
return; return;
} }
String nomeArquivo = UsuarioLogado.getUsuarioLogado().getNombusuario() downloadArquivo(wb);
+ "_" + Calendar.getInstance().getTime().getTime()
+ "_" + "EmbarqueLocalidade";
File fNomeArquivo = File.createTempFile(nomeArquivo, ".tmp");
FileOutputStream stream = new FileOutputStream(fNomeArquivo);
wb.write(stream);
InputStream is = null;
is = new FileInputStream(fNomeArquivo);
Filedownload.save(is, "application/xls", "EmbarqueLocalidade.xls");
fNomeArquivo.delete();
stream.flush();
stream.close();
//is.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -307,6 +292,29 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardCompo
} }
} }
private void downloadArquivo(HSSFWorkbook wb) throws Exception {
String nomeArquivo = UsuarioLogado.getUsuarioLogado().getNombusuario() + "_" + Calendar.getInstance().getTime().getTime() + "_" + "EmbarqueLocalidade.xls";
File fNomeArquivo = File.createTempFile(nomeArquivo, ".tmp");
String contentType = "application/vnd.ms-excel";
InputStream isFile = new FileInputStream(fNomeArquivo);
Filedownload.save(isFile, contentType, nomeArquivo);
FileOutputStream stream = new FileOutputStream(fNomeArquivo);
wb.write(stream);
InputStream is = new FileInputStream(fNomeArquivo);
Filedownload.save(is, contentType, nomeArquivo);
stream.flush();
stream.close();
if (fNomeArquivo != null) {
fNomeArquivo.delete();
}
}
private void geraCabecalhoTitulo(HSSFSheet sheet1, HSSFWorkbook wb) { private void geraCabecalhoTitulo(HSSFSheet sheet1, HSSFWorkbook wb) {
HSSFRow titulo = sheet1.createRow(NUM_LINHA_TITULO); HSSFRow titulo = sheet1.createRow(NUM_LINHA_TITULO);
@ -422,7 +430,7 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardCompo
lsEmpresas = empresaService.obtenerTodos(); lsEmpresas = empresaService.obtenerTodos();
lsOrgaosConcedentes = orgaoConcedenteService.obtenerTodos(); lsOrgaosConcedentes = orgaoConcedenteService.obtenerTodos();
lsOrigens = paradaService.obtenerTodos(); lsOrigens = paradaService.obtenerTodos();
// lsRutas = rutaService.obtenerTodos(); lsRutas = rutaService.obtenerTodos();
} }
public void onChange$cmbOrgaoConcedente(Event ev) throws Exception { public void onChange$cmbOrgaoConcedente(Event ev) throws Exception {