From a040e5ae0239808e51fb78678f9e60922d11b930 Mon Sep 17 00:00:00 2001
From: 刘磊 <1161824510@qq.com>
Date: 星期二, 17 十二月 2024 20:01:42 +0800
Subject: [PATCH] 同步

---
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoRepository/Dt_needBarcodeRepository.cs      |   29 ++
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_BZ/CommonConveyorLine_BZJob.cs |  239 +++++++++++++++++
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/Dt_needBarcodeService.cs            |   15 +
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/Task/Task_HtyController.cs        |   25 +
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/ConveyorLine/CommonConveyorLine_BZ.cs      |  342 ++++++++++++++++++++++++
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/BasicInfo/dt_needBarcode.cs             |   72 +++++
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_IBasicInfoService/IDt_needBarcodeService.cs          |   29 ++
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_IBasicInfoRepository/IDt_needBarcodeRepository.cs    |   32 ++
 8 files changed, 783 insertions(+), 0 deletions(-)

diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoRepository/Dt_needBarcodeRepository.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoRepository/Dt_needBarcodeRepository.cs
new file mode 100644
index 0000000..e262ac4
--- /dev/null
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoRepository/Dt_needBarcodeRepository.cs
@@ -0,0 +1,29 @@
+锘�#region << 鐗� 鏈� 娉� 閲� >>
+/*----------------------------------------------------------------
+ * 鍛藉悕绌洪棿锛歐IDESEAWCS_TaskInfoRepository
+ * 鍒涘缓鑰咃細鑳$搴�
+ * 鍒涘缓鏃堕棿锛�2024/8/2 16:13:36
+ * 鐗堟湰锛歏1.0.0
+ * 鎻忚堪锛�
+ *
+ * ----------------------------------------------------------------
+ * 淇敼浜猴細
+ * 淇敼鏃堕棿锛�
+ * 鐗堟湰锛歏1.0.1
+ * 淇敼璇存槑锛�
+ * 
+ *----------------------------------------------------------------*/
+#endregion << 鐗� 鏈� 娉� 閲� >>
+
+using WIDESEAWCS_Core.BaseRepository;
+using WIDESEAWCS_Model.Models;
+
+namespace WIDESEAWCS_BasicInfoRepository
+{
+    public class Dt_needBarcodeRepository : RepositoryBase<dt_needBarcode>, IDt_needBarcodeRepository
+    {
+        public Dt_needBarcodeRepository(IUnitOfWorkManage unitOfWorkManage) : base(unitOfWorkManage)
+        {
+        }
+    }
+}
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/Dt_needBarcodeService.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/Dt_needBarcodeService.cs
new file mode 100644
index 0000000..5b0e895
--- /dev/null
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/Dt_needBarcodeService.cs
@@ -0,0 +1,15 @@
+锘縰sing WIDESEAWCS_BasicInfoRepository;
+using WIDESEAWCS_Core.BaseServices;
+using WIDESEAWCS_ISystemServices;
+using WIDESEAWCS_Model.Models;
+
+namespace WIDESEAWCS_BasicInfoService
+{
+    public partial class dt_needBarcodeService : ServiceBase<dt_needBarcode, IDt_needBarcodeRepository>, Idt_needBarcodeService
+    {
+        public dt_needBarcodeService(IDt_needBarcodeRepository BaseDal) : base(BaseDal)
+        {
+            
+        }
+    }
+}
\ No newline at end of file
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_IBasicInfoRepository/IDt_needBarcodeRepository.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_IBasicInfoRepository/IDt_needBarcodeRepository.cs
new file mode 100644
index 0000000..0d6c0af
--- /dev/null
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_IBasicInfoRepository/IDt_needBarcodeRepository.cs
@@ -0,0 +1,32 @@
+锘�#region << 鐗� 鏈� 娉� 閲� >>
+/*----------------------------------------------------------------
+ * 鍛藉悕绌洪棿锛歐IDESEAWCS_ITaskInfoRepository
+ * 鍒涘缓鑰咃細鑳$搴�
+ * 鍒涘缓鏃堕棿锛�2024/8/2 16:13:36
+ * 鐗堟湰锛歏1.0.0
+ * 鎻忚堪锛�
+ *
+ * ----------------------------------------------------------------
+ * 淇敼浜猴細
+ * 淇敼鏃堕棿锛�
+ * 鐗堟湰锛歏1.0.1
+ * 淇敼璇存槑锛�
+ * 
+ *----------------------------------------------------------------*/
+#endregion << 鐗� 鏈� 娉� 閲� >>
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEAWCS_Core.BaseRepository;
+using WIDESEAWCS_Model.Models;
+
+namespace WIDESEAWCS_BasicInfoRepository
+{
+    public interface IDt_needBarcodeRepository : IRepository<dt_needBarcode>
+    {
+
+    }
+}
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_IBasicInfoService/IDt_needBarcodeService.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_IBasicInfoService/IDt_needBarcodeService.cs
new file mode 100644
index 0000000..e4c1cac
--- /dev/null
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_IBasicInfoService/IDt_needBarcodeService.cs
@@ -0,0 +1,29 @@
+锘�#region << 鐗� 鏈� 娉� 閲� >>
+
+/*----------------------------------------------------------------
+ * 鍛藉悕绌洪棿锛歐IDESEAWCS_ITaskInfoService
+ * 鍒涘缓鑰咃細鑳$搴�
+ * 鍒涘缓鏃堕棿锛�2024/8/2 16:13:36
+ * 鐗堟湰锛歏1.0.0
+ * 鎻忚堪锛�
+ *
+ * ----------------------------------------------------------------
+ * 淇敼浜猴細
+ * 淇敼鏃堕棿锛�
+ * 鐗堟湰锛歏1.0.1
+ * 淇敼璇存槑锛�
+ *
+ *----------------------------------------------------------------*/
+
+#endregion << 鐗� 鏈� 娉� 閲� >>
+
+using WIDESEAWCS_Core.BaseServices;
+using WIDESEAWCS_Model.Models;
+
+namespace WIDESEAWCS_BasicInfoService
+{
+    public interface Idt_needBarcodeService : IService<dt_needBarcode>
+    {
+
+    }
+}
\ No newline at end of file
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/BasicInfo/dt_needBarcode.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/BasicInfo/dt_needBarcode.cs
new file mode 100644
index 0000000..6de828c
--- /dev/null
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/BasicInfo/dt_needBarcode.cs
@@ -0,0 +1,72 @@
+锘縰sing SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Text;
+using WIDESEAWCS_Core.DB.Models;
+
+namespace WIDESEAWCS_Model.Models
+{
+    public class dt_needBarcode : BaseEntity
+    {
+        [Key]
+        [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "涓婚敭")]
+        public int id { get; set; }
+
+        /// <summary>
+        /// 鐩爣搴撳尯
+        /// </summary>
+        [SugarColumn(IsNullable = false, Length = 20, ColumnDescription = "鐩爣搴撳尯")]
+        public string toArea { get; set; }
+
+        /// <summary>
+        /// 鏉ユ簮搴撳尯
+        /// </summary>
+        [SugarColumn(IsNullable = false, Length = 10, ColumnDescription = "鏉ユ簮搴撳尯")]
+        public string fromArea { get; set; }
+
+        /// <summary>
+        /// 鎵樼洏绫诲瀷
+        /// </summary>
+        [SugarColumn(IsNullable = false, Length = 10, ColumnDescription = "鎵樼洏绫诲瀷")]
+        public string barcodeType { get; set; }
+
+        /// <summary>
+        /// 浜х嚎
+        /// </summary>
+        [SugarColumn(IsNullable = false, Length = 10, ColumnDescription = "鎵�灞炰骇绾�")]
+        public string productLine {  get; set; }
+
+        /// <summary>
+        /// 鍦ㄩ�旀暟閲�
+        /// </summary>
+        [SugarColumn(IsNullable = false, Length = 10, ColumnDescription = "鍦ㄩ�旀暟閲�")]
+        public int inLineNum { get; set; }
+
+        /// <summary>
+        /// 鐩爣缂撳瓨鏁伴噺
+        /// </summary>
+        [SugarColumn(IsNullable = false, Length = 10, ColumnDescription = "鍙紦瀛樻暟閲�")]
+        public int cacheNum { get; set; } = 0;
+
+
+        /// <summary>
+        /// 宸插垱寤哄嚭搴撲换鍔℃暟閲�
+        /// </summary>
+        [NotMapped]
+        public int haveOutNum { get; set; } = 0;
+
+        /// <summary>
+        /// 鍙叆鏁伴噺
+        /// </summary>
+        [NotMapped]
+        public int canInNum { get; set; } = 0;
+
+        /// <summary>
+        /// 宸插垱寤哄嚭搴撲换鍔�
+        /// </summary>
+        [NotMapped]
+        public List<Dt_Task> haveOutList { get; set; }
+    }
+}
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/ConveyorLine/CommonConveyorLine_BZ.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/ConveyorLine/CommonConveyorLine_BZ.cs
new file mode 100644
index 0000000..57e35bf
--- /dev/null
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/ConveyorLine/CommonConveyorLine_BZ.cs
@@ -0,0 +1,342 @@
+锘�#region << 鐗� 鏈� 娉� 閲� >>
+
+/*----------------------------------------------------------------
+ * 鍛藉悕绌洪棿锛歐IDESEAWCS_QuartzJob
+ * 鍒涘缓鑰咃細鑳$搴�
+ * 鍒涘缓鏃堕棿锛�2024/8/2 16:13:36
+ * 鐗堟湰锛歏1.0.0
+ * 鎻忚堪锛氫竴鑸緭閫佺嚎瀹炵幇绫�
+ *
+ * ----------------------------------------------------------------
+ * 淇敼浜猴細
+ * 淇敼鏃堕棿锛�
+ * 鐗堟湰锛歏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
+{
+    [Description("杈撻�佺嚎")]
+    public class CommonConveyorLine_BZ : IConveyorLine
+    {
+        #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 IsFault => false;
+
+        /// <summary>
+        /// 閫氳鏄惁宸茶繛鎺�
+        /// </summary>
+        public bool IsConnected => Communicator.IsConnected && _isConnected;
+
+        /// <summary>
+        /// 璁惧鐘舵��
+        /// </summary>
+        public DeviceStatus Status => DeviceStatus.Offline;
+
+        #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 CommonConveyorLine_BZ(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="TRsult">璇诲彇鏁版嵁鐨勭被鍨嬪璞′俊鎭��</typeparam>
+        /// <param name="value">鏋氫妇鍊�</param>
+        /// <param name="deviceChildCode">璁惧瀛愮紪鍙�</param>
+        /// <returns>璇诲彇鍒扮殑鏁版嵁</returns>
+        public TRsult GetValue<TEnum, TRsult>(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() : (TRsult)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 (!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;
+        }
+
+        /// <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 == "DeviceCommand" && x.DeviceChildCode == deviceChildCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
+
+            if (devicePro == null)
+            {
+                throw new Exception($"銆恵_deviceCode}銆�--鏈壘鍒般�恵deviceChildCode}銆戝崗璁俊鎭�");
+            }
+            else
+            {
+                return Communicator.ReadCustomer<T>(devicePro.DeviceProAddress);
+            }
+        }
+
+        /// <summary>
+        /// 璇诲彇PLC鏁版嵁锛岃繑鍥炶嚜瀹氫箟瀵硅薄
+        /// </summary>
+        /// <typeparam name="T">娉涘瀷</typeparam>
+        /// <param name="deviceChildCode">瀛愯澶囩紪鍙�</param>
+        /// <param name="deviceProParamType">鍙傛暟绫诲瀷</param>
+        /// <returns>杩斿洖鑷畾涔夊璞℃垨鎶涘嚭寮傚父</returns>
+        /// <exception cref="Exception"></exception>
+        public T ReadCustomer<T>(string deviceChildCode, string deviceProParamType) where T : IDataTransfer, new()
+        {
+            if (!IsConnected) throw new Exception($"閫氳杩炴帴閿欒锛岃妫�鏌ョ綉缁�");
+            DeviceProDTO? devicePro = _deviceProDTOs.Where(x => x.DeviceProParamType == deviceProParamType && x.DeviceChildCode == deviceChildCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
+
+            if (devicePro == null)
+            {
+                throw new Exception($"鏈壘鍒般�恵deviceChildCode}銆戝崗璁俊鎭�");
+            }
+            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() : Communicator.WriteObj(devicePro.DeviceProAddress, devicePro.DeviceDataType, value);
+        }
+
+        /// <summary>
+        /// 鏍规嵁鍙傛暟鍚嶇О銆佽澶囧瓙缂栧彿璇诲彇瀵瑰簲鐨勬暟鎹��
+        /// </summary>
+        /// <typeparam name="TEnum">鍙傛暟鍚嶇О鏋氫妇绫诲瀷銆�</typeparam>
+        /// <param name="enum">鍙傛暟鍚嶇О銆�</param>
+        /// <param name="deviceChildCode">璁惧瀛愮紪鍙峰啓</param>
+        /// <returns>杩斿洖鍐欏叆鎴愬姛鎴栧け璐�</returns>
+        public object ReadValue<TEnum>(TEnum @enum, string deviceChildCode)
+            where TEnum : Enum
+        {
+            if (!IsConnected) throw new Exception($"閫氳杩炴帴閿欒锛岃妫�鏌ョ綉缁�");
+            DeviceProDTO? devicePro = _deviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == @enum.ToString() && x.DeviceChildCode == deviceChildCode);
+            return devicePro == null ? throw new Exception() : Communicator.ReadAsObj(devicePro.DeviceProAddress, devicePro.DeviceDataType);
+        }
+
+        //public bool IsOccupied(string deviceChildCode)
+        //{
+        //    if (Communicator.IsConnected)
+        //    {
+                
+        //    }
+        //}
+
+        /// <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.DeviceChildCode == deviceChildCode && x.DeviceProParamName == "InteractiveSignal").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 == "InteractiveSignal" && x.ProtocalDetailValue.Equals(readStatus.ToString()));
+                    if (deviceProtocolDetail != null)
+                    {
+                        return true;
+                    }
+                    return false;
+                }
+            }
+            //todo 閫氳鏈繛鎺ユ椂鎶涘嚭寮傚父
+            return false;
+        }
+
+        public void Dispose()
+        {
+            _heartStatr = false;
+            _communicator.Dispose();
+            GC.SuppressFinalize(this);
+        }
+
+        #endregion
+    }
+}
\ No newline at end of file
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/Task/Task_HtyController.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/Task/Task_HtyController.cs
new file mode 100644
index 0000000..28a2ea2
--- /dev/null
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/Task/Task_HtyController.cs
@@ -0,0 +1,25 @@
+锘縰sing Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using WIDESEAWCS_Core;
+using WIDESEAWCS_Core.BaseController;
+using WIDESEAWCS_DTO.TaskInfo;
+using WIDESEAWCS_ITaskInfo_HtyService;
+using WIDESEAWCS_ITaskInfoService;
+using WIDESEAWCS_Model.Models;
+
+namespace WIDESEAWCS_WCSServer.Controllers.Task
+{
+    [Route("api/Task_Hty")]
+    [ApiController]
+    public class Task_HtyController : ApiBaseController<ITask_HtyService, Dt_Task_Hty>
+    {
+        private readonly IHttpContextAccessor _httpContextAccessor;
+        public Task_HtyController(ITask_HtyService service, IHttpContextAccessor httpContextAccessor) : base(service)
+        {
+            _httpContextAccessor = httpContextAccessor;
+        }
+
+        
+    }
+}
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_BZ/CommonConveyorLine_BZJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_BZ/CommonConveyorLine_BZJob.cs
new file mode 100644
index 0000000..5a08e4b
--- /dev/null
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_BZ/CommonConveyorLine_BZJob.cs
@@ -0,0 +1,239 @@
+锘�#region MyRegion
+#region << 鐗� 鏈� 娉� 閲� >>
+
+/*----------------------------------------------------------------
+ * 鍛藉悕绌洪棿锛歐IDESEAWCS_Tasks.ConveyorLineJob
+ * 鍒涘缓鑰咃細鑳$搴�
+ * 鍒涘缓鏃堕棿锛�2024/8/2 16:13:36
+ * 鐗堟湰锛歏1.0.0
+ * 鎻忚堪锛�
+ *
+ * ----------------------------------------------------------------
+ * 淇敼浜猴細
+ * 淇敼鏃堕棿锛�
+ * 鐗堟湰锛歏1.0.1
+ * 淇敼璇存槑锛�
+ *
+ *----------------------------------------------------------------*/
+
+#endregion << 鐗� 鏈� 娉� 閲� >>
+
+using AutoMapper;
+using HslCommunication;
+using Microsoft.AspNetCore.Server.HttpSys;
+using Newtonsoft.Json;
+using Quartz;
+using SqlSugar;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Reflection;
+using System.Threading.Tasks;
+using WIDESEAWCS_BasicInfoRepository;
+using WIDESEAWCS_BasicInfoService;
+using WIDESEAWCS_Common;
+using WIDESEAWCS_Common.TaskEnum;
+using WIDESEAWCS_Core;
+using WIDESEAWCS_Core.Caches;
+using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_Core.HttpContextUser;
+using WIDESEAWCS_DTO.MOM;
+using WIDESEAWCS_DTO.TaskInfo;
+using WIDESEAWCS_IProcessRepository;
+using WIDESEAWCS_ISystemRepository;
+using WIDESEAWCS_ISystemServices;
+using WIDESEAWCS_ITaskInfoRepository;
+using WIDESEAWCS_ITaskInfoService;
+using WIDESEAWCS_Model.Models;
+using WIDESEAWCS_QuartzJob;
+using WIDESEAWCS_QuartzJob.DeviceBase;
+using WIDESEAWCS_QuartzJob.DTO;
+using WIDESEAWCS_QuartzJob.Service;
+using WIDESEAWCS_SignalR;
+using WIDESEAWCS_Tasks.ConveyorLineJob;
+using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
+using ICacheService = WIDESEAWCS_Core.Caches.ICacheService;
+
+namespace WIDESEAWCS_Tasks
+{
+    [DisallowConcurrentExecution]
+    public partial class CommonConveyorLine_BZJob : JobBase, IJob
+    {
+        public readonly ITaskService _taskService;
+        private readonly ITaskRepository _taskRepository;
+        private readonly ITaskExecuteDetailService _taskExecuteDetailService;
+        private readonly IRouterService _routerService;
+        private readonly IPlatFormRepository _platFormRepository;
+        private readonly ISys_ConfigService _sys_ConfigService;
+        private readonly IMapper _mapper;
+        private readonly IDt_StationManagerService _stationManagerService;
+        private readonly IDt_StationManagerRepository _stationManagerRepository;
+        private readonly ICacheService _cacheService;
+        private readonly INoticeService _noticeService;
+        private readonly IDt_needBarcodeRepository _needBarcodeRepository;
+
+        public CommonConveyorLine_BZJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper, ITaskRepository taskRepository, IPlatFormRepository platFormRepository, ISys_ConfigService sys_ConfigService, IDt_StationManagerRepository stationManagerRepository, ICacheService cacheService, INoticeService noticeService, IDt_StationManagerService stationManagerService, IDt_needBarcodeRepository needBarcodeRepository)
+        {
+            _taskService = taskService;
+            _taskExecuteDetailService = taskExecuteDetailService;
+            _routerService = routerService;
+            _mapper = mapper;
+            _taskRepository = taskRepository;
+            _platFormRepository = platFormRepository;
+            _sys_ConfigService = sys_ConfigService;
+            _stationManagerRepository = stationManagerRepository;
+            _cacheService = cacheService;
+            _noticeService = noticeService;
+            _stationManagerService = stationManagerService;
+            _needBarcodeRepository = needBarcodeRepository;
+        }
+
+        public Task Execute(IJobExecutionContext context)
+        {
+            try
+            {
+                CommonConveyorLine_BZ conveyorLine = (CommonConveyorLine_BZ)context.JobDetail.JobDataMap.Get("JobParams");
+                if (conveyorLine != null)
+                {
+                    #region 绔欏彴鏂瑰紡
+                    List<Dt_StationManager> stationManagers = _stationManagerService.GetAllStationByDeviceCode(conveyorLine.DeviceCode);
+
+                    foreach (var station in stationManagers)
+                    {
+                        ConveyorLineTaskCommand_After command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(station.stationChildCode);
+
+                        DeviceProtocolDetailDTO? deviceProtocolDetails = conveyorLine.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(ConveyorLineTaskCommand_After.InteractiveSignal) && x.ProtocalDetailValue == command.InteractiveSignal.ToString());
+                        if (deviceProtocolDetails != null)
+                        {
+                            MethodInfo? method = GetType().GetMethod(deviceProtocolDetails.ProtocolDetailType);
+                            if (method != null)
+                            {
+                                method.Invoke(this, new object[] { conveyorLine, command, station });
+                            }
+                        }
+
+                        #region 璋冪敤浜嬩欢鎬荤嚎閫氱煡鍓嶇
+                        var tokenInfos = _cacheService.Get<List<UserInfo>>("Cache_UserToken");
+                        if (tokenInfos == null || !tokenInfos.Any())
+                        {
+                            //throw new Exception(conveyorLine.DeviceName + "缂撳瓨涓湭鎵惧埌Token缂撳瓨");
+                            continue;
+                        }
+                        var userTokenIds = tokenInfos?.Select(x => x.Token_ID).ToList();
+                        var userIds = tokenInfos?.Select(x => x.UserId).ToList();
+
+                        object obj = new
+                        {
+                            station.stationChildCode,
+                            commandAfter = command,
+                        };
+                        _noticeService.StackerData(userIds?.FirstOrDefault(), userTokenIds, new { conveyorLine.DeviceName, data = obj });
+
+                        #endregion 璋冪敤浜嬩欢鎬荤嚎閫氱煡鍓嶇
+                    }
+                    #endregion
+
+                    #region 璺敱鏂瑰紡
+                    //List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode);
+                    //foreach (string childDeviceCode in childDeviceCodes)
+                    //{
+                    //    ConveyorLineTaskCommand_After command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(childDeviceCode);
+
+                    //    if (command == null) continue;
+                    //    if (command.ConveyorLineBarcode.Trim().Contains("\0")) command.ConveyorLineBarcode = "";
+
+                    //    DeviceProtocolDetailDTO? deviceProtocolDetails = conveyorLine.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(ConveyorLineTaskCommand_After.InteractiveSignal) && x.ProtocalDetailValue == command.InteractiveSignal.ToString());
+                    //    if (deviceProtocolDetails != null)
+                    //    {
+                    //        MethodInfo? method = GetType().GetMethod(deviceProtocolDetails.ProtocolDetailType);
+                    //        if (method != null)
+                    //        {
+                    //            method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode });
+                    //        }
+                    //    }
+
+                    //    if (childDeviceCode == "1670")
+                    //    {
+                    //        Platform platform = _platFormRepository.QueryFirst(x => x.PLCCode == conveyorLine.DeviceCode && x.PlatCode == childDeviceCode && x.Status == "Active");
+                    //        if (platform != null)
+                    //        {
+                    //            if (command.HasPallet != 1)
+                    //            {
+                    //                MethodInfo? method = GetType().GetMethod(platform.ExecutionMethod);
+                    //                if (method != null)
+                    //                {
+                    //                    int count = string.IsNullOrEmpty(platform.Location) ? 0 + 1 : platform.Location.Split(',').Count() + 1;
+                    //                    method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform });
+                    //                }
+                    //            }
+                    //        }
+                    //    }
+                    //}
+                    #endregion
+                }
+            }
+            catch (Exception ex)
+            {
+                Console.Out.WriteLine(nameof(CommonConveyorLine_BZJob) + ":" + ex.ToString());
+            }
+            finally
+            {
+                //WriteDebug("CommonConveyorLineJob", "test");
+                //Console.Out.WriteLine(DateTime.Now);
+            }
+            return Task.CompletedTask;
+        }
+
+        /// <summary>
+        /// 杈撻�佺嚎璇锋眰鍑轰俊鎭�
+        /// </summary>
+        /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
+        /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
+        /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
+        /// <param name="station">绾夸綋褰撳墠bool璇诲彇鍋忕Щ鍦板潃</param>
+        public void RequestOutbound(CommonConveyorLine_BZ conveyorLine, ConveyorLineTaskCommand_After command, Dt_StationManager station)
+        {
+            //鏌ヨ瀵瑰簲浜х嚎鐨勫湪閫旀暟鎹�
+            dt_needBarcode needBarcode = _needBarcodeRepository.QueryFirst(x => x.productLine == station.stationRemark);
+
+            //needBarcode.haveOutNum
+
+            //鑻ュ湪閫旀暟閲忓皬浜庣洰鏍囦綅缃殑缂撳瓨鏁伴噺 鍒欏鎵惧搴斿父娓╁簱瀛樹腑甯告俯3宸ュ簭鐨勫彲鍑哄簱鏁版嵁 骞跺缓绔嬪嚭搴撲换鍔�
+            if (needBarcode.inLineNum <= needBarcode.cacheNum)
+            {
+                if (_taskService.RequestOutTaskToBZAsync(station).Result.Status)
+                {
+                    needBarcode.inLineNum++;
+                    _needBarcodeRepository.UpdateData(needBarcode);
+                }
+            }
+        }
+
+        /// <summary>
+        /// 鍒拌揪鐩爣浣嶇疆鍚�  灏嗗搴斾换鍔℃竻闄� 骞舵洿鏂板湪閫旀暟鎹�
+        /// </summary>
+        /// <param name="conveyorLine"></param>
+        /// <param name="command"></param>
+        /// <param name="station"></param>
+        public void RecivcePalletBarcode(CommonConveyorLine_BZ conveyorLine, ConveyorLineTaskCommand_After command, Dt_StationManager station)
+        {
+            Dt_Task task = _taskRepository.QueryFirst(x => x.PalletCode == command.ConveyorLineBarcode && x.CurrentAddress == station.stationChildCode);
+
+            dt_needBarcode needBarcode = _needBarcodeRepository.QueryFirst(x => x.toArea == station.stationChildCode);
+            if (needBarcode == null) throw new Exception($"鏈厤缃浉鍏硔station.stationChildCode}鐨勪骇绾垮湪閫旀暟鎹�");
+
+            if (task != null)
+            {
+                conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, task.NextAddress, station.stationChildCode);
+                _taskRepository.DeleteData(task);
+            }
+            else
+            {
+                conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, station.stationNGChildCode, station.stationChildCode);
+            }
+
+            needBarcode.inLineNum--;
+            _needBarcodeRepository.UpdateData(needBarcode);
+        }
+    }
+}
+#endregion
\ No newline at end of file

--
Gitblit v1.9.3