1
昨天 18b895f274f2a9f471cf1489a9b9b0543785d08e
rsf-server/src/main/java/com/vincent/rsf/server/manager/utils/LocManageUtil.java
@@ -201,7 +201,6 @@
                    locItems = LocManageUtil.getFirstInFirstOutItemList(item.getMatnrCode(), item.getBatch(), item.getAnfme());
                }
            }
            for (LocItem locItem : locItems) {
                Loc loc = locService.getById(locItem.getLocId());
                List<LocItem> itemList = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, loc.getId()));
@@ -244,62 +243,133 @@
                                .apply("JSON_CONTAINS(container_type, {0}) = 1", containerType.getContainerType().toString())//容器类型
                                .eq(BasStationArea::getDeleted, 0));
//                                .apply("JSON_CONTAINS(station_alias, '\"{0}\"') = 1", null)//区域包含站点集
                        List<String> targSiteAreaList = new ArrayList<>();
                        for (BasStationArea basStationArea : basStationAreas) {
                            targSiteAreaList.add(basStationArea.getStationAreaId());
                        }
                        int count = 0;
                        for (BasStationArea basStationArea : basStationAreas) {
                            count++;
                            if (!basStationArea.getStationAlias().isEmpty()) {
                        if (!basStationAreas.isEmpty()){
                            List<String> targSiteAreaList = new ArrayList<>();
                            for (BasStationArea basStationArea : basStationAreas) {
                                if (basStationArea.getStationAliasStaNo().isEmpty()){
                                    continue;
                                }
                                targSiteAreaList.add(basStationArea.getId().toString());
                            }
                            if (targSiteAreaList.isEmpty()){
                                throw new CoolException("未找到符合条件站点!!!请检查库区配置!!!");
                            }
                            int count = 0;
                            for (BasStationArea basStationArea : basStationAreas) {
                                count++;
                                if (!basStationArea.getStationAliasStaNo().isEmpty()) {
                                    List<OrderOutItemDto.staListDto> maps = new ArrayList<>();
                                    for (String site : basStationArea.getStationAliasStaNo()) {
                                        OrderOutItemDto.staListDto staListDto = new OrderOutItemDto.staListDto();
                                        staListDto.setStaNo(site);
                                        staListDto.setStaName(site);
                                        maps.add(staListDto);
                                    }
                                    orderOutItemDto.setStaNos(maps);
                                    //获取满足条件站点
                                    Set<String> stationSet = new HashSet<>(basStationArea.getStationAliasStaNo());
//                                Set<String> stationSet = basStationArea.getStationAlias().stream().collect(Collectors.toSet());
//                                Set<String> stationSet = deviceSites.stream().map(DeviceSite::getSite).collect(Collectors.toSet());
                                    //已使用站点
                                    Set<String> stas = stations.stream().map(BasStation::getStationName).collect(Collectors.toSet());
                                    if (stas.size() == maps.size()) {
                                        stations = new ArrayList<>();
                                        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)
                                            .in(BasStation::getStationName, stationSet)
                                            .notIn(!stas.isEmpty(), BasStation::getStationName, stas)
                                            .last("LIMIT 1"));
                                    if (!Objects.isNull(basStation)) {
                                        stations.add(basStation);
                                    }
                                    if (count == basStationAreas.size()) {
                                        if (!Objects.isNull(basStation)) {
                                            orderOutItemDto.setTargSiteAreaNow(basStationArea.getStationAreaId());
                                            orderOutItemDto.setSiteNo(basStation.getStationName());
//                                        throw new CoolException("站點不存在!!");
                                        } else if (!stas.isEmpty()) {
                                            orderOutItemDto.setTargSiteAreaNow(basStationArea.getStationAreaId());
                                            orderOutItemDto.setSiteNo(basStationArea.getStationAliasStaNo().get(0));
                                        } else {
                                            throw new CoolException("未找到符合条件站点!!!请检查库区或者路径配置!!!");
                                        }
                                    } else {
                                        if (Objects.isNull(basStation)) {
                                            continue;
//                                        throw new CoolException("站點不存在!!");
                                        }
                                        orderOutItemDto.setTargSiteAreaNow(basStationArea.getStationAreaId());
                                        orderOutItemDto.setSiteNo(basStation.getStationName());
                                    }
                                }
                                orderOutItemDto.setSource(item.getItemId().toString())
                                        .setTargSiteAreaList(targSiteAreaList)
                                        .setSourceId(item.getWaveId().toString());
                                list.add(orderOutItemDto);
                                locList.add(loc);
                                issued = issued.subtract(new BigDecimal(locItem.getAnfme().toString()));
                                break;
                            }
                        } else {
                            List<DeviceSite> deviceSites = deviceSiteService.list(new LambdaQueryWrapper<DeviceSite>()
                                    .eq(!Objects.isNull(loc.getChannel()), DeviceSite::getChannel, loc.getChannel())
                                    .eq(!Objects.isNull(loc.getAreaId()), DeviceSite::getAreaIdStart, loc.getAreaId())
                                    .eq(DeviceSite::getType, issued.doubleValue() >= locItem.getAnfme() && itemList.size() == 1 ? TaskType.TASK_TYPE_OUT.type : TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)
                            );
                            if (!deviceSites.isEmpty()) {
                                List<OrderOutItemDto.staListDto> maps = new ArrayList<>();
                                for (String site : basStationArea.getStationAlias()) {
                                for (DeviceSite sta : deviceSites) {
                                    OrderOutItemDto.staListDto staListDto = new OrderOutItemDto.staListDto();
                                    staListDto.setStaNo(site);
                                    staListDto.setStaName(site);
                                    staListDto.setStaNo(sta.getSite());
                                    staListDto.setStaName(sta.getSite());
                                    maps.add(staListDto);
                                }
                                orderOutItemDto.setStaNos(maps);
                                //获取满足条件站点
                                Set<String> stationSet = new HashSet<>(basStationArea.getStationAlias());
//                                Set<String> stationSet = basStationArea.getStationAlias().stream().collect(Collectors.toSet());
//                                Set<String> stationSet = deviceSites.stream().map(DeviceSite::getSite).collect(Collectors.toSet());
                                Set<String> stationSet = deviceSites.stream().map(DeviceSite::getSite).collect(Collectors.toSet());
                                //已使用站点
                                Set<String> stas = stations.stream().map(BasStation::getStationName).collect(Collectors.toSet());
                                BasStationService basStationService = SpringUtils.getBean(BasStationService.class);
                                BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
                                        .apply("cross_zone_area != '[]'")  // 不是空数组
                                        .apply("container_type != '[]'")
                                        .apply("JSON_CONTAINS(cross_zone_area, {0}) = 1", loc.getAreaId().toString())//可执行库区区区域id
                                        .apply("JSON_CONTAINS(container_type, {0}) = 1", containerType.getContainerType().toString())//容器类型
                                        .eq(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
                                        .in(BasStation::getStationName, stationSet)
                                        .notIn(!stas.isEmpty(), BasStation::getStationName, stas)
                                        .last("LIMIT 1"));
                                if (!Objects.isNull(basStation)) {
                                if (Objects.isNull(basStation)) {
                                    throw new CoolException("站點不存在!!");
                                }
                                if (basStation.getType()!=0){
                                    stations.add(basStation);
                                }
                                if (count == basStationAreas.size()) {
                                    if (!Objects.isNull(basStation)) {
                                        orderOutItemDto.setSiteNo(basStation.getStationName());
//                                        throw new CoolException("站點不存在!!");
                                    }
                                } else {
                                    if (Objects.isNull(basStation)) {
                                        continue;
//                                        throw new CoolException("站點不存在!!");
                                    }
                                    orderOutItemDto.setSiteNo(basStation.getStationName());
                                }
                                orderOutItemDto.setSiteNo(basStation.getStationName());
                            } else {
                                throw new CoolException("未找到符合条件站点!!!请检查路径管理!!!");
                            }
                            orderOutItemDto.setSource(item.getItemId().toString())
                                    .setTargSiteAreaList(targSiteAreaList)
                                    .setTargSiteAreaList(new ArrayList<>())
                                    .setSourceId(item.getWaveId().toString());
                            list.add(orderOutItemDto);
                            locList.add(loc);
                            locList.add(loc);
                            issued = issued.subtract(new BigDecimal(locItem.getAnfme().toString()));
                            break;
                        }
//                         if (true){
////                            throw new CoolException("未找到符合条件站点!!!请检查库区配置!!!");
//                        }
                    }
                }
            }
@@ -324,7 +394,7 @@
                return container;
            }
        }
        return null;
        throw new CoolException("容器码:"+barcode+"异常==>未找到匹配的规则");
    }
}