From 1a3a67b5797183d92443acb5a642af3bdb2c3713 Mon Sep 17 00:00:00 2001
From: lvzb <35200379@qq.com>
Date: Fri, 7 Jun 2024 16:43:14 +0800
Subject: [PATCH] =?UTF-8?q?=E5=BA=93=E5=AD=98=E5=88=9D=E5=A7=8B=E5=8C=96?=
=?UTF-8?q?=E5=AF=BC=E5=85=A5=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../InventoryInitialNoteAppService.cs | 49 ++++++++++++++++++-
1 file changed, 47 insertions(+), 2 deletions(-)
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);