| | |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_DTO.Agv; |
| | | using System.Reflection.Metadata; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | |
| | | namespace WIDESEAWCS_TaskInfoService |
| | | { |
| | |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// AGVä»»å¡ç¶æå·æ°/AGVä»»å¡å®æ |
| | | /// AGVç¶ææ¥è¯¢è°ç¨åWMSæ
é䏿¥ |
| | | /// </summary> |
| | | /// <param name="agvUpdateModel"></param> |
| | | /// <returns></returns> |
| | | public AgvResponseContent AgvUpdateTask(AgvUpdateDTO agvUpdateModel) |
| | | public void AgvSearchStatus() |
| | | { |
| | | return new AgvResponseContent(); |
| | | try |
| | | { |
| | | AgvSearchStatusDTO agvSearchStatusDTO = new AgvSearchStatusDTO(); |
| | | string? apiAddress = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.AgvSearchStatus.ToString())?.ApiAddress; |
| | | if (string.IsNullOrEmpty(apiAddress)) throw new Exception($"æªæ¾å°AGVç¶ææ¥è¯¢æ¥å£,è¯·æ£æ¥æ¥å£é
ç½®"); |
| | | string? apiErrorBack = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.WMSErrorBack.ToString())?.ApiAddress; |
| | | if (string.IsNullOrEmpty(apiErrorBack)) throw new Exception($"æªæ¾å°WMSæ
é䏿¥,è¯·æ£æ¥æ¥å£é
ç½®"); |
| | | string request = JsonConvert.SerializeObject(agvSearchStatusDTO, settings); |
| | | string response = HttpHelper.Post(apiAddress, request); |
| | | AgvStatusContent agvContent = response.DeserializeObject<AgvStatusContent>() ?? throw new Exception("AGVç¶ææ¥è¯¢æªè¿åç»æ"); |
| | | |
| | | //è·åæææ
éä¿¡æ¯ |
| | | List <Dt_ErrorInfo> errorInfos = _errorInfoRepository.QueryData(); |
| | | int errorId = errorInfos.Count > 0 ? errorInfos.Max(x => x.Id) : 0; |
| | | List<Dt_ErrorInfo> delErrorInfos = new List<Dt_ErrorInfo>(); |
| | | List<Dt_ErrorInfo> addErrorInfos = new List<Dt_ErrorInfo>(); |
| | | //è·åä»»å¡ä¿¡æ¯ |
| | | List<Dt_Task> tasks = BaseDal.QueryData(); |
| | | if (agvContent.Success) |
| | | { |
| | | foreach (var item in agvContent.Data.Where(x => errorInfos.Select(x => x.RobotCode).Contains(x.RobotId) && x.Status != 7)) |
| | | { |
| | | //䏿¥æ
éæ¢å¤ |
| | | Dt_ErrorInfo errorInfo = errorInfos.FirstOrDefault(x => x.RobotCode == item.RobotId); |
| | | |
| | | delErrorInfos.Add(errorInfo); |
| | | } |
| | | foreach (var item in agvContent.Data.Where(x => !x.MissionCode.IsNullOrEmpty() && !errorInfos.Select(x => x.RobotCode).Contains(x.RobotId) && x.Status == 7)) |
| | | { |
| | | Dt_Task? task = tasks.FirstOrDefault(x=>x.TaskNum == item.MissionCode.ObjToInt() || x.GroupId==item.MissionCode); |
| | | if (task != null) |
| | | { |
| | | Dt_ErrorInfo errorInfo = new Dt_ErrorInfo() |
| | | { |
| | | RobotCode = item.RobotId, |
| | | Message = "æ
é" |
| | | }; |
| | | if (task.TaskType==TaskTypeEnum.Inbound.ObjToInt()) |
| | | { |
| | | errorInfo.StationCode = task.CurrentAddress; |
| | | } |
| | | else |
| | | { |
| | | errorInfo.StationCode = task.NextAddress; |
| | | } |
| | | addErrorInfos.Add(errorInfo); |
| | | } |
| | | } |
| | | } |
| | | //æ°æ®åºæä½ |
| | | _unitOfWorkManage.BeginTran(); |
| | | _errorInfoRepository.DeleteData(delErrorInfos); |
| | | _errorInfoRepository.AddData(addErrorInfos); |
| | | _unitOfWorkManage.CommitTran(); |
| | | List<Dt_ErrorInfo> newErrInfos = _errorInfoRepository.QueryData(x=>x.Id > errorId); |
| | | if (delErrorInfos.Count>0) |
| | | { |
| | | foreach (var item in delErrorInfos) |
| | | { |
| | | TaskError taskError = new TaskError() |
| | | { |
| | | MsgID = item.Id, |
| | | StationCode = item.StationCode, |
| | | MsgCode = 0, |
| | | Msg = "æ¢å¤" |
| | | }; |
| | | string reqErrorBack = JsonConvert.SerializeObject(taskError, settings); |
| | | HttpHelper.Post(apiErrorBack, reqErrorBack); |
| | | } |
| | | } |
| | | if (newErrInfos.Count>0) |
| | | { |
| | | //ä¸ä¼ æ
é |
| | | foreach (var item in newErrInfos) |
| | | { |
| | | TaskError taskError = new TaskError() |
| | | { |
| | | MsgID = item.Id, |
| | | StationCode = item.StationCode, |
| | | MsgCode = 1, |
| | | Msg = item.Message |
| | | }; |
| | | string reqErrorBack = JsonConvert.SerializeObject(taskError, settings); |
| | | HttpHelper.Post(apiErrorBack, reqErrorBack); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | throw new Exception(ex.Message); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |