From 681d093f9ea16ab2d480d77e6b04b197e506ff60 Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期四, 19 六月 2025 01:29:12 +0800 Subject: [PATCH] 1 --- 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs | 139 +++++++++++++++++++-------------------------- 1 files changed, 59 insertions(+), 80 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs" index 1178b32..b727fc4 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs" @@ -1,14 +1,7 @@ -锘縰sing Microsoft.AspNetCore.Components.Routing; -using Quartz; +锘縰sing Quartz; using SqlSugar.Extensions; -using System; -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Net; -using System.Text; -using System.Threading.Tasks; -using WIDESEAWCS_Core.Enums; +using WIDESEA_Core.Enums; using WIDESEAWCS_ITaskInfoRepository; using WIDESEAWCS_ITaskInfoService; using WIDESEAWCS_Model.Models; @@ -16,6 +9,7 @@ using WIDESEAWCS_QuartzJob.DeviceBase; using WIDESEAWCS_QuartzJob.Models; using WIDESEAWCS_QuartzJob.Service; +using WIDESEAWCS_QuartzJob.StackerCrane; using WIDESEAWCS_Tasks.StackerCraneJob; namespace WIDESEAWCS_Tasks @@ -28,11 +22,11 @@ private readonly ITaskRepository _taskRepository; private readonly IRouterService _routerService; - public CommonStackerCraneJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService) + public CommonStackerCraneJob(ITaskService taskService, ITaskRepository taskRepository, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService) { _taskService = taskService; - _taskExecuteDetailService = taskExecuteDetailService; _taskRepository = taskRepository; + _taskExecuteDetailService = taskExecuteDetailService; _routerService = routerService; } @@ -41,49 +35,38 @@ try { SpeStackerCrane speStackerCrane = (SpeStackerCrane)context.JobDetail.JobDataMap.Get("JobParams"); - GetStackerObject getStackerObject = new GetStackerObject(); if (speStackerCrane != null) { - if (getStackerObject.StackerCraneTaskCompletedValue(speStackerCrane) == StackerCraneTaskCompleted.WorkCompleted) + GetStackerObject getStackerObject = new GetStackerObject(speStackerCrane); + if (!getStackerObject.IsEventSubscribed) { - _taskService.StackCraneTaskCompleted(speStackerCrane.CurrentTaskNum); - speStackerCrane.SetValue(StackerCraneDBName.WorkType, 2); + getStackerObject.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢 } - else + + getStackerObject.CheckStackerCraneTaskCompleted();//妫�娴嬪爢鍨涙満浠诲姟瀹屾垚浜嬩欢 + + if (getStackerObject.StackerCraneStatusValue == StackerCraneStatus.Ready) { - if (getStackerObject.StackerCraneAutoStatusValue(speStackerCrane) == StackerCraneAutoStatus.Automatic && getStackerObject.StackerCraneStatusValue(speStackerCrane) == StackerCraneStatus.Ready) + Dt_Task? task = GetTask(speStackerCrane); + if (task != null) { - if (getStackerObject.StackerCraneWorkStatusValue(speStackerCrane) == StackerCraneWorkStatus.Standby) + bool sendFlag = true; + //if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt() || task.TaskType == TaskTypeEnum.PalletOutbound.ObjToInt()) + //{ + // //鍚慦MS鐢宠鍑哄叆搴撳彛鏄惁鏈夌┖鎵樼洏 + // sendFlag = false; + //} + if (sendFlag) { - Dt_Task? task = GetTask(speStackerCrane); - if (task != null) + StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task); + if (stackerCraneTaskCommand != null) { - if (task.TaskType == TaskTypeGroup.OutbondGroup.ObjToInt()) + sendFlag = getStackerObject.SendCommand(stackerCraneTaskCommand); + if (sendFlag) { - //todo鍑哄簱鍒ゆ柇璐ф灦鐘舵�� - StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task); - if (stackerCraneTaskCommand != null) - { - bool sendFlag = speStackerCrane.SendCommand(stackerCraneTaskCommand); - if (sendFlag) - { - speStackerCrane.LastTaskType = task.TaskType; - _taskService.UpdateTaskStatusToNext(task.TaskNum); - } - } - } - else - { - StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task); - if (stackerCraneTaskCommand != null) - { - bool sendFlag = speStackerCrane.SendCommand(stackerCraneTaskCommand); - if (sendFlag) - { - speStackerCrane.LastTaskType = task.TaskType; - _taskService.UpdateTaskStatusToNext(task.TaskNum); - } - } + speStackerCrane.SetValue(StackerCraneDBName.CommandSend, 1);//鍚姩鍛戒护 + speStackerCrane.LastTaskType = task.TaskType; + _taskService.UpdateTaskStatusToNext(task.TaskNum); } } } @@ -93,7 +76,7 @@ } catch (Exception ex) { - Console.WriteLine(nameof(CommonStackerCraneJob) + ":" + ex.ToString()); + //WriteLog.GetLog($"鍫嗗灈鏈哄紓甯�").Write($"{nameof(CommonStackerCraneJob)}:{ex.Message}", "鍫嗗灈鏈哄紓甯�"); } return Task.CompletedTask; } @@ -103,16 +86,15 @@ /// </summary> /// <param name="sender"></param> /// <param name="e"></param> - private void CommonStackerCrane_StackerCraneTaskCompletedEventHandler(object? sender, WIDESEAWCS_QuartzJob.StackerCrane.StackerCraneTaskCompletedEventArgs e) + private void CommonStackerCrane_StackerCraneTaskCompletedEventHandler(object? sender, StackerCraneTaskCompletedEventArgs e) { SpeStackerCrane? speStackerCrane = sender as SpeStackerCrane; if (speStackerCrane != null) { - if (speStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5) + if (speStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.CommandSend) != 2) { - Console.Out.WriteLine("TaskCompleted" + e.TaskNum); - _taskService.StackCraneTaskCompleted(e.TaskNum); - speStackerCrane.SetValue(StackerCraneDBName.WorkType, 5); + speStackerCrane.SetValue(StackerCraneDBName.CommandSend, 2); + _taskService.StackCraneTaskCompleted(e.TaskNum, "鍫嗗灈鏈�"); } } } @@ -124,15 +106,21 @@ /// <returns></returns> private Dt_Task? GetTask(SpeStackerCrane speStackerCrane) { - Dt_Task task; + Dt_Task? task; + string DeviceCode = speStackerCrane.DeviceCode.Contains("CP") ? "CP" : "FL"; if (speStackerCrane.LastTaskType == null) { - task = _taskService.QueryStackerCraneTask(speStackerCrane.DeviceCode); + task = _taskService.QueryStackerCraneTask(DeviceCode); } else { - bool flag = speStackerCrane.LastTaskType.GetValueOrDefault().GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup; - if (flag) + if (speStackerCrane.LastTaskType == TaskTypeEnum.Relocation.ObjToInt()) + { + task = _taskService.QueryStackerCraneTask(DeviceCode); + if (task != null) return task; + } + bool flag = speStackerCrane.LastTaskType == TaskTypeEnum.Inbound.ObjToInt() || speStackerCrane.LastTaskType == TaskTypeEnum.PalletInbound.ObjToInt(); + if (flag == false) { task = _taskService.QueryStackerCraneInTask(speStackerCrane.DeviceCode); if (task == null) @@ -143,21 +131,12 @@ else { task = _taskService.QueryStackerCraneOutTask(speStackerCrane.DeviceCode); + if (task == null) + { + task = _taskService.QueryStackerCraneInTask(speStackerCrane.DeviceCode); + } } } - - if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) - { - - List<Dt_Task> tasks = _taskService.QueryStackerCraneOutTasks(speStackerCrane.DeviceCode, task.TargetAddress); - foreach (var item in tasks) - { - return task; - } - return task; - - } - return task; } @@ -191,7 +170,6 @@ } return null; } - /// <summary> /// 浠诲姟瀹炰綋杞崲鎴愬懡浠odel /// </summary> @@ -204,14 +182,14 @@ stackerCraneTaskCommand.Barcode = task.PalletCode; stackerCraneTaskCommand.TaskNum = task.TaskNum; - stackerCraneTaskCommand.WorkType = 1; stackerCraneTaskCommand.TrayType = 0; - if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//鍒ゆ柇鏄惁鏄叆搴撲换鍔� + if (task.TaskType == TaskTypeEnum.Inbound.ObjToInt() || task.TaskType == TaskTypeEnum.PalletInbound.ObjToInt())//鍒ゆ柇鏄惁鏄叆搴撲换鍔� { + stackerCraneTaskCommand.WorkType = 1; if (task.SourceAddress != null && task.TargetAddress != null) { string[] sourceCodes = task.SourceAddress.Split("-"); - if (sourceCodes.Length == 3) + if (sourceCodes.Length == 5) { stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[1]); stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[2]); @@ -224,7 +202,7 @@ return null; } string[] targetCodes = task.TargetAddress.Split("-"); - if (targetCodes.Length == 3) + if (targetCodes.Length == 5) { stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[1]); stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[2]); @@ -243,12 +221,13 @@ return null; } } - else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) + else if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt() || task.TaskType == TaskTypeEnum.PalletOutbound.ObjToInt()) { + stackerCraneTaskCommand.WorkType = 2; if (task.SourceAddress != null && task.TargetAddress != null) { string[] targetCodes = task.TargetAddress.Split("-"); - if (targetCodes.Length == 3) + if (targetCodes.Length == 5) { stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[1]); stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[2]); @@ -261,7 +240,7 @@ return null; } string[] sourceCodes = task.SourceAddress.Split("-"); - if (sourceCodes.Length == 3) + if (sourceCodes.Length == 5) { stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[1]); stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[2]); @@ -280,12 +259,13 @@ return null; } } - else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup) + else if (task.TaskType == TaskTypeEnum.Relocation.ObjToInt()) { + stackerCraneTaskCommand.WorkType = 3; if (task.SourceAddress != null && task.TargetAddress != null) { string[] targetCodes = task.TargetAddress.Split("-"); - if (targetCodes.Length == 3) + if (targetCodes.Length == 5) { stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[1]); stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[2]); @@ -298,7 +278,7 @@ return null; } string[] sourceCodes = task.SourceAddress.Split("-"); - if (sourceCodes.Length == 3) + if (sourceCodes.Length == 5) { stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[1]); stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[2]); @@ -318,6 +298,5 @@ } return stackerCraneTaskCommand; } - } } -- Gitblit v1.9.3