From 0f4a3549ec70f5799294a836dee3cadda2660852 Mon Sep 17 00:00:00 2001 From: 肖洋 <cathay_xy@163.com> Date: 星期三, 20 十一月 2024 11:11:48 +0800 Subject: [PATCH] MOMIP改为可配置 --- Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs | 41 ++++++++- Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/Const/ConfigConst.cs | 45 +++++++++++ Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs | 64 ++++++++------- Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/Unbind/UnbindService.cs | 36 ++++++++- Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs | 28 +++++- 5 files changed, 168 insertions(+), 46 deletions(-) diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/Const/ConfigConst.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/Const/ConfigConst.cs index 93d08c3..55311cd 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/Const/ConfigConst.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/Const/ConfigConst.cs @@ -25,6 +25,11 @@ /// IP鎺ュ彛鍦板潃 /// </summary> public const string CONFIG_SYS_IPAddress = "CONFIG_SYS_IPAddress"; + + /// <summary> + /// MOM鎺ュ彛鍦板潃 + /// </summary> + public const string SYS_MOMIPAddress = "SYS_MOMIPAddress"; } /// <summary> @@ -75,5 +80,45 @@ /// HK IP /// </summary> public const string HKIPAddress = "HKIPAddress"; + + /// <summary> + /// MOMIP鍦板潃 + /// </summary> + public const string MOMBaseIP = "MOMBaseIP"; + + /// <summary> + /// 鍗曠數鑺睘鎬ц幏鍙� + /// </summary> + public const string CellState = "CellState"; + + /// <summary> + /// 鏁寸洏鐢佃姱灞炴�ц幏鍙� + /// </summary> + public const string TrayCellsStatus = "TrayCellsStatus"; + + /// <summary> + /// 闈欑疆\闄堝寲鍏ュ簱锛堟暣鎵樼洏锛� + /// </summary> + public const string AgingInput = "AgingInput"; + + /// <summary> + /// 闈欑疆\闄堝寲鍑哄簱锛堟暣鎵樼洏锛� + /// </summary> + public const string AgingOutput = "AgingOutput"; + + /// <summary> + /// 宸ヨ壓璺嚎鐢宠 + /// </summary> + public const string ProcessApply = "ProcessApply"; + + /// <summary> + /// 鎵樼洏鍗曠數鑺В缁� + /// </summary> + public const string TrayCellUnbind = "TrayCellUnbind"; + + /// <summary> + /// 鏁寸洏鐢佃姱瑙g粦 + /// </summary> + public const string TrayUnbind = "TrayUnbind"; } } \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs index 4d7c2c4..5b55915 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs @@ -2,8 +2,11 @@ using Masuit.Tools; using WIDESEA_Common; using WIDESEA_Core; +using WIDESEA_Core.Const; using WIDESEA_DTO; using WIDESEA_DTO.MOM; +using WIDESEA_IServices; +using WIDESEA_IStorageBasicService; using WIDESEA_IStoragIntegrationServices; namespace WIDESEA_StoragIntegrationServices; @@ -11,6 +14,12 @@ public class AgingInOrOutInputService : IAgingInOrOutInputService { private readonly LogFactory LogFactory = new LogFactory(); + private readonly ISys_ConfigService _configService; + + public AgingInOrOutInputService(ISys_ConfigService configRepository) + { + _configService = configRepository; + } /// <summary> /// 闈欑疆\闄堝寲鍏ュ簱锛堟暣鎵樼洏锛� @@ -26,11 +35,21 @@ input.EmployeeNo = "MITest"; input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ"); var inputJson = input.ToDictionary(); - var x = await HttpsClient.PostAsync("http://c24-cellmi3:12020/api/MachineIntegration/AgingInput", inputJson); - content.OK(data: x); + var configs = _configService.GetConfigsByCategory(CateGoryConst.SYS_MOMIPAddress); + var wmsBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.MOMBaseIP)?.ConfigValue; + var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.AgingInput)?.ConfigValue; + if (wmsBase == null || ipAddress == null) + { + throw new InvalidOperationException("WMS IP 鏈厤缃�"); + } + var wmsIpAddress = wmsBase + ipAddress; + + var result = HttpsClient.PostAsync(wmsIpAddress, inputJson).Result; + //var x = await HttpsClient.PostAsync("http://c24-cellmi3:12020/api/MachineIntegration/AgingInput", inputJson); + content.OK(data: result); LogFactory.GetLog("闈欑疆闄堝寲鍏ュ簱锛堟暣鎵樼洏锛�").Info(true, $"\r\r--------------------------------------"); - LogFactory.GetLog("闈欑疆闄堝寲鍏ュ簱锛堟暣鎵樼洏锛�").Info(true, x); + LogFactory.GetLog("闈欑疆闄堝寲鍏ュ簱锛堟暣鎵樼洏锛�").Info(true, result); } catch (Exception err) { @@ -55,10 +74,20 @@ input.EmployeeNo = "MITest"; input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ"); var inputJson = input.ToDictionary(); - var x = await HttpsClient.PostAsync("http://c24-cellmi3:12020/api/MachineIntegration/AgingOutput", inputJson); - content.OK(data: x); + var configs = _configService.GetConfigsByCategory(CateGoryConst.SYS_MOMIPAddress); + var wmsBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.MOMBaseIP)?.ConfigValue; + var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.AgingOutput)?.ConfigValue; + if (wmsBase == null || ipAddress == null) + { + throw new InvalidOperationException("WMS IP 鏈厤缃�"); + } + var wmsIpAddress = wmsBase + ipAddress; + + var result = HttpsClient.PostAsync(wmsIpAddress, inputJson).Result; + //var x = await HttpsClient.PostAsync("http://c24-cellmi3:12020/api/MachineIntegration/AgingOutput", inputJson); + content.OK(data: result); LogFactory.GetLog("闈欑疆闄堝寲鍑哄簱锛堟暣鎵樼洏锛�").Info(true, $"\r\r--------------------------------------"); - LogFactory.GetLog("闈欑疆闄堝寲鍑哄簱锛堟暣鎵樼洏锛�").Info(true, x); + LogFactory.GetLog("闈欑疆闄堝寲鍑哄簱锛堟暣鎵樼洏锛�").Info(true, result); } catch (Exception err) { diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs index bb14e28..2746a02 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs @@ -3,9 +3,14 @@ using Newtonsoft.Json; using WIDESEA_Common; using WIDESEA_Core; +using WIDESEA_Core.Const; +using WIDESEA_Core.Helper; using WIDESEA_DTO; +using WIDESEA_IRepository; +using WIDESEA_IServices; using WIDESEA_IStorageBasicService; using WIDESEA_IStoragIntegrationServices; +using static Org.BouncyCastle.Math.EC.ECCurve; namespace WIDESEA_StoragIntegrationServices; @@ -14,10 +19,12 @@ private readonly LogFactory LogFactory = new LogFactory(); private readonly IBoxingInfoService _boxingInfoService; + private readonly ISys_ConfigService _configService; - public CellStateService(IBoxingInfoService boxingInfoService) + public CellStateService(IBoxingInfoService boxingInfoService, ISys_ConfigService configRepository) { _boxingInfoService = boxingInfoService; + _configService = configRepository; } /// <summary> @@ -34,7 +41,17 @@ input.EmployeeNo = "MITest"; input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ"); var inputJson = input.ToDictionary(); - var x = await HttpsClient.PostAsync("http://c24-cellmi3:12020/api/MachineIntegration/CellState", inputJson); + var configs = _configService.GetConfigsByCategory(CateGoryConst.SYS_MOMIPAddress); + var wmsBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.MOMBaseIP)?.ConfigValue; + var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.CellState)?.ConfigValue; + if (wmsBase == null || ipAddress == null) + { + throw new InvalidOperationException("WMS IP 鏈厤缃�"); + } + var wmsIpAddress = wmsBase + ipAddress; + + var result = HttpsClient.PostAsync(wmsIpAddress, inputJson).Result; + //var x = await HttpsClient.PostAsync("http://c24-cellmi3:12020/api/MachineIntegration/CellState", inputJson); #region //if (x != null) //{ @@ -65,8 +82,8 @@ #endregion LogFactory.GetLog("鍗曠數鑺睘鎬ц幏鍙�").Info(true, $"\r\r--------------------------------------"); - LogFactory.GetLog("鍗曠數鑺睘鎬ц幏鍙�").Info(true, x); - return x; + LogFactory.GetLog("鍗曠數鑺睘鎬ц幏鍙�").Info(true, result); + return result; } catch (Exception err) { @@ -93,36 +110,21 @@ input.EmployeeNo = "MITest"; input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ"); var inputJson = input.ToDictionary(); - var x = await HttpsClient.PostAsync("http://c24-cellmi3:12020/api/MachineIntegration/TrayCellsStatus", inputJson); - if (x != null) + var configs = _configService.GetConfigsByCategory(CateGoryConst.SYS_MOMIPAddress); + var wmsBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.MOMBaseIP)?.ConfigValue; + var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.TrayCellsStatus)?.ConfigValue; + if (wmsBase == null || ipAddress == null) { - // 鍙嶅簭鍒楀寲ResultTrayCellsStatus瀵硅薄 - //ResultTrayCellsStatus result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(x); - - //// 鍒涘缓DtBoxingInfo瀵硅薄 - //DtBoxingInfo boxingInfo = new DtBoxingInfo - //{ - // IsFull = true, - // PalletCode = result.TrayBarcode, - //}; - - //// 浣跨敤LINQ鍒涘缓DtBoxingInfoDetail瀵硅薄鍒楄〃 - //var details = result.SerialNos.Select(item => new DtBoxingInfoDetail - //{ - // SerialNumber = item.SerialNo, - // OrderNo = item.PositionNo.ToString(), - // Status = item.SerialNoStatus, - // Remark = result.TrayBarcodePropertys.ToJsonString(), - // MaterielCode = result.BindCode, - //}).ToList(); - - //// 璧嬪�糄tBoxingInfoDetails - //boxingInfo.BoxingInfoDetails = details; - //var abc = await _boxingInfoService.AddBoxingInfoAsync(boxingInfo); - content.OK("缁勭洏鎴愬姛", x); + throw new InvalidOperationException("WMS IP 鏈厤缃�"); } + var wmsIpAddress = wmsBase + ipAddress; + + var result = HttpsClient.PostAsync(wmsIpAddress, inputJson).Result; + //var x = await HttpsClient.PostAsync("http://c24-cellmi3:12020/api/MachineIntegration/TrayCellsStatus", inputJson); + LogFactory.GetLog("鏁寸洏鐢佃姱灞炴�ц幏鍙�").Info(true, $"\r\r--------------------------------------"); - LogFactory.GetLog("鏁寸洏鐢佃姱灞炴�ц幏鍙�").Info(true, x); + LogFactory.GetLog("鏁寸洏鐢佃姱灞炴�ц幏鍙�").Info(true, result); + content.OK(data: result); } catch (Exception err) { diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs index 2391a6b..3de2826 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs @@ -3,8 +3,10 @@ using Newtonsoft.Json; using WIDESEA_Common; using WIDESEA_Core; +using WIDESEA_Core.Const; using WIDESEA_DTO; using WIDESEA_DTO.MOM; +using WIDESEA_IServices; using WIDESEA_IStoragIntegrationServices; namespace WIDESEA_StoragIntegrationServices; @@ -12,6 +14,12 @@ public class ProcessApplyService : IProcessApplyService { private readonly LogFactory LogFactory = new LogFactory(); + private readonly ISys_ConfigService _configService; + + public ProcessApplyService(ISys_ConfigService configRepository) + { + _configService = configRepository; + } /// <summary> /// 宸ヨ壓璺嚎鐢宠 @@ -26,15 +34,25 @@ input.SessionId = Guid.NewGuid().ToString(); input.EmployeeNo = "MITest"; input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ"); - var inputIson = input.ToDictionary(); - var x = await HttpsClient.PostAsync("http://c24-cellmi3:12020/api/MachineIntegration/ProcessApply", inputIson); - if (x != null) + var inputJson = input.ToDictionary(); + var configs = _configService.GetConfigsByCategory(CateGoryConst.SYS_MOMIPAddress); + var wmsBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.MOMBaseIP)?.ConfigValue; + var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.ProcessApply)?.ConfigValue; + if (wmsBase == null || ipAddress == null) + { + throw new InvalidOperationException("WMS IP 鏈厤缃�"); + } + var wmsIpAddress = wmsBase + ipAddress; + + var result = HttpsClient.PostAsync(wmsIpAddress, inputJson).Result; + //var x = await HttpsClient.PostAsync("http://c24-cellmi3:12020/api/MachineIntegration/ProcessApply", inputJson); + if (result != null) { //var ResultProcess = JsonConvert.DeserializeObject<ResultProcessApply>(x); - content.OK(data: x); + content.OK(data: result); } LogFactory.GetLog("宸ヨ壓璺嚎鐢宠").Info(true, $"\r\r--------------------------------------"); - LogFactory.GetLog("宸ヨ壓璺嚎鐢宠").Info(true, x); + LogFactory.GetLog("宸ヨ壓璺嚎鐢宠").Info(true, result); } catch (Exception ex) { diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/Unbind/UnbindService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/Unbind/UnbindService.cs index d3c750f..4225e41 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/Unbind/UnbindService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/Unbind/UnbindService.cs @@ -7,7 +7,9 @@ using System.Text; using System.Threading.Tasks; using WIDESEA_Common; +using WIDESEA_Core.Const; using WIDESEA_DTO; +using WIDESEA_IServices; using WIDESEA_IStoragIntegrationServices; namespace WIDESEA_StoragIntegrationServices; @@ -15,6 +17,12 @@ public class UnbindService : IUnbindService { private readonly LogFactory LogFactory = new LogFactory(); + private readonly ISys_ConfigService _configService; + + public UnbindService(ISys_ConfigService configRepository) + { + _configService = configRepository; + } /// <summary> /// 鎵樼洏鍗曠數鑺В缁� @@ -32,9 +40,19 @@ input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ"); var inputJson = input.ToDictionary(); LogFactory.GetLog("鎵樼洏鍗曠數鑺В缁�1").Info(true, JsonConvert.SerializeObject(inputJson)); - var x = await HttpsClient.PostAsync("http://c24-cellmi3:12020/api/MachineIntegration/TrayCellUnbind", inputJson); + var configs = _configService.GetConfigsByCategory(CateGoryConst.SYS_MOMIPAddress); + var wmsBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.MOMBaseIP)?.ConfigValue; + var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.TrayCellUnbind)?.ConfigValue; + if (wmsBase == null || ipAddress == null) + { + throw new InvalidOperationException("WMS IP 鏈厤缃�"); + } + var wmsIpAddress = wmsBase + ipAddress; + + var result = HttpsClient.PostAsync(wmsIpAddress, inputJson).Result; + //var x = await HttpsClient.PostAsync("http://c24-cellmi3:12020/api/MachineIntegration/TrayCellUnbind", inputJson); LogFactory.GetLog("鎵樼洏鍗曠數鑺В缁�").Info(true, $"\r\r--------------------------------------"); - LogFactory.GetLog("鎵樼洏鍗曠數鑺В缁�").Info(true, x); + LogFactory.GetLog("鎵樼洏鍗曠數鑺В缁�").Info(true, result); } catch (Exception ex) { @@ -61,9 +79,19 @@ input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ"); var inputJson = input.ToDictionary(); Console.WriteLine(inputJson); - var x = await HttpsClient.PostAsync("http://c24-cellmi3:12020/api/MachineIntegration/TrayUnbind", inputJson); + var configs = _configService.GetConfigsByCategory(CateGoryConst.SYS_MOMIPAddress); + var wmsBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.MOMBaseIP)?.ConfigValue; + var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.TrayUnbind)?.ConfigValue; + if (wmsBase == null || ipAddress == null) + { + throw new InvalidOperationException("WMS IP 鏈厤缃�"); + } + var wmsIpAddress = wmsBase + ipAddress; + + var result = HttpsClient.PostAsync(wmsIpAddress, inputJson).Result; + //var x = await HttpsClient.PostAsync("http://c24-cellmi3:12020/api/MachineIntegration/TrayUnbind", inputJson); LogFactory.GetLog("鏁寸洏鐢佃姱瑙g粦").Info(true, $"\r\r--------------------------------------"); - LogFactory.GetLog("鏁寸洏鐢佃姱瑙g粦").Info(true, x); + LogFactory.GetLog("鏁寸洏鐢佃姱瑙g粦").Info(true, result); } catch (Exception ex) { -- Gitblit v1.9.3