feat(wms): 增加库位拆分前的占用状态校验
- 在拆分逻辑中增加对父库位占用状态的批量校验 - 若父库位被占用则抛出明确提示异常 - 优化库位拆分与合并时的子库位查询逻辑 - 统一处理拆分与合并操作中的空子库位判断 - 调整代码结构,增强可读性与维护性
This commit is contained in:
@@ -455,15 +455,34 @@ 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) {
|
||||
// 锁定状态=0 → 被占用
|
||||
boolean isOccupied = parent.getIsEnabled() != null && parent.getIsEnabled() == 0;
|
||||
if (isOccupied) {
|
||||
occupiedCodes.add(parent.getActualWarehouseCode());
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 存在被占用的父库位,抛出异常提示
|
||||
if (!occupiedCodes.isEmpty()) {
|
||||
throw new ServiceException("以下父库位被占用,无法拆分:" + String.join(",", occupiedCodes));
|
||||
}
|
||||
// 批量查询所有子库位(一次性查询,避免循环查询)
|
||||
List<Long> parentIds = columnLocations.stream()
|
||||
.map(WmsActualWarehouse::getActualWarehouseId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
List<WmsActualWarehouse> allChildren = baseMapper.selectList(Wrappers.<WmsActualWarehouse>lambdaQuery()
|
||||
.in(WmsActualWarehouse::getParentId, parentIds)
|
||||
.eq(WmsActualWarehouse::getActualWarehouseType, 4)); // 四级子库位
|
||||
|
||||
|
||||
boolean hasExistingChildren = CollUtil.isNotEmpty(allChildren);
|
||||
|
||||
if (hasExistingChildren) {
|
||||
@@ -498,11 +517,11 @@ public class WmsActualWarehouseServiceImpl implements IWmsActualWarehouseService
|
||||
.collect(Collectors.groupingBy(WmsActualWarehouse::getParentId, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
List<WmsActualWarehouse> toUpdate = new ArrayList<>();
|
||||
|
||||
|
||||
for (WmsActualWarehouse location : columnLocations) {
|
||||
boolean isSplitLocation = splitIds.contains(location.getActualWarehouseId());
|
||||
List<WmsActualWarehouse> children = childrenByParent.get(location.getActualWarehouseId());
|
||||
|
||||
|
||||
if (CollUtil.isEmpty(children)) {
|
||||
continue;
|
||||
}
|
||||
@@ -536,7 +555,7 @@ public class WmsActualWarehouseServiceImpl implements IWmsActualWarehouseService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 批量更新
|
||||
if (!toUpdate.isEmpty()) {
|
||||
baseMapper.updateBatchById(toUpdate);
|
||||
@@ -693,7 +712,7 @@ public class WmsActualWarehouseServiceImpl implements IWmsActualWarehouseService
|
||||
List<Long> parentIds = locationsToMerge.stream()
|
||||
.map(WmsActualWarehouse::getActualWarehouseId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
List<WmsActualWarehouse> allChildren = baseMapper.selectList(Wrappers.<WmsActualWarehouse>lambdaQuery()
|
||||
.in(WmsActualWarehouse::getParentId, parentIds)
|
||||
.eq(WmsActualWarehouse::getActualWarehouseType, 4)); // 四级子库位
|
||||
@@ -721,7 +740,7 @@ public class WmsActualWarehouseServiceImpl implements IWmsActualWarehouseService
|
||||
|
||||
for (WmsActualWarehouse location : locationsToMerge) {
|
||||
List<WmsActualWarehouse> children = childrenByParent.get(location.getActualWarehouseId());
|
||||
|
||||
|
||||
// 隐藏所有子库位
|
||||
if (CollUtil.isNotEmpty(children)) {
|
||||
for (WmsActualWarehouse child : children) {
|
||||
|
||||
Reference in New Issue
Block a user