| | |
| | | using Microsoft.AspNetCore.Authorization; |
| | | using Microsoft.AspNetCore.Http; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Information; |
| | | using Org.BouncyCastle.Asn1.Ocsp; |
| | | using System.Text; |
| | | using System.Text.RegularExpressions; |
| | | using WIDESEA_DTO.Agv; |
| | |
| | | using WIDESEAWCS_QuartzJob.DTO; |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | | using WIDESEAWCS_QuartzJob.Repository; |
| | | using WIDESEAWCS_TaskInfoService; |
| | | using WIDESEAWCS_Tasks; |
| | | using WIDESEAWCS_Tasks.DBNames; |
| | | using static Dm.net.buffer.ByteArrayBuffer; |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var task = _taskRepository.QueryFirst(x => (agvUpdateDTO.ContainerCode ?? "")==x.PalletCode); |
| | | WriteLog.Write_Log("AGV任塿´æ°æ¥å£", "AGV任塿´æ°æ¥å£", "æ´æ°ä»»å¡", $"ä»»å¡ï¼{agvUpdateDTO.ToJson()}"); |
| | | if (agvUpdateDTO.Message != null && agvUpdateDTO.Message == "ROBOT_ERROR-haiUnknownError") |
| | | { |
| | | var task1 = _taskRepository.QueryFirst(x => (agvUpdateDTO.MissionCode ?? "") == x.GroupId); |
| | | if (task1 != null) |
| | | { |
| | | Dt_ErrorInfo errorInfo = new Dt_ErrorInfo() |
| | | { |
| | | RobotCode = agvUpdateDTO.RobotId, |
| | | Message = agvUpdateDTO.Message, |
| | | ErrorType = 2 |
| | | }; |
| | | if (task1.TaskType == 500) |
| | | { |
| | | errorInfo.Message = "å
¥åºå¼å¸¸"; |
| | | errorInfo.StationCode = task1.CurrentAddress; |
| | | } |
| | | else |
| | | { |
| | | errorInfo.Message = "åºåºå¼å¸¸"; |
| | | errorInfo.StationCode = task1.NextAddress; |
| | | } |
| | | _taskService.AgvSearchStatus1(errorInfo); |
| | | } |
| | | } |
| | | var task = _taskRepository.QueryFirst(x => (agvUpdateDTO.ContainerCode ?? "") == x.PalletCode); |
| | | switch (agvUpdateDTO.MissionStatus) |
| | | { |
| | | case nameof(AGVStatusEnum.PICKER_RECEIVE): |
| | | if (task == null) throw new Exception($"æªæ¾å°æç®±ã{agvUpdateDTO.ContainerCode}ãä»»å¡"); |
| | | _taskService.UpdateTask(task, TaskStatusEnum.AGV_TakeFinish); |
| | | Dt_ErrorInfo e1 = new Dt_ErrorInfo() |
| | | { |
| | | RobotCode = agvUpdateDTO.RobotId, |
| | | Message = agvUpdateDTO.Message, |
| | | ErrorType = 0 |
| | | }; |
| | | _taskService.AgvSearchStatus1(e1); |
| | | |
| | | break; |
| | | case nameof(AGVStatusEnum.PICKER_SEND): |
| | | if (task == null) throw new Exception($"æªæ¾å°æç®±ã{agvUpdateDTO.ContainerCode}ãä»»å¡"); |
| | | _taskService.TaskCompleted(task.TaskNum); |
| | | Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => x.PickStationCode == task.NextAddress); |
| | | if (task.IsCancel > 0 && stationManger != null && stationManger.StationCode != agvUpdateDTO.CurrentPosition) |
| | | { |
| | | _taskService.TaskCancelCompleted(task.TaskNum); |
| | | } |
| | | else |
| | | { |
| | | _taskService.TaskCompleted(task.TaskNum); |
| | | } |
| | | Dt_ErrorInfo e2 = new Dt_ErrorInfo() |
| | | { |
| | | RobotCode = agvUpdateDTO.RobotId, |
| | | Message = agvUpdateDTO.Message, |
| | | ErrorType = 0 |
| | | }; |
| | | _taskService.AgvSearchStatus1(e2); |
| | | break; |
| | | case nameof(AGVStatusEnum.WAITFEEDBACK): |
| | | //AGVæ¾è¡ |
| | | List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x=>x.StationType==StationTypeEnum.StationType_OnlyInbound.ObjToInt()); |
| | | if (!stationMangers.Select(x=>x.StationCode).Contains(agvUpdateDTO.CurrentPosition)) |
| | | List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt()); |
| | | if (!stationMangers.Select(x => x.StationCode).Contains(agvUpdateDTO.CurrentPosition)) |
| | | { |
| | | WebResponseContent responseContent = _taskService.AgvTaskFlow(agvUpdateDTO.MissionCode); |
| | | if (!responseContent.Status) throw new Exception($"{responseContent.Message}"); |
| | | } |
| | | Dt_ErrorInfo e3 = new Dt_ErrorInfo() |
| | | { |
| | | RobotCode = agvUpdateDTO.RobotId, |
| | | Message = agvUpdateDTO.Message, |
| | | ErrorType = 0 |
| | | }; |
| | | _taskService.AgvSearchStatus1(e3); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | AgvTaskReqContent content = new AgvTaskReqContent(); |
| | | try |
| | | { |
| | | WriteLog.Write_Log("AGVä»»å¡è¯·æ±", "AGVä»»å¡è¯·æ±æ¥å£", "ä»»å¡", $"ä»»å¡ï¼{agvTaskRequestDTO.ToJson()}"); |
| | | //è·åä»»å¡ |
| | | Dt_Task? taskExist = _taskRepository.QueryFirst(x=>x.PalletCode==agvTaskRequestDTO.ContainerCode) ?? throw new Exception($"æªæ¾å°æç®±{agvTaskRequestDTO.ContainerCode}ä»»å¡"); |
| | | //è·åç«å° |
| | |
| | | AgvTaskReqContent content = new AgvTaskReqContent(); |
| | | try |
| | | { |
| | | WriteLog.Write_Log("AGVä½ä¸å®æ", "AGVä½ä¸å®ææ¥å£", "ä»»å¡", $"ä»»å¡ï¼{agvTaskRequestDTO.ToJson()}"); |
| | | //è·åç«å° |
| | | Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == agvTaskRequestDTO.PositionId) ?? throw new Exception($"æªæ¾å°{agvTaskRequestDTO.PositionId}ç«å°ä½ç½®"); |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode) ?? throw new Exception($"æªæ¾å°å¯¹åºè®¾å¤{stationManger.StationDeviceCode}"); |
| | |
| | | |
| | | if (stationManger.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt()) |
| | | { |
| | | commonConveyorLine.Communicator.Write("21", (short)256); |
| | | commonConveyorLine.Communicator.Write("21", new byte[] { 1, 0 }); |
| | | } |
| | | else |
| | | { |
| | | commonConveyorLine.Communicator.Write("23", (short)256); |
| | | commonConveyorLine.Communicator.Write("23", new byte[] { 1, 0 }); |
| | | } |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | if (ex.Message.Contains("æ°æ®åå
¥ï¼å°åï¼ã23ãï¼åå
¥çæ°æ®ï¼ã256ã") || ex.Message.Contains("æ°æ®åå
¥ï¼å°åï¼ã21ãï¼åå
¥çæ°æ®ï¼ã256ã")) |
| | | { |
| | | content.OK(); |
| | | } |
| | | else |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// AGVä½ä¸å®æ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("AgvSearchStatus"), AllowAnonymous] |
| | | public void AgvSearchStatus() |
| | | { |
| | | _taskService.AgvSearchStatus(); |
| | | } |
| | | } |
| | | } |