Browse Source

库存初始化导入修改

dev_DY_CC
lvzb 11 months ago
parent
commit
1a3a67b579
  1. 49
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/InventoryInitialNotes/InventoryInitialNoteAppService.cs

49
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.Collections.Generic;
using System.ComponentModel.DataAnnotations; 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.Application.Contracts;
using Win_in.Sfs.Shared.Domain;
using Win_in.Sfs.Basedata.Application.Contracts;
/// <summary> /// <summary>
/// 计划外入库记录 /// 库存初始化记录
/// </summary> /// </summary>
[Authorize] [Authorize]
[Route($"{StoreConsts.RootPath}inventory-initial-note")] [Route($"{StoreConsts.RootPath}inventory-initial-note")]
@ -26,15 +31,54 @@ public class InventoryInitialNoteAppService :
{ {
private readonly IInventoryInitialNoteManager _inventoryInitialNoteManager; private readonly IInventoryInitialNoteManager _inventoryInitialNoteManager;
private readonly IInventoryLabelAppService _inventoryLabelService; private readonly IInventoryLabelAppService _inventoryLabelService;
private readonly IItemBasicAppService _itemBasicAppService;
public InventoryInitialNoteAppService( public InventoryInitialNoteAppService(
IInventoryInitialNoteRepository repository IInventoryInitialNoteRepository repository
, IInventoryInitialNoteManager inventoryInitialNoteManager , IInventoryInitialNoteManager inventoryInitialNoteManager
, IInventoryLabelAppService inventoryLabelService , IInventoryLabelAppService inventoryLabelService,
IItemBasicAppService itemBasicAppService
) : base(repository) ) : base(repository)
{ {
_inventoryInitialNoteManager = inventoryInitialNoteManager; _inventoryInitialNoteManager = inventoryInitialNoteManager;
_inventoryLabelService = inventoryLabelService; _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("")] [HttpPost("")]
@ -49,6 +93,7 @@ public class InventoryInitialNoteAppService :
return dto; return dto;
} }
protected virtual async Task ImportDataAsync(List<InventoryInitialNote> entites, List<InventoryInitialNote> deleteEntities) protected virtual async Task ImportDataAsync(List<InventoryInitialNote> entites, List<InventoryInitialNote> deleteEntities)
{ {
await _inventoryInitialNoteManager.ImportDataAsync(entites, deleteEntities).ConfigureAwait(false); await _inventoryInitialNoteManager.ImportDataAsync(entites, deleteEntities).ConfigureAwait(false);

Loading…
Cancel
Save