package com.fr.plugin; import com.fr.decision.webservice.bean.security.WatermarkBean; import com.fr.decision.webservice.v10.security.SecurityService; import com.fr.io.collection.ExportCollection; import com.fr.io.exporter.AppExporter; import com.fr.plugin.excel.ExAppExporter; import com.fr.plugin.transform.ExecuteFunctionRecord; import com.fr.plugin.transform.FunctionRecorder; import com.fr.stable.StringUtils; import com.fr.web.core.ReportSessionIDInfor; import com.fr.web.core.reserve.DefaultExportExtension; import com.fr.web.core.reserve.ExportFactory; import com.fr.web.core.reserve.Operate; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @FunctionRecorder public class WmExportProcessor extends DefaultExportExtension { @Override @ExecuteFunctionRecord public ExportCollection createCollection(HttpServletRequest req, HttpServletResponse res, ReportSessionIDInfor sessionIDInfor, String format, String fileName, boolean isEmbed) throws Exception { Operate operate = ExportFactory.getOperate(format.toLowerCase()); if(StringUtils.equals("image",format)){ res.setHeader("Content-Disposition", "attachment;filename="+fileName+".png"); }else{ res.setHeader("Content-Disposition", "attachment;filename="+fileName+"."+format); } if (StringUtils.equals(format, "excel")) { SecurityService securityService = SecurityService.getInstance(); WatermarkBean parsedWatermarkBean = securityService.getParsedWatermarkBean(req); if (StringUtils.isNotBlank(parsedWatermarkBean.getText())) { if (operate != null) { //先获取到真的AppExporter 然后构造我们自己的导出器 ExportCollection exportCollection = operate.newExportCollection(req, res, sessionIDInfor, fileName); AppExporter exporter = exportCollection.getExporter(); ExAppExporter exAppExporter = new ExAppExporter(exporter, parsedWatermarkBean); exportCollection.setExporter(exAppExporter); return exportCollection; } } } ExportCollection exportCollection = operate.newExportCollection(req, res, sessionIDInfor, fileName); return exportCollection; } }