cl
2026-04-21 fc634e5b62b85396196e2dd8f51bfe5ba7337522
rsf-server/src/main/java/com/vincent/rsf/server/manager/utils/LocManageUtil.java
@@ -101,7 +101,7 @@
            locItemQueryWrapper.and(w -> w.eq(LocItem::getBatch, splrBatch).or().isNull(LocItem::getBatch));
        }
        // 含 F.在库 与 R.出库预约(拣料出库未确认前可再下发,使用剩余可用) “LocStsType.LOC_STS_TYPE_R.type用于出库拣料过程中追加相同物料出库单”
        String applySql = "EXISTS (SELECT 1 FROM man_loc ml WHERE ml.use_status IN ('" + LocStsType.LOC_STS_TYPE_F.type + "','" + LocStsType.LOC_STS_TYPE_R.type + "') AND ml.id = man_loc_item.loc_id)";
        String applySql = "EXISTS (SELECT 1 FROM man_loc ml WHERE ml.use_status IN ('" + LocStsType.LOC_STS_TYPE_F.type + "','" + LocStsType.LOC_STS_TYPE_R.type + "') AND ml.id = man_loc_item.loc_id AND ml.deleted = 0)";
        locItemQueryWrapper.apply(applySql);
        LocItemService locItemService = SpringUtils.getBean(LocItemService.class);
        List<LocItem> locItems = locItemService.list(locItemQueryWrapper);
@@ -136,7 +136,7 @@
            locItemQueryWrapper.orderByAsc(LocItem::getCreateTime);
        }
        // 含 F.在库 与 R.出库预约(拣料出库未确认前可再下发,使用剩余可用) “LocStsType.LOC_STS_TYPE_R.type用于出库拣料过程中追加相同物料出库单”
        String applySqlR = "EXISTS (SELECT 1 FROM man_loc ml WHERE ml.use_status IN ('" + LocStsType.LOC_STS_TYPE_F.type + "','" + LocStsType.LOC_STS_TYPE_R.type + "') AND ml.id = man_loc_item.loc_id)";
        String applySqlR = "EXISTS (SELECT 1 FROM man_loc ml WHERE ml.use_status IN ('" + LocStsType.LOC_STS_TYPE_F.type + "','" + LocStsType.LOC_STS_TYPE_R.type + "') AND ml.id = man_loc_item.loc_id AND ml.deleted = 0)";
        locItemQueryWrapper.apply(applySqlR);
        LocItemService locItemService = SpringUtils.getBean(LocItemService.class);
        List<LocItem> locItems = locItemService.list(locItemQueryWrapper);
@@ -156,8 +156,6 @@
        DeviceSiteService deviceSiteService = SpringUtils.getBean(DeviceSiteService.class);
        List<OrderOutItemDto> list = new ArrayList<>();
        //不让站点重复使用问题
        List<BasStation> stations = new ArrayList<>();
        List<ExistDto> existDtos = new ArrayList<>();
        Set<Loc> locs = new HashSet<>();
        for (WaveToLocParams item : params) {
@@ -207,27 +205,24 @@
                                    maps.add(staListDto);
                                }
                                orderOutItemDto.setStaNos(maps);
                                //获取满足条件站点
                                // 按可出规则选择站点
                                Set<String> stationSet = deviceSites.stream().map(DeviceSite::getSite).collect(Collectors.toSet());
                                String sType = "H";
                                //获取高低站点类型
                                if (startsWithTwoChars(loc.getBarcode(), "31")) {
                                    sType = "L";
                                }
                                //已使用站点
                                Set<String> stas = stations.stream().map(BasStation::getStationName).collect(Collectors.toSet());
                                BasStationService basStationService = SpringUtils.getBean(BasStationService.class);
                                BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
                                        .eq(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
                                List<BasStation> candidateStations = basStationService.list(new LambdaQueryWrapper<BasStation>()
                                        .in(BasStation::getStationName, stationSet)
//                                        .eq(BasStation::getSType, sType)
                                        .notIn(!stas.isEmpty(), BasStation::getStationName, stas)
                                        .last("LIMIT 1"));
                                stations.add(basStation);
                                if (Objects.isNull(basStation)) {
                                    throw new CoolException("站點不存在!!");
                                        .eq(BasStation::getStatus, 1)
                                        .eq(BasStation::getOutAble, 1));
                                if (candidateStations.isEmpty()) {
                                    throw new CoolException("无可出站点,请检查站点状态或能出配置!!");
                                }
                                candidateStations.sort((a, b) -> {
                                    boolean a1001 = "1001".equals(a.getStationName());
                                    boolean b1001 = "1001".equals(b.getStationName());
                                    if (a1001 && !b1001) return -1;
                                    if (!a1001 && b1001) return 1;
                                    return 0;
                                });
                                BasStation basStation = candidateStations.get(0);
                                orderOutItemDto.setSitesNo(basStation.getStationName());
                            }
                        }