自动化立体仓库 - WMS系统
#
zwl
2025-05-20 cb5092a38a5123bd9da452ad311b9323561802b1
src/main/java/com/zy/common/service/CommonService.java
@@ -548,105 +548,110 @@
     */
    public LocMast getLocNo2(WaitPakin waitPakin, Integer[] arr, Integer d, Integer locType, Integer locType1) {
        LocMast locMast = null;
        //一.查询入库货物是否是特殊摆放货物
        if (locType == 2) {
            //查找层标记的
            LocMast locMast1 = locMastService.selectOne(new EntityWrapper<LocMast>()
                    .eq("lev1", arr[d])
                    .eq("loc_sts", "O")
                    .eq("loc_type1", 2)
                    .eq("loc_attribute", 1));
            if (!Cools.isEmpty(locMast1)) {
                locMast = locMast1;
            }
        } else {
            List<LocMast> locMasts = new ArrayList<>();
            //二.空栈板摆放规则
            //1.该层相同空栈板
            //2.获得locAttribute库位属性为1的所有库位
            //3.查看组里是否还有空位
            if (locType1 == 2) {
                locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
                        .eq("lev1", arr[d])
                        .eq("loc_sts", "D")
                        .eq("loc_type1", 1)
                        .eq("loc_attribute", 1));
                if (!Cools.isEmpty(locMasts)) {
                    for (LocMast locMast1 : locMasts) {
                        //4.查看该组是否有预约入库和预约出库的库位,有的话直接跳过该组
                        List<LocMast> locMasts2 = locMastService.selectList(new EntityWrapper<LocMast>()
                                .eq("group1", locMast1.getGroup1())
                                .in("loc_sts", "P", "Q", "R", "S"));
                        if (!Cools.isEmpty(locMasts2)) {
                            continue;
                        }
                        //5.找出同一组的空库位
                        //6.对深浅库位进行排序
                        List<LocMast> locMasts1 = locMastService.selectList(new EntityWrapper<LocMast>()
                                .eq("group1", locMast1.getGroup1())
                                .eq("loc_sts", "O")
                                .orderBy("locAttribute"));
                        if (Cools.isEmpty(locMasts1)) {
                            continue;
                        }
                        //7.查看
                        locMast = locMasts1.get(0);
                    }
                }
            } else {
                //三.正常货物入库
                //1.该层相同物料摆放
                //2.获得locAttribute库位属性为1的所有库位
                //3.查看组里是否还有空位
                locMasts = locMastService.querySame(waitPakin.getMatnr(), arr[d]);
                if (!Cools.isEmpty(locMasts)) {
                    for (LocMast locMast1 : locMasts) {
                        //4.查看该组是否有预约入库和预约出库的库位,有的话直接跳过该组
                        List<LocMast> locMasts2 = locMastService.selectList(new EntityWrapper<LocMast>()
                                .eq("group1", locMast1.getGroup1())
                                .in("loc_sts", "P", "Q", "R", "S"));
                        if (!Cools.isEmpty(locMasts2)) {
                            continue;
                        }
                        //5.找出同一组的空库位
                        //6.对深浅库位进行排序
                        List<LocMast> locMasts1 = locMastService.selectList(new EntityWrapper<LocMast>()
                                .eq("group1", locMast1.getGroup1())
                                .eq("loc_sts", "O")
                                .orderBy("locAttribute"));
                        if (Cools.isEmpty(locMasts1)) {
                            continue;
                        }
                        //7.查看
                        locMast = locMasts1.get(0);
                    }
                }
            }
            //四.没有相同物料,进行正常找库
            if (Cools.isEmpty(locMast)) {
                //查找该层所有空的"loc_attribute",1
                List<LocMast> locMastList = locMastService.selectList(new EntityWrapper<LocMast>()
        try {
            //一.查询入库货物是否是特殊摆放货物
            if (locType == 2) {
                //查找层标记的
                LocMast locMast1 = locMastService.selectOne(new EntityWrapper<LocMast>()
                        .eq("lev1", arr[d])
                        .eq("loc_sts", "O")
                        .eq("loc_type1", 1)
                        .eq("loc_attribute", 1)
                        .orderBy("row1", false)
                        .orderBy("bay1", false));
                if (!Cools.isEmpty(locMastList)) {
                    locMast = locMastList.get(0);
                        .eq("loc_type1", 2)
                        .eq("loc_attribute", 1));
                if (!Cools.isEmpty(locMast1)) {
                    locMast = locMast1;
                }
            } else {
                List<LocMast> locMasts = new ArrayList<>();
                //二.空栈板摆放规则
                //1.该层相同空栈板
                //2.获得locAttribute库位属性为1的所有库位
                //3.查看组里是否还有空位
                if (locType1 == 2) {
                    locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
                            .eq("lev1", arr[d])
                            .eq("loc_sts", "D")
                            .eq("loc_type1", 1)
                            .eq("loc_attribute", 1));
                    if (!Cools.isEmpty(locMasts)) {
                        for (LocMast locMast1 : locMasts) {
                            //4.查看该组是否有预约入库和预约出库的库位,有的话直接跳过该组
                            List<LocMast> locMasts2 = locMastService.selectList(new EntityWrapper<LocMast>()
                                    .eq("group1", locMast1.getGroup1())
                                    .in("loc_sts", "P", "Q", "R", "S"));
                            if (!Cools.isEmpty(locMasts2)) {
                                continue;
                            }
                            //5.找出同一组的空库位
                            //6.对深浅库位进行排序
                            List<LocMast> locMasts1 = locMastService.selectList(new EntityWrapper<LocMast>()
                                    .eq("group1", locMast1.getGroup1())
                                    .eq("loc_sts", "O")
                                    .orderBy("locAttribute"));
                            if (Cools.isEmpty(locMasts1)) {
                                continue;
                            }
                            //7.查看
                            locMast = locMasts1.get(0);
                        }
                    }
                } else {
                    //三.正常货物入库
                    //1.该层相同物料摆放
                    //2.获得locAttribute库位属性为1的所有库位
                    //3.查看组里是否还有空位
                    locMasts = locMastService.querySame(waitPakin.getMatnr(), arr[d]);
                    if (!Cools.isEmpty(locMasts)) {
                        for (LocMast locMast1 : locMasts) {
                            //4.查看该组是否有预约入库和预约出库的库位,有的话直接跳过该组
                            List<LocMast> locMasts2 = locMastService.selectList(new EntityWrapper<LocMast>()
                                    .eq("group1", locMast1.getGroup1())
                                    .in("loc_sts", "P", "Q", "R", "S"));
                            if (!Cools.isEmpty(locMasts2)) {
                                continue;
                            }
                            //5.找出同一组的空库位
                            //6.对深浅库位进行排序
                            List<LocMast> locMasts1 = locMastService.selectList(new EntityWrapper<LocMast>()
                                    .eq("group1", locMast1.getGroup1())
                                    .eq("loc_sts", "O")
                                    .orderBy("locAttribute"));
                            if (Cools.isEmpty(locMasts1)) {
                                continue;
                            }
                            //7.查看
                            locMast = locMasts1.get(0);
                        }
                    }
                }
                //四.没有相同物料,进行正常找库
                if (Cools.isEmpty(locMast)) {
                    //查找该层所有空的"loc_attribute",1
                    List<LocMast> locMastList = locMastService.selectList(new EntityWrapper<LocMast>()
                            .eq("lev1", arr[d])
                            .eq("loc_sts", "O")
                            .eq("loc_type1", 1)
                            .eq("loc_attribute", 1)
                            .orderBy("row1", false)
                            .orderBy("bay1", false));
                    if (!Cools.isEmpty(locMastList)) {
                        locMast = locMastList.get(0);
                    }
                }
                //该层没有找到库位时进入递归换层找库位
                if (Cools.isEmpty(locMast)) {
                    ++d;
                    if (d > 6) {
                        throw new CoolException("没有空库位");
                    }
                    if (d == 6 && locType == 2) {
                        return getLocNo2(waitPakin, arr, 0, 1, locType1);
                    }
                    return getLocNo2(waitPakin, arr, d, locType, locType1);
                }
            }
            //该层没有找到库位时进入递归换层找库位
            if (Cools.isEmpty(locMast)) {
                if (d > 6) {
                    throw new CoolException("没有空库位");
                }
                if (d == 6 && locType == 2) {
                    return getLocNo2(waitPakin, arr, 0, 1, locType1);
                }
                return getLocNo2(waitPakin, arr, d++, locType, locType1);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return locMast;
    }