| | |
| | | using Autofac.Core; |
| | | using Magicodes.IE.Core; |
| | | using NetTaste; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | |
| | | 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; |
| | |
| | | task.TaskState = (int)TaskStatusEnum.HktransportIng; |
| | | BaseDal.UpdateData(task); |
| | | } |
| | | else |
| | | else if (task.TaskState == (int)TaskStatusEnum.Execut) |
| | | { |
| | | task.TaskState = (int)TaskStatusEnum.Takeing; |
| | | TaskFeedback(task, 1); |
| | |
| | | break; |
| | | case "leavelift": //离å¼çµæ¢¯ |
| | | { |
| | | if (task.TaskType == (int)TaskTypeEnum.Q3RK || task.TaskType == (int)TaskTypeEnum.MOVE || task.TaskType == (int)TaskTypeEnum.F01|| task.TaskType == (int)TaskTypeEnum.Q3CK) |
| | | if (task.TaskType == (int)TaskTypeEnum.Q3RK || task.TaskType == (int)TaskTypeEnum.MOVE || task.TaskType == (int)TaskTypeEnum.F01 || task.TaskType == (int)TaskTypeEnum.Q3CK) |
| | | { |
| | | task.TaskState = TaskStatusEnum.HKleavelift.ObjToInt(); |
| | | BaseDal.UpdateData(task); |
| | |
| | | var task = BaseDal.QueryFirst(x => x.PalletCode == Rgv.content.podID); |
| | | if (task == null) throw new Exception($"æªæ¾å°ä»»å¡,ä»»å¡ç¼å·ã{Rgv.content.taskID}ã"); |
| | | //ç§»åº |
| | | if (task.TaskType == TaskTypeEnum.CPMoveInventory.ObjToInt() && Rgv.messageType == 10 && Rgv.content.status == 4) |
| | | if (task.TaskType == TaskTypeEnum.CPMoveInventory.ObjToInt()) |
| | | { |
| | | deviceName += "ç§»åº"; |
| | | WMSMoveLocationFeedback wMSMoveLocationFeedback = new WMSMoveLocationFeedback() |
| | | if (Rgv.messageType == 72) |
| | | { |
| | | containerCode = task.PalletCode, |
| | | fromStationCode = task.SourceAddress, |
| | | toLocationCode = task.TargetAddress |
| | | }; |
| | | Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(WMSMoveLocationFeedback)); |
| | | WMSReturn agvContent = null; |
| | | if (apiInfo == null) task.ExceptionMessage = "æªæ¾å°ç§»åºå®æåé¦WMSæ¥å£é
置信æ¯ï¼è¯·æ£æ¥æ¥å£é
ç½®"; |
| | | else |
| | | task.TaskState = TaskStatusEnum.TakeFinish.ObjToInt(); |
| | | BaseDal.UpdateData(task); |
| | | UpdateLocationStatus(task.SourceAddress, task.PalletCode, deviceTypeEnum, LocationStatusEnum.Free); |
| | | } |
| | | if (Rgv.messageType == 10 && Rgv.content.status == 4) |
| | | { |
| | | task.TaskState = TaskStatusEnum.Finish.ObjToInt(); |
| | | string response = HttpHelper.Post(apiInfo.ApiAddress, wMSMoveLocationFeedback.Serialize()); |
| | | agvContent = response.DeserializeObject<WMSReturn>(); |
| | | content.OK(data: agvContent); |
| | | if (agvContent.code != 200) |
| | | deviceName += "ç§»åº"; |
| | | WMSMoveLocationFeedback wMSMoveLocationFeedback = new WMSMoveLocationFeedback() |
| | | { |
| | | task.ExceptionMessage = agvContent.message; |
| | | content.Error(agvContent.message); |
| | | containerCode = task.PalletCode, |
| | | fromStationCode = task.SourceAddress, |
| | | toLocationCode = task.TargetAddress |
| | | }; |
| | | Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(WMSMoveLocationFeedback)); |
| | | WMSReturn agvContent = null; |
| | | if (apiInfo == null) task.ExceptionMessage = "æªæ¾å°ç§»åºå®æåé¦WMSæ¥å£é
置信æ¯ï¼è¯·æ£æ¥æ¥å£é
ç½®"; |
| | | else |
| | | { |
| | | task.TaskState = TaskStatusEnum.Finish.ObjToInt(); |
| | | string response = HttpHelper.Post(apiInfo.ApiAddress, wMSMoveLocationFeedback.Serialize()); |
| | | agvContent = response.DeserializeObject<WMSReturn>(); |
| | | content.OK(data: agvContent); |
| | | if (agvContent.code != 200) |
| | | { |
| | | task.ExceptionMessage = agvContent.message; |
| | | content.Error(agvContent.message); |
| | | } |
| | | UpdateLocationStatus(task.TargetAddress, task.PalletCode, deviceTypeEnum, LocationStatusEnum.InStock); |
| | | BaseDal.DeleteAndMoveIntoHty(task, OperateTypeEnum.èªå¨å®æ); |
| | | } |
| | | UpdateLocationStatus(task.TargetAddress, task.PalletCode, deviceTypeEnum, LocationStatusEnum.InStock); |
| | | BaseDal.DeleteAndMoveIntoHty(task, OperateTypeEnum.èªå¨å®æ); |
| | | } |
| | | } |
| | | else |
| | |
| | | } |
| | | 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 (task.TaskType == (int)TaskTypeEnum.CPOutbound && task.TaskState == (int)TaskStatusEnum.Execut && Rgv.content.errorCode == 1330003)//æååºåºä»»å¡ä¸ååå馿é»ç¢æï¼ä¿®æ¹ä»»å¡ç¶æä¸ºæ°å»ºéæ°æ¥è¯¢é»ç¢æå
³ç³» |
| | | { |
| | | task.TaskState = (int)TaskStatusEnum.New; |
| | | task.Remark = "åå车åé¦å¤±è´¥,éæ°ä¸å"; |
| | | BaseDal.UpdateData(task); |
| | | } |
| | | else |
| | | { |
| | | if (Error != null) |
| | | { |
| | | 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 |
| | | |
| | |
| | | dt_RGVLocationInfo.LocationStatus = locationStatusEnum.ObjToInt(); |
| | | _rGVLocationInfoService.Repository.UpdateData(dt_RGVLocationInfo); |
| | | } |
| | | } |
| | | else//å¹³åºåºä½ |
| | | { |
| | | |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region æ´æ°ä¸æ¥¼ç«å°ç¶æ |
| | | public WebResponseContent UpdateStandStatus(Dt_Task task, string stationCode, LocationStatusEnum locationStatusEnum) |
| | | { |
| | | try |
| | | { |
| | | Dt_StationManger? stationManger = _stationMangerService.Repository.QueryFirst(x => x.StationCode == task.TargetAddress); |
| | | //stationManger.IsOccupied = LocationStatusEnum.Lock.ObjToInt(); |
| | | if (stationManger != null) |
| | | { |
| | | if (locationStatusEnum == LocationStatusEnum.Free) //å¦æèµ·ç¹å®æå°±ç»è´§ä½èµå¼æçå· |
| | | Dt_StationManger stationManger = _stationMangerService.Repository.QueryFirst(x => x.StationCode == locationCode); |
| | | if (stationManger != null) |
| | | { |
| | | stationManger.IsOccupied = LocationStatusEnum.Lock.ObjToInt(); |
| | | if (locationStatusEnum == LocationStatusEnum.Free) //å¦æèµ·ç¹å®æå°±ç»è´§ä½èµå¼æçå· |
| | | { |
| | | stationManger.Remark = ""; |
| | | stationManger.IsOccupied = LocationStatusEnum.Free.ObjToInt(); |
| | | } |
| | | else |
| | | { |
| | | stationManger.Remark = palletCode; |
| | | stationManger.IsOccupied = LocationStatusEnum.Lock.ObjToInt(); |
| | | } |
| | | _stationMangerService.UpdateData(stationManger); |
| | | } |
| | | else |
| | | { |
| | | stationManger.IsOccupied = LocationStatusEnum.Free.ObjToInt(); |
| | | } |
| | | _stationMangerService.UpdateData(stationManger); |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | |
| | | } |
| | | #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 |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | } |