|
|
@@ -201,11 +201,12 @@ public class PrintController {
|
|
|
// 检查第一页的pdf文件是否存在,若不存在,先生成第一页pdf,返回给前台展示,
|
|
|
// 再开线程生成后面页的pdf和总的pdf(即未分页的pdf),以备后续可能的打印、下载操作使用
|
|
|
if (pageIndex != null) {
|
|
|
- Integer pageSize = printService.previewFirstPage(userName, reportName, whereCondition, otherParameters, file.getPath());
|
|
|
- result=new HashMap<>();
|
|
|
+ Integer pageSize = printService.previewFirstPage(userName, reportName, whereCondition, otherParameters,
|
|
|
+ file.getPath());
|
|
|
+ result = new HashMap<>();
|
|
|
result.put("pageSize", pageSize);
|
|
|
- }
|
|
|
- //参数pageIndex为null,表示是直接打印,需要先生成总的pdf
|
|
|
+ }
|
|
|
+ // 参数pageIndex为null,表示是直接打印,需要先生成总的pdf
|
|
|
else {
|
|
|
result = printService.preview(userName, reportName, whereCondition, otherParameters, null);
|
|
|
byte[] data = null;
|
|
|
@@ -228,6 +229,46 @@ public class PrintController {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取生成的pdf或者xls的信息
|
|
|
+ *
|
|
|
+ * @param userName
|
|
|
+ * 不为null;当前账套用户名
|
|
|
+ * @param reportName
|
|
|
+ * 不为null;需要预览的报表的名称,不带任何后缀(如预览采购单,即为"Purchase")
|
|
|
+ * @param whereCondition
|
|
|
+ * 可为null;where之后的条件(包括where)
|
|
|
+ * @param otherParameters
|
|
|
+ * 若模板已指定需要的参数,则不可为null;其他参数,区别于whereCondition,报表某些字段的值取决于这些参数;
|
|
|
+ * JSON格式,数据为键值对
|
|
|
+ * @param pdfOrXls
|
|
|
+ * pdf或者xls
|
|
|
+ * @return 文件的信息
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/getGeneratedPdfOrXlsInformation")
|
|
|
+ @ResponseBody
|
|
|
+ public Map<String, Object> getGeneratedPdfOrXlsInformation(String userName, String reportName,
|
|
|
+ String whereCondition, String otherParameters, String pdfOrXls) {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ if (StringUtils.isEmpty(pdfOrXls)) {
|
|
|
+ pdfOrXls = "pdf";
|
|
|
+ }
|
|
|
+ String filePath = ReportConstants.GENERATED_FILES_PATH + reportName + "/"
|
|
|
+ + printService.generateFileName(userName, reportName, whereCondition, otherParameters);
|
|
|
+ File file = new File(PathUtils.getAppPath() + filePath + "." + pdfOrXls);
|
|
|
+ result.put("file", file.getPath());
|
|
|
+ if (pdfOrXls.equals("pdf")) {
|
|
|
+ result.put("valid", printService.isFileValid(file.getPath()));
|
|
|
+ result.put("size", file.length());
|
|
|
+ } else if (pdfOrXls.equals("xls")) {
|
|
|
+ result.put("valid", printService.isFileValid(file.getPath()));
|
|
|
+ result.put("size", file.length());
|
|
|
+ } else {
|
|
|
+ throw new SystemError("pdfOrXls只能为pdf或xls");
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 检查userName、reportName参数是否有效,无效则抛出异常
|
|
|
*
|