Exemplo n.º 1
0
        public object GetSystemParameter(int page, int rows, string parameterName, string parameterValue, string remark, string userName, string SystemID)
        {
            IQueryable <SystemParameter> systemParameterQuery      = SystemParameterRepository.GetQueryable();
            IQueryable <THOK.Authority.DbModel.System> systemQuery = SystemRepository.GetQueryable();

            var systemParameter = systemParameterQuery.Join(systemQuery,
                                                            s => s.SystemID,
                                                            s1 => s1.SystemID,
                                                            (s, s1) => new { s.Id, s.ParameterName, s.ParameterValue, s.Remark, s.UserName, SystemName = s1.SystemName })
                                  .Join(systemQuery,
                                        c => c.SystemName,
                                        s2 => s2.SystemName,
                                        (c, s2) => new { c.Id, c.ParameterName, c.ParameterValue, c.Remark, c.SystemName, c.UserName, SystemID = s2.SystemName })
                                  .Where(p => p.ParameterName.Contains(parameterName) && p.ParameterValue.Contains(parameterValue) && p.Remark.Contains(remark))
                                  .OrderBy(p => p.Id).AsEnumerable()
                                  .Select(p => new
            {
                Id = p.Id,
                p.ParameterName,
                p.ParameterValue,
                p.Remark,
                p.UserName,
                p.SystemID,
                SystemName = p.SystemID == null ? "" : p.SystemName
            });

            int total = systemParameter.Count();

            systemParameter = systemParameter.Skip((page - 1) * rows).Take(rows);
            return(new { total, rows = systemParameter.ToArray() });
        }
Exemplo n.º 2
0
        public bool SetSystemParameter(SystemParameter systemParameter, string userName, out string error)
        {
            error = string.Empty;
            bool result = false;

            var query = SystemParameterRepository.GetQueryable().FirstOrDefault(a => a.Id == systemParameter.Id);

            if (query != null)
            {
                try
                {
                    query.ParameterName  = systemParameter.ParameterName;
                    query.ParameterValue = systemParameter.ParameterValue;
                    query.Remark         = systemParameter.Remark;
                    query.UserName       = userName;
                    query.SystemID       = systemParameter.SystemID;

                    SystemParameterRepository.SaveChanges();
                    result = true;
                }
                catch (Exception ex)
                {
                    error = "原因:" + ex.Message;
                }
            }
            else
            {
                error = "原因:未找到当前需要修改的数据!";
            }
            return(result);
        }
Exemplo n.º 3
0
        public bool DelSystemParameter(int id, out string error)
        {
            error = string.Empty;
            bool result = false;

            var query = SystemParameterRepository.GetQueryable().FirstOrDefault(a => a.Id == id);

            if (query != null)
            {
                try
                {
                    SystemParameterRepository.Delete(query);
                    SystemParameterRepository.SaveChanges();
                    result = true;
                }
                catch (Exception ex)
                {
                    error = "原因:" + ex.Message;
                }
            }
            else
            {
                error = "原因:未找到当前需要删除的数据!";
            }

            return(result);
        }
Exemplo n.º 4
0
        public bool SetSystemParameter(AUTH_SYSTEM_PARAMETER systemParameter, string userName, out string error)
        {
            error = string.Empty;
            bool result = false;

            var query = SystemParameterRepository.GetQueryable().FirstOrDefault(a => a.ID == systemParameter.ID);

            if (query != null)
            {
                try
                {
                    query.PARAMETER_NAME  = systemParameter.PARAMETER_NAME;
                    query.PARAMETER_VALUE = systemParameter.PARAMETER_VALUE;
                    query.REMARK          = systemParameter.REMARK;
                    query.USER_NAME       = userName;
                    query.SYSTEM_ID       = systemParameter.SYSTEM_ID;

                    SystemParameterRepository.SaveChanges();
                    result = true;
                }
                catch (Exception ex)
                {
                    error = "原因:" + ex.Message;
                }
            }
            else
            {
                error = "原因:未找到当前需要修改的数据!";
            }
            return(result);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        public bool SetSystemParameter()
        {
            var query = SystemParameterRepository.GetQueryable().FirstOrDefault(a => a.ParameterName == "DownInterFace").ParameterValue;

            if (query == "2")
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 7
0
        public object GetSystemParameter(int page, int rows, SystemParameter systemParameter)
        {
            var query = SystemParameterRepository.GetQueryable()
                        .Where(a => a.ParameterName.Contains(systemParameter.ParameterName) ||
                               a.ParameterValue.Contains(systemParameter.ParameterValue) ||
                               a.Remark.Contains(systemParameter.Remark) ||
                               a.UserName.Contains(systemParameter.UserName) ||
                               a.SystemID == systemParameter.SystemID);

            if (!systemParameter.ParameterName.Equals(string.Empty))
            {
                query.Where(a => a.ParameterName == systemParameter.ParameterName);
            }
            if (!systemParameter.ParameterValue.Equals(string.Empty))
            {
                query.Where(a => a.ParameterValue == systemParameter.ParameterValue);
            }
            if (!systemParameter.Remark.Equals(string.Empty))
            {
                query.Where(a => a.Remark == systemParameter.Remark);
            }
            if (!systemParameter.UserName.Equals(string.Empty))
            {
                query.Where(a => a.UserName == systemParameter.UserName);
            }
            if (systemParameter.SystemID != null)
            {
                query.Where(a => a.SystemID == systemParameter.SystemID);
            }
            query = query.OrderBy(a => a.Id);
            int total = query.Count();

            query = query.Skip((page - 1) * rows).Take(rows);
            var info = query.ToArray().Select(a => new
            {
                Id = a.Id,
                a.ParameterName,
                a.ParameterValue,
                a.Remark,
                a.UserName,
                a.SystemID,
                SystemName = a.SystemID == null ? "" : a.System.SystemName
            });

            return(new { total, rows = info.ToArray() });
        }
Exemplo n.º 8
0
        public object GetSystemParameter(int page, int rows, AUTH_SYSTEM_PARAMETER systemParameter)
        {
            var query = SystemParameterRepository.GetQueryable()
                        .Where(a => a.PARAMETER_NAME.Contains(systemParameter.PARAMETER_NAME) ||
                               a.PARAMETER_VALUE.Contains(systemParameter.PARAMETER_VALUE) ||
                               a.REMARK.Contains(systemParameter.REMARK) ||
                               a.USER_NAME.Contains(systemParameter.USER_NAME) ||
                               a.SYSTEM_ID == systemParameter.SYSTEM_ID);

            if (!systemParameter.PARAMETER_NAME.Equals(string.Empty))
            {
                query.Where(a => a.PARAMETER_NAME == systemParameter.PARAMETER_NAME);
            }
            if (!systemParameter.PARAMETER_VALUE.Equals(string.Empty))
            {
                query.Where(a => a.PARAMETER_VALUE == systemParameter.PARAMETER_VALUE);
            }
            if (!systemParameter.REMARK.Equals(string.Empty))
            {
                query.Where(a => a.REMARK == systemParameter.REMARK);
            }
            if (!systemParameter.USER_NAME.Equals(string.Empty))
            {
                query.Where(a => a.USER_NAME == systemParameter.USER_NAME);
            }
            if (systemParameter.SYSTEM_ID != null)
            {
                query.Where(a => a.SYSTEM_ID == systemParameter.SYSTEM_ID);
            }
            query = query.OrderBy(a => a.ID);
            int total = query.Count();

            query = query.Skip((page - 1) * rows).Take(rows);
            var info = query.ToArray().Select(a => new
            {
                Id = a.ID,
                a.PARAMETER_NAME,
                a.PARAMETER_VALUE,
                a.REMARK,
                a.USER_NAME,
                a.SYSTEM_ID,
                SystemName = a.SYSTEM_ID == null ? "" : a.AUTH_SYSTEM.SYSTEM_NAME
            });

            return(new { total, rows = info.ToArray() });
        }
Exemplo n.º 9
0
        public bool AddSystemParameter(SystemParameter systemParameter, string userName, out string error)
        {
            error = string.Empty;
            bool result = false;
            var  query  = SystemParameterRepository.GetQueryable().FirstOrDefault(a => a.Id == systemParameter.Id);

            if (query == null)
            {
                SystemParameter sp = new SystemParameter();
                if (sp != null)
                {
                    try
                    {
                        sp.ParameterName  = systemParameter.ParameterName;
                        sp.ParameterValue = systemParameter.ParameterValue;
                        sp.Remark         = systemParameter.Remark;
                        sp.UserName       = userName;
                        sp.SystemID       = systemParameter.SystemID;

                        SystemParameterRepository.Add(sp);
                        SystemParameterRepository.SaveChanges();
                        result = true;
                    }
                    catch (Exception ex)
                    {
                        error = "原因:" + ex.Message;
                    }
                }
                else
                {
                    error = "原因:找不到当前登陆用户!请重新登陆!";
                }
            }
            else
            {
                error = "原因:该编号已存在!";
            }
            return(result);
        }
Exemplo n.º 10
0
        public bool AddSystemParameter(AUTH_SYSTEM_PARAMETER systemParameter, string userName, out string error)
        {
            error = string.Empty;
            bool result = false;
            var  query  = SystemParameterRepository.GetQueryable().FirstOrDefault(a => a.ID == systemParameter.ID);

            if (query == null)
            {
                AUTH_SYSTEM_PARAMETER sp = new AUTH_SYSTEM_PARAMETER();
                if (sp != null)
                {
                    try
                    {
                        sp.PARAMETER_NAME  = systemParameter.PARAMETER_NAME;
                        sp.PARAMETER_VALUE = systemParameter.PARAMETER_VALUE;
                        sp.REMARK          = systemParameter.REMARK;
                        sp.USER_NAME       = userName;
                        sp.SYSTEM_ID       = systemParameter.SYSTEM_ID;

                        SystemParameterRepository.Add(sp);
                        SystemParameterRepository.SaveChanges();
                        result = true;
                    }
                    catch (Exception ex)
                    {
                        error = "原因:" + ex.Message;
                    }
                }
                else
                {
                    error = "原因:找不到当前登陆用户!请重新登陆!";
                }
            }
            else
            {
                error = "原因:该编号已存在!";
            }
            return(result);
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
0
        public void Allot(string connectionId, ProgressState ps, CancellationToken cancellationToken, string billNo, string[] areaCodes)
        {
            Locker.LockKey = billNo;
            ConnectionId   = connectionId;
            ps.State       = StateType.Start;
            ps.Messages.Add("开始分配!");
            NotifyConnection(ps.Clone());
            IQueryable <THOK.Authority.DbModel.SystemParameter> systemParQuery = SystemParameterRepository.GetQueryable();
            IQueryable <InBillMaster> inBillMasterQuery = InBillMasterRepository.GetQueryable();
            IQueryable <Cell>         cellQuery         = CellRepository.GetQueryable();

            InBillMaster billMaster = inBillMasterQuery.Single(b => b.BillNo == billNo);

            if (!CheckAndLock(billMaster, ps))
            {
                return;
            }

            var isDefaultProduct  = systemParQuery.FirstOrDefault(s => s.ParameterName == "IsDefaultProduct");  //查询预设的卷烟其他卷烟是否可入 0 否 1是
            var InMantissaIsPiece = systemParQuery.FirstOrDefault(s => s.ParameterName == "InMantissaIsPiece"); //查询入库的尾数是否放入件烟区  0 否 1是

            //选择未分配的细单数组;
            var billDetails = billMaster.InBillDetails
                              .Where(b => (b.BillQuantity - b.AllotQuantity) > 0)
                              .ToArray();


            //选择当前订单操作目标仓库;
            var cells = cellQuery.Where(c => c.WarehouseCode == billMaster.WarehouseCode &&
                                        c.Warehouse.IsActive == "1" &&
                                        c.Area.IsActive == "1" &&
                                        c.IsActive == "1" &&
                                        (areaCodes.Any(a => a == c.AreaCode) ||
                                         (!areaCodes.Any() && c.Area.AllotInOrder > 0)))
                        .ToArray();

            //1:主库区;2:件烟区;
            //3;条烟区;4:暂存区;
            //5:备货区;6:残烟区;
            //7:罚烟区;8:虚拟区;
            //9:其他区;

            //排除 件烟区,条烟区 货位是单一存储的空货位;
            string [] areaTypes = new string [] { "2", "3" };
            var       cells1    = cells.Where(c => areaTypes.All(a => a != c.Area.AreaType) &&
                                              c.IsSingle == "1" &&
                                              (c.Storages.Count == 0 ||
                                               c.Storages.Any(s => string.IsNullOrEmpty(s.LockTag) &&
                                                              s.Quantity == 0 &&
                                                              s.InFrozenQuantity == 0)))
                                  .ToArray();

            //条烟区 货位是单一存储的货位(不必是空货位,因为条烟会多次存储到同一个货位);
            areaTypes = new string[] { "3" };
            var cell2 = cells.Where(c => areaTypes.Any(a => a == c.Area.AreaType) &&
                                    c.IsSingle == "1")
                        .ToArray();

            //件烟区 货位是单一存储的空货位;
            areaTypes = new string[] { "2", "4" };
            var cell3 = cells.Where(c => areaTypes.Any(a => a == c.Area.AreaType) &&
                                    c.IsSingle == "1" &&
                                    c.Storages.Any(s => string.IsNullOrEmpty(s.LockTag) &&
                                                   s.Product != null &&
                                                   (s.Quantity > 0 || s.InFrozenQuantity > 0) &&
                                                   c.MaxQuantity * s.Product.Unit.Count > s.Quantity - s.InFrozenQuantity))
                        .ToArray();

            //件烟区 货位是单一存储的空货位;
            areaTypes = new string[] { "2" };
            var cell4 = cells.Where(c => areaTypes.Any(a => a == c.Area.AreaType) &&
                                    c.IsSingle == "1" &&
                                    (c.Storages.Count == 0 ||
                                     c.Storages.Any(s => string.IsNullOrEmpty(s.LockTag) &&
                                                    s.Quantity == 0 &&
                                                    s.InFrozenQuantity == 0
                                                    )
                                    )
                                    )
                        .ToArray();

            //非货位管理区
            var cell5 = cells.Where(c => c.IsSingle == "0")
                        .ToArray();


            //排除 件烟区,条烟区
            var cellQueryFromList1 = cells1.Where(c => c.Storages.Count == 0 ||
                                                  c.Storages.Any(s => string.IsNullOrEmpty(s.LockTag) &&
                                                                 s.Quantity == 0 &&
                                                                 s.InFrozenQuantity == 0))
                                     .OrderBy(c => c.Area.AllotInOrder);
            //条烟区
            var cellQueryFromList2 = cell2.OrderBy(c => c.Area.AllotInOrder);

            //件烟区 --入库尾数可以放入件烟区
            var cellQueryFromList3 = cell3.OrderBy(c => c.Area.AllotInOrder);

            if (InMantissaIsPiece.ParameterValue != "0")
            {
                cellQueryFromList3 = cell3.Where(c => c.Storages.Any(s => c.MaxQuantity * s.Product.Unit.Count > s.Quantity - s.InFrozenQuantity))
                                     .OrderBy(c => c.Area.AllotInOrder);
            }
            //件烟区 --入库尾数不放入件烟区
            var cellQueryFromList4 = cell4.Where(c => c.Storages.Count == 0 ||
                                                 c.Storages.Any(s => string.IsNullOrEmpty(s.LockTag) &&
                                                                s.Quantity == 0 &&
                                                                s.InFrozenQuantity == 0))
                                     .OrderBy(c => c.Area.AllotInOrder);

            //非货位管理区
            var cellQueryFromList5 = cell5.OrderBy(c => c.Area.AllotInOrder % 10000);

            foreach (var billDetail in billDetails)
            {
                //分配预设当前卷烟的货位;
                var cs = cellQueryFromList1.Where(c => c.DefaultProductCode == billDetail.ProductCode);
                AllotPallet(billMaster, billDetail, cs, cancellationToken, ps);
                //分配没预设卷烟的货位;
                cs = cellQueryFromList1.Where(c => string.IsNullOrEmpty(c.DefaultProductCode));
                AllotPallet(billMaster, billDetail, cs, cancellationToken, ps);

                if (isDefaultProduct.ParameterValue != "0")//判断预设卷烟后不能放入其他烟
                {
                    //分配预设其他卷烟的货位;
                    cs = cellQueryFromList1.Where(c => c.DefaultProductCode != billDetail.ProductCode &&
                                                  !string.IsNullOrEmpty(c.DefaultProductCode));
                    AllotPallet(billMaster, billDetail, cs, cancellationToken, ps);
                }

                //分配条烟到条烟区;
                cs = cellQueryFromList2.Where(c => c.DefaultProductCode == billDetail.ProductCode ||
                                              (c.Storages.Count == 1 &&
                                               c.Storages.First().ProductCode == billDetail.ProductCode)
                                              );
                AllotBar(billMaster, billDetail, cs, cancellationToken, ps);
                //分配条烟到条烟区;
                if (!cs.Any())
                {
                    cs = cellQueryFromList2.Where(c => (isDefaultProduct.ParameterValue == "0" ? string.IsNullOrEmpty(c.DefaultProductCode) : c.WarehouseCode == c.WarehouseCode));
                    AllotBar(billMaster, billDetail, cs, cancellationToken, ps);
                }

                //分配未满一托盘的卷烟到件烟区;
                cs = cellQueryFromList3.Where(c => (isDefaultProduct.ParameterValue == "0" ? string.IsNullOrEmpty(c.DefaultProductCode) : c.WarehouseCode == c.WarehouseCode) || c.DefaultProductCode == billDetail.ProductCode);
                if (cellQueryFromList2.Any())
                {
                    if (InMantissaIsPiece.ParameterValue != "0")
                    {
                        AllotPiece(billMaster, billDetail, cs, cancellationToken, ps);
                    }
                    cs = cellQueryFromList4.Where(c => (isDefaultProduct.ParameterValue == "0" ? string.IsNullOrEmpty(c.DefaultProductCode) : c.WarehouseCode == c.WarehouseCode));
                    AllotPiece(billMaster, billDetail, cs, cancellationToken, ps);
                }
                else
                {
                    if (InMantissaIsPiece.ParameterValue != "0")
                    {
                        AllotPieceAndBar(billMaster, billDetail, cs, cancellationToken, ps);
                    }
                    cs = cellQueryFromList4.Where(c => (isDefaultProduct.ParameterValue == "0" ? string.IsNullOrEmpty(c.DefaultProductCode) : c.WarehouseCode == c.WarehouseCode));
                    AllotPieceAndBar(billMaster, billDetail, cs, cancellationToken, ps);
                }

                //分配未满一托盘的卷烟到下层货架;
                cs = cellQueryFromList1.Where(c => c.Layer == 1 && (isDefaultProduct.ParameterValue == "0" ? string.IsNullOrEmpty(c.DefaultProductCode) : c.WarehouseCode == c.WarehouseCode));
                if (cellQueryFromList2.Count() > 0)
                {
                    AllotPiece(billMaster, billDetail, cs, cancellationToken, ps);
                }
                else
                {
                    AllotPieceAndBar(billMaster, billDetail, cs, cancellationToken, ps);
                }

                //分配未分配卷烟到其他库区;
                cs = cellQueryFromList1.Where(c => (isDefaultProduct.ParameterValue == "0" ? string.IsNullOrEmpty(c.DefaultProductCode) : c.WarehouseCode == c.WarehouseCode));
                AllotPiece(billMaster, billDetail, cs, cancellationToken, ps);

                //分配未分配卷烟到其他非货位管理货位;
                while (!cancellationToken.IsCancellationRequested && (billDetail.BillQuantity - billDetail.AllotQuantity) > 0)
                {
                    var c = cellQueryFromList5.Where(i => !i.Storages.Any() ||
                                                     i.Storages.Count() < i.MaxPalletQuantity ||
                                                     i.Storages.Any(s => string.IsNullOrEmpty(s.LockTag) &&
                                                                    s.Quantity == 0 &&
                                                                    s.InFrozenQuantity == 0))
                            .FirstOrDefault();

                    if (c != null)
                    {
                        lock (c)
                        {
                            decimal allotQuantity = c.MaxQuantity * billDetail.Product.Unit.Count;
                            decimal billQuantity  = billDetail.BillQuantity - billDetail.AllotQuantity;
                            allotQuantity = allotQuantity < billQuantity ? allotQuantity : billQuantity;
                            var targetStorage = Locker.LockStorage(c);
                            if (targetStorage != null &&
                                targetStorage.Quantity == 0 &&
                                targetStorage.InFrozenQuantity == 0)
                            {
                                Allot(billMaster, billDetail, c, targetStorage, allotQuantity, ps);
                                Locker.UnLockStorage(targetStorage);
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }

            string billno = billMaster.BillNo;

            if (billMaster.InBillDetails.Any(i => i.BillQuantity - i.AllotQuantity > 0))
            {
                ps.State = StateType.Warning;
                ps.Errors.Add("分配未全部完成,没有储位可分配!");
                NotifyConnection(ps.Clone());

                InBillMasterRepository.GetObjectSet()
                .UpdateEntity(i => i.BillNo == billno,
                              i => new InBillMaster()
                {
                    LockTag = ""
                });
            }
            else
            {
                ps.State = StateType.Info;
                ps.Messages.Add("分配完成,开始保存请稍候!");
                NotifyConnection(ps.Clone());

                billMaster.Status = "3";
                try
                {
                    if (!cancellationToken.IsCancellationRequested)
                    {
                        billMaster.LockTag = string.Empty;
                        CellRepository.SaveChanges();
                        ps.State = StateType.Info;
                        ps.Messages.Clear();
                        ps.Messages.Add("分配成功!");
                        NotifyConnection(ps.Clone());
                    }
                }
                catch (Exception e)
                {
                    ps.State = StateType.Error;
                    ps.Messages.Add("保存失败,详情:" + e.Message);
                    NotifyConnection(ps.Clone());
                }
                finally
                {
                    InBillMasterRepository.GetObjectSet()
                    .UpdateEntity(i => i.BillNo == billno,
                                  i => new InBillMaster()
                    {
                        LockTag = ""
                    });
                }
            }
        }
Exemplo n.º 13
0
        public void Dispatch(string connectionId, Model.ProgressState ps, CancellationToken cancellationToken, string workDispatchId, string userName)
        {
            Locker.LockKey = workDispatchId;
            ConnectionId   = connectionId;
            ps.State       = StateType.Start;
            NotifyConnection(ps.Clone());

            IQueryable <SortOrderDispatch> sortOrderDispatchQuery = SortOrderDispatchRepository.GetQueryable();
            IQueryable <SortOrder>         sortOrderQuery         = SortOrderRepository.GetQueryable();
            IQueryable <SortOrderDetail>   sortOrderDetailQuery   = SortOrderDetailRepository.GetQueryable();

            IQueryable <OutBillMaster>  outBillMasterQuery  = OutBillMasterRepository.GetQueryable();
            IQueryable <OutBillDetail>  outBillDetailQuery  = OutBillDetailRepository.GetQueryable();
            IQueryable <MoveBillMaster> moveBillMasterQuery = MoveBillMasterRepository.GetQueryable();
            IQueryable <MoveBillDetail> moveBillDetailQuery = MoveBillDetailRepository.GetQueryable();

            IQueryable <SortingLowerlimit> sortingLowerlimitQuery = SortingLowerlimitRepository.GetQueryable();
            IQueryable <SortingLine>       sortingLineQuery       = SortingLineRepository.GetQueryable();
            IQueryable <Storage>           storageQuery           = StorageRepository.GetQueryable();

            IQueryable <SortWorkDispatch> sortWorkDispatchQuery = SortWorkDispatchRepository.GetQueryable();

            IQueryable <THOK.Authority.DbModel.SystemParameter> systemParQuery = SystemParameterRepository.GetQueryable();


            var IsUselowerlimit = systemParQuery.FirstOrDefault(s => s.ParameterName == "IsUselowerlimit");//查询调度是否使用下限 0 否 1是

            workDispatchId = workDispatchId.Substring(0, workDispatchId.Length - 1);
            int[] work = workDispatchId.Split(',').Select(s => Convert.ToInt32(s)).ToArray();

            //调度表未作业的数据
            var temp = sortOrderDispatchQuery.Join(sortOrderQuery,
                                                   dp => new { dp.OrderDate, dp.DeliverLineCode },
                                                   om => new { om.OrderDate, om.DeliverLineCode },
                                                   (dp, om) => new { dp.ID, dp.WorkStatus, dp.OrderDate, dp.SortingLine, dp.DeliverLineCode, om.OrderID }
                                                   ).Join(sortOrderDetailQuery,
                                                          dm => new { dm.OrderID },
                                                          od => new { od.OrderID },
                                                          (dm, od) => new { dm.ID, dm.WorkStatus, dm.OrderDate, dm.SortingLine, od.Product, od.UnitCode, od.Price, od.RealQuantity }
                                                          ).WhereIn(s => s.ID, work)
                       .Where(s => s.WorkStatus == "1")
                       .GroupBy(r => new { r.OrderDate, r.SortingLine, r.Product, r.UnitCode, r.Price })
                       .Select(r => new { r.Key.OrderDate, r.Key.SortingLine, r.Key.Product, r.Key.UnitCode, r.Key.Price, SumQuantity = r.Sum(p => p.RealQuantity * r.Key.Product.UnitList.Unit02.Count) })
                       .AsParallel()
                       .GroupBy(r => new { r.OrderDate, r.SortingLine })
                       .Select(r => new { r.Key.OrderDate, r.Key.SortingLine, Products = r })
                       .ToArray();


            var    employee        = EmployeeRepository.GetQueryable().FirstOrDefault(i => i.UserName == userName);
            string operatePersonID = employee != null?employee.ID.ToString() : "";

            if (employee == null)
            {
                ps.State = StateType.Error;
                ps.Errors.Add("未找到当前用户,或当前用户不可用!");
                NotifyConnection(ps.Clone());
                return;
            }

            decimal sumAllotQuantity     = 0;
            decimal sumAllotLineQuantity = 0;

            MoveBillMaster lastMoveBillMaster = null;

            foreach (var item in temp)
            {
                try
                {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        return;
                    }

                    bool hasError = false;
                    ps.State = StateType.Info;
                    ps.Messages.Add("开始调度" + item.SortingLine.SortingLineName);
                    NotifyConnection(ps.Clone());

                    using (var scope = new TransactionScope())
                    {
                        if (item.Products.Count() > 0)
                        {
                            if (cancellationToken.IsCancellationRequested)
                            {
                                return;
                            }

                            if (lastMoveBillMaster != null && lastMoveBillMaster.WarehouseCode != item.SortingLine.Cell.WarehouseCode)
                            {
                                if (MoveBillCreater.CheckIsNeedSyncMoveBill(lastMoveBillMaster.WarehouseCode))
                                {
                                    MoveBillCreater.CreateSyncMoveBillDetail(lastMoveBillMaster);
                                }
                            }

                            sumAllotLineQuantity = 0;

                            if (cancellationToken.IsCancellationRequested)
                            {
                                return;
                            }
                            MoveBillMaster moveBillMaster = MoveBillCreater.CreateMoveBillMaster(item.SortingLine.Cell.WarehouseCode,
                                                                                                 item.SortingLine.MoveBillTypeCode,
                                                                                                 operatePersonID);
                            moveBillMaster.Origin      = "2";
                            moveBillMaster.Description = item.SortingLine.SortingLineCode + " 分拣调度生成!";
                            lastMoveBillMaster         = moveBillMaster;
                            foreach (var product in item.Products.ToArray())
                            {
                                if (product.SumQuantity > 0)
                                {
                                    if (cancellationToken.IsCancellationRequested)
                                    {
                                        return;
                                    }

                                    decimal sumBillQuantity = temp.Sum(t => t.Products.Sum(p => p.SumQuantity));
                                    sumAllotQuantity += product.SumQuantity;

                                    decimal sumBillProductQuantity = item.Products.Sum(p => p.SumQuantity);
                                    sumAllotLineQuantity += product.SumQuantity;

                                    ps.State                = StateType.Processing;
                                    ps.TotalProgressName    = "分拣作业调度";
                                    ps.TotalProgressValue   = (int)(sumAllotQuantity / sumBillQuantity * 100);
                                    ps.CurrentProgressName  = "正在调度:" + item.SortingLine.SortingLineName;
                                    ps.CurrentProgressValue = (int)(sumAllotLineQuantity / sumBillProductQuantity * 100);
                                    NotifyConnection(ps.Clone());

                                    if (cancellationToken.IsCancellationRequested)
                                    {
                                        return;
                                    }
                                    //获取分拣线下限数据
                                    var sortingLowerlimitQuantity = sortingLowerlimitQuery.Where(s => s.ProductCode == product.Product.ProductCode &&
                                                                                                 s.SortingLineCode == product.SortingLine.SortingLineCode);
                                    decimal lowerlimitQuantity = 0;
                                    if (sortingLowerlimitQuantity.Count() > 0)
                                    {
                                        lowerlimitQuantity = sortingLowerlimitQuantity.Sum(s => s.Quantity);
                                    }

                                    if (cancellationToken.IsCancellationRequested)
                                    {
                                        return;
                                    }
                                    //获取分拣备货区库存
                                    var storageQuantity = storageQuery.Where(s => s.ProductCode == product.Product.ProductCode)
                                                          .Join(sortingLineQuery,
                                                                s => s.Cell,
                                                                l => l.Cell,
                                                                (s, l) => new { l.SortingLineCode, s.Quantity }
                                                                )
                                                          .Where(r => r.SortingLineCode == product.SortingLine.SortingLineCode);
                                    decimal storQuantity = 0;
                                    if (storageQuantity.Count() > 0)
                                    {
                                        storQuantity = storageQuantity.Sum(s => s.Quantity);
                                    }
                                    //获取当前这个卷烟库存数量
                                    string[] areaTypes        = new string[] { "1", "2", "4" };
                                    var      areaSumQuantitys = storageQuery.Where(s => areaTypes.Any(t => t == s.Cell.Area.AreaType) &&
                                                                                   s.ProductCode == product.Product.ProductCode).ToArray();
                                    decimal areaQuantiy = 0;
                                    if (areaSumQuantitys.Count() > 0)
                                    {
                                        areaQuantiy = areaSumQuantitys.Sum(s => s.Quantity - s.OutFrozenQuantity);
                                    }

                                    //是否使用下限
                                    if (IsUselowerlimit != null && IsUselowerlimit.ParameterValue == "0")
                                    {
                                        lowerlimitQuantity = 0;
                                    }

                                    if (cancellationToken.IsCancellationRequested)
                                    {
                                        return;
                                    }

                                    //获取移库量(按整件计)出库量加上下限量减去备货区库存量取整
                                    decimal quantity = 0;

                                    quantity = Math.Ceiling((product.SumQuantity + lowerlimitQuantity - storQuantity) / product.Product.Unit.Count)
                                               * product.Product.Unit.Count;

                                    //取整托盘
                                    decimal wholeTray = 0;
                                    if (product.Product.IsRounding == "2")
                                    {
                                        wholeTray = Math.Ceiling(quantity / (product.Product.CellMaxProductQuantity * product.Product.Unit.Count));
                                        quantity  = Convert.ToDecimal(wholeTray * (product.Product.Unit.Count * product.Product.CellMaxProductQuantity));
                                    }

                                    if (areaQuantiy < quantity)//判断当前这个卷烟库存是否小于移库量
                                    {
                                        //出库量减去备货区库存量取整
                                        quantity = Math.Ceiling((product.SumQuantity - storQuantity) / product.Product.Unit.Count)
                                                   * product.Product.Unit.Count;

                                        if (areaQuantiy < quantity)
                                        {
                                            //出库量减去备货区库存量
                                            quantity = product.SumQuantity - storQuantity;
                                        }
                                    }

                                    //不取整的烟直接出库。
                                    if (product.Product.IsRounding == "1")
                                    {
                                        quantity = product.SumQuantity - storQuantity;
                                    }

                                    if (quantity > 0)
                                    {
                                        if (cancellationToken.IsCancellationRequested)
                                        {
                                            return;
                                        }
                                        AlltoMoveBill(moveBillMaster, product.Product, item.SortingLine.Cell, ref quantity, cancellationToken, ps, item.SortingLine.Cell.CellCode);
                                    }

                                    if (quantity > 0)
                                    {
                                        //生成移库不完整,可能是库存不足;
                                        hasError = true;
                                        ps.State = StateType.Error;
                                        ps.Errors.Add(item.SortingLine.SortingLineCode + "线," + product.Product.ProductCode + " " + product.Product.ProductName + ",库存不足!当前总量:" + Convert.ToDecimal(product.SumQuantity / product.Product.UnitList.Unit02.Count) + "(条),缺少:" + Convert.ToDecimal(quantity / product.Product.UnitList.Unit02.Count) + "(条)");
                                        NotifyConnection(ps.Clone());
                                    }
                                }
                            }

                            if (!hasError)
                            {
                                if (cancellationToken.IsCancellationRequested)
                                {
                                    return;
                                }

                                OutBillMaster outBillMaster = OutBillCreater.CreateOutBillMaster(item.SortingLine.Cell.WarehouseCode,
                                                                                                 item.SortingLine.OutBillTypeCode,
                                                                                                 operatePersonID);
                                outBillMaster.Origin      = "2";
                                outBillMaster.Description = item.SortingLine.SortingLineCode + " 分拣调度生成!";
                                //添加出库单细单
                                foreach (var product in item.Products.ToArray())
                                {
                                    if (cancellationToken.IsCancellationRequested)
                                    {
                                        return;
                                    }
                                    OutBillCreater.AddToOutBillDetail(outBillMaster, product.Product, product.Price, product.SumQuantity);
                                }

                                if (cancellationToken.IsCancellationRequested)
                                {
                                    return;
                                }
                                //添加出库、移库主单和作业调度表
                                SortWorkDispatch sortWorkDisp = AddSortWorkDispMaster(moveBillMaster, outBillMaster, item.SortingLine.SortingLineCode, item.OrderDate);

                                //修改线路调度作业状态和作业ID
                                var sortDispTemp = sortOrderDispatchQuery.WhereIn(s => s.ID, work)
                                                   .Where(s => s.OrderDate == item.OrderDate &&
                                                          s.SortingLineCode == item.SortingLine.SortingLineCode);

                                foreach (var sortDisp in sortDispTemp.ToArray())
                                {
                                    if (cancellationToken.IsCancellationRequested)
                                    {
                                        return;
                                    }
                                    sortDisp.SortWorkDispatchID = sortWorkDisp.ID;
                                    sortDisp.WorkStatus         = "2";
                                }
                                if (cancellationToken.IsCancellationRequested)
                                {
                                    return;
                                }
                                SortWorkDispatchRepository.SaveChanges();
                                scope.Complete();
                                ps.Messages.Add(item.SortingLine.SortingLineName + " 调度成功!");
                            }
                            else
                            {
                                ps.State = StateType.Info;
                                ps.Messages.Add(item.SortingLine.SortingLineName + " 调度失败!");
                                NotifyConnection(ps.Clone());
                                return;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    ps.State = StateType.Info;
                    ps.Errors.Add(item.SortingLine.SortingLineName + "作业调度失败! 详情:" + e.Message);
                    NotifyConnection(ps.Clone());
                    return;
                }
            }

            if (cancellationToken.IsCancellationRequested)
            {
                return;
            }

            if (MoveBillCreater.CheckIsNeedSyncMoveBill(lastMoveBillMaster.WarehouseCode))
            {
                MoveBillCreater.CreateSyncMoveBillDetail(lastMoveBillMaster);
            }
            MoveBillMasterRepository.SaveChanges();

            ps.State = StateType.Info;
            ps.Messages.Add("调度完成!");
            NotifyConnection(ps.Clone());
        }
Exemplo n.º 14
0
        /// <summary>获得移库细单信息</summary>
        public System.Data.DataTable GetMoveBillDetail(int page, int rows, string BillNo, bool isAbnormity, bool isGroup, out string sortingName)
        {
            System.Data.DataTable dt = new System.Data.DataTable();
            IQueryable <THOK.Authority.DbModel.SystemParameter> systemParQuery = SystemParameterRepository.GetQueryable();

            BillNo = BillNo.Substring(0, BillNo.Length - 1);
            string[] BillNos = BillNo.Split(',');
            sortingName = "合单";
            isGroup     = true;
            if (BillNos.Count() > 0)
            {
                IQueryable <MoveBillDetail> MoveBillDetailQuery = MoveBillDetailRepository.GetQueryable();
                if (BillNos.Count() == 1)
                {
                    string billnoStr = BillNos[0].ToString();
                    var    sortWork  = SortWorkDispatchRepository.GetQueryable().FirstOrDefault(i => i.MoveBillNo == billnoStr);
                    if (sortWork != null)
                    {
                        sortingName = sortWork.SortingLine.SortingLineName;
                    }
                    else
                    {
                        sortingName = "";
                    }
                }
                var IsSummary = systemParQuery.FirstOrDefault(s => s.ParameterName == "IsSummary");//打印是否合单汇总0:不汇总;1:汇总
                if (IsSummary != null && IsSummary.ParameterValue == "0")
                {
                    isGroup = false;
                }
                var moves = MoveBillDetailQuery.Where(i => BillNos.Any(b => b == i.BillNo));
                if (isAbnormity == false)
                {
                    moves = moves.Where(i => i.Product.IsAbnormity != "1");
                }
                if (isGroup)
                {
                    var moveBillDetail = moves.Where(s => s.OutCell.Area.AreaType != "5" && s.Product.IsAbnormity == "1" && s.InCell.Area.AreaType == "5")
                                         .GroupBy(m => new { m.ProductCode, m.Product.ProductName, m.Product })
                                         .Select(r => new { r.Key.ProductCode, r.Key.ProductName, r.Key.Product, RealQuantity = r.Sum(p => p.RealQuantity) }).AsEnumerable()
                                         .Select(r => new { r.Product, isAbnormity = r.Product.IsAbnormity == "1" ? "*" : " ", r.ProductCode, r.ProductName, RealQuantity = r.RealQuantity / r.Product.Unit.Count, strRealQuantity = r.RealQuantity / r.Product.UnitList.Unit02.Count })
                                         .OrderBy(r => r.RealQuantity).ThenBy(s => s.Product.BelongRegion);

                    var moveBillDetail1 = moves.Where(s => s.OutCell.Area.AreaType != "5" && s.Product.IsAbnormity != "1" && s.InCell.Area.AreaType == "5")
                                          .GroupBy(m => new { m.ProductCode, m.Product.ProductName, m.Product })
                                          .Select(r => new { r.Key.ProductCode, r.Key.ProductName, r.Key.Product, RealQuantity = r.Sum(p => p.RealQuantity) }).AsEnumerable()
                                          .Select(r => new { r.Product, isAbnormity = r.Product.IsAbnormity == "1" ? "*" : " ", r.ProductCode, r.ProductName, RealQuantity = r.RealQuantity / r.Product.Unit.Count, strRealQuantity = r.RealQuantity / r.Product.UnitList.Unit02.Count })
                                          .OrderBy(r => r.RealQuantity).ThenBy(s => s.Product.BelongRegion);

                    var moveBillDetail2 = moves.Where(s => s.OutCell.Area.AreaType == "5" && s.InCell.Area.AreaType == "5").AsEnumerable()
                                          .Select(r => new { OutCellName = r.OutCell.CellName, InCellName = r.InCell.CellName, r.Product, isAbnormity = r.Product.IsAbnormity == "1" ? "*" : " ", r.ProductCode, r.Product.ProductName, RealQuantity = r.RealQuantity / r.Product.Unit.Count, strRealQuantity = r.RealQuantity / r.Product.UnitList.Unit02.Count })
                                          .OrderBy(r => r.RealQuantity).ThenBy(s => s.Product.BelongRegion);

                    dt.Columns.Add("产品代码", typeof(string));
                    dt.Columns.Add("产品名称", typeof(string));
                    dt.Columns.Add("数量(件)", typeof(string));
                    dt.Columns.Add("数量(条)", typeof(string));
                    dt.Columns.Add("异形烟(*)", typeof(string));
                    dt.Columns.Add("分拣互移", typeof(string));
                    dt.Columns.Add("01线签字", typeof(string));
                    dt.Columns.Add("02线签字", typeof(string));
                    foreach (var m in moveBillDetail)//异形烟
                    {
                        dt.Rows.Add
                        (
                            m.ProductCode
                            , m.ProductName
                            , m.RealQuantity
                            , m.strRealQuantity
                            , m.isAbnormity
                        );
                    }

                    foreach (var m in moveBillDetail1)//不是整托的烟和整托的烟排序
                    {
                        dt.Rows.Add
                        (
                            m.ProductCode
                            , m.ProductName
                            , m.RealQuantity
                            , m.strRealQuantity
                            , m.isAbnormity
                        );
                    }

                    foreach (var m in moveBillDetail2)//分拣线互移的烟
                    {
                        dt.Rows.Add
                        (
                            m.ProductCode
                            , m.ProductName
                            , Convert.ToDecimal(m.RealQuantity)
                            , Convert.ToDecimal(m.strRealQuantity)
                            , m.isAbnormity
                            , m.OutCellName + "移入" + m.InCellName
                        );
                    }
                    if (moveBillDetail.Count() > 0 || moveBillDetail1.Count() > 0 || moveBillDetail2.Count() > 0)
                    {
                        dt.Rows.Add(null, "总数:", moveBillDetail.Sum(m => m.RealQuantity) + moveBillDetail1.Sum(s => s.RealQuantity) + moveBillDetail2.Sum(b => b.RealQuantity));
                        dt.Rows.Add("出库:", null, "验收:", null);
                    }
                }
                else
                {
                    var moveBillDetail = moves.AsEnumerable().Select(i => new
                    {
                        OutCellName       = i.OutCell.CellName,
                        OutStorageCode    = i.OutStorageCode,
                        InCellName        = i.InCell.CellName,
                        InStorageCode     = i.InStorageCode,
                        ProductCode       = i.ProductCode,
                        ProductName       = i.Product.ProductName,
                        UnitCode          = i.UnitCode,
                        UnitName          = i.Unit.UnitName,
                        RealQuantity      = i.RealQuantity / i.Unit.Count,
                        strRealQuantity   = i.RealQuantity / i.Product.UnitList.Unit02.Count,
                        OperatePersonName = i.OperatePerson == null ? string.Empty : i.OperatePerson.EmployeeName,
                        Status            = i.Status == "0" ? "未开始" : i.Status == "1" ? "已申请" : i.Status == "2" ? "已完成" : "空",
                        isAbnormity       = i.Product.IsAbnormity == "1" ? "*" : "",
                    }).OrderBy(i => i.OutCellName).ThenBy(i => i.ProductCode);

                    dt.Columns.Add("移出储位名称", typeof(string));
                    dt.Columns.Add("移入储位名称", typeof(string));
                    dt.Columns.Add("产品代码", typeof(string));
                    dt.Columns.Add("产品名称", typeof(string));
                    //dt.Columns.Add("单位编码", typeof(string));
                    //dt.Columns.Add("单位名称", typeof(string));
                    dt.Columns.Add("数量(件)", typeof(string));
                    dt.Columns.Add("数量(条)", typeof(string));
                    dt.Columns.Add("异形烟(*)", typeof(string));
                    foreach (var m in moveBillDetail)
                    {
                        dt.Rows.Add
                        (
                            m.OutCellName
                            , m.InCellName
                            , m.ProductCode
                            , m.ProductName
                            //, m.UnitCode
                            //, m.UnitName
                            , m.RealQuantity
                            , m.strRealQuantity
                            , m.isAbnormity
                        );
                    }
                    if (moveBillDetail.Count() > 0)
                    {
                        dt.Rows.Add(null, null, null, null, "总数:", moveBillDetail.Sum(m => m.RealQuantity));
                    }
                }
            }
            return(dt);
        }