|
|
@@ -77,12 +77,12 @@ public class PrintController {
|
|
|
userName = userName == null ? null : userName.toUpperCase();
|
|
|
// printType为空,默认进入预览页
|
|
|
if (StringUtils.isEmpty(printType)) {
|
|
|
- printType = ReportConstants.PREVIEW_PRINT_TYPE;
|
|
|
+ printType = ReportConstants.PRINT_TYPE_PREVIEW;
|
|
|
}
|
|
|
|
|
|
// 预览或打印
|
|
|
- if (printType.equals(ReportConstants.PREVIEW_PRINT_TYPE)
|
|
|
- || printType.equals(ReportConstants.PRINT_PRINT_TYPE)) {
|
|
|
+ if (printType.equals(ReportConstants.PRINT_TYPE_PREVIEW)
|
|
|
+ || printType.equals(ReportConstants.PRINT_TYPE_PRINT)) {
|
|
|
try {
|
|
|
request.getRequestDispatcher("preview").forward(request, response);
|
|
|
} catch (IOException | ServletException e) {
|
|
|
@@ -90,19 +90,19 @@ public class PrintController {
|
|
|
}
|
|
|
}
|
|
|
// 下载pdf、纯数据excel
|
|
|
- else if (printType.equals(ReportConstants.PDF_PRINT_TYPE)) {
|
|
|
- export(userName, profile, reportName, whereCondition, otherParameters, ReportConstants.PDF_FILE_TYPE, true,
|
|
|
+ else if (printType.equals(ReportConstants.PRINT_TYPE_PDF)) {
|
|
|
+ export(userName, profile, reportName, whereCondition, otherParameters, ReportConstants.FILE_TYPE_PDF, true,
|
|
|
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, title, request, response);
|
|
|
+ // 该下载接口供UAS系统使用,应其要求,PRINT_TYPE_EXCEL只能为EXCEL(该值意思本应为下载全部数据的excel),
|
|
|
+ // 导致与FILE_TYPE_EXCEL_DATA(下载纯数据的excel)命名不相匹配
|
|
|
+ else if (printType.equals(ReportConstants.PRINT_TYPE_EXCEL)) {
|
|
|
+ export(userName, profile, reportName, whereCondition, otherParameters, ReportConstants.FILE_TYPE_EXCEL_DATA,
|
|
|
+ true, title, request, response);
|
|
|
}
|
|
|
// 下载word
|
|
|
- else if (printType.equals(ReportConstants.WORD_PRINT_TYPE)) {
|
|
|
- export(userName, profile, reportName, whereCondition, otherParameters, ReportConstants.WORD_FILE_TYPE, true,
|
|
|
+ else if (printType.equals(ReportConstants.PRINT_TYPE_WORD)) {
|
|
|
+ export(userName, profile, reportName, whereCondition, otherParameters, ReportConstants.FILE_TYPE_WORD, true,
|
|
|
title, request, response);
|
|
|
} else {
|
|
|
throw new ReportException("printType不合法");
|
|
|
@@ -141,15 +141,15 @@ public class PrintController {
|
|
|
ReportUtils.checkParameters(userName, reportName);
|
|
|
String masterOfJrxml = printService.getMasterOfJrxml(userName, reportName);
|
|
|
if (StringUtils.isEmpty(exportFileType)) {
|
|
|
- exportFileType = ReportConstants.PDF_FILE_TYPE;
|
|
|
+ exportFileType = ReportConstants.FILE_TYPE_PDF;
|
|
|
}
|
|
|
|
|
|
byte[] data = null;
|
|
|
|
|
|
String filePath = ReportConstants.GENERATED_FILES_PATH + reportName + "/"
|
|
|
+ fileService.generateFileName(userName, profile, whereCondition, otherParameters, exportFileType);
|
|
|
- if (exportFileType.equals(ReportConstants.EXCEL_WITH_ONLY_DATA_FILE_TYPE)) {
|
|
|
- filePath += "." + ReportConstants.EXCEL_FILE_TYPE;
|
|
|
+ if (exportFileType.equals(ReportConstants.FILE_TYPE_EXCEL_DATA)) {
|
|
|
+ filePath += "." + ReportConstants.FILE_TYPE_EXCEL;
|
|
|
} else {
|
|
|
filePath += "." + exportFileType;
|
|
|
}
|
|
|
@@ -179,8 +179,8 @@ public class PrintController {
|
|
|
if (StringUtils.isEmpty(exportFileName)) {
|
|
|
exportFileName = reportName;
|
|
|
}
|
|
|
- if (exportFileType.equals(ReportConstants.EXCEL_WITH_ONLY_DATA_FILE_TYPE)) {
|
|
|
- exportFileName += "." + ReportConstants.EXCEL_FILE_TYPE;
|
|
|
+ if (exportFileType.equals(ReportConstants.FILE_TYPE_EXCEL_DATA)) {
|
|
|
+ exportFileName += "." + ReportConstants.FILE_TYPE_EXCEL;
|
|
|
} else {
|
|
|
exportFileName += "." + exportFileType;
|
|
|
}
|
|
|
@@ -217,17 +217,16 @@ public class PrintController {
|
|
|
*/
|
|
|
@RequestMapping(value = "/pdfPath")
|
|
|
@ResponseBody
|
|
|
- public String pdfPath(String userName, final String profile, final String reportName,
|
|
|
- final String whereCondition, final String otherParameters, Boolean flush, HttpServletRequest request,
|
|
|
- HttpServletResponse response) {
|
|
|
+ public String pdfPath(String userName, final String profile, final String reportName, final String whereCondition,
|
|
|
+ final String otherParameters, Boolean flush, HttpServletRequest request, HttpServletResponse response) {
|
|
|
userName = userName == null ? null : userName.toUpperCase();
|
|
|
ReportUtils.checkParameters(userName, reportName);
|
|
|
String masterOfJrxml = printService.getMasterOfJrxml(userName, reportName);
|
|
|
|
|
|
// 相对路径,返回给前端
|
|
|
String pdfPath = ReportConstants.GENERATED_FILES_PATH + reportName + "/" + fileService
|
|
|
- .generateFileName(userName, profile, whereCondition, otherParameters, ReportConstants.PDF_FILE_TYPE)
|
|
|
- + "." + ReportConstants.PDF_FILE_TYPE;
|
|
|
+ .generateFileName(userName, profile, whereCondition, otherParameters, ReportConstants.FILE_TYPE_PDF)
|
|
|
+ + "." + ReportConstants.FILE_TYPE_PDF;
|
|
|
final File file = new File(ReportConstants.GENERATED_FILES_DIR + pdfPath);
|
|
|
// 指定flush为true(强制刷新pdf)
|
|
|
// 文件无效(不存在或过期),重新创建pdf文件
|