|
@ -472,10 +472,8 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService |
|
|
Integer sharedAvailableStockNum = Optional.ofNullable(warehouseInventoryInquiry.getSharedAvailableStockNum()).orElse(0); |
|
|
Integer sharedAvailableStockNum = Optional.ofNullable(warehouseInventoryInquiry.getSharedAvailableStockNum()).orElse(0); |
|
|
|
|
|
|
|
|
Integer availableStockNum = Optional.ofNullable(warehouseInventoryInquiry.getAvailableStockNum()).orElse(0); |
|
|
Integer availableStockNum = Optional.ofNullable(warehouseInventoryInquiry.getAvailableStockNum()).orElse(0); |
|
|
Integer lockStockNum = Optional.ofNullable(warehouseInventoryInquiry.getLockStockNum()).orElse(0); |
|
|
|
|
|
warehouseInventoryInquiry.setAvailableStockNum(availableStockNum - sharedInventoryOccupancyNum); |
|
|
warehouseInventoryInquiry.setAvailableStockNum(availableStockNum - sharedInventoryOccupancyNum); |
|
|
warehouseInventoryInquiry.setSharedAvailableStockNum(sharedAvailableStockNum - sharedInventoryOccupancyNum); |
|
|
warehouseInventoryInquiry.setSharedAvailableStockNum(sharedAvailableStockNum - sharedInventoryOccupancyNum); |
|
|
warehouseInventoryInquiry.setLockStockNum(lockStockNum + sharedInventoryOccupancyNum); |
|
|
|
|
|
warehouseInventoryInquiry.setNoOccupancyNum(sharedAvailableStockNum - sharedInventoryOccupancyNum); |
|
|
warehouseInventoryInquiry.setNoOccupancyNum(sharedAvailableStockNum - sharedInventoryOccupancyNum); |
|
|
warehouseInventoryInquiry.setUpdateTime(new Date()); |
|
|
warehouseInventoryInquiry.setUpdateTime(new Date()); |
|
|
warehouseInventoryInquiry.setUpdateBy(ShiroUtils.getLoginName()); |
|
|
warehouseInventoryInquiry.setUpdateBy(ShiroUtils.getLoginName()); |
|
@ -753,7 +751,6 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService |
|
|
/** |
|
|
/** |
|
|
* 采购订单审核通过,需要更新库存查询数据 |
|
|
* 采购订单审核通过,需要更新库存查询数据 |
|
|
* */ |
|
|
* */ |
|
|
|
|
|
|
|
|
private void purchaseOrderAuditApprove(PurchaseOrder purchaseOrder) { |
|
|
private void purchaseOrderAuditApprove(PurchaseOrder purchaseOrder) { |
|
|
|
|
|
|
|
|
Long purchaseOrderId = purchaseOrder.getPurchaseOrderId(); |
|
|
Long purchaseOrderId = purchaseOrder.getPurchaseOrderId(); |
|
@ -761,36 +758,34 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService |
|
|
|
|
|
|
|
|
String purchaseOrderCode = purchaseOrderVo.getPurchaseOrderCode(); |
|
|
String purchaseOrderCode = purchaseOrderVo.getPurchaseOrderCode(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//得到采购订单子表的数据
|
|
|
//得到采购订单子表的数据
|
|
|
List<PurchaseOrderChild> purchaseOrderChildList = purchaseOrderChildMapper.selectPurchaseOrderChildByOrderCode(purchaseOrderCode); |
|
|
List<PurchaseOrderChild> purchaseOrderChildList = purchaseOrderChildMapper.selectPurchaseOrderChildByOrderCode(purchaseOrderCode); |
|
|
|
|
|
|
|
|
String purchasePlanCode = purchaseOrderVo.getPurchasePlanCode(); |
|
|
for (PurchaseOrderChild purchaseOrderChild : purchaseOrderChildList) { |
|
|
|
|
|
String materialNo = purchaseOrderChild.getMaterialNo(); |
|
|
//得到采购计划单号的集合
|
|
|
Integer sharedInventoryOccupancyNum = purchaseOrderChild.getSharedInventoryOccupancyNum(); |
|
|
List<String> purchasePlanCodeList = new ArrayList<>(); |
|
|
WarehouseInventoryInquiry warehouseInventoryInquiry = inventoryInquiryMapper.selectWarehouseInventoryInquiryByMaterialNo(materialNo); |
|
|
|
|
|
if (warehouseInventoryInquiry != null && sharedInventoryOccupancyNum > 0){ |
|
|
|
|
|
updateStockNumbers(warehouseInventoryInquiry, sharedInventoryOccupancyNum); |
|
|
|
|
|
warehouseInventoryInquiry.setUpdateBy(ShiroUtils.getLoginName()); |
|
|
|
|
|
warehouseInventoryInquiry.setUpdateTime(new Date()); |
|
|
|
|
|
int result = inventoryInquiryMapper.updateWarehouseInventoryInquiry(warehouseInventoryInquiry); |
|
|
|
|
|
if (result <= 0){ |
|
|
|
|
|
throw new BusinessException("更新库存查询记录失败"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(purchasePlanCode)){ |
|
|
|
|
|
String[] splitSalesOrderCode = purchasePlanCode.split(","); |
|
|
|
|
|
purchasePlanCodeList = Arrays.asList(splitSalesOrderCode); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 得到采购计划主表数据
|
|
|
//计算可用库存和固定可用库存
|
|
|
List<PurchasePlan> purchasePlanList = purchasePlanMapper.selectPurchaseOrderByPlanCodeList(purchasePlanCodeList); |
|
|
private void updateStockNumbers(WarehouseInventoryInquiry inquiry, Integer occupancyNum) { |
|
|
// 得到采购计划子表数据
|
|
|
Integer fixedAvailableStockNum = inquiry.getFixedAvailableStockNum() != null ? inquiry.getFixedAvailableStockNum() : 0; |
|
|
List<PurchasePlanChild> purchasePlanChildList = purchasePlanChildMapper.selectPurchasePlanChildPlanCodeList(purchasePlanCodeList); |
|
|
Integer availableStockNum = inquiry.getAvailableStockNum() != null ? inquiry.getAvailableStockNum() : 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建一个 map 用于快速查找采购计划子表数据
|
|
|
|
|
|
Map<String, List<PurchasePlanChild>> purchasePlanChildMap = purchasePlanChildList.stream() |
|
|
|
|
|
.collect(Collectors.groupingBy(PurchasePlanChild::getPurchasePlanCode)); |
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
// for (PurchasePlanChild purchasePlanChild : purchasePlanChildList) {
|
|
|
|
|
|
//
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inquiry.setFixedAvailableStockNum(fixedAvailableStockNum + occupancyNum); |
|
|
|
|
|
inquiry.setAvailableStockNum(availableStockNum + occupancyNum); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|