|
|
@ -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; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 计划外入库记录
|
|
|
|
/// 库存初始化记录
|
|
|
|
/// </summary>
|
|
|
|
[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; |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 数据加工
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="dictionary"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
protected override async Task<Dictionary<InventoryInitialNote, EntityState>> ImportProcessingEntityAsync(Dictionary<InventoryInitialNote, EntityState> 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<InventoryInitialNote> entites, List<InventoryInitialNote> deleteEntities) |
|
|
|
{ |
|
|
|
await _inventoryInitialNoteManager.ImportDataAsync(entites, deleteEntities).ConfigureAwait(false); |
|
|
|