fix(inventory): 解决库存不足时的错误处理和查询逻辑

- 在OutAssistanceController中添加库存不足验证和错误提示
- 在OutCostCenterController中添加库存不足验证和错误提示
- 在OutProduceController中添加库存不足验证和错误提示
- 在TransferCompanyController中添加库存不足验证和错误提示
- 在TransferFactoryController中添加库存不足验证和错误提示
- 在WmsReturnRequestServiceImpl中添加库存不足验证和错误提示
- 修复WmsWarehouseMapper.xml中的仓库名称查询SQL逻辑
- 统一库存锁定列表的获取和验证流程
This commit is contained in:
曹鹏飞 2026-03-23 21:17:50 +08:00
parent 448577914d
commit 5ae75d46c0
7 changed files with 26 additions and 10 deletions

View File

@ -344,7 +344,9 @@ public class OutAssistanceController extends BaseController {
// 等待5秒获取锁10秒后自动释放
if (lock.tryLock(5, 10, TimeUnit.SECONDS)) {
if (inventoryService.getNumOne(info.getFactoryNo(), info.getWarehouseNo(), info.getMaterialNo()).compareTo(lockNum) < 0) {
lockVOS.addAll(inventoryService.getLockList(info.getFactoryNo(), info.getWarehouseNo(), info.getMaterialNo()));
List<InventoryLockVO> itemLocks = inventoryService.getLockList(info.getFactoryNo(), info.getWarehouseNo(), info.getMaterialNo());
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(itemLocks)).throwMessage("库存不足:" + info.getMaterialNo());
lockVOS.addAll(itemLocks);
}
} else {
throw new NflgException(STATE.BusinessError, "获取锁失败");

View File

@ -338,7 +338,9 @@ public class OutCostCenterController extends BaseController {
// 等待5秒获取锁10秒后自动释放
if (lock.tryLock(5, 10, TimeUnit.SECONDS)) {
if (inventoryService.getNumOne(info.getFactoryNo(), info.getWarehouseNo(), info.getMaterialNo()).compareTo(lockNum) < 0) {
lockVOS.addAll(inventoryService.getLockList(info.getFactoryNo(), info.getWarehouseNo(), info.getMaterialNo()));
List<InventoryLockVO> itemLocks = inventoryService.getLockList(info.getFactoryNo(), info.getWarehouseNo(), info.getMaterialNo());
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(itemLocks)).throwMessage("库存不足:" + info.getMaterialNo());
lockVOS.addAll(itemLocks);
}
} else {
throw new NflgException(STATE.BusinessError, "获取锁失败");

View File

@ -166,7 +166,9 @@ public class OutProduceController extends BaseController {
if (inventoryService.getNumOne(item.getDwerk(), item.getLgort2(), item.getMatnr())
.compareTo(item.getSqsl()) < 0
) {
lockVOS.addAll(inventoryService.getLockList(item.getDwerk(), item.getLgort2(), item.getMatnr()));
List<InventoryLockVO> itemLocks = inventoryService.getLockList(item.getDwerk(), item.getLgort2(), item.getMatnr());
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(itemLocks)).throwMessage("库存不足:" + item.getMatnr());
lockVOS.addAll(itemLocks);
} else {
WmsOutProduceItem data = Convert.convert(WmsOutProduceItem.class, item);
data.setLockNum(item.getSqsl());
@ -225,7 +227,9 @@ public class OutProduceController extends BaseController {
if (inventoryService.getNumOne(item.getDwerk(), item.getLgort2(), item.getMatnr())
.compareTo(item.getSqsl()) < 0
) {
lockVOS.addAll(inventoryService.getLockList(item.getDwerk(), item.getLgort2(), item.getMatnr()));
List<InventoryLockVO> itemLocks = inventoryService.getLockList(item.getDwerk(), item.getLgort2(), item.getMatnr());
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(itemLocks)).throwMessage("库存不足:" + item.getMatnr());
lockVOS.addAll(itemLocks);
} else {
WmsOutProduceItem data = Convert.convert(WmsOutProduceItem.class, item);
data.setLockNum(data.getSqsl());

View File

@ -144,7 +144,9 @@ public class TransferCompanyController extends BaseController {
if (inventoryService.getNumOne(item.getReswk(), item.getLgfsb1(), item.getMatnr())
.compareTo(item.getNum()) < 0
) {
lockVOS.addAll(inventoryService.getLockList(item.getReswk(), item.getLgfsb1(), item.getMatnr()));
List<InventoryLockVO> itemLocks = inventoryService.getLockList(item.getReswk(), item.getLgfsb1(), item.getMatnr());
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(itemLocks)).throwMessage("库存不足:" + item.getMatnr());
lockVOS.addAll(itemLocks);
} else {
WmsTransferCompanyItem data = Convert.convert(WmsTransferCompanyItem.class, item);
data.setOrderId(order.getId());

View File

@ -142,7 +142,9 @@ public class TransferFactoryController extends BaseController {
if (inventoryService.getNumOne(item.getWerks(), item.getLgort(), item.getMatnr())
.compareTo(item.getNum()) < 0
) {
lockVOS.addAll(inventoryService.getLockList(item.getWerks(), item.getLgort(), item.getMatnr()));
List<InventoryLockVO> itemLocks = inventoryService.getLockList(item.getWerks(), item.getLgort(), item.getMatnr());
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(itemLocks)).throwMessage("库存不足:" + item.getMatnr());
lockVOS.addAll(itemLocks);
} else {
WmsTransferFactoryItem data = Convert.convert(WmsTransferFactoryItem.class, item);
data.setOrderId(order.getId());

View File

@ -17,6 +17,7 @@ import com.nflg.wms.common.pojo.qo.GoodsReceiptSearchQO;
import com.nflg.wms.common.pojo.vo.ApplyReturnRequestVO;
import com.nflg.wms.common.pojo.vo.GoodsReceiptVO;
import com.nflg.wms.common.pojo.vo.InventoryLockVO;
import com.nflg.wms.common.util.VUtil;
import com.nflg.wms.repository.entity.WmsOutProduceItem;
import com.nflg.wms.repository.entity.WmsReturnRequest;
import com.nflg.wms.repository.entity.WmsReturnRequestItem;
@ -71,7 +72,9 @@ public class WmsReturnRequestServiceImpl extends ServiceImpl<WmsReturnRequestMap
if (inventoryService.getNumOne(item.getFactoryCode(), item.getStorageLocation(), item.getMaterialCode())
.compareTo(item.getLeft()) < 0
) {
lockVOS.addAll(inventoryService.getLockList(item.getFactoryCode(), item.getStorageLocation(), item.getMaterialCode()));
List<InventoryLockVO> itemLocks = inventoryService.getLockList(item.getFactoryCode(), item.getStorageLocation(), item.getMaterialCode());
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(itemLocks)).throwMessage("库存不足:" + item.getMaterialCode());
lockVOS.addAll(itemLocks);
} else {
itemService.save(item);
}

View File

@ -86,9 +86,10 @@
</select>
<select id="getWname" resultType="java.lang.String">
SELECT name
FROM wms_inventory a,dictonary_item b
WHERE a.factory_no=b.id AND a.warehouse_no=#{warehouseNo} AND a.no=#{factoryNo}
SELECT wh.name
FROM wms_warehouse wh
LEFT JOIN dictionary_item di ON wh.factory_id=di.id
WHERE di.code=#{factoryNo} AND wh.no=#{warehouseNo}
</select>
</mapper>