自动化立体仓库 - WMS系统
#1
dubin
2025-12-20 db11805d2209fd37b24037fce159c7d5a39d8177
src/main/java/com/zy/asrs/controller/MatController.java
@@ -13,9 +13,7 @@
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.EmptyPlateOutParam;
import com.zy.asrs.entity.result.KeyValueVo;
import com.zy.asrs.service.InOutService;
import com.zy.asrs.service.MatBarcodeService;
import com.zy.asrs.service.MatService;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.MatExcelListener;
import com.zy.common.CodeRes;
import com.zy.common.config.AdminInterceptor;
@@ -46,6 +44,12 @@
    private InOutService inOutService;
    @Autowired
    private MatBarcodeService matBarcodeService;
    @Autowired
    private WaitPakinService waitPakinService;
    @Autowired
    private LocDetlService locDetlService;
    @Autowired
    private WrkDetlService wrkDetlService;
    @RequestMapping(value = "/mat/auto/matnr/auth")
    public R autoMatnr(){
@@ -153,6 +157,9 @@
        if (Cools.isEmpty(mat) || null==mat.getId()){
            return R.error();
        }
        if (null != matService.selectByMatnr(mat.getMatnr())) {
            return R.error("商品模具名称已存在");
        }
        if (mat.getColor().equals("正常")){
            mat.setColor("报废");
        }else if (mat.getColor().equals("报废")){
@@ -171,15 +178,21 @@
    }
    /*物料托盘绑定*/
//    @RequestMapping(value = "/mat/barcode/auth")
//    @ManagerAuth
//    public R addBarcodeMatnr(Mat mat) {
//        if (Cools.isEmpty(mat.getUnit())){
//            return R.error(BaseRes.PARAM);
//        }
//        matBarcodeService.addBarcodeMatnrTwo(mat);
//        return R.ok();
//    }
    @RequestMapping(value = "/mat/barcode/auth")
    @ManagerAuth
    public R addBarcodeMatnr(Mat mat) {
        if (Cools.isEmpty(mat.getUnit())){
            return R.error(BaseRes.PARAM);
        }
        if (!mat.getUnit().startsWith("6")&&!mat.getUnit().startsWith("7")&&!mat.getUnit().startsWith("8")){
            throw new CoolException("托盘码首位不符合规范");
        }
        if (mat.getUnit().length()!= 8){
            throw new CoolException("托盘码不是八位,请检查");
        }
        matBarcodeService.addBarcodeMatnrTwo(mat);
        return R.ok();
    }
    @RequestMapping(value = "/mat/delete/auth")
    @ManagerAuth
@@ -189,9 +202,18 @@
            return R.error();
        }
        for (Mat entity : list){
            if (!matService.delete(new EntityWrapper<>(entity))) {
                throw new CoolException("删除失败,请联系管理员");
            Integer locCount = locDetlService.selectCountByMatNr(entity.getMatnr());
            Integer waitCount = waitPakinService.selectCountByMatNr(entity.getMatnr());
            Integer wrkCount = wrkDetlService.selectCountByMatNr(entity.getMatnr());
            InOut inOut = inOutService.selectByMatnr(entity.getMatnr());
            if (locCount > 0 || waitCount > 0 || wrkCount >0){
                throw new CoolException(entity.getMatnr() + "模具库存/组托/工作档数据已存在,不能删除");
            }else {
                if (!matService.delete(new EntityWrapper<>(entity)) && !inOutService.delete(new EntityWrapper<>(inOut))) {
                    throw new CoolException("删除商品档案/商品信息失败,请联系管理员");
                }
            }
        }
        return R.ok();
    }