按客户预约库存分配库存;
This commit is contained in:
+1
-1
@@ -85,7 +85,7 @@ public class RemoteWmsFallbackFactory implements FallbackFactory<WmsServiceFeign
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult execution(StockOutOrderDTO stockOutOrderDTO) {
|
public AjaxResult execution(StockOutOrderDTO stockOutOrderDTO) {
|
||||||
return null;
|
return AjaxResult.error(cause.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+6
@@ -251,9 +251,15 @@ public class ReservationStockOutOrderApplicationService {
|
|||||||
shipperParam(stockOutOrderDO);
|
shipperParam(stockOutOrderDO);
|
||||||
//设置客户信息
|
//设置客户信息
|
||||||
//customerParam(stockOutOrderDO);
|
//customerParam(stockOutOrderDO);
|
||||||
|
if (stockOutOrderDO.getOrderTypeCode() == null) {
|
||||||
stockOutOrderDO.setOrderTypeCode("pu_tong_chu_ku");
|
stockOutOrderDO.setOrderTypeCode("pu_tong_chu_ku");
|
||||||
|
}
|
||||||
|
if (stockOutOrderDO.getBusinessType() == null) {
|
||||||
stockOutOrderDO.setBusinessType("pu_tong_chu_ku");
|
stockOutOrderDO.setBusinessType("pu_tong_chu_ku");
|
||||||
|
}
|
||||||
|
if (stockOutOrderDO.getOrderTypeName() == null) {
|
||||||
stockOutOrderDO.setOrderTypeName("普通出库");
|
stockOutOrderDO.setOrderTypeName("普通出库");
|
||||||
|
}
|
||||||
//设置数据字典键值
|
//设置数据字典键值
|
||||||
//setDataDict(stockOutOrderDO);
|
//setDataDict(stockOutOrderDO);
|
||||||
return stockOutOrderDomainService.insert(stockOutOrderDO);
|
return stockOutOrderDomainService.insert(stockOutOrderDO);
|
||||||
|
|||||||
+11
-15
@@ -989,24 +989,23 @@ public class StockOutOrderApplicationService {
|
|||||||
// if (materialInventories == null || materialInventories.isEmpty()) {
|
// if (materialInventories == null || materialInventories.isEmpty()) {
|
||||||
// throw new ServiceException("库存不存在:" + batchRefNo + " " + sheetRefNo + " " + boxPalletNo);
|
// throw new ServiceException("库存不存在:" + batchRefNo + " " + sheetRefNo + " " + boxPalletNo);
|
||||||
// }
|
// }
|
||||||
|
Long materialInventoryId = detail.getMaterialInventoryId();
|
||||||
|
MaterialInventory materialInventory = materialInventoryMapper.selectById(materialInventoryId);
|
||||||
BigDecimal remainingQuantity = detail.getQuantity(); // 计划数量
|
BigDecimal remainingQuantity = detail.getQuantity(); // 计划数量
|
||||||
for (MaterialInventory materialInventory : materialInventories) {
|
|
||||||
if (remainingQuantity.compareTo(BigDecimal.ZERO) <= 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// 当前物料的可用库存
|
// 当前物料的可用库存
|
||||||
BigDecimal availableStock = materialInventory.getAllocationQuantity();
|
BigDecimal availableStock = materialInventory.getAllocationQuantity();
|
||||||
// 如果当前物料没有库存,跳过
|
// 如果当前物料没有库存,跳过
|
||||||
if (availableStock == null || availableStock.compareTo(BigDecimal.ZERO) <= 0) {
|
if (availableStock == null || availableStock.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 计算本次能扣减的数量:取 剩余计划 和 当前库存 的较小值
|
if (availableStock.compareTo(remainingQuantity) < 0) {
|
||||||
BigDecimal deductQuantity = remainingQuantity.compareTo(availableStock) <= 0
|
throw new RuntimeException(
|
||||||
? remainingQuantity // 剩余计划 <= 库存,扣剩余计划
|
String.format("可用库存不足,计划数量:%s,当前可用库存:%s",
|
||||||
: availableStock; // 剩余计划 > 库存,扣全部库存
|
remainingQuantity, availableStock)
|
||||||
|
);
|
||||||
detail.setMaterialInventoryId(materialInventory.getMaterialInventoryId());
|
}
|
||||||
|
// detail.setMaterialInventoryId(materialInventory.getMaterialInventoryId());
|
||||||
detail.setStorageLocationId(materialInventory.getStorageLocationId());
|
detail.setStorageLocationId(materialInventory.getStorageLocationId());
|
||||||
detail.setStorageLocationName(materialInventory.getStorageLocationName());
|
detail.setStorageLocationName(materialInventory.getStorageLocationName());
|
||||||
detail.setStorageLocationCode(materialInventory.getStorageLocationCode());
|
detail.setStorageLocationCode(materialInventory.getStorageLocationCode());
|
||||||
@@ -1014,11 +1013,8 @@ public class StockOutOrderApplicationService {
|
|||||||
detail.setStorageName(materialInventory.getStorageName());
|
detail.setStorageName(materialInventory.getStorageName());
|
||||||
detail.setStorageCode(materialInventory.getStorageCode());
|
detail.setStorageCode(materialInventory.getStorageCode());
|
||||||
detail.setInventoryQuantity(materialInventory.getInventoryQuantity());
|
detail.setInventoryQuantity(materialInventory.getInventoryQuantity());
|
||||||
detail.setAllocationQuantity(deductQuantity);
|
detail.setAllocationQuantity(remainingQuantity);
|
||||||
materialDetailList2.add(detail);
|
materialDetailList2.add(detail);
|
||||||
// 更新剩余计划数量
|
|
||||||
remainingQuantity = remainingQuantity.subtract(deductQuantity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
stockOutOrderD.setMaterialDetailList(materialDetailList2);
|
stockOutOrderD.setMaterialDetailList(materialDetailList2);
|
||||||
StockOutOrderDO assembleStockOutOrderDO = assembleParamByOutOrder(stockOutOrderD);
|
StockOutOrderDO assembleStockOutOrderDO = assembleParamByOutOrder(stockOutOrderD);
|
||||||
|
|||||||
Reference in New Issue
Block a user