Esempio n. 1
0
        public ActionResult ExcelBatchStrageCheck()
        {
            var _key = "sess_excel_inpor_instorage_11";
            var dat  = SessionAccess.Get(_key) as List <List <string> >;
            Dictionary <string, string> dic = new Dictionary <string, string>();

            if (dat != null && dat.Any())
            {
                foreach (var li in dat)
                {
                    var  te   = li[0];
                    Guid guid = Guid.NewGuid();
                    var  key  = guid.ToString();
                    dic.Add(key, te);
                }
            }
            BatchInputStorageCheck(dic, true);
            var scanValidKey   = "ScanValid";
            var scanInvalidKey = "ScanInvalid";
            List <Product_Model> validModels   = SessionAccess.Get(scanValidKey) as List <Product_Model>;
            List <Product_Model> inValidModels = SessionAccess.Get(scanInvalidKey) as List <Product_Model>;

            OperationResult resul = new OperationResult(OperationResultType.Success);

            resul.Other = new {
                validCoun   = validModels.Count,
                inValidCoun = inValidModels.Count
            };
            SessionAccess.Remove(_key);
            return(Json(resul));
        }
 private List <List <String> > ExcelToJson(string fileName)
 {
     if (System.IO.File.Exists(fileName))
     {
         var da = new List <List <String> >();
         if (Path.GetExtension(fileName) == ".txt")
         {
             string st    = System.IO.File.ReadAllText(fileName);
             var    retda = st.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
             var    li    = new List <List <string> >();
             retda.Each(c =>
             {
                 var t = new List <string>()
                 {
                     c
                 };
                 li.Add(t);
             });
             da = li;
         }
         else
         {
             YxkSabri.ExcelUtility excel = new YxkSabri.ExcelUtility();
             da = excel.ExcelToArray(fileName, 0, 0);
             var _key = "sess_excel_inpor_instorage_11";
             SessionAccess.Set(_key, da, true);
         }
         return(da);
     }
     return(null);
 }
Esempio n. 3
0
        /// <summary>
        /// 批量导入页面分页获取excel的数据
        /// </summary>
        /// <returns></returns>
        public ActionResult GetBatchImportExcelData()
        {
            GridRequest gr = new GridRequest(Request);

            var _key             = "sess_excel_inpor_instorage_11";
            var dat              = SessionAccess.Get(_key) as List <List <string> >;
            GridData <object> da = new GridData <object>(new List <object>(), 0, Request);

            if (dat != null)
            {
                var te = dat.Select(c => new {
                    Barcode = c[0],
                    RowInd  = Convert.ToInt32(c[1]),
                }).ToList();

                var li =
                    te.OrderBy(c => c.RowInd).Skip(gr.PageCondition.PageIndex).Take(gr.PageCondition.PageSize).Select(c => new {
                    ProductBarcode = c.Barcode,
                    c.RowInd
                }
                                                                                                                      ).ToList();
                da = new GridData <object>(li, dat.Count, Request);
            }
            return(Json(da));
        }
Esempio n. 4
0
        public static void Initialize()
        {
            sessionAccess  = new SessionAccess();
            settingsAccess = new SettingsAccess();

            var sessionResult  = sessionAccess.LoadSession();
            var settingsResult = settingsAccess.LoadSettings();

            if (sessionResult.Status != Status.Success)
            {
                sessionResult.Print();
            }

            if (settingsResult.Status != Status.Success)
            {
                settingsResult.Print();
            }

            Session  = sessionResult.Data;
            Settings = settingsResult.Data;


            Author        = "Near Huscarl";
            License       = "BSD 3-Clauses";
            SourceCodeURL = "https://github.com/NearHuscarl/Breakout";

            ScoreFont = new FontShape(width: 6, height: 18);
            MenuFont  = new FontShape(width: 9, height: 20);

            SpriteData = new SpriteData();

            Theme = new Dictionary <string, Color>()
            {
                { "Red", "#c0392b".ToColor() },
                { "Orange", "#d35400".ToColor() },
                { "Yellow", "#f39c12".ToColor() },
                { "Green", "#27ae60".ToColor() },
                { "Blue", "#2980b9".ToColor() },
                { "Cyan", "#16a085".ToColor() },
                { "Magenta", "#8e44ad".ToColor() },
                { "Gray", "#7f8c8d".ToColor() },
                { "Black", "#2c3e50".ToColor() },

                { "LightRed", "#e74c3c".ToColor() },
                { "LightOrange", "#e67e22".ToColor() },
                { "LightYellow", "#f1c40f".ToColor() },
                { "LightGreen", "#2ecc71".ToColor() },
                { "LightBlue", "#3498db".ToColor() },
                { "LightCyan", "#1abc9c".ToColor() },
                { "LightMagenta", "#9b59b6".ToColor() },
                { "LightGray", "#95a5a6".ToColor() },
                { "Dark", "#34495e".ToColor() },

                { "Silver", "#bdc3c7".ToColor() },
                { "White", "#ecf0f1".ToColor() },
            };

            ExplosiveRadius = 40;
        }
Esempio n. 5
0
        public void UnloadCurPage()
        {
            string _validSessionKey  = "1102_validsessionkey_09";
            string _invaliSessionKey = "1102_invalidsessionkey_03";

            SessionAccess.Remove(_validSessionKey);
            SessionAccess.Remove(_invaliSessionKey);
        }
Esempio n. 6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     SessionAccess.Control_Session_Values(SessionAccess.CRM_User_Email);
     Category_Title(Txt_Ttl);
     if (!IsPostBack)
     {
         NewsSql.GetRecords(DataGrid1, "SUBCATEGORY_PROC_ID", int.Parse(Request["Category_ID"]));
     }
 }
Esempio n. 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SessionAccess.Control_Session_Values(SessionAccess.CRM_User_Email);


        if (!IsPostBack)
        {
            NewsSql.GetRecords(DataGrid1, "PRODUCT_PROC_AREA", "BP");
            Clear();
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        SessionAccess.Control_Session_Values(SessionAccess.CRM_User_Email);


        if (!IsPostBack)
        {
            NewsSql.GetRecords(DataGrid1, "SUBPRODUCT_PROC_ID", int.Parse(Request["Product_ID"]));
            Clear();
        }
    }
Esempio n. 9
0
        public ActionResult GetValidDataList()
        {
            string _validSessionKey  = "1102_validsessionkey_09";
            string _invaliSessionKey = "1102_invalidsessionkey_03";
            var    validData         = SessionAccess.Get(_validSessionKey) as List <DiscountValidSession>;
            var    invalidData       = SessionAccess.Get(_invaliSessionKey) as List <DiscountValidSession>;

            return(Json(new {
                validDa = validData,
                invaliDa = invalidData
            }));
        }
Esempio n. 10
0
        /// <summary>
        /// 获取数据
        /// </summary>
        /// <returns></returns>
        public ActionResult VaildViewList(string uid)
        {
            GridRequest request            = new GridRequest(Request);
            int         count              = 0;
            int         pageIndex          = request.PageCondition.PageIndex;
            int         pageSize           = request.PageCondition.PageSize;
            var         validListFromCache = (List <Product_Model>)SessionAccess.Get(SESSION_KEY_VALID_LIST + uid) ?? new List <Product_Model>();

            count = validListFromCache.Count;
            var index   = 1;
            var resData = validListFromCache.Skip(pageIndex).Take(pageSize).Select(p => new { Id = index++, ProductBarcode = p.ProductBarcode }).ToList();
            var data    = new GridData <object>(resData, count, request.RequestInfo);

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Esempio n. 11
0
        public JsonResult BathcProductCreate(int?[] ids, ProductDiscountDto dto)
        {
            OperationResult resul = new OperationResult(OperationResultType.Error);

            #region 添加前校验

            if (!string.IsNullOrEmpty(dto.DiscountName))
            {
                bool exis = _productDiscountContract.ProductDiscounts.Any(
                    c => c.DiscountName == dto.DiscountName && !c.IsDeleted && c.IsEnabled);
                if (exis)
                {
                    resul.Message = "已存在同名的折扣方案";
                    return(Json(resul));
                }
            }
            #endregion
            string _validSessionKey  = "1102_validsessionkey_09";
            string _invaliSessionKey = "1102_invalidsessionkey_03";

            if (ids.Any(c => c != null))
            {
                if (dto.DiscountType == 1)
                {
                    dto.BigNumbers = string.Join(",", ids);
                }
                resul = _productDiscountContract.Insert(dto);
            }
            else
            {
                var discountvalids = SessionAccess.Get(_validSessionKey) as List <DiscountValidSession>;
                if (discountvalids != null)
                {
                    resul = _productDiscountContract.Insert(dto);
                }
                else
                {
                    resul = new OperationResult(OperationResultType.ValidError);
                }
            }
            if (resul.ResultType == OperationResultType.Success)
            {
                SessionAccess.Remove(_validSessionKey);
                SessionAccess.Remove(_invaliSessionKey);
            }
            return(Json(resul));
        }
Esempio n. 12
0
        public ActionResult RemoveInstoraggeByCach(string[] barcodes)
        {
            OperationResult resul = new OperationResult(OperationResultType.Error);

            var scanValidKey   = "ScanValid";
            var scanInvalidKey = "ScanInvalid";
            List <Product_Model> validModels   = SessionAccess.Get(scanValidKey) as List <Product_Model>;
            List <Product_Model> inValidModels = SessionAccess.Get(scanInvalidKey) as List <Product_Model>;

            if (validModels != null && validModels.Any())
            {
                var ts = validModels.Where(c => barcodes.Contains(c.ProductBarcode)).ToList();
                for (int i = 0; i < ts.Count(); i++)
                {
                    validModels.Remove(ts[i]);
                }

                SessionAccess.Set(scanValidKey, validModels, true);


                //从错误列表中也移除该货号
                if (inValidModels != null && inValidModels.Any())
                {
                    var list = inValidModels.Where(c => barcodes.Contains(c.ProductBarcode)).ToList();
                    for (int i = 0; i < list.Count(); i++)
                    {
                        inValidModels.Remove(list[i]);
                    }

                    SessionAccess.Set(scanInvalidKey, inValidModels, true);
                }

                resul = new OperationResult(OperationResultType.Success);

                resul.Other = new {
                    validCoun   = validModels.Count,
                    inValidCoun = inValidModels.Count
                };
            }



            return(Json(resul));
        }
Esempio n. 13
0
        public ActionResult GetInputStorageCheckData()
        {
            GridRequest gr  = new GridRequest(Request);
            var         exp = FilterHelper.GetExpression <Product_Model>(gr.FilterGroup);

            var scanValidKey = "ScanValid";
            List <Product_Model> validModels = SessionAccess.Get(scanValidKey) as List <Product_Model>;

            if (validModels == null)
            {
                validModels = new List <Product_Model>();
            }
            List <object> da = new List <object>();

            if (validModels.Any())
            {
                var codes = validModels.OrderBy(c => c.Id).Skip(gr.PageCondition.PageIndex).Take(gr.PageCondition.PageSize).Select(c => c.ProductBarcode);

                da = _productBarcodeDetailContract.productBarcodeDetails.Where(c => codes.Contains(c.ProductNumber + c.OnlyFlag)).Select(c => new {
                    c.Product.Id,
                    c.ProductNumber,
                    Barcode       = c.ProductNumber + c.OnlyFlag,
                    ThumbnailPath = c.Product.ThumbnailPath ?? c.Product.ProductOriginNumber.ThumbnailPath,
                    c.Product.ProductOriginNumber.Brand.BrandName,
                    c.Product.ProductOriginNumber.Category.CategoryName,
                    c.Product.Size.SizeName
                }).ToList().Select(c => new {
                    c.Id,
                    Pind = (validModels.FirstOrDefault(g => g.ProductBarcode == c.Barcode)) == null ? 0 : validModels.FirstOrDefault(g => g.ProductBarcode == c.Barcode).Id,
                    c.ProductNumber,
                    c.Barcode,
                    c.ThumbnailPath,
                    c.BrandName,
                    c.CategoryName,
                    c.SizeName,
                }).OrderBy(c => c.Pind).ToList <object>();
            }
            GridData <object> resda = new GridData <object>(da, validModels.Count, Request);

            return(Json(resda));
        }
Esempio n. 14
0
        /// <summary>
        /// 入库校验
        /// </summary>
        /// <param name="uuid"></param>
        /// <param name="number"></param>
        /// <returns></returns>
        public ActionResult InputStorageCheck(string uuid, string number)
        {
            Dictionary <string, string> dicpre = new Dictionary <string, string>();

            dicpre.Add(uuid, number);
            BatchInputStorageCheck(dicpre);

            var scanValidKey   = "ScanValid";
            var scanInvalidKey = "ScanInvalid";
            List <Product_Model> validModels   = SessionAccess.Get(scanValidKey) as List <Product_Model>;
            List <Product_Model> inValidModels = SessionAccess.Get(scanInvalidKey) as List <Product_Model>;

            OperationResult resul = new OperationResult(OperationResultType.Success);

            resul.Other = new {
                uuid,
                validCoun   = validModels.Count,
                inValidCoun = inValidModels.Count
            };
            return(Json(resul));
        }
Esempio n. 15
0
        public ActionResult AddToScan(string uuid, string number, bool isbigNumb)
        {
            OperationResult     resul             = new OperationResult(OperationResultType.Success);
            string              _validSessionKey  = "1102_validsessionkey_09";
            string              _invaliSessionKey = "1102_invalidsessionkey_03";
            Product             product           = null;
            ProductOriginNumber orignum           = null;

            List <DiscountValidSession> discouvalidssion =
                (SessionAccess.Get(_validSessionKey) as List <DiscountValidSession>) ?? new List <DiscountValidSession>();

            List <DiscountValidSession> discouInvalidSession =
                (SessionAccess.Get(_invaliSessionKey) as List <DiscountValidSession>) ?? new List <DiscountValidSession>();

            if (discouvalidssion.Any() && discouvalidssion.FirstOrDefault(c => c.Uuid == uuid) != null)
            {
                discouvalidssion.FirstOrDefault(c => c.Uuid == uuid).Count += 1;
            }
            else
            {
                if (discouInvalidSession.Any() && discouInvalidSession.FirstOrDefault(c => c.Uuid == uuid) != null)
                {
                    discouInvalidSession.FirstOrDefault(c => c.Uuid == uuid).Count += 1;
                }
                else
                {
                    DiscountValidSession dis = new DiscountValidSession()
                    {
                        Uuid   = uuid,
                        Number = number,
                        Count  = 1
                    };
                    if (isbigNumb)
                    {//传入的是大款号
                        orignum  = ProductOrigNumberValid(number);
                        dis.Type = 1;
                        if (orignum != null)
                        {
                            dis.Id     = orignum.Id;
                            dis.Number = orignum.BigProdNum;
                            discouvalidssion.Add(dis);
                        }
                        else
                        {
                            discouInvalidSession.Add(dis);
                            resul.ResultType = OperationResultType.Error;
                            resul.Message    = "商品货号不存在";
                        }
                    }
                    else
                    {//传入的是商品货号
                        product  = ProductValid(number);
                        dis.Type = 0;
                        if (product != null)
                        {
                            dis.Id     = product.Id;
                            dis.Number = product.ProductNumber;
                            discouvalidssion.Add(dis);
                        }
                        else
                        {
                            discouInvalidSession.Add(dis);
                            resul.ResultType = OperationResultType.Error;
                            resul.Message    = "商品货号不存在";
                        }
                    }
                }
            }
            try
            {
                SessionAccess.Set(_validSessionKey, discouvalidssion, true);
                SessionAccess.Set(_invaliSessionKey, discouInvalidSession, true);
            }
            catch (Exception)
            {
                throw;
            }
            resul.Data = new {
                uuid       = uuid,
                validCou   = discouvalidssion.GroupBy(c => c.Number).Count(),
                invalidCou = discouInvalidSession.GroupBy(c => c.Number).Count()
            };
            if (isbigNumb)
            {
                orignum = orignum ?? ProductOrigNumberValid(number);
                if (orignum == null)
                {
                    resul.ResultType = OperationResultType.Error;
                    resul.Message    = "商品款号不存在";
                }
                else
                {
                    Product prod = _productContract.Products.FirstOrDefault(c => c.OriginNumber == orignum.OriginNumber);
                    resul.Other = new {
                        Id            = orignum.Id,
                        ProductNumber = orignum.BigProdNum,
                        Brand         = prod.ProductOriginNumber.Brand.BrandName,
                        Category      = prod.ProductOriginNumber.Category.CategoryName,
                        Size          = "",
                        Thumbnail     = prod.ThumbnailPath,
                    };
                }
            }
            else
            {
                product = product ?? ProductValid(number);
                if (product != null)
                {
                    resul.Other = new {
                        Id            = product.Id,
                        ProductNumber = product.ProductNumber,
                        Brand         = product.ProductOriginNumber.Brand.BrandName,
                        Category      = product.ProductOriginNumber.Category.CategoryName,
                        Size          = product.Size.SizeName,
                        Thumbnail     = product.ThumbnailPath,
                    }
                }
                ;
                else
                {
                    resul.ResultType = OperationResultType.Error;
                    resul.Message    = "商品编号不存在";
                }
            }
            return(Json(resul));
        }
Esempio n. 16
0
 protected void Page_Load(object sender, EventArgs e)
 {
     SessionAccess.Control_Session_Values(SessionAccess.CRM_User_Email);
 }
Esempio n. 17
0
        /// <summary>
        /// 批量导入校验
        /// </summary>
        public ActionResult MultitudeVaild(string nums, string uid)
        {
            var dat = nums.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            int storeCollocationId   = _storeProductCollocationContract.StoreProductCollocations.Where(o => o.Guid == uid).Select(x => x.Id).FirstOrDefault();
            var result               = new OperationResult(OperationResultType.Error, "");
            var validListFromCache   = (List <Product_Model>)SessionAccess.Get(SESSION_KEY_VALID_LIST + uid) ?? new List <Product_Model>();
            var invalidlistFromCache = (List <Product_Model>)SessionAccess.Get(SESSION_KEY_INVALID_LIST + uid) ?? new List <Product_Model>();
            var storeCollocation     = _storeProductCollocationContract.StoreProductCollocations.Where(o => !o.IsDeleted && o.IsEnabled)
                                       .Where(o => o.Id == storeCollocationId)
                                       .Include(o => o.StoreCollocationInfoItems)
                                       .FirstOrDefault();


            string strMessage = string.Empty;

            var modelList = dat.Select(barcode => new Product_Model {
                ProductBarcode = barcode, UUID = Guid.NewGuid().ToString()
            }).ToList();


            var checkRes = CheckCollcationEntity(storeCollocation);

            if (!checkRes.Item1)
            {
                invalidlistFromCache.Add(new Product_Model {
                    ProductBarcode = string.Empty
                });
            }
            else //批量校验
            {
                var tmpValidModels = new List <Product_Model>();
                //var allValid = true;
                var orderblankItemsFromDb = storeCollocation.StoreCollocationInfoItems.ToList();
                foreach (var modelToCheck in modelList)
                {
                    var res = CheckBarcode(modelToCheck, validListFromCache, invalidlistFromCache, orderblankItemsFromDb, storeCollocationId);
                    if (!res.Item1)
                    {
                        //allValid = false;
                        modelToCheck.Notes = res.Item2;
                        invalidlistFromCache.Add(modelToCheck);
                    }
                    else
                    {
                        tmpValidModels.Add(modelToCheck);
                        validListFromCache.Add(modelToCheck);
                    }
                }
                if (tmpValidModels.Count > 0)
                {
                    var optRes = BatchAddCollocationItem(storeCollocation, orderblankItemsFromDb, tmpValidModels.ToArray());
                    if (optRes.ResultType != OperationResultType.Success)
                    {
                        invalidlistFromCache.Add(new Product_Model {
                            ProductBarcode = string.Empty, Notes = optRes.Message
                        });
                    }
                }
            }

            SessionAccess.Set(SESSION_KEY_VALID_LIST + uid, validListFromCache);
            SessionAccess.Set(SESSION_KEY_INVALID_LIST + uid, invalidlistFromCache);
            result.Data       = new { validCount = validListFromCache.Count, invalidCount = invalidlistFromCache.Count };
            result.ResultType = OperationResultType.Success;
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 18
0
 public ActionResult Logout()
 {
     SessionAccess.ClearSession();
     return(RedirectToAction("Index", "Home", new { message = "Wylogowano pomyślnie!" }));
 }
Esempio n. 19
0
        //da= [{ProduId:22,StorCou:120,StoreId:12,StorageId:2},{ProduId:22,StorCou:120,StoreId:12,StorageId:2}]
        //yxk
        public JsonResult AddInventory(string[] prCodes, int storageId, string notes, string recordOrderNumber, DateTime?CreatedTime)
        {
            if (!CreatedTime.HasValue)
            {
                CreatedTime = DateTime.Now;
            }
            OperationResult  optresul = new OperationResult(OperationResultType.Error, "入库失败");
            List <Inventory> inves    = new List <Inventory>();

            if (prCodes == null)
            {
                prCodes = new string[0];
            }
            string key = "ScanValid";
            var    productsModeList = Session[key] as List <Product_Model>;
            int    err = 0;

            if (productsModeList == null || productsModeList.Count == 0)
            {
                optresul.Message = "在服务器中未查到相关的入库操作,可能是操作超时";
            }
            else
            {
                var instorageCode = prCodes.Any() ? productsModeList.Where(c => prCodes.Contains(c.ProductBarcode)).Select(c => c.ProductBarcode).ToList()
                                                  : productsModeList.Select(c => c.ProductBarcode).Distinct().ToList();
                //检查是否有已经入库的条码
                if (_inventoryContract.Inventorys.Any(i => instorageCode.Contains(i.ProductBarcode)))
                {
                    return(Json(OperationResult.Error("检测到有已经入过库的流水号")));
                }
                int adminid = (int)AuthorityHelper.OperatorId;

                var storage = CacheAccess.GetManagedStorage(_storageContract, _administratorContract).FirstOrDefault(f => f.Id == storageId);

                if (storage.IsNull())
                {
                    optresul.Message = "当前用户无权限操作该仓库,ID:" + storageId;
                }
                else
                {
                    var barcodesFromDb = _productBarcodeDetailContract.productBarcodeDetails
                                         .Where(c => instorageCode.Contains(c.ProductNumber + c.OnlyFlag))
                                         .ToList();
                    var distinceBarcodes = new List <ProductBarcodeDetail>();
                    foreach (var code in barcodesFromDb)
                    {
                        if (distinceBarcodes.Any(i => i.ProductNumber == code.ProductNumber && i.OnlyFlag == code.OnlyFlag))
                        {
                            continue;
                        }
                        else
                        {
                            distinceBarcodes.Add(code);
                        }
                    }
                    var productNumbersFromBarcode = distinceBarcodes.Select(c => c.ProductNumber).ToList();
                    var products = _productContract.Products.Where(c => productNumbersFromBarcode.Contains(c.ProductNumber))
                                   .Select(c => new
                    {
                        c.ProductNumber,
                        c.Id,
                        c.ProductOriginNumber.TagPrice,
                        c.ProductOriginNumber.WholesalePrice,
                        c.ProductOriginNumber.PurchasePrice
                    })
                                   .ToList();
                    var           productNumbersFromProduct = products.Select(c => c.ProductNumber).ToList();
                    var           errproduct = distinceBarcodes.Where(c => !productNumbersFromProduct.Contains(c.ProductNumber));
                    List <string> errbarcode = new List <string>();
                    if (errproduct.Any())
                    {
                        //与该商品相关的商品档案不存在
                        //写日志 待完善

                        errbarcode = errproduct.Select(c => c.ProductNumber + c.OnlyFlag).ToList();
                        //inves = new List<Inventory>(); //清空需要入库的数据
                        var errst = "";
                        if (errbarcode.Count > 4)
                        {
                            errst = string.Join(",", errbarcode.Take(4).ToArray());
                        }
                        else
                        {
                            errst = string.Join(",", errbarcode);
                        }
                        _logContract.Insert(new LogDto()
                        {
                            Description = string.Join(",", errbarcode) + "未查找到商品档案",
                        });
                        optresul.Message = "部分商品未查找到商品档案:" + errst + "……,详情请查看日志";
                    }
                    else
                    {
                        inves = distinceBarcodes.Select(c => new Inventory()
                        {
                            ProductNumber  = c.ProductNumber,
                            OnlyFlag       = c.OnlyFlag,
                            ProductLogFlag = Guid.NewGuid().ToString().Replace("-", ""),
                            ProductBarcode = c.ProductNumber + c.OnlyFlag,
                            StoreId        = storage.StoreId,
                            StorageId      = storageId,
                            ProductId      = products.FirstOrDefault(g => g.ProductNumber == c.ProductNumber).Id,
                            Description    = notes,
                        }).ToList();
                    }
                    if (inves.Any())
                    {
                        // 计算本次入库总吊牌价
                        float totalTagPrice = 0;
                        foreach (var inventory in inves)
                        {
                            totalTagPrice += products.First(p => p.Id == inventory.ProductId).TagPrice;
                        }
                        // 根据生成的库存信息,插入入库记录
                        var record = new InventoryRecord()
                        {
                            Quantity          = inves.Count,
                            OperatorId        = adminid,
                            StorageId         = storageId,
                            StoreId           = storage.StoreId,
                            TagPrice          = totalTagPrice,
                            RecordOrderNumber = recordOrderNumber,
                            CreatedTime       = CreatedTime.Value
                        };

                        using (var tran = _inventoryContract.GetTransaction())
                        {
                            var res = _inventoryRecordContract.Insert(record);
                            if (res.ResultType != OperationResultType.Success)
                            {
                                tran.Rollback();
                                return(Json(OperationResult.Error("库存记录插入失败")));
                            }

                            // 将库存信息与入库记录进行关联
                            inves.Each(i => i.InventoryRecordId = record.Id);
                            // 保存库存信息
                            optresul = _inventoryContract.BulkInsert(inves);
                            if (optresul.ResultType != OperationResultType.Success)
                            {
                                tran.Rollback();
                                return(Json(OperationResult.Error("保存库存信息失败")));
                            }
                            List <ProductTrack> listpt = new List <ProductTrack>();
                            foreach (var item in inves)
                            {
                                #region 商品追踪
                                ProductTrack pt = new ProductTrack();
                                pt.ProductNumber  = item.ProductNumber;
                                pt.ProductBarcode = item.ProductNumber + item.OnlyFlag;
                                pt.Describe       = String.Format(ProductOptDescTemplate.ON_PRODUCT_INVENTORY, storage.StorageName);

                                listpt.Add(pt);
                                #endregion
                            }
                            var resPT = _productTrackContract.BulkInsert(listpt);
                            if (resPT.ResultType != OperationResultType.Success)
                            {
                                tran.Rollback();
                                return(Json(OperationResult.Error("商品追踪插入失败")));
                            }
                            List <string> proCodes = inves.Select(c => c.ProductBarcode).ToList();
                            var           details  = _productBarcodeDetailContract.productBarcodeDetails.Where(c => proCodes.Contains(c.ProductNumber + c.OnlyFlag));
                            details.Each(c => c.Status = 1);

                            var resPBD = _productBarcodeDetailContract.BulkUpdate(details);
                            if (resPBD.ResultType != OperationResultType.Success)
                            {
                                tran.Rollback();
                                return(Json(OperationResult.Error("商品条码信息更新失败")));
                            }
                            productsModeList.RemoveAll(c => proCodes.Contains(c.ProductBarcode));
                            SessionAccess.Set(key, productsModeList);

                            tran.Commit();
                        }
                    }
                }
            }
            return(Json(optresul, JsonRequestBehavior.AllowGet));
        }
Esempio n. 20
0
        public ActionResult ExceptionDataExportToExcel()
        {
            OperationResult result         = new OperationResult(OperationResultType.Error);
            var             scanValidKey   = "ScanValid";
            var             scanInvalidKey = "ScanInvalid";

            List <Product_Model> validModels   = SessionAccess.Get(scanValidKey) as List <Product_Model>;
            List <Product_Model> inValidModels = SessionAccess.Get(scanInvalidKey) as List <Product_Model>;

            List <List <string> > validDa   = new List <List <string> >();
            List <List <string> > inValidDa = new List <List <string> >();

            if (validModels != null && validModels.Any())
            {
                foreach (var valda in validModels)
                {
                    validDa.Add(new List <string>()
                    {
                        valda.Id.ToString(), valda.ProductBarcode
                    });
                }
            }
            if (inValidModels != null && inValidModels.Any())
            {
                foreach (var valda in inValidModels)
                {
                    inValidDa.Add(new List <string>()
                    {
                        valda.Id.ToString(), valda.ProductBarcode, valda.Notes
                    });
                }
            }
            List <List <List <string> > > li = new List <List <List <string> > >();

            li.Add(validDa);
            li.Add(inValidDa);

            YxkSabri.ExcelUtility excel = new ExcelUtility();
            var    name    = DateTime.Now.ToString("yyyyMMddHHff") + ".xls";
            string basedir = Server.MapPath(@"\Content\UploadFiles\Excels\ExportDa\");

            if (Directory.Exists(basedir))
            {
                Directory.Delete(basedir, true);
            }
            Directory.CreateDirectory(basedir);


            string path = basedir + name;
            var    rsul = excel.ExportMulitExcelSheet(li, path, new string[] { "有效", "无效" });

            if (rsul)
            {
                result = new OperationResult(OperationResultType.Success);
            }

            return(File(path, "application/ms-excel", "导出数据.xls"));


            //// string path = "D:/test/销售月报表.xlsx";
            // FileStream fs = new FileStream(path, FileMode.Open);
            // byte[] buffer = new byte[fs.Length];
            // fs.Read(buffer, 0, buffer.Length);

            // fs.Close();
            //System.IO.File.Delete(path);

            // Response.ContentType = "application/ms-excel";
            // Response.Charset = "GB2312";
            // Response.ContentEncoding = System.Text.Encoding.UTF8;

            // Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode("销售月报表.xlsx"));
            // Response.OutputStream.Write(buffer, 0, buffer.Length);
            // Response.Flush();
            // Response.End();


            //  return Json(result);
        }
Esempio n. 21
0
        /// <summary>
        /// 入库数据批量校验
        /// </summary>
        /// <param name="pre"></param>
        private void BatchInputStorageCheck(Dictionary <string, string> pre, bool isclear = false)
        {
            var           scanValidKey   = "ScanValid";
            var           scanInvalidKey = "ScanInvalid";
            List <string> errli          = new List <string>();

            List <Product_Model> validModels   = new List <Product_Model>();
            List <Product_Model> inValidModels = new List <Product_Model>();

            if (!isclear)
            {
                validModels   = SessionAccess.Get(scanValidKey) as List <Product_Model>;
                inValidModels = SessionAccess.Get(scanInvalidKey) as List <Product_Model>;
                if (validModels == null)
                {
                    validModels = new List <Product_Model>();
                }
                if (inValidModels == null)
                {
                    inValidModels = new List <Product_Model>();
                }
            }

            List <string> numbs  = pre.Select(c => c.Value).ToList();
            List <string> valied = new List <string>();

            //是否与已校验通过的结果重复
            var exisVali = validModels.Where(c => numbs.Contains(c.ProductBarcode)).ToList();
            //是否与校验不通过的结果重复
            var exisInvali = inValidModels.Where(c => numbs.Contains(c.ProductBarcode)).ToList();
            int cuind      = inValidModels.Count + validModels.Count + 1;

            if (exisVali.Any())
            {
                valied.AddRange(exisVali.Select(c => c.ProductBarcode));
                for (int i = 0; i < exisVali.Count(); i++)
                {
                    var ite = exisVali[0];
                    var t   = CacheAccess.Clone <Product_Model>(ite);
                    t.Id    = cuind;
                    t.Notes = "已进入缓存队列";
                    inValidModels.Add(t);
                }
                var exiscodes = exisVali.Select(c => c.ProductBarcode).ToList();
                numbs.RemoveAll(c => exiscodes.Contains(c));
            }
            else if (exisInvali.Any())
            {
                valied.AddRange(exisInvali.Select(c => c.ProductBarcode));
                for (int i = 0; i < exisInvali.Count(); i++)
                {
                    var ite = exisInvali[i];
                    var t   = CacheAccess.Clone <Product_Model>(ite);
                    t.Id     = cuind;
                    t.Notes += ",且已经重复";
                    inValidModels.Add(t);
                }

                var exiscodes = exisVali.Select(c => c.ProductBarcode).ToList();
                numbs.RemoveAll(c => exiscodes.Contains(c));
            }

            var plbarcode = numbs.Where(c => !valied.Contains(c)).ToList();//没有经过校验的条码

            if (plbarcode.Any())
            {
                //商品的打印记录
                var vadali = _productBarcodeDetailContract.productBarcodeDetails.Where(c => plbarcode.Contains(c.ProductNumber + c.OnlyFlag));
                //根据条码得到编号
                var pnums = numbs.Where(c => c.Length == 14).Select(c => c.Substring(0, 11)).ToList();
                //存在商品檔案的库存
                var exisnum = _productContract.Products.Where(c => pnums.Contains(c.ProductNumber))
                              .Select(c => c.ProductNumber)
                              .ToList();
                //入库校验
                foreach (var inda in plbarcode)
                {
                    //序列号
                    var ind = inValidModels.Count + validModels.Count + 1;
                    if (validModels.Any(c => c.ProductBarcode == inda))
                    {
                        var exc = validModels.FirstOrDefault(c => c.ProductBarcode == inda);
                        if (exc != null)
                        {
                            var t = CacheAccess.Clone <Product_Model>(exc);
                            t.Id    = ind;
                            t.Notes = "已进入缓存队列";
                            inValidModels.Add(t);
                        }
                    }
                    else if (inValidModels.Any(c => c.ProductBarcode == inda))
                    {
                        var exc = inValidModels.FirstOrDefault(c => c.ProductBarcode == inda);
                        if (exc != null)
                        {
                            var te = CacheAccess.Clone <Product_Model>(exc);
                            te.Id     = ind;
                            te.Notes += ",且已经重复";
                            inValidModels.Add(te);
                        }
                        var exiscodes = exisVali.Select(c => c.ProductBarcode).ToList();
                        numbs.RemoveAll(c => exiscodes.Contains(c));
                    }
                    else
                    {
                        //带校验对象
                        var di = pre.FirstOrDefault(c => c.Value == inda);
                        if (inda.Length == 14)
                        {
                            var prnum = inda.Substring(0, 11);
                            //打印记录
                            var barcode = vadali.FirstOrDefault(c => c.ProductNumber + c.OnlyFlag == inda);
                            //商品档案
                            var detai = exisnum.FirstOrDefault(c => c == prnum);

                            if (detai != null)
                            {
                                if (barcode != null)
                                {
                                    if (barcode.IsDeleted)
                                    {
                                        inValidModels.Add(new Product_Model
                                        {
                                            Id             = ind,
                                            UUID           = di.Key,
                                            ProductBarcode = di.Value,
                                            Notes          = "商品档案存在,且有打印记录,但已经被移除到回收站"
                                        });
                                    }
                                    else
                                    {
                                        if (barcode.Status == 0)
                                        {
                                            validModels.Add(new Product_Model
                                            {
                                                Id             = ind,
                                                UUID           = di.Key,
                                                ProductBarcode = di.Value,
                                                Notes          = "商品档案存在,且有打印记录,可以入库"
                                            });
                                        }
                                        else
                                        {
                                            string err = barcode.Status == 1 ? "已入库" : "已删除或禁用";
                                            inValidModels.Add(new Product_Model
                                            {
                                                Id             = ind,
                                                UUID           = di.Key,
                                                ProductBarcode = di.Value,
                                                Notes          = err
                                            });
                                        }
                                    }
                                }
                                else
                                {
                                    inValidModels.Add(new Product_Model
                                    {
                                        Id             = ind,
                                        UUID           = di.Key,
                                        ProductBarcode = di.Value,
                                        Notes          = "商品档案存在,但是没有打印记录"
                                    });
                                }
                            }
                            else
                            {
                                inValidModels.Add(new Product_Model
                                {
                                    Id             = ind,
                                    UUID           = di.Key,
                                    ProductBarcode = di.Value,
                                    Notes          = "商品档案不存在"
                                });
                            }
                        }
                        else
                        {
                            inValidModels.Add(new Product_Model
                            {
                                Id             = ind,
                                UUID           = di.Key,
                                ProductBarcode = di.Value,
                                Notes          = "录入的条码不符合14位数"
                            });
                        }
                    }
                }
            }

            SessionAccess.Set(scanValidKey, validModels, true);
            SessionAccess.Set(scanInvalidKey, inValidModels, true);
        }