#
Junjie
2024-05-30 7ce4419c34a54a968d4e9fe0e4f1b1a7595e868d
zy-asrs-wms/src/main/java/com/zy/asrs/wms/task/handler/WorkMastHandler.java
@@ -1,10 +1,7 @@
package com.zy.asrs.wms.task.handler;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.common.wms.entity.LocDetl;
import com.zy.asrs.common.wms.entity.LocMast;
import com.zy.asrs.common.wms.entity.WrkDetl;
import com.zy.asrs.common.wms.entity.WrkMast;
import com.zy.asrs.common.wms.entity.*;
import com.zy.asrs.common.wms.service.*;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.wms.task.AbstractHandler;
@@ -36,6 +33,8 @@
    private LocDetlService locDetlService;
    @Autowired
    private WaitPakinService waitPakinService;
    @Autowired
    private OrderDetlService orderDetlService;
    public ReturnT<String> start(WrkMast wrkMast) {
        // 99.入库完成
@@ -68,6 +67,7 @@
                        locMast.setLocSts("D");
                        locMast.setIoTime(now);
                        locMast.setModiTime(now);
                        locMast.setPic(wrkMast.getPic());
                        if (!locMastService.updateById(locMast)) {
                            exceptionHandle("空板入库 ===>> 修改库位状态失败;[workNo={0}],[locNo={1}]", wrkMast.getWrkNo(), wrkMast.getLocNo());
                        }
@@ -130,6 +130,7 @@
                        locMast.setBarcode(wrkMast.getBarcode());
                        locMast.setIoTime(now);
                        locMast.setModiTime(now);
                        locMast.setPic(wrkMast.getPic());
                        if (!locMastService.updateById(locMast)) {
                            exceptionHandle("全板入库 ===>> 修改库位状态失败;[workNo={0}],[locNo={1}]", wrkMast.getWrkNo(), wrkMast.getLocNo());
                        }
@@ -157,6 +158,7 @@
                        locMast.setBarcode(wrkMast.getBarcode());
                        locMast.setIoTime(now);
                        locMast.setModiTime(now);
                        locMast.setPic(wrkMast.getPic());
                        if (!locMastService.updateById(locMast)) {
                            exceptionHandle("拣料入库 ===>> 修改库位状态失败;[workNo={0}],[locNo={1}]", wrkMast.getWrkNo(), wrkMast.getLocNo());
                        }
@@ -174,7 +176,7 @@
                        LocDetl locDetl = locDetlService.selectItem(locMast.getLocNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), hostId);
                        if (null != locDetl) {
                            if (!locDetlService.updateAnfme(wrkDetl.getAnfme(), locMast.getLocNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), hostId)) {
                            if (!locDetlService.updateAnfme(locDetl.getAnfme() + wrkDetl.getAnfme(), locMast.getLocNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), hostId)) {
                                exceptionHandle("并板入库 ===>> 修改库存明细数量失败;[workNo={0}],[matnr={1}]", wrkMast.getWrkNo(), wrkDetl.getMatnr());
                            }
                        } else {
@@ -189,6 +191,22 @@
                                exceptionHandle("并板入库 ===>> 新增库存明细失败;[workNo={0}],[matnr={1}]", wrkMast.getWrkNo(), wrkDetl.getMatnr());
                            }
                        }
                        // 更新订单完成数量
                        OrderDetl orderDetl = orderDetlService.selectItem(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), hostId);
                        if (orderDetl == null) {
                            orderDetl = orderDetlService.selectItem(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), hostId);
                        }
                        try {
                            if(!Cools.isEmpty(orderDetl)){
                                if (!orderDetlService.increaseQtyByOrderNo(wrkDetl.getOrderNo(), wrkDetl.getMatnr(),
                                        orderDetl.getBatch(), wrkDetl.getAnfme(), hostId)) {
                                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                    return FAIL.setMsg("并板入库 ===>> 更新订单完成数量失败; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
                                }
                            }
                        } catch (Exception ignore){}
                    }
                    // 修改库位状态 Q ====>> F
                    if (locMast.getLocSts().equals("Q")) {
@@ -196,6 +214,7 @@
                        locMast.setBarcode(wrkMast.getBarcode());
                        locMast.setIoTime(now);
                        locMast.setModiTime(now);
                        locMast.setPic(wrkMast.getPic());
                        if (!locMastService.updateById(locMast)) {
                            exceptionHandle("并板入库 ===>> 修改库位状态失败;[workNo={0}],[locNo={1}]", wrkMast.getWrkNo(), wrkMast.getLocNo());
                        }
@@ -214,6 +233,7 @@
                        locMast.setBarcode(wrkMast.getBarcode());
                        locMast.setIoTime(now);
                        locMast.setModiTime(now);
                        locMast.setPic(wrkMast.getPic());
                        if (!locMastService.updateById(locMast)) {
                            exceptionHandle("盘点入库 ===>> 修改库位状态失败;[workNo={0}],[locNo={1}]", wrkMast.getWrkNo(), wrkMast.getLocNo());
                        }
@@ -233,11 +253,14 @@
                    }
                    // 修改源库位状态 ==> O
                    LocMast sourceLoc = locMastService.getOne(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocNo, wrkMast.getSourceLocNo()).eq(LocMast::getHostId, hostId));
                    String picUrl = "";
                    if (null != sourceLoc) {
                        picUrl = sourceLoc.getPic();
                        sourceLoc.setBarcode("");
                        sourceLoc.setLocSts("O");
                        sourceLoc.setModiTime(now);
                        sourceLoc.setIoTime(now);
                        sourceLoc.setPic("");
                        if (!locMastService.updateById(sourceLoc)) {
                            exceptionHandle("库位移转 ===>> 修改源库位状态失败;[workNo={0}],[sourceLoc={1}]", wrkMast.getWrkNo(), wrkMast.getSourceLocNo());
                        }
@@ -247,6 +270,7 @@
                    locMast.setBarcode(wrkMast.getBarcode());
                    locMast.setIoTime(now);
                    locMast.setModiTime(now);
                    locMast.setPic(picUrl);
                    if (!locMastService.updateById(locMast)) {
                        exceptionHandle("库位移转 ===>> 修改目标库位状态失败;[workNo={0}],[locNo={1}]", wrkMast.getWrkNo(), wrkMast.getLocNo());
                    }
@@ -303,6 +327,7 @@
                        locMast.setBarcode("");
                        locMast.setModiTime(now);
                        locMast.setIoTime(now);
                        locMast.setPic("");
                        if (!locMastService.updateById(locMast)) {
                            exceptionHandle("全板出库 ===>> 修改源库位状态失败;[workNo={0}],[sourceLocNo={1}]", wrkMast.getWrkNo(), wrkMast.getSourceLocNo());
                        }
@@ -316,6 +341,7 @@
                        locMast.setBarcode("");
                        locMast.setModiTime(now);
                        locMast.setIoTime(now);
                        locMast.setPic("");
                        if (!locMastService.updateById(locMast)) {
                            exceptionHandle("空板出库 ===>> 修改源库位状态失败;[workNo={0}],[sourceLocNo={1}]", wrkMast.getWrkNo(), wrkMast.getSourceLocNo());
                        }