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 JRException
      * @throws ServletException
      * @throws ServletException
      */
      */
-    @RequestMapping(value = "/pre")
+    @RequestMapping(value = "")
     @ResponseBody
     @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)
                            String printType, String title, HttpServletRequest request, HttpServletResponse response)
             throws JRException, IOException, DocumentException, SQLException, ServletException {
             throws JRException, IOException, DocumentException, SQLException, ServletException {
         userName = userName == null ? null : userName.toUpperCase();
         userName = userName == null ? null : userName.toUpperCase();
@@ -90,7 +90,7 @@ public class PrintController {
         PrintType type = StringUtils.isEmpty(printType) ? PrintType.PREVIEW : PrintType.checkType(printType);
         PrintType type = StringUtils.isEmpty(printType) ? PrintType.PREVIEW : PrintType.checkType(printType);
         String requestId = UUID.randomUUID().toString().replace("-", "");
         String requestId = UUID.randomUUID().toString().replace("-", "");
         printParameters.put(requestId, new PrintParameter(userName, profile, reportName, whereCondition, otherParameters, type, title));
         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 JRException
      * @throws ServletException
      * @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 {
 			throws JRException, IOException, DocumentException, SQLException, ServletException {
         switch (getPrintParameter(id, request, response).getPrintType()) {
         switch (getPrintParameter(id, request, response).getPrintType()) {
 		// 预览或打印
 		// 预览或打印
 		case PREVIEW:
 		case PREVIEW:
 		case PRINT:
 		case PRINT:
-            request.getRequestDispatcher("preview").forward(request, response);
+            response.sendRedirect("../preview?id=" + id);
 			break;
 			break;
 		case PDF:
 		case PDF:
 			export(id, ExportType.PDF.name(), true, request, response);
 			export(id, ExportType.PDF.name(), true, request, response);
@@ -163,7 +163,7 @@ public class PrintController {
      * @throws IOException
      * @throws IOException
      * @throws JRException
      * @throws JRException
      */
      */
-    @RequestMapping(value = "/export", method = RequestMethod.GET)
+    @RequestMapping(value = "/export")
     @ResponseBody
     @ResponseBody
     public void export(@RequestParam String id, String exportFileType, Boolean flush, HttpServletRequest request,
     public void export(@RequestParam String id, String exportFileType, Boolean flush, HttpServletRequest request,
 			HttpServletResponse response) throws JRException, IOException, DocumentException, SQLException {
 			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;
 package com.uas.report.model;
 
 
+import java.io.Serializable;
+
 /**
 /**
  * 打印参数
  * 打印参数
  *
  *
  * @author sunyj
  * @author sunyj
  * @since 2018/1/23 14:13
  * @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() {
     public String getTitle() {
         return title;
         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>
 			<ol>
 				<strong><li class="title1">预览</li></strong>
 				<strong><li class="title1">预览</li></strong>
 				<ol>
 				<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">print?id=81a7854cd907438f98968a3e2d0024d6</a></li>
 					<li><a target="_blank">preview?id=81a7854cd907438f98968a3e2d0024d6</a></li>
 					<li><a target="_blank">preview?id=81a7854cd907438f98968a3e2d0024d6</a></li>
 				</ol>
 				</ol>
 
 
 				<strong><li class="title1">打印</li></strong>
 				<strong><li class="title1">打印</li></strong>
 				<ol>
 				<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>
 				</ol>
 
 
 
 
 				<strong><li class="title1">导出</li></strong>
 				<strong><li class="title1">导出</li></strong>
 				<ol>
 				<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>
 			</ol>
 			</ol>
 
 
@@ -89,12 +89,12 @@
 				</ol>
 				</ol>
 				<strong><li class="title2">B2C</li></strong>
 				<strong><li class="title2">B2C</li></strong>
 				<ol>
 				<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>
 					<li><a target="_blank">fileUpload?userName=B2C</a></li>
 				</ol>
 				</ol>
 				<strong><li class="title2">B2B</li></strong>
 				<strong><li class="title2">B2B</li></strong>
 				<ol>
 				<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>
 					<li><a target="_blank">fileUpload?userName=B2B/1111</a></li>
 				</ol>
 				</ol>
 			</ol>
 			</ol>