| | |
| | | task.Creater = "WMS"; |
| | | if (!int.TryParse(Enum.Parse<TaskOutboundTypeEnum>(task.TaskType.ToString()).ToString(), out int result)) |
| | | { |
| | | List<Dt_Router> routers = _routerService.QueryNextRoutes(item.SourceAddress, item.TargetAddress); |
| | | List<Dt_Router> routers = _routerService.QueryNextRoutes(item.RoadWay, item.TargetAddress); |
| | | //暂不考虑多路径 |
| | | if (routers.Count > 0) |
| | | { |
| | |
| | | return content; |
| | | } |
| | | |
| | | public WebResponseContent RequestWMsTask(string palletCode, string sourceAddress) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | WMSTaskDTO taskDTO = new WMSTaskDTO() |
| | | { |
| | | TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")), |
| | | Grade = 1, |
| | | PalletCode = palletCode, |
| | | RoadWay = "SC01", |
| | | SourceAddress = sourceAddress, |
| | | TargetAddress = "SC01", |
| | | TaskState = (int)TaskInStatusEnum.InNew, |
| | | Id = 0, |
| | | TaskType = (int)TaskInboundTypeEnum.Inbound |
| | | }; |
| | | |
| | | content = ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | public Dt_Task QueryConveyorLineTask(string deviceNo, string currentAddress) |
| | | { |
| | | IEnumerable<int> taskInboundTypes = Enum.GetValues(typeof(TaskInboundTypeEnum)).Cast<int>(); |
| | | IEnumerable<int> taskOutboundTypes = Enum.GetValues(typeof(TaskOutboundTypeEnum)).Cast<int>(); |
| | | |
| | | Dictionary<string, OrderByType> orderBy = new() |
| | | { |
| | | {nameof(Dt_Task.Grade),OrderByType.Desc }, |
| | | {nameof(Dt_Task.CreateDate),OrderByType.Asc}, |
| | | }; |
| | | |
| | | return BaseDal.QueryFirst(x => (x.TaskType >= taskInboundTypes.Min() && x.TaskType <= taskInboundTypes.Max() && x.TaskState == (int)TaskInStatusEnum.InNew || x.TaskType >= taskOutboundTypes.Min() && x.TaskType <= taskOutboundTypes.Max() && x.TaskState == (int)TaskOutStatusEnum.SC_OutFinish) && x.CurrentAddress == currentAddress, orderBy); |
| | | } |
| | | |
| | | public Dt_Task QueryExecutingConveyorLineTask(int taskNum, string nextAddress) |
| | | { |
| | | Dictionary<string, OrderByType> orderBy = new() |
| | | { |
| | | {nameof(Dt_Task.Grade),OrderByType.Desc }, |
| | | {nameof(Dt_Task.CreateDate),OrderByType.Asc}, |
| | | }; |
| | | |
| | | return BaseDal.QueryFirst(x => x.TaskNum == taskNum && x.NextAddress == nextAddress, orderBy); |
| | | } |
| | | |
| | | public Dt_Task QueryCompletedConveyorLineTask(int taskNum, string currentAddress) |
| | | { |
| | | Dictionary<string, OrderByType> orderBy = new() |
| | | { |
| | | {nameof(Dt_Task.Grade),OrderByType.Desc }, |
| | | {nameof(Dt_Task.CreateDate),OrderByType.Asc}, |
| | | }; |
| | | |
| | | return BaseDal.QueryFirst(x => x.TaskNum == taskNum && x.CurrentAddress == currentAddress, orderBy); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据设备编号、当前地址按照优先级以及创建时间排序查询任务池新增的任务 |
| | | /// </summary> |
| | |
| | | if (string.IsNullOrEmpty(currentAddress)) |
| | | return BaseDal.QueryFirst(x => x.Roadway == deviceNo && (x.TaskType >= taskInboundTypes.Min() && x.TaskType <= taskInboundTypes.Max() && x.TaskState == (int)TaskInStatusEnum.Line_InFinish || x.TaskType >= taskOutboundTypes.Min() && x.TaskType <= taskOutboundTypes.Max() && x.TaskState == (int)TaskOutStatusEnum.OutNew), orderBy); |
| | | else |
| | | return BaseDal.QueryFirst(x => x.Roadway == deviceNo && (x.TaskType >= taskInboundTypes.Min() && x.TaskType <= taskInboundTypes.Max() && x.TaskState == (int)TaskInStatusEnum.Line_InFinish || x.TaskType >= taskOutboundTypes.Min() && x.TaskType <= taskOutboundTypes.Max() && x.TaskState == (int)TaskOutStatusEnum.OutNew), orderBy); |
| | | return BaseDal.QueryFirst(x => x.Roadway == deviceNo && x.CurrentAddress == currentAddress && (x.TaskType >= taskInboundTypes.Min() && x.TaskType <= taskInboundTypes.Max() && x.TaskState == (int)TaskInStatusEnum.Line_InFinish || x.TaskType >= taskOutboundTypes.Min() && x.TaskType <= taskOutboundTypes.Max() && x.TaskState == (int)TaskOutStatusEnum.OutNew), orderBy); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | int nextStatus = Enum.GetValues(typeof(TaskInStatusEnum)).Cast<int>().Where(x => x > task.TaskState && x < (int)TaskInStatusEnum.InFinish).OrderBy(x => x).FirstOrDefault(); |
| | | task.TaskState = nextStatus; |
| | | |
| | | if (task.TaskState == (int)TaskInStatusEnum.Line_InFinish) |
| | | { |
| | | Random random = new Random(); |
| | | task.CurrentAddress = task.NextAddress; |
| | | task.NextAddress = $"{random.Next(1, 100).ToString().PadLeft(3, '0')}-{random.Next(1, 100).ToString().PadLeft(3, '0')}-{random.Next(1, 100).ToString().PadLeft(3, '0')}"; |
| | | task.TargetAddress = task.NextAddress; |
| | | } |
| | | } |
| | | else if (!int.TryParse(Enum.Parse<TaskRelocationTypeEnum>(task.TaskType.ToString()).ToString(), out result)) |
| | | { |
| | |
| | | return content = WebResponseContent.Instance.Error($"该任务状态不可跳转到下一步,任务号:【{taskNum}】,任务状态:【{task.TaskState}】"); |
| | | } |
| | | |
| | | if (task.TaskState == (int)TaskInStatusEnum.Line_InFinish || task.TaskState == (int)TaskInStatusEnum.AGV_InFinish || task.TaskState == (int)TaskInStatusEnum.SC_InFinish || task.TaskState == (int)TaskOutStatusEnum.Line_OutFinish || task.TaskState == (int)TaskOutStatusEnum.AGV_OutFinish || task.TaskState == (int)TaskOutStatusEnum.SC_OutFinish) |
| | | { |
| | | List<Dt_Router> routers = _routerService.QueryNextRoutes(task.NextAddress, task.TargetAddress); |
| | | if (!routers.Any()) return WebResponseContent.Instance.Error($"未找到设备路由信息"); |
| | | |
| | | task.CurrentAddress = task.NextAddress; |
| | | task.NextAddress = routers.FirstOrDefault().ChildPosi; |
| | | } |
| | | |
| | | task.ModifyDate = DateTime.Now; |
| | | task.Modifier = "System"; |
| | | BaseDal.UpdateData(task); |
| | |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | public Dt_Task? UpdatePosition(int taskNum, string currentAddress) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum && x.CurrentAddress == currentAddress); |
| | | if (task == null) throw new Exception($"未找到该任务信息,任务号:【{taskNum}】"); |
| | | |
| | | string oldCurrentPos = task.CurrentAddress; |
| | | string oldNextPos = task.NextAddress; |
| | | |
| | | List<Dt_Router> routers = _routerService.QueryNextRoutes(task.NextAddress, task.TargetAddress); |
| | | if (!routers.Any()) throw new Exception($"未找到设备路由信息"); |
| | | |
| | | task.CurrentAddress = task.NextAddress; |
| | | task.NextAddress = routers.FirstOrDefault().ChildPosi; |
| | | |
| | | task.ModifyDate = DateTime.Now; |
| | | task.Modifier = "System"; |
| | | BaseDal.UpdateData(task); |
| | | |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"系统自动流程,更新当前位置【{oldCurrentPos} ----> {task.CurrentAddress}】和下一位置【{oldNextPos} ----> {task.NextAddress}】"); |
| | | return task; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | } |
| | | else if (!int.TryParse(Enum.Parse<TaskInboundTypeEnum>(task.TaskType.ToString()).ToString(), out result) && task.TaskState == (int)TaskInStatusEnum.SC_InExecuting) |
| | | { |
| | | string locationCode = ""; |
| | | //todo |
| | | |
| | | int nextStatus = Enum.GetValues(typeof(TaskInStatusEnum)).Cast<int>().Where(x => x > task.TaskState).OrderBy(x => x).FirstOrDefault(); |
| | | task.TaskState = nextStatus; |
| | | task.CurrentAddress = task.NextAddress; |
| | | task.NextAddress = locationCode; |
| | | |
| | | task.ModifyDate = DateTime.Now; |
| | | task.Modifier = "System"; |
| | | BaseDal.UpdateData(task); |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"堆垛机入库完成"); |
| | | |
| | | WMSTaskDTO taskDTO = new WMSTaskDTO() |
| | | { |
| | | TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")), |
| | | Grade = 1, |
| | | PalletCode = task.PalletCode + "S", |
| | | RoadWay = "SC01", |
| | | SourceAddress = task.TargetAddress, |
| | | TargetAddress = "CLOutAreaA", |
| | | TaskState = (int)TaskOutStatusEnum.OutNew, |
| | | Id = 0, |
| | | TaskType = (int)TaskOutboundTypeEnum.Outbound |
| | | }; |
| | | |
| | | content = ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO }); |
| | | } |
| | | else if (!int.TryParse(Enum.Parse<TaskRelocationTypeEnum>(task.TaskType.ToString()).ToString(), out result)) |
| | | { |