|
|
@@ -1,38 +1,30 @@
|
|
|
package com.uas.report.controller;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
-import java.sql.SQLException;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-import javax.servlet.ServletException;
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-
|
|
|
+import com.uas.report.SystemProperties;
|
|
|
+import com.uas.report.model.ExportType;
|
|
|
+import com.uas.report.model.PrintType;
|
|
|
+import com.uas.report.service.FileService;
|
|
|
+import com.uas.report.service.PrintService;
|
|
|
+import com.uas.report.util.*;
|
|
|
+import net.sf.jasperreports.engine.JRException;
|
|
|
import org.dom4j.DocumentException;
|
|
|
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.ResponseBody;
|
|
|
|
|
|
-import com.uas.report.model.ExportType;
|
|
|
-import com.uas.report.model.PrintType;
|
|
|
-import com.uas.report.service.FileService;
|
|
|
-import com.uas.report.service.PrintService;
|
|
|
-import com.uas.report.util.ArrayUtils;
|
|
|
-import com.uas.report.util.CollectionUtils;
|
|
|
-import com.uas.report.util.FileUtils;
|
|
|
-import com.uas.report.util.Platform;
|
|
|
-import com.uas.report.util.ReportConstants;
|
|
|
-import com.uas.report.util.ReportUtils;
|
|
|
-import com.uas.report.util.StringUtils;
|
|
|
-
|
|
|
-import net.sf.jasperreports.engine.JRException;
|
|
|
+import javax.servlet.ServletException;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.sql.SQLException;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 报表打印
|
|
|
- *
|
|
|
+ *
|
|
|
* @author sunyj
|
|
|
* @since 2016年8月16日 下午3:49:02
|
|
|
*/
|
|
|
@@ -41,6 +33,9 @@ import net.sf.jasperreports.engine.JRException;
|
|
|
@RequestMapping("/print")
|
|
|
public class PrintController {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SystemProperties systemProperties;
|
|
|
+
|
|
|
@Autowired
|
|
|
private PrintService printService;
|
|
|
|
|
|
@@ -49,7 +44,7 @@ public class PrintController {
|
|
|
|
|
|
/**
|
|
|
* 为UAS系统打印提供服务, 根据printType进行预览、打印、下载pdf、下载纯数据excel等操作
|
|
|
- *
|
|
|
+ *
|
|
|
* @param userName
|
|
|
* 不为null;当前账套名称
|
|
|
* @param profile
|
|
|
@@ -89,28 +84,33 @@ public class PrintController {
|
|
|
request.getRequestDispatcher("preview").forward(request, response);
|
|
|
break;
|
|
|
case PDF:
|
|
|
- export(userName, profile, reportName, whereCondition, otherParameters, ExportType.PDF.name(), true,
|
|
|
- title, request, response);
|
|
|
+ export(userName, profile, reportName, whereCondition, otherParameters, ExportType.PDF.name(), true, title,
|
|
|
+ request, response);
|
|
|
break;
|
|
|
// 该下载接口供 UAS 系统使用,应其要求,printType 为{@link PrintType.EXCEL}时,下载纯数据的 excel
|
|
|
case EXCEL:
|
|
|
- export(userName, profile, reportName, whereCondition, otherParameters, ExportType.XLS_DATA.name(),
|
|
|
- true, title, request, response);
|
|
|
+ if (systemProperties.isUseXlsx()) {
|
|
|
+ export(userName, profile, reportName, whereCondition, otherParameters, ExportType.XLSX_DATA.name(),
|
|
|
+ true, title, request, response);
|
|
|
+ } else {
|
|
|
+ export(userName, profile, reportName, whereCondition, otherParameters, ExportType.XLS_DATA.name(), true,
|
|
|
+ title, request, response);
|
|
|
+ }
|
|
|
break;
|
|
|
case WORD:
|
|
|
- export(userName, profile, reportName, whereCondition, otherParameters, ExportType.DOC.name(), true,
|
|
|
- title, request, response);
|
|
|
+ export(userName, profile, reportName, whereCondition, otherParameters, ExportType.DOC.name(), true, title,
|
|
|
+ request, response);
|
|
|
break;
|
|
|
case TEXT:
|
|
|
- export(userName, profile, reportName, whereCondition, otherParameters, ExportType.TXT.name(), true,
|
|
|
- title, request, response);
|
|
|
+ export(userName, profile, reportName, whereCondition, otherParameters, ExportType.TXT.name(), true, title,
|
|
|
+ request, response);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 导出报表
|
|
|
- *
|
|
|
+ *
|
|
|
* @param userName
|
|
|
* 不为null;当前账套名称
|
|
|
* @param profile
|
|
|
@@ -171,7 +171,7 @@ public class PrintController {
|
|
|
|
|
|
/**
|
|
|
* 报表预览时获取pdf相对路径
|
|
|
- *
|
|
|
+ *
|
|
|
* @param userName
|
|
|
* 不为null;当前账套名称
|
|
|
* @param profile
|
|
|
@@ -227,7 +227,7 @@ public class PrintController {
|
|
|
|
|
|
/**
|
|
|
* 获取pdf数据(该接口暂时供手机端访问)
|
|
|
- *
|
|
|
+ *
|
|
|
* @param userName
|
|
|
* 不为null;当前账套名称
|
|
|
* @param profile
|
|
|
@@ -269,8 +269,9 @@ public class PrintController {
|
|
|
|
|
|
/**
|
|
|
* 获取该模板在当前条件下的结果数目
|
|
|
- *
|
|
|
- * @param userName不为null;当前账套用户名
|
|
|
+ *
|
|
|
+ * @param userName
|
|
|
+ * 不为null;当前账套用户名
|
|
|
* @param profile
|
|
|
* 用于标识请求源(B2C、B2B)是正式、测试还是开发版本:prod、test、dev
|
|
|
* @param reportName
|
|
|
@@ -296,4 +297,17 @@ public class PrintController {
|
|
|
ReportUtils.checkParameters(userName, reportName);
|
|
|
return printService.getCount(userName, profile, reportName, whereCondition, otherParameters);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 是否使用 xlsx
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/isUseXlsx")
|
|
|
+ @ResponseBody
|
|
|
+ public boolean isUseXlsx(HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ return systemProperties.isUseXlsx();
|
|
|
+ }
|
|
|
}
|