Merge branch '0.8.X' of https://gitee.com/hdka/klp-oa into 0.8.X
This commit is contained in:
@@ -455,25 +455,21 @@ public class WmsActualWarehouseServiceImpl implements IWmsActualWarehouseService
|
||||
throw new ServiceException("未找到列标识为 " + columnFlag + " 的库位");
|
||||
}
|
||||
|
||||
// 1. 筛选出待拆分的父库位(只校验需要拆分的库位,非拆分库位不限制)
|
||||
List<WmsActualWarehouse> toSplitParents = columnLocations.stream()
|
||||
.filter(loc -> splitIds.contains(loc.getActualWarehouseId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 2. 批量校验占用状态
|
||||
// 检查整个列中是否有任何库位被占用
|
||||
List<String> occupiedCodes = new ArrayList<>();
|
||||
for (WmsActualWarehouse parent : toSplitParents) {
|
||||
for (WmsActualWarehouse location : columnLocations) {
|
||||
// 锁定状态=0 → 被占用
|
||||
boolean isOccupied = parent.getIsEnabled() != null && parent.getIsEnabled() == 0;
|
||||
boolean isOccupied = location.getIsEnabled() != null && location.getIsEnabled() == 0;
|
||||
if (isOccupied) {
|
||||
occupiedCodes.add(parent.getActualWarehouseCode());
|
||||
occupiedCodes.add(location.getActualWarehouseCode());
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 存在被占用的父库位,抛出异常提示
|
||||
// 如果有任何库位被占用,抛出异常提示
|
||||
if (!occupiedCodes.isEmpty()) {
|
||||
throw new ServiceException("以下父库位被占用,无法拆分:" + String.join(",", occupiedCodes));
|
||||
throw new ServiceException("以下库位被占用,无法拆分:" + String.join(",", occupiedCodes));
|
||||
}
|
||||
|
||||
// 批量查询所有子库位(一次性查询,避免循环查询)
|
||||
List<Long> parentIds = columnLocations.stream()
|
||||
.map(WmsActualWarehouse::getActualWarehouseId)
|
||||
@@ -709,7 +705,7 @@ public class WmsActualWarehouseServiceImpl implements IWmsActualWarehouseService
|
||||
}
|
||||
|
||||
// 批量查询所有子库位
|
||||
List<Long> parentIds = locationsToMerge.stream()
|
||||
List<Long> parentIds = columnLocations.stream()
|
||||
.map(WmsActualWarehouse::getActualWarehouseId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -717,20 +713,13 @@ public class WmsActualWarehouseServiceImpl implements IWmsActualWarehouseService
|
||||
.in(WmsActualWarehouse::getParentId, parentIds)
|
||||
.eq(WmsActualWarehouse::getActualWarehouseType, 4)); // 四级子库位
|
||||
|
||||
// 按父ID分组子库位
|
||||
Map<Long, List<WmsActualWarehouse>> childrenByParent = allChildren.stream()
|
||||
.collect(Collectors.groupingBy(WmsActualWarehouse::getParentId));
|
||||
|
||||
// 检查是否有子库位被占用
|
||||
for (WmsActualWarehouse location : locationsToMerge) {
|
||||
List<WmsActualWarehouse> children = childrenByParent.get(location.getActualWarehouseId());
|
||||
if (CollUtil.isNotEmpty(children)) {
|
||||
boolean anyOccupied = children.stream()
|
||||
.filter(c -> c.getDelFlag() == 0)
|
||||
.anyMatch(c -> !Objects.equals(c.getIsEnabled(), 1));
|
||||
if (anyOccupied) {
|
||||
throw new ServiceException("子库位被占用,不能合并:" + location.getActualWarehouseCode());
|
||||
}
|
||||
// 检查整列中是否有任何子库位被占用
|
||||
if (CollUtil.isNotEmpty(allChildren)) {
|
||||
boolean anyOccupied = allChildren.stream()
|
||||
.filter(c -> c.getDelFlag() == 0)
|
||||
.anyMatch(c -> !Objects.equals(c.getIsEnabled(), 1));
|
||||
if (anyOccupied) {
|
||||
throw new ServiceException("该列存在被占用的子库位,不能合并");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -739,7 +728,9 @@ public class WmsActualWarehouseServiceImpl implements IWmsActualWarehouseService
|
||||
List<WmsActualWarehouse> parentsToUpdate = new ArrayList<>();
|
||||
|
||||
for (WmsActualWarehouse location : locationsToMerge) {
|
||||
List<WmsActualWarehouse> children = childrenByParent.get(location.getActualWarehouseId());
|
||||
List<WmsActualWarehouse> children = allChildren.stream()
|
||||
.filter(c -> Objects.equals(c.getParentId(), location.getActualWarehouseId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 隐藏所有子库位
|
||||
if (CollUtil.isNotEmpty(children)) {
|
||||
@@ -747,7 +738,7 @@ public class WmsActualWarehouseServiceImpl implements IWmsActualWarehouseService
|
||||
if (child.getDelFlag() == 0) {
|
||||
WmsActualWarehouse childUpdate = new WmsActualWarehouse();
|
||||
childUpdate.setActualWarehouseId(child.getActualWarehouseId());
|
||||
childUpdate.setDelFlag(2);
|
||||
childUpdate.setDelFlag(1);
|
||||
childrenToUpdate.add(childUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user