自动化立体仓库 - WMS系统
luxiaotao1123
2020-06-22 7c7e00d91e3cfd334ec4035e620b7cb6a153e91b
src/main/java/com/zy/asrs/controller/MatCodeController.java
@@ -17,6 +17,7 @@
import com.zy.asrs.service.MatCodeService;
import com.zy.common.CodeRes;
import com.zy.common.utils.BarcodeUtils;
import com.zy.common.utils.QrCode;
import com.zy.common.utils.excel.matcode.MatCodeExcel;
import com.zy.common.utils.excel.matcode.MatCodeExcelListener;
import com.zy.common.web.BaseController;
@@ -54,6 +55,9 @@
        EntityWrapper<MatCode> wrapper = new EntityWrapper<>();
        convert(param, wrapper);
        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
        else {
            wrapper.orderBy("modi_time", false);
        }
        return R.ok(matCodeService.selectPage(new Page<>(curr, limit), wrapper));
    }
@@ -64,7 +68,7 @@
            } else if (entry.getKey().endsWith("<")) {
                wrapper.le(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue())));
            } else {
                wrapper.eq(entry.getKey(), String.valueOf(entry.getValue()));
                wrapper.like(entry.getKey(), String.valueOf(entry.getValue()));
            }
        }
    }
@@ -119,7 +123,6 @@
            excel.setBarcode(matCode.getBarcode());
            excel.setMatName(matCode.getMatName());
            excel.setStr1(matCode.getStr1());
            excel.setStr2(matCode.getStr2());
            excels.add(excel);
            if (rowCount != null && excels.size() >= rowCount){
                break;
@@ -139,9 +142,9 @@
    @RequestMapping(value = "/matCode/import/auth")
    @ManagerAuth(memo = "物料编码数据导入")
    public R matCodeImport(MultipartFile file) throws IOException, InterruptedException {
        Thread.sleep(2000);
        EasyExcel.read(file.getInputStream(), MatCodeExcel.class, new MatCodeExcelListener()).sheet().doRead();
        return R.ok();
        MatCodeExcelListener listener = new MatCodeExcelListener(getUserId());
        EasyExcel.read(file.getInputStream(), MatCodeExcel.class, listener).sheet().doRead();
        return R.ok("成功导入"+listener.getTotal()+"条物料信息");
    }
    // 打印
@@ -157,7 +160,7 @@
            // 打印数据注入
            MatCodePrint print = new MatCodePrint();
            print.setMatNo(matCode.getMatNo());
            print.setBarcodeUrl(matCode.getBarcode());
            print.setBarcode(matCode.getBarcode());
            print.setMatName(matCode.getMatName());
            print.setStr1(matCode.getStr1());
            print.setStr2(matCode.getStr2());
@@ -166,11 +169,20 @@
        return R.ok().add(res);
    }
    // todo resource
    @RequestMapping(value = "/macCode/barcode/auth")
    @ManagerAuth(memo = "物料编码条形码获取")
    public R matCodeBarcode(@RequestParam String param, HttpServletResponse response) throws IOException {
        BufferedImage img = BarcodeUtils.encode(param);
    @RequestMapping(value = "/macCode/code/auth")
//    @ManagerAuth(memo = "物料编码条形码获取(type:1(条形码);2(二维码)")
    public R matCodeBarcode(@RequestParam(defaultValue = "1") Integer type
                        , @RequestParam String param
                        , HttpServletResponse response) throws Exception {
        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");
        }