| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_DTO.WMSInfo; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | | using WIDESEAWCS_QuartzJob.StackerCrane.Enum; |
| | | using WIDESEAWCS_TaskInfoService; |
| | | |
| | | namespace WIDESEAWCS_TaskInfoService |
| | |
| | | if (saveModel == null) throw new Exception("æ´æ°ä»»å¡ä¿¡æ¯ä¸ºç©º"); |
| | | Dt_Task dt_Task = GetTaskInfo(Convert.ToInt32(saveModel.outID)); |
| | | if (dt_Task == null) throw new Exception($"æªæ¾å°ä»»å¡å·ä¸ºã{saveModel.outID}ãçä»»å¡"); |
| | | dt_Task.TaskState = saveModel.status switch |
| | | if (dt_Task.TaskState >= (int)TaskInStatusEnum.AGV_InFinish) |
| | | { |
| | | "02" => (int)TaskInStatusEnum.AGV_InExecuting, |
| | | "08" => (int)TaskInStatusEnum.AGV_InFinish, |
| | | _ => throw new Exception($"æªå®ä¹ä»»å¡ç¶æã{saveModel.status}ã"), |
| | | }; |
| | | return content = WebResponseContent.Instance.Error($"该任å¡ç¶æä¸å¯è·³è½¬å°ä¸ä¸æ¥,ä»»å¡å·:ã{dt_Task.TaskNum}ã,ä»»å¡ç¶æ:ã{GetEnumDescription(Enum.Parse<TaskInStatusEnum>(Enum.GetName(typeof(TaskInStatusEnum), dt_Task.TaskState)))}ã"); |
| | | } |
| | | switch (saveModel.status) |
| | | { |
| | | case "02": |
| | | dt_Task.TaskState = (int)TaskInStatusEnum.AGV_InExecuting; |
| | | break; |
| | | case "08": |
| | | { |
| | | dt_Task.TaskState = (int)TaskInStatusEnum.AGV_InFinish; |
| | | dt_Task.CurrentAddress = dt_Task.NextAddress; |
| | | List<Dt_Router> routers = _routerService.QueryNextRoutes(dt_Task.CurrentAddress, dt_Task.TargetAddress); |
| | | if (routers.Count > 0) |
| | | { |
| | | dt_Task.NextAddress = routers.FirstOrDefault().ChildPosi; |
| | | } |
| | | } |
| | | break; |
| | | default: |
| | | throw new Exception($"æªå®ä¹ä»»å¡ç¶æã{saveModel.status}ã"); |
| | | } |
| | | //dt_Task.TaskState = saveModel.status switch |
| | | //{ |
| | | // "02" => (int)TaskInStatusEnum.AGV_InExecuting, |
| | | // "08" => (int)TaskInStatusEnum.AGV_InFinish, |
| | | // _ => throw new Exception($"æªå®ä¹ä»»å¡ç¶æã{saveModel.status}ã"), |
| | | //}; |
| | | content = UpdateData(dt_Task); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | // message = content.Message, |
| | | //}; |
| | | } |
| | | /// <summary> |
| | | /// åºåºä»»å¡å®æ |
| | | /// </summary> |
| | | /// <param name="Address"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent OutTaskFinish(string Address) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task dt_Task = BaseDal.QueryFirst(x => x.TargetAddress == Address); |
| | | if (dt_Task != null && dt_Task.TaskState != TaskOutStatusEnum.AGV_OutFinish.ObjToInt()) |
| | | throw new Exception($"å°åã{Address}ãå卿ªå®æAGVä»»å¡"); |
| | | Dt_Router _Router = _routerRepository.QueryFirst(x => x.NextPosi == Address); |
| | | if (_Router == null) throw new Exception($"å°åã{Address}ãæªé
置路ç±"); |
| | | _Router.Remark = "æªå ç¨"; |
| | | Db.Ado.BeginTran(); |
| | | _routerRepository.UpdateData(_Router); |
| | | if (dt_Task != null) |
| | | { |
| | | dt_Task.TaskState = TaskOutStatusEnum.OutFinish.ObjToInt(); |
| | | WMSTaskDTO WMStask = _mapper.Map<WMSTaskDTO>(dt_Task); |
| | | AddTask_Hty(dt_Task, TaskOperateTypeEnum.AutoComplete); |
| | | HttpHelper.PostAsync(WMSInterfaceAddress.UpdateTaskStatus, WMStask.ToJson(), headers: new Dictionary<string, string>()); |
| | | } |
| | | Db.Ado.CommitTran(); |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | public static string GetEnumDescription<T>(T value) where T : Enum |
| | | { |
| | | FieldInfo fieldInfo = typeof(T).GetField(value.ToString()); |
| | | DescriptionAttribute attribute = (DescriptionAttribute)Attribute.GetCustomAttribute(fieldInfo, typeof(DescriptionAttribute)); |
| | | return attribute?.Description ?? value.ToString(); |
| | | } |
| | | } |
| | | } |