|
|
@@ -64,12 +64,14 @@ public class PrintController {
|
|
|
* @param printType
|
|
|
* 打印类型,可为PREVIEW_PRINT_TYPE、PRINT_PRINT_TYPE、PDF_PRINT_TYPE、
|
|
|
* EXCEL_PRINT_TYPE
|
|
|
+ * @param title
|
|
|
+ * 导出为文件时的名称
|
|
|
* @param request
|
|
|
* @param response
|
|
|
*/
|
|
|
@RequestMapping()
|
|
|
public void print(String userName, String profile, String reportName, String whereCondition, String otherParameters,
|
|
|
- String printType, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ String printType, String title, HttpServletRequest request, HttpServletResponse response) {
|
|
|
// printType为空,默认进入预览页
|
|
|
if (StringUtils.isEmpty(printType)) {
|
|
|
printType = ReportConstants.PREVIEW_PRINT_TYPE;
|
|
|
@@ -87,18 +89,18 @@ public class PrintController {
|
|
|
// 下载pdf、纯数据excel
|
|
|
else if (printType.equals(ReportConstants.PDF_PRINT_TYPE)) {
|
|
|
export(userName, profile, reportName, whereCondition, otherParameters, ReportConstants.PDF_FILE_TYPE, true,
|
|
|
- request, response);
|
|
|
+ title, 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, true, request, response);
|
|
|
+ ReportConstants.EXCEL_WITH_ONLY_DATA_FILE_TYPE, true, title, request, response);
|
|
|
}
|
|
|
// 下载word
|
|
|
else if (printType.equals(ReportConstants.WORD_PRINT_TYPE)) {
|
|
|
export(userName, profile, reportName, whereCondition, otherParameters, ReportConstants.WORD_FILE_TYPE, true,
|
|
|
- request, response);
|
|
|
+ title, request, response);
|
|
|
} else {
|
|
|
throw new ReportException("printType不合法");
|
|
|
}
|
|
|
@@ -122,13 +124,15 @@ public class PrintController {
|
|
|
* 报表导出的格式,默认为pdf
|
|
|
* @param flush
|
|
|
* 是否强制刷新pdf、xls
|
|
|
+ * @param title
|
|
|
+ * 导出为文件时的名称
|
|
|
* @param request
|
|
|
* @param response
|
|
|
*/
|
|
|
@RequestMapping("/export")
|
|
|
@ResponseBody
|
|
|
public void export(String userName, String profile, String reportName, String whereCondition,
|
|
|
- String otherParameters, String exportFileType, Boolean flush, HttpServletRequest request,
|
|
|
+ String otherParameters, String exportFileType, Boolean flush, String title, HttpServletRequest request,
|
|
|
HttpServletResponse response) {
|
|
|
ReportUtils.checkParameters(userName, reportName);
|
|
|
if (printService.overload(userName, profile, reportName, whereCondition)) {
|
|
|
@@ -178,7 +182,10 @@ public class PrintController {
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- String exportFileName = reportName;
|
|
|
+ String exportFileName = title;
|
|
|
+ if (StringUtils.isEmpty(exportFileName)) {
|
|
|
+ exportFileName = reportName;
|
|
|
+ }
|
|
|
if (exportFileType.equals(ReportConstants.EXCEL_WITH_ONLY_DATA_FILE_TYPE)) {
|
|
|
exportFileName += "." + ReportConstants.EXCEL_FILE_TYPE;
|
|
|
} else {
|