diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/Incoming/ShipReader.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/Incoming/ShipReader.cs index 18dac4fa1..50912c74a 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/Incoming/ShipReader.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/Incoming/ShipReader.cs @@ -19,18 +19,20 @@ public class ShipReader : IReader private readonly IIncomingFromExternalManager _incomingFromExternalManager; private readonly ILogger _logger; private readonly ISupplierItemAppService _supplierItemAppService; - + private readonly ISupplierAppService _supplierAppService; public ShipReader( IShipManager shipManager , IIncomingFromExternalManager incomingFromExternalManager , ILogger logger, - ISupplierItemAppService supplierItemAppService + ISupplierItemAppService supplierItemAppService, + ISupplierAppService supplierAppService ) { _shipManager = shipManager; _incomingFromExternalManager = incomingFromExternalManager; _logger = logger; _supplierItemAppService = supplierItemAppService; + _supplierAppService = supplierAppService; } public virtual async Task> ReadAsync() @@ -103,10 +105,12 @@ public class ShipReader : IReader continue; } var supplierItemDTO = await _supplierItemAppService.GetBySupplierCodeAndItemCodeAsync(item.SupplierCode, item.ERP).ConfigureAwait(false); - if (supplierItemDTO == null) + var supplierDto = await _supplierAppService.GetByCodeAsync(item.SupplierCode).ConfigureAwait(false); + if (supplierItemDTO == null||supplierDto==null) { shipbillno.Add(item.ShipBillNo); - } + } + } return shipbillno; } 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 e5d108a13..cbaa74062 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 @@ -1,5 +1,7 @@ +using System; using System.Collections.Generic; using System.Text.Json; +using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.BackgroundWorkers; @@ -8,7 +10,6 @@ using Win_in.Sfs.Auth.Users; using Win_in.Sfs.Auth.Users.Inputs; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Label.Application.Contracts; -using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Wms.DataExchange.Domain; using Win_in.Sfs.Wms.Inventory.Application.Contracts; using Win_in.Sfs.Wms.Store.Application.Contracts; @@ -54,6 +55,25 @@ public static class IncomingToWmsExtensions var item = JsonSerializer.Deserialize(incomingConverted.DataContent); var itemBasicAppService = workerContext.ServiceProvider.GetRequiredService(); await itemBasicAppService.UpsertAsyncByInterface(item).ConfigureAwait(false); + + try + { + + var BalanceAppService = workerContext.ServiceProvider.GetRequiredService(); + BalanceUpdateItemBasicInfoDto balan = new BalanceUpdateItemBasicInfoDto(); + BalanceUpdateItemBasicInfo bala = new BalanceUpdateItemBasicInfo(); + bala.ItemCode = item.Code; + bala.ItemDesc1 = item.Desc1; + bala.ItemDesc2 = item.Desc2; + balan.BalanceUpdateItemBasicInfos.Add(bala); + await BalanceAppService.UpdateItemBasicInfoAsync(balan).ConfigureAwait(false); + } + catch (Exception e) + { + + + } + } public static async Task HandleErpLocationsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext) diff --git a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application.Contracts/Balances/DTOs/BalanceUpdateItemBasicInfoDto.cs b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application.Contracts/Balances/DTOs/BalanceUpdateItemBasicInfoDto.cs new file mode 100644 index 000000000..3b40cfb2e --- /dev/null +++ b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application.Contracts/Balances/DTOs/BalanceUpdateItemBasicInfoDto.cs @@ -0,0 +1,45 @@ +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace Win_in.Sfs.Wms.Inventory.Application.Contracts; + +/// +/// 库存更新物品基础信息 +/// +public class BalanceUpdateItemBasicInfoDto +{ + /// + /// 库存更新物品基础信息 + /// + public List BalanceUpdateItemBasicInfos { get; set; } +} + +/// +/// 库存更新物品基础信息 +/// +public class BalanceUpdateItemBasicInfo +{ + /// + /// 物品编码 + /// + [Display(Name = "物品编码")] + public string ItemCode { get; set; } + + /// + /// 物品名称 + /// + [Display(Name = "物品名称")] + public string ItemName { get; set; } + + /// + /// 物品描述1 + /// + [Display(Name = "物品描述1")] + public string ItemDesc1 { get; set; } + + /// + /// 物品描述2 + /// + [Display(Name = "物品描述2")] + public string ItemDesc2 { get; set; } +} diff --git a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application.Contracts/Balances/IBalanceAppService.cs b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application.Contracts/Balances/IBalanceAppService.cs index 9c6dcd45c..cf79d0628 100644 --- a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application.Contracts/Balances/IBalanceAppService.cs +++ b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application.Contracts/Balances/IBalanceAppService.cs @@ -151,4 +151,10 @@ public interface IBalanceAppService string lot, string locationCode, EnumInventoryStatus status); + + /// + /// 库存余额更新物品基础信息 + /// + Task UpdateItemBasicInfoAsync(BalanceUpdateItemBasicInfoDto balanceUpdateItemBasicInfoDto); + } diff --git a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/Balances/BalanceAppService.cs b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/Balances/BalanceAppService.cs index bcfbbed1c..4d1ebb37b 100644 --- a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/Balances/BalanceAppService.cs +++ b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/Balances/BalanceAppService.cs @@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Volo.Abp; using Volo.Abp.Application.Dtos; +using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Repositories; using Win_in.Sfs.Shared.Application.Contracts; using Win_in.Sfs.Shared.Domain; @@ -650,4 +651,44 @@ public class BalanceAppService } #endregion Get + + /// + /// 库存余额更新物品基础信息 + /// + [HttpPost("update/item-basic-info")] + public async Task UpdateItemBasicInfoAsync(BalanceUpdateItemBasicInfoDto balanceUpdateItemBasicInfoDto) + { + // 物品编码 + var itemCodes = balanceUpdateItemBasicInfoDto.BalanceUpdateItemBasicInfos?.Select(c => c.ItemCode); + itemCodes = itemCodes?.Where(t => string.IsNullOrWhiteSpace(t) == false); + if (itemCodes == null || itemCodes.Any() == false) + { + return; + } + + // 获取库存余额 + var entitys = await _repository.GetListAsync(p => + itemCodes.Contains(p.ItemCode)).ConfigureAwait(false); + if (entitys.Count <= 0) + { + return; + } + + // 库存余额更新物品基础信息 + var entitysGroup = entitys.GroupBy(t => t.ItemCode); + + foreach (var entity in entitysGroup) + { + var balanceUpdateItemBasicInfo = balanceUpdateItemBasicInfoDto.BalanceUpdateItemBasicInfos.FirstOrDefault(t => t.ItemCode == entity.Key); + foreach (var item in entity) + { + item.ItemName = balanceUpdateItemBasicInfo.ItemName ?? item.ItemName; + item.ItemDesc1 = balanceUpdateItemBasicInfo.ItemDesc1 ?? item.ItemDesc1; + item.ItemDesc2 = balanceUpdateItemBasicInfo.ItemDesc2 ?? item.ItemDesc2; + } + } + + await _repository.UpdateManyAsync(entitys).ConfigureAwait(false); + } + } diff --git a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Domain/Balances/BalanceManager.cs b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Domain/Balances/BalanceManager.cs index a7babf41a..526f26173 100644 --- a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Domain/Balances/BalanceManager.cs +++ b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Domain/Balances/BalanceManager.cs @@ -192,6 +192,15 @@ public class BalanceManager : DomainService, IBalanceManager Logger.LogDebug($"{transaction.DocNumber}|BeforeOutBound:{existBalance}"); if (transaction.ManageType == EnumItemManageType.SingleUnit) { + if (existBalance == null) + { + throw new UserFriendlyException($"库位在{transaction.LocationCode}," + + $"物品编号为{transaction.ItemCode}," + + $"箱码为{transaction.PackingCode}," + + $"批次为{transaction.Lot}," + + $"状态为{transaction.Status.GetDisplayName()}" + + $"的库存未找到"); + } //检查出库数量与库存数量是否一致 transaction.CheckSingleUnitQtyEqual(existBalance.Qty); @@ -263,6 +272,16 @@ public class BalanceManager : DomainService, IBalanceManager balance.Status ).ConfigureAwait(false); + if (existBalance == null) + { + throw new UserFriendlyException($"库位在{balance.LocationCode}," + + $"物品编号为{balance.ItemCode}," + + $"箱码为{balance.PackingCode}," + + $"批次为{balance.Lot}," + + $"状态为{balance.Status.GetDisplayName()}" + + $"的库存未找到"); + } + //if (!existBalance.IsActive) //{ // throw new UserFriendlyException( @@ -318,9 +337,8 @@ public class BalanceManager : DomainService, IBalanceManager protected virtual async Task GetFirstAsync(string packingCode, string itemCode, string lot, string locationCode, EnumInventoryStatus enumInventoryStatus) { - var balance = await _balanceRepository - .FindAsync(p => p.ItemCode == itemCode + .FirstOrDefaultAsync(p => p.ItemCode == itemCode && p.LocationCode == locationCode && p.Lot == lot && p.PackingCode == packingCode @@ -451,14 +469,14 @@ public class BalanceManager : DomainService, IBalanceManager { expression = expression.And(p => p.ExpireDate > DateTime.Now); } - //筛选有效库区 - if (validLocationAreas.Any() ) - { - if (!string.IsNullOrEmpty(validLocationAreas[0])) - { - expression = expression.And(p => validLocationAreas.Contains(p.LocationArea)); - } - } + //筛选有效库区 2023-6-29 李智慧 王旭 袁静雯 确认不需要做区域校验 + //if (validLocationAreas.Any()) + //{ + // if (!string.IsNullOrEmpty(validLocationAreas[0])) + // { + // expression = expression.And(p => validLocationAreas.Contains(p.LocationArea)); + // } + //} var allBalances = await (await _balanceRepository.GetDbSetAsync().ConfigureAwait(false)) .Where(expression) @@ -606,7 +624,7 @@ public class BalanceManager : DomainService, IBalanceManager Logger.LogDebug($"{traceId}:RequestQty:{requestQty},RemainQty:{remainingQty},AvailableQty:{balanceQty},RecommendQty:{recommendQty}"); return recommendQty; } - + /// /// 计算推荐库位 /// diff --git a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Domain/Balances/BalanceValidateExtension.cs b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Domain/Balances/BalanceValidateExtension.cs index aafbf6dba..a512067eb 100644 --- a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Domain/Balances/BalanceValidateExtension.cs +++ b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Domain/Balances/BalanceValidateExtension.cs @@ -108,7 +108,6 @@ public static class BalanceValidateExtension /// public static List SortByFifo(this List balances) { - return balances .OrderBy(p => p.Lot) .ThenBy(p => p.ArriveDate) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/BackFlusNotes/IBackFlushNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/BackFlusNotes/IBackFlushNoteAppService.cs index 2de4b8ab2..84c8f5aa8 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/BackFlusNotes/IBackFlushNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/BackFlusNotes/IBackFlushNoteAppService.cs @@ -9,5 +9,5 @@ ISfsStoreMasterReadOnlyAppServiceBase> CreateManyAsync(List inputs); - Task> GetListByProductRecycleNumber(string number); + Task> GetListByProductRecycleNumberAsync(string number); } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/BackFlushNotes/BackFlushNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/BackFlushNotes/BackFlushNoteAppService.cs index 07e300af2..6fd68de17 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/BackFlushNotes/BackFlushNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/BackFlushNotes/BackFlushNoteAppService.cs @@ -32,7 +32,7 @@ public class BackFlushNoteAppService : { var entities = ObjectMapper.Map, List>(inputs); - entities = await ProcessingBackFlushNoteData(entities).ConfigureAwait(false); + entities = await ProcessingBackFlushNoteDataAsync(entities).ConfigureAwait(false); entities = await _backFlushNoteManager.CreateManyAsync(entities).ConfigureAwait(false); @@ -42,7 +42,7 @@ public class BackFlushNoteAppService : } [HttpGet("by-product-recyle-number")] - public async Task> GetListByProductRecycleNumber(string number) + public async Task> GetListByProductRecycleNumberAsync(string number) { var entities = await _repository.GetListAsync(t => t.ProductRecycleNumber == number, true) .ConfigureAwait(false); @@ -54,11 +54,16 @@ public class BackFlushNoteAppService : /// 处理数据 /// /// - private async Task> ProcessingBackFlushNoteData(List backFlushNotes) + private async Task> ProcessingBackFlushNoteDataAsync(List backFlushNotes) { if (backFlushNotes != null && backFlushNotes.Count > 0) { + // 主零件号 var itemCodes = backFlushNotes.Select(t => t.ItemCode); + // 从零件号 + var detailsItemCodes = backFlushNotes.SelectMany(t => t.Details).Select(t => t.ItemCode); + itemCodes = itemCodes.Concat(detailsItemCodes).Distinct(); + List itemBasicDtos = await _itemBasicAppService.GetByCodesAsync(itemCodes).ConfigureAwait(false); backFlushNotes.ForEach(t => @@ -70,8 +75,12 @@ public class BackFlushNoteAppService : t.ItemDesc2 = itemBasicDto.Desc2; t.Details.ForEach(tDetail => { - tDetail.ItemDesc1 = itemBasicDto.Desc1; - tDetail.ItemDesc2 = itemBasicDto.Desc2; + var detailsItemBasicDto = itemBasicDtos.FirstOrDefault(w => w.Code == tDetail.ItemCode); + if (detailsItemBasicDto != null) + { + tDetail.ItemDesc1 = detailsItemBasicDto.Desc1; + tDetail.ItemDesc2 = detailsItemBasicDto.Desc2; + } }); } }); 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 042e52d93..d6a62e406 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 @@ -95,6 +95,8 @@ public class CountNoteAppService : detail.LocationGroup = locationDto.LocationGroupCode; detail.LocationErpCode = locationDto.ErpLocationCode; detail.WarehouseCode = locationDto.WarehouseCode; + detail.PackingCode=detail.PackingCode ?? ""; + detail.Lot = detail.Lot ?? ""; detail.ItemCode = itemcBasicDto.Code; detail.ItemDesc1 = itemcBasicDto.Desc1; diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/CountAdjustRequestEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/CountAdjustRequestEventHandler.cs index e927211b9..c26fbd720 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/CountAdjustRequestEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/CountAdjustRequestEventHandler.cs @@ -50,6 +50,12 @@ public class CountAdjustRequestEventHandler { if (entity.DirectCreateNote) { + entity.Details.ForEach(p => + { + p.PackingCode = p.PackingCode ?? ""; + p.Lot = p.Lot ?? ""; + p.ContainerCode = p.ContainerCode ?? ""; + }); await ThawBalancesAsync(entity).ConfigureAwait(false); var note = await BuildCountAdjustNoteCreateInputAsync(entity).ConfigureAwait(false);