| | |
| | | import com.vincent.rsf.framework.common.SpringUtils; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.api.utils.LocUtils; |
| | | import com.vincent.rsf.server.common.redis.RedisKeys; |
| | | import com.vincent.rsf.server.manager.controller.dto.ExistDto; |
| | | import com.vincent.rsf.server.manager.controller.dto.OrderOutItemDto; |
| | | import com.vincent.rsf.server.manager.controller.params.WaveToLocParams; |
| | |
| | | if (Objects.isNull(loc) || Cools.isEmpty(loc.getCode())) { |
| | | continue; |
| | | } |
| | | boolean claimed = wmsRedisLuaService.claimLocation(buildTargetLocLockKey(loc.getCode()), loc.getCode(), TARGET_LOC_LOCK_TTL); |
| | | boolean claimed = wmsRedisLuaService.claimLocation(RedisKeys.locationOccupy(loc.getCode()), loc.getCode(), TARGET_LOC_LOCK_TTL); |
| | | if (claimed) { |
| | | return loc.getCode(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private static String buildTargetLocLockKey(String locCode) { |
| | | return TARGET_LOC_LOCK_KEY_PREFIX + locCode; |
| | | } |
| | | |
| | | /** |
| | |
| | | public static List<LocItem> getEfficiencyFirstItemList(String matnrCode, String splrBatch, Double anfme) { |
| | | LambdaQueryWrapper<LocItem> locItemQueryWrapper = new LambdaQueryWrapper<>(); |
| | | locItemQueryWrapper.eq(LocItem::getMatnrCode, matnrCode); |
| | | locItemQueryWrapper.eq(StringUtils.isNotBlank(splrBatch), LocItem::getBatch, splrBatch); |
| | | String applySql = String.format( |
| | | "EXISTS (SELECT 1 FROM man_loc ml " + |
| | | "WHERE ml.use_status = '%s'" + |
| | | "AND ml.id = man_loc_item.loc_id " + |
| | | ")", |
| | | LocStsType.LOC_STS_TYPE_F.type |
| | | ); |
| | | locItemQueryWrapper.apply(applySql); |
| | | LocItemService locItemService = SpringUtils.getBean(LocItemService.class); |
| | | List<LocItem> locItems = locItemService.list(locItemQueryWrapper); |
| | | locItems.sort(Comparator.comparing((LocItem item) -> !LocUtils.isShallowLoc(item.getLocCode()))); |
| | | List<LocItem> locsSet = locItems.stream().filter(locItem -> locItem.getAnfme().compareTo(anfme) == 0.0).collect(Collectors.toList()); |
| | | if (!locsSet.isEmpty()) { |
| | | return locsSet; |
| | | } |
| | | return locItems; |
| | | } |
| | | |
| | | /** |
| | | * 出库策略:--〈效率优化〉 |
| | | * |
| | | * @param matnrCode |
| | | * @param splrBatch |
| | | * @param anfme |
| | | * @return |
| | | */ |
| | | public static List<LocItem> getEfficiencyFirstItemList(String matnrCode, String splrBatch, Double anfme,String locCode) { |
| | | LambdaQueryWrapper<LocItem> locItemQueryWrapper = new LambdaQueryWrapper<>(); |
| | | locItemQueryWrapper.eq(LocItem::getMatnrCode, matnrCode); |
| | | if (!Cools.isEmpty(locCode)){ |
| | | locItemQueryWrapper.eq(LocItem::getLocCode, locCode); |
| | | } |
| | | locItemQueryWrapper.eq(StringUtils.isNotBlank(splrBatch), LocItem::getBatch, splrBatch); |
| | | String applySql = String.format( |
| | | "EXISTS (SELECT 1 FROM man_loc ml " + |
| | |
| | | return locItems; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 出库策略:--<先进先出> |
| | | * |
| | | * @param matnrCode |
| | | * @param splrBatch |
| | | * @param anfme |
| | | * @return |
| | | */ |
| | | public static List<LocItem> getFirstInFirstOutItemList(String matnrCode, String splrBatch, Double anfme,String locCode) { |
| | | LambdaQueryWrapper<LocItem> locItemQueryWrapper = new LambdaQueryWrapper<>(); |
| | | locItemQueryWrapper.eq(LocItem::getMatnrCode, matnrCode); |
| | | if (!Cools.isEmpty(locCode)){ |
| | | locItemQueryWrapper.eq(LocItem::getLocCode, locCode); |
| | | } |
| | | locItemQueryWrapper.eq(StringUtils.isNotEmpty(splrBatch), LocItem::getBatch, splrBatch); |
| | | //如果批次不为空,按批次先后出库 |
| | | if (StringUtils.isNotBlank(splrBatch)) { |
| | | locItemQueryWrapper.orderByAsc(LocItem::getBatch); |
| | | } else { |
| | | locItemQueryWrapper.orderByAsc(LocItem::getCreateTime); |
| | | } |
| | | String applySql = String.format( |
| | | "EXISTS (SELECT 1 FROM man_loc ml " + |
| | | "WHERE ml.use_status = '%s'" + |
| | | "AND ml.id = man_loc_item.loc_id " + |
| | | ")", |
| | | LocStsType.LOC_STS_TYPE_F.type |
| | | ); |
| | | locItemQueryWrapper.apply(applySql); |
| | | LocItemService locItemService = SpringUtils.getBean(LocItemService.class); |
| | | List<LocItem> locItems = locItemService.list(locItemQueryWrapper); |
| | | return locItems; |
| | | } |
| | | |
| | | /** |
| | | * 获取出库库位信息 |
| | | * |
| | |
| | | } |
| | | List<LocItem> locItems; |
| | | if (Objects.isNull(waveRule)) { |
| | | locItems = LocManageUtil.getFirstInFirstOutItemList(item.getMatnrCode(), item.getBatch(), item.getAnfme()); |
| | | locItems = LocManageUtil.getFirstInFirstOutItemList(item.getMatnrCode(), item.getBatch(), item.getAnfme(),locCode); |
| | | } else { |
| | | if (WaveRuleType.Efficiency_First.type.equals(waveRule.getType())) { |
| | | locItems = LocManageUtil.getEfficiencyFirstItemList(item.getMatnrCode(), item.getBatch(), item.getAnfme()); |
| | | locItems = LocManageUtil.getEfficiencyFirstItemList(item.getMatnrCode(), item.getBatch(), item.getAnfme(),locCode); |
| | | } else if (WaveRuleType.First_In_First_Out.type.equals(waveRule.getType())) { |
| | | locItems = LocManageUtil.getFirstInFirstOutItemList(item.getMatnrCode(), item.getBatch(), item.getAnfme()); |
| | | locItems = LocManageUtil.getFirstInFirstOutItemList(item.getMatnrCode(), item.getBatch(), item.getAnfme(),locCode); |
| | | } else { |
| | | locItems = LocManageUtil.getFirstInFirstOutItemList(item.getMatnrCode(), item.getBatch(), item.getAnfme()); |
| | | locItems = LocManageUtil.getFirstInFirstOutItemList(item.getMatnrCode(), item.getBatch(), item.getAnfme(),locCode); |
| | | } |
| | | } |
| | | for (LocItem locItem : locItems) { |
| | |
| | | .apply("cross_zone_area != '[]'") // 不是空数组 |
| | | .apply("container_type != '[]'") |
| | | .apply("station_alias != '[]'") |
| | | .apply("station_alias_sta_no != '[]'") |
| | | .apply("JSON_CONTAINS(cross_zone_area, {0}) = 1", loc.getAreaId().toString())//可执行库区区区域id |
| | | .apply("JSON_CONTAINS(container_type, {0}) = 1", containerType.getContainerType().toString())//容器类型 |
| | | .eq(BasStationArea::getDeleted, 0)); |