|
@@ -116,7 +116,6 @@ public class WmsDocOrderSubService {
|
|
//重新筛选库存
|
|
//重新筛选库存
|
|
// baseLocationLotattVOS1 = filterInv(baseLocationLotattVOS, orderNo);
|
|
// baseLocationLotattVOS1 = filterInv(baseLocationLotattVOS, orderNo);
|
|
|
|
|
|
- if(1==1) throw new RuntimeException("test");
|
|
|
|
boolean con = true;
|
|
boolean con = true;
|
|
//机械手应拆袋数
|
|
//机械手应拆袋数
|
|
int allocateQuantities = 0;
|
|
int allocateQuantities = 0;
|
|
@@ -241,7 +240,7 @@ public class WmsDocOrderSubService {
|
|
|
|
|
|
int locationIndex = partitionLocationIdList.indexOf(locationInfo.getId());
|
|
int locationIndex = partitionLocationIdList.indexOf(locationInfo.getId());
|
|
if(StringUtils.equals(partitionRowKey, Constants.FIRST)) {
|
|
if(StringUtils.equals(partitionRowKey, Constants.FIRST)) {
|
|
- List<Long> firstRightSubList = ListUtil.sub(partitionLocationIdList, locationIndex, partitionLocationIdList.size());
|
|
|
|
|
|
+ List<Long> firstRightSubList = ListUtil.reverse(ListUtil.sub(partitionLocationIdList, locationIndex, partitionLocationIdList.size()));
|
|
List<Long> resultLocationIdList = checkLocationIdList(locationInfo.getId(), sourceInvLotLocIdList, firstRightSubList,
|
|
List<Long> resultLocationIdList = checkLocationIdList(locationInfo.getId(), sourceInvLotLocIdList, firstRightSubList,
|
|
baseLocationLotattList, quantity);
|
|
baseLocationLotattList, quantity);
|
|
if(CollectionUtil.isEmpty(resultLocationIdList)) continue;
|
|
if(CollectionUtil.isEmpty(resultLocationIdList)) continue;
|
|
@@ -257,12 +256,16 @@ public class WmsDocOrderSubService {
|
|
}
|
|
}
|
|
|
|
|
|
if(StringUtils.equals(partitionRowKey, Constants.MIDDLE)){
|
|
if(StringUtils.equals(partitionRowKey, Constants.MIDDLE)){
|
|
- List<Long> middleLeftSubList = ListUtil.reverse(ListUtil.sub(partitionLocationIdList, Constants.START_VALUE, locationIndex + 1));
|
|
|
|
|
|
+ List<Long> middleLeftSubList = ListUtil.sub(partitionLocationIdList, Constants.START_VALUE, locationIndex + 1);
|
|
List<Long> middleLeftLocationIdList = checkLocationIdList(locationInfo.getId(), sourceInvLotLocIdList, middleLeftSubList,
|
|
List<Long> middleLeftLocationIdList = checkLocationIdList(locationInfo.getId(), sourceInvLotLocIdList, middleLeftSubList,
|
|
baseLocationLotattList, quantity);
|
|
baseLocationLotattList, quantity);
|
|
- List<Long> middleRightSubList = ListUtil.sub(partitionLocationIdList, locationIndex, partitionLocationIdList.size());
|
|
|
|
|
|
+ System.err.println(JSONObject.toJSONString(middleLeftLocationIdList));
|
|
|
|
+
|
|
|
|
+ List<Long> middleRightSubList = ListUtil.reverse(ListUtil.sub(partitionLocationIdList, locationIndex, partitionLocationIdList.size()));
|
|
List<Long> middleRightLocationIdList = checkLocationIdList(locationInfo.getId(), sourceInvLotLocIdList, middleRightSubList,
|
|
List<Long> middleRightLocationIdList = checkLocationIdList(locationInfo.getId(), sourceInvLotLocIdList, middleRightSubList,
|
|
baseLocationLotattList, quantity);
|
|
baseLocationLotattList, quantity);
|
|
|
|
+ System.err.println(JSONObject.toJSONString(middleRightLocationIdList));
|
|
|
|
+
|
|
if(CollectionUtil.isEmpty(middleLeftLocationIdList)
|
|
if(CollectionUtil.isEmpty(middleLeftLocationIdList)
|
|
&& CollectionUtil.isEmpty(middleRightLocationIdList)) continue;
|
|
&& CollectionUtil.isEmpty(middleRightLocationIdList)) continue;
|
|
|
|
|
|
@@ -274,22 +277,25 @@ public class WmsDocOrderSubService {
|
|
.filter(item -> CollectionUtil.contains(middleRightLocationIdList, Long.parseLong(item.getLocationId()))
|
|
.filter(item -> CollectionUtil.contains(middleRightLocationIdList, Long.parseLong(item.getLocationId()))
|
|
&& ObjectUtil.isNotNull(item.getQty()))
|
|
&& ObjectUtil.isNotNull(item.getQty()))
|
|
.map(item -> item.getQty()).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
.map(item -> item.getQty()).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
- BigDecimal singleRowInvCount = CompareUtil.compare(middleLeftCount, middleRightCount) < 0
|
|
|
|
- && CompareUtil.compare(middleLeftCount, BigDecimal.ZERO) > 0 ? middleLeftCount : middleRightCount;
|
|
|
|
- quantity = NumberUtil.sub(quantity, singleRowInvCount);
|
|
|
|
|
|
|
|
- List<Long> finalList = CompareUtil.compare(middleLeftCount, middleRightCount) < 0
|
|
|
|
- && CompareUtil.compare(middleLeftCount, BigDecimal.ZERO) > 0
|
|
|
|
|
|
+
|
|
|
|
+ BigDecimal compareCount = compareCount(middleLeftCount, middleRightCount);
|
|
|
|
+ if(ObjectUtil.isNull(compareCount) || CompareUtil.compare(compareCount, BigDecimal.ZERO)==0) continue;
|
|
|
|
+ List<Long> finalLeftLocationIdList = CompareUtil.compare(compareCount, middleLeftCount) == 0
|
|
? middleLeftLocationIdList : middleRightLocationIdList;
|
|
? middleLeftLocationIdList : middleRightLocationIdList;
|
|
|
|
+ BigDecimal singleRowInvCount = CompareUtil.compare(compareCount, middleLeftCount) == 0
|
|
|
|
+ ? middleLeftCount : middleRightCount;
|
|
|
|
+ quantity = NumberUtil.sub(quantity, singleRowInvCount);
|
|
|
|
|
|
baseLocationLotattList = baseLocationLotattList.stream()
|
|
baseLocationLotattList = baseLocationLotattList.stream()
|
|
- .filter(item -> !CollectionUtil.contains(finalList, item.getId())).collect(Collectors.toList());
|
|
|
|
- selectedLocationIdList.addAll(finalList);
|
|
|
|
|
|
+ .filter(item -> !CollectionUtil.contains(finalLeftLocationIdList, item.getId())).collect(Collectors.toList());
|
|
|
|
+ System.err.println(JSONObject.toJSONString(finalLeftLocationIdList));
|
|
|
|
+ selectedLocationIdList.addAll(finalLeftLocationIdList);
|
|
if(CompareUtil.compare(quantity, BigDecimal.ZERO) <= 0) break;
|
|
if(CompareUtil.compare(quantity, BigDecimal.ZERO) <= 0) break;
|
|
}
|
|
}
|
|
|
|
|
|
if(StringUtils.equals(partitionRowKey, Constants.LAST)) {
|
|
if(StringUtils.equals(partitionRowKey, Constants.LAST)) {
|
|
- List<Long> lastLeftSubList = ListUtil.reverse(ListUtil.sub(partitionLocationIdList, Constants.START_VALUE, locationIndex + 1));
|
|
|
|
|
|
+ List<Long> lastLeftSubList = ListUtil.sub(partitionLocationIdList, Constants.START_VALUE, locationIndex + 1);
|
|
List<Long> lastLeftLocationIdList = checkLocationIdList(locationInfo.getId(), sourceInvLotLocIdList, lastLeftSubList,
|
|
List<Long> lastLeftLocationIdList = checkLocationIdList(locationInfo.getId(), sourceInvLotLocIdList, lastLeftSubList,
|
|
baseLocationLotattList, quantity);
|
|
baseLocationLotattList, quantity);
|
|
if(CollectionUtil.isEmpty(lastLeftLocationIdList)) continue;
|
|
if(CollectionUtil.isEmpty(lastLeftLocationIdList)) continue;
|
|
@@ -309,6 +315,25 @@ public class WmsDocOrderSubService {
|
|
return copyLocationLotattList.stream().filter(item -> CollectionUtil.contains(selectedLocationIdList, item.getId())).collect(Collectors.toList());
|
|
return copyLocationLotattList.stream().filter(item -> CollectionUtil.contains(selectedLocationIdList, item.getId())).collect(Collectors.toList());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private BigDecimal compareCount(BigDecimal middleLeftCount, BigDecimal middleRightCount) {
|
|
|
|
+ if(CompareUtil.compare(middleLeftCount, middleRightCount) < 0
|
|
|
|
+ && CompareUtil.compare(middleLeftCount, BigDecimal.ZERO) > 0){
|
|
|
|
+ return middleLeftCount;
|
|
|
|
+ }
|
|
|
|
+ if(CompareUtil.compare(middleLeftCount, middleRightCount) >= 0
|
|
|
|
+ && CompareUtil.compare(middleRightCount, BigDecimal.ZERO) > 0){
|
|
|
|
+ return middleRightCount;
|
|
|
|
+ }
|
|
|
|
+ if(CompareUtil.compare(middleLeftCount, BigDecimal.ZERO) != 0
|
|
|
|
+ && CompareUtil.compare(middleRightCount, BigDecimal.ZERO) == 0){
|
|
|
|
+ return middleLeftCount;
|
|
|
|
+ }
|
|
|
|
+ if(CompareUtil.compare(middleRightCount, BigDecimal.ZERO) != 0
|
|
|
|
+ && CompareUtil.compare(middleLeftCount, BigDecimal.ZERO) == 0){
|
|
|
|
+ return middleRightCount;
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
private List<Long> checkLocationIdList(Long locationId, List<InvLotLocId> sourceInvLotLocIdList, List<Long> subList,
|
|
private List<Long> checkLocationIdList(Long locationId, List<InvLotLocId> sourceInvLotLocIdList, List<Long> subList,
|
|
@@ -334,8 +359,9 @@ public class WmsDocOrderSubService {
|
|
.filter(item -> CollectionUtil.contains(subList, Long.parseLong(item.getLocationId()))).collect(Collectors.toList());
|
|
.filter(item -> CollectionUtil.contains(subList, Long.parseLong(item.getLocationId()))).collect(Collectors.toList());
|
|
BigDecimal singleRowInvCount = invLocIdList.stream().filter(item -> ObjectUtil.isNotNull(item.getQty()))
|
|
BigDecimal singleRowInvCount = invLocIdList.stream().filter(item -> ObjectUtil.isNotNull(item.getQty()))
|
|
.map(item -> item.getQty()).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
|
|
.map(item -> item.getQty()).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
|
|
|
|
+ List<Long> invIdList = invLocIdList.stream().map(item -> Long.parseLong(item.getLocationId())).collect(Collectors.toList());
|
|
return CompareUtil.compare(singleRowInvCount, quantity) < 0
|
|
return CompareUtil.compare(singleRowInvCount, quantity) < 0
|
|
- ? invLocIdList.stream().map(item -> Long.parseLong(item.getLocationId())).collect(Collectors.toList())
|
|
|
|
|
|
+ ? subList.stream().filter(item -> CollectionUtil.contains(invIdList, item)).collect(Collectors.toList())
|
|
: Lists.newArrayList();
|
|
: Lists.newArrayList();
|
|
}
|
|
}
|
|
|
|
|