|
|
@@ -57,7 +57,7 @@ public class PrintController {
|
|
|
/**
|
|
|
* 缓存的打印参数
|
|
|
*/
|
|
|
- private ConcurrentMap<String, PrintParameter> printParameters = new ConcurrentHashMap<>();
|
|
|
+ private ConcurrentMap<String, PrintParameter> printParameters = new ConcurrentHashMap<>();
|
|
|
|
|
|
/**
|
|
|
* 预打印,用于缓存参数,以便之后通过 GET 方式调用打印接口(GET 下参数不能过长)
|
|
|
@@ -83,72 +83,69 @@ public class PrintController {
|
|
|
@RequestMapping(value = "")
|
|
|
@ResponseBody
|
|
|
public void preprint(String userName, String profile, String reportName, String whereCondition, String otherParameters,
|
|
|
- String printType, String title, HttpServletRequest request, HttpServletResponse response)
|
|
|
+ String printType, String title, HttpServletRequest request, HttpServletResponse response)
|
|
|
throws JRException, IOException, DocumentException, SQLException, ServletException {
|
|
|
userName = userName == null ? null : userName.toUpperCase();
|
|
|
// printType为空,默认进入预览页
|
|
|
PrintType type = StringUtils.isEmpty(printType) ? PrintType.PREVIEW : PrintType.checkType(printType);
|
|
|
String requestId = UUID.randomUUID().toString().replace("-", "");
|
|
|
printParameters.put(requestId, new PrintParameter(userName, profile, reportName, whereCondition, otherParameters, type, title));
|
|
|
- response.sendRedirect("print/routing?id=" +requestId);
|
|
|
+ response.sendRedirect("print/routing?id=" + requestId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取缓存的打印参数
|
|
|
*
|
|
|
* @param id 预打印时获取的 id
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
* @return 缓存的打印参数
|
|
|
*/
|
|
|
- @RequestMapping("/parameter")
|
|
|
- @ResponseBody
|
|
|
- public PrintParameter getPrintParameter(@RequestParam String id, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ private PrintParameter getPrintParameter(String id) {
|
|
|
PrintParameter printParameter = printParameters.get(id);
|
|
|
Assert.notNull(printParameter, "id 不存在");
|
|
|
return printParameter;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 为UAS系统打印提供服务, 根据printType进行预览、打印、下载pdf、下载纯数据excel等操作
|
|
|
- *
|
|
|
- * @param id 预打印时获取的 id
|
|
|
+ /**
|
|
|
+ * 为UAS系统打印提供服务, 根据printType进行预览、打印、下载pdf、下载纯数据excel等操作
|
|
|
+ *
|
|
|
+ * @param id 预打印时获取的 id
|
|
|
* @param request
|
|
|
* @param response
|
|
|
* @throws SQLException
|
|
|
- * @throws DocumentException
|
|
|
- * @throws IOException
|
|
|
- * @throws JRException
|
|
|
+ * @throws DocumentException
|
|
|
+ * @throws IOException
|
|
|
+ * @throws JRException
|
|
|
* @throws ServletException
|
|
|
- */
|
|
|
- @RequestMapping(value = "/routing", method = RequestMethod.GET)
|
|
|
- public void routing(@RequestParam String id, HttpServletRequest request, HttpServletResponse response)
|
|
|
- throws JRException, IOException, DocumentException, SQLException, ServletException {
|
|
|
- switch (getPrintParameter(id, request, response).getPrintType()) {
|
|
|
- // 预览或打印
|
|
|
- case PREVIEW:
|
|
|
- case PRINT:
|
|
|
- response.sendRedirect("../preview?id=" + id);
|
|
|
- break;
|
|
|
- case PDF:
|
|
|
- export(id, ExportType.PDF.name(), true, request, response);
|
|
|
- break;
|
|
|
- // 该下载接口供 UAS 系统使用,应其要求,printType 为{@link PrintType.EXCEL}时,下载纯数据的 excel
|
|
|
- case EXCEL:
|
|
|
- if (systemProperties.isUseXlsx()) {
|
|
|
- export(id, ExportType.XLSX_DATA.name(), true, request, response);
|
|
|
- } else {
|
|
|
- export(id, ExportType.XLS_DATA.name(), true, request, response);
|
|
|
- }
|
|
|
- break;
|
|
|
- case WORD:
|
|
|
- export(id, ExportType.DOC.name(), true, request, response);
|
|
|
- break;
|
|
|
- case TEXT:
|
|
|
- export(id, ExportType.TXT.name(), true, request, response);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/routing", method = RequestMethod.GET)
|
|
|
+ public void routing(@RequestParam String id, HttpServletRequest request, HttpServletResponse response)
|
|
|
+ throws JRException, IOException, DocumentException, SQLException, ServletException {
|
|
|
+ PrintParameter printParameter = getPrintParameter(id);
|
|
|
+ switch (printParameter.getPrintType()) {
|
|
|
+ // 预览或打印
|
|
|
+ case PREVIEW:
|
|
|
+ case PRINT:
|
|
|
+ response.sendRedirect(String.format("../preview?id=%s&printType=%s&reportName=%s", id, printParameter.getPrintType(), printParameter.getReportName()));
|
|
|
+ break;
|
|
|
+ case PDF:
|
|
|
+ export(id, ExportType.PDF.name(), true, request, response);
|
|
|
+ break;
|
|
|
+ // 该下载接口供 UAS 系统使用,应其要求,printType 为{@link PrintType.EXCEL}时,下载纯数据的 excel
|
|
|
+ case EXCEL:
|
|
|
+ if (systemProperties.isUseXlsx()) {
|
|
|
+ export(id, ExportType.XLSX_DATA.name(), true, request, response);
|
|
|
+ } else {
|
|
|
+ export(id, ExportType.XLS_DATA.name(), true, request, response);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case WORD:
|
|
|
+ export(id, ExportType.DOC.name(), true, request, response);
|
|
|
+ break;
|
|
|
+ case TEXT:
|
|
|
+ export(id, ExportType.TXT.name(), true, request, response);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 导出报表
|
|
|
@@ -168,7 +165,7 @@ public class PrintController {
|
|
|
public void export(@RequestParam String id, String exportFileType, Boolean flush, HttpServletRequest request,
|
|
|
HttpServletResponse response) throws JRException, IOException, DocumentException, SQLException {
|
|
|
// TODO show download process
|
|
|
- PrintParameter printParameter = getPrintParameter(id, request, response);
|
|
|
+ PrintParameter printParameter = getPrintParameter(id);
|
|
|
String userName = printParameter.getUserName();
|
|
|
String profile = printParameter.getProfile();
|
|
|
String reportName = printParameter.getReportName();
|
|
|
@@ -215,7 +212,7 @@ public class PrintController {
|
|
|
@RequestMapping(value = "/pdfPath")
|
|
|
@ResponseBody
|
|
|
public String getPdfPath(@RequestParam String id, Boolean flush, HttpServletRequest request, HttpServletResponse response) throws JRException, IOException, DocumentException, SQLException {
|
|
|
- PrintParameter printParameter = getPrintParameter(id, request, response);
|
|
|
+ PrintParameter printParameter = getPrintParameter(id);
|
|
|
String userName = printParameter.getUserName();
|
|
|
String profile = printParameter.getProfile();
|
|
|
String reportName = printParameter.getReportName();
|