|
|
@@ -13,6 +13,7 @@ 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.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import com.uas.report.service.FileService;
|
|
|
@@ -44,22 +45,22 @@ public class PdfController {
|
|
|
|
|
|
/**
|
|
|
* @param u
|
|
|
- * 不为null;当前账套名称
|
|
|
- * @param p
|
|
|
- * 可选(UAS等系统不必传递该参数),用于标识请求源(B2C、B2B)是正式、测试还是开发版本:prod、test、dev
|
|
|
+ * 当前账套名称,不可为空
|
|
|
+ * @param pr
|
|
|
+ * 用于标识请求源(B2C、B2B)是正式、测试还是开发版本:prod、test、dev,可选(UAS等系统不必传递该参数)
|
|
|
* @param r
|
|
|
- * 不为null;需要导出的报表的名称,不带任何后缀(如导出采购单,即为"Purchase")
|
|
|
+ * 需要导出的报表的名称,不带任何后缀(如导出采购单,即为"Purchase"),不可为空
|
|
|
* @param w
|
|
|
- * 可为null;where之后的条件(包括where)
|
|
|
+ * where之后的条件(包括where),可为空
|
|
|
* @param o
|
|
|
- * 若模板已指定需要的参数,则不可为null;其他参数,区别于whereCondition,报表某些字段的值取决于这些参数;
|
|
|
- * JSON格式,数据为键值对
|
|
|
+ * 其他参数,区别于w,报表某些字段的值取决于这些参数, JSON格式,数据为键值对,若模板已指定需要的参数,则不可为空
|
|
|
+ * @param pf
|
|
|
+ * 请求来自的平台,不可为空
|
|
|
* @param request
|
|
|
* @param response
|
|
|
* @return JSON格式
|
|
|
*
|
|
|
- * <table border=1 cellpadding=5 cellspacing=0 summary=
|
|
|
- * "result">
|
|
|
+ * <table border=1 cellpadding=5 cellspacing=0 summary= "result">
|
|
|
* <tr>
|
|
|
* <th>key</th>
|
|
|
* <th>description</th>
|
|
|
@@ -84,25 +85,28 @@ public class PdfController {
|
|
|
*/
|
|
|
@RequestMapping(value = "/path")
|
|
|
@ResponseBody
|
|
|
- public Map<String, Object> getPath(String u, String p, String r, String w, String o, HttpServletRequest request,
|
|
|
- HttpServletResponse response) throws JRException, IOException, DocumentException, SQLException {
|
|
|
+ public Map<String, Object> getPath(@RequestParam(required = true) String u, String pr,
|
|
|
+ @RequestParam(required = true) String r, String w, String o, @RequestParam(required = true) String pf,
|
|
|
+ HttpServletRequest request, HttpServletResponse response)
|
|
|
+ throws JRException, IOException, DocumentException, SQLException {
|
|
|
u = u == null ? null : u.toUpperCase();
|
|
|
ReportUtils.checkParameters(u, r);
|
|
|
+
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
// 判断是否过载
|
|
|
- if (printService.overload(u, p, r, w, o, Platform.PHONE)) {
|
|
|
+ if (printService.overload(u, pr, r, w, o, Platform.checkPlatform(pf))) {
|
|
|
result.put("path", "");
|
|
|
result.put("pageSize", 0);
|
|
|
result.put("overload", true);
|
|
|
} else {
|
|
|
- result = printService.preview(u, p, r, w, o, null);
|
|
|
+ result = printService.preview(u, pr, r, w, o, null);
|
|
|
if (CollectionUtils.isEmpty(result) || ArrayUtils.isEmpty((byte[]) result.get("data"))) {
|
|
|
throw new IllegalStateException("pdf生成失败:" + u + "/" + r);
|
|
|
}
|
|
|
byte[] data = (byte[]) result.remove("data");
|
|
|
// 相对路径
|
|
|
String pdfPath = ReportConstants.GENERATED_FILES_PATH + r + "/"
|
|
|
- + fileService.generateFileName(u, p, w, o, ReportConstants.FILE_TYPE_PDF) + "."
|
|
|
+ + fileService.generateFileName(u, pr, w, o, ReportConstants.FILE_TYPE_PDF) + "."
|
|
|
+ ReportConstants.FILE_TYPE_PDF;
|
|
|
File file = new File(ReportConstants.GENERATED_FILES_DIR + pdfPath);
|
|
|
FileUtils.write(file.getPath(), data);
|