自动化立体仓库 - WMS系统
#1
dubin
2025-12-18 b353180b80a56e62884df783416903858c97936f
#1
2个文件已修改
192 ■■■■■ 已修改文件
src/main/java/com/zy/common/service/CommonService.java 179 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/web/WcsController.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/service/CommonService.java
@@ -417,6 +417,12 @@
        return getLocNoEmpty(whsType, staDescId, sourceStaNo, matnr, batch, grade, 0, locTypeDto, 0);
    }
//    @Transactional
//    public StartupDto getLocNoEmptyNew(Integer whsType, Integer staDescId, Integer sourceStaNo,LocTypeDto locTypeDto,String barcode) {
//        whsType = Utils.GetWhsType(sourceStaNo);
//        return getLocNoEmptyNew(whsType, staDescId, sourceStaNo,locTypeDto,barcode,0,0);
//    }
    @Transactional
    public StartupDto getLocNoEmpty(Integer whsType, Integer staDescId, Integer sourceStaNo, String matnr, String batch, String grade, Integer moveCrnNo, LocTypeDto locTypeDto, int times) {
        if (Cools.isEmpty(matnr)) {  //物料号
@@ -722,4 +728,177 @@
        startupDto.setLocNo(locNo);
        return startupDto;
    }
//    @Transactional
//    public StartupDto getLocNoEmptyNew(Integer whsType, Integer staDescId, Integer sourceStaNo,LocTypeDto locTypeDto,String barcode,int  times, Integer moveCrnNo) {
//        // 初始化参数
//        int crnNo = 0;      //堆垛机号
//        int nearRow = 0;    //最浅库位排
//        int curRow = 0;     //最深库位排
//        int rowCount = 0;   //轮询轮次
//        LocMast locMast = null;     // 目标库位
//
//        StartupDto startupDto = new StartupDto();
//        RowLastno rowLastno = rowLastnoService.selectById(whsType);
//        int sRow = rowLastno.getsRow();
//        int eRow = rowLastno.geteRow();
//        int crnNumber = rowLastno.getCrnQty();
//
//        if (Cools.isEmpty(rowLastno)) {
//            throw new CoolException("数据异常,请联系管理员");
//        }
//        // ===============>>>> 开始执行
//        curRow = rowLastno.getCurrentRow();
//
//        if (!Cools.isEmpty(moveCrnNo) && moveCrnNo != 0) {
//            crnNumber = moveCrnNo;
//            if (times == 0) {
//                curRow = moveCrnNo * 4 - 1;
//            } else {
//                curRow = moveCrnNo * 4 - 2;
//            }
//        }
//
//        //此程序用于优化堆垛机异常时的运行时间
//        for (int i = times; i < crnNumber; i++) {
//            int[] locNecessaryParameters = Utils.LocNecessaryParameters(whsType, curRow, crnNumber);
//            curRow = locNecessaryParameters[1];
//            crnNo = locNecessaryParameters[2];
//            if (basCrnpService.checkSiteError(crnNo, true)) {
//                rowCount = locNecessaryParameters[0];
//                nearRow = locNecessaryParameters[3];
//                break;
//            } else {
//                times++;
//            }
//        }
//        if (nearRow == 0) {
//            throw new CoolException("无可用堆垛机");
//        }
//
//        Wrapper<StaDesc> wrapper = null;
//        StaDesc staDesc = null;
//        BasDevp staNo = null;
//
//        if (Utils.BooleanWhsTypeSta(whsType, staDescId)) {
//            // 获取目标站
//            wrapper = new EntityWrapper<StaDesc>()
//                    .eq("type_no", staDescId)
//                    .eq("stn_no", sourceStaNo)
//                    .eq("crn_no", crnNo);
//            staDesc = staDescService.selectOne(wrapper);
//            if (Cools.isEmpty(staDesc)) {
//                log.error("type_no={},stn_no={},crn_no={}", staDescId, sourceStaNo, crnNo);
//                crnNo = 0;
//            }
//            staNo = basDevpService.selectById(staDesc.getCrnStn());
//            if (!staNo.getAutoing().equals("Y")) {
//                crnNo = 0;
//            }
//            startupDto.setStaNo(staNo.getDevNo());
//        }
//
//        // 更新库位排号
//        if (Utils.BooleanWhsTypeSta(whsType, staDescId)) {
//            rowLastno.setCurrentRow(curRow);
//            rowLastnoService.updateById(rowLastno);
//        }
//
//        // 1.按规则查找库位
//        if (Cools.isEmpty(locMast) && crnNo != 0) {
//            List<LocMast> locMasts = new ArrayList<>();
//            if (barcode.startsWith("6")){
//                locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
//                        .eq("loc_sts","O")
//                        .in("row1",2,3)
//                        .in("lev1",1,2,3,4,5,6,7)
//                        .orderBy("row1",true)
//                        .orderBy("lev1",true)
//                );
//            }else if (barcode.startsWith("7")){
//                locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
//                        .eq("loc_sts","O")
//                        .in("row1",2,3)
//                        .in("lev1",8,9,10,11,12)
//                        .orderBy("row1",true)
//                        .orderBy("lev1",true)
//                );
//            }else if (barcode.startsWith("8")){
//                locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
//                        .eq("loc_sts","O")
//                        .eq("lev1",13)
//                        .in("row1",2,3)
//                        .orderBy("row1",true)
//                        .orderBy("lev1",true)
//                );
//            }
//
//            if (locMasts.size() <= 7){
//                throw new CoolException("无空库位可用");
//            }
//
//            locMasts.sort(new Comparator<LocMast>() {
//                @Override
//                public int compare(LocMast o1, LocMast o2) {
//                    int b1 = o1.getBay1();
//                    int b2 = o2.getBay1();
//                    if (o1.getBay1() >= 15) {
//                        b1 = Math.abs(15 - o1.getBay1());
//                    }
//                    if (o2.getBay1() >= 15) {
//                        b2 = Math.abs(15 - o2.getBay1());
//                    }
//                    return b2 - b1;
//                }
//            });
//
//            for (LocMast locMast1 : locMasts) {
//                if (Utils.isDeepLoc(slaveProperties,locMast1.getLocNo())){
//                    continue;
//                }
//                String deepLoc = Utils.getDeepLoc(slaveProperties, locMast1.getLocNo());
//                LocMast locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", deepLoc));
//                if (Cools.isEmpty(locMast2)){
//                    continue;
//                }
//                if (locMast2.getLocSts().equals("P")||locMast2.getLocSts().equals("Q")||locMast2.getLocSts().equals("R")||locMast2.getLocSts().equals("S")){
//                    continue;
//                }
//                if (!Cools.isEmpty(locMast2)&&locMast2.getLocSts().equals("O")){
//                    locMast = locMast2;
//                    break;
//                }
//                if (!Cools.isEmpty(locMast2)&&(locMast2.getLocSts().equals("F")||locMast2.getLocSts().equals("D"))){
//                    locMast = locMast1;
//                    break;
//                }
//            }
//        }
//
//        if (!Cools.isEmpty(locMast) && !basCrnpService.checkSiteError(crnNo, true)) {
//            locMast = null;
//        }
//
//        // 递归查询
//        if (Cools.isEmpty(locMast) || !locMast.getLocSts().equals("O")) {
//            // 当前巷道无空库位时,递归调整至下一巷道,检索全部巷道无果后,跳出递归
//            if (times < rowCount) {
//                times = times + 1;
//                return getLocNoEmptyNew(1, staDescId, sourceStaNo,locTypeDto,barcode);
//            }
//            log.error("系统没有空库位!!! 尺寸规格: {}, 轮询次数:{}", JSON.toJSONString(locTypeDto), times);
//            throw new CoolException("没有空库位");
//        }
//        String locNo = locMast.getLocNo();
//
//        // 生成工作号
//        int workNo = getWorkNo(0);
//        // 返回dto
//        startupDto.setWorkNo(workNo);
//        startupDto.setCrnNo(crnNo);
//        startupDto.setSourceStaNo(sourceStaNo);
//        startupDto.setLocNo(locNo);
//        return startupDto;
//
//    }
}
src/main/java/com/zy/common/web/WcsController.java
@@ -93,6 +93,18 @@
                return R.error("工作档已存在");
            }
        }
        // 空托盘按照托盘码分配库位
//        else if (param.getIoType() == 10) {
//            if (Cools.isEmpty(param.getBarcode())) {
//                return R.error("条码不能为空");
//            }
//            if (!param.getBarcode().startsWith("6") && !param.getBarcode().startsWith("7") && !param.getBarcode().startsWith("8")){
//                return R.error("不存在的托盘类型");
//            }
//        }
        if (Cools.isEmpty(param.getLocType1())) {
            return R.error("高低检测信号不能为空");
        }
@@ -434,6 +446,7 @@
        BasDevp sourceStaNo = basDevpService.checkSiteStatus(devpNo, true);
        // 检索库位
        StartupDto dto = commonService.getLocNoEmpty(1, 10, devpNo, null, null, null, locTypeDto);
//        StartupDto dto = commonService.getLocNoEmptyNew(1, 10, devpNo,locTypeDto,barcode);
        int workNo = dto.getWorkNo();
        // 生成工作档
        WrkMast wrkMast = new WrkMast();