fix(wms): 解决库存批量更新问题

- 将 updateBatchById 方法替换为单个 updateById 的循环调用
- 添加更新失败时的业务异常处理
- 确保每次更新失败都能抛出 "库存更新失败" 错误信息
- 提高了库存更新操作的可靠性和错误处理能力
This commit is contained in:
曹鹏飞 2026-02-25 09:05:47 +08:00
parent 94594abdf1
commit 7b31d1cf77
1 changed files with 6 additions and 2 deletions

View File

@ -86,7 +86,9 @@ public class WmsInventoryServiceImpl extends ServiceImpl<WmsInventoryMapper, Wms
if (CollectionUtil.isNotEmpty(forDelete)) { if (CollectionUtil.isNotEmpty(forDelete)) {
removeBatchByIds(forDelete); removeBatchByIds(forDelete);
} }
updateBatchById(dbInventories); dbInventories.forEach(inventory -> {
VUtil.trueThrowBusinessError(!updateById(inventory)).throwMessage("库存更新失败");
});
} }
@Transactional @Transactional
@ -130,7 +132,9 @@ public class WmsInventoryServiceImpl extends ServiceImpl<WmsInventoryMapper, Wms
saveBatch(forAdd); saveBatch(forAdd);
} }
if (CollectionUtil.isNotEmpty(forUpdate)) { if (CollectionUtil.isNotEmpty(forUpdate)) {
updateBatchById(forUpdate); forUpdate.forEach(inventory -> {
VUtil.trueThrowBusinessError(!updateById(inventory)).throwMessage("库存更新失败");
});
} }
} }