From af56472e4a0e6555edf4962e873cb24c65c7a382 Mon Sep 17 00:00:00 2001 From: lvzb <35200379@qq.com> Date: Mon, 22 Jul 2024 17:01:06 +0800 Subject: [PATCH] =?UTF-8?q?EOS=E4=BA=A7=E5=93=81=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=8Ctyrp=E5=BC=80=E8=B4=A6=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=94=B9=E4=B8=BA=E5=A2=9E=E9=87=8F=E6=8E=A5=E6=94=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Incoming/ProductReader.cs | 2 +- .../FawtygAutoMapperProfile.cs | 1 + .../Incoming/ErpLocationItemReader.cs | 48 ++++++++++++------- .../WMS/ErpLocationItem/ErpLocationItem.cs | 14 ++++++ 4 files changed, 47 insertions(+), 18 deletions(-) diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/Incoming/ProductReader.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/Incoming/ProductReader.cs index c974dae55..2d77cc231 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/Incoming/ProductReader.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent/Incoming/ProductReader.cs @@ -45,7 +45,7 @@ public class ProductReader : IReader return new List(); } //Product逐一转换为ItemPack - var incomingDataList = BuildIncomingFromExternalFromProductAsync(toBeProcessedProducts.Where(r => !string.IsNullOrWhiteSpace(r.Code)).ToList()); + var incomingDataList = BuildIncomingFromExternalFromProductAsync(toBeProcessedProducts).ToList(); await _incomingFromExternalManager.CreateBulkAsync(incomingDataList).ConfigureAwait(false); return incomingDataList; diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/FawtygAutoMapperProfile.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/FawtygAutoMapperProfile.cs index 300c8bd05..53f9205a6 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/FawtygAutoMapperProfile.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/FawtygAutoMapperProfile.cs @@ -130,5 +130,6 @@ public class FawtygAutoMapperProfile : Profile CreateMap(); CreateMap(); CreateMap(); + CreateMap(); } } diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Incoming/ErpLocationItemReader.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Incoming/ErpLocationItemReader.cs index 5fdea32b5..59dbe2d5b 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Incoming/ErpLocationItemReader.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Incoming/ErpLocationItemReader.cs @@ -7,11 +7,13 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using Volo.Abp.Guids; using Volo.Abp.ObjectMapping; +using Win_in.Sfs.Basedata.Application; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Wms.DataExchange.Domain; using Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp; using Win_in.Sfs.Wms.DataExchange.Domain.Shared; using Win_in.Sfs.Wms.DataExchange.WMS.ErpLocationItem; +using Win_in.Sfs.Wms.DataExchange.WMS.ItemBasic; namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent.Incoming; @@ -22,12 +24,16 @@ public class ErpLocationItemReader : IReader private readonly ILogger _logger; private readonly IGuidGenerator _guidGenerator; private readonly IConfiguration _configuration; + private readonly IErpLocationItemAppService _erpLocationItemAppService; + private readonly IObjectMapper _objectMapper; public ErpLocationItemReader( IErpLocationItemManager ilocdoutManager , IIncomingFromExternalManager incomingFromExternalManager , IGuidGenerator guidGenerator , ILogger logger , IConfiguration configuration + , IErpLocationItemAppService erpLocationItemAppService + , IObjectMapper objectMapper ) { _guidGenerator = guidGenerator; @@ -35,35 +41,41 @@ public class ErpLocationItemReader : IReader _ilocdoutManager = ilocdoutManager; _incomingFromExternalManager = incomingFromExternalManager; _logger = logger; + _erpLocationItemAppService = erpLocationItemAppService; + _objectMapper = objectMapper; } public virtual async Task> ReadAsync() { //从Tyrp读取待处理locdout - var toBeProcessedIssue = await _ilocdoutManager.GetToBeProcessedListAsync().ConfigureAwait(false); - if (!toBeProcessedIssue.Any()) + var toBeProcessedItems = await _ilocdoutManager.GetToBeProcessedListAsync().ConfigureAwait(false); + //获取wms开账数据 + SfsBaseDataRequestInputBase input = new SfsBaseDataRequestInputBase(); + var wmsErpLocationItems = await _erpLocationItemAppService.GetAllListByFilterAsync(input).ConfigureAwait(false); + var wmsToErpLocationItemExchangeDtos = _objectMapper.Map, List>(wmsErpLocationItems); + List tyrpToItemBasicExchangeDtos = new List(); + foreach (var locdout in toBeProcessedItems) + { + var erpLocationItem = BuildErpLocationItemExchangeMes(locdout); + tyrpToItemBasicExchangeDtos.Add(erpLocationItem); + } + //和wms和tyrp数据进行比较,获取需要处理得数据 + var updateDatas = tyrpToItemBasicExchangeDtos.Except(wmsToErpLocationItemExchangeDtos).ToList(); + + if (!updateDatas.Any()) { _logger.LogInformation("未读到Tyrp开账数据"); return new List(); } - //locdout逐一转换为locdout - var incomingDataList = BuildIncomingFromExternalFromBomAsync(toBeProcessedIssue); - await _incomingFromExternalManager.CreateBulkAsync(incomingDataList).ConfigureAwait(false); - return incomingDataList; - } - private List BuildIncomingFromExternalFromBomAsync(List toBeProcessedIssue) - { - var incomingDataList = new List(); - foreach (var locdout in toBeProcessedIssue) + List incomingDataList = new List(); + foreach (var data in updateDatas) { - var incomingData = BuildIncomingFromExternal(locdout); - + var item = toBeProcessedItems.FirstOrDefault(r => r.locdout_loc == data.ErpLocationCode&&r.locdout_part==data.ItemCode); + var incomingData = BuildIncomingFromExternal(item); incomingData.SetEffectiveDate(DateTime.Now); - try { - var bm = BuildScrapNoteOrderExchangeMes(locdout); - incomingData.DestinationDataContent = JsonSerializer.Serialize(bm); + incomingData.DestinationDataContent = JsonSerializer.Serialize(data); incomingData.SetId(_guidGenerator.Create()); } catch (Exception ex) @@ -74,8 +86,10 @@ public class ErpLocationItemReader : IReader incomingDataList.Add(incomingData); } + await _incomingFromExternalManager.CreateBulkAsync(incomingDataList).ConfigureAwait(false); return incomingDataList; } + private IncomingFromExternal BuildIncomingFromExternal(locdout locdout) { var incomingData = new IncomingFromExternal() @@ -95,7 +109,7 @@ public class ErpLocationItemReader : IReader return incomingData; } - private static ErpLocationItemExchangeDto BuildScrapNoteOrderExchangeMes(locdout locdout) + private ErpLocationItemExchangeDto BuildErpLocationItemExchangeMes(locdout locdout) { var cust = new ErpLocationItemExchangeDto() diff --git a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/WMS/ErpLocationItem/ErpLocationItem.cs b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/WMS/ErpLocationItem/ErpLocationItem.cs index 180e65e2b..2e5694bf9 100644 --- a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/WMS/ErpLocationItem/ErpLocationItem.cs +++ b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/WMS/ErpLocationItem/ErpLocationItem.cs @@ -20,4 +20,18 @@ public class ErpLocationItemExchangeDto [Required(ErrorMessage = "{0}是必填项")] [StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] public string ItemCode { get; set; } + + public override bool Equals(object obj) + { + if (obj is ErpLocationItemExchangeDto) + { + ErpLocationItemExchangeDto item = obj as ErpLocationItemExchangeDto; + return ErpLocationCode == item.ErpLocationCode && ItemCode == item.ItemCode; + } + return false; + } + public override int GetHashCode() + { + return ErpLocationCode.GetHashCode()^ ItemCode.GetHashCode(); + } }