using JSMachine.WMS.App.Dto.Enum; using JSMachine.WMS.App.Dto; using JSMachine.WMS.Common.Cache; using JSMachine.WMS.Job.Enum; using JSMachine.WMS.Job.JobAttributes; using JSMachine.WMS.RPC.RcsRPC.Dto; using JSMachine.WMS.RPC.RcsRPC.Dto.In; using Quartz; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using JSMachine.WMS.Infrastructure.Helper; using JSMachine.WMS.App.IService; using JSMachine.WMS.Infrastructure; using JSMachine.WMS.Business.RcsCallBack.IService; namespace JSMachine.WMS.Job.Job { [DisallowConcurrentExecution] [PersistJobDataAfterExecution] [Job(Name = nameof(RcsCallbackJob) , Group = nameof(RcsCallbackJob) + "_Group" , Description = "rcs回调作业" , ScheduleType = ScheduleType.Simple , IntervalMilliSeconds = 1000 , RepeatCount = 0 , StartTimeStr = null)] public class RcsCallbackJob : IJob { private static readonly IAGVTaskService AgvTaskService = GlobalServericeProvidor.GetService(); private static readonly IRcsCallBackService RcsCallBackService = GlobalServericeProvidor.GetService(); public async Task Execute(IJobExecutionContext context) { if (RcsCallbackCache.RcsCallbackQueue.TryDequeue(out AgvExcutionInfo agvExcutionInfo)) { AGVTaskDto agvTask = await AgvTaskService.GetSingalByExpression(p => p.Id == new Guid(agvExcutionInfo.OrderId)); if (agvTask == null) { LogHelper.Warn($"agv上报的任务 {agvExcutionInfo.OrderId} 不存在"); return; } string msg = $"agv上报的任务 ({agvExcutionInfo.OrderId}) 状态已经处理,属于重复上传,不再动作"; if (agvExcutionInfo.Status == 7 && agvTask.TaskStatus == TaskStatusEnum.Failed) { LogHelper.Info(msg); return; } if (agvExcutionInfo.Status == 3 && agvTask.TaskStatus == TaskStatusEnum.Cancelled) { LogHelper.Info(msg); return; } if (agvExcutionInfo.Status == 21 && agvTask.TaskStatus == TaskStatusEnum.PickupCompleted) { LogHelper.Info(msg); return; } if (agvExcutionInfo.Status == 23 && agvTask.TaskStatus == TaskStatusEnum.Completed) { LogHelper.Info(msg); return; } await RcsCallBackService.DealwithExcutionStatus(agvExcutionInfo, agvTask); } } } }