| | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | | [DisallowConcurrentExecution] |
| | | public class CommonConveyorLineJob : IJob |
| | | public class CommonConveyorLineJob : JobBase, IJob |
| | | { |
| | | private readonly ITaskService _taskService; |
| | | private readonly ITaskExecuteDetailService _taskExecuteDetailService; |
| | |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams"); |
| | | if (conveyorLine != null) |
| | | { |
| | | List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode); |
| | | List<Task> tasks = new List<Task>(); |
| | | List<string> childDeviceCodes = new List<string>(); |
| | | |
| | | foreach (string childDeviceCode in childDeviceCodes) |
| | | { |
| | | //Task task = Task.Run(() => |
| | | //{ |
| | | ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(childDeviceCode); |
| | | if (command != null) |
| | | { |
| | | DeviceProtocolDetailDTO? deviceProtocolDetail = conveyorLine.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.ProtocalDetailValue == command.InteractiveSignal.ToString() && x.DeviceProParamName == nameof(ConveyorLineTaskCommand.InteractiveSignal)); |
| | | if (deviceProtocolDetail != null) |
| | | { |
| | | MethodInfo? method = GetType().GetMethod(deviceProtocolDetail.ProtocolDetailType); |
| | | if (method != null) |
| | | { |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode }); |
| | | } |
| | | else |
| | | { |
| | | //todo æªæ¾å°æ¹æ³æ¶ |
| | | } |
| | | } |
| | | } |
| | | //}); |
| | | //tasks.Add(task); |
| | | R_ConveyorLineInfo command = conveyorLine.ReadCustomer<R_ConveyorLineInfo>(childDeviceCode); |
| | | if (command != null) |
| | | { |
| | | |
| | | } |
| | | } |
| | | |
| | | Task.WaitAll(tasks.ToArray()); |
| | | } |
| | | |
| | | } |
| | |
| | | /// <param name="conveyorLine">è¾é线å®ä¾å¯¹è±¡</param> |
| | | /// <param name="command">读åç请æ±ä¿¡æ¯</param> |
| | | /// <param name="childDeviceCode">å设å¤ç¼å·</param> |
| | | public void RequestInbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command,string childDeviceCode) |
| | | public void RequestInbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode) |
| | | { |
| | | if (_taskService.RequestWMSTask(command.Barcode, childDeviceCode).Status) |
| | | { |
| | | Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode); |
| | | if (task != null) |
| | | { |
| | | ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(task); |
| | | taskCommand.InteractiveSignal = command.InteractiveSignal; |
| | | conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | |
| | | _taskService.UpdateTaskStatusToNext(task); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="childDeviceCode">å设å¤ç¼å·</param> |
| | | public void RequestInNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode) |
| | | { |
| | | Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode); |
| | | if (task != null) |
| | | { |
| | | Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress); |
| | | if (newTask != null) |
| | | { |
| | | ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(newTask); |
| | | taskCommand.InteractiveSignal = command.InteractiveSignal; |
| | | conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="childDeviceCode">å设å¤ç¼å·</param> |
| | | public void ConveyorLineInFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode) |
| | | { |
| | | Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode); |
| | | if (task != null) |
| | | { |
| | | conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, 0, childDeviceCode); |
| | | WebResponseContent content = _taskService.UpdateTaskStatusToNext(task); |
| | | Console.Out.WriteLine(content.Serialize()); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="childDeviceCode">å设å¤ç¼å·</param> |
| | | public void RequestOutbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode) |
| | | { |
| | | Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode); |
| | | if (task != null) |
| | | { |
| | | ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(task); |
| | | taskCommand.InteractiveSignal = command.InteractiveSignal; |
| | | conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | |
| | | _taskService.UpdateTaskStatusToNext(task); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="childDeviceCode">å设å¤ç¼å·</param> |
| | | public void RequestOutNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode) |
| | | { |
| | | Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode); |
| | | if (task != null) |
| | | { |
| | | Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress); |
| | | if (newTask != null) |
| | | { |
| | | ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(newTask); |
| | | taskCommand.InteractiveSignal = command.InteractiveSignal; |
| | | conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="childDeviceCode">å设å¤ç¼å·</param> |
| | | public void ConveyorLineOutFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode) |
| | | { |
| | | Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode); |
| | | if (task != null) |
| | | { |
| | | conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, 0, childDeviceCode); |
| | | WebResponseContent content = _taskService.UpdateTaskStatusToNext(task); |
| | | Console.Out.WriteLine(content.Serialize()); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |