| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | |
| | | import com.core.common.R; |
| | | import com.zy.asrs.entity.MatCode; |
| | | import com.zy.asrs.service.MatCodeService; |
| | | import com.zy.common.utils.BarcodeUtils; |
| | | import com.zy.common.utils.excel.matcode.MatCodeExcel; |
| | | import com.zy.common.utils.excel.matcode.MatCodeExcelListener; |
| | | import com.zy.common.web.BaseController; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | |
| | | response.setCharacterEncoding("utf-8"); |
| | | fileName = URLEncoder.encode(Cools.isEmpty(fileName)?"物料编码":fileName, "UTF-8"); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | EasyExcel.write(response.getOutputStream(), MatCodeExcel.class).sheet("表1").doWrite(excels); |
| | | EasyExcel.write(response.getOutputStream(), MatCodeExcel.class) |
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
| | | .sheet("表1") |
| | | .doWrite(excels); |
| | | } |
| | | |
| | | // 导入 |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | // todo resource |
| | | // 物料打印 |
| | | @RequestMapping(value = "/macCode/print/auth") |
| | | // @ManagerAuth(memo = "物料编码打印") |
| | | public R matCodePrint(HttpServletResponse response) throws IOException { |
| | | BufferedImage img = BarcodeUtils.encode("123456789"); |
| | | if (!ImageIO.write(img, "jpg", response.getOutputStream())) { |
| | | throw new IOException("Could not write an image of format jpg"); |
| | | } |
| | | response.getOutputStream().flush(); |
| | | response.getOutputStream().close(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/matCodeQuery/auth") |
| | | @ManagerAuth |
| | | public R query(String condition) { |