From b879053cc8414be35ea60e4c1667039053e3f6e5 Mon Sep 17 00:00:00 2001 From: duyongjia <adu_555@163.com> Date: 星期五, 27 十二月 2024 20:51:26 +0800 Subject: [PATCH] 增加余料回库功能 --- 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs | 67 ++++++++++++++++++++++++++------- 1 files changed, 52 insertions(+), 15 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs" index edfd8e8..224c882 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs" @@ -4,10 +4,14 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; +using System.Security.Policy; using System.Text; using System.Threading.Tasks; +using WIDESEAWCS_Common.Http; using WIDESEAWCS_Common.TaskEnum; +using WIDESEAWCS_Core; using WIDESEAWCS_Core.Enums; +using WIDESEAWCS_Core.Helper; using WIDESEAWCS_ITaskInfoRepository; using WIDESEAWCS_ITaskInfoService; using WIDESEAWCS_Model.Models; @@ -21,7 +25,7 @@ namespace WIDESEAWCS_Tasks { [DisallowConcurrentExecution] - public class CommonStackerCraneJob : IJob + public class CommonStackerCraneJob :JobBase, IJob { private readonly ITaskService _taskService; private readonly ITaskExecuteDetailService _taskExecuteDetailService; @@ -35,23 +39,23 @@ _taskRepository = taskRepository; _routerService = routerService; } - + public string url = AppSettings.Configuration["WMS"]; public Task Execute(IJobExecutionContext context) { + CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams"); try - { - - CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams"); + { + //CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams"); if (commonStackerCrane != null) { - if (!commonStackerCrane.IsEventSubscribed) - { - commonStackerCrane.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢 - } + //if (!commonStackerCrane.IsEventSubscribed) + //{ + // commonStackerCrane.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢 + //} if (commonStackerCrane.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && commonStackerCrane.StackerCraneStatusValue == StackerCraneStatus.Normal) { - commonStackerCrane.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆� + //commonStackerCrane.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆� if (commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby) { @@ -60,7 +64,7 @@ { StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task); int isIn = commonStackerCrane.Communicator.Read<byte>("DB106.12.0"); - if(task.TaskType == (int)TaskOutboundTypeEnum.Outbound&&isIn==1)//濡傛灉鍦ㄥ叆搴撲腑锛屼笉鍏佽涓嬪彂鍑哄簱浠诲姟 + if((task.TaskType == (int)TaskOutboundTypeEnum.Outbound|| task.TaskType == (int)TaskOutboundTypeEnum.OutInventory) &&isIn==1)//濡傛灉鍦ㄥ叆搴撲腑锛屼笉鍏佽涓嬪彂鍑哄簱浠诲姟 { return Task.CompletedTask; } @@ -69,15 +73,17 @@ bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand); if (sendFlag) { - if (task.TaskType == (int)TaskInboundTypeEnum.Inbound) + if (task.TaskType == (int)TaskInboundTypeEnum.Inbound|| task.TaskType == (int)TaskInboundTypeEnum.InInventory) { _taskService.UpdateTaskStatus(task.TaskId, (int)TaskInStatusEnum.SC_InExecuting); _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"鍫嗗灈鏈哄叆搴撴墽琛屼腑"); + var response = HttpHelpers.Post<WebResponseContent>(url.Replace("PDA", "Task") + "UpdateTaskStatus?taskNum=" + task.TaskNum, "", "鏇存柊浠诲姟鐘舵��"); } - else if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound) + else if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound|| task.TaskType == (int)TaskOutboundTypeEnum.OutInventory) { _taskService.UpdateTaskStatus(task.TaskId, (int)TaskOutStatusEnum.SC_OutExecuting); _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"鍫嗗灈鏈哄嚭搴撴墽琛屼腑"); + var response = HttpHelpers.Post<WebResponseContent>(url.Replace("PDA", "Task") + "UpdateTaskStatus?taskNum=" + task.TaskNum, "", "鏇存柊浠诲姟鐘舵��"); } } } @@ -90,6 +96,29 @@ { Console.WriteLine(nameof(CommonStackerCraneJob) + ":" + ex.ToString()); } + + if (commonStackerCrane != null) + { + //璇诲彇澶у爢鍨涙満浠诲姟鍙峰拰浠诲姟瀹屾垚纭鐘舵�侊紙鍥犱负灏佽鐨勪簨浠剁粡甯镐笉瑙﹀彂锛屾墍浠ュ姞涓洿鎺ヨ鐨勯�昏緫锛屼互鍏嶅嚭鐜板爢鍨涙満涓�鐩存帴澶勪簬绛夊緟wcs纭锛� + byte IsOver = commonStackerCrane.Communicator.Read<byte>("DB106.22"); + int tasknum = commonStackerCrane.Communicator.Read<int>("DB106.18"); + //WriteDebug(nameof(CommonStackerCraneJob), $"澶у爢鍨涙満SC01浠诲姟鍙峰爢鍨涙満浠诲姟鍙凤細{tasknum}鐘舵�侊細{IsOver}"); + if (IsOver == 6) + { + if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5) + { + _taskService.StackCraneTaskCompleted(tasknum); + Console.Out.WriteLine("TaskCompleted" + tasknum); + bool issuccess = commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5); + if (issuccess) + { + WriteDebug(nameof(CommonStackerCraneJob), $"鍫嗗灈鏈轰换鍔″彿锛歿tasknum},鍫嗗灈鏈哄洖鍐�5鎴愬姛"); + + } + } + } + } + return Task.CompletedTask; } @@ -120,7 +149,7 @@ private Dt_Task? GetTask(CommonStackerCrane commonStackerCrane) { Dt_Task task; - task = _taskService.QueryStackerCraneTask(commonStackerCrane.DeviceCode); + task = _taskService.QueryStackerCraneTask("R01"); return task; } @@ -168,7 +197,15 @@ stackerCraneTaskCommand.Barcode = task.PalletCode; stackerCraneTaskCommand.TaskNum = task.TaskNum; stackerCraneTaskCommand.WorkType = 1; - stackerCraneTaskCommand.TrayType = 1; + if(task.PalletCode.Substring(0,1)=="B") + { + stackerCraneTaskCommand.TrayType = 2; + } + else + { + stackerCraneTaskCommand.TrayType = 1; + } + //stackerCraneTaskCommand.TrayType = 1; string[] SourceCodes = task.SourceAddress.Split("-"); if (SourceCodes.Length == 4) { -- Gitblit v1.9.3