|
|
@@ -1,61 +1,66 @@
|
|
|
package com.uas.platform.b2b.controller;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.http.HttpHeaders;
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
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 com.uas.platform.b2b.service.ReportConfigService;
|
|
|
-import com.uas.platform.core.util.Des;
|
|
|
+import com.uas.platform.b2b.support.SysConf;
|
|
|
|
|
|
/**
|
|
|
- * 报表请求
|
|
|
- *
|
|
|
- * @author suntg
|
|
|
- * @date 2015年3月9日19:58:22
|
|
|
+ * 打印相关接口
|
|
|
*
|
|
|
+ * @author sunyj
|
|
|
+ * @since 2016年11月4日 上午8:57:16
|
|
|
*/
|
|
|
@Controller
|
|
|
-@RequestMapping(value = "/reports")
|
|
|
+@RequestMapping(value = "/report")
|
|
|
public class ReportController {
|
|
|
|
|
|
@Autowired
|
|
|
- private ReportConfigService reportConfigService;
|
|
|
+ private SysConf sysConf;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 打印
|
|
|
+ *
|
|
|
+ * @param enuu
|
|
|
+ * 模板所属的企业的uu
|
|
|
+ * @param reportName
|
|
|
+ * 需要打印的报表的名称,不带任何后缀(如导出订单,即为"order")
|
|
|
+ * @param whereCondition
|
|
|
+ * where之后的条件(包括where)
|
|
|
+ * @param response
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/print")
|
|
|
+ public void print(@RequestParam(required = true) Long enuu, @RequestParam(required = true) String reportName,
|
|
|
+ @RequestParam(required = true) String whereCondition, HttpServletResponse response) {
|
|
|
+ try {
|
|
|
+ response.sendRedirect(
|
|
|
+ String.format(sysConf.getReportPrintUrl(), URLEncoder.encode("/" + enuu.toString(), "UTF-8"),
|
|
|
+ URLEncoder.encode(reportName, "UTF-8"), URLEncoder.encode(whereCondition, "UTF-8")));
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
- * 根据企业UU号和页面名称获取报表名称
|
|
|
+ * 模板文件上传路径
|
|
|
*
|
|
|
- * @return
|
|
|
+ * @param response
|
|
|
*/
|
|
|
- @RequestMapping(value = "/path", method = RequestMethod.GET)
|
|
|
- public ResponseEntity<String> getReportNameByEnuuAndPagename(Long enuu,
|
|
|
- String pagename) {
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.add("Content-Type", "application/text; charset=utf-8");
|
|
|
- String key = "12345678";
|
|
|
- String reportName = reportConfigService.getReportNameByEnuuAndPageName(
|
|
|
- enuu, pagename);
|
|
|
- if (reportName == null) {
|
|
|
- return new ResponseEntity<String>("未找到报表文件", headers,
|
|
|
- HttpStatus.EXPECTATION_FAILED);
|
|
|
- } else {
|
|
|
- Des de = new Des();
|
|
|
- // 文件名
|
|
|
- String name;
|
|
|
- try {
|
|
|
- name = URLEncoder.encode(reportName, "utf-8").toLowerCase();
|
|
|
- String a = de.toHexString(de.encrypt(name, key)).toUpperCase();
|
|
|
- reportName = a;
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ @RequestMapping(value = "/upload")
|
|
|
+ public void upload(@RequestParam(required = true) Long enuu, HttpServletResponse response) {
|
|
|
+ try {
|
|
|
+ response.sendRedirect(
|
|
|
+ String.format(sysConf.getReportUploadUrl(), URLEncoder.encode(enuu.toString(), "UTF-8")));
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- return new ResponseEntity<String>(reportName, headers, HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
}
|