From 3c41fec3221a32192214cbe7be3776f66290d6cc Mon Sep 17 00:00:00 2001
From: wankeda <Administrator@DESKTOP-HAU3ST3>
Date: 星期五, 11 四月 2025 14:32:26 +0800
Subject: [PATCH] 1

---
 代码管理/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Elevator/CommonElevator.cs |  276 +++++++++++++++++++++++
 代码管理/NEWCode/WIDESEAWCS_PDA/pages/叫料/负极叫料.vue                                  |    6 
 代码管理/NEWCode/WIDESEAWCS_PDA/pages/叫料/正极叫料.vue                                  |   31 +-
 代码管理/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Roast/CommonRoast.cs       |   25 +
 代码管理/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Roast/IRoast.cs            |    7 
 代码管理/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ElevatorJob/ElevatorJob.cs     |  274 ++++++++++++++++++++++
 代码管理/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json              |    2 
 代码管理/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Elevator/IElevator.cs      |   71 +++++
 8 files changed, 660 insertions(+), 32 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_PDA/pages/\345\217\253\346\226\231/\346\255\243\346\236\201\345\217\253\346\226\231.vue" "b/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_PDA/pages/\345\217\253\346\226\231/\346\255\243\346\236\201\345\217\253\346\226\231.vue"
index 63d62be..d0a7e9f 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_PDA/pages/\345\217\253\346\226\231/\346\255\243\346\236\201\345\217\253\346\226\231.vue"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_PDA/pages/\345\217\253\346\226\231/\346\255\243\346\236\201\345\217\253\346\226\231.vue"
@@ -101,7 +101,7 @@
 							size: this.size
 						};
 						// 浣跨敤鍒涙櫤瀹屾暣鎺ュ彛
-					this.$u.post(res.data.CZFJiP + '/makerwit/selectKHWareType', null).then(res => {
+						this.$u.post(res.data.CZFJiP + '/makerwit/selectKHWareType', null).then(res => {
 							console.log(res);
 							this.$t.message.closeLoading();
 							cb && cb();
@@ -120,7 +120,7 @@
 					},
 				});
 			},
-			
+
 			clickLoadMore(e) {
 				this.status = 'loading';
 				this.current += 1;
@@ -152,19 +152,20 @@
 					this.$t.message.toast('鍙彨鏁伴噺涓�0锛屾棤娉曞彨浠诲姟');
 					return;
 				}
+				let guid = this.generateUUID()
 				let formDataParam = {
-				dTaskId: this.generateUUID(),
-				productCode: productCode,
-				orderNo: orderNo,
-				taskNo:2,
-				number: availableQuantity > 4 ? 4 : availableQuantity,
-				inputValue: inputValue,
-				DTaskId: this.generateUUID(),
-				ProductCode: productCode,
-				OrderNo: orderNo,
-				Number: availableQuantity > 4 ? 4 : availableQuantity,
-				InputValue: inputValue,
-				TaskType: "姝f瀬"
+					dTaskId: guid,
+					productCode: productCode,
+					orderNo: orderNo,
+					taskNo: 2,
+					number: availableQuantity > 4 ? 4 : availableQuantity,
+					inputValue: inputValue,
+					DTaskId: guid,
+					ProductCode: productCode,
+					OrderNo: orderNo,
+					Number: availableQuantity > 4 ? 4 : availableQuantity,
+					InputValue: inputValue,
+					TaskType: "姝f瀬"
 					// ...鍏朵粬闇�瑕佷紶閫掔殑鍙傛暟
 				};
 				this.$u.post('/api/PDA/AddCZTask', formDataParam).then(res => {
@@ -173,7 +174,7 @@
 						// 浣跨敤鍒涙櫤瀹屾暣鎺ュ彛
 						this.$u.post(value.CZZJip + '/makerwit/insertTask', formDataParam).then(res => {
 							this.$t.message.closeLoading();
-									if (res.code == 200) {
+							if (res.code == 200) {
 								this.$t.message.toast('鍛煎彨鎴愬姛');
 								this.$refs.popup.close();
 								// this.submit();
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_PDA/pages/\345\217\253\346\226\231/\350\264\237\346\236\201\345\217\253\346\226\231.vue" "b/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_PDA/pages/\345\217\253\346\226\231/\350\264\237\346\236\201\345\217\253\346\226\231.vue"
index 9693c0d..9f8413e 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_PDA/pages/\345\217\253\346\226\231/\350\264\237\346\236\201\345\217\253\346\226\231.vue"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_PDA/pages/\345\217\253\346\226\231/\350\264\237\346\236\201\345\217\253\346\226\231.vue"
@@ -112,7 +112,7 @@
 							size: this.size
 						};
 						// 浣跨敤鍒涙櫤瀹屾暣鎺ュ彛
-							// this.$u.post('http://192.168.31.240:9090/makerwit/selectKHWareType', null).then(res => {
+						// this.$u.post('http://192.168.31.240:9090/makerwit/selectKHWareType', null).then(res => {
 						this.$u.post(res.data.CZFJiP + '/makerwit/selectKHWareType', null).then(res => {
 							console.log(res);
 							this.$t.message.closeLoading();
@@ -172,13 +172,13 @@
 				}
 				
 				let formDataParam = {
-					dTaskId: this.generateUUID(),
+					dTaskId: guid,
 					productCode: productCode,
 					orderNo: orderNo,
 					taskNo:2,
 					number: numberValue,
 					inputValue: inputValue,
-					DTaskId: this.generateUUID(),
+					DTaskId: guid,
 					ProductCode: productCode,
 					OrderNo: orderNo,
 					Number: numberValue,
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Elevator/CommonElevator.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Elevator/CommonElevator.cs"
new file mode 100644
index 0000000..018d2cd
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Elevator/CommonElevator.cs"
@@ -0,0 +1,276 @@
+锘縰sing HslCommunication;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEAWCS_Communicator;
+using WIDESEAWCS_QuartzJob.ConveyorLine.Enum;
+using WIDESEAWCS_QuartzJob.DeviceBase;
+using WIDESEAWCS_QuartzJob.DTO;
+
+namespace WIDESEAWCS_QuartzJob.Elevator
+{
+    public class CommonElevator: IElevator
+    {
+        #region Private Member
+
+        /// <summary>
+        /// 鐑樼儰閫氳瀵硅薄
+        /// </summary>
+        private readonly BaseCommunicator _communicator;
+
+        /// <summary>
+        /// 鐑樼儰鍗忚淇℃伅
+        /// </summary>
+        private readonly List<DeviceProDTO> _deviceProDTOs;
+
+        /// <summary>
+        /// 鐑樼儰鍗忚鏄庣粏淇℃伅
+        /// </summary>
+        private readonly List<DeviceProtocolDetailDTO> _deviceProtocolDetailDTOs;
+
+        /// <summary>
+        /// 璁惧缂栧彿
+        /// </summary>
+        public readonly string _deviceCode;
+
+        /// <summary>
+        /// 璁惧鍚嶇О
+        /// </summary>
+        public readonly string _deviceName;
+
+        private bool _heartStatr = true;
+
+        private bool _isConnected = true;
+
+        #endregion
+
+        #region Public Member
+
+        /// <summary>
+        /// 鐑樼儰閫氳瀵硅薄
+        /// </summary>
+        public BaseCommunicator Communicator => _communicator;
+
+        /// <summary>
+        /// 鐑樼儰鍗忚淇℃伅
+        /// </summary>
+        public List<DeviceProDTO> DeviceProDTOs => _deviceProDTOs;
+
+        /// <summary>
+        /// 鐑樼儰鍗忚鏄庣粏淇℃伅
+        /// </summary>
+        public List<DeviceProtocolDetailDTO> DeviceProtocolDetailDTOs => _deviceProtocolDetailDTOs;
+
+        /// <summary>
+        /// 璁惧缂栧彿
+        /// </summary>
+        public string DeviceCode => _deviceCode;
+
+        /// <summary>
+        /// 璁惧鍚嶇О
+        /// </summary>
+        public string DeviceName => _deviceName;
+
+        /// <summary>
+        /// 閫氳鏄惁宸茶繛鎺�
+        /// </summary>
+        public bool IsConnected => Communicator.IsConnected && _isConnected;
+
+        #endregion
+
+        #region Constructor Function
+
+        /// <summary>
+        /// 鏋勯�犲嚱鏁�
+        /// </summary>
+        /// <param name="communicator">鐑樼儰閫氳瀵硅薄</param>
+        /// <param name="deviceProDTOs">鐑樼儰鍗忚淇℃伅</param>
+        /// <param name="deviceProtocolDetailDTOs">鐑樼儰鍗忚鏄庣粏淇℃伅</param>
+        /// <param name="deviceCode">璁惧缂栧彿</param>
+        /// <param name="deviceName">璁惧鍚嶇О</param>
+        public CommonElevator(BaseCommunicator communicator, List<DeviceProDTO> deviceProDTOs, List<DeviceProtocolDetailDTO> deviceProtocolDetailDTOs, string deviceCode, string deviceName)
+        {
+            _communicator = communicator;
+            _deviceProDTOs = deviceProDTOs;
+            _deviceProtocolDetailDTOs = deviceProtocolDetailDTOs;
+            _deviceCode = deviceCode;
+            _deviceName = deviceName;
+            CheckConnect();
+        }
+
+        #endregion
+
+        #region Private Method
+
+        private void CheckConnect()
+        {
+            Task.Run(() =>
+            {
+                while (_heartStatr)
+                {
+                    try
+                    {
+                        DeviceProDTO? devicePro = _deviceProDTOs.FirstOrDefault();
+                        if (devicePro == null)
+                            _isConnected = false;
+                        else
+                            Communicator.ReadAsObj(devicePro.DeviceProAddress, devicePro.DeviceDataType);
+                        _isConnected = true;
+                    }
+                    catch (Exception ex)
+                    {
+                        _isConnected = false;
+                    }
+                    Thread.Sleep(500);
+                }
+            });
+        }
+
+        #endregion
+
+        #region Public Method
+
+        /// <summary>
+        /// 璇诲彇PLC鍗忚鍦板潃鐨勬暟鎹�
+        /// </summary>
+        /// <typeparam name="TEnum">鍗忚淇℃伅鐨勬灇涓惧璞′俊鎭��</typeparam>
+        /// <typeparam name="TResult">璇诲彇鏁版嵁鐨勭被鍨嬪璞′俊鎭��</typeparam>
+        /// <param name="value">鏋氫妇鍊�</param>
+        /// <param name="deviceChildCode">璁惧瀛愮紪鍙�</param>
+        /// <returns>璇诲彇鍒扮殑鏁版嵁</returns>
+        public TResult GetValue<TEnum, TResult>(TEnum value, string deviceChildCode) where TEnum : Enum
+        {
+            if (!IsConnected) throw new Exception($"閫氳杩炴帴閿欒锛岃妫�鏌ョ綉缁�");
+            DeviceProDTO? devicePro = _deviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == value.ToString() && x.DeviceChildCode == deviceChildCode);
+            return devicePro == null ? throw new Exception($"璇诲彇鏁版嵁閿欒,鏈湪鍗忚淇℃伅閲岄潰鎵惧埌鍙傛暟{value.ToString()}") : (TResult)Communicator.ReadAsObj(devicePro.DeviceProAddress, devicePro.DeviceDataType);
+        }
+
+        /// <summary>
+        /// 涓庤澶囩殑蹇冭烦
+        /// </summary>
+        public void Heartbeat()
+        {
+            throw new NotImplementedException();
+        }
+
+        /// <summary>
+        ///
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="command"></param>
+        /// <param name="deviceChildCode"></param>
+        /// <returns></returns>
+        /// <exception cref="Exception"></exception>
+        public bool SendCommand<T>(T command, string deviceChildCode) where T : IDataTransfer, new()
+        {
+            if (Communicator is SiemensS7)
+            {
+                if (!IsConnected) throw new Exception($"閫氳杩炴帴閿欒锛岃妫�鏌ョ綉缁�");
+                DeviceProDTO? devicePro = _deviceProDTOs.Where(x => x.DeviceProParamType == nameof(DeviceCommand) && x.DeviceChildCode == deviceChildCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
+                if (devicePro == null)
+                {
+                    return false;
+                }
+                if (Communicator.WriteCustomer(devicePro.DeviceProAddress, command))
+                {
+                    return true;
+                }
+                return false;
+            }
+            else
+            {
+                throw new Exception("鏆備笉鏀寔闄よタ闂ㄥ瓙涔嬪鐨凱LC");
+            }
+        }
+
+        /// <summary>
+        /// 璇诲彇PLC鏁版嵁锛岃繑鍥炶嚜瀹氫箟瀵硅薄
+        /// </summary>
+        /// <typeparam name="T">娉涘瀷</typeparam>
+        /// <param name="deviceChildCode">瀛愯澶囩紪鍙�</param>
+        /// <returns>杩斿洖鑷畾涔夊璞℃垨鎶涘嚭寮傚父</returns>
+        /// <exception cref="Exception"></exception>
+        public T ReadCustomer<T>(string deviceChildCode) where T : IDataTransfer, new()
+        {
+            if (!IsConnected) throw new Exception($"閫氳杩炴帴閿欒锛岃妫�鏌ョ綉缁�");
+            DeviceProDTO? devicePro = _deviceProDTOs.Where(x => x.DeviceProParamType == "ReadDeviceCommand" && x.DeviceChildCode == deviceChildCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
+
+            if (devicePro == null)
+            {
+                throw new Exception("鏈壘鍒板崗璁俊鎭�");
+            }
+            else
+            {
+                return Communicator.ReadCustomer<T>(devicePro.DeviceProAddress);
+            }
+        }
+
+        /// <summary>
+        /// 鏍规嵁鍙傛暟鍚嶇О銆佽澶囧瓙缂栧彿鍐欏叆瀵瑰簲鐨勬暟鎹��
+        /// </summary>
+        /// <typeparam name="TEnum">鍙傛暟鍚嶇О鏋氫妇绫诲瀷銆�</typeparam>
+        /// <typeparam name="TValue">瑕佸啓鍏ョ殑鏁版嵁绫诲瀷銆�</typeparam>
+        /// <param name="enum">鍙傛暟鍚嶇О銆�</param>
+        /// <param name="value">瑕佸啓鍏ョ殑鏁版嵁銆�</param>
+        /// <param name="deviceChildCode">璁惧瀛愮紪鍙峰啓</param>
+        /// <returns>杩斿洖鍐欏叆鎴愬姛鎴栧け璐�</returns>
+        public bool SetValue<TEnum, TValue>(TEnum @enum, TValue value, string deviceChildCode)
+            where TEnum : Enum
+            where TValue : notnull
+        {
+            if (!IsConnected) throw new Exception($"閫氳杩炴帴閿欒锛岃妫�鏌ョ綉缁�");
+            DeviceProDTO? devicePro = _deviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == @enum.ToString() && x.DeviceChildCode == deviceChildCode);
+            return devicePro == null ? throw new Exception($"鍐欏叆鏁版嵁閿欒,鏈湪鍗忚淇℃伅閲岄潰鎵惧埌鍙傛暟{value.ToString()}") : Communicator.WriteObj(devicePro.DeviceProAddress, devicePro.DeviceDataType, value);
+        }
+
+        /// <summary>
+        /// 鏄惁鍗犱綅
+        /// </summary>
+        /// <param name="deviceChildCode">璁惧瀛愮紪鍙�</param>
+        /// <returns></returns>
+        /// <exception cref="Exception"></exception>
+        public bool IsOccupied(string deviceChildCode)
+        {
+            if (Communicator.IsConnected)
+            {
+                List<DeviceProDTO> devicePros = _deviceProDTOs.Where(x => x.DeviceProParamType == ConveyorLineStatus.IsOccupied.ToString()).ToList();
+                if (devicePros.Count == 0)
+                {
+                    //todo 鍗忚淇℃伅鏈幏鍙栧埌鏃舵姏鍑哄紓甯�
+                    throw new Exception();
+                }
+                for (int i = 0; i < devicePros.Count; i++)
+                {
+                    object readStatus = Communicator.ReadAsObj(devicePros[i].DeviceProAddress, devicePros[i].DeviceDataType);
+                    //todo 鍗忚鏄庣粏淇℃伅鏈幏鍙栧埌鏃舵姏鍑哄紓甯�
+                    DeviceProtocolDetailDTO? deviceProtocolDetail = _deviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == devicePros[i].DeviceProParamName) ?? throw new Exception();
+                    deviceProtocolDetail = _deviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == devicePros[i].DeviceProParamType && x.ProtocalDetailValue.Equals(readStatus.ToString()));
+                    if (deviceProtocolDetail != null)
+                    {
+                        return true;
+                    }
+                    return false;
+                }
+            }
+            //todo 閫氳鏈繛鎺ユ椂鎶涘嚭寮傚父
+            return false;
+        }
+
+        /// <summary>
+        /// 閲婃斁瀵硅薄
+        /// </summary>
+        public void Dispose()
+        {
+            // 璁剧疆蹇冭烦鐘舵�佷负false
+            _heartStatr = false;
+            // 閲婃斁閫氫俊鍣ㄨ祫婧�
+            _communicator.Dispose();
+            // 鍛婅瘔鍨冨溇鍥炴敹鍣ㄤ笉鍐嶈皟鐢ㄧ粓缁撳櫒
+            GC.SuppressFinalize(this);
+        }
+
+        #endregion
+    }
+}
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Elevator/IElevator.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Elevator/IElevator.cs"
new file mode 100644
index 0000000..af59980
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Elevator/IElevator.cs"
@@ -0,0 +1,71 @@
+锘縰sing HslCommunication;
+using WIDESEAWCS_Communicator;
+using WIDESEAWCS_QuartzJob.DTO;
+
+namespace WIDESEAWCS_QuartzJob
+{
+    public interface IElevator : IDevice
+    {
+        /// <summary>
+        /// 閫氳瀵硅薄
+        /// </summary>
+        BaseCommunicator Communicator { get; }
+
+        /// <summary>
+        /// 閫氳鍗忚淇℃伅
+        /// </summary>
+        List<DeviceProDTO> DeviceProDTOs { get; }
+
+        /// <summary>
+        /// 閫氳鍗忚鏄庣粏淇℃伅
+        /// </summary>
+        List<DeviceProtocolDetailDTO> DeviceProtocolDetailDTOs { get; }
+
+        /// <summary>
+        /// 璁惧鏄惁宸茶繛鎺�
+        /// </summary>
+        bool IsConnected { get; }
+
+        /// <summary>
+        /// 涓庤澶囩殑蹇冭烦
+        /// </summary>
+        void Heartbeat();
+
+        /// <summary>
+        /// 璇诲彇PLC鍗忚鍦板潃鐨勬暟鎹�
+        /// </summary>
+        /// <typeparam name="TEnum">鍗忚淇℃伅鐨勬灇涓惧璞′俊鎭��</typeparam>
+        /// <typeparam name="TResult">璇诲彇鏁版嵁鐨勭被鍨嬪璞′俊鎭��</typeparam>
+        /// <param name="value">鏋氫妇鍊�</param>
+        /// <param name="deviceChildCode">璁惧瀛愮紪鍙�</param>
+        /// <returns>璇诲彇鍒扮殑鏁版嵁</returns>
+        TResult GetValue<TEnum, TResult>(TEnum value, string deviceChildCode) where TEnum : Enum;
+
+        /// <summary>
+        /// 鏍规嵁鍙傛暟鍚嶇О銆佽澶囧瓙缂栧彿鍐欏叆瀵瑰簲鐨勬暟鎹��
+        /// </summary>
+        /// <typeparam name="TEnum">鍙傛暟鍚嶇О鏋氫妇绫诲瀷銆�</typeparam>
+        /// <typeparam name="TValue">瑕佸啓鍏ョ殑鏁版嵁绫诲瀷銆�</typeparam>
+        /// <param name="enum">鍙傛暟鍚嶇О銆�</param>
+        /// <param name="value">瑕佸啓鍏ョ殑鏁版嵁銆�</param>
+        /// <param name="deviceChildCode">璁惧瀛愮紪鍙峰啓</param>
+        /// <returns>杩斿洖鍐欏叆鎴愬姛鎴栧け璐�</returns>
+        bool SetValue<TEnum, TValue>(TEnum @enum, TValue value, string deviceChildCode) where TEnum : Enum where TValue : notnull;
+
+        /// <summary>
+        /// 璇诲彇绔欏彴鏄惁琚崰鐢�
+        /// </summary>
+        /// <param name="deviceChildCode">璁惧瀛愮紪鍙�</param>
+        /// <returns></returns>
+        bool IsOccupied(string deviceChildCode);
+
+        /// <summary>
+        /// 鍙戦�佷换鍔″懡浠�
+        /// </summary>
+        /// <typeparam name="T">浠诲姟鍛戒护瀵硅薄鐨勭被鍨嬫硾鍨�</typeparam>
+        /// <param name="command">浠诲姟鍛戒护</param>
+        /// <param name="deviceChildCode">璁惧瀛愮紪鍙�</param>
+        /// <returns></returns>
+        bool SendCommand<T>(T command, string deviceChildCode) where T : IDataTransfer, new();
+    }
+}
\ No newline at end of file
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Roast/CommonRoast.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Roast/CommonRoast.cs"
index 935e5df..da22bf6 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Roast/CommonRoast.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Roast/CommonRoast.cs"
@@ -1,4 +1,5 @@
 锘�#region << 鐗� 鏈� 娉� 閲� >>
+
 /*----------------------------------------------------------------
  * 鍛藉悕绌洪棿锛歐IDESEAWCS_QuartzJob
  * 鍒涘缓鑰咃細鑳$搴�
@@ -11,22 +12,17 @@
  * 淇敼鏃堕棿锛�
  * 鐗堟湰锛歏1.0.1
  * 淇敼璇存槑锛�
- * 
+ *
  *----------------------------------------------------------------*/
+
 #endregion << 鐗� 鏈� 娉� 閲� >>
 
 using HslCommunication;
-using System;
-using System.Collections.Generic;
 using System.ComponentModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using WIDESEAWCS_Communicator;
 using WIDESEAWCS_QuartzJob.ConveyorLine.Enum;
 using WIDESEAWCS_QuartzJob.DeviceBase;
 using WIDESEAWCS_QuartzJob.DTO;
-using WIDESEAWCS_QuartzJob.StackerCrane.Enum;
 
 namespace WIDESEAWCS_QuartzJob
 {
@@ -37,6 +33,7 @@
     public class CommonRoast : IRoast
     {
         #region Private Member
+
         /// <summary>
         /// 鐑樼儰閫氳瀵硅薄
         /// </summary>
@@ -65,9 +62,11 @@
         private bool _heartStatr = true;
 
         private bool _isConnected = true;
+
         #endregion
 
         #region Public Member
+
         /// <summary>
         /// 鐑樼儰閫氳瀵硅薄
         /// </summary>
@@ -101,6 +100,7 @@
         #endregion
 
         #region Constructor Function
+
         /// <summary>
         /// 鏋勯�犲嚱鏁�
         /// </summary>
@@ -118,9 +118,11 @@
             _deviceName = deviceName;
             CheckConnect();
         }
+
         #endregion
 
         #region Private Method
+
         private void CheckConnect()
         {
             Task.Run(() =>
@@ -144,9 +146,11 @@
                 }
             });
         }
+
         #endregion
 
         #region Public Method
+
         /// <summary>
         /// 璇诲彇PLC鍗忚鍦板潃鐨勬暟鎹�
         /// </summary>
@@ -171,7 +175,7 @@
         }
 
         /// <summary>
-        /// 
+        ///
         /// </summary>
         /// <typeparam name="T"></typeparam>
         /// <param name="command"></param>
@@ -180,7 +184,7 @@
         /// <exception cref="Exception"></exception>
         public bool SendCommand<T>(T command, string deviceChildCode) where T : IDataTransfer, new()
         {
-            if(Communicator is SiemensS7)
+            if (Communicator is MelsecA1ENetCommunicator)
             {
                 if (!IsConnected) throw new Exception($"閫氳杩炴帴閿欒锛岃妫�鏌ョ綉缁�");
                 DeviceProDTO? devicePro = _deviceProDTOs.Where(x => x.DeviceProParamType == nameof(DeviceCommand) && x.DeviceChildCode == deviceChildCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
@@ -285,6 +289,7 @@
             // 鍛婅瘔鍨冨溇鍥炴敹鍣ㄤ笉鍐嶈皟鐢ㄧ粓缁撳櫒
             GC.SuppressFinalize(this);
         }
+
         #endregion
     }
-}
+}
\ No newline at end of file
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Roast/IRoast.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Roast/IRoast.cs"
index d747b41..896a76a 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Roast/IRoast.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Roast/IRoast.cs"
@@ -1,4 +1,5 @@
 锘�#region << 鐗� 鏈� 娉� 閲� >>
+
 /*----------------------------------------------------------------
  * 鍛藉悕绌洪棿锛歐IDESEAWCS_QuartzJob
  * 鍒涘缓鑰咃細鑳$搴�
@@ -11,8 +12,9 @@
  * 淇敼鏃堕棿锛�
  * 鐗堟湰锛歏1.0.1
  * 淇敼璇存槑锛�
- * 
+ *
  *----------------------------------------------------------------*/
+
 #endregion << 鐗� 鏈� 娉� 閲� >>
 
 using HslCommunication;
@@ -32,7 +34,6 @@
     /// </summary>
     public interface IRoast : IDevice
     {
-
         /// <summary>
         /// 閫氳瀵硅薄
         /// </summary>
@@ -95,4 +96,4 @@
         /// <returns></returns>
         bool SendCommand<T>(T command, string deviceChildCode) where T : IDataTransfer, new();
     }
-}
+}
\ No newline at end of file
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json" "b/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json"
index 6ea10f4..f7ed751 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json"
@@ -18,7 +18,7 @@
     "DBType": "SqlServer",
     //杩炴帴瀛楃涓�
     //"ConnectionString": "HTI6FB1H05Krd07mNm9yBCNhofW6edA5zLs9TY~MNthRYW3kn0qKbMIsGp~3yyPDF1YZUCPBQx8U0Jfk4PH~ajNFXVIwlH85M3F~v_qKYQ3CeAz3q1mLVDn8O5uWt1~3Ut2V3KRkEwYHvW2oMDN~QIDXPxDgXN0R2oTIhc9dNu7QNaLEknblqmHhjaNSSpERdDVZIgHnMKejU_SL49tralBkZmDNi0hmkbL~837j1NWe37u9fJKmv91QPb~16JsuI9uu0EvNZ06g6PuZfOSAeFH9GMMIZiketdcJG3tHelo=",
-    "ConnectionString": "Data Source=.;Initial Catalog=WIDESEAWCS_GanFengLiYeNew;User ID=sa;Password=sa123456;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
+    "ConnectionString": "Data Source=.;Initial Catalog=WIDESEAWCS_GanFengLiYeNew;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
 
     //璺ㄥ煙
     "Cors": {
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ElevatorJob/ElevatorJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ElevatorJob/ElevatorJob.cs"
new file mode 100644
index 0000000..b657268
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ElevatorJob/ElevatorJob.cs"
@@ -0,0 +1,274 @@
+锘縰sing Quartz;
+using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_QuartzJob;
+using WIDESEAWCS_QuartzJob.Elevator;
+
+namespace WIDESEAWCS_Tasks
+{
+    public class ElevatorJob : JobBase, IJob, IDisposable
+    {
+        public void Dispose()
+        {
+            GC.SuppressFinalize(this);
+        }
+
+        public Task Execute(IJobExecutionContext context)
+        {
+            // 浠庝笂涓嬫枃涓幏鍙� JobParams 骞惰浆鎹负 Roast 绫诲瀷
+            CommonElevator elevator = (CommonElevator)context.JobDetail.JobDataMap.Get("JobParams");
+            // 鍒濆鍖� AGV 鍙橀噺
+            AGV agv = null;
+
+            if (elevator == null)
+            {
+                throw new Exception("鏈壘鍒版彁鍗囨満璁惧鍙傛暟銆�");
+            }
+
+            // 杩炴帴 AGV
+            // 鏍规嵁璁惧鍚嶇О鍐冲畾鏄鏋佽繕鏄礋鏋� AGV
+            List<string> agvNames = new List<string>() { "姝f瀬AGV", "璐熸瀬AGV" };
+            foreach (var agvName in agvNames)
+            {
+                // 浠庡瓨鍌ㄤ腑鏌ユ壘鎸囧畾鍚嶇О鐨勮澶�
+                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceName == agvName);
+                if (device != null)
+                {
+                    agv = (AGV)device;
+                }
+                else
+                {
+                    ConsoleHelper.WriteErrorLine($"鏈壘鍒皗agvName}璁惧鍙傛暟銆�");
+                    continue;
+                }
+                var elevatorNamesValues = GetDBElevatorNamesValues(agvName);
+                var agvNamesValues = GetDBAGVNamesValues(agvName);
+                DeviceInteraction(elevator, agv, elevatorNamesValues, agvNamesValues);
+            }
+            return Task.CompletedTask;
+        }
+
+
+        public static void DeviceInteraction(CommonElevator elevator, AGV agv, List<string> elevatorNames, List<string> agvNames)
+        {
+            if (agv.DeviceName == "姝f瀬AGV")
+            {
+                HandlePositiveAGV(elevator, agv, elevatorNames, agvNames);
+            }
+            else
+            {
+                HandleNegativeAGV(elevator, agv, elevatorNames, agvNames);
+            }
+        }
+
+        private static void HandlePositiveAGV(CommonElevator elevator, AGV agv, List<string> elevatorNames, List<string> agvNames)
+        {
+            // 姝f瀬AGV鍙渶瑕佸鐞嗗墠涓や釜淇″彿
+            var elevatorSignal = elevator.Communicator.Read<byte>(elevatorNames[0], 100);
+            var agvSignal = agv.Communicator.Read<byte>(agvNames[1], 100);
+
+            agv.Communicator.Write(agvNames[0], elevatorSignal);
+            elevator.Communicator.Write(agvNames[1], agvSignal);
+
+            ConsoleHelper.WriteInfoLine($"姝f瀬AGV浜や簰: 鍐欏叆鐢垫淇″彿[{elevatorSignal}]鍒皗agvNames[0]}锛�" +
+                                       $"鍐欏叆AGV淇″彿[{agvSignal}]鍒皗agvNames[1]}");
+        }
+
+        private static void HandleNegativeAGV(CommonElevator elevator, AGV agv, List<string> elevatorNames, List<string> agvNames)
+        {
+            // 瀹氫箟淇″彿缁勫鐞嗭紙璧峰绱㈠紩锛屾搷浣滅被鍨嬶紝鏃ュ織鎻忚堪锛�
+            var operations = new List<(int startIdx, string type, string desc)>
+            {
+                (0,  "E鈫扐", "鍩虹淇″彿浜や簰"),
+                (2,  "A鈫扙", "鐘舵�佸弽棣�"),
+                (4,  "E鈫扐", "璁惧鐘舵�佸悓姝�"),
+                (6,  "A鈫扙", "浠诲姟鎸囦护"),
+                (8,  "E鈫扐", "浣嶇疆淇℃伅鍚屾"),
+                (10, "A鈫扙", "鍗曚俊鍙峰弽棣�"),
+                (11, "A鈫扙", "鍙屼俊鍙峰弽棣�"),
+                (13, "A鈫扙", "鍗曚俊鍙峰弽棣�"),
+                (14, "E鈫扐", "璁惧鐘舵�佸悓姝�"),
+                (16, "A鈫扙", "杩愯鎸囦护"),
+                (18, "E鈫扐", "澶氫俊鍙峰悓姝�"),
+                (22, "A鈫扙", "缁撴潫淇″彿鍙嶉")
+            };
+
+            foreach (var op in operations)
+            {
+                ProcessSignalGroup(
+                    elevator, agv,
+                    elevatorNames, agvNames,
+                    op.startIdx,
+                    op.type,
+                    op.desc
+                );
+            }
+        }
+
+        private static void ProcessSignalGroup(CommonElevator elevator, AGV agv, List<string> elevatorNames, List<string> agvNames, int startIdx, string operationType, string description)
+        {
+            const int GROUP_SIZE = 2; // 姣忕粍澶勭悊2涓俊鍙�
+
+            // 鐗规畩澶勭悊鏈�鍚庡嚑涓俊鍙风粍
+            if (startIdx >= 18)
+            {
+                HandleSpecialSignals(elevator, agv, elevatorNames, agvNames, startIdx);
+                return;
+            }
+
+            var values = new List<byte[]>();
+            var targets = new List<string>();
+
+            // 鏍规嵁鎿嶄綔绫诲瀷澶勭悊淇″彿
+            if (operationType == "E鈫扐")
+            {
+                for (int i = 0; i < GROUP_SIZE; i++)
+                {
+                    int idx = startIdx + i;
+                    if (idx >= elevatorNames.Count) break;
+
+                    var value = elevator.Communicator.Read<byte>(elevatorNames[idx], 100);
+                    agv.Communicator.Write(agvNames[idx], value);
+                    values.Add(value);
+                    targets.Add(agvNames[idx]);
+                    if (description == "鍗曚俊鍙峰弽棣�") break;
+                }
+            }
+            else if (operationType == "A鈫扙")
+            {
+                for (int i = 0; i < GROUP_SIZE; i++)
+                {
+                    int idx = startIdx + i;
+                    if (idx >= agvNames.Count) break;
+
+                    var value = agv.Communicator.Read<byte>(agvNames[idx], 100);
+                    elevator.Communicator.Write(elevatorNames[idx], value);
+                    values.Add(value);
+                    targets.Add(elevatorNames[idx]);
+                    if (description == "鍗曚俊鍙峰弽棣�") break;
+                }
+            }
+
+            // 鐢熸垚鍔ㄦ�佹棩蹇楁弿杩�
+            var logValues = string.Join("], [", values);
+            var logTargets = string.Join("锛�", targets);
+            ConsoleHelper.WriteInfoLine($"璐熸瀬AGV浜や簰({description}): 浼犺緭淇″彿缁刐{logValues}]鍒扮洰鏍囧湴鍧�[{logTargets}]");
+        }
+
+        private static void HandleSpecialSignals(CommonElevator elevator, AGV agv,
+                                                List<string> elevatorNames, List<string> agvNames,
+                                                int startIdx)
+        {
+            // 澶勭悊18-21鍙风數姊俊鍙凤紙4涓俊鍙凤級
+            var elevatorSignals = Enumerable.Range(18, 4)
+                .Select(i => elevator.Communicator.Read<byte>(elevatorNames[i], 100))
+                .ToList();
+
+            for (int i = 0; i < 4; i++)
+            {
+                agv.Communicator.Write(agvNames[18 + i], elevatorSignals[i]);
+            }
+
+            // 澶勭悊22-23鍙稟GV淇″彿
+            var agvSignals = Enumerable.Range(22, 2)
+                .Select(i => agv.Communicator.Read<byte>(agvNames[i], 100))
+                .ToList();
+
+            for (int i = 0; i < 2; i++)
+            {
+                elevator.Communicator.Write(elevatorNames[22 + i], agvSignals[i]);
+            }
+
+            ConsoleHelper.WriteInfoLine($"璐熸瀬AGV浜や簰(鐗规畩淇″彿缁�): " +
+                                       $"鍐欏叆鐢垫淇″彿[{string.Join(",", elevatorSignals)}]鍒癆GV锛�" +
+                                       $"璇诲彇AGV淇″彿[{string.Join(",", agvSignals)}]鍒扮數姊�");
+        }
+
+        private List<string> GetDBElevatorNamesValues(string deviceName)
+        {
+            List<string> dbNamesValues = null;
+            if (deviceName == "姝f瀬AGV")
+            {
+                dbNamesValues = new List<string>()
+                {
+                    "DB1002.1600",
+                    "DB1002.1700"
+                };
+            }
+            else
+            {
+                dbNamesValues = new List<string>()
+                {
+                    "DB1002.0",
+                    "DB1002.600",
+                    "DB1002.100",
+                    "DB1002.700",
+                    "DB1002.1000",
+                    "DB1002.1200",
+                    "DB1002.1100",
+                    "DB1002.1300",
+                    "DB1002.1800",
+                    "DB1002.1200",
+                    "DB1002.11400",
+                    "DB1002.1900",
+                    "DB1002.2100",
+                    "DB1002.2300",
+                    "DB1002.2400",
+                    "DB1002.2600",
+                    "DB1002.2500",
+                    "DB1002.2700",
+                    "DB1002.2000",
+                    "DB1002.2800",
+                    "DB1002.3000",
+                    "DB1002.2200",
+                    "DB1002.2900",
+                    "DB1002.3100"
+                };
+            }
+            return dbNamesValues;
+        }
+
+        private List<string> GetDBAGVNamesValues(string deviceName)
+        {
+            List<string> dbNamesValues = null;
+            if (deviceName == "姝f瀬AGV")
+            {
+                dbNamesValues = new List<string>()
+                {
+                    "DB1002.4000",
+                    "DB1002.4100"
+                };
+            }
+            else
+            {
+                dbNamesValues = new List<string>()
+                {
+                    "DB1002.200",
+                    "DB1002.600",
+                    "DB1002.300",
+                    "DB1002.700",
+                    "DB1002.1000",
+                    "DB1002.1400",
+                    "DB1002.1100",
+                    "DB1002.1500",
+                    "DB1002.17800",
+                    "DB1002.1400",
+                    "DB1002.2200",
+                    "DB1002.17900",
+                    "DB1002.18100",
+                    "DB1002.18300",
+                    "DB1002.18400",
+                    "DB1002.18600",
+                    "DB1002.18500",
+                    "DB1002.18700",
+                    "DB1002.18800",
+                    "DB1002.19000",
+                    "DB1002.18200",
+                    "DB1002.18000",
+                    "DB1002.18900",
+                    "DB1002.19100"
+                };
+            }
+            return dbNamesValues;
+        }
+    }
+}
\ No newline at end of file

--
Gitblit v1.9.3