| | |
| | | using HslCommunication.WebSocket; |
| | | using Autofac.Core.Resolving.Middleware; |
| | | using HslCommunication.WebSocket; |
| | | using Microsoft.AspNetCore.Authorization; |
| | | using Microsoft.AspNetCore.Http; |
| | | using Microsoft.AspNetCore.Mvc; |
| | |
| | | //private readonly WebSocketServer _webSocketServer; |
| | | private readonly ITaskService _taskService; |
| | | private readonly ITaskRepository _taskRepository; |
| | | public TaskController(ITaskService service, IHttpContextAccessor httpContextAccessor, IRouterExtension routerExtension ,ITaskService taskService,ITaskRepository taskRepository /*, WebSocketServer webSocketServer*/) : base(service) |
| | | public TaskController(ITaskService service, IHttpContextAccessor httpContextAccessor, IRouterExtension routerExtension, ITaskService taskService, ITaskRepository taskRepository /*, WebSocketServer webSocketServer*/) : base(service) |
| | | { |
| | | _httpContextAccessor = httpContextAccessor; |
| | | _routerExtension = routerExtension; |
| | |
| | | return Service.ReceiveWMSTask(taskDTOs); |
| | | } |
| | | |
| | | |
| | | [HttpPost, Route("ReceiveCPTask"), AllowAnonymous] |
| | | public WebResponseContent ReceiveWMSCPTask([FromBody] List<WMSTaskDTO> taskDTOs) |
| | | { |
| | | return Service.ReceiveWMSCPTask(taskDTOs); |
| | | } |
| | | |
| | | |
| | | [HttpPost, HttpGet, Route("RequestAssignLocation"), AllowAnonymous] |
| | | public string? RequestAssignLocation(int taskNum, string roadwayNo) |
| | | { |
| | | return Service.RequestAssignLocation(taskNum, roadwayNo); |
| | | } |
| | | |
| | | |
| | | [HttpPost, HttpGet, Route("UpdateTaskExceptionMessage")] |
| | | public WebResponseContent UpdateTaskExceptionMessage(int taskNum, string message) |
| | |
| | | { |
| | | return Service.AgvCarrying(row, startColumn, endColumn, layer, targetLayer); |
| | | } |
| | | |
| | | [HttpPost, HttpGet, Route("LedShowTask"), AllowAnonymous] |
| | | public WebResponseContent LedShowTask(string stationCode, string palletCode, int taskType) |
| | | { |
| | | return Service.LedShowTask(stationCode,palletCode,taskType); |
| | | } |
| | | //[HttpPost, HttpGet, Route("WebSocketPushMessage"), AllowAnonymous] |
| | | //public WebResponseContent WebSocketPushMessage(string message) |
| | | //{ |
| | |
| | | // return WebResponseContent.Instance.Error(ex.Message); |
| | | // } |
| | | //} |
| | | |
| | | |
| | | [HttpPost, HttpGet, Route("RecWMSTaskCompleted"), AllowAnonymous] |
| | | public WebResponseContent RecWMSTaskCompleted(int taskNum) |
| | | { |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error("未找到该任务信息"); |
| | | } |
| | | if(task.TaskState == TaskStatusEnum.SC_Executing.ObjToInt()) |
| | | if (task.TaskState == TaskStatusEnum.SC_Executing.ObjToInt()) |
| | | { |
| | | _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute); |
| | | } |
| | |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch(Exception ex) |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | //RGV入库任务重发 |
| | | [HttpPost, HttpGet, Route("RGVTaskResending"), AllowAnonymous] |
| | | //堆垛机任务优先执行 |
| | | [HttpPost, HttpGet, Route("StackerCraneTaskPriority"), AllowAnonymous] |
| | | public WebResponseContent StackerCraneTaskPriority(int taskNum) |
| | | { |
| | | try |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error("未找到该任务信息"); |
| | | } |
| | | if (task.TaskState == TaskStatusEnum.RGV_Executing.ObjToInt()) |
| | | if (task.TaskState == TaskStatusEnum.SC_Execute.ObjToInt()) |
| | | { |
| | | _taskService.UpdateTask(task, TaskStatusEnum.RGV_NEW); |
| | | task.Grade = 98; |
| | | } |
| | | else |
| | | { |
| | | return WebResponseContent.Instance.Error("非RGV执行中状态"); |
| | | return WebResponseContent.Instance.Error("非堆垛机待执行状态"); |
| | | } |
| | | _taskRepository.UpdateData(task); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 任务手动完成 |
| | | /// </summary> |
| | | /// <param name="taskNum"></param> |
| | | /// <returns></returns> |
| | | [HttpGet, HttpPost, Route("ManualTaskCompleted"), AllowAnonymous] |
| | | public async Task<WebResponseContent> ManualTaskCompleted(int taskNum) |
| | | { |
| | | return await Service.ManualTaskCompleted(taskNum); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// RGV任务重发 |
| | | /// </summary> |
| | | /// <param name="taskNum"></param> |
| | | /// <returns></returns> |
| | | [HttpGet, HttpPost, Route("RGVTaskResending"), AllowAnonymous] |
| | | public WebResponseContent RGVTaskResending(int taskNum) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum); |
| | | if(task == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("未找到该任务信息"); |
| | | } |
| | | if (task.TaskState == TaskStatusEnum.RGV_Executing.ObjToInt()) |
| | | { |
| | | if (task.TaskType >= TaskTypeEnum.Inbound.ObjToInt()) |
| | | { |
| | | _taskService.UpdateTask(task, TaskStatusEnum.RGV_NEW); |
| | | } |
| | | else if (task.TaskType >= TaskTypeEnum.Outbound.ObjToInt() && task.TaskType < TaskTypeEnum.Inbound.ObjToInt()) |
| | | { |
| | | _taskService.UpdateTask(task, TaskStatusEnum.RGV_Execute); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return WebResponseContent.Instance.Error("非RGV执行中状态"); |
| | | } |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch(Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |