Browse Source

there is no need to visit preprint before print

sunyj 7 years ago
parent
commit
2c4240cb51

+ 7 - 7
report/src/main/java/com/uas/report/controller/PrintController.java

@@ -80,9 +80,9 @@ public class PrintController {
      * @throws JRException
      * @throws ServletException
      */
-    @RequestMapping(value = "/pre")
+    @RequestMapping(value = "")
     @ResponseBody
-    public String preprint(String userName, String profile, String reportName, String whereCondition, String otherParameters,
+    public void preprint(String userName, String profile, String reportName, String whereCondition, String otherParameters,
                            String printType, String title, HttpServletRequest request, HttpServletResponse response)
             throws JRException, IOException, DocumentException, SQLException, ServletException {
         userName = userName == null ? null : userName.toUpperCase();
@@ -90,7 +90,7 @@ public class PrintController {
         PrintType type = StringUtils.isEmpty(printType) ? PrintType.PREVIEW : PrintType.checkType(printType);
         String requestId = UUID.randomUUID().toString().replace("-", "");
         printParameters.put(requestId, new PrintParameter(userName, profile, reportName, whereCondition, otherParameters, type, title));
-        return requestId;
+        response.sendRedirect("print/routing?id=" +requestId);
     }
 
     /**
@@ -121,14 +121,14 @@ public class PrintController {
 	 * @throws JRException
      * @throws ServletException
 	 */
-	@RequestMapping(method = RequestMethod.GET)
-	public void print(@RequestParam String id, HttpServletRequest request, HttpServletResponse response)
+	@RequestMapping(value = "/routing", method = RequestMethod.GET)
+	public void routing(@RequestParam String id, HttpServletRequest request, HttpServletResponse response)
 			throws JRException, IOException, DocumentException, SQLException, ServletException {
         switch (getPrintParameter(id, request, response).getPrintType()) {
 		// 预览或打印
 		case PREVIEW:
 		case PRINT:
-            request.getRequestDispatcher("preview").forward(request, response);
+            response.sendRedirect("../preview?id=" + id);
 			break;
 		case PDF:
 			export(id, ExportType.PDF.name(), true, request, response);
@@ -163,7 +163,7 @@ public class PrintController {
      * @throws IOException
      * @throws JRException
      */
-    @RequestMapping(value = "/export", method = RequestMethod.GET)
+    @RequestMapping(value = "/export")
     @ResponseBody
     public void export(@RequestParam String id, String exportFileType, Boolean flush, HttpServletRequest request,
 			HttpServletResponse response) throws JRException, IOException, DocumentException, SQLException {

+ 18 - 1
report/src/main/java/com/uas/report/model/PrintParameter.java

@@ -1,12 +1,16 @@
 package com.uas.report.model;
 
+import java.io.Serializable;
+
 /**
  * 打印参数
  *
  * @author sunyj
  * @since 2018/1/23 14:13
  */
-public class PrintParameter {
+public class PrintParameter implements Serializable {
+
+    private static final long serialVersionUID = 1L;
 
     /**
      * 当前账套名称
@@ -80,4 +84,17 @@ public class PrintParameter {
     public String getTitle() {
         return title;
     }
+
+    @Override
+    public String toString() {
+        return "PrintParameter{" +
+                "userName='" + userName + '\'' +
+                ", profile='" + profile + '\'' +
+                ", reportName='" + reportName + '\'' +
+                ", whereCondition='" + whereCondition + '\'' +
+                ", otherParameters='" + otherParameters + '\'' +
+                ", printType=" + printType +
+                ", title='" + title + '\'' +
+                '}';
+    }
 }

+ 6 - 6
report/src/main/webapp/WEB-INF/views/console.html

@@ -12,21 +12,21 @@
 			<ol>
 				<strong><li class="title1">预览</li></strong>
 				<ol>
-					<li><a target="_blank">print/pre?userName=UAS&reportName=PURCLIST&whereCondition=where rownum<30</a></li>
+					<li><a target="_blank">print?userName=UAS&reportName=PURCLIST&whereCondition=where rownum<30</a></li>
                     <li><a target="_blank">print?id=81a7854cd907438f98968a3e2d0024d6</a></li>
 					<li><a target="_blank">preview?id=81a7854cd907438f98968a3e2d0024d6</a></li>
 				</ol>
 
 				<strong><li class="title1">打印</li></strong>
 				<ol>
-					<li><a target="_blank">print/pre?userName=UAS_TEST&reportName=AccountRegZW_fybx&whereCondition=where rownum<13&printType=PRINT</a></li>
+					<li><a target="_blank">print?userName=UAS_TEST&reportName=AccountRegZW_fybx&whereCondition=where rownum<13&printType=PRINT</a></li>
 				</ol>
 
 
 				<strong><li class="title1">导出</li></strong>
 				<ol>
-					<li><a target="_blank">print/pre?userName=UAS&reportName=Purchase&whereCondition=where rownum<14&printType=PDF</a></li>
-					<li><a target="_blank">print/pre?userName=UAS&reportName=Purchase&whereCondition=where rownum<15&printType=EXCEL</a></li>
+					<li><a target="_blank">print?userName=UAS&reportName=Purchase&whereCondition=where rownum<14&printType=PDF</a></li>
+					<li><a target="_blank">print?userName=UAS&reportName=Purchase&whereCondition=where rownum<15&printType=EXCEL</a></li>
 				</ol>
 			</ol>
 
@@ -89,12 +89,12 @@
 				</ol>
 				<strong><li class="title2">B2C</li></strong>
 				<ol>
-					<li><a target="_blank">print/pre?userName=B2C&profile=test&reportName=order&whereCondition=where rownum<30</a></li>
+					<li><a target="_blank">print?userName=B2C&profile=test&reportName=order&whereCondition=where rownum<30</a></li>
 					<li><a target="_blank">fileUpload?userName=B2C</a></li>
 				</ol>
 				<strong><li class="title2">B2B</li></strong>
 				<ol>
-					<li><a target="_blank">print/pre?userName=B2B/10005740&profile=test&reportName=PURCLIST&whereCondition=where rownum<30</a></li>
+					<li><a target="_blank">print?userName=B2B/10005740&profile=test&reportName=PURCLIST&whereCondition=where rownum<30</a></li>
 					<li><a target="_blank">fileUpload?userName=B2B/1111</a></li>
 				</ol>
 			</ol>