feat(wms): 增加库位拆分前的占用状态校验
- 在拆分逻辑中增加对父库位占用状态的批量校验 - 若父库位被占用则抛出明确提示异常 - 优化库位拆分与合并时的子库位查询逻辑 - 统一处理拆分与合并操作中的空子库位判断 - 调整代码结构,增强可读性与维护性
This commit is contained in:
@@ -455,6 +455,25 @@ public class WmsActualWarehouseServiceImpl implements IWmsActualWarehouseService
|
|||||||
throw new ServiceException("未找到列标识为 " + columnFlag + " 的库位");
|
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()
|
List<Long> parentIds = columnLocations.stream()
|
||||||
.map(WmsActualWarehouse::getActualWarehouseId)
|
.map(WmsActualWarehouse::getActualWarehouseId)
|
||||||
|
|||||||
Reference in New Issue
Block a user