|
|
@@ -8,6 +8,7 @@ import com.uas.report.model.PrintType;
|
|
|
import com.uas.report.service.FileService;
|
|
|
import com.uas.report.service.PrintService;
|
|
|
import com.uas.report.util.Assert;
|
|
|
+import com.uas.report.util.PdfUtils;
|
|
|
import com.uas.report.util.ReportUtils;
|
|
|
import com.uas.report.util.StringUtils;
|
|
|
import net.sf.jasperreports.engine.JRException;
|
|
|
@@ -176,6 +177,9 @@ public class PrintController {
|
|
|
String otherParameters = printParameter.getOtherParameters();
|
|
|
String title = printParameter.getTitle();
|
|
|
ReportUtils.checkParameters(userName, reportName);
|
|
|
+ //是否以分页的形式导出pdf文件
|
|
|
+ boolean split = "SPLITBYPAGE".equals(exportFileType) ? true : false;
|
|
|
+ exportFileType = split ? "PDF" : exportFileType;
|
|
|
|
|
|
String masterOfJrxml = printService.getMasterOfJrxml(userName, reportName);
|
|
|
ExportType exportType = StringUtils.isEmpty(exportFileType) ? ExportType.PDF
|
|
|
@@ -194,9 +198,16 @@ public class PrintController {
|
|
|
}
|
|
|
printService.export(userName, profile, reportName, whereCondition, otherParameters, exportType, file, null, true);
|
|
|
}
|
|
|
-
|
|
|
- String exportFileName = (!StringUtils.isEmpty(title) ? title : reportName) + "." + exportType.getQualifier();
|
|
|
- fileService.rangeDownload(file, exportFileName, request, response);
|
|
|
+ String exportFileName = (!StringUtils.isEmpty(title) ? title : reportName);
|
|
|
+ if (split) {
|
|
|
+ //pdf按页分文件
|
|
|
+ String[] files = PdfUtils.splitByPage(file.getAbsolutePath(), exportFileName);
|
|
|
+ exportFileName += ".zip";
|
|
|
+ fileService.rangeDownload(files, exportFileName, request, response);
|
|
|
+ } else {
|
|
|
+ exportFileName += "." + exportType.getQualifier();
|
|
|
+ fileService.rangeDownload(file, exportFileName, request, response);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -227,7 +238,7 @@ public class PrintController {
|
|
|
String pdfPath = reportName + "/"
|
|
|
+ fileService.generateFileName(userName, profile, whereCondition, otherParameters, ExportType.PDF.getQualifier())
|
|
|
+ "." + ExportType.PDF.getQualifier();
|
|
|
- File file = new File(ReportUtils.getDocumentsDir(), pdfPath);
|
|
|
+ File file = new File(ReportUtils.getDocumentsDir(), pdfPath);
|
|
|
// 指定flush为true(强制刷新pdf)
|
|
|
// 文件无效(不存在或过期),重新创建pdf文件
|
|
|
if ((flush != null && flush)
|