liyong
2026-05-11 efdcd7a9eb1e0365bccb1390ee9febe7d1918dc7
fix(stock): 修复库存盘点锁定检查的空指针异常

- 添加 ObjectUtils 用于空值检查
- 在访问 stockInventory.getLocked() 之前验证对象不为空
- 防止因 stockInventory 为 null 导致的 NullPointerException
- 保持原有的库存盘点锁定逻辑不变
已修改1个文件
7 ■■■■ 文件已修改
src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java
@@ -30,6 +30,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import java.util.List;
@@ -193,8 +194,10 @@
                if ("0".equals(stockInRecord.getType())) {
                    // 合格入库 -> 先查库存,存在则更新,不存在则新增
                    StockInventory stockInventory = getStockInventory(stockInRecord.getProductModelId(), stockInRecord.getBatchNo());
                    if (stockInventory.getLocked().equals( true)&&!stockInRecord.getRecordType().equals(StockInQualifiedRecordTypeEnum.INVENTORY_CHECK_STOCK_IN.getCode())) {
                        throw new BaseException("正在库存盘点,无法入库,入库批次:" + stockInRecord.getInboundBatches());
                    if (!ObjectUtils.isEmpty(stockInventory)) {
                        if (stockInventory.getLocked().equals( true)&&!stockInRecord.getRecordType().equals(StockInQualifiedRecordTypeEnum.INVENTORY_CHECK_STOCK_IN.getCode())) {
                            throw new BaseException("正在库存盘点,无法入库,入库批次:" + stockInRecord.getInboundBatches());
                        }
                    }
                    StockInventoryDto stockInventoryDto = new StockInventoryDto();
                    stockInventoryDto.setProductModelId(stockInRecord.getProductModelId());