| | |
| | | using Autofac.Core; |
| | | using Newtonsoft.Json.Serialization; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Serialization; |
| | | using Org.BouncyCastle.Asn1.Ocsp; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Reflection.Metadata; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_DTO.Agv; |
| | |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_DTO.Agv; |
| | | using System.Reflection.Metadata; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_Model.Models; |
| | | |
| | | namespace WIDESEAWCS_TaskInfoService |
| | | { |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | |
| | | string? apiAddress = _apiInfoRepository.QueryFirst(x => x.ApiCode == SendTask.ToString())?.ApiAddress; |
| | | if (string.IsNullOrEmpty(apiAddress)) throw new Exception($"æªæ¾å°åéAGV任塿¥å£,è¯·æ£æ¥æ¥å£é
ç½®"); |
| | | string request = JsonConvert.SerializeObject(taskModel, settings); |
| | | string response = HttpHelper.Post(apiAddress, request); |
| | | WriteLog.Write_Log("AGVå
¥åºä»»å¡ä¸å", "åºåºä»»å¡ä¸åæ¥å£", "请æ±ä»»å¡", $"请æ±ï¼{request},åä¼ ï¼{response}"); |
| | | AgvResponseContent agvContent = response.DeserializeObject<AgvResponseContent>() ?? throw new Exception("AGVä»»å¡åéæªè¿åç»æ"); |
| | | if (agvContent.Success) |
| | | { |
| | |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// AGVæ¥è¯¢è°ç¨åWMSæ
é䏿¥ |
| | | /// </summary> |
| | | public void AgvSearchStatus1(Dt_ErrorInfo e2) |
| | | { |
| | | WriteLog.Write_Log("AGVæ¥è¯¢è°ç¨åWMSæ
é䏿¥", "AGVæ¥è¯¢è°ç¨åWMSæ
鿥å£", "请æ±", $"请æ±ï¼{e2.ToJson()}"); |
| | | if (e2 != null) |
| | | { |
| | | // æ¥è¯¢æ¯å¦æé误没æå°±æ·»å ï¼æå°±åæ¶ |
| | | List<Dt_ErrorInfo> existingErrors = _errorInfoRepository.QueryData(x => |
| | | x.RobotCode == e2.RobotCode && |
| | | x.ErrorType == 2); // åªæ¥è¯¢æ
éç±»å为2çè®°å½ |
| | | |
| | | string? ErrorBack = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.WMSErrorBack.ToString())?.ApiAddress; |
| | | if (string.IsNullOrEmpty(ErrorBack)) |
| | | { |
| | | return; |
| | | }else{ |
| | | // å¦ææ¯æ
é䏿¥(e2.ErrorType == 2) |
| | | if (e2.ErrorType == 2) |
| | | { |
| | | // æ£æ¥æ¯å¦å·²åå¨ç¸åæºå¨äººçæ
éè®°å½ |
| | | if (existingErrors.Count == 0) |
| | | { |
| | | _errorInfoRepository.AddData(e2); |
| | | // åéç»WMS - æ
é䏿¥ |
| | | TaskError taskError = new TaskError() |
| | | { |
| | | MsgID = e2.Id, |
| | | StationCode = e2.StationCode, |
| | | MsgCode = 1, // 1表示æ
é |
| | | Msg = e2.Message |
| | | }; |
| | | string reqErrorBack = JsonConvert.SerializeObject(taskError, settings); |
| | | HttpHelper.Post(ErrorBack, reqErrorBack); |
| | | } |
| | | // 妿已å卿
éè®°å½ï¼åä¸é夿·»å |
| | | } |
| | | // å¦ææ¯æ£å¸¸ç¶æ(e2.ErrorType == 0)ä¸å卿
éè®°å½ï¼åæ§è¡æ
éæ¢å¤ |
| | | else if (e2.ErrorType == 0 && existingErrors.Count > 0) |
| | | { |
| | | // å 餿
éè®°å½ |
| | | if (_errorInfoRepository.DeleteData(existingErrors)) |
| | | { |
| | | // åéç»WMS - æ
éæ¢å¤ |
| | | foreach (var error in existingErrors) |
| | | { |
| | | TaskError taskError = new TaskError() |
| | | { |
| | | MsgID = error.Id, |
| | | StationCode = error.StationCode, |
| | | MsgCode = 0, // 0表示æ¢å¤ |
| | | Msg = "æ
鿢å¤" |
| | | }; |
| | | string reqErrorBack = JsonConvert.SerializeObject(taskError, settings); |
| | | HttpHelper.Post(ErrorBack, reqErrorBack); |
| | | } |
| | | } |
| | | } |
| | | return; |
| | | } |
| | | |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// AGVç¶ææ¥è¯¢è°ç¨åWMSæ
é䏿¥ |
| | | /// </summary> |
| | | public void AgvSearchStatus() |
| | | { |
| | | try |
| | | { |
| | | // æ¥è¯¢æ¯å¦æä»»å¡ |
| | | List<Dt_Task> tasks = BaseDal.QueryData(); |
| | | // å¦ææ²¡æä»»å¡ï¼ç´æ¥è¿å |
| | | if (tasks == null || tasks.Count == 0) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | AgvSearchStatusDTO agvSearchStatusDTO = new AgvSearchStatusDTO(); |
| | | string? apiAddress = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.AgvSearchStatus.ToString())?.ApiAddress; |
| | | if (string.IsNullOrEmpty(apiAddress)) throw new Exception($"æªæ¾å°AGVç¶ææ¥è¯¢æ¥å£,è¯·æ£æ¥æ¥å£é
ç½®"); |
| | |
| | | AgvStatusContent agvContent = response.DeserializeObject<AgvStatusContent>() ?? throw new Exception("AGVç¶ææ¥è¯¢æªè¿åç»æ"); |
| | | |
| | | //è·åæææ
éä¿¡æ¯ |
| | | List <Dt_ErrorInfo> errorInfos = _errorInfoRepository.QueryData(); |
| | | List <Dt_ErrorInfo> errorInfos = _errorInfoRepository.QueryData(x => x.ErrorType == 1); |
| | | 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(); |
| | | //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 = new Dt_ErrorInfo() |
| | | { |
| | | RobotCode = item.RobotId, |
| | | Message = "æ
é" |
| | | Message = "æ
é", |
| | | ErrorType = 1, |
| | | }; |
| | | if (task.TaskType==TaskTypeEnum.Inbound.ObjToInt()) |
| | | { |
| | |
| | | _errorInfoRepository.DeleteData(delErrorInfos); |
| | | _errorInfoRepository.AddData(addErrorInfos); |
| | | _unitOfWorkManage.CommitTran(); |
| | | List<Dt_ErrorInfo> newErrInfos = _errorInfoRepository.QueryData(x=>x.Id > errorId); |
| | | List<Dt_ErrorInfo> newErrInfos = _errorInfoRepository.QueryData(x=>x.Id > errorId && x.ErrorType == 1); |
| | | if (delErrorInfos.Count>0) |
| | | { |
| | | foreach (var item in delErrorInfos) |
| | |
| | | }; |
| | | string reqErrorBack = JsonConvert.SerializeObject(taskError, settings); |
| | | HttpHelper.Post(apiErrorBack, reqErrorBack); |
| | | |
| | | } |
| | | } |
| | | if (newErrInfos.Count>0) |
| | |
| | | } |
| | | |
| | | } |
| | | public WebResponseContent AgvCancelTask(AgvTaskCancelDTO taskModel, APIEnum SendTask = APIEnum.AgvTaskCancel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | string? apiAddress = _apiInfoRepository.QueryFirst(x => x.ApiCode == SendTask.ToString())?.ApiAddress; |
| | | if (string.IsNullOrEmpty(apiAddress)) throw new Exception($"æªæ¾å°åéAGV任塿¥å£,è¯·æ£æ¥æ¥å£é
ç½®"); |
| | | string request = JsonConvert.SerializeObject(taskModel, settings); |
| | | string response = HttpHelper.Post(apiAddress, request); |
| | | AgvResponseContent agvContent = response.DeserializeObject<AgvResponseContent>() ?? throw new Exception("AGVä»»å¡åéæªè¿åç»æ"); |
| | | if (agvContent.Success) |
| | | { |
| | | content.OK(); |
| | | } |
| | | else |
| | | { |
| | | content.Error(agvContent.Message); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |