|
@@ -1,139 +1,35 @@
|
|
|
package com.tld.controller;
|
|
|
|
|
|
|
|
|
-//import com.google.zxing.client.j2se.MatrixToImageWriter;
|
|
|
-import cn.afterturn.easypoi.excel.annotation.Excel;
|
|
|
-import com.google.zxing.common.BitMatrix;
|
|
|
-//import com.tld.util.MyQRUtils;
|
|
|
-//import org.apache.commons.logging.Log;
|
|
|
-//import org.apache.commons.logging.LogFactory;
|
|
|
-import com.tld.excel.ExcelUtil;
|
|
|
-import com.tld.model.Print;
|
|
|
-import org.apache.poi.hpsf.Variant;
|
|
|
-import org.springframework.ui.Model;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import com.tld.model.TldPrint;
|
|
|
+import com.tld.service.WebPrintService;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-//
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.OutputStream;
|
|
|
-import java.nio.file.Path;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 打印二维码
|
|
|
*/
|
|
|
@RestController
|
|
|
-@RequestMapping("/Printer")
|
|
|
+@RequestMapping("/printer")
|
|
|
+@RequiredArgsConstructor
|
|
|
public class WebPrintController {
|
|
|
-// private static final Log logger = LogFactory.getLog(MyQRUtils.class);
|
|
|
|
|
|
-// /**
|
|
|
-// * 二维码预览页面
|
|
|
-// * @param model
|
|
|
-// * @return
|
|
|
-// */
|
|
|
-// @PostMapping("/showList")
|
|
|
-// public String showQRList(Model model){
|
|
|
-// //模拟获取数据库数据
|
|
|
-// List listData = new ArrayList();
|
|
|
-// StringBuffer ids = new StringBuffer();
|
|
|
-// String code = "print00";
|
|
|
-// for (int i = 0; i < 3; i++) {
|
|
|
-// Map<String,String> map = new HashMap<String,String>(); //模拟VO
|
|
|
-// map.put("id",code+""+i);
|
|
|
-// ids.append(code+""+i).append(",");
|
|
|
-// listData.add(map);
|
|
|
-// }
|
|
|
-// model.addAttribute("showListData", listData);
|
|
|
-// model.addAttribute("ids", ids);
|
|
|
-// return "showQR";
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 二维码打印页面
|
|
|
-// * 隐藏在iframe中
|
|
|
-// * @param model
|
|
|
-// * @return
|
|
|
-// */
|
|
|
-// @PostMapping("/printEWM")
|
|
|
-// public String printQRFrame(Model model, HttpServletRequest request){
|
|
|
-// String ids = request.getParameter("ids");
|
|
|
-// model.addAttribute("ids", ids);
|
|
|
-// return "printFrameQR";
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 显示二维码图片保存打印
|
|
|
-// * @param request
|
|
|
-// * @param response
|
|
|
-// * @throws Exception
|
|
|
-// */
|
|
|
-// @PostMapping("/showEWMImage")
|
|
|
-// public void showImageByType(HttpServletRequest request, HttpServletResponse response){
|
|
|
-// String id = request.getParameter("showID"); //ID
|
|
|
-//
|
|
|
-// //此处可从数据库中获取内容
|
|
|
-// String content ="打印二维码\n打印测试\nID:"+id;
|
|
|
-// //content 二维码中的信息
|
|
|
-//
|
|
|
-// OutputStream outStream = null;
|
|
|
-// try {
|
|
|
-// outStream = response.getOutputStream();
|
|
|
-// String format = "jpg";
|
|
|
-// String type = "png" ;
|
|
|
-// String bottomText = ""; //水印文字
|
|
|
-// //生成二维码前的配置信息
|
|
|
-// BitMatrix bitMatrix = MyQRUtils.setBitMatrix(content, 30 , 30);
|
|
|
-// //暂时不使用LOGO图片
|
|
|
-// //以流的形式展示
|
|
|
-// MyQRUtils.megerToFile(bitMatrix, format, outStream, null,bottomText);
|
|
|
-// //定义路径,用绝对路径
|
|
|
-// Path file = new File("D:/workspace/code.png").toPath();
|
|
|
-// System.out.println("---路径---"+file.toFile());
|
|
|
-// //生成路径并且保存文件
|
|
|
-// MatrixToImageWriter.writeToPath(bitMatrix,type,file);
|
|
|
-// //将图片二维码放入到excel中
|
|
|
-//
|
|
|
-// //开始打印
|
|
|
-// MyQRUtils.getPrint(file.toFile());
|
|
|
-//
|
|
|
-// } catch (Exception e) {
|
|
|
-// logger.error("二维码生成失败", e);
|
|
|
-// }finally{
|
|
|
-// try {
|
|
|
-// if(outStream!=null){
|
|
|
-// outStream.flush();
|
|
|
-// outStream.close();
|
|
|
-// }
|
|
|
-// } catch (IOException e) {
|
|
|
-// logger.error("关闭数据流失败", e);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
+ private final WebPrintService webPrintService;
|
|
|
|
|
|
/**
|
|
|
- 生成Excel文件
|
|
|
+ * 查询打印信息
|
|
|
+ * @param tldPrint 打印信息
|
|
|
+ * @param request 用户id
|
|
|
+ * @return 返回结果
|
|
|
*/
|
|
|
- @PostMapping("/showEWMImage")
|
|
|
- public String showImageByType(HttpServletRequest request, HttpServletResponse response){
|
|
|
- ArrayList<Print> print = new ArrayList<>();
|
|
|
- for (int i = 0; i < 10; i++) {
|
|
|
- Print print1 = new Print();
|
|
|
- print1.setId("1");
|
|
|
- print1.setEarTag("二维码");
|
|
|
- print.add(print1);
|
|
|
- }
|
|
|
- String fileName = "打印二维码" ;
|
|
|
- ExcelUtil.writeExcel(response,fileName,ExcelUtil.exportPicture(print));
|
|
|
- return "操作成功";
|
|
|
+ @GetMapping("getSerial")
|
|
|
+ public Map<String, Object> getSerial(TldPrint tldPrint, HttpServletRequest request){
|
|
|
+ return webPrintService.getSerial(tldPrint, request);
|
|
|
}
|
|
|
|
|
|
}
|