copy from "\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGVController.cs"
copy to "\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGV/CTU_AGVController .cs"
Îļþ´Ó ´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGVController.cs ¸´ÖÆ |
| | |
| | | { |
| | | [Route("api/[controller]")] |
| | | [ApiController] |
| | | public class AGVController : ControllerBase |
| | | public class CTU_AGVController : ControllerBase |
| | | { |
| | | private readonly IStationMangerRepository _stationMangerRepository; |
| | | private readonly ITaskService _taskService; |
| | | private readonly ITaskRepository _taskRepository; |
| | | |
| | | public AGVController(IStationMangerRepository stationMangerRepository, ITaskService taskService, ITaskRepository taskRepository) |
| | | public CTU_AGVController(IStationMangerRepository stationMangerRepository, ITaskService taskService, ITaskRepository taskRepository) |
| | | { |
| | | _stationMangerRepository = stationMangerRepository; |
| | | _taskService = taskService; |
| | | _taskRepository = taskRepository; |
| | | } |
| | | [HttpPost, HttpGet, Route("AGVFinish"), AllowAnonymous] |
| | | public WebResponseContent AGVFinish(string barcode) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var task = _taskRepository.QueryFirst(x => x.PalletCode == barcode); |
| | | if (task == null) throw new Exception($"æªæ¾å°ä»»å¡,æçå·ã{barcode}ã"); |
| | | AgvUpdateDTO updateDTO = new AgvUpdateDTO() |
| | | { |
| | | TaskCode = task.AgvTaskNum, |
| | | Method = "end" |
| | | }; |
| | | var agvResponseContent = CtuCallback(updateDTO); |
| | | if (agvResponseContent.Code == "1") throw new Exception(agvResponseContent.Message); |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | #region å®å
¨ä¿¡å·ç³è¯· |
| | | /// <summary> |
| | | /// å®å
¨ä¿¡å·ç³è¯· AGV-WCS |
| | | /// </summary> |
| | |
| | | if (task == null) throw new Exception("æªæ¾å°ä»»å¡"); |
| | | if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt()) |
| | | { |
| | | var content = TakeRequest(task.CurrentAddress); |
| | | if (!content.Status) |
| | | { |
| | | throw new Exception(content.Message); |
| | | } |
| | | var content = PutRequest(task.NextAddress, task.PalletType); |
| | | } |
| | | else |
| | | { |
| | | var content = PutRequest(task.NextAddress, task.PalletType); |
| | | if (!content.Status) |
| | | { |
| | | throw new Exception(content.Message); |
| | | } |
| | | var content = TakeRequest(task.CurrentAddress); |
| | | } |
| | | task.TaskState = TaskStatusEnum.AGV_WaitToExecute.ObjToInt(); |
| | | var up = _taskRepository.UpdateData(task); |
| | |
| | | return agvResponseContent; |
| | | //return _taskService.AgvSecureApply(secureApplyModel); |
| | | } |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// AGV任塿´æ°/宿 |
| | | /// CtuAGV任塿´æ°/宿 |
| | | /// </summary> |
| | | /// <param name="agvUpdateModel"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("AgvCallback"), AllowAnonymous] |
| | | public AgvResponseContent AgvUpdateTask([FromBody] AgvUpdateDTO agvUpdateModel) |
| | | [HttpPost, HttpGet, Route("CtuCallback"), AllowAnonymous] |
| | | public AgvResponseContent CtuCallback([FromBody] AgvUpdateDTO agvUpdateModel) |
| | | { |
| | | AgvResponseContent agvResponseContent = new AgvResponseContent(); |
| | | try |
| | |
| | | agvResponseContent.ReqCode = agvUpdateModel.ReqCode; |
| | | var task = _taskRepository.QueryFirst(x => agvUpdateModel.TaskCode == x.AgvTaskNum); |
| | | if (task == null) throw new Exception($"æªæ¾å°ä»»å¡,ä»»å¡å·ã{agvUpdateModel.TaskCode}ã"); |
| | | switch (agvUpdateModel.Method) |
| | | |
| | | if (agvUpdateModel.Method == "end") |
| | | { |
| | | case "start": |
| | | break; |
| | | case "outbin"://åºåºæ ¹æ®è¿ä¸ªä¿¡å·å¤æåè´§å®æ |
| | | if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt()) |
| | | { |
| | | var content = TakeFinish(task.CurrentAddress); |
| | | if (!content.Status) throw new Exception(content.Message); |
| | | task.TaskState = TaskStatusEnum.AGV_Finish.ObjToInt(); |
| | | var up = _taskRepository.DeleteAndMoveIntoHty(task, OperateTypeEnum.èªå¨å®æ); |
| | | if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt()) PutFinish(task.NextAddress); |
| | | _taskService.TaskCompleted(task.TaskNum); |
| | | agvResponseContent.Code = up ? "0" : "1"; |
| | | agvResponseContent.Message = up ? "æå" : "失败"; |
| | | return agvResponseContent; |
| | | } |
| | | break; |
| | | case "getSafetySignal"://å®å
¨ä¿¡å·ç³è¯· |
| | | { |
| | | if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt()) |
| | | { |
| | | var content = TakeRequest(task.CurrentAddress); |
| | | if (!content.Status) throw new Exception(content.Message); |
| | | } |
| | | else |
| | | { |
| | | var content = PutRequest(task.NextAddress, task.PalletType); |
| | | if (!content.Status) throw new Exception(content.Message); |
| | | } |
| | | task.TaskState = TaskStatusEnum.AGV_WaitToExecute.ObjToInt(); |
| | | var up = _taskRepository.UpdateData(task); |
| | | agvResponseContent.Code = up ? "0" : "1"; |
| | | agvResponseContent.Message = up ? "æå" : "失败"; |
| | | return agvResponseContent; |
| | | } |
| | | case "end"://å
¥åºæ ¹æ®è¿ä¸ªä¿¡å·å¤ææ¾è´§å®æ |
| | | if (task.TaskType != TaskTypeEnum.Outbound.ObjToInt()) |
| | | { |
| | | var content = PutFinish(task.NextAddress); |
| | | if (!content.Status) throw new Exception(content.Message); |
| | | Dt_StationManger dt_Station=_stationMangerRepository.QueryFirst(x=>x.AGVStationCode== task.NextAddress); |
| | | if (dt_Station==null) |
| | | { |
| | | throw new Exception($"{task.NextAddress}AGVç«å°æªå®ä¹"); |
| | | } |
| | | task.CurrentAddress = dt_Station.StationCode; |
| | | task.NextAddress = ""; |
| | | task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt(); |
| | | task.DeviceCode = "SC01_CSJ"; |
| | | var up = _taskRepository.UpdateData(task); |
| | | agvResponseContent.Code = up ? "0" : "1"; |
| | | agvResponseContent.Message = up ? "æå" : "失败"; |
| | | return agvResponseContent; |
| | | } |
| | | break; |
| | | case "cancel": |
| | | task.TaskState = TaskStatusEnum.Cancel.ObjToInt(); |
| | | _taskRepository.UpdateData(task); |
| | | break; |
| | | default: |
| | | throw new Exception($"æªå®ä¹æ¹æ³åã{agvUpdateModel.Method}ã"); |
| | | } |
| | | agvResponseContent.Code = "0"; |
| | | agvResponseContent.Message = "æå"; |
| | |
| | | agvResponseContent.Message = ex.Message; |
| | | } |
| | | return agvResponseContent; |
| | | //return _taskService.AgvUpdateTask(agvUpdateModel); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | bool canPut = otherDevice.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanPut, stationManger.StationCode); |
| | | if (canPut) |
| | | { |
| | | otherDevice.SetValue(GroundStationDBName.W_PutRequest, true, stationManger.StationCode); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | else |
| | |
| | | bool canPut = otherDevice.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanTake, stationManger.StationCode); |
| | | if (canPut) |
| | | { |
| | | otherDevice.SetValue(GroundStationDBName.W_TakeRequest, true, stationManger.StationCode); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | else |