Пример #1
0
        /// <summary>
        /// 在生成任务对象前进行检查。
        /// </summary>
        /// <param name="start">任务起点。</param>
        /// <param name="end">任务终点。</param>
        /// <param name="unitload">要移动的货载。</param>
        /// <exception cref="InvalidOperationException">
        /// </exception>
        void CheckForWcs(Location start, Location end, Unitload unitload)
        {
            // 检查起点
            if (start.Exists == false)
            {
                throw new FailToBuildTaskException(FailtoBuildTaskReason.LocationNotExists);
            }
            if (start.LocationType == LocationTypes.N)
            {
                throw new FailToBuildTaskException(FailtoBuildTaskReason.NForWcsTask);
            }

            if (start.OutboundDisabled)
            {
                throw new FailToBuildTaskException(FailtoBuildTaskReason.OutboundDisabled);
            }

            if (start.OutboundCount >= start.OutboundLimit)
            {
                throw new FailToBuildTaskException(FailtoBuildTaskReason.OutboundLimitReached);
            }

            if (start?.Rack?.Laneway?.Automated == false)
            {
                throw new FailToBuildTaskException(FailtoBuildTaskReason.LanewayNotAutomated);
            }

            if (start.LocationType == LocationTypes.S)
            {
                if (start.Rack.Laneway.Offline)
                {
                    throw new FailToBuildTaskException(FailtoBuildTaskReason.LanewayOffline);
                }


                if (start.Rack.Deep == RackDeep.Deep2)
                {
                    Location deep1 = start.GetDeep1();

                    if (deep1.InboundCount > 0)
                    {
                        throw new FailToBuildTaskException(FailtoBuildTaskReason.DoubleDeepInterference);
                    }
                    if (deep1.Loaded())
                    {
                        throw new FailToBuildTaskException(FailtoBuildTaskReason.DoubleDeepInterference);
                    }
                }
            }

            // 检查货载当前位置和起点的关系
            if (unitload.CurrentLocation == null)
            {
                // noop
            }
            else if (unitload.CurrentLocation.LocationType == LocationTypes.N)
            {
                if (start.LocationType != LocationTypes.K)
                {
                    throw new FailToBuildTaskException(FailtoBuildTaskReason.InvalidStart);
                }
            }
            else
            {
                if (unitload.CurrentLocation != start)
                {
                    throw new FailToBuildTaskException(FailtoBuildTaskReason.InvalidStart);
                }
            }

            // 检查终点
            if (end.Exists == false)
            {
                throw new FailToBuildTaskException(FailtoBuildTaskReason.LocationNotExists);
            }

            if (end.LocationType == LocationTypes.N)
            {
                throw new FailToBuildTaskException(FailtoBuildTaskReason.NForWcsTask);
            }

            if (end.InboundDisabled)
            {
                throw new FailToBuildTaskException(FailtoBuildTaskReason.InboundDisabled);
            }

            if (end.InboundCount >= end.InboundLimit)
            {
                throw new FailToBuildTaskException(FailtoBuildTaskReason.InboundLimitReached);
            }

            if (end?.Rack?.Laneway?.Automated == false)
            {
                throw new FailToBuildTaskException(FailtoBuildTaskReason.LanewayNotAutomated);
            }

            if (end.LocationType == LocationTypes.S)
            {
                if (end.Rack.Laneway.Offline)
                {
                    throw new FailToBuildTaskException(FailtoBuildTaskReason.LanewayOffline);
                }

                if (end.Rack.Deep == RackDeep.Deep2)
                {
                    Location deep1 = end.GetDeep1();

                    if (deep1.Loaded())
                    {
                        throw new FailToBuildTaskException(FailtoBuildTaskReason.DoubleDeepInterference);
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// 生成任务,并保存到数据库。
        /// </summary>
        /// <param name="transTask">空白的、尚未保存到数据库的任务对象。</param>
        /// <param name="start">起点。</param>
        /// <param name="end">终点。</param>
        /// <param name="unitload">要移动的货载。</param>
        /// <param name="taskType">任务类型</param>
        /// <param name="forWcs">是否是为 wcs 准备的。若为 true,则会在生成任务指令之前执行一些检查,例如,货位是否存在,详细的检查规则见 <see cref="CheckForWcs(Location, Location, IEnumerable{Unitload})"/> 方法。</param>
        public async Task BuildAsync(TransportTask transTask, string taskType, Location start, Location end, Unitload unitload, bool forWcs = true)
        {
            if (transTask == null)
            {
                throw new ArgumentNullException(nameof(transTask));
            }

            if (IsBlank(transTask) == false)
            {
                throw new ArgumentException($"transTask 实参不是空白对象,其 Id 值为 {transTask.TaskId}。");
            }

            if (string.IsNullOrWhiteSpace(taskType))
            {
                throw new ArgumentNullException(nameof(taskType));
            }

            if (start == null)
            {
                throw new ArgumentNullException(nameof(start));
            }

            if (end == null)
            {
                throw new ArgumentNullException(nameof(end));
            }

            if (unitload == null)
            {
                throw new ArgumentNullException(nameof(unitload));
            }

            if (start == end)
            {
                throw new FailToBuildTaskException(FailtoBuildTaskReason.StartAndEndArdTheSame);
            }


            // 检查货载
            if (unitload.BeingMoved)
            {
                throw new FailToBuildTaskException(FailtoBuildTaskReason.UnitloadBeingMoved);
            }

            // 检查
            if (forWcs)
            {
                _logger.Debug("这是 WCS 任务,进行生成前检查");
                this.CheckForWcs(start, end, unitload);
                _logger.Debug("检查 WCS 任务通过");
            }

            _logger.Information("正在生成任务");

            // 生成
            transTask.TaskCode = await GetNextTaskCode().ConfigureAwait(false);

            transTask.TaskType = taskType;
            transTask.Start    = start;
            transTask.End      = end;
            transTask.ForWcs   = forWcs;
            transTask.Unitload = unitload;
            await _session.SaveAsync(transTask);

            // 更新货位
            unitload.BeingMoved = true;
            start.OutboundCount++;
            end.InboundCount++;
            _logger.Information("已生成任务,任务号 {taskCode}, 任务类型 {taskType}", transTask.TaskCode, transTask.TaskType);

            bool IsBlank(TransportTask task)
            {
                return(task.TaskId == 0 &&
                       task.TaskCode == null &&
                       task.TaskType == null &&
                       task.Unitload == null &&
                       task.Start == null &&
                       task.End == null);
            }
        }
Пример #3
0
 public virtual string GetContainerSpecification(Unitload unitload)
 {
     return("NA");
 }