public ViewResult NCInventory(PlanSearchCondition condition, string errorMsg = "", bool isloadCondition = false)
        {
            if (isloadCondition)
            {
                condition = TempData["nc_inventory_condition"] as PlanSearchCondition;
            }

            if (string.IsNullOrEmpty(errorMsg) == false)
            {
                ViewBag.ErrorMsg = errorMsg;
            }

            // 委外仓库
            ViewBag.ListCK = bll_Product.GetWWCK();

            // 委外转库线材
            var list = new List <NCInventoryDto>();

            list.AddRange(bll_Product.GetNCInventory(condition?.LineWhCode, condition?.Gz, condition?.Zxbz, condition?.Gg, condition?.SearchBatchNo));

            ViewBag.InventoryData = list.OrderBy(w => w.BatchNo).ThenBy(w => w.StlGrd).ThenBy(w => w.Spec).ToList();

            // 用于在Action中传递查询条件
            TempData["nc_inventory_condition"] = condition;

            return(View(condition));
        }
        public ViewResult Plan(PlanSearchCondition condition)
        {
            //string user = Request.Headers.cur
            var list = bll.GetWWOrdList(
                condition?.Gz, condition?.Zxbz, condition?.Gg,
                condition?.Kh, condition?.Wl, condition?.Ht, condition?.LineWhCode,
                condition?.BeginTime, condition?.EndTime);

            //var vUser = (NF.Framework.CurrentUser)HttpContext.Current.Session["CurrentUser"];
            ViewBag.PlanData = list;

            // 委外仓库
            ViewBag.ListCK = bll_Product.GetWWCK();

            return(View(condition));
        }
        public ViewResult InventoryManager(PlanSearchCondition condition, string errorMsg = "", bool isloadCondition = false)
        {
            if (isloadCondition)
            {
                condition = TempData["inventory_condition"] as PlanSearchCondition;
            }

            if (string.IsNullOrEmpty(errorMsg) == false)
            {
                ViewBag.ErrorMsg = errorMsg;
            }

            // 委外仓库
            ViewBag.ListCK = bll_Product.GetWWCK();

            // 委外转库线材
            var list = new List <NF.MODEL.Mod_TRC_ROLL_PRODCUT>();

            list.AddRange(bll_Product.GetByWWCK(condition?.LineWhCode, condition?.Gz, condition?.Zxbz, condition?.Gg, condition?.SearchBatchNo));

            var listzkd = new List <NF.MODEL.ZKDInfoDto>();
            var user    = System.Web.HttpContext.Current.Session["CurrentUser"] as CurrentUser;

            listzkd.AddRange(bll_Product.GetWWZKD(user?.Id, condition?.SearchBatchNo));
            ViewBag.ZKDData = listzkd;

            var ncList = bll_Product.GetNCInventory(condition?.LineWhCode, condition?.Gz, condition?.Zxbz, condition?.Gg, condition?.SearchBatchNo);

            ViewBag.InventoryData = list.GroupBy(w => new
            {
                w.C_BATCH_NO,
                w.C_STL_GRD,
                w.C_STD_CODE,
                w.C_SPEC,
                w.C_MAT_CODE,
                w.C_MAT_DESC,
                w.C_LINEWH_CODE,
                w.C_BZYQ,
                w.C_JUDGE_LEV_ZH,
                w.C_SALE_AREA
            }).Select(w =>
            {
                Expression <Func <NCInventoryDto, bool> > expre = x =>
                                                                  x.StdCode == w.Key.C_STD_CODE &
                                                                  x.StlGrd == w.Key.C_STL_GRD &
                                                                  x.MtrlCode == w.Key.C_MAT_CODE &
                                                                  x.ZLDJ == w.Key.C_JUDGE_LEV_ZH;

                if (string.IsNullOrEmpty(w.Key.C_BZYQ))
                {
                    expre = expre.And(x => string.IsNullOrEmpty(x.BZYQ) == string.IsNullOrEmpty(w.Key.C_BZYQ));
                }
                else
                {
                    expre = expre.And(x => x.BZYQ == w.Key.C_BZYQ);
                }

                var expre1 = expre.And(l => l.BatchNo == w.Key.C_BATCH_NO);

                var ncItem = ncList.FirstOrDefault(expre1.Compile());

                if (ncItem == null)
                {
                    var expre2 = expre.And(l => l.BatchNo.Contains(w.Key.C_BATCH_NO));
                    ncItem     = ncList.FirstOrDefault(expre2.Compile());
                }

                var item = new ProductGrpInfo
                {
                    BatchNo       = w.Key.C_BATCH_NO,
                    Spec          = w.Key.C_SPEC,
                    StdCode       = w.Key.C_STD_CODE,
                    StlGrd        = w.Key.C_STL_GRD,
                    Count         = w.Count(),
                    Wgt           = w.Sum(x => x.N_WGT),
                    MtrlCode      = w.Key.C_MAT_CODE,
                    MtrlName      = w.Key.C_MAT_DESC,
                    InventoryCode = w.Key.C_LINEWH_CODE,
                    BZYQ          = w.Key.C_BZYQ,
                    ZLDJ          = w.Key.C_JUDGE_LEV_ZH,
                    SalesArea     = w.Key.C_SALE_AREA,
                    NCCount       = ncItem?.Count ?? 0,
                    NCWgt         = ncItem?.Wgt ?? 0,
                    NCBatchNO     = ncItem?.BatchNo
                };

                ncList.Remove(ncItem);

                return(item);
            }).OrderBy(w => w.BatchNo).ThenBy(w => w.StlGrd).ThenBy(w => w.Spec).ToList();

            // 用于在Action中传递查询条件
            TempData["inventory_condition"] = condition;

            return(View(condition));
        }