|
@@ -4,9 +4,11 @@ import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.lang.Snowflake;
|
|
|
+import cn.hutool.core.net.NetUtil;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.extra.servlet.ServletUtil;
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.jd.printserver.common.controller.BaseController;
|
|
|
import com.jd.printserver.common.domain.AjaxResult;
|
|
@@ -26,6 +28,7 @@ import javax.print.attribute.standard.PrinterIsAcceptingJobs;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
+import java.nio.file.Path;
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
@@ -504,4 +507,38 @@ public class PrintServerController extends BaseController {
|
|
|
return success();
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping(value = "/printReportTable")
|
|
|
+ @CrossOrigin
|
|
|
+ public AjaxResult printReportTable(HttpServletRequest request,String httpUrl) {
|
|
|
+ if (StringUtils.isEmpty(httpUrl)) {
|
|
|
+ log.info("接口参数httpUrl缺失");
|
|
|
+ return error("参数缺失");
|
|
|
+ }
|
|
|
+ boolean flag = SeleniumUtils.getResultDataByUrl(httpUrl);
|
|
|
+ if(flag){
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+ return error();
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/printPdf")
|
|
|
+ @CrossOrigin
|
|
|
+ public AjaxResult printPdf(HttpServletRequest request,String pdfUrl, PrintParam printConfig) {
|
|
|
+ log.info("--------------------------本地打印开始");
|
|
|
+ if (StringUtils.isEmpty(pdfUrl)) {
|
|
|
+ log.info("接口参数pdfUrl缺失");
|
|
|
+ return error("参数缺失");
|
|
|
+ }
|
|
|
+ File tempFile = FileUtil.file("tempDir/printPdf"); // 临时文件存储目录
|
|
|
+
|
|
|
+ HttpUtil.downloadFile(pdfUrl, tempFile);
|
|
|
+
|
|
|
+ Boolean printFlag = PrintUtils.PDFprint(tempFile.getPath(), printConfig);
|
|
|
+ log.info("打印返回结果:{}", printFlag);
|
|
|
+ log.info("--------------------------结束本地打印");
|
|
|
+ if(!printFlag){
|
|
|
+ return error("打印失败");
|
|
|
+ }
|
|
|
+ return success();
|
|
|
+ }
|
|
|
}
|