From b2e04d15e8284aa23af89200075b6fd52a77477e Mon Sep 17 00:00:00 2001 From: z8018 <1282578289@qq.com> Date: 星期四, 08 五月 2025 14:50:36 +0800 Subject: [PATCH] 1 --- project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs | 103 +++++++++++++++++++++++---------------------------- 1 files changed, 46 insertions(+), 57 deletions(-) diff --git a/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs b/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs index ebcf6ae..45cd188 100644 --- a/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs +++ b/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs @@ -9,6 +9,7 @@ using WIDESEAWCS_Core; using WIDESEAWCS_Core.BaseRepository; using WIDESEAWCS_Core.BaseServices; +using WIDESEAWCS_Core.Helper; using WIDESEAWCS_ITelescopicService; using WIDESEAWCS_Model.Models; using WIDESEAWCS_QuartzJob; @@ -31,35 +32,21 @@ /// 鑷姩鎺у埗浼哥缉鏉嗙殑浼稿嚭鍜岀缉鍥為�熷害 /// </summary> /// <param name="ExtendedState">浼�/鍑虹姸鎬�</param> - /// <param name="account">鐢ㄦ埛璐﹀彿</param> /// <returns></returns> - public WebResponseContent automation(string ExtendedState, string account) + public WebResponseContent automation(string ExtendedState) { try { - var loginer = _user.QueryData(x => x.UserName == account).FirstOrDefault(); - if (loginer == null) - return new WebResponseContent { Status = false, Message = "鐧诲綍鐢ㄦ埛涓嶅瓨鍦�" }; - // 璁惧缂栧彿瑙勫垯鏄寜閮ㄩ棬缂栧彿渚濇涓� SSG001~SSG010 - string liftDeviceCode = $"SSG{(loginer.Dept_Id * 2 - 1):D3}"; - string rightDeviceCode = $"SSG{(loginer.Dept_Id * 2):D3}"; - - OtherDevice liftDevice = (OtherDevice)Storage.Devices.Find(x => x.DeviceCode == liftDeviceCode); - OtherDevice rightDevice = (OtherDevice)Storage.Devices.Find(x => x.DeviceCode == rightDeviceCode); - - if (liftDevice == null || rightDevice == null) + //鏍规嵁int.TryParse(AppSettings.Get("DepartmentID")璇诲彇鍒板綋鍓嶆槸杞ㄩ亾鍑狅紝鎵�鏈変汉閮藉彧鑳芥搷浣滃綋鍓� + if (!int.TryParse(AppSettings.Get("DepartmentID"), out int deid)) { - return new WebResponseContent { Status = false, Message = $"璁惧 {liftDeviceCode} 鎴� {rightDeviceCode} 鏈壘鍒�" }; - } - - if (liftDevice.Communicator == null || rightDevice.Communicator == null) - { - return new WebResponseContent { Status = false, Message = "璁惧閫氳鏈垵濮嬪寲" }; - } + return new WebResponseContent { Status = false, Message = "閰嶇疆椤� DepartmentID 鏃犳硶杞崲涓烘暣鏁�" }; + }; + var devices = GetDevicesByDeptId(deid); //鎵惧埌Dt_Parameters涓殑鏈�鏂颁竴鏉℃暟鎹� - var para = BaseDal.QueryData().OrderByDescending(x => x.CreateDate).FirstOrDefault(); + var para = BaseDal.QueryData().Where(x=>x.Deptid== deid).OrderByDescending(x => x.CreateDate).FirstOrDefault(); if (para == null) return new WebResponseContent { Status = false, Message = "鏈壘鍒板弬鏁伴厤缃�" }; @@ -68,19 +55,19 @@ if (ExtendedState == "浼稿嚭") { - liftDevice.Communicator.Write<int>("D500", ext); - liftDevice.Communicator.Write<bool>("M100", true); - rightDevice.Communicator.Write<int>("D500", ext); - rightDevice.Communicator.Write<bool>("M100", true); - Console.WriteLine($"浼哥缉鏉嗕几鍑� {ext}"); + devices.Value.left.Communicator.Write<int>("D500", ext);//浼稿嚭閫熷害 + devices.Value.left.Communicator.Write<bool>("M100", true);//浼稿嚭鎸夐挳 + devices.Value.right.Communicator.Write<int>("D500", ext);//浼稿嚭閫熷害 + devices.Value.right.Communicator.Write<bool>("M100", true);//浼稿嚭鎸夐挳 + Console.WriteLine($"鑷姩浼哥缉鏉嗕几鍑� {ext}"); } else if (ExtendedState == "缂╁洖") { - liftDevice.Communicator.Write<int>("D501", ret); - liftDevice.Communicator.Write<bool>("M101", true); - rightDevice.Communicator.Write<int>("D501", ret); - rightDevice.Communicator.Write<bool>("M101", true); - Console.WriteLine($"浼哥缉鏉嗙缉鍥� {ret}"); + devices.Value.left.Communicator.Write<int>("D501", ext);//浼稿嚭閫熷害 + devices.Value.left.Communicator.Write<bool>("M101", true);//浼稿嚭鎸夐挳 + devices.Value.right.Communicator.Write<int>("D501", ext);//浼稿嚭閫熷害 + devices.Value.right.Communicator.Write<bool>("M101", true);//浼稿嚭鎸夐挳 + Console.WriteLine($"鑷姩浼哥缉鏉嗙缉鍥� {ret}"); } else { @@ -99,53 +86,55 @@ - public WebResponseContent ManualOperation(string position, string ExtendedState,string account) - { + /// <summary> + /// 鎵嬪姩鎺у埗锛屼几缂╂潌鐨勭缉鍥炲拰浼稿嚭閫熷害 + /// </summary> + /// <param name="position">浼哥缉鏉嗙殑浣嶇疆锛堝乏鍙筹級</param> + /// <param name="ExtendedState">浼�/缂╃姸鎬�</param> + /// <returns></returns> + /// + public WebResponseContent ManualOperation(string position, string ExtendedState) + { try { - var loginer = _user.QueryData(x => x.UserName == account).FirstOrDefault(); - if (loginer == null) - return new WebResponseContent { Status = false, Message = "鐢ㄦ埛涓嶅瓨鍦�" }; + if (!int.TryParse(AppSettings.Get("DepartmentID"), out int deid)) + { + return new WebResponseContent { Status = false, Message = "閰嶇疆椤� DepartmentID 鏃犳硶杞崲涓烘暣鏁�" }; + } + var devices = GetDevicesByDeptId(deid); - var devices = GetDevicesByDeptId((int)loginer.Dept_Id); - if (devices == null) - return new WebResponseContent { Status = false, Message = "璁惧鏈壘鍒�" }; - - var para = BaseDal.QueryData().OrderByDescending(x => x.CreateDate).FirstOrDefault(); - if (para == null) - return new WebResponseContent { Status = false, Message = "鍙傛暟鏈厤缃�" }; - - int ext = (int)para.ExtendSpeed; - int ret = (int)para.RetractionSpeed; - + //淇╀釜plc宸﹀彸鍚勪竴涓� + //OtherDevice liftotherDevice = (OtherDevice)Storage.Devices.Find(x => x.DeviceCode == "SSG001"); + //OtherDevice rightotherDevice = (OtherDevice)Storage.Devices.Find(x => x.DeviceCode == "SSG002"); + //鎵惧埌Dt_Parameters涓殑鏈�鏂颁竴鏉℃暟鎹牴鎹綋鍓嶇殑deid + var para = BaseDal.QueryData().Where(x => x.Deptid == deid).OrderByDescending(x => x.CreateDate).FirstOrDefault(); + int ext = (int)para.ManualExtend;//鎵嬪姩浼稿嚭閫熷害 + int ret = (int)para.ManualRetraction;//鎵嬪姩缂╁洖閫熷害 if (position == "宸�" && ExtendedState == "浼稿嚭") { - devices.Value.left.Communicator.Write<int>("D500", ext); - devices.Value.left.Communicator.Write<bool>("M100", true); + devices.Value.left.Communicator.Write<int>("D500", ext);//浼稿嚭閫熷害 + devices.Value.left.Communicator.Write<bool>("M100", true);//浼稿嚭鎸夐挳 + Console.WriteLine($"{position}浼哥缉鏉嗘墜鍔ㄤ几鍑簕ext}"); } else if (position == "宸�" && ExtendedState == "缂╁洖") { - devices.Value.left.Communicator.Write<int>("D501", ret); + devices.Value.left.Communicator.Write<int>("D501", ret);//缂╁洖閫熷害 devices.Value.left.Communicator.Write<bool>("M101", true); + Console.WriteLine($"{position}浼哥缉鏉嗘墜鍔ㄧ缉鍥瀧ret}"); } else if (position == "鍙�" && ExtendedState == "浼稿嚭") { devices.Value.right.Communicator.Write<int>("D500", ext); devices.Value.right.Communicator.Write<bool>("M100", true); + Console.WriteLine($"{position}浼哥缉鏉嗘墜鍔ㄤ几鍑簕ext}"); } else if (position == "鍙�" && ExtendedState == "缂╁洖") { devices.Value.right.Communicator.Write<int>("D501", ret); devices.Value.right.Communicator.Write<bool>("M101", true); + Console.WriteLine($"{position}浼哥缉鏉嗘墜鍔ㄧ缉鍥瀧ret}"); } - - else - { - return new WebResponseContent { Status = false, Message = "鐘舵�佸弬鏁伴敊璇�" }; - } - return new WebResponseContent { Status = true, Message = "鎴愬姛" }; - } catch (Exception ex) { -- Gitblit v1.9.3