| | |
| | | return !Objects.isNull(loc) ? loc.getCode() : null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @param |
| | | * @return |
| | | * @author Ryan |
| | | * @description 获取目标站点 |
| | | * @time 2025/3/31 09:49 |
| | | */ |
| | | public static String getTargetSite() { |
| | | //TODO 站点策略后续排期 |
| | | DeviceSiteService deviceSite = SpringUtils.getBean(DeviceSiteService.class); |
| | | DeviceSite loc = deviceSite.getOne(new LambdaQueryWrapper<DeviceSite>().eq(DeviceSite::getStatus, 1), false); |
| | | return !Objects.isNull(loc) ? loc.getSite() : null; |
| | | } |
| | | |
| | | /** |
| | | * 出库策略:--〈效率优化〉 |
| | | * |
| | |
| | | * @param waveRule |
| | | * @return |
| | | */ |
| | | public static List<OrderOutItemDto> getOutOrderList(List<WaveToLocParams> params, WaveRule waveRule,String stationId) { |
| | | public static List<OrderOutItemDto> getOutOrderList(List<WaveToLocParams> params, WaveRule waveRule,String stationId,String locCode) { |
| | | LocService locService = SpringUtils.getBean(LocService.class); |
| | | LocItemService locItemService = SpringUtils.getBean(LocItemService.class); |
| | | DeviceSiteService deviceSiteService = SpringUtils.getBean(DeviceSiteService.class); |
| | | BasStationAreaService basStationAreaService = SpringUtils.getBean(BasStationAreaService.class); |
| | | // List<BasStationArea> basStationAreas = basStationAreaService.list(new LambdaQueryWrapper<>());// |
| | | List<Loc> locList = new ArrayList<>(); |
| | | List<OrderOutItemDto> list = new ArrayList<>(); |
| | | //不让站点重复使用问题 |
| | |
| | | } |
| | | for (LocItem locItem : locItems) { |
| | | Loc loc = locService.getById(locItem.getLocId()); |
| | | if (!Cools.isEmpty(locCode) || !Cools.isEmpty(stationId)) { |
| | | if (!loc.getCode().equals(locCode)){ |
| | | continue; |
| | | } |
| | | } |
| | | List<LocItem> itemList = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, loc.getId())); |
| | | |
| | | if (issued.doubleValue() > 0 && locList.contains(loc)) { |
| | |
| | | // orderOutItemDto.setLocItem(locItem); |
| | | orderOutItemDto.setLoc(loc); |
| | | orderOutItemDto.getLocItemList().add(locItem); |
| | | BasContainer containerType = getContainerType(loc.getBarcode()); |
| | | BasContainer containerType = new WarehouseLocationRetrievalUtil().getContainerByBarcode(loc.getBarcode()); |
| | | if (Cools.isEmpty(containerType)){ |
| | | continue; |
| | | } |
| | |
| | | if (Objects.isNull(basStation)) { |
| | | throw new CoolException("绑定站點不存在!!"); |
| | | } |
| | | 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::getSite, stationId) |
| | | .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 (DeviceSite sta : deviceSites) { |
| | | OrderOutItemDto.staListDto staListDto = new OrderOutItemDto.staListDto(); |
| | | staListDto.setStaNo(sta.getSite()); |
| | | staListDto.setStaName(sta.getSite()); |
| | | maps.add(staListDto); |
| | | } |
| | | orderOutItemDto.setStaNos(maps); |
| | | orderOutItemDto.setSiteNo(basStation.getStationName()); |
| | | } else { |
| | | throw new CoolException("未找到符合条件站点路径!!!请检查路径管理!!!"); |
| | | boolean available = new WarehouseLocationRetrievalUtil().queryPathIsItAvailableOutArea(loc.getAreaId().toString(), stationId, loc.getBarcode(),"out"); |
| | | if (!available) { |
| | | throw new CoolException("未找到符合条件路径!!!请检查路径配置!!!"); |
| | | } |
| | | orderOutItemDto.setSiteNo(basStation.getStationName()); |
| | | |
| | | orderOutItemDto.setSource(item.getItemId().toString()) |
| | | .setTargSiteAreaList(new ArrayList<>()) |
| | |
| | | |
| | | locList.add(loc); |
| | | issued = issued.subtract(new BigDecimal(locItem.getAnfme().toString())); |
| | | |
| | | } 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 (DeviceSite sta : deviceSites) { |
| | | OrderOutItemDto.staListDto staListDto = new OrderOutItemDto.staListDto(); |
| | | staListDto.setStaNo(sta.getSite()); |
| | | staListDto.setStaName(sta.getSite()); |
| | | maps.add(staListDto); |
| | | } |
| | | orderOutItemDto.setStaNos(maps); |
| | | //获取满足条件站点 |
| | | 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)) { |
| | | throw new CoolException("站點不存在!!"); |
| | | } |
| | | if (basStation.getType()!=0){ |
| | | stations.add(basStation); |
| | | } |
| | | orderOutItemDto.setSiteNo(basStation.getStationName()); |
| | | } else { |
| | | throw new CoolException("未找到符合条件站点!!!请检查路径管理!!!"); |
| | | } |
| | | |
| | | orderOutItemDto.setSource(item.getItemId().toString()) |
| | | .setTargSiteAreaList(new ArrayList<>()) |
| | | .setSourceId(item.getWaveId().toString()); |
| | | list.add(orderOutItemDto); |
| | | |
| | | locList.add(loc); |
| | | issued = issued.subtract(new BigDecimal(locItem.getAnfme().toString())); |
| | | throw new CoolException("未找到符合条件出库站点区域!!!请检查库区配置!!!"); |
| | | } |
| | | // if (true){ |
| | | //// throw new CoolException("未找到符合条件站点!!!请检查库区配置!!!"); |
| | | // } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //根据条码获取规则 |
| | | private static BasContainer getContainerType(String barcode) { |
| | | BasContainerService basContainerService = SpringUtils.getBean(BasContainerService.class); |
| | | if (Cools.isEmpty(barcode)) { |
| | | throw new CoolException("容器码不能为空"); |
| | | } |
| | | List<BasContainer> containers = basContainerService.list(new LambdaQueryWrapper<>()); |
| | | for (BasContainer container : containers) { |
| | | String codeType = container.getCodeType(); // 获取正则表达式 |
| | | if (barcode.matches(codeType)) { // 判断条码是否符合这个正则 |
| | | return container; |
| | | } |
| | | } |
| | | throw new CoolException("容器码:"+barcode+"异常==>未找到匹配的规则"); |
| | | } |
| | | |
| | | } |