From cb385f0b515c738b503c5c75c9d7efcec323716d Mon Sep 17 00:00:00 2001 From: duyongjia <adu_555@163.com> Date: 星期五, 28 二月 2025 09:12:40 +0800 Subject: [PATCH] 数据库脚本提交 --- 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/DoubleStackerCraneJob.cs | 159 ++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 115 insertions(+), 44 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/DoubleStackerCraneJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/DoubleStackerCraneJob.cs" index fdac4dc..a9eb49d 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/DoubleStackerCraneJob.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/DoubleStackerCraneJob.cs" @@ -1,5 +1,6 @@ 锘縰sing HslCommunication; using Microsoft.AspNetCore.Components.Routing; +using Newtonsoft.Json; using Quartz; using System; using System.Collections.Generic; @@ -49,30 +50,23 @@ _locationInfoRepository = locationInfoRepository; } - public Task Execute(IJobExecutionContext context) + public Task Execute(IJobExecutionContext context) { + + CommonStackerCrane? stackerCraneOne = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "SC02") as CommonStackerCrane; + CommonStackerCrane? stackerCraneTwo = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "SC03") as CommonStackerCrane; + try { - CommonStackerCrane? stackerCraneOne = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "SC02") as CommonStackerCrane; - CommonStackerCrane? stackerCraneTwo = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "SC03") as CommonStackerCrane; - - //Dt_DeviceInfo deviceSC02= _deviceInfoRepository.QueryFirst(x => x.DeviceCode == "SC02"); - //Dt_DeviceInfo deviceSC03 = _deviceInfoRepository.QueryFirst(x => x.DeviceCode == "SC03"); - //if(deviceSC02.DeviceStatus=="0") - //{ - // stackerCraneOne = null; - //} - //if(deviceSC03.DeviceStatus=="0") - //{ - // stackerCraneTwo = null; - //} - stackerCraneOne.CheckStackerCraneTaskCompleted(); + Dt_Task? task = GetTask(); + if (task != null) - { - CommonStackerCrane? StackerCrane= GetStrackerCrane(task, stackerCraneOne, stackerCraneTwo); - if(StackerCrane != null) + { + CommonStackerCrane? StackerCrane = GetStrackerCrane(task, stackerCraneOne, stackerCraneTwo); + if (StackerCrane != null) { + WriteDebug(nameof(DoubleStackerCraneJob), $"灏忓爢鍨涙満浠诲姟鍙穥task.TaskNum}--{StackerCrane.DeviceCode}"); StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task); if (stackerCraneTaskCommand != null) { @@ -85,24 +79,71 @@ } else { - _taskService.UpdateTaskExceptionMessage(task.TaskNum, "鍫嗗灈鏈烘墽琛屼换鍔″懡浠ゅけ璐ワ紒"); - WriteDebug(nameof(CommonStackerCraneJob), "鍫嗗灈鏈烘墽琛屼换鍔″懡浠ゅけ璐ワ紒"); + _taskService.UpdateTaskExceptionMessage(task.TaskNum, "鍫嗗灈鏈哄彂閫佷换鍔″懡浠ゅけ璐ワ紒"); + WriteDebug(nameof(DoubleStackerCraneJob), $"鍫嗗灈鏈哄彂閫佷换鍔″懡浠ゅけ璐ワ紒{task.TaskNum}"); } } } else { - WriteDebug(nameof(CommonStackerCraneJob), "鏈煡璇㈠埌褰撳墠鍙互鎵ц涓婃枡浠诲姟鐨勫皬鍫嗗灈鏈猴紒"); + WriteDebug(nameof(DoubleStackerCraneJob), "鏈煡璇㈠埌褰撳墠鍙互鎵ц涓婃枡浠诲姟鐨勫皬鍫嗗灈鏈猴紒"); } - + } } catch (Exception ex) { - WriteError(nameof(CommonStackerCraneJob), "灏忓爢鍨涙満鎵ц浠诲姟寮傚父锛�", ex); + WriteError(nameof(DoubleStackerCraneJob), "灏忓爢鍨涙満鎵ц浠诲姟寮傚父锛�", ex); } + + + + try + { + if (stackerCraneOne != null)//SC02 + { + byte IsOver = stackerCraneOne.Communicator.Read<byte>("DB106.22"); + int tasknum = stackerCraneOne.Communicator.Read<int>("DB106.18"); + WriteDebug(nameof(DoubleStackerCraneJob), $"灏忓爢鍨涙満SC02浠诲姟鍙峰爢鍨涙満浠诲姟鍙凤細{tasknum}鐘舵�侊細{IsOver}"); + if (IsOver == 6) + { + if (stackerCraneOne.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5) + { + _taskService.StackCraneTaskCompleted(tasknum); + Console.Out.WriteLine("TaskCompleted" + tasknum); + bool issuccess = stackerCraneOne.SetValue(StackerCraneDBName.WorkType, 5); + + } + } + } + + if (stackerCraneTwo != null)//SC03 + { + //璇诲彇鍫嗗灈鏈轰换鍔″彿鍜屼换鍔″畬鎴愮‘璁ょ姸鎬� + byte IsOver = stackerCraneTwo.Communicator.Read<byte>("DB106.22"); + int tasknum = stackerCraneTwo.Communicator.Read<int>("DB106.18"); + WriteDebug(nameof(DoubleStackerCraneJob), $"灏忓爢鍨涙満SC03浠诲姟鍙峰爢鍨涙満浠诲姟鍙凤細{tasknum}鐘舵�侊細{IsOver}"); + if (IsOver == 6) + { + if (stackerCraneTwo.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5) + { + _taskService.StackCraneTaskCompleted(tasknum); + Console.Out.WriteLine("TaskCompleted" + tasknum); + bool issuccess = stackerCraneTwo.SetValue(StackerCraneDBName.WorkType, 5); + + } + } + } + } + catch (Exception ex) + { + WriteError(nameof(DoubleStackerCraneJob), "鎵ц寮傚父锛�", ex); + } + + + return Task.CompletedTask; } @@ -147,13 +188,9 @@ { if (stackerCraneOne != null) { - if (!stackerCraneOne.IsEventSubscribed) - { - stackerCraneOne.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢 - } + if (stackerCraneOne.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && stackerCraneOne.StackerCraneStatusValue == StackerCraneStatus.Normal) { - stackerCraneOne.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆� if (stackerCraneOne.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby) { return stackerCraneOne; @@ -166,15 +203,17 @@ if (deviceSC02.DeviceStatus=="0"&& stackerCraneTwo != null) { - if (!stackerCraneTwo.IsEventSubscribed) - { - stackerCraneTwo.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢 - } + //if (!stackerCraneTwo.IsEventSubscribed) + //{ + // stackerCraneTwo.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢 + //} if (stackerCraneTwo.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && stackerCraneTwo.StackerCraneStatusValue == StackerCraneStatus.Normal) { - stackerCraneTwo.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆� + //stackerCraneTwo.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆� if (stackerCraneTwo.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby) { + //todo:浠诲姟琛ㄤ腑鐨凴oadWay鍒囨崲涓篠C03 + return stackerCraneTwo; } } @@ -184,18 +223,34 @@ } } + else + { + if(stackerCraneTwo != null) + { + if (stackerCraneTwo.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && stackerCraneTwo.StackerCraneStatusValue == StackerCraneStatus.Normal) + { + if (stackerCraneTwo.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby) + { + //todo:浠诲姟琛ㄤ腑鐨凴oadWay鍒囨崲涓篠C03 + + return stackerCraneTwo; + } + } + } + + } } else if (task.Roadway=="SC03") { if (stackerCraneTwo != null) - { - if (!stackerCraneTwo.IsEventSubscribed) - { - stackerCraneTwo.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢 - } + { + // if (!stackerCraneTwo.IsEventSubscribed) + // { + // stackerCraneTwo.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢 + // } if (stackerCraneTwo.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && stackerCraneOne.StackerCraneStatusValue == StackerCraneStatus.Normal) { - stackerCraneTwo.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆� + //stackerCraneTwo.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆� if (stackerCraneTwo.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby) { return stackerCraneTwo; @@ -206,15 +261,16 @@ Dt_DeviceInfo deviceSC03 = _deviceInfoRepository.QueryFirst(x => x.DeviceCode == "SC03"); if (deviceSC03.DeviceStatus=="0"&&stackerCraneOne != null) { - if (!stackerCraneOne.IsEventSubscribed) - { - stackerCraneOne.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢 - } + //if (!stackerCraneOne.IsEventSubscribed) + //{ + // stackerCraneOne.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢 + //} if (stackerCraneOne.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && stackerCraneTwo.StackerCraneStatusValue == StackerCraneStatus.Normal) { - stackerCraneOne.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆� + //stackerCraneOne.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆� if (stackerCraneOne.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby) { + //todo锛氫换鍔¤〃涓殑RoadWay鍒囨崲涓篠C03 return stackerCraneOne; } } @@ -222,6 +278,21 @@ } } + else + { + if(stackerCraneOne != null) + { + if (stackerCraneOne.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && stackerCraneOne.StackerCraneStatusValue == StackerCraneStatus.Normal) + { + if (stackerCraneOne.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby) + { + return stackerCraneOne; + } + + } + + } + } } return null; -- Gitblit v1.9.3