mirror of
https://github.com/zccbbg/wms-ruoyi.git
synced 2024-11-10 09:02:51 +08:00
feat: 删除校验库存的方法
This commit is contained in:
parent
a76885eb8e
commit
42c24f50de
3 changed files with 12 additions and 34 deletions
|
@ -148,24 +148,6 @@ public class InventoryService extends ServiceImpl<InventoryMapper, Inventory> {
|
|||
return inventoryMapper.exists(lqw);
|
||||
}
|
||||
|
||||
public void validateInventory(@NotNull Long warehouseId, @NotEmpty List<InventoryBo> inventoryBoList) {
|
||||
LambdaQueryWrapper<Inventory> inventoryLambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||
inventoryLambdaQueryWrapper.eq(Inventory::getWarehouseId, warehouseId);
|
||||
inventoryLambdaQueryWrapper.in(Inventory::getAreaId, inventoryBoList.stream().map(InventoryBo::getAreaId).toList());
|
||||
inventoryLambdaQueryWrapper.gt(Inventory::getQuantity, 0);
|
||||
List<Inventory> inventoryList = inventoryMapper.selectList(inventoryLambdaQueryWrapper);
|
||||
if (CollUtil.isEmpty(inventoryList)) {
|
||||
throw new BaseException("库存不足");
|
||||
}
|
||||
Map<String, Inventory> inventoryMap = inventoryList.stream().collect(Collectors.toMap(PlaceAndItem::getKey, Function.identity()));
|
||||
for (InventoryBo bo : inventoryBoList) {
|
||||
Inventory inventory = inventoryMap.get(bo.getKey());
|
||||
if (inventory == null || inventory.getQuantity().compareTo(bo.getQuantity()) < 0) {
|
||||
throw new BaseException("库存不足");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TableDataInfo<InventoryVo> queryWarehouseBoardList(InventoryBo bo, PageQuery pageQuery) {
|
||||
TableDataInfo<InventoryVo> tableDataInfo = TableDataInfo.build(inventoryMapper.selectBoardPageByWarehouse(pageQuery.build(), bo));
|
||||
if (CollUtil.isEmpty(tableDataInfo.getRows())) {
|
||||
|
|
|
@ -170,27 +170,25 @@ public class MovementOrderService {
|
|||
validateBeforeMove(bo);
|
||||
// 2.按源仓库库区规格合并商品明细数量
|
||||
List<List<InventoryBo>> mergedInventoryList = mergeMovementOrderDetailByPlaceAndItem(bo.getDetails());
|
||||
// 3.校验库存
|
||||
List<InventoryBo> mergedShipmentInventoryList = mergedInventoryList.get(0);
|
||||
inventoryService.validateInventory(bo.getSourceWarehouseId(), mergedShipmentInventoryList);
|
||||
// 4.校验库存记录
|
||||
// 3.校验库存记录
|
||||
List<InventoryDetailBo> inventoryDetailBoList = convertMovementOrderDetailToInventoryDetail(bo.getDetails());
|
||||
inventoryDetailService.validateRemainQuantity(inventoryDetailBoList);
|
||||
// 5.保存移库单核移库单明细
|
||||
// 4.保存移库单核移库单明细
|
||||
if (Objects.isNull(bo.getId())) {
|
||||
insertByBo(bo);
|
||||
} else {
|
||||
updateByBo(bo);
|
||||
}
|
||||
// 6.更新库存
|
||||
// 5.更新库存
|
||||
List<InventoryBo> mergedShipmentInventoryList = mergedInventoryList.get(0);
|
||||
mergedShipmentInventoryList.forEach(mergedShipmentInventory -> mergedShipmentInventory.setQuantity(mergedShipmentInventory.getQuantity().negate()));
|
||||
inventoryService.updateInventoryQuantity(mergedShipmentInventoryList);
|
||||
inventoryService.updateInventoryQuantity(mergedInventoryList.get(1));
|
||||
// 7.更新入库记录剩余数
|
||||
// 6.更新入库记录剩余数
|
||||
inventoryDetailMapper.updateRemainQuantity(inventoryDetailBoList, LoginHelper.getUsername(), LocalDateTime.now());
|
||||
// 8.创建入库记录
|
||||
// 7.创建入库记录
|
||||
createNewInventoryDetail(bo);
|
||||
// 9.创建库存记录
|
||||
// 8.创建库存记录
|
||||
saveInventoryHistory(bo);
|
||||
}
|
||||
|
||||
|
|
|
@ -157,23 +157,21 @@ public class ShipmentOrderService {
|
|||
validateBeforeShipment(bo);
|
||||
// 2.按仓库库区规格合并商品明细数量
|
||||
List<InventoryBo> mergedInventoryBoList = mergeShipmentOrderDetailByPlaceAndItem(bo.getDetails());
|
||||
// 3.校验库存
|
||||
inventoryService.validateInventory(bo.getWarehouseId(), mergedInventoryBoList);
|
||||
// 4.校验库存记录
|
||||
// 3.校验库存记录
|
||||
List<InventoryDetailBo> inventoryDetailBoList = convertShipmentOrderDetailToInventoryDetail(bo.getDetails());
|
||||
inventoryDetailService.validateRemainQuantity(inventoryDetailBoList);
|
||||
// 5. 保存入库单和入库单明细
|
||||
// 4. 保存入库单和入库单明细
|
||||
if (Objects.isNull(bo.getId())) {
|
||||
insertByBo(bo);
|
||||
} else {
|
||||
updateByBo(bo);
|
||||
}
|
||||
// 6.更新库存
|
||||
// 5.更新库存
|
||||
mergedInventoryBoList.forEach(mergedInventoryBo -> mergedInventoryBo.setQuantity(mergedInventoryBo.getQuantity().negate()));
|
||||
inventoryService.updateInventoryQuantity(mergedInventoryBoList);
|
||||
// 7.更新入库记录剩余数
|
||||
// 6.更新入库记录剩余数
|
||||
inventoryDetailMapper.updateRemainQuantity(inventoryDetailBoList, LoginHelper.getUsername(), LocalDateTime.now());
|
||||
// 8.创建库存记录
|
||||
// 7.创建库存记录
|
||||
saveInventoryHistory(bo);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue