Esempio n. 1
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (!DesignerProperties.GetIsInDesignMode(this))
            {
                this.AST_PalletTaskItem = null;
            }

            this.opacityAnimation = new DoubleAnimation(0.5, 1, TimeSpan.FromMilliseconds(400));
            this.opacityAnimation.RepeatBehavior = RepeatBehavior.Forever;
            this.opacityAnimation.AutoReverse    = true;
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            AST_PalletTaskItemDto dto = (AST_PalletTaskItemDto)value;

            if (dto.IsSpecial)
            {
                return(string.IsNullOrEmpty(dto.MaterialBarcode) ? "√" : dto.MaterialBarcode);
            }
            else
            {
                return(string.Empty);
            }
        }
Esempio n. 3
0
        void RefreshUI()
        {
            if (this.astPalletTask == null)
            {
                this.boxUserControl1.AST_PalletTaskItem = null;
                this.boxUserControl2.AST_PalletTaskItem = null;
                this.boxUserControl3.AST_PalletTaskItem = null;
                this.boxUserControl4.AST_PalletTaskItem = null;
                this.boxUserControl5.AST_PalletTaskItem = null;
            }
            else
            {
                if (this.astPalletTask.PalletType == "04") //标准箱托盘
                {
                    this.Visibility = Visibility.Collapsed;
                    return;
                }
                else
                {
                    this.Visibility = Visibility.Visible;
                }

                AST_PalletTaskItemDto astPalletTaskItem1 = this.astPalletTask.Items.FirstOrDefault(pti => pti.FromPalletPosition == 1);
                AST_PalletTaskItemDto astPalletTaskItem2 = this.astPalletTask.Items.FirstOrDefault(pti => pti.FromPalletPosition == 2);
                AST_PalletTaskItemDto astPalletTaskItem3 = this.astPalletTask.Items.FirstOrDefault(pti => pti.FromPalletPosition == 3);
                AST_PalletTaskItemDto astPalletTaskItem4 = this.astPalletTask.Items.FirstOrDefault(pti => pti.FromPalletPosition == 4);
                AST_PalletTaskItemDto astPalletTaskItem5 = this.astPalletTask.Items.FirstOrDefault(pti => pti.FromPalletPosition == 5);

                this.boxUserControl1.AST_PalletTaskItem = astPalletTaskItem1;
                this.boxUserControl2.AST_PalletTaskItem = astPalletTaskItem2;
                this.boxUserControl3.AST_PalletTaskItem = astPalletTaskItem3;
                this.boxUserControl4.AST_PalletTaskItem = astPalletTaskItem4;
                this.boxUserControl5.AST_PalletTaskItem = astPalletTaskItem5;
            }

            //托盘类型
            if (this.astPalletTask != null)
            {
                if (this.astPalletTask.PalletType == "01")
                {
                    this.column1.Width = new GridLength(0.5, GridUnitType.Star);
                    this.column2.Width = new GridLength(0.5, GridUnitType.Star);
                    this.column3.Width = new GridLength(1, GridUnitType.Star);
                    this.row1.Height   = new GridLength(0.6, GridUnitType.Star);
                }
                else
                {
                    this.column1.Width = new GridLength(0);
                    this.column2.Width = new GridLength(0);
                    this.column3.Width = new GridLength(0);
                    this.row1.Height   = new GridLength(0);
                }
            }

            //托盘方向与旋转
            if (this.astPalletTask == null)
            {
                this.inAnimation = true;

                this.translateTransform.BeginAnimation(TranslateTransform.YProperty, null);
                this.rotateTransform.BeginAnimation(RotateTransform.AngleProperty, null);

                this.translateTransform.Y  = 0;
                this.rotateTransform.Angle = 0;

                this.boxUserControl1.Rotate(0);
                this.boxUserControl2.Rotate(0);
                this.boxUserControl3.Rotate(0);
                this.boxUserControl4.Rotate(0);
                this.boxUserControl5.Rotate(0);

                this.inAnimation = false;
            }
            else
            {
                if (!this.inAnimation)
                {
                    this.inAnimation = true;

                    if (this.astPalletTask.PalletRotationStatus == PalletRotationStatus.Normal)
                    {
                        this.translateTransform.BeginAnimation(TranslateTransform.YProperty, null);
                        this.rotateTransform.BeginAnimation(RotateTransform.AngleProperty, null);

                        this.translateTransform.Y  = 0;
                        this.rotateTransform.Angle = 0;

                        this.boxUserControl1.Rotate(0);
                        this.boxUserControl2.Rotate(0);
                        this.boxUserControl3.Rotate(0);
                        this.boxUserControl4.Rotate(0);
                        this.boxUserControl5.Rotate(0);

                        this.inAnimation = false;
                    }
                    else if (this.astPalletTask.PalletRotationStatus == PalletRotationStatus.BeginRotation)
                    {
                        DoubleAnimation upAnimation = new DoubleAnimation(0, -50, PalletUserControl.UpTimeSpan);
                        upAnimation.Completed += (sender1, e1) =>
                        {
                            Thread.Sleep(PalletUserControl.ActionSplitTimeSpan);

                            DoubleAnimation angleAnimation = new DoubleAnimation(0, 180, PalletUserControl.RotationTimeSpan);
                            angleAnimation.Completed += (sender2, e2) =>
                            {
                                Thread.Sleep(PalletUserControl.ActionSplitTimeSpan);

                                DoubleAnimation downAnimation = new DoubleAnimation(-50, 0, PalletUserControl.DownTimeSpan);
                                downAnimation.Completed += (sender3, e3) =>
                                {
                                    this.inAnimation = false;
                                };
                                this.translateTransform.BeginAnimation(TranslateTransform.YProperty, downAnimation);
                            };
                            this.rotateTransform.BeginAnimation(RotateTransform.AngleProperty, angleAnimation);
                        };
                        this.translateTransform.BeginAnimation(TranslateTransform.YProperty, upAnimation);
                    }
                    else if (this.astPalletTask.PalletRotationStatus == PalletRotationStatus.Reversed)
                    {
                        this.translateTransform.BeginAnimation(TranslateTransform.YProperty, null);
                        this.rotateTransform.BeginAnimation(RotateTransform.AngleProperty, null);

                        this.translateTransform.Y  = 0;
                        this.rotateTransform.Angle = 180;

                        this.boxUserControl1.Rotate(180);
                        this.boxUserControl2.Rotate(180);
                        this.boxUserControl3.Rotate(180);
                        this.boxUserControl4.Rotate(180);
                        this.boxUserControl5.Rotate(180);

                        this.inAnimation = false;
                    }
                    else if (this.astPalletTask.PalletRotationStatus == PalletRotationStatus.BeginReverseRotation)
                    {
                        DoubleAnimation upAnimation = new DoubleAnimation(0, -50, PalletUserControl.UpTimeSpan);
                        upAnimation.Completed += (sender1, e1) =>
                        {
                            Thread.Sleep(PalletUserControl.ActionSplitTimeSpan);

                            DoubleAnimation angleAnimation = new DoubleAnimation(180, 0, PalletUserControl.ReverseRotationTimeSpan);
                            angleAnimation.Completed += (sender2, e2) =>
                            {
                                Thread.Sleep(PalletUserControl.ActionSplitTimeSpan);

                                DoubleAnimation downAnimation = new DoubleAnimation(-50, 0, PalletUserControl.DownTimeSpan);
                                downAnimation.Completed += (sender3, e3) =>
                                {
                                    this.inAnimation = false;
                                };
                                this.translateTransform.BeginAnimation(TranslateTransform.YProperty, downAnimation);
                            };
                            this.rotateTransform.BeginAnimation(RotateTransform.AngleProperty, angleAnimation);
                        };
                        this.translateTransform.BeginAnimation(TranslateTransform.YProperty, upAnimation);
                    }
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 按巷道查询当前PDA任务。
        /// </summary>
        /// <param name="cfgChannelId">巷道的主键。</param>
        /// <param name="dPtlPalletLastArriveTime">PTL托盘最后到达时间。</param>
        private AssortingKanbanTaskInfo QueryPDACurrentTaskInfo(int cfgChannelId, DateTime dPtlPalletLastArriveTime)
        {
            AssortingKanbanTaskInfo result = new AssortingKanbanTaskInfo();

            try
            {
                using (GeelyPtlEntities dbContext = new GeelyPtlEntities())
                {
                    DateTime minTime = DateTime.Today;
                    DateTime maxTime = minTime.AddDays(1);

                    AST_PalletTask_PDA astPalletTask = null;
                    if (dPtlPalletLastArriveTime == DateTime.MinValue)
                    {
                        astPalletTask = dbContext.AST_PalletTask_PDAs
                                        .Where(pt => pt.CFG_ChannelId == cfgChannelId && pt.PickStatus != PickStatus.Finished && pt.CreateTime > minTime && pt.CreateTime < maxTime)
                                        .OrderByDescending(pt => pt.Id)
                                        .FirstOrDefault();
                    }
                    else
                    {
                        astPalletTask = dbContext.AST_PalletTask_PDAs
                                        .Where(pt => pt.CFG_ChannelId == cfgChannelId && pt.PickStatus != PickStatus.Finished && pt.CreateTime > minTime && pt.CreateTime <maxTime &&
                                                                                                                                                                           pt.CreateTime> dPtlPalletLastArriveTime)
                                        .OrderByDescending(pt => pt.Id)
                                        .FirstOrDefault();
                    }

                    //AST_PalletTask_PDA astPalletTask = dbContext.AST_PalletTask_PDAs
                    //                                   .Where(pt => pt.CFG_ChannelId == cfgChannelId && pt.PickStatus != PickStatus.Finished && pt.CreateTime > minTime && pt.CreateTime < maxTime)
                    //                                   .OrderByDescending(pt => pt.Id)
                    //                                   .FirstOrDefault();

                    //AST_CartTask astCartTask = dbContext.AST_CartTaskItems
                    //                               .Where(cti => cti.AST_CartTask.CFG_ChannelId == cfgChannelId && cti.AssortingStatus != AssortingStatus.Finished)
                    //                               .Select(cti => cti.AST_CartTask)
                    //                               .FirstOrDefault();

                    if (astPalletTask == null)
                    {
                        result = null;
                        return(result);
                    }

                    string currentBatchCode = astPalletTask.BatchCode;

                    if (!string.IsNullOrEmpty(currentBatchCode))
                    {
                        AST_LesTask_PDA currentBatchFirstAstLesTask = dbContext.AST_LesTask_PDAs
                                                                      .Where(lt => lt.CFG_ChannelId == cfgChannelId && lt.BatchCode == currentBatchCode && lt.CFG_PalletId == astPalletTask.CFG_PalletId)
                                                                      .OrderByDescending(lt => lt.Id).FirstOrDefault();

                        result.CurrentBatchInfo.PickType = ConverterPickTypeToText(currentBatchFirstAstLesTask.WbsId); //PDA手持机拣料
                        //result.CurrentBatchInfo.PickType = currentBatchFirstAstLesTask.WbsId; //PDA手持机拣料
                        //result.CurrentBatchInfo.PickType = 2; //PDA手持机拣料
                        result.CurrentBatchInfo.ProjectCode         = currentBatchFirstAstLesTask.ProjectCode;
                        result.CurrentBatchInfo.ProjectStep         = currentBatchFirstAstLesTask.ProjectStep;
                        result.CurrentBatchInfo.BatchCode           = currentBatchFirstAstLesTask.BatchCode;
                        result.CurrentBatchInfo.FinishedPalletCount = dbContext.AST_PalletTask_PDAs
                                                                      .Count(pr => pr.CFG_ChannelId == cfgChannelId && pr.BatchCode == currentBatchCode && pr.PickStatus == PickStatus.Finished);
                        //result.CurrentBatchInfo.FinishedPalletCount = 0;
                        result.CurrentBatchInfo.TotalPalletCount = dbContext.AST_LesTask_PDAs
                                                                   .Where(lt => lt.CFG_ChannelId == cfgChannelId && lt.BatchCode == currentBatchCode)
                                                                   .Select(lt => lt.CFG_PalletId)
                                                                   .Distinct()
                                                                   .Count();
                        //以下 4 个汇总界面不展示
                        result.CurrentBatchInfo.FinishedMaterialTypeCount = 0;
                        result.CurrentBatchInfo.TotalMaterialTypeCount    = 0;
                        result.CurrentBatchInfo.FinishedMaterialCount     = 0;
                        result.CurrentBatchInfo.TotalMaterialCount        = 0;

                        List <CFG_ChannelCurrentCart> cfgChannelCurrentCarts = dbContext.CFG_ChannelCurrentCarts
                                                                               .Where(ccc => ccc.CFG_ChannelId == cfgChannelId)
                                                                               .OrderBy(ccc => ccc.Position)
                                                                               .ToList();
                        foreach (CFG_ChannelCurrentCart cfgChannelCurrentCart in cfgChannelCurrentCarts)
                        {
                            CFG_ChannelCurrentCartDto cfgChannelCurrentCartDto = new CFG_ChannelCurrentCartDto();
                            cfgChannelCurrentCartDto.CFG_ChannelCurrentCartId = cfgChannelCurrentCart.Id;
                            cfgChannelCurrentCartDto.CFG_ChannelId            = cfgChannelCurrentCart.CFG_ChannelId;
                            cfgChannelCurrentCartDto.Position   = cfgChannelCurrentCart.Position;
                            cfgChannelCurrentCartDto.CFG_CartId = cfgChannelCurrentCart.CFG_CartId;
                            if (cfgChannelCurrentCart.CFG_Cart != null)
                            {
                                cfgChannelCurrentCartDto.CartCode = cfgChannelCurrentCart.CFG_Cart.Code;
                                cfgChannelCurrentCartDto.CartName = cfgChannelCurrentCart.CFG_Cart.Name;
                            }
                        }

                        if (astPalletTask != null)
                        {
                            AST_PalletTaskDto astPalletTaskDto = new AST_PalletTaskDto();
                            astPalletTaskDto.AST_PalletTaskId     = astPalletTask.Id;
                            astPalletTaskDto.CFG_PalletId         = astPalletTask.CFG_PalletId;
                            astPalletTaskDto.PalletCode           = astPalletTask.CFG_Pallet.Code;
                            astPalletTaskDto.PalletType           = astPalletTask.CFG_Pallet.PalletType;
                            astPalletTaskDto.PalletRotationStatus = astPalletTask.CFG_Pallet.PalletRotationStatus;

                            List <AST_PalletTaskItem_PDA> astPalletTaskItems = astPalletTask.AST_PalletTaskItem_PDAs
                                                                               .OrderBy(pti => pti.FromPalletPosition)
                                                                               .ToList();
                            foreach (AST_PalletTaskItem_PDA astPalletTaskItem in astPalletTaskItems)
                            {
                                AST_PalletTaskItemDto astPalletTaskItemDto = new AST_PalletTaskItemDto();
                                astPalletTaskItemDto.AST_PalletTaskItemId = astPalletTaskItem.Id;
                                astPalletTaskItemDto.FromPalletPosition   = astPalletTaskItem.FromPalletPosition;
                                astPalletTaskItemDto.WorkStationCode      = astPalletTaskItem.CFG_WorkStation.Code;
                                astPalletTaskItemDto.MaterialCode         = astPalletTaskItem.MaterialCode;
                                astPalletTaskItemDto.MaterialName         = astPalletTaskItem.MaterialName;
                                astPalletTaskItemDto.MaterialBarcode      = astPalletTaskItem.MaterialBarcode;
                                astPalletTaskItemDto.ToPickQuantity       = astPalletTaskItem.ToPickQuantity;
                                astPalletTaskItemDto.IsSpecial            = astPalletTaskItem.IsSpecial;
                                astPalletTaskItemDto.IsBig          = astPalletTaskItem.IsBig;
                                astPalletTaskItemDto.PickStatus     = astPalletTaskItem.PickStatus;
                                astPalletTaskItemDto.PickedQuantity = astPalletTaskItem.PickedQuantity;

                                astPalletTaskDto.Items.Add(astPalletTaskItemDto);
                            }

                            result.CurrentPalletTask = astPalletTaskDto;
                        }

                        //if (astCartTask != null)
                        //{
                        //    AST_CartTaskDto astCartTaskDto = new AST_CartTaskDto();
                        //    astCartTaskDto.AST_CartTaskId = astCartTask.Id;
                        //    astCartTaskDto.CFG_CartId = astCartTask.CFG_CartId;
                        //    astCartTaskDto.CartCode = astCartTask.CFG_Cart.Code;
                        //    astCartTaskDto.CartName = astCartTask.CFG_Cart.Name;

                        //    List<AST_CartTaskItem> astCartTaskItems = astCartTask.AST_CartTaskItems
                        //                                                  .OrderBy(cti => cti.CartPosition)
                        //                                                  .ToList();
                        //    foreach (AST_CartTaskItem astCartTaskItem in astCartTaskItems)
                        //    {
                        //        AST_PalletTaskItem astPalletTaskItem = astCartTaskItem.AST_PalletTaskItem;

                        //        AST_CartTaskItemDto astCartTaskItemDto = new AST_CartTaskItemDto();
                        //        astCartTaskItemDto.AST_CartTaskItemId = astCartTaskItem.Id;
                        //        astCartTaskItemDto.CartPosition = astCartTaskItem.CartPosition;
                        //        astCartTaskItemDto.WorkStationCode = astCartTask.CFG_WorkStation.Code;
                        //        astCartTaskItemDto.MaterialCode = astPalletTaskItem.MaterialCode;
                        //        astCartTaskItemDto.MaterialName = astPalletTaskItem.MaterialName;
                        //        astCartTaskItemDto.MaterialBarcode = astPalletTaskItem.MaterialBarcode;
                        //        astCartTaskItemDto.MaxQuantityInSingleCartPosition = astPalletTaskItem.MaxQuantityInSingleCartPosition;
                        //        astCartTaskItemDto.IsSpecial = astPalletTaskItem.IsSpecial;
                        //        astCartTaskItemDto.IsBig = astPalletTaskItem.IsBig;
                        //        astCartTaskItemDto.AssortingStatus = astCartTaskItem.AssortingStatus;
                        //        astCartTaskItemDto.PickedQuantity = astCartTaskItem.AssortedQuantity;

                        //        astCartTaskDto.Items.Add(astCartTaskItemDto);
                        //    }

                        //    result.CurrentCartTask = astCartTaskDto;
                        //}
                    }
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                DbEntityValidationException dbEntityValidationException = ex as DbEntityValidationException;
                if (dbEntityValidationException != null)
                {
                    foreach (DbEntityValidationResult validationResult in dbEntityValidationException.EntityValidationErrors)
                    {
                        foreach (DbValidationError validationError in validationResult.ValidationErrors)
                        {
                            message += Environment.NewLine + validationError.ErrorMessage;
                        }
                    }
                }
                message += Environment.NewLine + ex.StackTrace;

                Logger.Log("ForAssortingKanbanService.QueryPDACurrentTaskInfo", DateTime.Now.ToString("HH:mm:ss") + Environment.NewLine
                           + message + Environment.NewLine
                           + Environment.NewLine);
            }

            return(result);
        }
Esempio n. 5
0
        /// <summary>
        /// 按巷道查询当前任务。
        /// </summary>
        /// <param name="cfgChannelId">巷道的主键。</param>
        public AssortingKanbanTaskInfo QueryCurrentTaskInfo(int cfgChannelId)
        {
            AssortingKanbanTaskInfo result = new AssortingKanbanTaskInfo();

            try
            {
                using (GeelyPtlEntities dbContext = new GeelyPtlEntities())
                {
                    AST_PalletTask astPalletTask = dbContext.AST_PalletTasks
                                                   .FirstOrDefault(pt => pt.CFG_ChannelId == cfgChannelId && pt.PickStatus != PickStatus.Finished);
                    //新增PDA拣料显示
                    if (astPalletTask == null)
                    {
                        AST_PalletTask lastPalletTask           = dbContext.AST_PalletTasks.Where(t => t.CFG_ChannelId == cfgChannelId).OrderByDescending(t => t.CreateTime).FirstOrDefault();
                        DateTime       dPtlPalletLastArriveTime = DateTime.MinValue;
                        if (lastPalletTask != null)
                        {
                            dPtlPalletLastArriveTime = lastPalletTask.CreateTime;
                        }

                        result = QueryPDACurrentTaskInfo(cfgChannelId, dPtlPalletLastArriveTime);
                        if (result != null)
                        {
                            return(result);
                        }
                        result = new AssortingKanbanTaskInfo();
                    }

                    AST_CartTask astCartTask = dbContext.AST_CartTaskItems
                                               .Where(cti => cti.AST_CartTask.CFG_ChannelId == cfgChannelId && cti.AssortingStatus != AssortingStatus.Finished)
                                               .Select(cti => cti.AST_CartTask)
                                               .FirstOrDefault();

                    string currentBatchCode;
                    if (astPalletTask == null)
                    {
                        currentBatchCode = dbContext.AST_LesTasks
                                           .Where(lt => lt.CFG_ChannelId == cfgChannelId && !lt.TaskGenerated)
                                           .Select(lt => lt.BatchCode)
                                           .FirstOrDefault();
                    }
                    else
                    {
                        currentBatchCode = astPalletTask.BatchCode;
                    }

                    if (!string.IsNullOrEmpty(currentBatchCode))
                    {
                        AST_LesTask currentBatchFirstAstLesTask = new AST_LesTask();
                        if (astPalletTask == null)
                        {
                            currentBatchFirstAstLesTask = dbContext.AST_LesTasks.First(lt => lt.BatchCode == currentBatchCode);
                        }
                        else
                        {
                            currentBatchFirstAstLesTask = dbContext.AST_LesTasks.First(lt => lt.BatchCode == currentBatchCode && lt.CFG_PalletId == astPalletTask.CFG_PalletId);
                        }

                        string projectCode = currentBatchFirstAstLesTask.ProjectCode;
                        string projectStep = currentBatchFirstAstLesTask.ProjectStep;

                        string[] codes = projectCode.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        string[] steps = projectStep.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        if (codes.Length > 1 && codes[0] == codes[1])
                        {
                            projectCode = codes[0];
                        }
                        if (steps.Length > 1 && steps[0] == steps[1])
                        {
                            projectStep = steps[0];
                        }

                        result.CurrentBatchInfo.PickType = "P"; //PTL料架拣料
                        //result.CurrentBatchInfo.PickType = 1; //PTL料架拣料
                        result.CurrentBatchInfo.ProjectCode         = projectCode;
                        result.CurrentBatchInfo.ProjectStep         = projectStep;
                        result.CurrentBatchInfo.BatchCode           = currentBatchFirstAstLesTask.BatchCode;
                        result.CurrentBatchInfo.FinishedPalletCount = dbContext.AST_PalletResults
                                                                      .Count(pr => pr.CFG_ChannelId == cfgChannelId && pr.BatchCode == currentBatchCode);
                        result.CurrentBatchInfo.TotalPalletCount = dbContext.AST_LesTasks
                                                                   .Where(lt => lt.CFG_ChannelId == cfgChannelId && lt.BatchCode == currentBatchCode)
                                                                   .Select(lt => lt.CFG_PalletId)
                                                                   .Distinct()
                                                                   .Count();
                        //以下 4 个汇总界面不展示
                        result.CurrentBatchInfo.FinishedMaterialTypeCount = 0;
                        result.CurrentBatchInfo.TotalMaterialTypeCount    = 0;
                        result.CurrentBatchInfo.FinishedMaterialCount     = 0;
                        result.CurrentBatchInfo.TotalMaterialCount        = 0;

                        List <CFG_ChannelCurrentCart> cfgChannelCurrentCarts = dbContext.CFG_ChannelCurrentCarts
                                                                               .Where(ccc => ccc.CFG_ChannelId == cfgChannelId)
                                                                               .OrderBy(ccc => ccc.Position)
                                                                               .ToList();
                        foreach (CFG_ChannelCurrentCart cfgChannelCurrentCart in cfgChannelCurrentCarts)
                        {
                            CFG_ChannelCurrentCartDto cfgChannelCurrentCartDto = new CFG_ChannelCurrentCartDto();
                            cfgChannelCurrentCartDto.CFG_ChannelCurrentCartId = cfgChannelCurrentCart.Id;
                            cfgChannelCurrentCartDto.CFG_ChannelId            = cfgChannelCurrentCart.CFG_ChannelId;
                            cfgChannelCurrentCartDto.Position   = cfgChannelCurrentCart.Position;
                            cfgChannelCurrentCartDto.CFG_CartId = cfgChannelCurrentCart.CFG_CartId;
                            if (cfgChannelCurrentCart.CFG_Cart != null)
                            {
                                cfgChannelCurrentCartDto.CartCode = cfgChannelCurrentCart.CFG_Cart.Code;
                                cfgChannelCurrentCartDto.CartName = cfgChannelCurrentCart.CFG_Cart.Name;
                            }
                        }

                        if (astPalletTask != null)
                        {
                            AST_PalletTaskDto astPalletTaskDto = new AST_PalletTaskDto();
                            astPalletTaskDto.AST_PalletTaskId     = astPalletTask.Id;
                            astPalletTaskDto.CFG_PalletId         = astPalletTask.CFG_PalletId;
                            astPalletTaskDto.PalletCode           = astPalletTask.CFG_Pallet.Code;
                            astPalletTaskDto.PalletType           = astPalletTask.CFG_Pallet.PalletType;
                            astPalletTaskDto.PalletRotationStatus = astPalletTask.CFG_Pallet.PalletRotationStatus;

                            List <AST_PalletTaskItem> astPalletTaskItems = astPalletTask.AST_PalletTaskItems
                                                                           .OrderBy(pti => pti.FromPalletPosition)
                                                                           .ToList();
                            astPalletTaskItems.Sort(new PalletTaskSortComparer()); //正在拣选的排在最前面
                            foreach (AST_PalletTaskItem astPalletTaskItem in astPalletTaskItems)
                            {
                                AST_PalletTaskItemDto astPalletTaskItemDto = new AST_PalletTaskItemDto();
                                astPalletTaskItemDto.AST_PalletTaskItemId = astPalletTaskItem.Id;
                                astPalletTaskItemDto.FromPalletPosition   = astPalletTaskItem.FromPalletPosition;
                                astPalletTaskItemDto.WorkStationCode      = astPalletTaskItem.CFG_WorkStation.Code;
                                astPalletTaskItemDto.MaterialCode         = astPalletTaskItem.MaterialCode;
                                astPalletTaskItemDto.MaterialName         = astPalletTaskItem.MaterialName;
                                astPalletTaskItemDto.MaterialBarcode      = astPalletTaskItem.MaterialBarcode;
                                astPalletTaskItemDto.ToPickQuantity       = astPalletTaskItem.ToPickQuantity;
                                astPalletTaskItemDto.IsSpecial            = astPalletTaskItem.IsSpecial;
                                astPalletTaskItemDto.IsBig          = astPalletTaskItem.IsBig;
                                astPalletTaskItemDto.PickStatus     = astPalletTaskItem.PickStatus;
                                astPalletTaskItemDto.PickedQuantity = astPalletTaskItem.PickedQuantity;

                                astPalletTaskDto.Items.Add(astPalletTaskItemDto);
                            }

                            result.CurrentPalletTask = astPalletTaskDto;
                        }

                        if (astCartTask != null)
                        {
                            AST_CartTaskDto astCartTaskDto = new AST_CartTaskDto();
                            astCartTaskDto.AST_CartTaskId = astCartTask.Id;
                            astCartTaskDto.CFG_CartId     = astCartTask.CFG_CartId;
                            astCartTaskDto.CartCode       = astCartTask.CFG_Cart.Code;
                            astCartTaskDto.CartName       = astCartTask.CFG_Cart.Name;

                            List <AST_CartTaskItem> astCartTaskItems = astCartTask.AST_CartTaskItems
                                                                       .OrderBy(cti => cti.CartPosition)
                                                                       .ToList();
                            foreach (AST_CartTaskItem astCartTaskItem in astCartTaskItems)
                            {
                                AST_PalletTaskItem astPalletTaskItem = astCartTaskItem.AST_PalletTaskItem;

                                AST_CartTaskItemDto astCartTaskItemDto = new AST_CartTaskItemDto();
                                astCartTaskItemDto.AST_CartTaskItemId = astCartTaskItem.Id;
                                astCartTaskItemDto.CartPosition       = astCartTaskItem.CartPosition;
                                astCartTaskItemDto.WorkStationCode    = astCartTask.CFG_WorkStation.Code;
                                astCartTaskItemDto.MaterialCode       = astPalletTaskItem.MaterialCode;
                                astCartTaskItemDto.MaterialName       = astPalletTaskItem.MaterialName;
                                astCartTaskItemDto.MaterialBarcode    = astPalletTaskItem.MaterialBarcode;
                                astCartTaskItemDto.MaxQuantityInSingleCartPosition = astPalletTaskItem.MaxQuantityInSingleCartPosition;
                                astCartTaskItemDto.IsSpecial       = astPalletTaskItem.IsSpecial;
                                astCartTaskItemDto.IsBig           = astPalletTaskItem.IsBig;
                                astCartTaskItemDto.AssortingStatus = astCartTaskItem.AssortingStatus;
                                astCartTaskItemDto.PickedQuantity  = astCartTaskItem.AssortedQuantity;

                                astCartTaskDto.Items.Add(astCartTaskItemDto);
                            }

                            result.CurrentCartTask = astCartTaskDto;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                DbEntityValidationException dbEntityValidationException = ex as DbEntityValidationException;
                if (dbEntityValidationException != null)
                {
                    foreach (DbEntityValidationResult validationResult in dbEntityValidationException.EntityValidationErrors)
                    {
                        foreach (DbValidationError validationError in validationResult.ValidationErrors)
                        {
                            message += Environment.NewLine + validationError.ErrorMessage;
                        }
                    }
                }
                message += Environment.NewLine + ex.StackTrace;

                Logger.Log("ForAssortingKanbanService.QueryCurrentTaskInfo", DateTime.Now.ToString("HH:mm:ss") + Environment.NewLine
                           + message + Environment.NewLine
                           + Environment.NewLine);
            }

            return(result);
        }