|
|
@@ -39,19 +39,14 @@ import com.uas.report.util.ReportUtils;
|
|
|
@RequestMapping("/print")
|
|
|
public class PrintController {
|
|
|
|
|
|
- private static Logger logger = LoggerFactory.getLogger(PrintController.class);
|
|
|
-
|
|
|
- /**
|
|
|
- * 报表支持的最大页数,无论是下载excel、pdf还是预览,超过该数值,均不提供服务
|
|
|
- */
|
|
|
- private static final Integer MAX_PAGE_SIZE = 1000;
|
|
|
-
|
|
|
@Autowired
|
|
|
private PrintService printService;
|
|
|
|
|
|
@Autowired
|
|
|
private FileService fileService;
|
|
|
|
|
|
+ private static Logger logger = LoggerFactory.getLogger(PrintController.class);
|
|
|
+
|
|
|
/**
|
|
|
* 为UAS系统打印提供服务, 根据printType进行预览、打印、下载pdf、下载纯数据excel等操作
|
|
|
*
|
|
|
@@ -136,6 +131,9 @@ public class PrintController {
|
|
|
String otherParameters, String exportFileType, Boolean flush, HttpServletRequest request,
|
|
|
HttpServletResponse response) {
|
|
|
ReportUtils.checkParameters(userName, reportName);
|
|
|
+ if (printService.overload(userName, profile, reportName, whereCondition)) {
|
|
|
+ throw new ReportException("数据量过大,无法提供服务");
|
|
|
+ }
|
|
|
String masterOfJrxml = printService.getMasterOfJrxml(userName, reportName);
|
|
|
if (StringUtils.isEmpty(exportFileType)) {
|
|
|
exportFileType = ReportConstants.PDF_FILE_TYPE;
|
|
|
@@ -225,6 +223,9 @@ public class PrintController {
|
|
|
final String whereCondition, final String otherParameters, Integer pageIndex, Boolean flush,
|
|
|
HttpServletRequest request, HttpServletResponse response) {
|
|
|
ReportUtils.checkParameters(userName, reportName);
|
|
|
+ if (printService.overload(userName, profile, reportName, whereCondition)) {
|
|
|
+ throw new ReportException("数据量过大,无法提供服务");
|
|
|
+ }
|
|
|
String masterOfJrxml = printService.getMasterOfJrxml(userName, reportName);
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
|
|
|
@@ -296,25 +297,16 @@ public class PrintController {
|
|
|
*/
|
|
|
@RequestMapping(value = "/pdfData")
|
|
|
@ResponseBody
|
|
|
- public Map<String, Object> getPdfPath(final String userName, final String profile, final String reportName,
|
|
|
+ public Map<String, Object> getPdfData(final String userName, final String profile, final String reportName,
|
|
|
final String whereCondition, final String otherParameters, HttpServletRequest request,
|
|
|
HttpServletResponse response) {
|
|
|
ReportUtils.checkParameters(userName, reportName);
|
|
|
-
|
|
|
- // 通过预览第一页,获取总页数
|
|
|
- // TODO 需重写判断页数的方法
|
|
|
- Map<String, Object> result = printService.preview(userName, profile, reportName, whereCondition,
|
|
|
- otherParameters, 1);
|
|
|
- Integer pageSize = null;
|
|
|
- if (result != null && result.containsKey("data") && result.containsKey("pageSize")) {
|
|
|
- pageSize = (Integer) result.get("pageSize");
|
|
|
- }
|
|
|
- if (pageSize == null) {
|
|
|
- throw new ReportException("获取预览数据失败");
|
|
|
- }
|
|
|
- if (pageSize > MAX_PAGE_SIZE) {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ // 判断是否过载
|
|
|
+ if (printService.overload(userName, profile, reportName, whereCondition)) {
|
|
|
result.put("data", "");
|
|
|
- result.put("overload", "true");
|
|
|
+ result.put("pageSize", 0);
|
|
|
+ result.put("overload", true);
|
|
|
} else {
|
|
|
result = printService.preview(userName, profile, reportName, whereCondition, otherParameters, null);
|
|
|
result.put("overload", false);
|