|
|
@@ -12,11 +12,12 @@ import com.uas.report.util.ReportUtils;
|
|
|
import com.uas.report.util.StringUtils;
|
|
|
import net.sf.jasperreports.engine.JRException;
|
|
|
import org.dom4j.DocumentException;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
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.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import javax.servlet.ServletException;
|
|
|
@@ -44,6 +45,8 @@ import java.util.concurrent.ConcurrentMap;
|
|
|
@RequestMapping("/print")
|
|
|
public class PrintController {
|
|
|
|
|
|
+ private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
+
|
|
|
@Autowired
|
|
|
private SystemProperties systemProperties;
|
|
|
|
|
|
@@ -100,6 +103,7 @@ public class PrintController {
|
|
|
// printType为空,默认进入预览页
|
|
|
PrintType type = StringUtils.isEmpty(printType) ? PrintType.PREVIEW : PrintType.checkType(printType);
|
|
|
String requestId = UUID.randomUUID().toString().replace("-", "");
|
|
|
+ logger.info("generated id... " + requestId);
|
|
|
printParameters.put(requestId, new PrintParameter(userName, profile, reportName, whereCondition, otherParameters, type, title));
|
|
|
response.sendRedirect("print/routing?id=" + requestId);
|
|
|
}
|
|
|
@@ -111,6 +115,7 @@ public class PrintController {
|
|
|
* @return 缓存的打印参数
|
|
|
*/
|
|
|
private PrintParameter getPrintParameter(String id) {
|
|
|
+ Assert.hasText(id, "Required String parameter 'id' is not present");
|
|
|
PrintParameter printParameter = printParameters.get(id);
|
|
|
Assert.notNull(printParameter, "id 不存在");
|
|
|
return printParameter;
|
|
|
@@ -129,7 +134,7 @@ public class PrintController {
|
|
|
* @throws ServletException
|
|
|
*/
|
|
|
@RequestMapping(value = "/routing", method = RequestMethod.GET)
|
|
|
- public void routing(@RequestParam String id, HttpServletRequest request, HttpServletResponse response)
|
|
|
+ public void routing(String id, HttpServletRequest request, HttpServletResponse response)
|
|
|
throws JRException, IOException, DocumentException, SQLException, ServletException {
|
|
|
PrintParameter printParameter = getPrintParameter(id);
|
|
|
switch (printParameter.getPrintType()) {
|
|
|
@@ -178,7 +183,7 @@ public class PrintController {
|
|
|
*/
|
|
|
@RequestMapping(value = "/export")
|
|
|
@ResponseBody
|
|
|
- public void export(@RequestParam String id, String exportFileType, Boolean flush, HttpServletRequest request,
|
|
|
+ public void export(String id, String exportFileType, Boolean flush, HttpServletRequest request,
|
|
|
HttpServletResponse response) throws JRException, IOException, DocumentException, SQLException {
|
|
|
// TODO show download process
|
|
|
PrintParameter printParameter = getPrintParameter(id);
|
|
|
@@ -227,7 +232,7 @@ public class PrintController {
|
|
|
*/
|
|
|
@RequestMapping(value = "/pdfPath")
|
|
|
@ResponseBody
|
|
|
- public String getPdfPath(@RequestParam String id, Boolean flush, HttpServletRequest request, HttpServletResponse response) throws JRException, IOException, DocumentException, SQLException {
|
|
|
+ public String getPdfPath(String id, Boolean flush, HttpServletRequest request, HttpServletResponse response) throws JRException, IOException, DocumentException, SQLException {
|
|
|
PrintParameter printParameter = getPrintParameter(id);
|
|
|
String userName = printParameter.getUserName();
|
|
|
String profile = printParameter.getProfile();
|