自动化立体仓库 - WMS系统
#
luxiaotao1123
2022-05-14 89af7e4c0a0fcd715bad4dbcf4e66442c0bf5975
src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -13,9 +13,11 @@
import com.zy.asrs.entity.param.LocDetlAdjustParam;
import com.zy.asrs.entity.param.StockOutParam;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.Utils;
import com.zy.common.model.*;
import com.zy.common.model.enums.IoWorkType;
import com.zy.common.model.enums.WorkNoType;
import com.zy.common.properties.SlaveProperties;
import com.zy.common.service.CommonService;
import com.zy.common.web.WcsController;
import lombok.extern.slf4j.Slf4j;
@@ -69,6 +71,10 @@
    private OrderDetlService orderDetlService;
    @Autowired
    private WcsController wcsController;
    @Autowired
    private RowLastnoService rowLastnoService;
    @Autowired
    private SlaveProperties slaveProperties;
    @Override
    @Transactional
@@ -220,6 +226,7 @@
            wrkMast.setExitMk("N"); // 退出
            wrkMast.setEmptyMk("N"); // 空板
            wrkMast.setLinkMis("N");
            wrkMast.setBarcode(locMast.getBarcode());
            wrkMast.setAppeUser(userId); // 操作人员数据
            wrkMast.setAppeTime(now);
            wrkMast.setModiUser(userId);
@@ -293,6 +300,7 @@
        wrkMast.setExitMk("N"); // 退出
        wrkMast.setEmptyMk("N"); // 空板
        wrkMast.setLinkMis("N");
        wrkMast.setBarcode(locMast.getBarcode());
        wrkMast.setAppeUser(userId); // 操作人员数据
        wrkMast.setAppeTime(now);
        wrkMast.setModiUser(userId);
@@ -304,8 +312,12 @@
        for (LocDto locDto : taskDto.getLocDtos()) {
            if (locDto.getAnfme()==null || locDto.getAnfme() <= 0.0D) { continue; }
            OrderDetl orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch());
            if (orderDetl == null) {
                orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null);
            }
            WrkDetl wrkDetl = new WrkDetl();
            wrkDetl.sync(orderDetl);
            wrkDetl.setZpallet(wrkMast.getBarcode());
            wrkDetl.setIoTime(now);
            wrkDetl.setWrkNo(workNo);
            wrkDetl.setBatch(locDto.getBatch());
@@ -746,7 +758,7 @@
                locSts = "D";
            // 库位转移 ===>> D.空桶/空栈板
            } else if (wrkMast.getIoType() == 11) {
                locSts = wrkMast.getFullPlt().equalsIgnoreCase("N")?"F":"D";
                locSts = wrkMast.getFullPlt().equalsIgnoreCase("N")?"D":"F";
                // 库位转移:目标库位
                LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
                if (Cools.isEmpty(locMast)) {
@@ -824,9 +836,9 @@
            throw new CoolException("当前工作状态无法进行操作");
        }
        // 保存工作明细档历史档
        if (!wrkDetlLogService.save(wrkMast.getWrkNo())) {
            throw new CoolException("保存工作明细档历史档失败");
        }
//        if (!wrkDetlLogService.save(wrkMast.getWrkNo())) {
//            throw new CoolException("保存工作明细档历史档失败");
//        }
        // 保存工作主档历史档
        if (!wrkMastLogService.save(wrkMast.getWrkNo())) {
            throw new CoolException("保存工作主档历史档失败");
@@ -874,4 +886,77 @@
        return wcsController.startupFullPutStore(301, list.get(0).getZpallet(), locTypeDto, list);
    }
    @Override
    @Transactional
    public String dealPreHaveStart(Integer wrkNo, Long userId) {
        WrkMast wrkMast = wrkMastService.selectById(wrkNo);
        if (wrkMast == null) {
            throw new CoolException("任务已失效");
        }
        String locNo = wrkMast.getLocNo();
        LocMast locMast = locMastService.selectById(locNo);
        assert locMast != null;
        RowLastno rowLastno = rowLastnoService.findBySection(locMast.getRow1());
        assert rowLastno != null;
        // 目标库位
        LocMast targetLoc = null;
        for (int curRow = rowLastno.getsRow(); curRow<=rowLastno.geteRow(); curRow++) {
            if (Utils.isShallowLoc(slaveProperties, curRow)) {
                Integer deepRow = Utils.getDeepRow(slaveProperties, curRow);
                targetLoc = locMastService.queryFreeLocMast(deepRow, locMast.getLocType1());
                // 因库位移转、需预留空库位
                if (!locMastService.checkEmptyCount(targetLoc)) {
                    continue;
                }
            }
            if (Cools.isEmpty(targetLoc)) {
                targetLoc = locMastService.queryFreeLocMast(curRow, locMast.getLocType1());
                // 因库位移转、需预留空库位
                if (!locMastService.checkEmptyCount(targetLoc)) {
                    continue;
                }
                // 目标库位 ===>> 浅库位, 则校验其深库位是否为 F D X
                if (null != targetLoc && Utils.isShallowLoc(slaveProperties, targetLoc.getLocNo())) {
                    LocMast deepLoc = locMastService.selectById(Utils.getDeepLoc(slaveProperties, targetLoc.getLocNo()));
                    if (!deepLoc.getLocSts().equals("F") && !deepLoc.getLocSts().equals("D") && !deepLoc.getLocSts().equals("X")) {
                        continue;
                    }
                }
                // 目标库位 ===>> 深库位, 则校验其浅库位是否为 O
                if (null != targetLoc && Utils.isDeepLoc(slaveProperties, targetLoc.getLocNo())) {
                    LocMast shallowLoc = locMastService.selectById(Utils.getShallowLoc(slaveProperties, targetLoc.getLocNo()));
                    if (!shallowLoc.getLocSts().equals("O")) {
                        continue;
                    }
                }
            }
            if (!Cools.isEmpty(targetLoc)) {
                break;
            }
        }
        if (targetLoc == null) {
            throw new CoolException("操作失败,当前仓库找不到空库位");
        }
        // 修改工作档
        StaDesc staDesc = staDescService.queryCrnStn(targetLoc.getCrnNo());
        if (Cools.isEmpty(staDesc)) {
            throw new CoolException("入库路径不存在");
        }
        wrkMast.setWrkSts(2L);
        wrkMast.setLocNo(targetLoc.getLocNo());
        wrkMast.setStaNo(staDesc.getCrnStn());
        if (!wrkMastService.updateById(wrkMast)) {
            throw new CoolException("修改工作档失败");
        }
        return targetLoc.getLocNo();
    }
}