fix(inventory):创建库存时,增加库存日志写入

This commit is contained in:
chengzhaofeng 2024-11-26 17:07:30 +08:00
parent fa9507b663
commit f3403d13fd
2 changed files with 9 additions and 16 deletions

View File

@ -84,20 +84,7 @@ public class ZWmsInventoryLogServiceImpl extends ServiceImpl<ZWmsInventoryLogMap
inventoryLog.setPreviousStatus(previousStatus);
inventoryLog.setStatus(inventory.getStatus());
inventoryLog.setChangeType(changeType);
if (StringUtil.notEmpty(previousStorageBinBo)) {
StorageBin storageBinGetById = storageBinService.getById(previousStorageBinBo);
StorageLocation storageLocation = storageLocationService.getById(storageBinGetById.getStorageLocationBo());
inventoryLog.setPreviousErpLocation(storageLocation.getErpStorageLocation());
inventoryLog.setPreviousStorageLocationBo(storageLocation.getHandle());
inventoryLog.setPreviousStorageBinBo(previousStorageBinBo);
}
if (StringUtil.notEmpty(currentStorageBinBo)) {
StorageBin storageBinGetById = storageBinService.getById(currentStorageBinBo);
StorageLocation storageLocation = storageLocationService.getById(storageBinGetById.getStorageLocationBo());
inventoryLog.setErpLocation(storageLocation.getErpStorageLocation());
inventoryLog.setStorageLocationBo(storageLocation.getHandle());
inventoryLog.setStorageBinBo(currentStorageBinBo);
}
inventoryLog.setErpLocation(StringUtil.getPart("StorageBinBO", currentStorageBinBo, 1));
inventoryLog.setBatchNo(inventory.getBatchNo());
inventoryLog.setOriginalQty(inventory.getOriginalQty());
inventoryLog.setPreviousQty(previousQty);

View File

@ -25,6 +25,7 @@ import com.foreverwin.mom.wms.dto.ScanCodeDTO;
import com.foreverwin.mom.wms.entity.Carrier;
import com.foreverwin.mom.wms.entity.Inventory;
import com.foreverwin.mom.wms.entity.InventoryLog;
import com.foreverwin.mom.wms.entity.StorageBin;
import com.foreverwin.mom.wms.mapper.ZWmsInventoryMapper;
import com.foreverwin.mom.wms.service.*;
import lombok.RequiredArgsConstructor;
@ -75,11 +76,16 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
// NLV 已用 Snow
@Override
public void createInventory(Inventory wmsInventory) {
wmsInventory.setSite(TenantContextHolder.getTenantId());
String tenantId = TenantContextHolder.getTenantId();
wmsInventory.setSite(tenantId);
wmsInventory.setHandle(Inventory.genHandle(wmsInventory.getSite(), wmsInventory.getInventoryId()));
wmsInventory.setCreator(SecurityUtils.getUserName());
String userName = SecurityUtils.getUserName();
wmsInventory.setCreator(userName);
wmsInventory.setCreateTime(LocalDateTime.now());
this.baseMapper.insert(wmsInventory);
// 记录日志
inventoryLogService.saveLog(userName, wmsInventory.getInventoryId(), null, null, "CREATE", null,
wmsInventory.getQtyOnHand(), StorageBin.genHandle(tenantId, wmsInventory.getErpStorageLocation()), "库存创建", null);
}
// NLV 已用 Snow