分配问题修改;

This commit is contained in:
王奎兴
2026-02-28 15:06:15 +08:00
parent 5b4c10b98e
commit b8f9156200
@@ -490,6 +490,93 @@ public class OutMaterialDetailImpl extends ServiceImpl<OutMaterialDetailMapper,
inventoryAdjustmentRecord.setCreateTime(new Date());
inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord);
}
Long uniqueId = outMaterialDetail.getUniqueId();
String outOrderNumber1 = outMaterialDetail.getOutOrderNumber();
List<OutMaterialDetail> outMaterialDetails = outMaterialDetailMapper.selectList(new QueryWrapper<OutMaterialDetail>().lambda().eq(OutMaterialDetail::getParentUniqueId, uniqueId).eq(OutMaterialDetail::getOutOrderNumber, outOrderNumber1));
if (!CollectionUtils.isEmpty(outMaterialDetails)) {
childrenxgkc(outMaterialDetails,outOrderNumber,loginUser);
}
}
}
public synchronized void childrenxgkc(List<OutMaterialDetail> outMaterialDetailList,String outOrderNumber,LoginUser loginUser) {
StockOutOrder stockOutOrder = stockOutOrderMapper.selectOne(new QueryWrapper<StockOutOrder>().lambda().eq(StockOutOrder::getOutOrderNumber, outOrderNumber));
for (OutMaterialDetail outMaterialDetail : outMaterialDetailList) {
BigDecimal nowAllocationQuantity = outMaterialDetail.getNowAllocationQuantity();
if (nowAllocationQuantity == null && nowAllocationQuantity.compareTo(BigDecimal.ZERO) <= 0) {
continue;
}
Long materialInventoryId = outMaterialDetail.getMaterialInventoryId();
//分配数量为本次分配数量
BigDecimal allocationQuantity = outMaterialDetail.getNowAllocationQuantity();
if (ObjectUtils.isEmpty(allocationQuantity)) {
allocationQuantity = BigDecimal.ZERO;
}
MaterialInventory materialInventoryPO = materialInventoryMapper.selectById(materialInventoryId);
if (materialInventoryPO != null) {
//更新库存数量
//可用数量
BigDecimal oldAllocationQuantity = materialInventoryPO.getAllocationQuantity();
//冻结数量
BigDecimal oldFreezeQuantity = materialInventoryPO.getFreezeQuantity();
//分配后可用数量
BigDecimal newAllocationQuantity = oldAllocationQuantity.subtract(allocationQuantity);
//分配后冻结数量
BigDecimal newFreezeQuantity = oldFreezeQuantity.add(allocationQuantity);
materialInventoryPO.setAllocationQuantity(newAllocationQuantity);
materialInventoryPO.setFreezeQuantity(newFreezeQuantity);
MaterialInventory materialInventory = new MaterialInventory();
BeanUtils.copyProperties(materialInventoryPO, materialInventory);
materialInventoryMapper.updateById(materialInventory);
//库存调整记录
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);
}
Long uniqueId = outMaterialDetail.getUniqueId();
String outOrderNumber1 = outMaterialDetail.getOutOrderNumber();
List<OutMaterialDetail> outMaterialDetails = outMaterialDetailMapper.selectList(new QueryWrapper<OutMaterialDetail>().lambda().eq(OutMaterialDetail::getParentUniqueId, uniqueId).eq(OutMaterialDetail::getOutOrderNumber, outOrderNumber1));
}
}