自动化立体仓库 - WMS系统
zwl
5 天以前 113b5a29d3a68bee7b3500bb7505fb937ae9ba8d
src/main/java/com/zy/asrs/task/handler/WorkMastHandler.java
@@ -10,6 +10,7 @@
import com.zy.asrs.task.AbstractHandler;
import com.zy.asrs.task.core.ReturnT;
import com.zy.common.entity.Parameter;
import com.zy.integration.iot.biz.IotInstructionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -18,6 +19,7 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@@ -49,6 +51,8 @@
    private OrderPakinService orderPakinService;
    @Autowired
    private WorkService workService;
    @Autowired
    private IotInstructionService iotInstructionService;
    @Value("${erp.switch.ErpReportOld}")
    private boolean erpReportOld;
@@ -77,7 +81,7 @@
            return false;
        }
        Integer ioType = wrkMast.getIoType();
        return ioType != null && (ioType == 1 || ioType == 8 || ioType == 53 || ioType == 54 || ioType == 57);
        return ioType != null && (ioType == 1 || ioType == 5 || ioType == 11 || ioType == 53 || ioType == 54 || ioType == 57);
    }
    private boolean needOutboundErpReport(WrkMast wrkMast) {
@@ -88,11 +92,30 @@
        if (!Cools.isEmpty(erpReport) && !"true".equalsIgnoreCase(erpReport)) {
            return false;
        }
        if (wrkMast == null || Cools.isEmpty(wrkMast.getBarcode())) {
        if (wrkMast == null) {
            return false;
        }
        Integer ioType = wrkMast.getIoType();
        return ioType != null && (ioType == 101 || ioType == 108 || ioType == 110);
        if (ioType == null || (ioType != 101 && ioType != 108 && ioType != 110)) {
            return false;
        }
        return !Cools.isEmpty(resolveOutboundPalletId(wrkMast));
    }
    private String resolveOutboundPalletId(WrkMast wrkMast) {
        if (!Cools.isEmpty(wrkMast.getBarcode())) {
            return wrkMast.getBarcode();
        }
        List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo());
        if (Cools.isEmpty(wrkDetls)) {
            return null;
        }
        for (WrkDetl wrkDetl : wrkDetls) {
            if (!Cools.isEmpty(wrkDetl.getZpallet())) {
                return wrkDetl.getZpallet();
            }
        }
        return null;
    }
    public ReturnT<String> doIn(WrkMast wrkMast) {
@@ -116,6 +139,7 @@
                        locMast.setLocSts("D");
                        locMast.setIoTime(now);
                        locMast.setModiTime(now);
                        locMast.setScWeight(wrkMast.getScWeight());
                        if (!locMastService.updateById(locMast)) {
//                            exceptionHandle("空板入库 ===>> 修改库位状态失败;[workNo={0}],[locNo={1}]", wrkMast.getWrkNo(), wrkMast.getLocNo());
                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -156,6 +180,7 @@
                            locDetl.setZpallet(wrkDetl.getZpallet()); // 托盘条码
                            locDetl.setModiTime(now);
                            locDetl.setAppeTime(now);
                            locDetl.setWeight(wrkDetl.getWeight());
                            if (!locDetlService.insert(locDetl)) {
//                                exceptionHandle("全板入库 ===>> 添加库存明细失败;[workNo={0}],[locNo={1}]", wrkMast.getWrkNo(), wrkMast.getLocNo());
                                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -169,6 +194,7 @@
                        locMast.setBarcode(wrkMast.getBarcode());
                        locMast.setIoTime(now);
                        locMast.setModiTime(now);
                        locMast.setScWeight(wrkMast.getScWeight());
                        if (!locMastService.updateById(locMast)) {
//                            exceptionHandle("全板入库 ===>> 修改库位状态失败;[workNo={0}],[locNo={1}]", wrkMast.getWrkNo(), wrkMast.getLocNo());
                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -202,6 +228,7 @@
                            locDetl.setZpallet(wrkDetl.getZpallet()); // 托盘条码
                            locDetl.setModiTime(now);
                            locDetl.setAppeTime(now);
                            locDetl.setWeight(wrkDetl.getWeight());
                            if (!locDetlService.insert(locDetl)) {
                                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                return FAIL.setMsg("拣料途中并板 ===>> 添加库存明细失败; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
@@ -272,6 +299,7 @@
                        locMast.setBarcode(wrkMast.getBarcode());
                        locMast.setIoTime(now);
                        locMast.setModiTime(now);
                        locMast.setScWeight(wrkMast.getScWeight());
                        if (!locMastService.updateById(locMast)) {
//                            exceptionHandle("拣料入库 ===>> 修改库位状态失败;[workNo={0}],[locNo={1}]", wrkMast.getWrkNo(), wrkMast.getLocNo());
                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -308,6 +336,7 @@
                            locDetl.setZpallet(wrkDetl.getZpallet()); // 托盘条码
                            locDetl.setModiTime(now);
                            locDetl.setAppeTime(now);
                            locDetl.setWeight(wrkDetl.getWeight());
                            if (!locDetlService.insert(locDetl)) {
                                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                return FAIL.setMsg("并板入库 ===>> 新增库存明细失败; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
@@ -336,6 +365,7 @@
                        locMast.setBarcode(wrkMast.getBarcode());
                        locMast.setIoTime(now);
                        locMast.setModiTime(now);
                        locMast.setScWeight(wrkMast.getScWeight());
                        if (!locMastService.updateById(locMast)) {
//                            exceptionHandle("并板入库 ===>> 修改库位状态失败;[workNo={0}],[locNo={1}]", wrkMast.getWrkNo(), wrkMast.getLocNo());
                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -373,6 +403,7 @@
                        locMast.setBarcode(wrkMast.getBarcode());
                        locMast.setIoTime(now);
                        locMast.setModiTime(now);
                        locMast.setScWeight(wrkMast.getScWeight());
                        if (!locMastService.updateById(locMast)) {
//                            exceptionHandle("盘点入库 ===>> 修改库位状态失败;[workNo={0}],[locNo={1}]", wrkMast.getWrkNo(), wrkMast.getLocNo());
                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -418,6 +449,36 @@
                        return FAIL.setMsg("库位移转 ===>> 修改目标库位状态失败; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
                    }
                    break;
                // 浅库位移库
                case 5:
                    String changeLocSts = "D";
                    if ("N".equals(wrkMast.getEmptyMk())) {
                        changeLocSts = "F";
                        if (!locDetlService.updateLocNo(wrkMast.getLocNo(), wrkMast.getSourceLocNo())) {
                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                            return FAIL.setMsg("浅库位移库 ===>> 转移库存明细数据失败; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
                        }
                    }
                    LocMast changeLocSource = locMastService.selectById(wrkMast.getSourceLocNo());
                    if (null != changeLocSource) {
                        changeLocSource.setBarcode("");
                        changeLocSource.setLocSts("O");
                        changeLocSource.setModiTime(now);
                        changeLocSource.setIoTime(now);
                        if (!locMastService.updateById(changeLocSource)) {
                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                            return FAIL.setMsg("浅库位移库 ===>> 修改源库位状态失败; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
                        }
                    }
                    locMast.setLocSts(changeLocSts);
                    locMast.setBarcode(wrkMast.getBarcode());
                    locMast.setIoTime(now);
                    locMast.setModiTime(now);
                    if (!locMastService.updateById(locMast)) {
                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                        return FAIL.setMsg("浅库位移库 ===>> 修改目标库位状态失败; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
                    }
                    break;
                default:
                    break;
            }
@@ -437,6 +498,7 @@
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                return FAIL.setMsg("更新入库完成状态失败; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
            }
            iotInstructionService.queueWorkCompletion(wrkMast);
        } catch (Exception e) {
            log.error("fail", e);
            e.printStackTrace();
@@ -505,6 +567,7 @@
                    if (locMast.getLocSts().equals("R")) {
                        locMast.setLocSts("O");
                        locMast.setBarcode("");
                        locMast.setScWeight(BigDecimal.ZERO);
                        locMast.setModiTime(now);
                        locMast.setIoTime(now);
                        if (!locMastService.updateById(locMast)) {
@@ -554,6 +617,7 @@
                    if (locMast.getLocSts().equals("R")) {
                        locMast.setLocSts("O");
                        locMast.setBarcode("");
                        locMast.setScWeight(BigDecimal.ZERO);
                        locMast.setModiTime(now);
                        locMast.setIoTime(now);
                        if (!locMastService.updateById(locMast)) {
@@ -586,6 +650,7 @@
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                return FAIL.setMsg("更新出库完成状态失败; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getSourceLocNo() + "]");
            }
            iotInstructionService.queueWorkCompletion(wrkMast);
        } catch (Exception e) {
            log.error("fail", e);
            e.printStackTrace();
@@ -595,3 +660,4 @@
        return SUCCESS;
    }
}