| | |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Common.ConveyorLineEnum; |
| | | using WIDESEAWCS_Common.ShuttleCarEnum; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Caches; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_DTO.WMSInfo; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_QuartzJob.ConveyorLine.Enum; |
| | | using WIDESEAWCS_QuartzJob.DTO; |
| | | using WIDESEAWCS_QuartzJob.Repository; |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | | using WIDESEAWCS_Tasks.ConveyorLineJob; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | | [DisallowConcurrentExecution] |
| | | public class CommonConveyorLineJob : JobBase, IJob |
| | | public partial class CommonConveyorLineJob : JobBase, IJob |
| | | { |
| | | private readonly ITaskService _taskService; |
| | | private readonly ITaskExecuteDetailService _taskExecuteDetailService; |
| | | private readonly IRouterService _routerService; |
| | | private readonly IRouterRepository _routerRepository; |
| | | private readonly ICacheService _cacheService; |
| | | private readonly IMapper _mapper; |
| | | |
| | | public CommonConveyorLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper) |
| | | public CommonConveyorLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IRouterRepository routerRepository,ICacheService cacheService, IMapper mapper) |
| | | { |
| | | _taskService = taskService; |
| | | _taskExecuteDetailService = taskExecuteDetailService; |
| | | _routerService = routerService; |
| | | _routerRepository = routerRepository; |
| | | _cacheService = cacheService; |
| | | _mapper = mapper; |
| | | } |
| | | |
| | |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams"); |
| | | if (conveyorLine != null) |
| | | { |
| | | List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode); |
| | | List<Task> tasks = new List<Task>(); |
| | | foreach (string childDeviceCode in childDeviceCodes) |
| | | { |
| | | ConveyorLineTaskCommandR command = conveyorLine.ReadCustomer<ConveyorLineTaskCommandR>(childDeviceCode); |
| | | if (command != null && command.Status == (ushort)ConveyorStatus.Stored)//æ·»å è¾éçº¿ç¶æConveyorLineStatus enum |
| | | { |
| | | switch (childDeviceCode) |
| | | { |
| | | case "102": |
| | | RequestInbound(conveyorLine, command, childDeviceCode); |
| | | break; |
| | | case "104": |
| | | ConveyorLineInFinish(conveyorLine, command, childDeviceCode); |
| | | break; |
| | | //case "105": |
| | | // RequestOutbound(conveyorLine, command, childDeviceCode); |
| | | // break; |
| | | case "108": |
| | | ConveyorLineOutFinish(conveyorLine, command, childDeviceCode); |
| | | break; |
| | | //default: |
| | | // RequestInNextAddress(conveyorLine, command, childDeviceCode); |
| | | // RequestOutNextAddress(conveyorLine, command, childDeviceCode); |
| | | // break; |
| | | } |
| | | } |
| | | } |
| | | Task.WaitAll(tasks.ToArray()); |
| | | conveyorLine.Communicator.IsReadAfterWrite = false; |
| | | ConveyorLineExtend(conveyorLine); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | //Console.Out.WriteLine(DateTime.Now); |
| | | } |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è¾é线请æ±å
¥åº |
| | | /// </summary> |
| | | /// <param name="conveyorLine">è¾é线å®ä¾å¯¹è±¡</param> |
| | | /// <param name="command">读åç请æ±ä¿¡æ¯</param> |
| | | /// <param name="childDeviceCode">å设å¤ç¼å·</param> |
| | | public void RequestInbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandR command, string childDeviceCode) |
| | | { |
| | | Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode, command.Barcode); |
| | | if (task != null) |
| | | { |
| | | ConveyorLineDTO lineDTO = new ConveyorLineDTO() |
| | | { |
| | | //TaskNum = task.TaskNum, |
| | | stationCode = childDeviceCode, |
| | | Barcode = command.Barcode, |
| | | Spec = command.Spec, |
| | | Weight = command.Weight, |
| | | }; |
| | | var content = _taskService.RequestWMSTask(lineDTO); |
| | | |
| | | if (content.Status) |
| | | { |
| | | task.TargetAddress = AppSettings.Configuration["OKAddress"]; |
| | | task.NextAddress = task.TargetAddress; |
| | | ConveyorLineTaskCommandW taskCommand = _mapper.Map<ConveyorLineTaskCommandW>(task); |
| | | |
| | | if (conveyorLine.SendCommand(taskCommand, childDeviceCode)) |
| | | _taskService.UpdateTaskStatusToNext(task); |
| | | } |
| | | else |
| | | { |
| | | if (content.Code == 404)//ä¿®æ¹ç»ç¹å°å |
| | | { |
| | | task.TargetAddress = AppSettings.Configuration["NGAddress"]; |
| | | task.NextAddress = task.TargetAddress; |
| | | task.ExceptionMessage = content.Message; |
| | | task.TaskState = (int)TaskInStatusEnum.InException; |
| | | ConveyorLineTaskCommandW taskCommand = _mapper.Map<ConveyorLineTaskCommandW>(task); |
| | | if (conveyorLine.SendCommand(taskCommand, childDeviceCode)) _taskService.UpdateData(task); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è¾é线请æ±å
¥åºä¸ä¸å°å |
| | | /// </summary> |
| | | /// <param name="conveyorLine">è¾é线å®ä¾å¯¹è±¡</param> |
| | | /// <param name="command">读åç请æ±ä¿¡æ¯</param> |
| | | /// <param name="childDeviceCode">å设å¤ç¼å·</param> |
| | | public void RequestInNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandR 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) |
| | | //{ |
| | | // ConveyorLineTaskCommandW taskCommand = _mapper.Map<ConveyorLineTaskCommandW>(newTask); |
| | | |
| | | // conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | //} |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è¾é线å
¥åºå®æ |
| | | /// </summary> |
| | | /// <param name="conveyorLine">è¾é线å®ä¾å¯¹è±¡</param> |
| | | /// <param name="command">读åç请æ±ä¿¡æ¯</param> |
| | | /// <param name="childDeviceCode">å设å¤ç¼å·</param> |
| | | public void ConveyorLineInFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandR command, string childDeviceCode) |
| | | { |
| | | Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode); |
| | | if (task != null) _taskService.UpdateTaskStatusToNext(task); |
| | | |
| | | task = _taskService.QueryCompletedConveyorLineTask(command.TaskNum, childDeviceCode); |
| | | if (task != null && string.IsNullOrEmpty(task.TargetAddress)) |
| | | { |
| | | _taskService.StackerCraneRequestInbound(task); |
| | | } |
| | | //if (task != null) |
| | | //{ |
| | | // //conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, 0, childDeviceCode); |
| | | // //åWMSæ´æ°ä»»å¡ç¶æï¼WMSè¿åå
¥åºä»»å¡ç»ç¹ |
| | | // WebResponseContent content = _taskService.UpdateTaskStatusToNext(task); |
| | | // //Console.Out.WriteLine(content.Serialize()); |
| | | //} |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è¾é线请æ±åºä¿¡æ¯ |
| | | /// </summary> |
| | | /// <param name="conveyorLine">è¾é线å®ä¾å¯¹è±¡</param> |
| | | /// <param name="command">读åç请æ±ä¿¡æ¯</param> |
| | | /// <param name="childDeviceCode">å设å¤ç¼å·</param> |
| | | public void RequestOutbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandR command, string childDeviceCode) |
| | | { |
| | | Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode, command.Barcode); |
| | | if (task != null) |
| | | { |
| | | ConveyorLineTaskCommandW taskCommand = _mapper.Map<ConveyorLineTaskCommandW>(task); |
| | | |
| | | conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | |
| | | _taskService.UpdateTaskStatusToNext(task); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è¾é线请æ±åºåºä¸ä¸å°å |
| | | /// </summary> |
| | | /// <param name="conveyorLine">è¾é线å®ä¾å¯¹è±¡</param> |
| | | /// <param name="command">读åç请æ±ä¿¡æ¯</param> |
| | | /// <param name="childDeviceCode">å设å¤ç¼å·</param> |
| | | public void RequestOutNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandR 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) |
| | | //{ |
| | | // ConveyorLineTaskCommandW taskCommand = _mapper.Map<ConveyorLineTaskCommandW>(newTask); |
| | | |
| | | // conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | //} |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è¾é线åºåºå®æ |
| | | /// </summary> |
| | | /// <param name="conveyorLine">è¾é线å®ä¾å¯¹è±¡</param> |
| | | /// <param name="command">读åç请æ±ä¿¡æ¯</param> |
| | | /// <param name="childDeviceCode">å设å¤ç¼å·</param> |
| | | public void ConveyorLineOutFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandR 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()); |
| | | } |
| | | } |
| | | } |
| | | } |