Exportação Fiscal : ECF e RMD (issue 8120)
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@65802 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
f619018768
commit
8cace07b18
|
@ -3,6 +3,8 @@ package com.rjconsultores.ventaboletos.web.gui.controladores.impressaofiscal;
|
|||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
@ -100,10 +102,12 @@ public class BusquedaExportacaoFiscalController extends MyGenericForwardComposer
|
|||
}
|
||||
|
||||
if (empresa != null && estado != null) {
|
||||
File arquivo = fiscalService.buscarArquivoExportacaoECF(datInicial.getValue(), datFinal.getValue(), empresa, estado);
|
||||
String nomeArquivo = getNomeArquivoExportacaoECF(datInicial.getValue(), estado);
|
||||
|
||||
File arquivo = fiscalService.buscarArquivoExportacaoECF(datInicial.getValue(), datFinal.getValue(), empresa, estado, nomeArquivo);
|
||||
|
||||
try {
|
||||
downloadArquivo(arquivo);
|
||||
downloadArquivo(arquivo, nomeArquivo);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
|
@ -111,6 +115,35 @@ public class BusquedaExportacaoFiscalController extends MyGenericForwardComposer
|
|||
}
|
||||
}
|
||||
|
||||
private String getNomeArquivoExportacaoECF(Date dataInicial, Estado estado) {
|
||||
String[] mesano = new SimpleDateFormat("MM/yyyy").format(dataInicial).split("/");
|
||||
|
||||
String mes = mesano[0].toString();
|
||||
String ano = mesano[1].toString();
|
||||
|
||||
String nome = "";
|
||||
|
||||
switch (Integer.valueOf(mes)) {
|
||||
case 1: nome = "Jan"; break;
|
||||
case 2: nome = "Fev"; break;
|
||||
case 3: nome = "Mar"; break;
|
||||
case 4: nome = "Abr"; break;
|
||||
case 5: nome = "Mai"; break;
|
||||
case 6: nome = "Jun"; break;
|
||||
case 7: nome = "Jul"; break;
|
||||
case 8: nome = "Ago"; break;
|
||||
case 9: nome = "Set"; break;
|
||||
case 10: nome = "Out"; break;
|
||||
case 11: nome = "Nov"; break;
|
||||
case 12: nome = "Dez"; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
String nomeArquivo = "TotalBus " + estado.getCveestado() + " ECF " + nome + ano;
|
||||
|
||||
return nomeArquivo;
|
||||
}
|
||||
|
||||
public void onClick$btnExeExportacaoRMD(Event ev) throws InterruptedException {
|
||||
Empresa empresa = null;
|
||||
Estado estado = null;
|
||||
|
@ -130,7 +163,7 @@ public class BusquedaExportacaoFiscalController extends MyGenericForwardComposer
|
|||
File arquivo = fiscalService.buscarArquivoExportacaoRMD(datInicial.getValue(), datFinal.getValue(), empresa, estado);
|
||||
|
||||
try {
|
||||
downloadArquivo(arquivo);
|
||||
downloadArquivo(arquivo, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
|
@ -138,16 +171,13 @@ public class BusquedaExportacaoFiscalController extends MyGenericForwardComposer
|
|||
}
|
||||
}
|
||||
|
||||
private void downloadArquivo(File arquivoTxt) throws Exception {
|
||||
private void downloadArquivo(File arquivoTxt, String nome) throws Exception {
|
||||
String contentType = "application/notepad";
|
||||
InputStream isFile = new FileInputStream(arquivoTxt);
|
||||
String nomeArquivo = arquivoTxt.getName();
|
||||
|
||||
if (nomeArquivo.contains(".fs")) {
|
||||
String nome = nomeArquivo.substring(0, nomeArquivo.length() - 3);
|
||||
String[] parte = nome.split("-");
|
||||
|
||||
nomeArquivo = parte[0].toString() + ".fs";
|
||||
if (nome != null && !nome.isEmpty()) {
|
||||
nomeArquivo = nome + ".fs";
|
||||
}
|
||||
|
||||
Filedownload.save(isFile, contentType, nomeArquivo);
|
||||
|
|
Loading…
Reference in New Issue