|
|
@@ -116,4 +116,69 @@ public class PdfController {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param u
|
|
|
+ * 当前账套名称,不可为空
|
|
|
+ * @param pr
|
|
|
+ * 用于标识请求源(B2C、B2B)是正式、测试还是开发版本:prod、test、dev,可选(UAS等系统不必传递该参数)
|
|
|
+ * @param r
|
|
|
+ * 需要导出的报表的名称,不带任何后缀(如导出采购单,即为"Purchase"),不可为空
|
|
|
+ * @param w
|
|
|
+ * where之后的条件(包括where),可为空
|
|
|
+ * @param o
|
|
|
+ * 其他参数,区别于w,报表某些字段的值取决于这些参数, JSON格式,数据为键值对,若模板已指定需要的参数,则不可为空
|
|
|
+ * @param pf
|
|
|
+ * 请求来自的平台,不可为空
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @return JSON格式
|
|
|
+ *
|
|
|
+ * <table border=1 cellpadding=5 cellspacing=0 summary= "result">
|
|
|
+ * <tr>
|
|
|
+ * <th>key</th>
|
|
|
+ * <th>description</th>
|
|
|
+ * </tr>
|
|
|
+ * <tr>
|
|
|
+ * <td>data</td>
|
|
|
+ * <td>pdf的字节数据</td>
|
|
|
+ * </tr>
|
|
|
+ * <tr>
|
|
|
+ * <td>pageSize</td>
|
|
|
+ * <td>pdf页数</td>
|
|
|
+ * </tr>
|
|
|
+ * <tr>
|
|
|
+ * <td>overload</td>
|
|
|
+ * <td>数据量是否过大</td>
|
|
|
+ * </tr>
|
|
|
+ * </table>
|
|
|
+ * @throws JRException
|
|
|
+ * @throws IOException
|
|
|
+ * @throws DocumentException
|
|
|
+ * @throws SQLException
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/data")
|
|
|
+ @ResponseBody
|
|
|
+ public Map<String, Object> getData(@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, pr, r, w, o, Platform.checkPlatform(pf))) {
|
|
|
+ result.put("data", "");
|
|
|
+ result.put("pageSize", 0);
|
|
|
+ result.put("overload", true);
|
|
|
+ } else {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ result.put("overload", false);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
}
|