From 222d2040c2a5e958b5fbd0b7047a8e802ec14288 Mon Sep 17 00:00:00 2001
From: 刘磊 <1161824510@qq.com>
Date: 星期六, 23 十一月 2024 14:42:34 +0800
Subject: [PATCH] 一大堆

---
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_After/CommonConveyorLine_AfterJob.cs |  129 +++++++++++++++++++++---------------------
 1 files changed, 64 insertions(+), 65 deletions(-)

diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_After/CommonConveyorLine_AfterJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_After/CommonConveyorLine_AfterJob.cs
index e5ded63..8ee125c 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_After/CommonConveyorLine_AfterJob.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_After/CommonConveyorLine_AfterJob.cs
@@ -54,7 +54,7 @@
         private readonly IMapper _mapper;
         private readonly IDt_StationManagerService _stationManagerService;
 
-        public CommonConveyorLine_AfterJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper, ITaskRepository taskRepository,IDt_StationManagerService stationManagerService)
+        public CommonConveyorLine_AfterJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper, ITaskRepository taskRepository, IDt_StationManagerService stationManagerService)
         {
             _taskService = taskService;
             _taskExecuteDetailService = taskExecuteDetailService;
@@ -72,13 +72,9 @@
                 if (conveyorLine != null)
                 {
                     List<Dt_StationManager> stationManagers = _stationManagerService.GetAllStationByDeviceCode(conveyorLine.DeviceCode);
-                    List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode);
-                    //List<Task> tasks = new List<Task>();
-                    foreach (string childDeviceCode in childDeviceCodes)
+                    foreach (var station in stationManagers)
                     {
-                        ConveyorLineTaskCommand_After command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(childDeviceCode);
-
-                        if (command.ConveyorLineBarcode.Trim().Contains("\0")) command.ConveyorLineBarcode = "";
+                        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)
@@ -86,16 +82,35 @@
                             MethodInfo? method = GetType().GetMethod(deviceProtocolDetails.ProtocolDetailType);
                             if (method != null)
                             {
-                                method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode });
+                                method.Invoke(this, new object[] { conveyorLine, command, station });
                             }
                         }
                     }
-                    //Task.WaitAll(tasks.ToArray());
+
+                    #region 璺敱鏂瑰紡
+                    //List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode);
+                    //foreach (string childDeviceCode in childDeviceCodes)
+                    //{
+                    //    ConveyorLineTaskCommand_After command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(childDeviceCode);
+
+                    //    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 });
+                    //        }
+                    //    }
+                    //} 
+                    #endregion
                 }
             }
             catch (Exception ex)
             {
-                Console.Out.WriteLine(nameof(CommonConveyorLineJob) + ":" + ex.ToString());
+                Console.Out.WriteLine(nameof(CommonConveyorLine_AfterJob) + ":" + ex.ToString());
             }
             finally
             {
@@ -111,82 +126,66 @@
         /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
         /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
         /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
-        public void RequestInbound(CommonConveyorLine_After conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode)
+        public void RequestInbound(CommonConveyorLine_After conveyorLine, ConveyorLineTaskCommand_After command, Dt_StationManager stationInfo)
         {
-
-            var taskNew = _taskService.QueryCraneConveyorLineTask(command.ConveyorLineTaskNum.ObjToInt(), childDeviceCode);
+            var taskNew = _taskService.QueryTaskByPalletCode(command.ConveyorLineBarcode, stationInfo.Roadway);
             if (taskNew == null)
             {
-                string barcode = command.ConveyorLineBarcode.TrimEnd();
-                if (_taskService.RequestWMSTask(command.ConveyorLineBarcode, childDeviceCode).Result.Status)
+                if (_taskService.RequestTask(command.ConveyorLineBarcode, stationInfo).Result.Status)
                 {
-                    Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
+                    Dt_Task task = _taskService.QueryTaskByPalletCode(command.ConveyorLineBarcode, stationInfo.Roadway);
                     if (task != null)
                     {
-                        ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task);
+                        //ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task);
                         //taskCommand.InteractiveSignal = command.InteractiveSignal;
-                        taskCommand.ResponState = 1;
-                        taskCommand.ConveyorLineTaskNum = task.TaskNum;
-                        taskCommand.ConveyorLineTargetAddress = Convert.ToInt16(task.NextAddress);
-                        conveyorLine.SendCommand(taskCommand, childDeviceCode);
-
+                        //taskCommand.ResponState = 1;
+                        //taskCommand.ConveyorLineTaskNum = task.TaskNum;
+                        //taskCommand.ConveyorLineTargetAddress = Convert.ToInt16(task.NextAddress);
+                        conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, stationInfo.stationChildCode);
+                        //conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, 1, task.NextAddress);
                         //ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
-
-                        _taskService.UpdateTaskStatusToNext(task);
                     }
                 }
             }
-
-            var inTask = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum.ObjToInt(), childDeviceCode);
-            if (inTask != null)
-            {
-                ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(inTask);
-                //taskCommand.InteractiveSignal = command.InteractiveSignal;
-                taskCommand.ResponState = 1;
-                conveyorLine.SendCommand(taskCommand, childDeviceCode);
-
-                _taskService.UpdateTaskStatusToNext(inTask);
-            }
         }
 
         /// <summary>
-        /// 杈撻�佺嚎鍏ュ簱瀹屾垚
+        /// 杈撻�佺嚎璇锋眰鍏ュ簱
         /// </summary>
         /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
         /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
         /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
-        /// <param name="ProtocalDetailValue">绾夸綋褰撳墠bool璇诲彇鍋忕Щ鍦板潃</param>
-        public void ConveyorLineInFinish(CommonConveyorLine_After conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode)
-        {
-            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode);
-            if (task != null && task.TaskState != (int)TaskInStatusEnum.Line_InFinish)
-            {
-                //ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
+        //public void RequestInbound(CommonConveyorLine_After conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode)
+        //{
+        //    var stationInfo = _stationManagerService.GetStationInfoByChildCode(childDeviceCode);
+        //    if (stationInfo != null)
+        //    {
+        //        //_taskService.r
+        //    }
+        //    var taskNew = _taskService.QueryCraneConveyorLineTask(command.ConveyorLineTaskNum.ObjToInt(), childDeviceCode);
+        //    if (taskNew == null)
+        //    {
+        //        string barcode = command.ConveyorLineBarcode.TrimEnd();
+        //        if (_taskService.RequestWMSTask(command.ConveyorLineBarcode, childDeviceCode).Result.Status)
+        //        {
+        //            Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
+        //            if (task != null)
+        //            {
+        //                ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task);
+        //                //taskCommand.InteractiveSignal = command.InteractiveSignal;
+        //                taskCommand.ResponState = 1;
+        //                taskCommand.ConveyorLineTaskNum = task.TaskNum;
+        //                taskCommand.ConveyorLineTargetAddress = Convert.ToInt16(task.NextAddress);
+        //                conveyorLine.SendCommand(taskCommand, childDeviceCode);
 
-                //conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, 0, childDeviceCode);
-                WebResponseContent content = _taskService.UpdateTaskStatusToNext(task);
-                Console.Out.WriteLine(content.Serialize());
-            }
-        }
+        //                //ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
 
-        /// <summary>
-        /// 杈撻�佺嚎璇锋眰鍑轰俊鎭�
-        /// </summary>
-        /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
-        /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
-        /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
-        public void RequestOutbound(CommonConveyorLine_After conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode)
-        {
-            Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
-            if (task != null)
-            {
-                // ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task);
-                //taskCommand.InteractiveSignal = command.InteractiveSignal;
-                // conveyorLine.SendCommand(taskCommand, childDeviceCode);
+        //                _taskService.UpdateTaskStatusToNext(task);
+        //            }
+        //        }
+        //    }
+        //}
 
-                _taskService.UpdateTaskStatusToNext(task);
-            }
-        }
     }
 }
 #endregion
\ No newline at end of file

--
Gitblit v1.9.3