自动化立体仓库 - WMS系统
zwl
4 天以前 9145f8a44c6ae733019e43c775cc30243032e502
src/main/java/com/zy/common/web/WcsController.java
@@ -58,6 +58,8 @@
    private WorkService workService;
    @Autowired
    private StaDescService staDescService;
    @Autowired
    private InboundCameraCaptureService inboundCameraCaptureService;
    @PostMapping("/pakin/loc/v1")
    @ResponseBody
@@ -83,6 +85,7 @@
            }
            WrkMast wrkMast1 = wrkMastService.selectByBarcode(param.getBarcode());
            if (!Cools.isEmpty(wrkMast1) && wrkMast1.getWrkSts() == 2) {
                triggerInboundCaptureAfterLocAssigned(wrkMast1);
                StartupDto dto1 = new StartupDto();
                dto1.setBarcode(param.getBarcode());
                dto1.setStaNo(Integer.valueOf(wrkMast1.getStaNo()));
@@ -495,7 +498,10 @@
            wrkMast.setUserNo(waitPakins.get(0).getOrderNo());
            wrkMast.setCubeNumber(waitPakins.get(0).getCubeNumber());
            wrkMast.setCtnType(sourceStaNo.getCtnType()); // 容器类型
            // WCS申请入库时,WMS找到库位后立即拍照;定时任务只作为未处理状态的兜底。
            wrkMast.setMemo(InboundCameraCaptureService.CAPTURE_PENDING);
            wrkMast.setPlateNo(waitPakins.get(0).getPlateNo());
            wrkMast.setTrainNo(waitPakins.get(0).getTrainNo());
            // 操作人员数据
            wrkMast.setAppeTime(now);
            wrkMast.setModiTime(now);
@@ -547,12 +553,62 @@
            String wcsLoc = Utils.WMSLocToWCSLoc(dto.getLocNo());
            dto.setLocNo(wcsLoc);
            dto.setTaskNo(workNo + "");
            triggerInboundCaptureAfterLocAssigned(wrkMast);
            return dto;
        } finally {
            log.info("startupFullPutStore耗时:{}ms, sourceStaNo:{}, barcode:{}", System.currentTimeMillis() - startTime, devpNo, barcode);
        }
    }
    private void triggerInboundCaptureAfterLocAssigned(WrkMast wrkMast) {
        if (!shouldTriggerInboundCapture(wrkMast)) {
            return;
        }
        try {
            ensureInboundCapturePending(wrkMast);
            inboundCameraCaptureService.processPendingCapture(wrkMast);
        } catch (Exception e) {
            log.warn("WCS申请入库后触发拍照失败:workNo={}, sourceStaNo={}, locNo={}, barcode={}",
                    wrkMast.getWrkNo(), wrkMast.getSourceStaNo(), wrkMast.getLocNo(), wrkMast.getBarcode(), e);
        }
    }
    private boolean shouldTriggerInboundCapture(WrkMast wrkMast) {
        if (wrkMast == null || wrkMast.getWrkNo() == null) {
            return false;
        }
        if (wrkMast.getIoType() == null || wrkMast.getIoType() != 1) {
            return false;
        }
        if (Cools.isEmpty(wrkMast.getSourceStaNo(), wrkMast.getLocNo(), wrkMast.getBarcode())) {
            return false;
        }
        if (InboundCameraCaptureService.CAPTURE_RUNNING.equals(wrkMast.getMemo())) {
            return false;
        }
        List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkMast.getWrkNo()));
        if (Cools.isEmpty(wrkDetls)) {
            return true;
        }
        for (WrkDetl wrkDetl : wrkDetls) {
            if (wrkDetl != null && !Cools.isEmpty(wrkDetl.getPic())) {
                return false;
            }
        }
        return true;
    }
    private void ensureInboundCapturePending(WrkMast wrkMast) {
        if (!Cools.isEmpty(wrkMast.getMemo())) {
            return;
        }
        WrkMast update = new WrkMast();
        update.setMemo(InboundCameraCaptureService.CAPTURE_PENDING);
        update.setModiTime(new Date());
        wrkMastService.update(update, new EntityWrapper<WrkMast>().eq("wrk_no", wrkMast.getWrkNo()));
        wrkMast.setMemo(InboundCameraCaptureService.CAPTURE_PENDING);
    }
    /**
     * 指定库位暂存在入库通知档 manu 字段,等 WCS 真正建任务时再读取。
     */