| | |
| | | using Microsoft.AspNetCore.Authorization; |
| | | using Microsoft.AspNetCore.Http; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using SqlSugar.Extensions; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseController; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_ITaskInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_TaskInfoRepository; |
| | | using WIDESEAWCS_TaskInfoService; |
| | | using WIDESEAWCS_Tasks; |
| | | |
| | | namespace WIDESEAWCS_WCSServer.Controllers.Task |
| | |
| | | { |
| | | private readonly IHttpContextAccessor _httpContextAccessor; |
| | | private readonly IRouterExtension _routerExtension; |
| | | private readonly WebSocketServer _webSocketServer; |
| | | |
| | | public TaskController(ITaskService service, IHttpContextAccessor httpContextAccessor, IRouterExtension routerExtension, WebSocketServer webSocketServer) : base(service) |
| | | //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) |
| | | { |
| | | _httpContextAccessor = httpContextAccessor; |
| | | _routerExtension = routerExtension; |
| | | _webSocketServer = webSocketServer; |
| | | _taskService = taskService; |
| | | _taskRepository = taskRepository; |
| | | //_webSocketServer = webSocketServer; |
| | | } |
| | | |
| | | [HttpPost, Route("ReceiveTask"), AllowAnonymous] |
| | |
| | | { |
| | | return WebResponseContent.Instance.OK(data: _routerExtension.GetEndPoint(startPoint, routeType)); |
| | | } |
| | | [HttpPost, HttpGet, Route("AgvCarrying"), AllowAnonymous] |
| | | public WebResponseContent AgvCarrying(int row, int startColumn, int endColumn, int layer, int targetLayer) |
| | | { |
| | | return Service.AgvCarrying(row, startColumn, endColumn, layer, targetLayer); |
| | | } |
| | | //[HttpPost, HttpGet, Route("WebSocketPushMessage"), AllowAnonymous] |
| | | //public WebResponseContent WebSocketPushMessage(string message) |
| | | //{ |
| | | // try |
| | | // { |
| | | // _webSocketServer.PublishAllClientPayload(message); |
| | | // return WebResponseContent.Instance.OK(); |
| | | // } |
| | | // catch(Exception ex) |
| | | // { |
| | | // return WebResponseContent.Instance.Error(ex.Message); |
| | | // } |
| | | //} |
| | | [HttpPost, HttpGet, Route("RecWMSTaskCompleted"), AllowAnonymous] |
| | | public WebResponseContent RecWMSTaskCompleted(int taskNum) |
| | | { |
| | | return Service.RecWMSTaskCompleted(taskNum); |
| | | } |
| | | |
| | | [HttpPost, HttpGet, Route("WebSocketPushMessage"), AllowAnonymous] |
| | | public WebResponseContent WebSocketPushMessage(string message) |
| | | //å åæºä»»å¡éå |
| | | [HttpPost, HttpGet, Route("StackerCraneTaskResending"), AllowAnonymous] |
| | | public WebResponseContent StackerCraneTaskResending(int taskNum) |
| | | { |
| | | try |
| | | { |
| | | _webSocketServer.PublishAllClientPayload(message); |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (task == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("æªæ¾å°è¯¥ä»»å¡ä¿¡æ¯"); |
| | | } |
| | | if(task.TaskState == TaskStatusEnum.SC_Executing.ObjToInt()) |
| | | { |
| | | _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute); |
| | | } |
| | | else |
| | | { |
| | | return WebResponseContent.Instance.Error("éå åæºæ§è¡ä¸ç¶æ"); |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch(Exception ex) |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | //å åæºä»»å¡ä¼å
æ§è¡ |
| | | [HttpPost, HttpGet, Route("StackerCraneTaskPriority"), AllowAnonymous] |
| | | public WebResponseContent StackerCraneTaskPriority(int taskNum) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (task == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("æªæ¾å°è¯¥ä»»å¡ä¿¡æ¯"); |
| | | } |
| | | if (task.TaskState == TaskStatusEnum.SC_Execute.ObjToInt()) |
| | | { |
| | | task.Grade = 98; |
| | | } |
| | | else |
| | | { |
| | | return WebResponseContent.Instance.Error("éå åæºå¾
æ§è¡ç¶æ"); |
| | | } |
| | | _taskRepository.UpdateData(task); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | } |
| | | } |