自动化立体仓库 - WMS系统
#
luxiaotao1123
2020-06-16 4ea00a26f7773e0ad27aeee512f34ff45fe0f18b
src/main/java/com/zy/asrs/controller/MatCodeController.java
@@ -13,7 +13,11 @@
import com.core.common.DateUtils;
import com.core.common.R;
import com.zy.asrs.entity.MatCode;
import com.zy.asrs.entity.MatCodePrint;
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;
@@ -21,7 +25,9 @@
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.*;
@@ -139,6 +145,50 @@
        return R.ok();
    }
    // 打印
    @RequestMapping(value = "/macCode/print/auth")
    @ManagerAuth(memo = "物料编码打印")
    public R matCodePrint(@RequestParam(value = "param[]") String[] param) {
        if(Cools.isEmpty(param)) {
            return R.parse(CodeRes.EMPTY);
        }
        List<MatCodePrint> res = new ArrayList<>();
        for (String matNo : param){
            MatCode matCode = matCodeService.selectById(matNo);
            // 打印数据注入
            MatCodePrint print = new MatCodePrint();
            print.setMatNo(matCode.getMatNo());
            print.setBarcode(matCode.getBarcode());
            print.setMatName(matCode.getMatName());
            print.setStr1(matCode.getStr1());
            print.setStr2(matCode.getStr2());
            res.add(print);
        }
        return R.ok().add(res);
    }
    @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");
        }
        response.getOutputStream().flush();
        response.getOutputStream().close();
        return R.ok();
    }
    @RequestMapping(value = "/matCodeQuery/auth")
    @ManagerAuth
    public R query(String condition) {