diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/InventoryInitialNotes/InventoryInitialNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/InventoryInitialNotes/InventoryInitialNoteAppService.cs
index bdc8d97bf..bbcb5d6be 100644
--- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/InventoryInitialNotes/InventoryInitialNoteAppService.cs
+++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/InventoryInitialNotes/InventoryInitialNoteAppService.cs
@@ -13,10 +13,15 @@ namespace Win_in.Sfs.Wms.Store.Application;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
+using Microsoft.EntityFrameworkCore;
+using System.Linq;
+using Volo.Abp;
using Win_in.Sfs.Shared.Application.Contracts;
+using Win_in.Sfs.Shared.Domain;
+using Win_in.Sfs.Basedata.Application.Contracts;
///
-/// 计划外入库记录
+/// 库存初始化记录
///
[Authorize]
[Route($"{StoreConsts.RootPath}inventory-initial-note")]
@@ -26,15 +31,54 @@ public class InventoryInitialNoteAppService :
{
private readonly IInventoryInitialNoteManager _inventoryInitialNoteManager;
private readonly IInventoryLabelAppService _inventoryLabelService;
+ private readonly IItemBasicAppService _itemBasicAppService;
public InventoryInitialNoteAppService(
IInventoryInitialNoteRepository repository
, IInventoryInitialNoteManager inventoryInitialNoteManager
- , IInventoryLabelAppService inventoryLabelService
+ , IInventoryLabelAppService inventoryLabelService,
+ IItemBasicAppService itemBasicAppService
) : base(repository)
{
_inventoryInitialNoteManager = inventoryInitialNoteManager;
_inventoryLabelService = inventoryLabelService;
+ _itemBasicAppService = itemBasicAppService;
+ }
+ ///
+ /// 数据加工
+ ///
+ ///
+ ///
+
+ protected override async Task> ImportProcessingEntityAsync(Dictionary dictionary)
+ {
+ var addList = dictionary.Where(p => p.Value == EntityState.Added).Select(p => p.Key);
+ foreach (var request in addList)
+ {
+ request.Worker = CurrentUser.GetUserName();
+ request.CreatorId = CurrentUser.Id;
+ request.Remark = "库存初始化";
+ request.ActiveDate = DateTime.Now;
+ foreach (var detail in request.Details)
+ {
+ var itemBasicDto = await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false);
+ CheckItemBasic(itemBasicDto, detail.ItemCode);
+ detail.ItemDesc1 = itemBasicDto.Desc1;
+ detail.ItemDesc2 = itemBasicDto.Desc2;
+ detail.ItemName = itemBasicDto.Name;
+ detail.Uom = itemBasicDto.BasicUom;
+ detail.StdPackQty = itemBasicDto.StdPackQty;
+ }
+ }
+ return dictionary;
+ }
+
+ private static void CheckItemBasic(ItemBasicDTO itemcBasicDto, string itemCode)
+ {
+ if (itemcBasicDto == null)
+ {
+ throw new UserFriendlyException($"ERP料号为【{itemCode}】不存在");
+ }
}
[HttpPost("")]
@@ -49,6 +93,7 @@ public class InventoryInitialNoteAppService :
return dto;
}
+
protected virtual async Task ImportDataAsync(List entites, List deleteEntities)
{
await _inventoryInitialNoteManager.ImportDataAsync(entites, deleteEntities).ConfigureAwait(false);