| | |
| | | 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; |
| | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | | [DisallowConcurrentExecution] |
| | | public class CommonStackerCraneJob : IJob |
| | | public class CommonStackerCraneJob :JobBase, IJob |
| | | { |
| | | private readonly ITaskService _taskService; |
| | | private readonly ITaskExecuteDetailService _taskExecuteDetailService; |
| | |
| | | _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) |
| | | { |
| | |
| | | { |
| | | 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; |
| | | } |
| | |
| | | bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand); |
| | | if (sendFlag) |
| | | { |
| | | if (task.TaskType == (int)TaskInboundTypeEnum.Inbound) |
| | | if (task.TaskType == (int)TaskInboundTypeEnum.Inbound|| task.TaskType == (int)TaskInboundTypeEnum.InInventory||task.TaskType==(int)TaskInboundTypeEnum.InPick) |
| | | { |
| | | _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, "", "æ´æ°ä»»å¡ç¶æ"); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | 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; |
| | | } |
| | | |
| | |
| | | private Dt_Task? GetTask(CommonStackerCrane commonStackerCrane) |
| | | { |
| | | Dt_Task task; |
| | | task = _taskService.QueryStackerCraneTask(commonStackerCrane.DeviceCode); |
| | | task = _taskService.QueryStackerCraneTask("R01"); |
| | | return task; |
| | | } |
| | | |
| | |
| | | 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) |
| | | { |