| | |
| | | using System.Reflection.Metadata; |
| | | using System.Text; |
| | | using System.Text.Json; |
| | | using System.Text.RegularExpressions; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Common; |
| | | using WIDESEAWCS_Common.LocationEnum; |
| | |
| | | } |
| | | if (Rgv.content.status == 5) |
| | | { |
| | | if (task.TaskState == (int)TaskStatusEnum.Execut) |
| | | task.ExceptionMessage = Rgv.content.errorReason; |
| | | var Error = _taskErrorMessageService.Repository.QueryFirst(x => x.ErrorCode == Rgv.content.errorCode && x.DeviceType == (int)deviceTypeEnum); |
| | | if (Error != null) |
| | | { |
| | | task.TaskState = (int)TaskStatusEnum.New; |
| | | task.Remark = "åå车åé¦å¤±è´¥,éæ°ä¸å"; |
| | | BaseDal.UpdateData(task); |
| | | task.ExceptionMessage = Error.ExceptionMessage; |
| | | MatchCollection matches = Regex.Matches(Rgv.content.errorReason, @"\(([^)]+)\)"); |
| | | if (matches.Count > 0) |
| | | task.ExceptionMessage = ReplacePlaceholders(Rgv.content.errorReason, Error.ExceptionMessage); |
| | | ErrorTaskFeedback(task, true, Error.ErrorCode.ToString()); |
| | | } |
| | | else |
| | | ErrorTaskFeedback(task, true); |
| | | } |
| | | } |
| | | } |
| | |
| | | _trackloginfoService.AddTrackLog(TaskDTO, content, $"{deviceName}ä»»å¡ç¶æåé¦", "", ""); |
| | | } |
| | | return content; |
| | | } |
| | | #endregion |
| | | |
| | | #region å¼å¸¸ä¿¡æ¯è½¬æ¢ |
| | | /// <summary> |
| | | /// å¼å¸¸ä¿¡æ¯()å
å®¹è½¬æ¢ |
| | | /// </summary> |
| | | /// <param name="source"></param> |
| | | /// <param name="targetTemplate"></param> |
| | | /// <returns></returns> |
| | | public string ReplacePlaceholders(string source, string targetTemplate) |
| | | { |
| | | // æåæºå符串ä¸çæææ¬å·å¼ |
| | | var values = Regex.Matches(source, @"\(([^)]+)\)") |
| | | .Cast<Match>() |
| | | .Select(m => m.Groups[1].Value) |
| | | .ToList(); |
| | | |
| | | // æ¿æ¢ç®æ 模æ¿ä¸çææ (%v) |
| | | int idx = 0; |
| | | string result = Regex.Replace(targetTemplate, @"\(\%v\)", _ => |
| | | idx < values.Count ? values[idx++] : ""); |
| | | |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | |
| | | } |
| | | #endregion |
| | | #region 失败任å¡ä¸æ¥WMSå¹¶å é¤ä»»å¡ |
| | | public WebResponseContent ErrorTaskFeedback(Dt_Task dt_Task, bool Del) |
| | | public WebResponseContent ErrorTaskFeedback(Dt_Task dt_Task, bool Del = false, string ErrorCode = "") |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | WMSInOutBoundCompleteFeedback boundCompleteFeedback = new WMSInOutBoundCompleteFeedback(); |
| | |
| | | boundCompleteFeedback.fromStationCode = dt_Task.SourceAddress; |
| | | boundCompleteFeedback.toLocationCode = dt_Task.TargetAddress; |
| | | boundCompleteFeedback.status = 3; |
| | | boundCompleteFeedback.custStatus = ""; |
| | | boundCompleteFeedback.custStatus = ErrorCode; |
| | | boundCompleteFeedback.memo = dt_Task.ExceptionMessage; |
| | | string response = HttpHelper.Post(apiInfo.ApiAddress, boundCompleteFeedback.Serialize()); |
| | | agvContent = response.DeserializeObject<WMSReturn>(); |
| | |
| | | finally |
| | | { |
| | | _trackloginfoService.AddTrackLog(boundCompleteFeedback, content, "åºå
¥åºä»»å¡ç¶æåé¦WMS", "", ""); |
| | | if (agvContent != null && agvContent.code == 200 && Del) BaseDal.DeleteAndMoveIntoHty(dt_Task, OperateTypeEnum.èªå¨å é¤); |
| | | if (agvContent != null && agvContent.code == 200 && Del) |
| | | BaseDal.DeleteAndMoveIntoHty(dt_Task, OperateTypeEnum.èªå¨å é¤); |
| | | else BaseDal.UpdateData(dt_Task); |
| | | } |
| | | return content; |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | } |