| | |
| | | import com.core.common.R; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import zy.cloud.wms.common.CodeRes; |
| | | import zy.cloud.wms.common.config.AdminInterceptor; |
| | | import zy.cloud.wms.common.utils.BarcodeUtils; |
| | | import zy.cloud.wms.common.utils.QrCode; |
| | | import zy.cloud.wms.common.web.BaseController; |
| | | import zy.cloud.wms.manager.entity.Mat; |
| | | import zy.cloud.wms.manager.entity.MatPrint; |
| | | import zy.cloud.wms.manager.service.MatService; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/mac/code/auth") |
| | | // @ManagerAuth(memo = "物料编码条形码获取(type:1(条形码);2(二维码)") |
| | | public R matCodeBarcode(@RequestParam(defaultValue = "1") Integer type |
| | | , @RequestParam String param |
| | | , HttpServletResponse response) throws Exception { |
| | | AdminInterceptor.cors(response); |
| | | if (Cools.isEmpty(param)){ |
| | | return R.parse(BaseRes.EMPTY); |
| | | } |
| | | BufferedImage img; |
| | | if (type == 1) { |
| | | img = BarcodeUtils.encode(param); |
| | | } else { |
| | | img = QrCode.createImg(param); |
| | | } |
| | | 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 = "/mat/print/auth") |
| | | @ManagerAuth(memo = "物料编码打印") |
| | | public R matCodePrint(@RequestParam(value = "param[]") String[] param) { |
| | | if(Cools.isEmpty(param)) { |
| | | return R.parse(CodeRes.EMPTY); |
| | | } |
| | | List<MatPrint> res = new ArrayList<>(); |
| | | for (String matnr : param){ |
| | | Mat mat = matService.selectByMatnr(matnr); |
| | | // 打印数据注入 |
| | | MatPrint print = new MatPrint(); |
| | | print.setMatnr(mat.getMatnr()); |
| | | print.setBarcode(mat.getBarcode()); |
| | | print.setMaktx(mat.getMaktx()); |
| | | print.setSpecs(mat.getSpecs()); |
| | | print.setUnit(mat.getUnit()); |
| | | res.add(print); |
| | | } |
| | | return R.ok().add(res); |
| | | } |
| | | |
| | | } |