Se agrega informe PDF a Informe de viajes ocasionales #AL-4555
parent
219872c1db
commit
c250a4a548
|
@ -1,34 +1,38 @@
|
|||
package com.rjconsultores.ventaboletos.web.gui.controladores.expressos;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.zkoss.util.media.AMedia;
|
||||
import org.zkoss.util.resource.Labels;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zul.Filedownload;
|
||||
import org.zkoss.zul.Messagebox;
|
||||
import org.zkoss.zul.Paging;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.SolicitudExpreso;
|
||||
import com.rjconsultores.ventaboletos.entidad.TrayectosExpresos;
|
||||
import com.rjconsultores.ventaboletos.service.SolicitudExpresosService;
|
||||
import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioInformeViajesOcasionalesPdf;
|
||||
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.MyDatebox;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.MyListbox;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.paginacion.HibernateSearchObject;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.paginacion.PagedListWrapper;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.render.RenderExpresosPorCotizar;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.render.RenderInformeViajesOcasionales;
|
||||
|
||||
@Controller("informeViajesOcasionalesExpresosController")
|
||||
@Scope("prototype")
|
||||
public class InformeViajesOcasionalesExpresosController extends MyGenericForwardComposer{
|
||||
|
||||
private static final String NOME_RELATORIO = "informeViajesOcasionales";
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Autowired
|
||||
|
@ -83,6 +87,26 @@ public class InformeViajesOcasionalesExpresosController extends MyGenericForward
|
|||
|
||||
public void onClick$btnImprimir(Event ev) throws InterruptedException {}
|
||||
|
||||
public void onClick$btnExportarPdf(Event ev) throws SQLException, Exception {
|
||||
excutarInformeViajes(true);
|
||||
}
|
||||
|
||||
private void excutarInformeViajes(boolean isPdf)throws SQLException, Exception {
|
||||
RelatorioInformeViajesOcasionalesPdf r = new RelatorioInformeViajesOcasionalesPdf(expresosList);
|
||||
InputStream mediais = new ByteArrayInputStream(r.generateReportRender(isPdf));
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH-mm");
|
||||
String nomeRelatorioDownload = NOME_RELATORIO + "_" + sdf.format(Calendar.getInstance().getTime());
|
||||
|
||||
if(isPdf) {
|
||||
AMedia conteudoRelatorioXLS = new AMedia("relatorio.pdf", "pdf", null, mediais);
|
||||
Filedownload.save(conteudoRelatorioXLS.getStreamData(), "application/pdf", nomeRelatorioDownload + ".pdf");
|
||||
}else {
|
||||
AMedia conteudoRelatorioXLS = new AMedia("relatorio.xls", "xls", null, mediais);
|
||||
Filedownload.save(conteudoRelatorioXLS.getStreamData(), "application/xls", nomeRelatorioDownload + ".xls");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public MyListbox getExpresosList() {
|
||||
return expresosList;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue