库存操作记录;

This commit is contained in:
王奎兴
2026-01-28 09:52:24 +08:00
parent 277dc19988
commit d7e5699410
2 changed files with 76 additions and 1 deletions
@@ -9,10 +9,15 @@ import com.mhd.wms.domain.handoverTaskOrder.entity.HandoverTaskOrder;
import com.mhd.wms.domain.handoverTaskOrder.repository.facade.IHandoverTaskOrderService;
import com.mhd.wms.domain.handoverTaskOrder.repository.po.HandoverTaskOrderPO;
import com.mhd.wms.domain.handoverTaskOrder.repository.todo.HandoverTaskOrderDO;
import com.mhd.wms.domain.inventoryAdjustmentRecord.entity.InventoryAdjustmentRecord;
import com.mhd.wms.domain.inventoryAdjustmentRecord.repository.mapper.InventoryAdjustmentRecordMapper;
import com.mhd.wms.domain.materialInventory.entity.MaterialInventory;
import com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryMapper;
import com.mhd.wms.domain.outMaterialDetail.entity.OutMaterialDetail;
import com.mhd.wms.domain.outMaterialDetail.repository.mapper.OutMaterialDetailMapper;
import com.mhd.wms.domain.stockOutOrder.entity.StockOutOrder;
import com.mhd.wms.domain.stockOutOrder.repository.mapper.StockOutOrderMapper;
import com.mhd.wms.domain.stockOutOrder.repository.po.StockOutOrderPO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -37,6 +42,10 @@ public class HandoverTaskOrderDomainService {
private MaterialInventoryMapper materialInventoryMapper;
@Autowired
private OutMaterialDetailMapper outMaterialDetailMapper;
@Autowired
private InventoryAdjustmentRecordMapper inventoryAdjustmentRecordMapper;
@Autowired
private StockOutOrderMapper stockOutOrderMapper;
/**
@@ -133,6 +142,7 @@ public class HandoverTaskOrderDomainService {
if (handoverTaskOrderIds == null || handoverTaskOrderIds.size() == 0) {
return false;
}
LoginUser loginUser = SecurityUtils.getLoginUser();
for (Long handoverTaskOrderId : handoverTaskOrderIds) {
HandoverTaskOrder handoverTaskOrder = handoverTaskOrderService.getById(handoverTaskOrderId);
if (handoverTaskOrder == null) {
@@ -140,6 +150,8 @@ public class HandoverTaskOrderDomainService {
}
//交接完成节点修改库存
String orderNumber = handoverTaskOrder.getOrderNumber();
StockOutOrder stockOutOrder = stockOutOrderMapper.selectOne(new QueryWrapper<StockOutOrder>().lambda()
.eq(StockOutOrder::getOutOrderNumber, orderNumber));
List<OutMaterialDetail> outMaterialDetailList = outMaterialDetailMapper.selectList(new QueryWrapper<OutMaterialDetail>().lambda()
.eq(OutMaterialDetail::getOutOrderNumber, orderNumber));
for (OutMaterialDetail outMaterialDetail : outMaterialDetailList) {
@@ -161,10 +173,39 @@ public class HandoverTaskOrderDomainService {
MaterialInventory materialInventory = new MaterialInventory();
BeanUtils.copyProperties(materialInventoryPO, materialInventory);
materialInventoryMapper.updateById(materialInventory);
//库存调整记录
InventoryAdjustmentRecord inventoryAdjustmentRecord = new InventoryAdjustmentRecord();
inventoryAdjustmentRecord.setOrganizationId(stockOutOrder.getOrganizationId());
inventoryAdjustmentRecord.setOrganizationName(stockOutOrder.getOrganizationName());
inventoryAdjustmentRecord.setTopOrganizationId(stockOutOrder.getTopOrganizationId());
inventoryAdjustmentRecord.setWarehouseCode(materialInventoryPO.getWarehouseCode());
inventoryAdjustmentRecord.setWarehouseName(materialInventoryPO.getWarehouseName());
inventoryAdjustmentRecord.setWarehouseId(materialInventoryPO.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(materialInventoryPO.getAllocationQuantity());
inventoryAdjustmentRecord.setAllocationBeforeQuantity(materialInventoryPO.getAllocationQuantity());
inventoryAdjustmentRecord.setFreezeBeforeQuantity(oldFreezeQuantity);
inventoryAdjustmentRecord.setFreezeAfterQuantity(newFreezeQuantity);
inventoryAdjustmentRecord.setInventoryBeforeQuantity(oldInventoryQuantity);
inventoryAdjustmentRecord.setInventoryAfterQuantity(newInventoryQuantity);
inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord);
}
}
}
LoginUser loginUser = SecurityUtils.getLoginUser();
return handoverTaskOrderService.update(null, new UpdateWrapper<HandoverTaskOrder>().lambda()
.set(HandoverTaskOrder::getStatus, 2)
.set(HandoverTaskOrder::getUpdateBy, loginUser.getUserid())
@@ -12,6 +12,8 @@ import com.mhd.common.core.utils.bean.BeanUtils;
import com.mhd.common.core.utils.uuid.IdGenerator;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import com.mhd.wms.domain.inventoryAdjustmentRecord.entity.InventoryAdjustmentRecord;
import com.mhd.wms.domain.inventoryAdjustmentRecord.repository.mapper.InventoryAdjustmentRecordMapper;
import com.mhd.wms.domain.materialInventory.entity.MaterialInventory;
import com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryMapper;
import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO;
@@ -58,6 +60,8 @@ public class OutMaterialDetailImpl extends ServiceImpl<OutMaterialDetailMapper,
private IdGenerator idGenerator;
@Autowired
private MaterialInventoryMapper materialInventoryMapper;
@Autowired
private InventoryAdjustmentRecordMapper inventoryAdjustmentRecordMapper;
/**
* 查询物料明细列表
@@ -298,6 +302,36 @@ public class OutMaterialDetailImpl extends ServiceImpl<OutMaterialDetailMapper,
MaterialInventory materialInventory = new MaterialInventory();
BeanUtils.copyProperties(materialInventoryPO, materialInventory);
materialInventoryMapper.updateById(materialInventory);
//库存调整记录
InventoryAdjustmentRecord inventoryAdjustmentRecord = new InventoryAdjustmentRecord();
inventoryAdjustmentRecord.setOrganizationId(stockOutOrderPO.getOrganizationId());
inventoryAdjustmentRecord.setOrganizationName(stockOutOrderPO.getOrganizationName());
inventoryAdjustmentRecord.setTopOrganizationId(stockOutOrderPO.getTopOrganizationId());
inventoryAdjustmentRecord.setWarehouseCode(stockOutOrderPO.getWarehouseCode());
inventoryAdjustmentRecord.setWarehouseName(stockOutOrderPO.getWarehouseName());
inventoryAdjustmentRecord.setWarehouseId(stockOutOrderPO.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(stockOutOrderPO.getShipperId());
inventoryAdjustmentRecord.setShipperName(stockOutOrderPO.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());
inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord);
}
}