diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/EosAgentModule.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/EosAgentModule.cs index 43fc043db..d1ed0e792 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/EosAgentModule.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/EosAgentModule.cs @@ -166,7 +166,7 @@ public class EosAgentModule : AbpModule { context.AddBackgroundWorkerAsync(); - context.AddBackgroundWorkerAsync(); + //context.AddBackgroundWorkerAsync(); } } diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/FawtygAutoMapperProfile.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/FawtygAutoMapperProfile.cs index e526956e1..10b785717 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/FawtygAutoMapperProfile.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/FawtygAutoMapperProfile.cs @@ -9,6 +9,7 @@ using Win_in.Sfs.Wms.DataExchange.WMS.ItemPack; using Win_in.Sfs.Wms.DataExchange.WMS.PurchaseOrder; using Win_in.Sfs.Wms.DataExchange.WMS.PurchaseReceipt; using Win_in.Sfs.Wms.DataExchange.WMS.PurchaseReturn; +using Win_in.Sfs.Wms.DataExchange.WMS.PutawayNote; using Win_in.Sfs.Wms.DataExchange.WMS.SuppplierAsn; using Win_in.Sfs.Wms.Store.Application.Contracts; @@ -23,6 +24,9 @@ public class FawtygAutoMapperProfile : Profile CreateMap(); CreateMap(); + CreateMap(); + CreateMap(); + CreateMap() .Ignore(x => x.Detail); CreateMap(); diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/Incoming/EosIncomingBackgroundWorker.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/Incoming/EosIncomingBackgroundWorker.cs index 8b13c38dd..48f9cbd07 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/Incoming/EosIncomingBackgroundWorker.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/Incoming/EosIncomingBackgroundWorker.cs @@ -35,13 +35,13 @@ public class EosIncomingBackgroundWorker : AsyncPeriodicBackgroundWorkerBase return; } - Logger.LogInformation($"Read Plan"); - var planReader = workerContext.ServiceProvider.GetRequiredService(); - var planConverter = workerContext.ServiceProvider.GetRequiredService(); - //读取并保存Plan - var plansFromExternalList = await planReader.ReadAsync().ConfigureAwait(false); - //转换Plan - await planConverter.ConvertAsync(plansFromExternalList).ConfigureAwait(false); + //Logger.LogInformation($"Read Plan"); + //var planReader = workerContext.ServiceProvider.GetRequiredService(); + //var planConverter = workerContext.ServiceProvider.GetRequiredService(); + ////读取并保存Plan + //var plansFromExternalList = await planReader.ReadAsync().ConfigureAwait(false); + ////转换Plan + //await planConverter.ConvertAsync(plansFromExternalList).ConfigureAwait(false); Logger.LogInformation($"Read Ship"); var shipHandleService = workerContext.ServiceProvider.GetRequiredService(); @@ -51,13 +51,13 @@ public class EosIncomingBackgroundWorker : AsyncPeriodicBackgroundWorkerBase //转换Ship await shipConverter.ConvertAsync(shipsFromExternalList).ConfigureAwait(false); - Logger.LogInformation($"Read Product"); - var productHandleService = workerContext.ServiceProvider.GetRequiredService(); - var productConverter = workerContext.ServiceProvider.GetRequiredService(); - //读取并保持Product - var productsFromExternalList = await productHandleService.ReadAsync().ConfigureAwait(false); - // 转换Product - await productConverter.ConvertAsync(productsFromExternalList).ConfigureAwait(false); + //Logger.LogInformation($"Read Product"); + //var productHandleService = workerContext.ServiceProvider.GetRequiredService(); + //var productConverter = workerContext.ServiceProvider.GetRequiredService(); + ////读取并保持Product + //var productsFromExternalList = await productHandleService.ReadAsync().ConfigureAwait(false); + //// 转换Product + //await productConverter.ConvertAsync(productsFromExternalList).ConfigureAwait(false); Logger.LogInformation($"Completed: Handling {Incoming}"); } diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/Incoming/ShipConverter.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/Incoming/ShipConverter.cs index 599879719..40b357a52 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/Incoming/ShipConverter.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/Incoming/ShipConverter.cs @@ -5,13 +5,16 @@ using System.Text.Json; using System.Threading.Tasks; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; +using Volo.Abp.Data; using Volo.Abp.ObjectMapping; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Label.Application.Contracts; +using Win_in.Sfs.Label.Domain.Shared; using Win_in.Sfs.Wms.DataExchange.Domain; using Win_in.Sfs.Wms.DataExchange.Domain.Shared; using Win_in.Sfs.Wms.DataExchange.WMS.SuppplierAsn; using Win_in.Sfs.Wms.Store.Application.Contracts; +using Win_in.Sfs.Wms.Store.Domain; namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent; @@ -24,6 +27,9 @@ public class ShipConverter : IIncomingConverter private readonly IItemPackAppService _itemPackAppService; private readonly ILogger _logger; private readonly IConfiguration _configuration; + private readonly ISupplierAppService _supplierAppService; + private readonly ISupplierItemAppService _supplierItemAppService; + public ShipConverter( IIncomingToWmsManager incomingToWmsManager , IObjectMapper objectMapper @@ -31,8 +37,9 @@ public class ShipConverter : IIncomingConverter , IItemPackAppService itemPackAppService , ILogger logger, IConfiguration configuration, - IIncomingFromExternalManager incomingFromExternalManager - ) + IIncomingFromExternalManager incomingFromExternalManager, + ISupplierAppService supplierAppService, + ISupplierItemAppService supplierItemAppService) { _incomingFromExternalManager = incomingFromExternalManager; _incomingToWmsManager = incomingToWmsManager; @@ -41,6 +48,8 @@ public class ShipConverter : IIncomingConverter _itemPackAppService = itemPackAppService; _logger = logger; _configuration = configuration; + _supplierAppService = supplierAppService; + _supplierItemAppService = supplierItemAppService; } public virtual async Task ConvertAsync(List incomingFromExternalList) @@ -95,13 +104,55 @@ public class ShipConverter : IIncomingConverter { purchaseLabel.ItemName = item.Name; purchaseLabel.ItemDesc1 = item.Desc1; - + purchaseLabel.Uom = item.BasicUom; + purchaseLabel.ItemDesc2 = item.Desc2; } else { purchaseLabel.ItemName = ""; purchaseLabel.ItemDesc1 = ""; + purchaseLabel.Uom = ""; + purchaseLabel.ItemDesc2 = ""; } + purchaseLabel.LabelType = EnumLabelType.PurchaseLabel; + var supplierDto = await _supplierAppService.GetByCodeAsync(exchangeAsn.SupplierCode).ConfigureAwait(false); + purchaseLabel.SupplierCode = exchangeAsn.SupplierCode; + purchaseLabel.PoNumber = exchangeAsn.PoNumber; + purchaseLabel.Qty = exchangeAsn.Detail.Qty; + + var supplierItemDTO=await _supplierItemAppService.GetBySupplierCodeAndItemCodeAsync(exchangeAsn.SupplierCode, purchaseLabel.ItemCode).ConfigureAwait(false); + + purchaseLabel.ProduceDate = exchangeAsn.Detail.ProduceDate; + purchaseLabel.ArriveDate = exchangeAsn.Detail.ArriveDate; + purchaseLabel.FullBarcodeString = exchangeAsn.Detail.PackingCode; + purchaseLabel.LocationErpCode = exchangeAsn.Detail.LocationErpCode; + purchaseLabel.Lot = exchangeAsn.Detail.Lot; + purchaseLabel.RecommendLocationCode = exchangeAsn.Detail.LocationErpCode; + purchaseLabel.Remark = exchangeAsn.Detail.Remark; + purchaseLabel.Code = exchangeAsn.Detail.PackingCode; + purchaseLabel.PlanArriveDate = exchangeAsn.PlanArriveDate; + + purchaseLabel.SupplierItemCode = supplierItemDTO.SupplierItemCode; + purchaseLabel.SupplierItemName = supplierItemDTO.ItemName; + + + purchaseLabel.ExpireDate = DateTime.Now.AddDays(item.GetValidateDays()); + purchaseLabel.ExtraProperties = new ExtraPropertyDictionary(); + purchaseLabel.LabelStatus = LabelStatus.Enable; + purchaseLabel.Specifications = item.Color; + purchaseLabel.StdPackQty = item.StdPackQty; + purchaseLabel.SupplierName = supplierDto.Name; + purchaseLabel.SupplierSimpleName = supplierDto.ShortName; + purchaseLabel.Team = string.Empty; + purchaseLabel.ProdLine = string.Empty; + purchaseLabel.QLevel = string.Empty; + purchaseLabel.QualityFile = string.Empty; + purchaseLabel.Shift = string.Empty; + purchaseLabel.ContainerCode = string.Empty; + + purchaseLabel.RpNumber = string.Empty; + purchaseLabel.SupplierBatch = string.Empty; + return purchaseLabel; } diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent/Incoming/BackFluConverter.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent/Incoming/BackFluConverter.cs index e7102b08a..602b3f018 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent/Incoming/BackFluConverter.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent/Incoming/BackFluConverter.cs @@ -50,7 +50,7 @@ public class BackFluConverter : IIncomingConverter var incomingToWmsDataList = await BuildIncomingToWmsOfPurchaseOrderAsync(incomingFromExternalList).ConfigureAwait(false); await _incomingToWmsManager.CreateManyAsync(incomingToWmsDataList).ConfigureAwait(false); //归档 - await _incomingFromExternalManager.ArchiveBulkAsync(incomingFromExternalList).ConfigureAwait(false); + await _incomingFromExternalManager.ArchiveManyAsync(incomingFromExternalList).ConfigureAwait(false); } diff --git a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/IncomingToWmsExtensions.cs b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/IncomingToWmsExtensions.cs index 0448cbeec..14f5e1a74 100644 --- a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/IncomingToWmsExtensions.cs +++ b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/IncomingToWmsExtensions.cs @@ -149,8 +149,8 @@ public static class IncomingToWmsExtensions public static async Task HandleInventoryLabelsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext) { var inventoryLabel = JsonSerializer.Deserialize(incomingConverted.DataContent); - var inventoryLabelAppService = workerContext.ServiceProvider.GetRequiredService(); - await inventoryLabelAppService.CreateAsync(inventoryLabel).ConfigureAwait(false); + var inventoryLabelAppService = workerContext.ServiceProvider.GetRequiredService(); + await inventoryLabelAppService.CreateManyByNoCodeAsync(new List { inventoryLabel }).ConfigureAwait(false); } public static async Task HandleBackFlushsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext) { diff --git a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Domain/OutgoingToExternal/OutgoingToExternalManager.cs b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Domain/OutgoingToExternal/OutgoingToExternalManager.cs index 2fa873f15..a2b7393d9 100644 --- a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Domain/OutgoingToExternal/OutgoingToExternalManager.cs +++ b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Domain/OutgoingToExternal/OutgoingToExternalManager.cs @@ -53,7 +53,7 @@ public class OutgoingToExternalManager : DomainService, IOutgoingToExternalManag public virtual async Task ArchiveManyAsync(List entities) { - var archivedEntities = _objectMapper.Map, List>(entities); + var archivedEntities = _objectMapper.Map, List>(entities); await _archiveRepository.InsertManyAsync(archivedEntities).ConfigureAwait(false); await _repository.DeleteManyAsync(entities).ConfigureAwait(false); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CountNotes/CountNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CountNotes/CountNoteAppService.cs index 47cdf7440..828b6c6ee 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CountNotes/CountNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CountNotes/CountNoteAppService.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore; using Volo.Abp; using Volo.Abp.Domain.Repositories; using Win_in.Sfs.Basedata.Application.Contracts; -using Win_in.Sfs.Shared.Application.Contracts; using Win_in.Sfs.Shared.Domain; using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Wms.Store.Application.Contracts; @@ -18,11 +17,10 @@ using Win_in.Sfs.Wms.Store.Domain.Shared; namespace Win_in.Sfs.Wms.Store.Application; /// -/// 盘点记录 +/// 盘点记录 /// [Authorize] [Route($"{StoreConsts.RootPath}count-note")] - public class CountNoteAppService : SfsStoreWithDetailsAppServiceBase - /// 用来重写 导入数据时可以加工数据 + /// 用来重写 导入数据时可以加工数据 /// /// /// - protected override async Task> ImportProcessingEntityAsync(Dictionary dictionary) + protected override async Task> ImportProcessingEntityAsync( + Dictionary dictionary) { - var dataList = dictionary.Select(p => p.Key);//查询所有的导入盘点数据 + var dataList = dictionary.Select(p => p.Key); //查询所有的导入盘点数据 var resultDictionary = new Dictionary(); - var allCountPlanNumbersList= dataList.GroupBy(p => p.CountPlanNumber).Select(p => p.Key).ToList(); + var allCountPlanNumbersList = dataList.GroupBy(p => p.CountPlanNumber).Select(p => p.Key).ToList(); //特殊处理 因为盘点记录可以重复导入 所以每次导入前删除调原有记录 foreach (var countPlanNumber in allCountPlanNumbersList) { var countPlanDto = await _countPlanAppService.GetByNumberAsync(countPlanNumber).ConfigureAwait(false); - if (countPlanDto.RequestType != CountPlanRequestType.Import) - { - throw new UserFriendlyException("非Excel盘点执行方式不能使用导入"); - } + CheckCountPlanNumber(countPlanDto, countPlanNumber); + CheckCountPlanRequestType(countPlanDto); await _repository.DeleteAsync(p => p.CountPlanNumber == countPlanNumber).ConfigureAwait(false); } @@ -81,40 +77,78 @@ public class CountNoteAppService : { countNote.Worker = CurrentUser.GetUserName(); countNote.CreatorId = CurrentUser.Id; - countNote.BeginTime= DateTime.Now; + countNote.BeginTime = DateTime.Now; countNote.Adjusted = false; - countNote.EndTime=DateTime.Now; + countNote.EndTime = DateTime.Now; countNote.Stage = EnumCountStage.Audit; foreach (var detail in countNote.Details) { - var locationDto= await _locationAppService.GetByCodeAsync(detail.LocationCode).ConfigureAwait(false); - var itemcBasicDto=await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); + var locationDto = await _locationAppService.GetByCodeAsync(detail.LocationCode).ConfigureAwait(false); + var itemcBasicDto = await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); + CheckLocation(locationDto, detail); + CheckItemBasic(itemcBasicDto, detail); - detail.CountLabel =Guid.NewGuid().ToString(); + detail.CountLabel = Guid.NewGuid().ToString(); detail.LocationArea = locationDto.AreaCode; - detail.LocationGroup= locationDto.LocationGroupCode; - detail.LocationErpCode= locationDto.ErpLocationCode; - detail.WarehouseCode= locationDto.WarehouseCode; + detail.LocationGroup = locationDto.LocationGroupCode; + detail.LocationErpCode = locationDto.ErpLocationCode; + detail.WarehouseCode = locationDto.WarehouseCode; detail.ItemCode = itemcBasicDto.Code; detail.ItemDesc1 = itemcBasicDto.Desc1; detail.ItemDesc2 = itemcBasicDto.Desc2; - detail.ItemName= itemcBasicDto.Name; + detail.ItemName = itemcBasicDto.Name; detail.Uom = itemcBasicDto.BasicUom; } - resultDictionary.Add(countNote,EntityState.Added); + resultDictionary.Add(countNote, EntityState.Added); } return resultDictionary; } + #region 校验 + + private static void CheckItemBasic(ItemBasicDTO itemcBasicDto, CountNoteDetail detail) + { + if (itemcBasicDto == null) + { + throw new UserFriendlyException($"物品代码为【{detail.LocationCode}】不存在"); + } + } + + private static void CheckLocation(LocationDTO locationDto, CountNoteDetail detail) + { + if (locationDto == null) + { + throw new UserFriendlyException($"库位代码为【{detail.LocationCode}】不存在"); + } + } + + private static void CheckCountPlanRequestType(CountPlanDTO countPlanDto) + { + if (countPlanDto.RequestType != CountPlanRequestType.Import) + { + throw new UserFriendlyException("非Excel盘点执行方式不能使用导入"); + } + } + + private static void CheckCountPlanNumber(CountPlanDTO countPlanDto, string countPlanNumber) + { + if (countPlanDto == null) + { + throw new UserFriendlyException($"盘点计划单号为【{countPlanNumber}】不存在"); + } + } + + #endregion + #endregion /// - /// 新增接口 + /// 新增接口 /// /// /// @@ -129,7 +163,7 @@ public class CountNoteAppService : } /// - /// 生成盘点调整申请 + /// 生成盘点调整申请 /// /// [HttpPost("{id}/generate-adjust-request")] @@ -150,11 +184,13 @@ public class CountNoteAppService : protected override async Task GetEntityAsync(CountNoteImportInput importInput) { - var countNote = await _repository.FirstOrDefaultAsync(t => t.CountPlanNumber == importInput.CountPlanNumber).ConfigureAwait(false); + var countNote = await _repository.FirstOrDefaultAsync(t => t.CountPlanNumber == importInput.CountPlanNumber) + .ConfigureAwait(false); - if (countNote != null)//特殊处理 因为盘点记录可以重复导入 所以每次导入前删除调原有记录 + if (countNote != null) //特殊处理 因为盘点记录可以重复导入 所以每次导入前删除调原有记录 { - var countplan = await _countPlanAppService.GetByNumberAsync(countNote.CountPlanNumber).ConfigureAwait(false); + var countplan = await _countPlanAppService.GetByNumberAsync(countNote.CountPlanNumber) + .ConfigureAwait(false); if (countplan != null) { @@ -178,7 +214,7 @@ public class CountNoteAppService : { var groups = entites.Select(p => p.CountPlanNumber).GroupBy(p => p); - if (entites.Any(p => p.Adjusted == true)) + if (entites.Any(p => p.Adjusted)) { throw new UserFriendlyException("库存已调整,不能导入"); } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestFisAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestFisAppService.cs index 2a980b30b..cf2e633cf 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestFisAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestFisAppService.cs @@ -86,6 +86,8 @@ public class DeliverRequestFisAppService : foreach (var detail in itemTransformRequest.Details) { var itemBasicDto = await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); + CheckItemBasic(itemBasicDto, detail.ItemCode); + var transactionType = await _transactionTypeAppService.GetByTransTypeAsync(EnumTransType.Deliver, EnumTransSubType.Deliver_FIS) .ConfigureAwait(false); @@ -100,16 +102,11 @@ public class DeliverRequestFisAppService : Statuses = transactionType.OutInventoryStatuses }).ConfigureAwait(false); + CheckBalances(balances, transactionType, itemBasicDto, detail); + var balanceSumQty = balances.Sum(t => t.Qty); - if (balanceSumQty < detail.Qty) - { - throw new UserFriendlyException($"物料号 {detail.ItemCode} " + - $"在库位类型 {transactionType.OutLocationTypes.JoinAsString(",")}," + - $"库区 {detail.AreaCode} " + - $"状态 {transactionType.OutInventoryStatuses.JoinAsString(",")}" + - $"库存余额 {balanceSumQty} 小于 {detail.Qty}。"); - } + CheckBalancesSumQty(balanceSumQty, detail, transactionType); detail.ItemDesc1 = itemBasicDto.Desc1; detail.ItemDesc2 = itemBasicDto.Desc2; @@ -122,6 +119,49 @@ public class DeliverRequestFisAppService : return dictionary; } + #region 校验 + + private static void CheckBalancesSumQty(decimal balanceSumQty, DeliverRequestDetail detail, + TransactionTypeDTO transactionType) + { + if (balanceSumQty < detail.Qty) + { + throw new UserFriendlyException($"物料号 {detail.ItemCode} " + + $"在库位类型 {transactionType.OutLocationTypes.JoinAsString(",")}," + + $"库区 {detail.AreaCode} " + + $"状态 {transactionType.OutInventoryStatuses.JoinAsString(",")}" + + $"库存余额 {balanceSumQty} 小于 {detail.Qty}。"); + } + } + + private static void CheckBalances(List balances, TransactionTypeDTO transactionType, ItemBasicDTO itemBasicDto, + DeliverRequestDetail detail) + { + if (balances == null) + { + var sbLocationTypes = string.Empty; + transactionType.OutLocationTypes.ForEach(p => sbLocationTypes += " " + p.GetDisplayName() + " "); + var sbStatuses = string.Empty; + transactionType.OutInventoryStatuses.ForEach(p => sbLocationTypes += " " + p.GetDisplayName() + " "); + throw new UserFriendlyException( + $"没有物品代码为【{itemBasicDto.Code}】," + + $"数量为【{detail.Qty}】," + + $"出库库位类型为【{sbLocationTypes}】," + + $"区域为【{detail.AreaCode}】," + + $"出库可用状态为【{sbStatuses}】的可用的库存。"); + } + } + + private static void CheckItemBasic(ItemBasicDTO itemcBasicDto, string itemCode) + { + if (itemcBasicDto == null) + { + throw new UserFriendlyException($"物品代码为【{itemCode}】不存在"); + } + } + + #endregion + #endregion [HttpPost("list")] diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ItemTransformRequests/ItemTransformRequestAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ItemTransformRequests/ItemTransformRequestAppService.cs index c2e79752c..34f407bc3 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ItemTransformRequests/ItemTransformRequestAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ItemTransformRequests/ItemTransformRequestAppService.cs @@ -3,11 +3,11 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading.Tasks; - using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Volo.Abp; +using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Label.Application.Contracts; using Win_in.Sfs.Shared.Application.Contracts; using Win_in.Sfs.Shared.Domain; @@ -20,12 +20,14 @@ using Win_in.Sfs.Wms.Store.Domain.Shared; namespace Win_in.Sfs.Wms.Store.Application; /// -/// 回收料调整申请 +/// 回收料调整申请 /// [Authorize] [Route($"{StoreConsts.RootPath}item-transform-request")] public class ItemTransformRequestAppService : - SfsStoreRequestAppServiceBase, + SfsStoreRequestAppServiceBase, IItemTransformRequestAppService { private const EnumTransSubType SubType = EnumTransSubType.Item_Transform; @@ -45,25 +47,12 @@ public class ItemTransformRequestAppService : _balanceAppService = balanceAppService; } - /// - /// 新增方法 - /// - /// - /// - [HttpPost("")] - - public override async Task CreateAsync(ItemTransformRequestEditInput input) - { - var entity = ObjectMapper.Map(input); - - await _manager.CreateAsync(entity).ConfigureAwait(false); - - var dto = ObjectMapper.Map(entity); + - return dto; - } + #region 东阳 - protected override async Task> ImportProcessingEntityAsync(Dictionary dictionary) + protected override async Task> ImportProcessingEntityAsync( + Dictionary dictionary) { var addList = dictionary.Where(p => p.Value == EntityState.Added).Select(p => p.Key); @@ -73,13 +62,27 @@ public class ItemTransformRequestAppService : itemTransformRequest.CreatorId = CurrentUser.Id; foreach (var detail in itemTransformRequest.Details) { - var fromLocationDto= await LocationAclService.GetByCodeAsync(detail.FromLocationCode).ConfigureAwait(false); - var toLocationDto= await LocationAclService.GetByCodeAsync(detail.ToLocationCode).ConfigureAwait(false); - var fromItemBasicDto=await ItemBasicAclService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); + var fromLocationDto = + await LocationAclService.GetByCodeAsync(detail.FromLocationCode).ConfigureAwait(false); + CheckLocation(fromLocationDto, detail.FromLocationCode); + + var toLocationDto = + await LocationAclService.GetByCodeAsync(detail.ToLocationCode).ConfigureAwait(false); + CheckLocation(toLocationDto, detail.ToLocationCode); + + var fromItemBasicDto = await ItemBasicAclService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); + CheckItemBasic(fromItemBasicDto, detail.ItemCode); + var toItemBasicDto = await ItemBasicAclService.GetByCodeAsync(detail.ToItemCode).ConfigureAwait(false); - var balanceDto= await _balanceAppService.GetByItemLocationAndPackingAsync(detail.FromPackingCode, detail.ItemCode, + CheckItemBasic(toItemBasicDto, detail.ToItemCode); + + var balanceDto = await _balanceAppService.GetByItemLocationAndPackingAsync(detail.FromPackingCode, + detail.ItemCode, detail.FromLocationCode).ConfigureAwait(false); - var inventoryLabelDto= await _inventoryLabelAppService.GetByCodeAsync(detail.ToPackingCode).ConfigureAwait(false); + + var inventoryLabelDto = await _inventoryLabelAppService.GetByCodeAsync(detail.ToPackingCode) + .ConfigureAwait(false); + CheckLabel(inventoryLabelDto, detail); detail.FromLocationArea = fromLocationDto.AreaCode; detail.FromLocationErpCode = fromLocationDto.ErpLocationCode; @@ -100,8 +103,8 @@ public class ItemTransformRequestAppService : detail.ToWarehouseCode = toLocationDto.WarehouseCode; detail.ItemDesc1 = fromItemBasicDto.Desc1; - detail.ItemDesc2= fromItemBasicDto.Desc2; - detail.ItemName= fromItemBasicDto.Name; + detail.ItemDesc2 = fromItemBasicDto.Desc2; + detail.ItemName = fromItemBasicDto.Name; detail.Uom = fromItemBasicDto.BasicUom; detail.ToItemCode = toItemBasicDto.Code; @@ -112,11 +115,58 @@ public class ItemTransformRequestAppService : } return dictionary; + } + + + #region 校验 + + private void CheckLabel(InventoryLabelDto inventoryLabelDto, ItemTransformRequestDetail detail) + { + if (inventoryLabelDto == null) + { + throw new UserFriendlyException($"标签箱码为【{detail.ToPackingCode}】不存在"); + } + } + + private void CheckItemBasic(ItemBasicDTO ItemBasicDto, string itemCode) + { + if (ItemBasicDto == null) + { + throw new UserFriendlyException($"物品代码为【{itemCode}】不存在"); + } + } + + private void CheckLocation(LocationDTO LocationDto, string LocationCode) + { + if (LocationDto == null) + { + throw new UserFriendlyException($"库位代码为【{LocationCode}】不存在"); + } + } + + #endregion + + #endregion + + /// + /// 新增方法 + /// + /// + /// + [HttpPost("")] + public override async Task CreateAsync(ItemTransformRequestEditInput input) + { + var entity = ObjectMapper.Map(input); + + await _manager.CreateAsync(entity).ConfigureAwait(false); + var dto = ObjectMapper.Map(entity); + return dto; } - protected virtual async Task ImportDataAsync(List entites, List deleteEntities) + protected virtual async Task ImportDataAsync(List entites, + List deleteEntities) { await _manager.ImportDataAsync(entites, deleteEntities).ConfigureAwait(false); } @@ -126,7 +176,9 @@ public class ItemTransformRequestAppService : return t => t.Worker; } - protected virtual async Task<(List entites, List deleteEntities)> BuildImportDataAsync(ImportResult importResult, EnumImportMethod importMethod = EnumImportMethod.Update, bool isAllowPartImport = false) + protected virtual async Task<(List entites, List deleteEntities)> + BuildImportDataAsync(ImportResult importResult, + EnumImportMethod importMethod = EnumImportMethod.Update, bool isAllowPartImport = false) { if (importResult.Data.Any(t => t.ReportStatus == EnumImportReportStatus.Failed)) { @@ -167,18 +219,21 @@ public class ItemTransformRequestAppService : { entity.SetId(exist.Id); } + break; case EnumImportMethod.Replace: if (exist != null) { deleteEntites.Add(exist); } + break; } foreach (var inputDetail in inputDetails) { - var detail = ObjectMapper.Map(inputDetail); + var detail = + ObjectMapper.Map(inputDetail); await SetDetailPropertiesAsync(detail, input).ConfigureAwait(false); entity.AddDetail(detail); @@ -191,7 +246,8 @@ public class ItemTransformRequestAppService : return (entites, deleteEntites); } - private async Task SetDetailPropertiesAsync(ItemTransformRequestDetail detail, ItemTransformRequestImportInput input) + private async Task SetDetailPropertiesAsync(ItemTransformRequestDetail detail, + ItemTransformRequestImportInput input) { var balanceDTO = await BalanceAclService.GetByPackingCodeAsync(detail.FromPackingCode).ConfigureAwait(false); var toItemBasicDTO = await ItemBasicAclService.GetByCodeAsync(detail.ToItemCode).ConfigureAwait(false); @@ -223,7 +279,8 @@ public class ItemTransformRequestAppService : private async Task SetEntityPropertiesAsync(ItemTransformRequest entity, ItemTransformRequestImportInput input) { - var tranType = await TransactionTypeAclService.GetByTransTypeAsync(EnumTransType.Adjust, SubType).ConfigureAwait(false); + var tranType = await TransactionTypeAclService.GetByTransTypeAsync(EnumTransType.Adjust, SubType) + .ConfigureAwait(false); Check.NotNull(tranType, "事务类型", "事务类型不存在"); @@ -234,7 +291,8 @@ public class ItemTransformRequestAppService : entity.DirectCreateNote = tranType.DirectCreateNote; } - protected virtual async Task CheckImportInputBusinessAsync(ItemTransformRequestImportInput importInput, EnumImportMethod importMethod, List validationRresult) + protected virtual async Task CheckImportInputBusinessAsync(ItemTransformRequestImportInput importInput, + EnumImportMethod importMethod, List validationRresult) { //await base.CheckImportInputBusinessAsync(importInput, importMethod); @@ -298,15 +356,16 @@ public class ItemTransformRequestAppService : var label = await _inventoryLabelAppService.GetByCodeAsync(packingCode).ConfigureAwait(false); if (label != null) { - var inventory = await BalanceAclService.GetListByPackingCodesAsync(new List { packingCode }).ConfigureAwait(false); + var inventory = await BalanceAclService.GetListByPackingCodesAsync(new List { packingCode }) + .ConfigureAwait(false); if (inventory.Count > 0) { - validationRresult.Add("库存余额已存在", $"库存余额已存在,请重新打印标签并导入。"); + validationRresult.Add("库存余额已存在", "库存余额已存在,请重新打印标签并导入。"); } } else { - validationRresult.Add("标签不存在", $"标签不存在,请重新打印标签并导入。"); + validationRresult.Add("标签不存在", "标签不存在,请重新打印标签并导入。"); } } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/MaterialRequests/MaterialRequestAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/MaterialRequests/MaterialRequestAppService.cs index bf07d2a39..304fd2166 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/MaterialRequests/MaterialRequestAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/MaterialRequests/MaterialRequestAppService.cs @@ -86,7 +86,10 @@ public class MaterialRequestAppService : SfsStoreRequestAppServiceBase(entity); } + #region 校验 + + private void CheckItemBasic(ItemBasicDTO ItemBasicDto, string itemCode) + { + if (ItemBasicDto == null) + { + throw new UserFriendlyException($"物品代码为【{itemCode}】不存在"); + } + } + + private void CheckLocation(LocationDTO LocationDto, string LocationCode) + { + if (LocationDto == null) + { + throw new UserFriendlyException($"库位代码为【{LocationCode}】不存在"); + } + } + + + #endregion + #endregion [HttpPost("")] diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/PurchaseReturnRequests/PurchaseReturnRequestAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/PurchaseReturnRequests/PurchaseReturnRequestAppService.cs index 8adf9ce95..4632ad53d 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/PurchaseReturnRequests/PurchaseReturnRequestAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/PurchaseReturnRequests/PurchaseReturnRequestAppService.cs @@ -38,19 +38,22 @@ public class PurchaseReturnRequestAppService : private readonly ITransactionTypeAppService _transactionTypeAppService; private readonly IPurchaseReturnRequestManager _purchaseReturnRequestManager; private readonly IPurchaseOrderAppService _purchaseOrderAppService; + private readonly IBalanceAppService _balanceAppService; public PurchaseReturnRequestAppService( IPurchaseReturnRequestRepository repository, IPurchaseReturnRequestManager purchaseReturnRequestManager, IInventoryLabelAppService inventoryLabelApp, ILocationAppService locationAppService, ITransactionTypeAppService transactionTypeAppService, - IPurchaseOrderAppService purchaseOrderAppService) : base(repository, purchaseReturnRequestManager) + IPurchaseOrderAppService purchaseOrderAppService, + IBalanceAppService balanceAppService) : base(repository, purchaseReturnRequestManager) { _purchaseReturnRequestManager = purchaseReturnRequestManager; _inventoryLabelApp = inventoryLabelApp; _locationAppService = locationAppService; _transactionTypeAppService = transactionTypeAppService; _purchaseOrderAppService = purchaseOrderAppService; + _balanceAppService = balanceAppService; base.CreatePolicyName = PurchaseReturnRequestPermissions.Create; base.UpdatePolicyName = PurchaseReturnRequestPermissions.Update; @@ -97,11 +100,18 @@ public class PurchaseReturnRequestAppService : { //通过箱标签 查找标签服务 构造其他字段 var labelDto = await _inventoryLabelApp.GetByCodeAsync(detail.PackingCode).ConfigureAwait(false); - var balanceDto = await BalanceAclService.GetByPackingCodeAsync(detail.PackingCode).ConfigureAwait(false); + CheckLabel(labelDto, detail); + + var balanceDto = await _balanceAppService.GetByPackingCodeAsync(detail.PackingCode).ConfigureAwait(false); + CheckBalance(balanceDto, detail); + var locationDto= await _locationAppService.GetByCodeAsync(balanceDto.LocationCode).ConfigureAwait(false); - var purchaseOrderDto= await _purchaseOrderAppService.GetByNumberAsync(labelDto.PoNumber).ConfigureAwait(false); - purchaseOrderDto = await _purchaseOrderAppService.GetAsync(purchaseOrderDto.Id).ConfigureAwait(false); + CheckLocation(locationDto, balanceDto); + var purchaseOrderDto = await _purchaseOrderAppService.GetByNumberAsync(labelDto.PoNumber).ConfigureAwait(false); + purchaseOrderDto = await _purchaseOrderAppService.GetAsync(purchaseOrderDto.Id).ConfigureAwait(false); + CheckPurchaseOrder(purchaseOrderDto, labelDto); + purchaseReturnRequest.AsnNumber = labelDto.AsnNumber; purchaseReturnRequest.RpNumber = labelDto.RpNumber; purchaseReturnRequest.ReturnTime=DateTime.Now; @@ -182,11 +192,78 @@ public class PurchaseReturnRequestAppService : if (purchaseOrderDto != null) { - detail.PoLine = - purchaseOrderDto.Details.FirstOrDefault(p => p.ItemCode == balanceDto.ItemCode && p.Lot == balanceDto.Lot).PoLine; + var purchaseOrderDetailDto=purchaseOrderDto.Details.FirstOrDefault(p => p.ItemCode == balanceDto.ItemCode && p.Lot == balanceDto.Lot); + if (purchaseOrderDetailDto == null) + { + purchaseOrderDetailDto = + purchaseOrderDto.Details.FirstOrDefault(p => p.ItemCode == balanceDto.ItemCode); + } + + if (purchaseOrderDetailDto == null) + { + throw new UserFriendlyException($"未找到物品代码为【{balanceDto.ItemCode}】,批次为【{balanceDto.Lot}】的订单详情"); + } + + detail.PoLine = purchaseOrderDetailDto.PoLine; + + + } + } + + #region 校验 + + private void CheckPurchaseOrder(PurchaseOrderDTO purchaseOrderDto, InventoryLabelDto labelDto) + { + if (purchaseOrderDto == null) + { + throw new UserFriendlyException($"采购订单编号为【{labelDto.PoNumber}】不存在"); } } + /// + /// 校验库位 + /// + /// + /// + /// + private void CheckLocation(LocationDTO locationDto, BalanceDTO balanceDto) + { + if (locationDto == null) + { + throw new UserFriendlyException($"库位为【{balanceDto.LocationCode}】不存在"); + } + } + + /// + /// 校验库存 + /// + /// + /// + /// + private void CheckBalance(BalanceDTO balanceDto, PurchaseReturnRequestDetail detail) + { + if (balanceDto == null) + { + throw new UserFriendlyException($"箱码为【{detail.PackingCode}】不存在"); + } + } + + /// + /// 校验标签 + /// + /// + /// + /// + private void CheckLabel(InventoryLabelDto labelDto, PurchaseReturnRequestDetail detail) + { + if (labelDto == null) + { + throw new UserFriendlyException($"标签为【{detail.PackingCode}】不存在"); + } + } + + #endregion + #endregion #region 校验 diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/SupplierAsns/SupplierAsnManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/SupplierAsns/SupplierAsnManager.cs index cbc2f0e0f..784fa00cd 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/SupplierAsns/SupplierAsnManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/SupplierAsns/SupplierAsnManager.cs @@ -1,7 +1,12 @@ +using System; using System.Collections.Generic; using System.Threading.Tasks; using Volo.Abp; +using Volo.Abp.Data; using Volo.Abp.Uow; +using Win_in.Sfs.Basedata.Application.Contracts; +using Win_in.Sfs.Label.Application.Contracts; +using Win_in.Sfs.Label.Domain.Shared; namespace Win_in.Sfs.Wms.Store.Domain; @@ -14,10 +19,14 @@ public class SupplierAsnManager : SfsStoreManagerBase CreateAsync(SupplierAsn entity) { - if (!string.IsNullOrWhiteSpace(entity.Number))//考虑 接口过来的数据是有Number的 + if (!string.IsNullOrWhiteSpace(entity.Number))//接口过来的数据是有Number的 { entity.SetIdAndNumberWithDetails(GuidGenerator, entity.Number); entity = await Repository.InsertAsync(entity).ConfigureAwait(false); @@ -86,7 +95,6 @@ public class SupplierAsnManager : SfsStoreManagerBase details) { foreach (var detail in details) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/MaterialRequests/MaterialRequestManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/MaterialRequests/MaterialRequestManager.cs index 5d0666e85..20456a5e7 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/MaterialRequests/MaterialRequestManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/MaterialRequests/MaterialRequestManager.cs @@ -85,7 +85,7 @@ public class MaterialRequestManager var issueJobs = await _issueJobRepository.GetListAsync(t => t.MaterialRequestNumber == materialRequest.Number).ConfigureAwait(false); if (issueJobs.Count > 0) { - if (issueJobs.All(t => t.JobStatus == EnumJobStatus.Done || t.JobStatus == EnumJobStatus.Closed || t.JobStatus == EnumJobStatus.Cancelled)) + if (issueJobs.All(t => t.JobStatus is EnumJobStatus.Done or EnumJobStatus.Closed or EnumJobStatus.Cancelled)) { if (materialRequest.Details.All(p => p.ReceivedQty >= p.Qty)) { diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Orders/PurchaseOrderEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Orders/PurchaseOrderEventHandler.cs index 143c43909..373067035 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Orders/PurchaseOrderEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Orders/PurchaseOrderEventHandler.cs @@ -267,15 +267,18 @@ public class PurchaseOrderEventHandler SupplierItemDTO supplierItemDto) { if (itemBasicDto == null) + { + throw new UserFriendlyException($"【{itemBasicDto.Code}】物品不存在"); + } if (supplierDto == null) { - throw new UserFriendlyException($"{supplierAsn.SupplierCode}供应商为空"); + throw new UserFriendlyException($"【{supplierAsn.SupplierCode}】供应商为空"); } if (supplierItemDto == null) { - throw new UserFriendlyException($"{supplierAsn.SupplierCode}供应商零件或{itemBasicDto.Code}零件信息为空"); + throw new UserFriendlyException($"【{supplierAsn.SupplierCode}】供应商零件或{itemBasicDto.Code}零件信息为空"); } var inputLabel = new InventoryLabelEditInput(); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/ProductReceiptNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/ProductReceiptNoteEventHandler.cs index 8646730cf..d79ffa44f 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/ProductReceiptNoteEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/ProductReceiptNoteEventHandler.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Volo.Abp; using Volo.Abp.EventBus; using Volo.Abp.Uow; using Win_in.Sfs.Basedata.Application.Contracts; @@ -76,15 +77,27 @@ public class ProductReceiptNoteEventHandler var transaction = ObjectMapper.Map(detail); var itemBasicDto= await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); - ; + var locationDtos = await _locationAppService.GetListByTypesAndErpCodeAsync( + new List { EnumLocationType.WIP }, + detail.LocationErpCode).ConfigureAwait(false); + + if (locationDtos == null) + { + throw new UserFriendlyException( + $"Erp储位为【{detail.LocationErpCode}】,库位类型为{EnumLocationType.WIP.GetDisplayName()}的库位不存在。"); + } + + if (itemBasicDto == null) + { + throw new UserFriendlyException( + $"物品编号为【{detail.ItemCode}】不存在。"); + } + detail.ItemDesc1 = itemBasicDto.Desc1; detail.ItemDesc2 = itemBasicDto.Desc2; detail.ItemName=itemBasicDto.Name; detail.StdPackQty=itemBasicDto.StdPackQty; - - var erpLocationDtos= await _locationAppService.GetListByTypesAndErpCodeAsync(new List { EnumLocationType.WIP }, - detail.LocationErpCode).ConfigureAwait(false); - var erpLocationDto = erpLocationDtos.First(); + var erpLocationDto = locationDtos.First(); detail.LocationArea = erpLocationDto.Code; detail.LocationGroup = erpLocationDto.LocationGroupCode; detail.LocationErpCode= erpLocationDto.Code;