|
|
@@ -86,14 +86,14 @@ public class PrintController {
|
|
|
}
|
|
|
// 下载pdf、纯数据excel
|
|
|
else if (printType.equals(ReportConstants.PDF_PRINT_TYPE)) {
|
|
|
- export(userName, profile, reportName, whereCondition, otherParameters, ReportConstants.PDF_FILE_TYPE,
|
|
|
+ export(userName, profile, reportName, whereCondition, otherParameters, ReportConstants.PDF_FILE_TYPE, true,
|
|
|
request, response);
|
|
|
}
|
|
|
// 该下载接口供UAS系统使用,应其要求,EXCEL_PRINT_TYPE只能为EXCEL(该值意思本应为下载全部数据的excel),
|
|
|
// 导致与EXCEL_WITH_ONLY_DATA_FILE_TYPE(下载纯数据的excel)命名不相匹配
|
|
|
else if (printType.equals(ReportConstants.EXCEL_PRINT_TYPE)) {
|
|
|
export(userName, profile, reportName, whereCondition, otherParameters,
|
|
|
- ReportConstants.EXCEL_WITH_ONLY_DATA_FILE_TYPE, request, response);
|
|
|
+ ReportConstants.EXCEL_WITH_ONLY_DATA_FILE_TYPE, true, request, response);
|
|
|
} else {
|
|
|
throw new ReportException("printType不合法");
|
|
|
}
|
|
|
@@ -115,13 +115,16 @@ public class PrintController {
|
|
|
* JSON格式,数据为键值对
|
|
|
* @param exportFileType
|
|
|
* 报表导出的格式,默认为pdf
|
|
|
+ * @param flush
|
|
|
+ * 是否强制刷新pdf、xls
|
|
|
* @param request
|
|
|
* @param response
|
|
|
*/
|
|
|
@RequestMapping("/export")
|
|
|
@ResponseBody
|
|
|
public void export(String userName, String profile, String reportName, String whereCondition,
|
|
|
- String otherParameters, String exportFileType, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ String otherParameters, String exportFileType, Boolean flush, HttpServletRequest request,
|
|
|
+ HttpServletResponse response) {
|
|
|
ReportUtils.checkParameters(userName, reportName);
|
|
|
String masterOfJrxml = printService.getMasterOfJrxml(userName, reportName);
|
|
|
if (StringUtils.isEmpty(exportFileType)) {
|
|
|
@@ -138,8 +141,10 @@ public class PrintController {
|
|
|
filePath += "." + exportFileType;
|
|
|
}
|
|
|
File file = new File(ReportConstants.GENERATED_FILES_DIR + filePath);
|
|
|
+ // 指定flush为true(强制刷新pdf、xls)
|
|
|
// 文件无效(不存在或过期),创建
|
|
|
- if (!fileService.isFileValid(file.getPath(), fileService.getJrxmlFilePath(masterOfJrxml, reportName))) {
|
|
|
+ if ((flush != null && flush.booleanValue())
|
|
|
+ || !fileService.isFileValid(file.getPath(), fileService.getJrxmlFilePath(masterOfJrxml, reportName))) {
|
|
|
data = printService.export(userName, profile, reportName, whereCondition, otherParameters, exportFileType);
|
|
|
if (ArrayUtils.isEmpty(data)) {
|
|
|
throw new ReportException("报表导出失败:" + userName + "/" + reportName + "\n");
|
|
|
@@ -198,6 +203,8 @@ public class PrintController {
|
|
|
* JSON格式,数据为键值对
|
|
|
* @param pageIndex
|
|
|
* 分页展示,当前页码,从0开始
|
|
|
+ * @param flush
|
|
|
+ * 是否强制刷新pdf、xls
|
|
|
* @param request
|
|
|
* @param response
|
|
|
* @return 包括pageSize、pdfPath
|
|
|
@@ -205,8 +212,8 @@ public class PrintController {
|
|
|
@RequestMapping(value = "/loadPdfData")
|
|
|
@ResponseBody
|
|
|
public Map<String, Object> loadPdfData(final String userName, final String profile, final String reportName,
|
|
|
- final String whereCondition, final String otherParameters, Integer pageIndex, HttpServletRequest request,
|
|
|
- HttpServletResponse response) {
|
|
|
+ final String whereCondition, final String otherParameters, Integer pageIndex, Boolean flush,
|
|
|
+ HttpServletRequest request, HttpServletResponse response) {
|
|
|
ReportUtils.checkParameters(userName, reportName);
|
|
|
String masterOfJrxml = printService.getMasterOfJrxml(userName, reportName);
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
@@ -218,8 +225,10 @@ public class PrintController {
|
|
|
+ "." + ReportConstants.PDF_FILE_TYPE;
|
|
|
final File file = new File(ReportConstants.GENERATED_FILES_DIR + pdfPath);
|
|
|
if (pageIndex == null || pageIndex == 1) {
|
|
|
+ // 指定flush为true(强制刷新pdf)
|
|
|
// 文件无效(不存在或过期),重新创建pdf文件
|
|
|
- if (!fileService.isFileValid(file.getPath(), fileService.getJrxmlFilePath(masterOfJrxml, reportName))) {
|
|
|
+ if ((flush != null && flush.booleanValue()) || !fileService.isFileValid(file.getPath(),
|
|
|
+ fileService.getJrxmlFilePath(masterOfJrxml, reportName))) {
|
|
|
// 参数pageIndex为null或1,表示是直接打印或预览第一页,
|
|
|
// 需要生成第一页(可能页数过多,提示用户不支持预览打印),再在后台开线程生成总的pdf
|
|
|
// 先生成第一页pdf
|