分配问题修改;
This commit is contained in:
+77
-4
@@ -542,6 +542,7 @@ public class OutMaterialDetailImpl extends ServiceImpl<OutMaterialDetailMapper,
|
||||
BigDecimal allocationQuantity = outMaterialDetailDO.getActualQuantity();
|
||||
BigDecimal alreadyAllocationQuantity = outMaterialDetailDO.getAlreadyAllocationQuantity();
|
||||
List<OutMaterialDetailDO> materialDetailDOChildList = outMaterialDetailDO.getChildren();
|
||||
BigDecimal childAllocationQuantity = BigDecimal.ZERO;
|
||||
if (!CollectionUtils.isEmpty(materialDetailDOChildList)){
|
||||
for (OutMaterialDetailDO outMaterialDetailDOChild : materialDetailDOChildList){
|
||||
OutMaterialDetail outMaterialDetailChildDb = materialDetailMap.get(outMaterialDetailDOChild.getMaterialDetailId());
|
||||
@@ -596,6 +597,7 @@ public class OutMaterialDetailImpl extends ServiceImpl<OutMaterialDetailMapper,
|
||||
materialDetailIdsByUpdate.add(outMaterialDetailDOChild.getMaterialDetailId());
|
||||
allocationQuantity = allocationQuantity.add(childCancelQty);
|
||||
alreadyAllocationQuantity = alreadyAllocationQuantity.add(childCancelQty);
|
||||
childAllocationQuantity = childAllocationQuantity.add(childDbAllocationQty);
|
||||
}
|
||||
}
|
||||
//判断取消分配数量不能大于已分配数量(取消分配应该检查alreadyAllocationQuantity,而不是allocationQuantity)
|
||||
@@ -610,7 +612,7 @@ public class OutMaterialDetailImpl extends ServiceImpl<OutMaterialDetailMapper,
|
||||
: BigDecimal.ZERO;
|
||||
// 分配数量和已分配数量都减少:本次手动取消分配视为“把这条明细已分配的全部撤回”
|
||||
BigDecimal newAllocationQuantity = dbAllocationQuantity.subtract(allocationQuantity);
|
||||
if (newAllocationQuantity.compareTo(BigDecimal.ZERO) < 0) {
|
||||
if ((newAllocationQuantity.add(childAllocationQuantity)).compareTo(BigDecimal.ZERO) < 0) {
|
||||
throw new ServiceException("物料" + outMaterialDetailDb.getMaterialName() + ",取消分配数量不能大于分配总数");
|
||||
}
|
||||
outMaterialDetail.setAllocationQuantity(newAllocationQuantity);
|
||||
@@ -673,8 +675,80 @@ public class OutMaterialDetailImpl extends ServiceImpl<OutMaterialDetailMapper,
|
||||
BigDecimal newFreezeQuantity = oldFreezeQuantity.subtract(allocationQuantity);
|
||||
materialInventoryPO.setAllocationQuantity(newAllocationQuantity);
|
||||
materialInventoryPO.setFreezeQuantity(newFreezeQuantity);
|
||||
//MaterialInventory materialInventory = new MaterialInventory();
|
||||
//BeanUtils.copyProperties(materialInventoryPO, materialInventory);
|
||||
materialInventoryMapper.updateById(materialInventoryPO);
|
||||
|
||||
|
||||
|
||||
//库存调整记录
|
||||
InventoryAdjustmentRecord inventoryAdjustmentRecord = new InventoryAdjustmentRecord();
|
||||
inventoryAdjustmentRecord.setAdjustAfterStatusCode("he_ge");
|
||||
inventoryAdjustmentRecord.setAdjustBeforeStatusCode("he_ge");
|
||||
inventoryAdjustmentRecord.setAdjustAfterStatusName("合格");
|
||||
inventoryAdjustmentRecord.setAdjustBeforeStatusName("合格");
|
||||
inventoryAdjustmentRecord.setAdjustType(1L);
|
||||
inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId());
|
||||
inventoryAdjustmentRecord.setMaterialCode(outMaterialDetail.getMaterialNo());
|
||||
inventoryAdjustmentRecord.setMaterialName(outMaterialDetail.getCommodityName());
|
||||
inventoryAdjustmentRecord.setBarCode(outMaterialDetail.getBarCode());
|
||||
inventoryAdjustmentRecord.setMaterialBaseInfoId(outMaterialDetail.getMaterialBaseInfoId());
|
||||
inventoryAdjustmentRecord.setOrganizationId(stockOutOrder.getOrganizationId());
|
||||
inventoryAdjustmentRecord.setOrganizationName(stockOutOrder.getOrganizationName());
|
||||
inventoryAdjustmentRecord.setTopOrganizationId(stockOutOrder.getTopOrganizationId());
|
||||
inventoryAdjustmentRecord.setWarehouseCode(stockOutOrder.getWarehouseCode());
|
||||
inventoryAdjustmentRecord.setWarehouseName(stockOutOrder.getWarehouseName());
|
||||
inventoryAdjustmentRecord.setWarehouseId(stockOutOrder.getWarehouseId());
|
||||
inventoryAdjustmentRecord.setStorageCode(materialInventoryPO.getStorageCode());
|
||||
inventoryAdjustmentRecord.setStorageName(materialInventoryPO.getStorageName());
|
||||
inventoryAdjustmentRecord.setStorageLocationId(materialInventoryPO.getStorageLocationId());
|
||||
inventoryAdjustmentRecord.setStorageLocationCode(materialInventoryPO.getStorageLocationCode());
|
||||
inventoryAdjustmentRecord.setStorageLocationName(materialInventoryPO.getStorageLocationName());
|
||||
inventoryAdjustmentRecord.setMaterialInventoryId(materialInventoryPO.getMaterialInventoryId());
|
||||
inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId());
|
||||
inventoryAdjustmentRecord.setShipperId(stockOutOrder.getShipperId());
|
||||
inventoryAdjustmentRecord.setShipperName(stockOutOrder.getShipperName());
|
||||
inventoryAdjustmentRecord.setStorageSectionId(materialInventoryPO.getStorageSectionId());
|
||||
inventoryAdjustmentRecord.setStorageLocationId(materialInventoryPO.getStorageLocationId());
|
||||
inventoryAdjustmentRecord.setCreateBy(loginUser.getUserid());
|
||||
inventoryAdjustmentRecord.setCreateByName(loginUser.getUsername());
|
||||
inventoryAdjustmentRecord.setCreateTime(new Date());
|
||||
inventoryAdjustmentRecord.setAllocationAfterQuantity(newAllocationQuantity);
|
||||
inventoryAdjustmentRecord.setAllocationBeforeQuantity(oldAllocationQuantity);
|
||||
inventoryAdjustmentRecord.setFreezeBeforeQuantity(oldFreezeQuantity);
|
||||
inventoryAdjustmentRecord.setFreezeAfterQuantity(newFreezeQuantity);
|
||||
inventoryAdjustmentRecord.setInventoryBeforeQuantity(materialInventoryPO.getInventoryQuantity());
|
||||
inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventoryPO.getInventoryQuantity());
|
||||
inventoryAdjustmentRecord.setCreateBy(loginUser.getUserid());
|
||||
inventoryAdjustmentRecord.setCreateByName(loginUser.getUsername());
|
||||
inventoryAdjustmentRecord.setCreateTime(new Date());
|
||||
inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord);
|
||||
}
|
||||
|
||||
List<OutMaterialDetailDO> children = outMaterialDetail.getChildren();
|
||||
if (!CollectionUtils.isEmpty(children)) {
|
||||
childrenqxfp(children,outOrderNumber,loginUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private synchronized void childrenqxfp(List<OutMaterialDetailDO> outMaterialDetailList,String outOrderNumber,LoginUser loginUser) {
|
||||
StockOutOrder stockOutOrder = stockOutOrderMapper.selectOne(new QueryWrapper<StockOutOrder>().lambda().eq(StockOutOrder::getOutOrderNumber, outOrderNumber));
|
||||
for (OutMaterialDetailDO outMaterialDetail : outMaterialDetailList) {
|
||||
Long materialInventoryId = outMaterialDetail.getMaterialInventoryId();
|
||||
BigDecimal allocationQuantity = outMaterialDetail.getActualQuantity();
|
||||
MaterialInventory materialInventoryPO = materialInventoryMapper.selectById(materialInventoryId);
|
||||
if (materialInventoryPO != null) {
|
||||
//更新库存数量
|
||||
//可用数量
|
||||
BigDecimal oldAllocationQuantity = materialInventoryPO.getAllocationQuantity();
|
||||
//冻结数量
|
||||
BigDecimal oldFreezeQuantity = materialInventoryPO.getFreezeQuantity();
|
||||
//分配后可用数量
|
||||
BigDecimal newAllocationQuantity = oldAllocationQuantity.add(allocationQuantity);
|
||||
//分配后冻结数量
|
||||
BigDecimal newFreezeQuantity = oldFreezeQuantity.subtract(allocationQuantity);
|
||||
materialInventoryPO.setAllocationQuantity(newAllocationQuantity);
|
||||
materialInventoryPO.setFreezeQuantity(newFreezeQuantity);
|
||||
materialInventoryMapper.updateById(materialInventoryPO);
|
||||
|
||||
|
||||
@@ -724,7 +798,6 @@ public class OutMaterialDetailImpl extends ServiceImpl<OutMaterialDetailMapper,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 拣货批量修改物流明细
|
||||
* @author ZhouGY
|
||||
|
||||
Reference in New Issue
Block a user