Ejemplo n.º 1
0
        public bool Save(CellPosition CellPosition, out string strResult)
        {
            strResult = string.Empty;
            bool result = false;
            var  c      = CellPositionRepository.GetQueryable().FirstOrDefault(s => s.ID == CellPosition.ID);

            if (c != null)
            {
                try
                {
                    c.CellCode           = CellPosition.CellCode;
                    c.StockInPositionID  = CellPosition.StockInPositionID;
                    c.StockOutPositionID = CellPosition.StockOutPositionID;

                    CellPositionRepository.SaveChanges();
                    result = true;
                }
                catch (Exception ex)
                {
                    strResult = "原因:" + ex.Message;
                }
            }
            else
            {
                strResult = "原因:未找到当前需要修改的数据!";
            }
            return(result);
        }
Ejemplo n.º 2
0
        public object GetDetails(int page, int rows, string CellCode, string StockInPosition, string StockOutPosition)
        {
            IQueryable <CellPosition> cellPositionQuery = CellPositionRepository.GetQueryable();
            IQueryable <Position>     positionQuery     = PositionRepository.GetQueryable();
            var cellPosition = cellPositionQuery.Join(positionQuery,
                                                      c => c.StockInPositionID,
                                                      p1 => p1.ID,
                                                      (c, p1) => new { c.ID, c.CellCode, c.StockInPositionID, c.StockOutPositionID, InName = p1.PositionName })
                               .Join(positionQuery,
                                     c => c.StockOutPositionID,
                                     p2 => p2.ID,
                                     (c, p2) => new { c.ID, c.CellCode, c.StockInPositionID, c.StockOutPositionID, c.InName, OutName = p2.PositionName })
                               .Where(p => p.CellCode.Contains(CellCode) && p.InName.Contains(StockInPosition) && p.OutName.Contains(StockOutPosition))
                               .OrderBy(p => p.ID).AsEnumerable()
                               .Select(p => new
            {
                p.ID,
                p.CellCode,
                p.StockInPositionID,
                p.InName,
                p.StockOutPositionID,
                p.OutName
            });

            int total = cellPosition.Count();

            cellPosition = cellPosition.Skip((page - 1) * rows).Take(rows);
            return(new { total, rows = cellPosition.ToArray() });
        }
Ejemplo n.º 3
0
        public bool Add(CellPosition cellPosition, out string strResult)
        {
            strResult = string.Empty;
            bool result = false;
            var  c      = new CellPosition();

            if (c != null)
            {
                try
                {
                    c.CellCode           = cellPosition.CellCode;
                    c.StockInPositionID  = cellPosition.StockInPositionID;
                    c.StockOutPositionID = cellPosition.StockOutPositionID;

                    CellPositionRepository.Add(c);
                    CellPositionRepository.SaveChanges();
                    result = true;
                }
                catch (Exception ex)
                {
                    strResult = "原因:" + ex.Message;
                }
            }
            else
            {
                strResult = "原因:找不到当前登陆用户!请重新登陆!";
            }
            return(result);
        }
Ejemplo n.º 4
0
        public bool CreateNewTaskForEmptyPalletSupply(int positionID)
        {
            string palletCode   = "";
            var    storageQuery = StorageRepository.GetQueryable()
                                  .Where(i => i.ProductCode == palletCode &&
                                         i.Quantity - i.OutFrozenQuantity > 0)
                                  .OrderBy(i => i.StorageTime);

            var storage  = storageQuery.FirstOrDefault();
            var position = PositionRepository.GetQueryable()
                           .Where(i => i.ID == positionID).FirstOrDefault();

            var positionCell = CellPositionRepository.GetQueryable()
                               .Where(i => i.StockInPositionID == positionID).FirstOrDefault();

            if (storage != null && position != null && positionCell != null)
            {
                var cellPosition = CellPositionRepository.GetQueryable()
                                   .Where(cp => cp.CellCode == storage.CellCode).FirstOrDefault();

                if (cellPosition != null)
                {
                    var path = PathRepository.GetQueryable()
                               .Where(p => p.OriginRegion == cellPosition.StockOutPosition.Region &&
                                      p.TargetRegion == position.Region)
                               .FirstOrDefault();
                    if (path != null)
                    {
                        var quantity = storage.Quantity - storage.OutFrozenQuantity;
                        storage.OutFrozenQuantity += quantity;

                        var newTask = new Task();
                        newTask.TaskType             = "01";
                        newTask.TaskLevel            = 0;
                        newTask.PathID               = path.ID;
                        newTask.ProductCode          = palletCode;
                        newTask.ProductName          = "空托盘";
                        newTask.OriginStorageCode    = storage.CellCode;
                        newTask.TargetStorageCode    = positionCell.CellCode;
                        newTask.OriginPositionID     = cellPosition.StockOutPositionID;
                        newTask.TargetPositionID     = positionID;
                        newTask.CurrentPositionID    = cellPosition.StockOutPositionID;
                        newTask.CurrentPositionState = "02";
                        newTask.State           = "01";
                        newTask.TagState        = "01";//拟不使用
                        newTask.Quantity        = Convert.ToInt32(storage.Quantity);
                        newTask.TaskQuantity    = Convert.ToInt32(quantity);
                        newTask.OperateQuantity = 0;
                        //newTask.OrderID = inItem.BillNo;
                        //newTask.OrderType = "01";
                        //newTask.AllotID = inItem.ID;
                        newTask.DownloadState = "1";
                        TaskRepository.Add(newTask);
                        TaskRepository.SaveChanges();
                        return(true);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 5
0
        public bool Delete(int cellPositionId, out string strResult)
        {
            strResult = string.Empty;
            bool result = false;
            var  c      = CellPositionRepository.GetQueryable().FirstOrDefault(s => s.ID == cellPositionId);

            if (c != null)
            {
                try
                {
                    CellPositionRepository.Delete(c);
                    CellPositionRepository.SaveChanges();
                    result = true;
                }
                catch (Exception)
                {
                    strResult = "原因:已在使用";
                }
            }
            else
            {
                strResult = "原因:未找到当前需要删除的数据!";
            }
            return(result);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 移库但觉作业
        /// </summary>
        /// <param name="billNo">单据号</param>
        /// <param name="errInfo">错误消息</param>
        /// <returns></returns>
        public bool MoveBIllTask(string billNo, out string errInfo)
        {
            bool result = true;

            errInfo = string.Empty;
            var moveQuery = MoveBillDetailRepository.GetQueryable().Where(i => i.BillNo == billNo);

            try
            {
                if (moveQuery.Any())
                {
                    foreach (var moveItem in moveQuery.ToArray())
                    {
                        //根据移出货位查找起始位置信息
                        var originCellPosition = CellPositionRepository.GetQueryable().FirstOrDefault(c => c.CellCode == moveItem.OutCellCode);
                        //根据移入货位查找目标位置信息
                        var targetCellPosition = CellPositionRepository.GetQueryable().FirstOrDefault(c => c.CellCode == moveItem.InCellCode);
                        //根据移出位置ID去找起始区域ID信息
                        var originPosition = PositionRepository.GetQueryable().FirstOrDefault(p => p.ID == originCellPosition.StockOutPositionID);
                        //根据移入位置ID去找目标区域ID信息
                        var targetPosition = PositionRepository.GetQueryable().FirstOrDefault(p => p.ID == targetCellPosition.StockInPositionID);
                        //根据入库的目标区域和起始位置区域去找路径信息
                        var path     = PathRepository.GetQueryable().FirstOrDefault(p => p.OriginRegionID == originPosition.RegionID && p.TargetRegionID == targetPosition.RegionID);
                        var moveTask = new Task();
                        moveTask.TaskType             = "01";
                        moveTask.TaskLevel            = 0;
                        moveTask.PathID               = path.ID;
                        moveTask.ProductCode          = moveItem.Product.ProductCode;
                        moveTask.ProductName          = moveItem.Product.ProductName;
                        moveTask.OriginStorageCode    = moveItem.OutCellCode;
                        moveTask.TargetStorageCode    = moveItem.InCellCode;
                        moveTask.OriginPositionID     = originPosition.ID;
                        moveTask.TargetPositionID     = targetPosition.ID;
                        moveTask.CurrentPositionID    = originPosition.ID;
                        moveTask.CurrentPositionState = "01";
                        moveTask.State           = "01";
                        moveTask.TagState        = "01";
                        moveTask.Quantity        = Convert.ToInt32(moveItem.RealQuantity);
                        moveTask.TaskQuantity    = Convert.ToInt32(moveItem.RealQuantity);
                        moveTask.OperateQuantity = Convert.ToInt32(moveItem.RealQuantity);
                        moveTask.OrderID         = moveItem.BillNo;
                        moveTask.OrderType       = "02";
                        moveTask.AllotID         = moveItem.ID;
                        TaskRepository.Add(moveTask);
                    }
                    TaskRepository.SaveChanges();
                }
                else
                {
                    errInfo = "当前选择订单没有移库细表数据,请重新选择!";
                }
            }
            catch (Exception e)
            {
                result  = false;
                errInfo = e.Message;
            }
            return(result);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 入库单据作业
        /// </summary>
        /// <param name="billNo">单据号</param>
        /// <param name="errInfo">错误消息</param>
        /// <returns></returns>
        public bool InBIllTask(string billNo, out string errInfo)
        {
            bool result = true;

            errInfo = string.Empty;
            var originPositionSystem = SystemParameterRepository.GetQueryable().FirstOrDefault(s => s.PARAMETER_VALUE == "IsDefaultProduct");//入库查询其实位置ID
            var allotQuery           = InBillAllotRepository.GetQueryable().Where(i => i.BillNo == billNo);

            try
            {
                if (allotQuery.Any())
                {
                    foreach (var inItem in allotQuery.ToArray())
                    {
                        //根据入库货位去找货位位置信息
                        var targetCellPosition = CellPositionRepository.GetQueryable().FirstOrDefault(c => c.CellCode == inItem.CellCode);
                        //根据入库位置ID去找目标区域ID信息
                        var targetPosition = PositionRepository.GetQueryable().FirstOrDefault(p => p.ID == targetCellPosition.StockInPositionID);
                        //根据起始位置ID去找起始区域ID信息
                        var originPosition = PositionRepository.GetQueryable().FirstOrDefault(p => p.ID == Convert.ToInt32(originPositionSystem.PARAMETER_VALUE));
                        //根据入库的目标区域和起始位置区域去找路径信息
                        var path   = PathRepository.GetQueryable().FirstOrDefault(p => p.OriginRegionID == originPosition.RegionID && p.TargetRegionID == targetPosition.RegionID);
                        var inTask = new Task();
                        inTask.TaskType             = "01";
                        inTask.TaskLevel            = 0;
                        inTask.PathID               = path.ID;
                        inTask.ProductCode          = inItem.Product.ProductCode;
                        inTask.ProductName          = inItem.Product.ProductName;
                        inTask.OriginStorageCode    = "";
                        inTask.TargetStorageCode    = inItem.CellCode;
                        inTask.OriginPositionID     = Convert.ToInt32(originPositionSystem.PARAMETER_VALUE);
                        inTask.TargetPositionID     = targetPosition.ID;
                        inTask.CurrentPositionID    = Convert.ToInt32(originPositionSystem.PARAMETER_VALUE);
                        inTask.CurrentPositionState = "01";
                        inTask.State           = "01";
                        inTask.TagState        = "01";
                        inTask.Quantity        = Convert.ToInt32(inItem.RealQuantity);
                        inTask.TaskQuantity    = Convert.ToInt32(inItem.RealQuantity);
                        inTask.OperateQuantity = Convert.ToInt32(inItem.AllotQuantity);
                        inTask.OrderID         = inItem.BillNo;
                        inTask.OrderType       = "01";
                        inTask.AllotID         = inItem.ID;
                        TaskRepository.Add(inTask);
                    }
                    TaskRepository.SaveChanges();
                }
                else
                {
                    errInfo = "当前选择订单没有分配数据,请重新选择!";
                }
            }
            catch (Exception e)
            {
                result  = false;
                errInfo = e.Message;
            }
            return(result);
        }
Ejemplo n.º 8
0
        public bool Add(CellPosition cellPosition)
        {
            var cp = new CellPosition();

            cp.ID                 = cellPosition.ID;
            cp.CellCode           = cellPosition.CellCode;
            cp.StockInPositionID  = cellPosition.StockInPositionID;
            cp.StockOutPositionID = cellPosition.StockOutPositionID;
            CellPositionRepository.Add(cp);
            CellPositionRepository.SaveChanges();
            return(true);
        }
Ejemplo n.º 9
0
        public System.Data.DataTable GetCellPosition(int page, int rows, CellPosition cp)
        {
            IQueryable <CellPosition> cellPositionQuery = CellPositionRepository.GetQueryable();
            IQueryable <Position>     positionQuery     = PositionRepository.GetQueryable();
            IQueryable <Cell>         cellQuery         = CellRepository.GetQueryable();

            var cellPosition = cellPositionQuery.Join(positionQuery,
                                                      c => c.StockInPositionID,
                                                      p1 => p1.ID,
                                                      (c, p1) => new { c.ID, c.CellCode, c.StockInPositionID, c.StockOutPositionID, InName = p1.PositionName })
                               .Join(positionQuery,
                                     c => c.StockOutPositionID,
                                     p2 => p2.ID,
                                     (c, p2) => new { c.ID, c.CellCode, c.StockInPositionID, c.StockOutPositionID, c.InName, OutName = p2.PositionName })
                               .Join(cellQuery,
                                     c => c.CellCode,
                                     cq => cq.CellCode,
                                     (c, cq) => new { c.ID, c.CellCode, c.StockInPositionID, c.StockOutPositionID, CellName = cq.CellName, c.InName, c.OutName }
                                     )
                               .Where(p => p.CellCode.Contains(cp.CellCode))
                               .OrderBy(p => p.ID).AsEnumerable()
                               .Select(p => new
            {
                p.ID,
                p.CellCode,
                p.InName,
                p.OutName,
                p.CellName
            });

            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("货位ID", typeof(string));
            dt.Columns.Add("货位代码", typeof(string));
            dt.Columns.Add("货位名称", typeof(string));
            dt.Columns.Add("入库位置", typeof(string));
            dt.Columns.Add("出库位置", typeof(string));
            foreach (var item in cellPosition)
            {
                dt.Rows.Add
                (
                    item.ID,
                    item.CellCode,
                    item.CellName,
                    item.InName,
                    item.OutName
                );
            }
            return(dt);
        }
Ejemplo n.º 10
0
        public bool Delete(int cellPositionId)
        {
            var cp = CellPositionRepository.GetQueryable().FirstOrDefault(s => s.ID == cellPositionId);

            if (cp != null)
            {
                CellPositionRepository.Delete(cp);
                CellPositionRepository.SaveChanges();
            }
            else
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 11
0
        public bool Save(CellPosition cellPosition)
        {
            IQueryable <Cell>     cellQuery     = CellRepository.GetQueryable();
            IQueryable <Position> positionQuery = PositionRepository.GetQueryable();
            var cell = cellQuery.FirstOrDefault(p => p.CellCode == cellPosition.CellCode);
            var c    = CellPositionRepository.GetQueryable().FirstOrDefault(s => s.ID == cellPosition.ID);

            //var position = positionQuery.FirstOrDefault(po => po.ID == cellPosition.ID);
            if (c != null)
            {
                c.ID                 = cellPosition.ID;
                c.CellCode           = cellPosition.CellCode;
                c.StockInPositionID  = cellPosition.StockInPositionID;
                c.StockOutPositionID = cellPosition.StockOutPositionID;
                CellPositionRepository.SaveChanges();
            }

            return(true);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 入库单据作业
        /// </summary>
        /// <param name="billNo">单据号</param>
        /// <param name="errInfo">错误消息</param>
        /// <returns></returns>
        public bool InBillTask(string billNo, out string errorInfo)
        {
            bool result = true;

            errorInfo = string.Empty;
            try
            {
                //查询“起始位置参数”
                var originPositionSystem = SystemParameterRepository.GetQueryable().FirstOrDefault(s => s.ParameterName == "IsDefaultProduct");
                int paramterValue        = Convert.ToInt32(originPositionSystem.ParameterValue);
                //入库分配信息
                var inBillAllot = InBillAllotRepository.GetQueryable().Where(i => i.BillNo == billNo);
                if (inBillAllot.Any())
                {
                    foreach (var inItem in inBillAllot.ToArray())
                    {
                        //根据“入库货位编码”查找“目标货位位置”
                        var targetCellPosition = CellPositionRepository.GetQueryable().FirstOrDefault(c => c.CellCode == inItem.CellCode);
                        if (targetCellPosition != null)
                        {
                            //根据“起始位置参数”查找“起始位置信息”
                            var originPosition = PositionRepository.GetQueryable().FirstOrDefault(p => p.ID == paramterValue);
                            if (originPosition != null)
                            {
                                //根据“货位位置中的入库位置ID”查找“目标位置信息”
                                var targetPosition = PositionRepository.GetQueryable().FirstOrDefault(p => p.ID == targetCellPosition.StockInPositionID);
                                if (targetPosition != null)
                                {
                                    //根据“入库(目标和起始)位置信息的区域ID”查找“路径信息”
                                    var path = PathRepository.GetQueryable().FirstOrDefault(p => p.OriginRegionID == originPosition.RegionID && p.TargetRegionID == targetPosition.RegionID);
                                    if (path != null)
                                    {
                                        var inTask = new Task();
                                        inTask.TaskType             = "01";
                                        inTask.TaskLevel            = 0;
                                        inTask.PathID               = path.ID;
                                        inTask.ProductCode          = inItem.Product.ProductCode;
                                        inTask.ProductName          = inItem.Product.ProductName;
                                        inTask.OriginStorageCode    = inItem.CellCode;
                                        inTask.TargetStorageCode    = inItem.CellCode;
                                        inTask.OriginPositionID     = Convert.ToInt32(originPositionSystem.Id);
                                        inTask.TargetPositionID     = targetPosition.ID;
                                        inTask.CurrentPositionID    = Convert.ToInt32(originPositionSystem.Id);
                                        inTask.CurrentPositionState = "01";
                                        inTask.State           = "04";
                                        inTask.TagState        = "01";
                                        inTask.Quantity        = Convert.ToInt32(inItem.RealQuantity);
                                        inTask.TaskQuantity    = Convert.ToInt32(inItem.RealQuantity);
                                        inTask.OperateQuantity = Convert.ToInt32(inItem.AllotQuantity);
                                        inTask.OrderID         = inItem.BillNo;
                                        inTask.OrderType       = "01";
                                        inTask.AllotID         = inItem.ID;
                                        inTask.DownloadState   = "0";
                                        TaskRepository.Add(inTask);
                                    }
                                    else
                                    {
                                        errorInfo = "未找到【路径信息】起始位置ID:" + originPosition.RegionID + ",目标位置ID:" + targetPosition.RegionID;
                                        result    = false;
                                    }
                                }
                                else
                                {
                                    errorInfo = "未找到【位置信息】目标货位位置ID:" + targetCellPosition.StockInPositionID;
                                    result    = false;
                                }
                            }
                            else
                            {
                                errorInfo = "请检查【系统参数】设置!";
                                result    = false;
                            }
                        }
                        else
                        {
                            errorInfo = "未找到【货位位置】入库货位编码:" + inItem.CellCode;
                            result    = false;
                        }
                    }
                    TaskRepository.SaveChanges();
                }
                else
                {
                    errorInfo = "当前选择订单没有分配数据,请重新选择!";
                }
            }
            catch (Exception e)
            {
                errorInfo = e.Message;
                result    = false;
            }
            return(result);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 移库单据作业
        /// </summary>
        /// <param name="billNo">单据号</param>
        /// <param name="errInfo">错误消息</param>
        /// <returns></returns>
        public bool MoveBillTask(string billNo, out string errorInfo)
        {
            bool result = true;

            errorInfo = string.Empty;
            try
            {
                var moveQuery = MoveBillDetailRepository.GetQueryable().Where(i => i.BillNo == billNo);
                if (moveQuery.Any())
                {
                    foreach (var moveItem in moveQuery.ToArray())
                    {
                        //根据“移出的货位信息的编码”查找“起始的位置信息”
                        var originCellPosition = CellPositionRepository.GetQueryable().FirstOrDefault(c => c.CellCode == moveItem.OutCellCode);
                        if (originCellPosition != null)
                        {
                            //根据“移入的货位信息”查找“目标货位位置”
                            var targetCellPosition = CellPositionRepository.GetQueryable().FirstOrDefault(c => c.CellCode == moveItem.InCellCode);
                            if (targetCellPosition != null)
                            {
                                //根据“移出的位置信息ID”去找“起始位置的位置信息”
                                var originPosition = PositionRepository.GetQueryable().FirstOrDefault(p => p.ID == originCellPosition.StockOutPositionID);
                                if (originPosition != null)
                                {
                                    //根据“移入位置ID”去找“目标位置的区域ID”信息
                                    var targetPosition = PositionRepository.GetQueryable().FirstOrDefault(p => p.ID == targetCellPosition.StockInPositionID);
                                    if (targetPosition != null)
                                    {
                                        //根据“入库的目标位置信息的区域ID”和"起始的位置信息的区域ID"去找"路径信息"
                                        var path = PathRepository.GetQueryable().FirstOrDefault(p => p.OriginRegionID == originPosition.RegionID && p.TargetRegionID == targetPosition.RegionID);
                                        if (path != null)
                                        {
                                            var moveTask = new Task();
                                            moveTask.TaskType             = "01";
                                            moveTask.TaskLevel            = 0;
                                            moveTask.PathID               = path.ID;
                                            moveTask.ProductCode          = moveItem.Product.ProductCode;
                                            moveTask.ProductName          = moveItem.Product.ProductName;
                                            moveTask.OriginStorageCode    = moveItem.OutCellCode;
                                            moveTask.TargetStorageCode    = moveItem.InCellCode;
                                            moveTask.OriginPositionID     = originPosition.ID;
                                            moveTask.TargetPositionID     = targetPosition.ID;
                                            moveTask.CurrentPositionID    = originPosition.ID;
                                            moveTask.CurrentPositionState = "01";
                                            moveTask.State           = "01";
                                            moveTask.TagState        = "01";
                                            moveTask.Quantity        = Convert.ToInt32(moveItem.RealQuantity);
                                            moveTask.TaskQuantity    = Convert.ToInt32(moveItem.RealQuantity);
                                            moveTask.OperateQuantity = Convert.ToInt32(moveItem.RealQuantity);
                                            moveTask.OrderID         = moveItem.BillNo;
                                            moveTask.OrderType       = "03";
                                            moveTask.AllotID         = moveItem.ID;
                                            moveTask.DownloadState   = "0";
                                            TaskRepository.Add(moveTask);
                                        }
                                        else
                                        {
                                            errorInfo = "未找到【路径信息】起始位置ID:" + originPosition.RegionID + ",目标位置ID:" + targetPosition.RegionID;
                                            result    = false;
                                        }
                                    }
                                    else
                                    {
                                        errorInfo = "未找到目标【位置信息】移入位置ID:" + targetCellPosition.StockInPositionID;
                                        result    = false;
                                    }
                                }
                                else
                                {
                                    errorInfo = "未找到起始【位置信息】移出位置ID:" + originCellPosition.StockOutPositionID;
                                    result    = false;
                                }
                            }
                            else
                            {
                                errorInfo = "未找到目标【货位位置】移入货位编码:" + moveItem.InCellCode;
                                result    = false;
                            }
                        }
                        else
                        {
                            errorInfo = "未找到起始【货位位置】移出货位编码:" + moveItem.OutCellCode;
                            result    = false;
                        }
                    }
                    TaskRepository.SaveChanges();
                }
                else
                {
                    errorInfo = "当前选择订单没有移库细表数据,请重新选择!";
                }
            }
            catch (Exception e)
            {
                result    = false;
                errorInfo = e.Message;
            }
            return(result);
        }
Ejemplo n.º 14
0
        public bool CreateNewTaskForEmptyPalletStack(int positionID)
        {
            string palletCode  = "";
            int    palletCount = 10;
            var    position    = PositionRepository.GetQueryable()
                                 .Where(i => i.ID == positionID).FirstOrDefault();

            if (position != null)
            {
                var positionQuery = PositionRepository.GetQueryable()
                                    .Where(i => i.SRMName == position.SRMName &&
                                           i.AbleStockInPallet && i.ID != positionID);
                var cellPositionQuery = CellPositionRepository.GetQueryable()
                                        .Where(i => i.StockOutPositionID != positionID &&
                                               positionQuery.Contains(i.StockInPosition));
                var cellQuery = CellRepository.GetQueryable()
                                .Where(i => i.IsSingle == "1" &&
                                       cellPositionQuery.Any(p => p.CellCode == i.CellCode) &&
                                       (i.Storages.Count == 0 ||
                                        i.Storages.Any(s => string.IsNullOrEmpty(s.LockTag) &&
                                                       s.Quantity == 0 &&
                                                       s.InFrozenQuantity == 0) ||
                                        i.Storages.Any(s => s.ProductCode == palletCode &&
                                                       s.Quantity + s.InFrozenQuantity < palletCount)));

                var cell = cellQuery.FirstOrDefault();
                if (cell != null)
                {
                    var cellPosition = CellPositionRepository.GetQueryable()
                                       .Where(cp => cp.CellCode == cell.CellCode).FirstOrDefault();
                    if (!cell.Storages.Any())
                    {
                        var storage = new Storage()
                        {
                            Cell        = cell,
                            StorageCode = Guid.NewGuid().ToString(),
                            CellCode    = cell.CellCode,
                            IsLock      = "0",
                            IsActive    = "0",
                            StorageTime = DateTime.Now,
                            UpdateTime  = DateTime.Now
                        };
                        lock (cell.Storages)
                        {
                            cell.Storages.Add(storage);
                        }
                    }
                    var targetStorage = cell.Storages.FirstOrDefault();
                    if (targetStorage != null && cellPosition != null)
                    {
                        targetStorage.InFrozenQuantity += 1;
                        var newTask = new Task();
                        newTask.TaskType  = "01";
                        newTask.TaskLevel = 0;
                        //newTask.PathID = path.ID;
                        newTask.ProductCode = palletCode;
                        newTask.ProductName = "空托盘";
                        //newTask.OriginStorageCode = inItem.CellCode;
                        newTask.TargetStorageCode    = cell.CellCode;
                        newTask.OriginPositionID     = positionID;
                        newTask.TargetPositionID     = cellPosition.StockInPositionID;
                        newTask.CurrentPositionID    = positionID;
                        newTask.CurrentPositionState = "02";
                        newTask.State           = "01";
                        newTask.TagState        = "01";//拟不使用
                        newTask.Quantity        = 1;
                        newTask.TaskQuantity    = 1;
                        newTask.OperateQuantity = 0;
                        //newTask.OrderID = inItem.BillNo;
                        //newTask.OrderType = "01";
                        //newTask.AllotID = inItem.ID;
                        newTask.DownloadState = "1";
                        TaskRepository.Add(newTask);
                        TaskRepository.SaveChanges();
                        return(true);
                    }
                }
            }
            return(false);
        }