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 |  169 ++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 122 insertions(+), 47 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 318452b..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,29 +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;
-                }
+               
                 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)
                         {
@@ -84,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;
         }
 
@@ -146,32 +188,32 @@
             {
                 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;
                         }
 
                     }
-                    else//涓嶈兘姝e父宸ヤ綔鐘舵��
+                    else//SC02涓嶈兘姝e父宸ヤ綔鐘舵��,杩欓噷闇�瑕佸垽鏂璼c02鏄惁绂佺敤锛屽鏋滃凡绂佺敤锛屾墠鍙互鍚姩sc03
                     {
-                        if (stackerCraneTwo != null)
+                        Dt_DeviceInfo deviceSC02 = _deviceInfoRepository.QueryFirst(x => x.DeviceCode == "SC02");
+
+                        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;
                                 }
                             }
@@ -181,36 +223,54 @@
 
                     }
                 }
+                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;
                         }
                     }
-                    else
+                    else//SC03涓嶈兘姝e父宸ヤ綔鐘舵��,杩欓噷闇�瑕佸垽鏂璼c03鏄惁绂佺敤锛屽鏋滃凡绂佺敤锛屾墠鍙互鍚姩sc02
                     {
-                        if (stackerCraneOne != null)
+                        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;
                                 }
                             }
@@ -218,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