自动化立体仓库 - WMS系统
zwl
2025-07-25 2f13ca17500528381cf808ee09cc540be61fbf94
src/main/java/com/zy/common/service/CommonService.java
@@ -511,12 +511,19 @@
    public StartupDto emptyIngetLocNo(Integer devpNo) {
        int crnNo = 0;
        // 目标库位
        LocMast locMast = null;
        if (devpNo == 304) {
            crnNo = 3;
            locMast = locMastMapper.queryEmptyLocNoByStaNo(crnNo);
        } else if(devpNo == 204) {
            crnNo = 2;
        } else if(devpNo == 104) {
            crnNo = 1;
        }else if(devpNo == 311) {
            crnNo = 4;
        }
        // 目标库位
        LocMast locMast = locMastMapper.queryEmptyLocNoByStaNo(crnNo);
        if (locMast == null) {
            throw new CoolException("没有空库位");
@@ -598,4 +605,113 @@
        startupDto.setLocNo(locMast.getLocNo());
        return startupDto;
    }
    public StartupDto getLocNoBy311(String type) {
        int row;
        int devpNo = 311;
        int crnNo = 4;
//        if (type.equals("1")) {
//            row =  7;
//        } else if (type.equals("2")) {
//            row = 6;
//        } else {
//            throw new CoolException("304物料类别识别错误:" + type);
//        }
        // 目标库位
        List<LocMast> locMasts = locMastMapper.selectOneByCrnNo(4);
        LocMast locMast = locMasts.get(0);
        if (locMast == null) {
            throw new CoolException("311入库没有空库位");
        }
        // 获取目标站
        Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
                .eq("type_no", 1)
                .eq("stn_no", devpNo)
                .eq("crn_no", crnNo);
        StaDesc staDesc = staDescService.selectOne(wrapper);
        if (Cools.isEmpty(staDesc)) {
            log.error("入库路径不存在, staDescId={}, sourceStaNo={}, crnNo={}", 1, devpNo, crnNo);
            throw new CoolException("入库路径不存在");
        }
        // 检测目标站
        BasDevp staNo = basDevpService.selectById(staDesc.getCrnStn());
        if (!staNo.getAutoing().equals("Y")) {
            throw new CoolException("目标站"+staDesc.getCrnStn()+"不可用");
        }
        basCrnpService.checkSiteStatus(crnNo, true);
        // 返回dto
        StartupDto startupDto = new StartupDto();
        startupDto.setWorkNo(getWorkNo(0));
        startupDto.setCrnNo(crnNo);
        startupDto.setSourceStaNo(devpNo);
        startupDto.setStaNo(devpNo);
        startupDto.setLocNo(locMast.getLocNo());
        return startupDto;
    }
    /**
     * 一期寻找库位
     * 1-6层 条码1或者2开头
     * 7-11层 条码8开头
     * @param ioType 1.入库
     * @param devpNo 入库站点
     * @param barcode 条码
     * @return 库位信息
     */
    public StartupDto getLocNoNew(int ioType, Integer devpNo, String barcode) {
        char type = barcode.charAt(0);
        int flag = 0;
        if (type == '1' || type == '2') {
            flag = 1;
        } else if( type == '8') {
            flag = 2;
        }
        if (flag == 0) {
            throw new CoolException("条码有误:" + barcode);
        }
        // 目标库位
        LocMast locMast = locMastMapper.queryLocByBarCodeNew(devpNo,flag);
        if (locMast == null) {
            throw new CoolException("入库没有空库位");
        }
        // 堆垛机号
        Integer crnNo = locMast.getCrnNo();
        // 获取目标站
        Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
                .eq("type_no", ioType)
                .eq("stn_no", devpNo)
                .eq("crn_no", crnNo);
        StaDesc staDesc = staDescService.selectOne(wrapper);
        if (Cools.isEmpty(staDesc)) {
            log.error("入库路径不存在, staDescId={}, sourceStaNo={}, crnNo={}", 1, devpNo, crnNo);
            throw new CoolException("入库路径不存在");
        }
        // 检测目标站
        BasDevp staNo = basDevpService.selectById(staDesc.getCrnStn());
        if (!staNo.getAutoing().equals("Y")) {
            throw new CoolException("目标站"+staDesc.getCrnStn()+"不可用");
        }
        basCrnpService.checkSiteStatus(crnNo, true);
        // 返回dto
        StartupDto startupDto = new StartupDto();
        startupDto.setWorkNo(getWorkNo(0));
        startupDto.setCrnNo(crnNo);
        startupDto.setSourceStaNo(devpNo);
        startupDto.setStaNo(devpNo);
        startupDto.setLocNo(locMast.getLocNo());
        return startupDto;
    }
}