From ce8f204db035e6fb7147edb4440591502f5c8567 Mon Sep 17 00:00:00 2001 From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com> Date: 星期四, 10 七月 2025 15:01:32 +0800 Subject: [PATCH] 1 --- Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs | 139 ++++++++++++++++++++++++++++++++++++---------- 1 files changed, 109 insertions(+), 30 deletions(-) diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs index edd2f0e..b710291 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs +++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs @@ -25,6 +25,7 @@ using Newtonsoft.Json; using Quartz; using SqlSugar; +using System.ComponentModel.Design; using System.Reflection; using WIDESEAWCS_BasicInfoRepository; using WIDESEAWCS_Common; @@ -132,7 +133,7 @@ } } - if (childDeviceCode == "1670"||childDeviceCode=="1666"||childDeviceCode=="1548"||childDeviceCode=="1448") + if (childDeviceCode == "1670" || childDeviceCode == "1666" || childDeviceCode == "1548" || childDeviceCode == "1448") { Platform platform = _platFormRepository.QueryFirst(x => x.DeviceCode == conveyorLine.DeviceCode && x.PlatCode == childDeviceCode && x.Status == "Active"); if (platform != null) @@ -198,8 +199,6 @@ try { var task = _taskService.QueryBarCodeConveyorLineTask(command.ConveyorLineBarcode, childDeviceCode); - //HandleTaskOut(conveyorLine, command, childDeviceCode, task); - // && command.ConveyorLineBarcode != "NoRead" && !command.ConveyorLineBarcode.IsNotEmptyOrNull() var log = $"銆恵conveyorLine.DeviceName}銆戞墭鐩樺彿锛氥�恵command.ConveyorLineBarcode}銆戜换鍔″彿锛氥�恵command.ConveyorLineTaskNum}銆戣澶囩紪鐮侊細銆恵childDeviceCode}銆�"; ConsoleHelper.WriteSuccessLine(log); @@ -213,15 +212,20 @@ else { var GWTask = _taskRepository.QueryData(x => x.Roadway.Contains("GWSC2") && x.SourceAddress == "1039" && (x.TaskState == (int)TaskInStatusEnum.Line_InExecuting || x.TaskState == (int)TaskInStatusEnum.Line_InFinish)).ToList(); - if (GWTask.Count >= 2 && childDeviceCode == "1039"&& task.Roadway.Contains("GWSC2")) + if (GWTask.Count >= 2 && childDeviceCode == "1039" && task.Roadway.Contains("GWSC2")) { ConsoleHelper.WriteErrorLine($"鎵樼洏鍙凤細銆恵command.ConveyorLineBarcode}銆戦珮娓╀簩宸插瓨鍦ㄣ�恵GWTask.Count}銆戜釜浠诲姟澶т簬2涓换鍔′笉鍙笅鍙�"); return; } ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task); - conveyorLine.SendCommand(taskCommand, childDeviceCode); - conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), childDeviceCode); - _taskService.UpdateTaskStatusToNext(task); + //conveyorLine.SendCommand(taskCommand, childDeviceCode); + + bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode); + if (sendFlag) + { + conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), childDeviceCode); + _taskService.UpdateTaskStatusToNext(task); + } } } catch (Exception ex) @@ -238,7 +242,6 @@ /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param> public void RequestInNextAddress(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode) { - //Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode); Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode, command.ConveyorLineBarcode); if (task != null) { @@ -252,11 +255,25 @@ if (newTask != null) { ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(newTask); - conveyorLine.SendCommand(taskCommand, childDeviceCode); - conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), childDeviceCode); - _taskService.UpdateData(newTask); + //conveyorLine.SendCommand(taskCommand, childDeviceCode); + + bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode); + if (sendFlag) + { + conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), childDeviceCode); + _taskService.UpdateData(newTask); + } } } + //else + //{ + // //褰撳墠鍦板潃璇锋眰 瀵绘壘褰撳墠鍦板潃鐨勬墭鐩樺彿 浠诲姟鍙风殑浠诲姟锛屽瀛樺湪浠诲姟鍒欓噸鏂板啀娆″啓鍏ユ柊鐩爣鍦板潃 + // Dt_Task currentTask = _taskService.QueryExecutingCurrentConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode, command.ConveyorLineBarcode); + // if (currentTask != null) + // { + // conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, Convert.ToInt16(currentTask.TargetAddress), childDeviceCode); + // } + //} } /// <summary> @@ -275,7 +292,7 @@ if (content.Status) { - conveyorLine.SetValue(ConveyorLineDBName_After.ResponState,Convert.ToInt16(1), childDeviceCode); + conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), childDeviceCode); } Console.Out.WriteLine(content.Serialize()); @@ -295,13 +312,18 @@ if (task != null) { ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task); - conveyorLine.SendCommand(taskCommand, childDeviceCode); - conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), childDeviceCode); + //conveyorLine.SendCommand(taskCommand, childDeviceCode); - _taskService.UpdateTaskStatusToNext(task); - if (task.TaskType == (int)TaskOutboundTypeEnum.OutTray) + bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode); + if (sendFlag) { + conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), childDeviceCode); + _taskService.UpdateTaskStatusToNext(task); + if (task.TaskType == (int)TaskOutboundTypeEnum.OutTray) + { + _taskService.UpdateTaskStatusToNext(task); + } } } } @@ -314,7 +336,6 @@ /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param> public void RequestOutNextAddress(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode) { - //Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode); Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode, command.ConveyorLineBarcode); if (task != null) { @@ -350,18 +371,28 @@ if (newTask != null) { ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(newTask); - conveyorLine.SendCommand(taskCommand, childDeviceCode); - conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), childDeviceCode); - _taskService.UpdateData(newTask); + //conveyorLine.SendCommand(taskCommand, childDeviceCode); + + bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode); + if (sendFlag) + { + conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), childDeviceCode); + _taskService.UpdateData(newTask); + } } } else { ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task); taskCommand.ConveyorLineTargetAddress = Convert.ToInt16(stationManager.stationNGChildCode); - conveyorLine.SendCommand(taskCommand, childDeviceCode); - conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), childDeviceCode); - _taskService.UpdateTaskStatusToNext(task); + //conveyorLine.SendCommand(taskCommand, childDeviceCode); + + bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode); + if (sendFlag) + { + conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), childDeviceCode); + _taskService.UpdateTaskStatusToNext(task); + } } } } @@ -408,9 +439,13 @@ } } - conveyorLine.SendCommand(taskCommand, childDeviceCode); - conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), childDeviceCode); - content = _taskService.UpdateTaskStatusToNext(task); + //conveyorLine.SendCommand(taskCommand, childDeviceCode); + bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode); + if (sendFlag) + { + conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), childDeviceCode); + content = _taskService.UpdateTaskStatusToNext(task); + } } else { @@ -441,9 +476,16 @@ } } - conveyorLine.SendCommand(taskCommand, childDeviceCode); - conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), childDeviceCode); - content = _taskService.UpdateTaskStatusToNext(taskNext); + //conveyorLine.SendCommand(taskCommand, childDeviceCode); + + bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode); + if (sendFlag) + { + conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), childDeviceCode); + + taskNext.ExceptionMessage = log; + content = _taskService.UpdateTaskStatusToNext(taskNext); + } } } } @@ -526,7 +568,44 @@ } return content; } + + public bool SendCommand(ConveyorLineTaskCommand_After taskCommand, CommonConveyorLine_GW conveyorLine, string childDeviceCode) + { + conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, Convert.ToInt16(taskCommand.ConveyorLineTargetAddress), childDeviceCode); + Thread.Sleep(100); + conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, taskCommand.ConveyorLineBarcode, childDeviceCode); + Thread.Sleep(100); + conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, taskCommand.ConveyorLineTaskNum, childDeviceCode); + for (int i = 0; i < 6; i++) + { + ConveyorLineTaskCommand_After command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(childDeviceCode); + if (command != null) + { + if (command.ConveyorLineBarcode == taskCommand.ConveyorLineBarcode && command.ConveyorLineTaskNum == taskCommand.ConveyorLineTaskNum && command.ConveyorLineTargetAddress == taskCommand.ConveyorLineTargetAddress) + { + WriteInfo(conveyorLine.DeviceName, $"鍐欏叆浠诲姟鎴愬姛鍐欏叆娆℃暟{i}鍐欏叆浠诲姟銆恵JsonConvert.SerializeObject(taskCommand)}銆�"); + return true; + } + if (command.ConveyorLineTargetAddress != taskCommand.ConveyorLineTargetAddress) + { + conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, Convert.ToInt16(taskCommand.ConveyorLineTargetAddress), childDeviceCode); + Thread.Sleep(100); + } + if (command.ConveyorLineBarcode != taskCommand.ConveyorLineBarcode) + { + conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, taskCommand.ConveyorLineBarcode, childDeviceCode); + Thread.Sleep(100); + } + if (command.ConveyorLineTaskNum != taskCommand.ConveyorLineTaskNum) + { + conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, taskCommand.ConveyorLineTaskNum, childDeviceCode); Thread.Sleep(100); + } + + } + } + WriteInfo(conveyorLine.DeviceName, $"鍐欏叆浠诲姟澶辫触浠诲姟鍙枫�恵taskCommand.ConveyorLineTaskNum}銆戞墭鐩樺彿銆恵taskCommand.ConveyorLineBarcode}銆戠洰鏍囧湴鍧�銆恵taskCommand.ConveyorLineTargetAddress}銆戝綋鍓嶈妭鐐广�恵childDeviceCode}銆�"); + return false; + } } } - #endregion \ No newline at end of file -- Gitblit v1.9.3