|
|
@@ -17,7 +17,6 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import javax.servlet.ServletException;
|
|
|
@@ -105,71 +104,52 @@ public class PrintController {
|
|
|
String requestId = UUID.randomUUID().toString().replace("-", "");
|
|
|
logger.info("generated id... " + requestId);
|
|
|
printParameters.put(requestId, new PrintParameter(userName, profile, reportName, whereCondition, otherParameters, type, title));
|
|
|
- response.sendRedirect("print/routing?id=" + requestId);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取缓存的打印参数
|
|
|
- *
|
|
|
- * @param id 预打印时获取的 id
|
|
|
- * @return 缓存的打印参数
|
|
|
- */
|
|
|
- @RequestMapping(value = "/parameter")
|
|
|
- @ResponseBody
|
|
|
- public PrintParameter getPrintParameter(String id, HttpServletRequest request, HttpServletResponse response) {
|
|
|
- Assert.hasText(id, "Required String parameter 'id' is not present");
|
|
|
- PrintParameter printParameter = printParameters.get(id);
|
|
|
- Assert.notNull(printParameter, "id 不存在");
|
|
|
- return printParameter;
|
|
|
- }
|
|
|
|
|
|
- /**
|
|
|
- * 为UAS系统打印提供服务, 根据printType进行预览、打印、下载pdf、下载纯数据excel等操作
|
|
|
- *
|
|
|
- * @param id 预打印时获取的 id
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- * @throws SQLException
|
|
|
- * @throws DocumentException
|
|
|
- * @throws IOException
|
|
|
- * @throws JRException
|
|
|
- * @throws ServletException
|
|
|
- */
|
|
|
- @RequestMapping(value = "/routing", method = RequestMethod.GET)
|
|
|
- public void routing(String id, HttpServletRequest request, HttpServletResponse response)
|
|
|
- throws JRException, IOException, DocumentException, SQLException, ServletException {
|
|
|
- PrintParameter printParameter = getPrintParameter(id, request, response);
|
|
|
- switch (printParameter.getPrintType()) {
|
|
|
+ switch (type) {
|
|
|
// 预览或打印
|
|
|
case PREVIEW:
|
|
|
case PRINT:
|
|
|
- String reportName = printParameter.getReportName();
|
|
|
- String previewUrl = String.format("../preview?id=%s&printType=%s", id, printParameter.getPrintType());
|
|
|
+ String previewUrl = String.format("preview?id=%s&printType=%s", requestId, type);
|
|
|
if(!StringUtils.isEmpty(reportName)){
|
|
|
previewUrl += "&reportName=" + URLEncoder.encode(reportName, "UTF-8");
|
|
|
}
|
|
|
response.sendRedirect(previewUrl);
|
|
|
break;
|
|
|
case PDF:
|
|
|
- export(id, ExportType.PDF.name(), true, request, response);
|
|
|
+ export(requestId, 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);
|
|
|
+ export(requestId, ExportType.XLSX_DATA.name(), true, request, response);
|
|
|
} else {
|
|
|
- export(id, ExportType.XLS_DATA.name(), true, request, response);
|
|
|
+ export(requestId, ExportType.XLS_DATA.name(), true, request, response);
|
|
|
}
|
|
|
break;
|
|
|
case WORD:
|
|
|
- export(id, ExportType.DOC.name(), true, request, response);
|
|
|
+ export(requestId, ExportType.DOC.name(), true, request, response);
|
|
|
break;
|
|
|
case TEXT:
|
|
|
- export(id, ExportType.TXT.name(), true, request, response);
|
|
|
+ export(requestId, ExportType.TXT.name(), true, request, response);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取缓存的打印参数
|
|
|
+ *
|
|
|
+ * @param id 预打印时获取的 id
|
|
|
+ * @return 缓存的打印参数
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/parameter")
|
|
|
+ @ResponseBody
|
|
|
+ public PrintParameter getPrintParameter(String id, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ Assert.hasText(id, "Required String parameter 'id' is not present");
|
|
|
+ PrintParameter printParameter = printParameters.get(id);
|
|
|
+ Assert.notNull(printParameter, "id 不存在");
|
|
|
+ return printParameter;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 导出报表
|
|
|
*
|