From af9c3ed5d036ad68faf7e18f566679b3da92d244 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期六, 22 三月 2025 11:36:06 +0800
Subject: [PATCH] 合并

---
 CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs |  201 +++++++++++---------------------------------------
 1 files changed, 45 insertions(+), 156 deletions(-)

diff --git a/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs b/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs
index 2383341..ba5dfc1 100644
--- a/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs
+++ b/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs
@@ -1,6 +1,5 @@
-锘�//using HslCommunication;
+锘縰sing HslCommunication;
 using Mapster;
-using Masuit.Tools;
 using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
 using Newtonsoft.Json;
 using System.Text.RegularExpressions;
@@ -283,18 +282,8 @@
         private async Task RequestWmsTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue, Dt_StationManager stationManager)
         {
             string isTrue = string.Empty;
-            ExecuteConveyorLineTask(conveyorLine, command, ProtocalDetailValue, childDeviceCode);
 
             ResultTrayCellsStatus result = GetResultTrayCellsStatus(command, stationManager);
-            if(result.SerialNos.Count == 0)
-            {
-                var Traycontent = await _taskService.RequestWMSTask(command.Barcode, childDeviceCode);
-                if (Traycontent.Status)
-                {
-                    ConsoleHelper.WriteSuccessLine("璇锋眰鍥炴祦闈欑疆");
-                    ExecuteConveyorLineTask(conveyorLine, command, ProtocalDetailValue, childDeviceCode);
-                }
-            }
 
             List<string> strings = stationManager.Roadway.Split(",").ToList();
             foreach (string item in strings)
@@ -515,161 +504,61 @@
                 }
             }
         }
-
-        /// <summary>
-        /// 鎵ц杈撻�佺嚎浠诲姟
-        /// </summary>
-        /// <param name="conveyorLine">杈撻�佺嚎瀵硅薄</param>
-        /// <param name="command">杈撻�佺嚎浠诲姟鍛戒护</param>
-        /// <param name="ProtocalDetailValue">鍗忚鏄庣粏鍊�</param>
-        /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
-        //public void ExecuteConveyorLineTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, int ProtocalDetailValue, string childDeviceCode)
-        //{
-        //    var task = _taskService.QueryBarCodeConveyorLineTask(command.Barcode, childDeviceCode);
-        //    if (task != null)
-        //    {
-        //        var value = _sys_ConfigService.GetByConfigKey(CateGoryConst.CONFIG_SYS_InStation, SysConfigKeyConst.JZNGInBoundStation).ConfigValue;
-        //        var valueList = value.Split(',').ToList();
-        //        if (valueList.Contains(task.SourceAddress))
-        //        {
-        //            conveyorLine.SetValue(ConveyorLineDBName.WriteConveyorLineTargetAddress, "1000", childDeviceCode);
-
-        //            var log = $"銆恵conveyorLine._deviceName}銆戜换鍔″彿锛氥�恵task.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵task.PalletCode}銆戝凡鍒拌揪銆恵childDeviceCode}銆戣姹傛壂鐮佸叆搴�(瀹炵洏),涓嬩竴鐩爣鍦板潃銆恵1000}銆�";
-        //            ConsoleHelper.WriteWarningLine(log);
-
-        //            _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
-        //            WriteInfo(conveyorLine.DeviceName, log);
-
-        //            ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
-        //        }
-        //        else
-        //        {
-        //            if (task.Roadway.Contains("JZ"))
-        //            {
-        //                var outJZTask = _taskRepository.QueryData(x => x.Roadway== task.Roadway && x.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting || x.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting || x.TaskState == (int)TaskOutStatusEnum.SC_OutFinish);
-        //                if (outJZTask.IsNullOrEmpty())
-        //                {
-        //                    var next = task.NextAddress;
-        //                    var taskCommand = MapTaskCommand(task, command);
-        //                    task.NextAddress = next;
-
-        //                    var log = $"銆恵conveyorLine._deviceName}銆戜换鍔″彿锛氥�恵command.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵command.Barcode}銆戝凡鍒拌揪銆恵childDeviceCode}銆戣姹傛壂鐮佸叆搴�(瀹炵洏),涓嬩竴鐩爣鍦板潃銆恵taskCommand.TargetAddress}銆�";
-        //                    ConsoleHelper.WriteWarningLine(log);
-
-        //                    _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
-        //                    WriteInfo(conveyorLine.DeviceName, log);
-
-        //                    conveyorLine.SendCommand(taskCommand, childDeviceCode);
-        //                    ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
-        //                    _taskService.UpdateTaskStatusToNext(task);
-        //                }
-        //                else
-        //                {
-        //                    ConsoleHelper.WriteWarningLine("宸插瓨鍦ㄩ潤缃嚭搴撲换鍔�,闈欑疆鍏ュ簱浠诲姟鏃犳硶涓嬪彂绾夸綋");
-        //                }
-        //            }
-        //            else
-        //            {
-        //                var next = task.NextAddress;
-        //                var taskCommand = MapTaskCommand(task, command);
-        //                task.NextAddress = next;
-        //                var log = $"銆恵conveyorLine._deviceName}銆戜换鍔″彿锛氥�恵command.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵command.Barcode}銆戝凡鍒拌揪銆恵childDeviceCode}銆戣姹傛壂鐮佸叆搴�(瀹炵洏),涓嬩竴鐩爣鍦板潃銆恵taskCommand.TargetAddress}銆�";
-        //                ConsoleHelper.WriteWarningLine(log);
-        //                _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
-        //                WriteInfo(conveyorLine.DeviceName, log);
-        //                conveyorLine.SendCommand(taskCommand, childDeviceCode);
-        //                ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
-        //                _taskService.UpdateTaskStatusToNext(task);
-        //            }
-        //        }
-        //    }
-        //}
-
-        /// <summary>
-        /// 鎵ц杈撻�佺嚎浠诲姟
-        /// </summary>
-        /// <param name="conveyorLine">杈撻�佺嚎瀵硅薄</param>
-        /// <param name="command">杈撻�佺嚎浠诲姟鍛戒护</param>
-        /// <param name="ProtocalDetailValue">鍗忚鏄庣粏鍊�</param>
-        /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
-        public void ExecuteConveyorLineTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, int ProtocalDetailValue, string childDeviceCode)
+        public void ExecuteConveyorLineTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, int ProtocalDetailValue ,string childDeviceCode)
         {
-            // 鏌ヨ浠诲姟淇℃伅
             var task = _taskService.QueryBarCodeConveyorLineTask(command.Barcode, childDeviceCode);
-            if (task == null) return;
-
-            // 鑾峰彇閰嶇疆鍊煎苟杞崲涓哄垪琛�
-            var value = _sys_ConfigService.GetByConfigKey(CateGoryConst.CONFIG_SYS_InStation, SysConfigKeyConst.JZNGInBoundStation).ConfigValue;
-            var valueList = value.Split(',').ToList();
-
-            // 鏃ュ織妯℃澘
-            var logMessage = $"銆恵conveyorLine._deviceName}銆戜换鍔″彿锛氥�恵task.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵task.PalletCode}銆戝凡鍒拌揪銆恵childDeviceCode}銆戣姹傛壂鐮佸叆搴�(瀹炵洏),涓嬩竴鐩爣鍦板潃銆恵{0}}銆�";
-
-            // 鍒ゆ柇浠诲姟鐨勮捣濮嬪湴鍧�鏄惁鍦ㄩ厤缃垪琛ㄤ腑
-            if (valueList.Contains(task.SourceAddress))
+            if (task != null)
             {
-                // 璁剧疆鐩爣鍦板潃涓� "1000"
-                conveyorLine.SetValue(ConveyorLineDBName.WriteConveyorLineTargetAddress, "1000", childDeviceCode);
-                // 璁板綍鏃ュ織骞跺彂閫佸畬鎴愪俊鍙�
-                LogAndSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, logMessage, "1000");
-            }
-            else if (task.Roadway.Contains("JZ"))
-            {
-                // 鏌ヨ鏄惁瀛樺湪闈欑疆鍑哄簱浠诲姟
-                var outJZTask = _taskRepository.QueryData(x => x.Roadway == task.Roadway &&
-                    (x.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting ||
-                     x.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting ||
-                     x.TaskState == (int)TaskOutStatusEnum.SC_OutFinish));
-
-                if (outJZTask.IsNullOrEmpty())
+                var value = _sys_ConfigService.GetByConfigKey(CateGoryConst.CONFIG_SYS_InStation, SysConfigKeyConst.JZNGInBoundStation).ConfigValue;
+                var valueList = value.Split(',').ToList();
+                if (valueList.Contains(task.SourceAddress))
                 {
-                    // 鏄犲皠浠诲姟鍛戒护
+                    conveyorLine.SetValue(ConveyorLineDBName.WriteConveyorLineTargetAddress, "1000", childDeviceCode);
+
+                    var log = $"銆恵conveyorLine._deviceName}銆戜换鍔″彿锛氥�恵task.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵task.PalletCode}銆戝凡鍒拌揪銆恵childDeviceCode}銆戣姹傛壂鐮佸叆搴�(瀹炵洏),涓嬩竴鐩爣鍦板潃銆恵1000}銆�";
+                    ConsoleHelper.WriteWarningLine(log);
+
+                    _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
+                    WriteInfo(conveyorLine.DeviceName, log);
+
+                    ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
+                }
+                else if (task.TargetAddress == "1020-1")
+                {
+                    var next = task.NextAddress;
                     var taskCommand = MapTaskCommand(task, command);
-                    // 璁板綍鏃ュ織骞跺彂閫佸畬鎴愪俊鍙�
-                    LogAndSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, logMessage, taskCommand.TargetAddress.ToString());
-                    // 鍙戦�佷换鍔″懡浠�
+                    task.NextAddress = next;
+
+                    var log = $"銆恵conveyorLine._deviceName}銆戜换鍔″彿锛氥�恵command.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵command.Barcode}銆戝凡鍒拌揪銆恵childDeviceCode}銆戣姹傛壂鐮佸叆搴�(瀹炵洏),涓嬩竴鐩爣鍦板潃銆恵taskCommand.TargetAddress}銆�";
+                    ConsoleHelper.WriteWarningLine(log);
+
+                    _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
+                    WriteInfo(conveyorLine.DeviceName, log);
+
                     conveyorLine.SendCommand(taskCommand, childDeviceCode);
-                    // 鏇存柊浠诲姟鐘舵��
-                    _taskService.UpdateTaskStatusToNext(task);
+                    ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
+
+                    var taskHty = task.Adapt<Dt_Task_Hty>();
+                    _task_HtyRepository.AddData(taskHty);
+                    _taskService.DeleteData(task);
                 }
                 else
                 {
-                    ConsoleHelper.WriteWarningLine("宸插瓨鍦ㄩ潤缃嚭搴撲换鍔�,闈欑疆鍏ュ簱浠诲姟鏃犳硶涓嬪彂鑷崇嚎浣�");
+                    var next = task.NextAddress;
+                    var taskCommand = MapTaskCommand(task, command);
+                    task.NextAddress = next;
+
+                    var log = $"銆恵conveyorLine._deviceName}銆戜换鍔″彿锛氥�恵command.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵command.Barcode}銆戝凡鍒拌揪銆恵childDeviceCode}銆戣姹傛壂鐮佸叆搴�(瀹炵洏),涓嬩竴鐩爣鍦板潃銆恵taskCommand.TargetAddress}銆�";
+                    ConsoleHelper.WriteWarningLine(log);
+
+                    _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
+                    WriteInfo(conveyorLine.DeviceName, log);
+
+                    conveyorLine.SendCommand(taskCommand, childDeviceCode);
+                    ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
+                    _taskService.UpdateTaskStatusToNext(task);
                 }
             }
-            else
-            {
-                // 鏄犲皠浠诲姟鍛戒护
-                var taskCommand = MapTaskCommand(task, command);
-                // 璁板綍鏃ュ織骞跺彂閫佸畬鎴愪俊鍙�
-                LogAndSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, logMessage, taskCommand.TargetAddress.ToString());
-                // 鍙戦�佷换鍔″懡浠�
-                conveyorLine.SendCommand(taskCommand, childDeviceCode);
-                // 鏇存柊浠诲姟鐘舵��
-                _taskService.UpdateTaskStatusToNext(task);
-            }
         }
-
-        /// <summary>
-        /// 璁板綍鏃ュ織骞跺彂閫佸畬鎴愪俊鍙�
-        /// </summary>
-        /// <param name="conveyorLine">杈撻�佺嚎瀵硅薄</param>
-        /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
-        /// <param name="ProtocalDetailValue">鍗忚鏄庣粏鍊�</param>
-        /// <param name="logMessage">鏃ュ織娑堟伅妯℃澘</param>
-        /// <param name="targetAddress">鐩爣鍦板潃</param>
-        private void LogAndSendFinish(CommonConveyorLine conveyorLine, string childDeviceCode, int ProtocalDetailValue, string logMessage, string targetAddress)
-        {
-            // 鏍煎紡鍖栨棩蹇楁秷鎭�
-            var log = string.Format(logMessage, targetAddress);
-            // 杈撳嚭璀﹀憡鏃ュ織
-            ConsoleHelper.WriteWarningLine(log);
-            // 璁板綍鏃ュ織
-            _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log, time = DateTime.Now.ToString("G"), color = "red" });
-            WriteInfo(conveyorLine.DeviceName, log);
-            // 鍙戦�佸畬鎴愪俊鍙�
-            ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
-        }
-
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3