From 2335866da6a112e8da0fecf8e4ab20da98cf13d3 Mon Sep 17 00:00:00 2001 From: lvzb <35200379@qq.com> Date: Mon, 14 Aug 2023 08:51:49 +0800 Subject: [PATCH 1/6] =?UTF-8?q?mes=E7=BC=B4=E5=BA=93=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Incoming/MesOutConverter.cs | 4 +++- .../Incoming/MesOutReader.cs | 2 +- .../Locations/ILocationAppService.cs | 3 +++ .../Locations/LocationAppService.cs | 9 +++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent/Incoming/MesOutConverter.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent/Incoming/MesOutConverter.cs index 695ae1c38..bb7a60b7e 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent/Incoming/MesOutConverter.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent/Incoming/MesOutConverter.cs @@ -90,10 +90,12 @@ public class MesOutConverter : IIncomingConverter wmsProductReceiptNoteDetail.WarehouseCode = "T8"; wmsProductReceiptNoteDetail.LocationArea = ""; wmsProductReceiptNoteDetail.LocationGroup = ""; - var loc = await _locationAppService.GetListByTypesAndErpCodeAsync(types, wmsProductReceiptNoteDetail.LocationErpCode).ConfigureAwait(false); + var loc = await _locationAppService.GetListByTypesAndErpCodeAsync(types, wmsProductReceiptNoteDetail.LocationErpCode, wmsProductReceiptNoteDetail.LocationErpCode).ConfigureAwait(false); if (loc != null) { wmsProductReceiptNoteDetail.LocationCode = loc[0].Code; + wmsProductReceiptNoteDetail.LocationArea = loc[0].AreaCode; + wmsProductReceiptNoteDetail.LocationGroup = loc[0].LocationGroupCode; } diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent/Incoming/MesOutReader.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent/Incoming/MesOutReader.cs index 63b9d0c06..def88e103 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent/Incoming/MesOutReader.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent/Incoming/MesOutReader.cs @@ -95,7 +95,7 @@ public class MesOutReader : IReader continue; } List types = new List { EnumLocationType.FG, EnumLocationType.WIP }; - var loc = await _locationAppService.GetListByTypesAndErpCodeAsync(types, item.Mesout_loc).ConfigureAwait(false); + var loc = await _locationAppService.GetListByTypesAndErpCodeAsync(types, item.Mesout_loc, item.Mesout_loc).ConfigureAwait(false); if (loc.Count == 0) { mesoutnbr.Add(item.Mesout_ref_nbr); diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Locations/ILocationAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Locations/ILocationAppService.cs index 2e2f7f1b9..a46e86f0a 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Locations/ILocationAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Locations/ILocationAppService.cs @@ -30,4 +30,7 @@ public interface ILocationAppService Task> GetListByManyCodes(List codes); Task> GetListByTypesAndErpCodeAsync(List types, string erpCode); + Task> GetListByTypesAndErpCodeAsync(List types, string erpCode,string locCode); + + } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Locations/LocationAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Locations/LocationAppService.cs index 70123d34f..61e0db700 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Locations/LocationAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Locations/LocationAppService.cs @@ -164,6 +164,15 @@ public class LocationAppService var dtos = ObjectMapper.Map, List>(locations); return dtos; } + [HttpGet("list/by-types-and-erp-code")] + public virtual async Task> GetListByTypesAndErpCodeAsync(List types, string erpCode,string locCode) + { + var locations = await _repository.GetListAsync(c => types.Contains(c.Type) && c.ErpLocationCode == erpCode&&c.Code==locCode).ConfigureAwait(false); + var dtos = ObjectMapper.Map, List>(locations); + return dtos; + } + + [HttpGet("list/by-location-group-code-and-location-type")] public virtual async Task> GeListByLocationGroupCodeAndLocationType(List locationGroupCodes, List locationTypes) From 64ac71f73f426fa8c8e2cbe34b600a152fc15406 Mon Sep 17 00:00:00 2001 From: lvzb <35200379@qq.com> Date: Mon, 14 Aug 2023 10:23:43 +0800 Subject: [PATCH 2/6] =?UTF-8?q?wms=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataExchangeOptions.cs | 1 + .../IncomingToWmsWorker.cs | 54 +++++++++++-------- .../appsettings.json | 10 ++-- 3 files changed, 40 insertions(+), 25 deletions(-) diff --git a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/DataExchangeOptions.cs b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/DataExchangeOptions.cs index 1dc8acf8c..1731c384a 100644 --- a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/DataExchangeOptions.cs +++ b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/DataExchangeOptions.cs @@ -12,6 +12,7 @@ public class IncomingOptions public int PeriodSeconds { get; set; } = 5 * 60; public int RetryTimes { get; set; } = 3; public int BatchSize { get; set; } = 100; + public string apiUrl { get; set; } = ""; } public class OutgoingOptions diff --git a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/IncomingToWmsWorker.cs b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/IncomingToWmsWorker.cs index 347421104..dcd78cc32 100644 --- a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/IncomingToWmsWorker.cs +++ b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/IncomingToWmsWorker.cs @@ -141,7 +141,7 @@ public class IncomingToWmsWorker : AsyncPeriodicBackgroundWorkerBase await incomingToWms.HandleAsnsAsync(workerContext).ConfigureAwait(false); break; case EnumIncomingDataType.ProductReceipt: - await SendProductReceipt(workerContext, incomingToWms); + await SendProductReceipt(workerContext, incomingToWms).ConfigureAwait(false); break; case EnumIncomingDataType.MaterialRequest: await incomingToWms.HandleMaterialRequestsAsync(workerContext).ConfigureAwait(false); @@ -169,34 +169,44 @@ public class IncomingToWmsWorker : AsyncPeriodicBackgroundWorkerBase private async Task SendProductReceipt(PeriodicBackgroundWorkerContext workerContext, IncomingToWms incomingToWms) { // 定义请求的 URL - string apiUrl = "http://10.164.113.31:60085/api/wms/store/product-receipt-note"; - - var productReceiptJson = JsonSerializer.Deserialize(incomingToWms.DataContent); - try + // string apiUrl = "http://10.164.113.31:60085/api/wms/store/product-receipt-note"; + + string apiUrl = _options.Value.IncomingOptions.apiUrl; + + if (!string.IsNullOrEmpty(apiUrl)) { - - // 将参数转换为 JSON 格式 - string jsonContent = JsonSerializer.Serialize(productReceiptJson); + var productReceiptJson = JsonSerializer.Deserialize(incomingToWms.DataContent); + try + { + + // 将参数转换为 JSON 格式 + string jsonContent = JsonSerializer.Serialize(productReceiptJson); - // 创建请求的内容 - StringContent content = new StringContent(jsonContent, Encoding.UTF8, "application/json"); + // 创建请求的内容 + StringContent content = new StringContent(jsonContent, Encoding.UTF8, "application/json"); - - // 发送 POST 请求 - HttpResponseMessage response = await _httpClient.PostAsync(apiUrl, content); - // 确保响应成功 - response.EnsureSuccessStatusCode(); + // 发送 POST 请求 + HttpResponseMessage response = await _httpClient.PostAsync(apiUrl, content).ConfigureAwait(false); - // 读取响应内容并返回 - string responseBody = await response.Content.ReadAsStringAsync(); + // 确保响应成功 + response.EnsureSuccessStatusCode(); + + // 读取响应内容并返回 + string responseBody = await response.Content.ReadAsStringAsync().ConfigureAwait(false); + } + catch (HttpRequestException ex) + { + // 处理请求异常 + // 可以记录日志或者抛出异常 + Console.WriteLine(ex.Message); + //incomingToWms.SetError(EnumExchangeDataErrorCode.Exception, ex.Message); + } } - catch (HttpRequestException ex) + else { - // 处理请求异常 - // 可以记录日志或者抛出异常 - Console.WriteLine(ex.Message); - //incomingToWms.SetError(EnumExchangeDataErrorCode.Exception, ex.Message); + Console.WriteLine("apiUrl未配置!"); + } //finally //{ diff --git a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/appsettings.json b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/appsettings.json index bf959b2e1..c3163280c 100644 --- a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/appsettings.json +++ b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/appsettings.json @@ -1,7 +1,7 @@ { "ConnectionStrings": { - "Default": "Server=10.164.113.32,1818\\SHDB;Database=WMS_DongYang_DataExchange;uid=ShWmsUser;pwd=Faty@Wms_20230413#SH;TrustServerCertificate=True", - "DataExchange": "Server=10.164.113.32,1818\\SHDB;Database=WMS_DongYang_DataExchange;uid=ShWmsUser;pwd=Faty@Wms_20230413#SH;TrustServerCertificate=True" + "Default": "Server=10.164.113.32,1818\\SHDB;Database=Wms_DataExchange_Main_Dy_ShangHai;uid=ShWmsUser;pwd=Faty@Wms_20230413#SH;TrustServerCertificate=True", + "DataExchange": "Server=10.164.113.32,1818\\SHDB;Database=Wms_DataExchange_Main_Dy_ShangHai;uid=ShWmsUser;pwd=Faty@Wms_20230413#SH;TrustServerCertificate=True" }, @@ -43,7 +43,8 @@ "Active": true, "PeriodSeconds": 10, "RetryTimes": 3, - "BatchSize": 100 + "BatchSize": 100, + "apiUrl": "http://10.164.113.31:60085/api/wms/store/product-receipt-note" }, "OutgoingOptions": { "Active": false, @@ -58,3 +59,6 @@ } + + + From 2c12375f94e3e900ed14ac01816c434b77c4905c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=B8=A4=E6=97=AD=5BIrelia=5D?= <366601522@qq.com> Date: Tue, 15 Aug 2023 15:24:11 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=8C=E5=B7=A5?= =?UTF-8?q?=E5=BA=93=E4=BD=8D=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Transactions/ProductReceiptNoteEventHandler.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 d20477238..51f04c5f1 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 @@ -78,8 +78,9 @@ public class ProductReceiptNoteEventHandler var itemBasicDto= await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); var locationDtos = await _locationAppService.GetListByTypesAndErpCodeAsync( - new List { EnumLocationType.WIP }, - detail.LocationErpCode).ConfigureAwait(false); + new List { EnumLocationType.WIP,EnumLocationType.FG }, + detail.LocationErpCode, + detail.LocationCode).ConfigureAwait(false); if (locationDtos == null||locationDtos.Count<1) { From 5e3b87dee404bcd8075dd0365897a818357edf09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=B8=A4=E6=97=AD=5BIrelia=5D?= <366601522@qq.com> Date: Tue, 15 Aug 2023 15:28:04 +0800 Subject: [PATCH 4/6] 1 --- .../ProductReceiptNoteEventHandler.cs | 15 --------------- 1 file changed, 15 deletions(-) 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 51f04c5f1..e000b4e8a 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 @@ -77,16 +77,6 @@ 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,EnumLocationType.FG }, - detail.LocationErpCode, - detail.LocationCode).ConfigureAwait(false); - - if (locationDtos == null||locationDtos.Count<1) - { - throw new UserFriendlyException( - $"Erp储位为【{detail.LocationErpCode}】,库位类型为{EnumLocationType.WIP.GetDisplayName()}的库位不存在。"); - } if (itemBasicDto == null) { @@ -98,11 +88,6 @@ public class ProductReceiptNoteEventHandler detail.ItemDesc2 = itemBasicDto.Desc2; detail.ItemName=itemBasicDto.Name; detail.StdPackQty=itemBasicDto.StdPackQty; - var erpLocationDto = locationDtos.First(); - detail.LocationArea = erpLocationDto.Code; - detail.LocationGroup = erpLocationDto.LocationGroupCode; - detail.LocationErpCode= erpLocationDto.Code; - detail.LocationCode= erpLocationDto.Code; transaction.TransType = TransType; transaction.TransInOut = TransInOut; From 8796f597c1416f28e974a88282bfd0a06be1fe8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=B8=A4=E6=97=AD=5BIrelia=5D?= <366601522@qq.com> Date: Tue, 15 Aug 2023 22:24:56 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=8C=E5=B7=A5?= =?UTF-8?q?=E6=94=B6=E8=B4=A7=E8=B5=8B=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Incoming/MesOutConverter.cs | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent/Incoming/MesOutConverter.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent/Incoming/MesOutConverter.cs index bb7a60b7e..0910e4add 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent/Incoming/MesOutConverter.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent/Incoming/MesOutConverter.cs @@ -12,6 +12,7 @@ using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Wms.DataExchange.Domain; using Win_in.Sfs.Wms.DataExchange.WMS.ProductReceiptNote; using Win_in.Sfs.Wms.Store.Application.Contracts; +using Win_in.Sfs.Wms.Store.Domain; namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent; @@ -96,25 +97,41 @@ public class MesOutConverter : IIncomingConverter wmsProductReceiptNoteDetail.LocationCode = loc[0].Code; wmsProductReceiptNoteDetail.LocationArea = loc[0].AreaCode; wmsProductReceiptNoteDetail.LocationGroup = loc[0].LocationGroupCode; - } + wmsProductReceiptNoteDetail.LocationErpCode = loc[0].ErpLocationCode; + + wmsProductReceiptNoteDetail.HandledToLocationCode = loc[0].Code; + wmsProductReceiptNoteDetail.HandledToLocationArea = loc[0].AreaCode; + wmsProductReceiptNoteDetail.HandledToLocationGroup = loc[0].LocationGroupCode; + wmsProductReceiptNoteDetail.HandledToLocationErpCode = loc[0].ErpLocationCode; + wmsProductReceiptNoteDetail.RecommendToLocationCode = loc[0].Code; + wmsProductReceiptNoteDetail.RecommendToLocationArea = loc[0].AreaCode; + wmsProductReceiptNoteDetail.RecommendToLocationGroup = loc[0].LocationGroupCode; + wmsProductReceiptNoteDetail.RecommendToLocationErpCode = loc[0].ErpLocationCode; + } var item = await _itemBasicAppService.GetByCodeAsync(wmsProductReceiptNoteDetail.ItemCode).ConfigureAwait(false); - if (item != null) - { + if (item != null) + { wmsProductReceiptNoteDetail.ItemName = !string.IsNullOrEmpty(item.Name) ? item.Name : ""; wmsProductReceiptNoteDetail.ItemDesc1 = !string.IsNullOrEmpty(item.Desc1) ? item.Desc1 : ""; wmsProductReceiptNoteDetail.ItemDesc2 = !string.IsNullOrEmpty(item.Desc2) ? item.Desc2 : ""; wmsProductReceiptNoteDetail.Uom = !string.IsNullOrEmpty(item.BasicUom) ? item.BasicUom : ""; - } - else - { + + wmsProductReceiptNoteDetail.ProduceDate = incomingFromExternal.EffectiveDate; + wmsProductReceiptNoteDetail.ArriveDate = incomingFromExternal.EffectiveDate; + wmsProductReceiptNoteDetail.ExpireDate = wmsProductReceiptNoteDetail.ProduceDate.AddDays(item.GetValidateDays()); + + } + else + { + //todo 这里不应该做完工 没有零件 wmsProductReceiptNoteDetail.ItemName = ""; wmsProductReceiptNoteDetail.ItemDesc1 = ""; wmsProductReceiptNoteDetail.ItemDesc2 = ""; wmsProductReceiptNoteDetail.Uom = ""; - } - wmsProductReceiptNote.Details.Add(wmsProductReceiptNoteDetail); + } + wmsProductReceiptNote.Details.Add(wmsProductReceiptNoteDetail); } incomingToWms.DataContent = JsonSerializer.Serialize(wmsProductReceiptNote); incomingToWmsList.Add(incomingToWms); From 7546e656b1b5ba1f67b7dfd593a3ccf5b050d4ac Mon Sep 17 00:00:00 2001 From: lvzb <35200379@qq.com> Date: Tue, 15 Aug 2023 22:25:12 +0800 Subject: [PATCH 6/6] =?UTF-8?q?wms=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IncomingToWmsWorker.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/IncomingToWmsWorker.cs b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/IncomingToWmsWorker.cs index dcd78cc32..5e915178c 100644 --- a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/IncomingToWmsWorker.cs +++ b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/IncomingToWmsWorker.cs @@ -163,8 +163,10 @@ public class IncomingToWmsWorker : AsyncPeriodicBackgroundWorkerBase default: throw new ArgumentOutOfRangeException(); } - - incomingToWms.SetSuccess(); + if( incomingToWms.Status != EnumExchangeDataStatus.Error) + { + incomingToWms.SetSuccess(); + } } private async Task SendProductReceipt(PeriodicBackgroundWorkerContext workerContext, IncomingToWms incomingToWms) @@ -200,13 +202,13 @@ public class IncomingToWmsWorker : AsyncPeriodicBackgroundWorkerBase // 处理请求异常 // 可以记录日志或者抛出异常 Console.WriteLine(ex.Message); - //incomingToWms.SetError(EnumExchangeDataErrorCode.Exception, ex.Message); + incomingToWms.SetError(EnumExchangeDataErrorCode.Exception, ex.Message); } } else { Console.WriteLine("apiUrl未配置!"); - + incomingToWms.SetError(EnumExchangeDataErrorCode.Exception, "apiUrl未配置!"); } //finally //{