From d0f01f571918ae942349068776fa7fb70f3ab5cd Mon Sep 17 00:00:00 2001 From: hutongqing <hutongqing@hnkhzn.com> Date: 星期三, 28 八月 2024 16:20:18 +0800 Subject: [PATCH] 更新设备信息表从表导入问题 --- WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs | 37 ++++++++++++++++++------------------- 1 files changed, 18 insertions(+), 19 deletions(-) diff --git a/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs b/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs index 77f830e..e126961 100644 --- a/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs +++ b/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs @@ -2,6 +2,7 @@ using Quartz; using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -55,7 +56,7 @@ if (task != null) { StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task); - if(stackerCraneTaskCommand != null) + if (stackerCraneTaskCommand != null) { bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand); if (sendFlag) @@ -83,12 +84,15 @@ /// <param name="e"></param> private void CommonStackerCrane_StackerCraneTaskCompletedEventHandler(object? sender, WIDESEAWCS_QuartzJob.StackerCrane.StackerCraneTaskCompletedEventArgs e) { - CommonStackerCrane commonStackerCrane = sender as CommonStackerCrane; - if (commonStackerCrane.GetValue<StackerCraneDBName,short>(StackerCraneDBName.WorkType) != 5) + CommonStackerCrane? commonStackerCrane = sender as CommonStackerCrane; + if (commonStackerCrane != null) { - Console.Out.WriteLine("TaskCompleted" + e.TaskNum); - _taskService.StackCraneTaskCompleted(e.TaskNum); - commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5); + if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5) + { + Console.Out.WriteLine("TaskCompleted" + e.TaskNum); + _taskService.StackCraneTaskCompleted(e.TaskNum); + commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5); + } } } @@ -106,10 +110,10 @@ } else { - if (!int.TryParse(Enum.Parse<TaskOutboundTypeEnum>(commonStackerCrane.LastTaskType.ToString()).ToString(), out int taskType)) + if (commonStackerCrane.LastTaskType.GetValueOrDefault().GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) { task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode); - if(task == null) + if (task == null) { task = _taskService.QueryStackerCraneOutTask(commonStackerCrane.DeviceCode); } @@ -120,7 +124,7 @@ } } - if (task != null && !int.TryParse(Enum.Parse<TaskOutboundTypeEnum>(task.TaskType.ToString()).ToString(), out int result)) + if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) { if (OutTaskStationIsOccupied(task) != null) { @@ -149,7 +153,7 @@ /// </summary> /// <param name="task">浠诲姟瀹炰綋</param> /// <returns>濡傛灉鏈鍗犵敤锛岃繑鍥炰紶鍏ョ殑浠诲姟淇℃伅锛屽惁鍒欙紝杩斿洖null</returns> - private Dt_Task? OutTaskStationIsOccupied(Dt_Task task) + private Dt_Task? OutTaskStationIsOccupied([NotNull] Dt_Task task) { Dt_Router? router = _routerService.QueryNextRoutes(task.Roadway, task.NextAddress).FirstOrDefault(); if (router != null) @@ -181,7 +185,7 @@ /// <param name="task">浠诲姟瀹炰綋</param> /// <returns></returns> /// <exception cref="Exception"></exception> - public StackerCraneTaskCommand? ConvertToStackerCraneTaskCommand(Dt_Task task) + public StackerCraneTaskCommand? ConvertToStackerCraneTaskCommand([NotNull] Dt_Task task) { StackerCraneTaskCommand stackerCraneTaskCommand = new StackerCraneTaskCommand(); @@ -189,7 +193,7 @@ stackerCraneTaskCommand.TaskNum = task.TaskNum; stackerCraneTaskCommand.WorkType = 1; stackerCraneTaskCommand.TrayType = 0; - if (!int.TryParse(Enum.Parse<TaskInboundTypeEnum>(task.TaskType.ToString()).ToString(), out int result))//鍒ゆ柇鏄惁鏄叆搴撲换鍔� + if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//鍒ゆ柇鏄惁鏄叆搴撲换鍔� { List<Dt_Router> routers = _routerService.QueryNextRoutes(task.CurrentAddress, task.Roadway); if (routers.Count > 0) @@ -218,7 +222,7 @@ return null; } } - else if (!int.TryParse(Enum.Parse<TaskOutboundTypeEnum>(task.TaskType.ToString()).ToString(), out result)) + else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) { List<Dt_Router> routers = _routerService.QueryNextRoutes(task.Roadway, task.TargetAddress); if (routers.Count > 0) @@ -247,7 +251,7 @@ return null; } } - else if (!int.TryParse(Enum.Parse<TaskRelocationTypeEnum>(task.TaskType.ToString()).ToString(), out result)) + else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup) { string[] targetCodes = task.NextAddress.Split("-"); if (targetCodes.Length == 3) @@ -276,11 +280,6 @@ return null; } } - else if (!int.TryParse(Enum.Parse<TaskOtherTypeEnum>(task.TaskType.ToString()).ToString(), out result)) - { - - } - return stackerCraneTaskCommand; } } -- Gitblit v1.9.3