自动化立体仓库 - WMS系统
#
zhou zhou
4 天以前 e0b041aca4e2ed0e0881e596c6cd1ec3dc63ddba
src/main/java/com/zy/asrs/task/handler/WorkMastHandler.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.service.*;
import com.zy.asrs.task.AbstractHandler;
@@ -35,6 +36,12 @@
    private WaitPakinService waitPakinService;
    @Autowired
    private OrderDetlService orderDetlService;
    @Autowired
    private InOutService inOutService;
    @Autowired
    private MatService matService;
    @Autowired
    private HalfBarcodeService halfBarcodeService;
    public ReturnT<String> start(WrkMast wrkMast) {
        // 4.入库完成
@@ -62,8 +69,18 @@
                case 10:
                    // 修改库位状态=D
                    if (locMast.getLocSts().equals("S") || locMast.getLocSts().equals("Q")) {
                        if (!Cools.isEmpty(wrkMast.getBarcode())) {
                            locMast.setBarcode(wrkMast.getBarcode());
                        if (Cools.isEmpty(wrkMast.getBarcode())) {
                            throw new CoolException("空板入库条码不能为空");
                        }
                        locMast.setBarcode(wrkMast.getBarcode());
                        if (Integer.parseInt(wrkMast.getBarcode().substring(0,1))==5){
                            locMast.setLocType2((short)5);
                        }else if (Integer.parseInt(wrkMast.getBarcode().substring(0,1))==6){
                            locMast.setLocType2((short)6);
                        }else if(Integer.parseInt(wrkMast.getBarcode().substring(0,1))==7){
                            locMast.setLocType2((short)7);
                        }else if(Integer.parseInt(wrkMast.getBarcode().substring(0,1))==8){
                            locMast.setLocType2((short)8);
                        }
                        locMast.setLocSts("D");
                        locMast.setIoTime(now);
@@ -107,6 +124,61 @@
                            locDetl.setZpallet(wrkDetl.getZpallet()); // 托盘条码
                            locDetl.setModiTime(now);
                            locDetl.setAppeTime(now);
                            locDetl.setModel(wrkDetl.getModel());
                            InOut inOut=inOutService.selectByMatnr(wrkDetl.getMatnr());
                            Mat mat = matService.selectByMatnr(wrkDetl.getMatnr());
                            if (inOut != null){
                                inOut.setTemp1("在库");//属性 是否在库
                                inOut.setBrand(wrkDetl.getZpallet());//托盘条码
                                inOut.setTemp2(mat.getName());//套号
                                inOut.setTemp3(wrkMast.getLocNo());//库位号
//                                inOut.setModiTime(now.toString());
                            }
                            if (!inOutService.updateById(inOut)){
                                return FAIL.setMsg("更新模具属性失败");
                            }
                            //更新半托信息
                            HalfBarcode halfBarcode = halfBarcodeService.selectByZpallet(wrkDetl.getZpallet());
                            //对模具的规格做处理得到厚度
                            Integer thickness = 0;
                            if (!Cools.isEmpty(wrkDetl.getSpecs())){
                                String[] split = wrkDetl.getSpecs().split("\\*");
                                thickness = Integer.parseInt(split[1]);
                            }
                            if (halfBarcode == null){
                                HalfBarcode hb = new HalfBarcode();
                                hb.setZpallet(wrkDetl.getZpallet());
                                hb.setSpecs(wrkDetl.getZpallet().substring(0,1));
                                hb.setAnfme(1);
                                if (Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==6){
                                    hb.setPrice(2650 - thickness);
                                }else if(Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==7){
                                    hb.setPrice(1750 - thickness);
                                }else if(Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==8){
                                    hb.setPrice(800 - thickness);
                                }
                                if (!halfBarcodeService.insert(hb)){
                                    throw new CoolException("更新半托信息失败");
                                }
                            }else {
                                if (Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==6){
                                    halfBarcode.setAnfme(halfBarcode.getAnfme() + 1);
                                    halfBarcode.setPrice(halfBarcode.getPrice() - thickness);
                                }else if(Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==7){
                                    halfBarcode.setAnfme(halfBarcode.getAnfme() + 1);
                                    halfBarcode.setPrice(halfBarcode.getPrice() - thickness);
                                }else if(Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==8){
                                    halfBarcode.setAnfme(halfBarcode.getAnfme() + 1);
                                    halfBarcode.setPrice(halfBarcode.getPrice() - thickness);
                                }
                                if (!halfBarcodeService.half(halfBarcode)){
                                    throw new CoolException("更新半托信息失败");
                                }
                            }
                            if (!locDetlService.insert(locDetl)) {
//                                exceptionHandle("全板入库 ===>> 添加库存明细失败;[workNo={0}],[locNo={1}]", wrkMast.getWrkNo(), wrkMast.getLocNo());
                                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -157,6 +229,32 @@
                        LocDetl locDetl = locDetlService.selectItem(locMast.getLocNo(), wrkDetl);
                        if (locDetl != null) {
                            InOut inOut=inOutService.selectByMatnr(wrkDetl.getMatnr());
                            if (inOut != null){
                                inOut.setTemp1("不在库");//属性 是否在库
                                inOut.setBrand("");//托盘条码
                                inOut.setTemp3("");
//                                inOut.setModiTime(now.toString());
                            }
                            if (!inOutService.updateById(inOut)){
                                return FAIL.setMsg("更新模具属性失败");
                            }
                            // 对模具的规格做处理得到厚度
                            Integer thickness = 0;
                            if (wrkDetl.getSpecs() != null){
                                String[] split = wrkDetl.getSpecs().split("\\*");
                                thickness = Integer.parseInt(split[1]);
                            }
                            // 根据托盘码找到半托信息
                            HalfBarcode halfBarcode = halfBarcodeService.selectByZpallet(wrkDetl.getZpallet());
                            if (halfBarcode != null){
                                halfBarcode.setPrice(thickness + halfBarcode.getPrice()); // 可放厚度
                                halfBarcode.setAnfme(halfBarcode.getAnfme() - 1); // 数量
                            }
                            if (!locDetlService.updateAnfme(locDetl.getAnfme() - wrkDetl.getAnfme(), locMast.getLocNo(), wrkDetl)) {
//                                exceptionHandle("拣料入库 ===>> 修改库存明细数量失败;[workNo={0}],[locNo={1}]", wrkMast.getWrkNo(), wrkMast.getLocNo());
                                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -200,34 +298,88 @@
                    List<WrkDetl> wrkDetls54 = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkMast.getWrkNo()));
                    if (wrkDetls54.isEmpty()) {
//                        exceptionHandle("并板入库 ===>> 工作明细档为空;[workNo={0}]", wrkMast.getWrkNo());
                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                        return FAIL.setMsg("并板入库 ===>> 工作明细档为空; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
                    }
                    // 修改库存明细数量,如无库存,曾新增
                    for (WrkDetl wrkDetl : wrkDetls54) {
//                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                        log.info("并板入库 ===>> 工作明细档为空; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
//                        return FAIL.setMsg("并板入库 ===>> 工作明细档为空; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
                    }else {
                        // 修改库存明细数量,如无库存,曾新增
                        for (WrkDetl wrkDetl : wrkDetls54) {
                        LocDetl locDetl = locDetlService.selectItem(locMast.getLocNo(), wrkDetl);
                        if (null != locDetl) {
                            if (!locDetlService.updateAnfme(wrkDetl.getAnfme(), locMast.getLocNo(), wrkDetl)) {
                            LocDetl locDetl = locDetlService.selectItem(locMast.getLocNo(), wrkDetl);
                            if (null != locDetl) {
                                if (!locDetlService.updateAnfme(wrkDetl.getAnfme(), locMast.getLocNo(), wrkDetl)) {
//                                exceptionHandle("并板入库 ===>> 修改库存明细数量失败;[workNo={0}],[matnr={1}]", wrkMast.getWrkNo(), wrkDetl.getMatnr());
                                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                return FAIL.setMsg("并板入库 ===>> 修改库存明细数量失败; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
                            }
                        } else {
                            locDetl = new LocDetl();
                            locDetl.sync(wrkDetl);
                            locDetl.setLocNo(wrkMast.getLocNo()); // 库位号
                            locDetl.setAnfme(wrkDetl.getAnfme()); // 数量
                            locDetl.setZpallet(wrkDetl.getZpallet()); // 托盘条码
                            locDetl.setModiTime(now);
                            locDetl.setAppeTime(now);
                            if (!locDetlService.insert(locDetl)) {
                                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                    return FAIL.setMsg("并板入库 ===>> 修改库存明细数量失败; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
                                }
                            } else {
                                InOut inOut=inOutService.selectByMatnr(wrkDetl.getMatnr());
                                if (inOut != null){
                                    inOut.setTemp1("在库");//属性 是否在库
                                    inOut.setBrand(wrkDetl.getZpallet());//托盘条码
                                    inOut.setTemp3(wrkMast.getLocNo());//库位号
//                                inOut.setModiTime(now.toString());
                                }
                                if (!inOutService.updateById(inOut)){
                                    return FAIL.setMsg("更新模具属性失败");
                                }
                                //更新半托信息
                                HalfBarcode halfBarcode = halfBarcodeService.selectByZpallet(wrkDetl.getZpallet());
                                //对模具的规格做处理得到厚度
                                Integer thickness = 0;
                                if (!Cools.isEmpty(wrkDetl.getSpecs())){
                                    String[] split = wrkDetl.getSpecs().split("\\*");
                                    thickness = Integer.parseInt(split[1]);
                                }
                                if (halfBarcode == null){
                                    HalfBarcode hb = new HalfBarcode();
                                    hb.setZpallet(wrkDetl.getZpallet());
                                    hb.setSpecs(wrkDetl.getZpallet().substring(0,1));
                                    hb.setAnfme(1);
                                    if (Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==6){
                                        hb.setPrice(2650 - thickness);
                                    }else if(Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==7){
                                        hb.setPrice(1750 - thickness);
                                    }else if(Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==8){
                                        hb.setPrice(800 - thickness);
                                    }
                                    if (!halfBarcodeService.insert(hb)){
                                        throw new CoolException("更新半托信息失败");
                                    }
                                }else {
                                    if (Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==6){
                                        halfBarcode.setAnfme(halfBarcode.getAnfme() + 1);
                                        halfBarcode.setPrice(halfBarcode.getPrice() - thickness);
                                    }else if(Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==7){
                                        halfBarcode.setAnfme(halfBarcode.getAnfme() + 1);
                                        halfBarcode.setPrice(halfBarcode.getPrice() - thickness);
                                    }else if(Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==8){
                                        halfBarcode.setAnfme(halfBarcode.getAnfme() + 1);
                                        halfBarcode.setPrice(halfBarcode.getPrice() - thickness);
                                    }
                                    if (!halfBarcodeService.half(halfBarcode)){
                                        throw new CoolException("更新半托信息失败");
                                    }
                                }
                                locDetl = new LocDetl();
                                locDetl.sync(wrkDetl);
                                locDetl.setLocNo(wrkMast.getLocNo()); // 库位号
                                locDetl.setAnfme(wrkDetl.getAnfme()); // 数量
                                locDetl.setZpallet(wrkDetl.getZpallet()); // 托盘条码
                                locDetl.setModiTime(now);
                                locDetl.setAppeTime(now);
                                if (!locDetlService.insert(locDetl)) {
//                                exceptionHandle("并板入库 ===>> 新增库存明细失败;[workNo={0}],[matnr={1}]", wrkMast.getWrkNo(), wrkDetl.getMatnr());
                                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                return FAIL.setMsg("并板入库 ===>> 新增库存明细失败; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
                                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                    return FAIL.setMsg("并板入库 ===>> 新增库存明细失败; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
                                }
                            }
                        }
                    }
                    // 修改库位状态 Q ====>> F
                    if (locMast.getLocSts().equals("Q")) {
                        locMast.setLocSts("F");
@@ -345,6 +497,35 @@
                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                        return FAIL.setMsg("全板出库 ===>> 工作明细档为空; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getSourceLocNo() + "]");
                    }
                    for (WrkDetl wrkDetl : wrkDetls101) {
                        InOut inOut=inOutService.selectByMatnr(wrkDetl.getMatnr());
                        // 对模具的规格做处理得到厚度
                        Integer thickness = 0;
                        if (wrkDetl.getSpecs() != null){
                            String[] split = wrkDetl.getSpecs().split("\\*");
                            thickness = Integer.parseInt(split[1]);
                        }
                        // 根据托盘码找到半托信息
                        HalfBarcode halfBarcode = halfBarcodeService.selectByZpallet(wrkDetl.getZpallet());
                        if (halfBarcode != null){
                            halfBarcode.setPrice(thickness + halfBarcode.getPrice()); // 可放厚度
                            halfBarcode.setAnfme(halfBarcode.getAnfme() - 1); // 数量
                        }
                        if (inOut != null){
                            inOut.setTemp1("不在库");//属性 是否在库
                            inOut.setBrand("");//托盘条码
                            inOut.setTemp3("");//库位号
//                            inOut.setModiTime(now.toString());
                        }
                        if (!inOutService.updateById(inOut)){
                            return FAIL.setMsg("更新模具属性失败");
                        }
                        if (!halfBarcodeService.half(halfBarcode)){
                            return FAIL.setMsg("更新半托信息失败");
                        }
                    }
                    for (WrkDetl wrkDetl : wrkDetls101) {
                        // 更新订单完成数量
                        OrderDetl orderDetl = orderDetlService.selectItem(wrkDetl);
@@ -370,7 +551,7 @@
                    // 修改源库位状态 R ===>> O
                    if (locMast.getLocSts().equals("R")) {
                        locMast.setLocSts("O");
                        locMast.setBarcode("");
                        locMast.setBarcode("");//托盘与库位绑定
                        locMast.setModiTime(now);
                        locMast.setIoTime(now);
                        if (!locMastService.updateById(locMast)) {
@@ -385,7 +566,8 @@
                    // 修改库位状态 R ===>> O
                    if (locMast.getLocSts().equals("R")) {
                        locMast.setLocSts("O");
                        locMast.setBarcode("");
                        locMast.setBarcode("");//托盘与库位绑定
                        locMast.setLocType2((short)0);
                        locMast.setModiTime(now);
                        locMast.setIoTime(now);
                        if (!locMastService.updateById(locMast)) {