Exemple #1
0
        public async Task 生成任务_如果重复使用任务对象_则会抛出异常()
        {
            var           start      = NewK();
            var           end        = NewK();
            Unitload      unitload1  = new Unitload();
            Unitload      unitload2  = new Unitload();
            TransportTask task       = new TransportTask();
            TaskHelper    taskHelper = new TaskHelper(For <ISession>(),
                                                      For <IAppSeqService>(),
                                                      new UnitloadSnapshopHelper(new DefaultUnitloadSnapshotFactory(), Log.Logger),
                                                      Log.Logger);

            await taskHelper.BuildAsync(task, "test", start, end, unitload1);

            await Assert.ThrowsAsync <ArgumentException>(() => taskHelper.BuildAsync(task, "test", start, end, unitload2));
        }
Exemple #2
0
        public async Task 生成任务_如果在一个货载上生成两个任务_则会抛出异常()
        {
            var           start      = NewK();
            var           end        = NewK();
            Unitload      unitload   = new Unitload();
            TransportTask task       = new TransportTask();
            TransportTask task2      = new TransportTask();
            TaskHelper    taskHelper = new TaskHelper(For <ISession>(),
                                                      For <IAppSeqService>(),
                                                      new UnitloadSnapshopHelper(new DefaultUnitloadSnapshotFactory(), Log.Logger),
                                                      Log.Logger);
            const string taskType = "T";

            await taskHelper.BuildAsync(task, taskType, start, end, unitload);

            var ex = await Assert.ThrowsAsync <FailToBuildTaskException>(() => taskHelper.BuildAsync(task2, taskType, start, end, unitload));

            Assert.Equal(FailtoBuildTaskReason.UnitloadBeingMoved, ex.Reason);
        }
Exemple #3
0
        public async Task 生成任务_显式指定ForWcs参数_检查任务的ForWcs属性()
        {
            var           start      = NewK();
            var           end        = NewK();
            Unitload      unitload1  = new Unitload();
            Unitload      unitload2  = new Unitload();
            TransportTask task1      = new TransportTask();
            TransportTask task2      = new TransportTask();
            TaskHelper    taskHelper = new TaskHelper(For <ISession>(),
                                                      For <IAppSeqService>(),
                                                      new UnitloadSnapshopHelper(new DefaultUnitloadSnapshotFactory(), Log.Logger),
                                                      Log.Logger);
            const string taskType = "T";

            await taskHelper.BuildAsync(task1, taskType, start, end, unitload1, true);

            await taskHelper.BuildAsync(task2, taskType, start, end, unitload2, false);

            Assert.True(task1.ForWcs);
            Assert.False(task2.ForWcs);
        }
Exemple #4
0
        public async Task 生成任务_如果超过起点的出站数限制_则会抛出异常()
        {
            var start = NewK();

            start.OutboundLimit = 1;
            var           end        = NewS();
            Unitload      unitload   = new Unitload();
            Unitload      unitload2  = new Unitload();
            TransportTask task1      = new TransportTask();
            TransportTask task2      = new TransportTask();
            TaskHelper    taskHelper = new TaskHelper(For <ISession>(),
                                                      For <IAppSeqService>(),
                                                      new UnitloadSnapshopHelper(new DefaultUnitloadSnapshotFactory(), Log.Logger),
                                                      Log.Logger);
            const string taskType = "T";

            await taskHelper.BuildAsync(task1, taskType, start, end, unitload);

            var ex = await Assert.ThrowsAsync <FailToBuildTaskException>(() => taskHelper.BuildAsync(task2, taskType, start, end, unitload2));

            Assert.Equal(FailtoBuildTaskReason.OutboundLimitReached, ex.Reason);
        }
Exemple #5
0
        public async Task 生成任务_如果以N位置作为终点生成非WCS任务_则不会抛出异常()
        {
            var      start    = NewK();
            var      end      = NewN();
            Unitload unitload = new Unitload();

            unitload.Enter(start);
            TransportTask task       = new TransportTask();
            TaskHelper    taskHelper = new TaskHelper(For <ISession>(),
                                                      For <IAppSeqService>(),
                                                      new UnitloadSnapshopHelper(new DefaultUnitloadSnapshotFactory(), Log.Logger),
                                                      Log.Logger);

            await taskHelper.BuildAsync(task, "A", start, end, unitload, false);
        }
Exemple #6
0
        public async Task 生成任务_如果终点禁止入站_则可以生成非WCS任务()
        {
            var start = NewK();
            var end   = NewK();

            end.InboundDisabled = true;
            Unitload      unitload1  = new Unitload();
            TransportTask task1      = new TransportTask();
            TaskHelper    taskHelper = new TaskHelper(For <ISession>(),
                                                      For <IAppSeqService>(),
                                                      new UnitloadSnapshopHelper(new DefaultUnitloadSnapshotFactory(), Log.Logger),
                                                      Log.Logger);

            await taskHelper.BuildAsync(task1, "T", start, end, unitload1, false);
        }
Exemple #7
0
        public async Task 生成任务_如果起点和终点相同_则会抛出异常()
        {
            Location      start      = NewK();
            Location      end        = start;
            Unitload      unitload   = new Unitload();
            TransportTask task       = new TransportTask();
            TaskHelper    taskHelper = new TaskHelper(For <ISession>(),
                                                      For <IAppSeqService>(),
                                                      new UnitloadSnapshopHelper(new DefaultUnitloadSnapshotFactory(), Log.Logger),
                                                      Log.Logger);
            const string taskType = "T";

            var ex = await Assert.ThrowsAsync <FailToBuildTaskException>(() => taskHelper.BuildAsync(task, taskType, start, end, unitload));

            Assert.Equal(FailtoBuildTaskReason.StartAndEndArdTheSame, ex.Reason);
        }
Exemple #8
0
        public async Task 生成任务_货载会被标记为正在移动()
        {
            var           start      = NewK();
            var           end        = NewK();
            Unitload      unitload   = new Unitload();
            TransportTask task       = new TransportTask();
            TaskHelper    taskHelper = new TaskHelper(For <ISession>(),
                                                      For <IAppSeqService>(),
                                                      new UnitloadSnapshopHelper(new DefaultUnitloadSnapshotFactory(), Log.Logger),
                                                      Log.Logger);
            const string taskType = "T";

            await taskHelper.BuildAsync(task, taskType, start, end, unitload);

            Assert.True(unitload.BeingMoved);
        }
Exemple #9
0
        public async Task 生成任务_终点的入站数会增加()
        {
            var           start      = NewK();
            var           end        = NewK();
            Unitload      unitload   = new Unitload();
            TransportTask task       = new TransportTask();
            TaskHelper    taskHelper = new TaskHelper(For <ISession>(),
                                                      For <IAppSeqService>(),
                                                      new UnitloadSnapshopHelper(new DefaultUnitloadSnapshotFactory(), Log.Logger),
                                                      Log.Logger);
            const string taskType = "T";

            await taskHelper.BuildAsync(task, taskType, start, end, unitload);

            Assert.Equal(1, end.InboundCount);
        }
Exemple #10
0
        public async Task 生成任务_如果以N位置作为终点生成WCS任务_则会抛出异常()
        {
            var      start    = NewK();
            var      end      = NewN();
            Unitload unitload = new Unitload();

            unitload.Enter(start);
            TransportTask task       = new TransportTask();
            TaskHelper    taskHelper = new TaskHelper(For <ISession>(),
                                                      For <IAppSeqService>(),
                                                      new UnitloadSnapshopHelper(new DefaultUnitloadSnapshotFactory(), Log.Logger),
                                                      Log.Logger);

            var ex = await Assert.ThrowsAsync <FailToBuildTaskException>(() => taskHelper.BuildAsync(task, "A", start, end, unitload));

            Assert.Equal(FailtoBuildTaskReason.NForWcsTask, ex.Reason);
        }
Exemple #11
0
        public async Task 生成任务_如果终点禁止入站_则不可生成WCS任务()
        {
            var start = NewK();
            var end   = NewK();

            end.InboundDisabled = true;
            Unitload      unitload1  = new Unitload();
            TransportTask task1      = new TransportTask();
            TaskHelper    taskHelper = new TaskHelper(For <ISession>(),
                                                      For <IAppSeqService>(),
                                                      new UnitloadSnapshopHelper(new DefaultUnitloadSnapshotFactory(), Log.Logger),
                                                      Log.Logger);

            var ex = await Assert.ThrowsAsync <FailToBuildTaskException>(() => taskHelper.BuildAsync(task1, "T", start, end, unitload1));

            Assert.Equal(FailtoBuildTaskReason.InboundDisabled, ex.Reason);
        }
Exemple #12
0
        public async Task 生成任务_如果货载在非N位置上_则任务起点必须与货载当前位置一致()
        {
            var      start    = NewK();
            var      end      = NewS();
            Unitload unitload = new Unitload();

            unitload.Enter(NewK());
            TransportTask task       = new TransportTask();
            TaskHelper    taskHelper = new TaskHelper(For <ISession>(),
                                                      For <IAppSeqService>(),
                                                      new UnitloadSnapshopHelper(new DefaultUnitloadSnapshotFactory(), Log.Logger),
                                                      Log.Logger);

            var ex = await Assert.ThrowsAsync <FailToBuildTaskException>(() => taskHelper.BuildAsync(task, "test", start, end, unitload));

            Assert.Equal(FailtoBuildTaskReason.InvalidStart, ex.Reason);
        }
Exemple #13
0
        public async Task 取消任务_如果起点不是N位置_则货载保持在原位置上()
        {
            var      start    = NewK();
            var      end      = NewK();
            Unitload unitload = new Unitload();

            unitload.Enter(start);
            TransportTask task       = new TransportTask();
            TaskHelper    taskHelper = new TaskHelper(For <ISession>(),
                                                      For <IAppSeqService>(),
                                                      new UnitloadSnapshopHelper(new DefaultUnitloadSnapshotFactory(), Log.Logger),
                                                      Log.Logger);
            await taskHelper.BuildAsync(task, "A", start, end, unitload);

            await taskHelper.CancelAsync(task);

            Assert.Same(start, unitload.CurrentLocation);
        }
Exemple #14
0
        public async Task 取消任务_检查货载属性()
        {
            var      start    = NewK();
            var      end      = NewK();
            Unitload unitload = new Unitload();

            unitload.Enter(start);
            TransportTask task       = new TransportTask();
            TaskHelper    taskHelper = new TaskHelper(For <ISession>(),
                                                      For <IAppSeqService>(),
                                                      new UnitloadSnapshopHelper(new DefaultUnitloadSnapshotFactory(), Log.Logger),
                                                      Log.Logger);
            await taskHelper.BuildAsync(task, "A", start, end, unitload);

            await taskHelper.CancelAsync(task);

            Assert.False(unitload.BeingMoved);
        }
Exemple #15
0
        public async Task 取消任务_起点的出站数会减少()
        {
            var      start    = NewK();
            var      end      = NewK();
            Unitload unitload = new Unitload();

            unitload.Enter(start);
            TransportTask task       = new TransportTask();
            TaskHelper    taskHelper = new TaskHelper(For <ISession>(),
                                                      For <IAppSeqService>(),
                                                      new UnitloadSnapshopHelper(new DefaultUnitloadSnapshotFactory(), Log.Logger),
                                                      Log.Logger);
            await taskHelper.BuildAsync(task, "A", start, end, unitload);

            await taskHelper.CancelAsync(task);

            Assert.Equal(0, start.OutboundCount);
        }
Exemple #16
0
        public async Task 完成任务_如果指定了实际终点_则货载被放在指定的位置上()
        {
            var      start     = NewK();
            var      end       = NewS();
            var      actualEnd = NewS();
            Unitload unitload  = new Unitload();

            unitload.Enter(start);
            TransportTask task       = new TransportTask();
            TaskHelper    taskHelper = new TaskHelper(For <ISession>(),
                                                      For <IAppSeqService>(),
                                                      new UnitloadSnapshopHelper(new DefaultUnitloadSnapshotFactory(), Log.Logger),
                                                      Log.Logger);
            await taskHelper.BuildAsync(task, "A", start, end, unitload);

            await taskHelper.CompleteAsync(task, actualEnd);

            Assert.Same(actualEnd, unitload.CurrentLocation);
        }
Exemple #17
0
        public async Task 生成任务_检查任务属性()
        {
            var           start      = NewK();
            var           end        = NewK();
            Unitload      unitload   = new Unitload();
            TransportTask task       = new TransportTask();
            TaskHelper    taskHelper = new TaskHelper(For <ISession>(),
                                                      For <IAppSeqService>(),
                                                      new UnitloadSnapshopHelper(new DefaultUnitloadSnapshotFactory(), Log.Logger),
                                                      Log.Logger);
            const string taskType = "T";

            await taskHelper.BuildAsync(task, taskType, start, end, unitload);

            Assert.Same(start, task.Start);
            Assert.Same(end, task.End);
            Assert.Same(unitload, task.Unitload);
            Assert.Equal(taskType, task.TaskType);
        }
Exemple #18
0
        public async Task 生成任务_如果货载在N位置上_则任务起点可以为K位置()
        {
            var      start    = NewK();
            var      end      = NewS();
            var      n        = NewN();
            Unitload unitload = new Unitload();

            unitload.Enter(n);
            TransportTask task       = new TransportTask();
            TaskHelper    taskHelper = new TaskHelper(For <ISession>(),
                                                      For <IAppSeqService>(),
                                                      new UnitloadSnapshopHelper(new DefaultUnitloadSnapshotFactory(), Log.Logger),
                                                      Log.Logger);

            await taskHelper.BuildAsync(task, "A", start, end, unitload);

            Assert.Same(n, unitload.CurrentLocation);
            Assert.Same(start, task.Start);
            Assert.Equal(0, n.UnitloadCount);
            Assert.Equal(0, n.OutboundCount);
            Assert.Equal(1, start.OutboundCount);
        }
        public async Task ProcessRequestAsync(RequestInfo requestInfo)
        {
            _logger.Debug(requestInfo.ToString());
            CheckRequest(requestInfo);

            // 1 入口
            string entranceLocationCode = requestInfo.LocationCode;
            var    entrance             = await _session.Query <Location>().GetAsync(entranceLocationCode).ConfigureAwait(false);

            if (entrance == null)
            {
                string msg = string.Format("请求位置在 Wms 中不存在。【{0}】。", entranceLocationCode);
                throw new InvalidRequestException(msg);
            }

            // 2 托盘
            string containerCode = requestInfo.PalletCode;
            var    unitload      = await _session.Query <Unitload>().GetAsync(containerCode).ConfigureAwait(false);

            if (unitload == null)
            {
                string msg = string.Format("货载不存在。容器编码【{0}】。", containerCode);
                throw new InvalidRequestException(msg);
            }

            // 将请求中的高度和重量记录到货载
            unitload.StorageInfo.Height = requestInfo.Height;
            unitload.StorageInfo.Weight = requestInfo.Weight;

            // 3 分配货位
            SResult s        = SResult.Failure;
            var     laneways = _session.Query <Laneway>().Take(5).ToArray();

            foreach (var laneway in laneways)
            {
                _logger.Debug("正在检查巷道 {lanewayCode}", laneway.LanewayCode);
                if (laneway.Offline)
                {
                    _logger.Warning("跳过脱机的巷道 {lanewayCode}", laneway.LanewayCode);
                    continue;
                }

                s = await _sallocHelper.AllocateAsync(laneway, unitload.StorageInfo).ConfigureAwait(false);

                if (s.Success)
                {
                    _logger.Information("在 {lanewayCode} 分配到货位 {locationCode}", laneway.LanewayCode, s.Target.LocationCode);
                    break;
                }
                else
                {
                    _logger.Information("在 {lanewayCode} 未分配到货位。", laneway.LanewayCode);
                    continue;
                }
            }
            if (s.Success == false)
            {
                // 分配货位失败
                throw new Exception("未分配到货位。");
            }

            // 4 生成任务
            var    task     = new TransportTask();
            string taskType = "上架";
            await _taskHelper.BuildAsync(task, taskType, entrance, s.Target, unitload);

            // 5 下发任务
            _taskSender.SendTask(task);
        }